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
// thanks to http://stackoverflow.com/questions/610406/javascript-printf-string-format/3492815#3492815 | |
// very similar to string.format: | |
// "{0} is dead, but {1} is alive!".format("ASP", "ASP.NET") | |
String.prototype.format = function() { | |
var formatted = this; | |
var args = Array.prototype.slice.call(arguments); | |
for(var i=0; args.length > i ;i++) { | |
formatted = formatted.replace("{" + i + "}", args[i]); | |
} |
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
/* Set the color : only for Linux | |
* | |
* with bash | |
* foreground \33[38;5;${code}m | |
* background \33[48;5;${code}m | |
* | |
* with c | |
* fg: \e[38;5;codem | |
* bg: \e[45;5;codem | |
* |
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 | |
echo `env LC_CTYPE=C tr -dc "a-zA-Z0-9′\!”.$%&/()=?|@#[]{}-_.:,;’" < /dev/urandom | head -c 20` |
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 | |
# js-quickstart.sh: creates a js project with maven and Jasmine | |
usage(){ | |
echo "Usage: $0 com.company.id folder" | |
echo "Example: $0 com.example.quickstart quickstart" | |
exit 1 | |
} | |
# invokes usage if com.company.id and folder not supplied |
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
[paths] | |
default = https://username@bitbucket.org/owner_username/repo | |
diff = --unified 8 | |
[alias] | |
# http://hgtip.com/tips/advanced/2010-01-15-styling-mercurials-cli/ | |
# repo https://bitbucket.org/sjl/mercurial-cli-templates/src | |
slog = log --style=/Path/to/mercurial-cli-templates/map-cmdline.slog | |
sglog = log --style=/Path/to/mercurial-cli-templates/map-cmdline.sglog |
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
SELECT name FROM sqlite_master WHERE type='table' AND name='table_name'; |
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
def find_duplicate(seq): | |
# holds our duplicate list | |
duplicate_bucket = [] | |
# helps to identify a duplicate | |
seen_bucket = set() | |
for item in (seq): | |
if item not in seen_bucket: | |
seen_bucket.add(item) | |
else: | |
duplicate_bucket.append(item) |
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
rsync -arvz --include-from=/Users/kev/filelist.txt -e ssh user@host:/ /dest/ --log-file=/var/log/rsync.cron.log | |
filelist.txt | |
+ / | |
+ /etc/ | |
+ /etc/apache2 | |
+ /etc/apache2/** | |
- * |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
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
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
func main() { | |
dataChan := make(chan string) |