This file contains 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 add1 = (v) => v + 1; | |
const mul2 = (v) => v * 2; | |
const div3 = (v) => v / 3; | |
const compose = (fn1, fn2) => (...args) => fn1(fn2(...args)); | |
const mapper = [div3, mul2, add1].reduce(compose); | |
const result = [2, 5, 8, 11, 14, 17, 20].map(mapper); | |
console.log(result); |
This file contains 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 wrapper<T, P extends any[]>(fetcher: (...args: P) => Promise<T>) { | |
let lastID = 0; | |
return (...args: P) => (function (id: number): Promise<T> { | |
return fetcher(...args).then((data: T) => ( | |
lastID === id ? data as any : Promise.reject(null) | |
)); | |
})(++lastID); | |
} |
This file contains 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
// return random number between 1 & 58 | |
const random = () => (Math.round(Math.random() * 100) % 58) + 1; |
This file contains 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 getAnagrams(arr) { | |
const map = {}; | |
const result = []; | |
arr.forEach(word => { | |
const key = word.split('').sort().join(''); | |
if (key in map) { | |
result[map[key]].push(word); | |
} else { |
This file contains 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 sum(val) { | |
var total = val; | |
function func(next) { | |
if (!next) return total; | |
total += next; | |
return func; | |
} |
This file contains 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
window['onSelectionChange'] = function() { | |
// Do something... | |
}; | |
window.external.RegisterEventListener( | |
'SelectionChange', | |
"window['onSelectionChange']()" | |
); |
This file contains 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
<div id="root"> | |
<div id="1"> | |
<div id="2"> | |
<div id="5"> | |
<div id="7"></div> | |
</div> | |
</div> | |
<div id="3"></div> | |
<div id="4"> | |
<div id="6"></div> |
This file contains 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
#!/bin/bash | |
find ~/Documents/Work/ -name '*.tmp' -type f -delete | |
echo "*.tmp files are deleted" | |
find ~/Documents/Work/ -name 'Backup_of_*.cdr' -type f -delete | |
echo "BackUp files are deleted" |
This file contains 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
#!/bin/bash | |
sudo rm -rf /Library/Java/* | |
sudo rm -rf /Library/PreferencePanes/Java* | |
sudo rm -rf /Library/Internet\ Plug-Ins/Java* | |
sudo rm -rf /Library/LaunchAgents/com.oracle.java.Java-Updater.plist | |
sudo rm -rf /Library/PrivilegedHelperTools/com.oracle.java.JavaUpdateHelper | |
sudo rm -rf /Library/LaunchDaemons/com.oracle.java.JavaUpdateHelper.plist | |
sudo rm -rf /Library/Preferences/com.oracle.java.Helper-Tool.plist |
This file contains 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
// http://www.stratege.ru/playstation/users/<user_name> | |
(function(year){ | |
const log = []; | |
let platforms = {}; | |
let progress = 0; | |
let difficulty = 0; | |
const games = [].slice.call(document.querySelectorAll('.pupfug_table tr')) |