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
<?php | |
$pattern = '/(?>\.no-touch\s+)?((?>[^,{;}\s][^,{;}]*?:hover)(?>[^,{;}]+)?)(?=[{,])/i'; | |
$replacement = ".no-touch $1"; | |
$subject = <<<CSS | |
a | |
{ |
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
/** | |
* Adapted from <http://neilk.net/blog/2000/06/01/abigails-regex-to-test-for-prime-numbers/>. | |
*/ | |
function isPrime(n) { | |
return !/^#?$|^(##+?)\1+$/.test(Array(n+1).join('#')); | |
} | |
(function (n){return !/^#?$|^(##+?)\1+$/.test(Array(n+1).join('#'))})(1); // false | |
(function (n){return !/^#?$|^(##+?)\1+$/.test(Array(n+1).join('#'))})(2); // true | |
(function (n){return !/^#?$|^(##+?)\1+$/.test(Array(n+1).join('#'))})(7); // true |
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/sh | |
# Flushes the DNS cache on Mac OS X | |
# | |
# From https://www.madboa.com/blog/2014/10/24/mac-dns-cache/ | |
# | |
# Only tested on Yosemite. | |
MAC_OS_X_VERSION=$(sw_vers -productVersion | awk -F '.' '{print $1 "." $2}') |
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/sh | |
# | |
# Author: Matthieu Prat <[email protected]> | |
# Date: 01/22/2015 | |
# | |
# Sync a local work tree with a remote one. | |
# It's rsync on steroids within large Git repositories. | |
USAGE='<repository>' | |
LONG_USAGE='Sync a local work tree with a remote one.' |
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
data:text/html,<script>var t = 3605</script><body style="display: flex; align-items: center; justify-content: center; font-family: sans-serif; font-size: 40vh;"><div></div><script>var e = document.getElementsByTagName('div')[0]; var tid = setInterval(() => {e.innerText = [~~(t/3600), ~~(t/60) % 60, t % 60].reduce((a, t) => ((a.length || t) && a.push(t), a), []).map(t => ('0' + t).slice(-2)).join(':') || '00'; --t < 0 && clearInterval(tid)}, 1000)</script></body> |
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
Array.apply(null, Array(parseInt(process.argv[1]) || 40)) | |
.map(Math.random) | |
.map(function (n) {return n*62}) | |
.map(Math.floor) | |
.map(String.prototype.charAt.bind('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')) | |
.join('') |
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
$ cd $(mktemp -d) && echo -n 1:2 | xargs -d: -n1 -P2 php --no-php-ini -r 'mkdir(str_repeat("dir/", 100) . $argv[1], 0777, true) or exit(1);' && echo OK | |
Warning: mkdir(): File exists in Command line code on line 1 | |
$ cd $(mktemp -d) && echo -n 1:2 | xargs -d: -n1 -P2 php --no-php-ini -r 'system(sprintf("mkdir -p %s", str_repeat("dir/", 100) . $argv[1]), $r); exit($r);' && echo OK | |
OK | |
$ cd $(mktemp -d) && echo -n 1:2 | xargs -d: -n1 -P2 python -c 'import os, sys; os.makedirs('dir/' * 100 + sys.argv[1]);' && echo 'OK' | |
OK |
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/sh | |
until openssl rand -base64 40 | grep -v '+\|/'; do :; done |
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 | |
while read -r f | |
do | |
if $(git diff-files --quiet -- ":(literal)$f") | |
then | |
# Check the file in the worktree since there are no unstaged changes. | |
flake8 "$f" || err=1 | |
else | |
# Pipe staged changes to flake8 and replace 'stdin:<error>' with |
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
/** | |
* Returns a promise that is fulfilled with an array of promise state | |
* snapshots, but only after all the original promises have settled, i.e. | |
* become either fulfilled or rejected. | |
* | |
* See https://github.com/kriskowal/q/wiki/API-Reference#promiseallsettled | |
*/ | |
allSettled = (promises) => { | |
let resolve, outer = new Promise((r) => { resolve = r }) | |
let snapshots = [], settledCount = 0 |
OlderNewer