Skip to content

Instantly share code, notes, and snippets.

View juliobetta's full-sized avatar
🎧

Julio Betta juliobetta

🎧
View GitHub Profile
# https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
# https://www.digitalocean.com/community/questions/how-to-change-swap-size-on-ubuntu-14-04
fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
swapon -s
sysctl vm.swappiness=10
sysctl vm.vfs_cache_pressure=50
@juliobetta
juliobetta / commands.sh
Last active February 28, 2017 16:06
Useful command line... commands
###########################################################################################################################
### MISC ##################################################################################################################
###########################################################################################################################
# Replace string in multiple files
grep --include=filename -rl 'string_to_be_replaced' /directory | xargs sed -i 's/string_to_be_replaced/new_string/g'
# Remove git sensitive data
git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch filename' --prune-empty --tag-name-filter cat -- --all
@juliobetta
juliobetta / style.css
Created September 16, 2017 03:46
Hide scrollbar, keeping the original behavior
.container {
-ms-overflow-style: none; /* IE 10+ */
overflow: -moz-scrollbars-none; /* Firefox */
}
.container::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}
@juliobetta
juliobetta / gist:d066c15c6be7d44d5257192021ae14fb
Created September 26, 2017 17:31
Git alias to order tags by version (git 2.3.3+)
git config --global alias.tags "tag --sort version:refname"
@juliobetta
juliobetta / reduce-01.js
Last active September 30, 2017 13:41
Reduce example
const list = [1, 2, 3, 4, 5];
const result = list.reduce((accumulator, item) => {
return accumulator + item;
}, 0);
console.log(result); // 15
const list = [
{
id: "772b70fa-57be-40fc-976a-1123320df94e",
name: "Jupiter"
},
{
id: "cced1a50-19b7-4971-aacc-a732eb5ec64c",
name: "Saturn"
},
{
characters.filter(character => character.debut < 1990).length > 0;
// true;
const withSome = characters.some(character => character.debut < 1990);
const withReduce = characters.reduce((accumulator, character) => {
if(character.debut < 1990) {
return true;
}
return accumulator;
}, false);
// true
const hasDebutAfter1980 = character => character.debut > 1980;
const withEvery = characters.every(hasDebutAfter1980);
const withReduce = characters.reduce((accumulator, character) => {
if(hasDebutAfter1980(character)) {
return true;
}
return accumulator && hasDebutAfter1980(character);
const result = (
characters
.filter(character => character.debut >= 1990)
.map(character => character.name)
);
// [
// "Captain Falcon",
// "Fox",
// "Kirby"