Tuesday, 27 August 2019

Post 70: Remove blue background on form input fields in Chrome

Chrome adds a default blue background color in your form input fields, e.g. text fields or password input fields.

In order to remove it apply this styling

<style>  input:-webkit-autofill,  input:-webkit-autofill:hover,  input:-webkit-autofill:focus textarea:-webkit-autofill,  textarea:-webkit-autofill:hover textarea:-webkit-autofill:focus,  select:-webkit-autofill,  select:-webkit-autofill:hover,  select:-webkit-autofill:focus {
    transition: background-color 5500s ease-in-out 0s;  }
</style>

Monday, 10 December 2018

Post 69: Git (merge|diff) tools and aliases

# based on http://blogs.pdmlab.com/alexander.zeitler/articles/installing-and-configuring-p4merge-for-git-on-ubuntu/



$ cd ~/Downloads

$ wget https://cdist2.perforce.com/perforce/r18.2/bin.linux26x86_64/p4v.tgz

$ tar zxvf p4v.tgz

$ sudo mkdir /opt/p4v

$ cd p4v-2018.2.1666551 # or the current version

$ sudo mv * /opt/p4v

$ sudo ln -s /opt/p4v/bin/p4merge /usr/local/bin/p4merge

vim ~/.gitconfig

[color]

ui = true

diff = true

branch = auto

status = auto

[alias]

new = checkout -b

co = checkout

ci = commit

cm = commit -m

cam = commit -am

ca = commit --amend # careful

st = status

br = branch

lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen--> %cr%Creset by %Cblue%cN <%cE>%Creset' --abbre

v-commit --date=relative

hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short

type = cat-file -t

dump = cat-file -p

s = status --short

a = !git add . && git status

au = !git add -u . && git statustus

aa = !git add . && git add -u . && git status

ac = !git add . && git commit

acm = !git add . && git commit -m

put = push origin HEAD

get = pull origin HEAD

[merge]

keepBackup = false;

tool = p4merge

[mergetool]

prompt = false

[mergetool "p4merge"]

cmd = p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"

keepTemporaries = false

trustExitCode = false

keepBackup = false

[diff]

tool = p4merge

[difftool]

prompt = false

[difftool "p4merge"]

cmd = p4merge "$LOCAL" "$REMOTE"

keepTemporaries = false

trustExitCode = false

keepBackup = false

Tuesday, 20 November 2018

Post 68: Webassembly example

Lately I wanted to dive into Web Assembly. The examples I found on the internet wouldn't work or information was missing. I would spend a couple of hours to figure it out. In order to save yourself time, I created this post.

I was inpsired by this post (but the project wouldn't run for me): https://medium.freecodecamp.org/get-started-with-webassembly-using-only-14-lines-of-javascript-b37b6aaca1e4#--respond

The file structure will look like this:
wasmDemo
|_index.html
|_scripts.js
|_server.js
|_squarer.wasm

So, everything is in one directory with now subfolder.

First go to the following page in order to write a C++ program:
https://mbebenita.github.io/WasmExplorer/

Let's write a squarer program:

int squarer(int i) {
  return i * i;
}

Paste that into the site above. Then compile it and download the `.wasm` file. Move that file into our folder "wasmDemo".

Next create a html file:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>WASM Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>WASM Demo</h1>
<script src="./scripts.js"></script>
</body>
</html>

Then create a js file:
let squarer;

function loadWebAssembly(fileName) {
return fetch(fileName)
.then(response => response.arrayBuffer())
.then(buffer => WebAssembly.compile(buffer))
.then(module => {
return new WebAssembly.Instance(module);
});
}
loadWebAssembly('./squarer.wasm').then(instance => {
squarer = instance.exports._Z7squareri;
console.log('Finished compiling! Ready when you are...');
});

Since we have to run it on the server, let's create a server.js file for our node server:
var http = require('http');
var fs = require('fs');
var path = require('path');

const PORT = 8080;

http
.createServer(function(request, response) {
var filePath = '.' + request.url;
if (filePath == './') {
filePath = './index.html';
}

var extname = String(path.extname(filePath)).toLowerCase();
var mimeTypes = {
'.html': 'text/html',
'.js': 'text/javascript',
'.css': 'text/css',
'.wasm': 'application/wasm'
};

var contentType = mimeTypes[extname] || 'application/octet-stream';

fs.readFile(filePath, function(error, content) {
if (error) {
response.writeHead(404);
response.end('404 Not Found');
} else {
response.writeHead(200, { 'Content-Type': contentType });
response.end(content, 'utf-8');
}
});
})
.listen(PORT);

If everything is correct, then start the application with `node server.js`

Now you can access the squarer function, that we wrote in C++ also in the js file or in the console.

Wednesday, 24 October 2018

Post 67: Set background image in ubuntu 18.04

Type in your terminal:
sudo gedit /usr/share/gnome-shell/theme/ubuntu.css
Then search for "lockDialogGroup". Replace the CSS query with the following:
#lockDialogGroup {
background: #2c001e url(file:///[fileLocation/filename.png]);
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}

Saturday, 1 April 2017

Post 66: How to SASS

How to use SASS?

SASS stands for "Syntactically Awesome Stylesheets Sass". It is a CSS preprocessor and offers you stuff you can't do normally with CSS, e.g. mixins, loops, inheritence.
  1. Create a new folder and "npm init"
  2. "npm install node-sass"
  3. Create a new folder "css" on the same level as "package.json"
  4. Go to your package.json and write in the scripts key "start": "node-sass -o css scss"
  5. Create a new folder "scss" and create a new file scss "main.scss" in it
  6. In the main.scss file write:
.red { color: red; }
.red-dark { color: darken(red, 20%);}

    7. Go to your terminal and write "npm start"
    8. A new file "main.css" was created in the folder "css" for you.

Sunday, 9 October 2016

Post 65: How to load a local file on ionic

I'm using ionic 1.x and I'm assuming the json file lies in the www-folder.

.controller('DashCtrl', function ($scope, $http) {
  $http({method: 'GET', url: 'quotes.json'})
    .success(function(data){
      console.log("success! ", data);
    })
    .error(function(){
      console.log("error!");
    })
    .finally(function(){
      console.log("finally!");
    });
    

Sunday, 18 September 2016

Post 64: New Blog (Mathematics for Computer Science)

After a long time of coding I think I'm ready to level up. I want to get a firm grasp of algorithm and datastructure. For that I want to dive into Mathematics for Computer Science, which basicailly is discrete maths. I intend to take the 6.042j course of MIT's OCW.

I'll intend to concentrate on that courses, listen to the lectures, read the course material, and solve the assignments and exams offered there. I will therefore not be that often here but at my new blog:
 
http://6-042j.blogspot.de/

But I won't forget this blog. I'll come back soon I complete my goal. See you around. :)
Tweet