Skip to content

Instantly share code, notes, and snippets.

View juliobetta's full-sized avatar
🎧

Julio Betta juliobetta

🎧
View GitHub Profile
const withSome = characters.some(character => character.debut < 1990);
const withReduce = characters.reduce((accumulator, character) => {
if(character.debut < 1990) {
return true;
}
return accumulator;
}, false);
// true
characters.filter(character => character.debut < 1990).length > 0;
// true;
const mapped = characters.map(character => character.name);
const reduced = characters.reduce((accumulator, character) => [...accumulator, character.name], []);
// [
// "Donkey Kong",
// "Captain Falcon",
// "Fox",
// "Kirby",
// "Link"
const filtered = characters.filter(character => character.debut < 1990);
const reduced = characters.reduce((accumulator, character) => {
if(character.debut < 1990) {
return [...accumulator, character];
}
return accumulator;
}, []);
const list = [
{
id: "772b70fa-57be-40fc-976a-1123320df94e",
name: "Jupiter"
},
{
id: "cced1a50-19b7-4971-aacc-a732eb5ec64c",
name: "Saturn"
},
{
@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
@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 / 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 / couchdb.service
Last active July 3, 2018 20:48
Install CouchDB 2.0 Ubuntu 16.04
# /etc/systemd/system/couchdb.service
[Unit]
Description=Couchdb service
After=network.target
[Service]
Type=simple
User=couchdb
ExecStart=/opt/couchdb/bin/couchdb -o /dev/stdout -e /dev/stderr
# 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