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
#!/bin/bash | |
# Removes old revisions of snaps | |
# CLOSE ALL SNAPS BEFORE RUNNING THIS | |
set -eu | |
LANG=C snap list --all | awk '/disabled/{print $1, $3}' | | |
while read snapname revision; do | |
snap remove "$snapname" --revision="$revision" | |
done |
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
/** | |
* Can return promise from express middleware | |
* router.get('/pets', expressPromise(req => { | |
return db.getAll().then(... do some stuff...); // <it's a Promise! | |
})); | |
*/ | |
export function expressPromise(worker: (req: Request) => any) { | |
return (req: Request, res: Response, next: NextFunction) => { | |
// wrap with "Promise.resolve()", so if an exception is thrown in "worker" it will be handled with 'catch' | |
Promise.resolve() |
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/local/bin/subl | |
open -b com.sublimetext.3 "$@" |
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
# | |
hasChanges=$(git diff-index --name-only HEAD --) | |
if [ -n "$hasChanges" ]; then | |
echo -e "*** Git repository is not clean!" | |
gitSha="$gitSha-DIRTY" | |
fi |
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
/** | |
* | |
*/ | |
export function getAge(now: Date, birthday: Date): number { | |
// trick to ignore year | |
const backToFuture = new Date(now.getTime()); | |
backToFuture.setFullYear(birthday.getFullYear()); | |
// 'now' and 'dateNoYear' has the same year, so it wouldn't affect the result | |
// check month to avoid leap year issue |
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
// ==UserScript== | |
// @name Enable global media keys in vk.com | |
// @namespace http://github.com/MaxXx1313 | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://vk.com/* | |
// @grant none | |
// ==/UserScript== |
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
window.fetchFile = function(fileName) { | |
function getFileEntry(fullFileName) { | |
return new Promise((resolve, reject) => { | |
window.resolveLocalFileSystemURL(fullFileName, resolve, reject); | |
}); | |
} |
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
// | |
// inspired by https://stackoverflow.com/a/838755/521197 | |
// | |
function getDPI() { | |
var div = document.createElement( "div"); | |
div.style.height = "1in"; | |
div.style.width = "1in"; | |
div.style.top = "-100%"; | |
div.style.left = "-100%"; | |
div.style.position = "absolute"; |
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
module.exports.filenameReservedRegex = () => (/[<>:"\/\\|?*\x00-\x1F]/g); | |
module.exports.windowsNames = () => (/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/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
#!/bin/bash | |
xrandr -s 0 |
NewerOlder