This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// remove duplicates | |
['such', 'wow',' amaze', 'wow', 'very', 'very'].filter(function (elem, index, src) { | |
return src.indexOf(elem, index+1) < 0; | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getShowHash (element) { | |
return Array.prototype.map.call(element.querySelectorAll('table.data tr'), function (row) { | |
var key = row.querySelector('.sortkey'); | |
var city = row.querySelector('a[href*="City"]'); | |
if (!key || !city) { return; } | |
key = key.textContent; | |
city = city.href.match(/\d+$/).pop(); | |
return { city: city, key: key }; | |
}) | |
.filter(function (i) { return i; }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getAchievements (dom) { | |
return Array.prototype.map.call(dom.querySelectorAll('table.data div.Achievement'), function (a) { | |
return a.classList.value.match(/Achievement_(\d+)/).shift(); | |
}); | |
} | |
function removeOverlapping (ach1, ach2) { | |
var table = document.querySelector('table.data'); | |
ach1.forEach(function (a) { | |
if (ach2.indexOf(a) < 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fib = (function fib () { | |
var prev = [ 0, 0 ]; | |
return () => { | |
let value = prev.shift() + Math.max(prev.find(i => i > -1), 1); | |
prev.push(value); | |
return value; | |
}; | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Touchpad | |
# This option enables the bottom right corner to be a right button on clickpads | |
# and the right and middle top areas to be right / middle buttons on clickpads | |
# with a top button area. | |
# This option is only interpreted by clickpads. | |
Section "InputClass" | |
Identifier "Ignore clickpad buttons" | |
MatchDriver "synaptics" | |
Option "SoftButtonAreas" "0 0 0 0 0 0 0 0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators | |
function createBinaryString (nMask) { | |
// nMask must be between -2147483648 and 2147483647 | |
for (var nFlag = 0, nShifted = nMask, sMask = ''; nFlag < 32; | |
nFlag++, sMask += String(nShifted >>> 31), nShifted <<= 1); | |
return sMask; | |
} | |
[-2, -1, 0, 1, 2].forEach(number => { | |
console.log(number + ' \t\t\t\t\t==>\t ' + ~number + ' \n' + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ROMAN_MAP = { | |
'I': 1, | |
'V': 5, | |
'X': 10, | |
'L': 50, | |
'C': 100, | |
'D': 500, | |
'M': 1000 | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# This is sp, the command-line Spotify controller. It talks to a running | |
# instance of the Spotify Linux client over dbus, providing an interface not | |
# unlike mpc. | |
# | |
# Put differently, it allows you to control Spotify without leaving the comfort | |
# of your command line, and without a custom client or Premium subscription. | |
# |