Skip to content

Instantly share code, notes, and snippets.

View nobitagit's full-sized avatar
🕸️
The less I know the better

Aurelio nobitagit

🕸️
The less I know the better
View GitHub Profile
@nobitagit
nobitagit / iterm2.md
Last active July 30, 2024 01:01
iterm2 cheatsheet

This gist has been moved to its own Github repo, so it's easier to contribute with additions and corrections. Please open a PR there if you see any mistake, I don't track comments on here as there's no notification system for gists AFAIK. Thanks.

Tabs and Windows

Function Shortcut
Previous Tab + Left Arrow
Next Tab + Right Arrow
Go to Tab + Number
@nobitagit
nobitagit / scales.js
Created September 4, 2016 16:05
find scales
let values = [{
nation: 'USA',
value: 150
}, {
nation: 'EU',
value: 75
}, {
nation: 'China',
value: 53
}];
@nobitagit
nobitagit / timeago.js
Created August 25, 2016 11:45 — forked from IbeVanmeenen/timeago.js
TimeAgo - ES6
// Epochs
const epochs = [
['year', 31536000],
['month', 2592000],
['day', 86400],
['hour', 3600],
['minute', 60],
['second', 1]
];
var items = document.querySelectorAll('.fsl.fwb.fcb');
var names = Array.prototype.slice.call(items).map(function(item){
return item.textContent;
}).sort(function(a,b){
if (a < b) {
return -1;
} else {
return 1;
}
@nobitagit
nobitagit / SPD.2b.enumeration.js
Created August 4, 2016 09:57
Systematic program design in Js - How to design data - Enumeration
/**
* Role is one of:
* - "superAdmin"
* - "admin"
* - "user"
*
* Interp. the role of a registered user
**/
// <examples are redundant for enumerations>
mysql.server start
mysql -u root -p
-> Enter password: password
# if a connection problem arises try this solution http://stackoverflow.com/a/25650062/1446845 but rather than editing the phpini file symlink the .sock files
# as explained here https://www.dokimay.com/index.php/tech-tips/10-mac-osx/8-installing-phpmyadmin-on-localhost-mac-osx-10-8 and here http://stackoverflow.com/a/9384672/1446845
SHOW DATABASES; #list dbs
show tables from my_db; #list tables for specified db

clean code

use meaningful variable names

int d; // bad
// better alternatives:
int elapsedTimeInDays;
int daysSinceCreation;
int daysSinceModification;
/**
* Lessons learned implementing a simple adder.
* Array functions do not have the arguments object
**/
var add = function() {
var args = Array.prototype.slice.call(arguments)
return args.reduce((all, item) => {
return all + item;
}, 0);
@nobitagit
nobitagit / .vimrc
Created June 19, 2016 11:33
My vimrc
" A minimal vimrc for new vim users to start with.
" Referenced here: http://vimuniversity.com/samples/your-first-vimrc-should-be-nearly-empty
" If you don't understand a setting in here, just type ':h setting'.
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" Make backspace behave in a sane manner.
set backspace=indent,eol,start
@nobitagit
nobitagit / vim_shortcuts.sh
Last active July 18, 2016 07:20
Vim shorcuts
# Move to end of line and enter EDIT mode
A
# Move to beginning of line and enter EDIT mode
I
# Move to end of file
G
# combine commands to get to end of last line and enter EDIT mode
GA
# Move to beginning of file
1G or gg