Skip to content

Instantly share code, notes, and snippets.

@xaptronic
xaptronic / file_input_example.css
Created December 9, 2011 18:41 — forked from nathansmith/file_input_example.css
Markup to Hide a File Input
.fake_file_input {
background: url(../images/fake_file_input.png) no-repeat;
cursor: pointer;
width: 150px;
height: 30px;
overflow: hidden;
position: relative;
display: inline-block;
*display: inline;
*zoom: 1;
@xaptronic
xaptronic / git_export_latest
Created November 10, 2011 14:52
Get names of files changed in the latest commit
die () {
echo >&2 "$@"
exit 1
}
HOW_FAR=1
[ "$#" -eq 0 ] || HOW_FAR=$1
echo $HOW_FAR | grep -E -q '^[0-9]+$' || die "need to pass a number if you gonna pass"
git log -n$HOW_FAR --oneline | cut -f1 -d' ' | xargs -I% git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT % | sort | uniq
@xaptronic
xaptronic / routing.yml
Created November 7, 2011 14:24
Potential for sfDoctrineRouteCollection to pass method_for_query to sfDoctrineRoutes
listings:
class: sfDoctrineRouteCollection
options:
model: Listing
with_wildcard_routes: true
method_for_query:
list: oldestToNewest
object: customObjectMethod
other_action: myCustomMethod
@xaptronic
xaptronic / find_empty_dirs_and_do
Created November 7, 2011 13:57
Find empty directories and do something with them.
function do_if_dir_empty {
[ "$(ls -A $1/)" ] || eval "$2"
}
find . -type d -not \( -wholename "*/.git*" -or -wholename "*/.svn*" \) -print | while read F; do do_if_dir_empty $F "$1"; done
# Usage: find_empty_dirs_and_do 'echo $1 is an empty dir'
# Ex: find_empty_dirs_and_do 'cp /path/to/gitignore $1/.gitignore' # now this directory will be tracked by git
@xaptronic
xaptronic / fs_sync
Created October 28, 2011 00:13
File System Sync will copy changes to files to a remote machine.
remote=$1
default_remote=$remote
rsync_extra=$2
if [ -z "$remote" ]; then
echo "Usage: fs_sync <sync_to>"
echo "Syncs changes made to the current directory tree to <sync_to>"
echo "E.g.; alex@hactar ~/dev/trunk $ fs_sync tpweb:code/trunk"
echo "Files in the current directory tree (~/dev/trunk) will be automatically pushed to tpweb:code/trunk whenever a change is made."
echo "Additionally you may define environment variables in the form git_sync_[branchname]=tpweb:code/other to push particular branches to specific remote locations and rely on the passed in remote as the default location."
@xaptronic
xaptronic / gist:1270830
Created October 7, 2011 17:19
Calling setMaxListeners on the sub object.
--- a/lib/stores/redis.js
+++ b/lib/stores/redis.js
@@ -75,6 +75,7 @@ function Redis (opts) {
} else {
opts.redisSub || (opts.redisSub = {});
this.sub = redis.createClient(opts.redisSub.port, opts.redisSub.host, opts.redisSub);
+ this.sub.setMaxListeners(0);
}
if (opts.redisClient instanceof RedisClient) {
this.cmd = opts.redisClient;
@xaptronic
xaptronic / gist:1270453
Created October 7, 2011 14:59
Hacked my way around not being able to have obj.default() as a method call.. probably would need to add more scope around this however
--- lexer.l.orig 2011-10-07 14:48:04.000000000 +0000
+++ lexer.l 2011-10-07 14:53:36.000000000 +0000
@@ -23,7 +23,7 @@
<INITIAL>"finally" return 'FINALLY';
<INITIAL>"case" return 'CASE';
<INITIAL>"switch" return 'SWITCH';
-<INITIAL>"default" return 'DEFAULT';
+<INITIAL>[^\.]"default" { return 'DEFAULT'; }
<INITIAL>"this" return 'THIS';
<INITIAL>"with" return 'WITH';
@xaptronic
xaptronic / gist:1270412
Created October 7, 2011 14:42
Error message when using .default method of the optimist library.
/usr/local/lib/node_modules/tamejs/lib/parser.js:276
throw new Error(str);
^
Error: Parse error on line 9:
...), args = optimist.default('port', 8082
----------------------^
Expecting 'QUOTE1', 'QUOTE2', 'LABEL', 'LPAREN', 'RPAREN', 'LBRACKET', 'RBRACKET', 'LBRACE', 'RBRACE', 'GENERIC', 'COMMA', 'DOT', 'COLON', 'ID', 'DECIMAL', 'THIS', 'DEFER', 'SEMICOLON', 'FUNCTION'
at Object.parseError (/usr/local/lib/node_modules/tamejs/lib/parser.js:276:11)
at Object.parse (/usr/local/lib/node_modules/tamejs/lib/parser.js:352:22)
at Engine.parse (/usr/local/lib/node_modules/tamejs/lib/engine.js:396:19)
@xaptronic
xaptronic / factories.yml
Created October 7, 2011 12:50
Symfony mailer config
mailer:
param:
transport:
class: Swift_SmtpTransport
param:
host: smtp.gmail.com
port: 465
encryption: ssl
username: your_gmail_account
password: your_gmail_password
@xaptronic
xaptronic / redis-alt-or-better.js
Created October 6, 2011 22:29
Changes applied to get rid of warning message
--- redis.js.orig 2011-10-06 22:28:10.000000000 +0000
+++ redis.js 2011-10-06 22:51:18.000000000 +0000
@@ -65,6 +65,7 @@
// initialize a pubsub client and a regular client
this.pub = redis.createClient(opts.redisPub);
this.sub = redis.createClient(opts.redisSub);
+ this.sub.setMaxListeners(0);
this.cmd = redis.createClient(opts.redisClient);