Skip to content

Instantly share code, notes, and snippets.

View danielbeardsley's full-sized avatar

Daniel Beardsley danielbeardsley

View GitHub Profile
if (window.XDomainRequest) (function(){
var onLoad = function(){
cleanup(this.xhr);
this.response = {text: this.xhr.responseText, xml: this.xhr.responseXML};
this.success(this.response.text, this.response.xml);
};
var onError = function(){
cleanup(this.xhr);
@SathyaBhat
SathyaBhat / gist:894012
Created March 30, 2011 07:36
Chrome extensions keyboard shortcut handler
/*
Right here's the thing - for keyPress events to be run, you'll have to make use of
content scripts. Content scripts handle things at webpage & DOM level. You'll have
to do changes to your manifest:
*/
------------------------
manifest.json:
------------------------
/*
Note: don't replace manifest.json, add the relevant changes else
@naltatis
naltatis / facebook-xmpp.js
Created May 9, 2011 09:11
connecting to Facebook via node-xmpp
var client = new xmpp.Client({
jid: '-123456@chat.facebook.com', // where 123456 is the users facebook id
api_key: apiKey, // api key of your facebook app
secret_key: secretKey, // secret key of your facebook app
session_key: sessionKey // users current session key
});
// you can find more details here http://developers.facebook.com/docs/chat/
@taf2
taf2 / reconnect-on-disconnect.js
Created July 1, 2011 15:51
mongoose node.js reconnect code
var mongoose = require('mongoose');
var db = mongoose.connect("mongodb://localhost/testdb");
var reconnTimer = null;
function tryReconnect() {
reconnTimer = null;
console.log("try to connect: %d", mongoose.connection.readyState);
db = mongoose.connect("mongodb://localhost/testdb");
}

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@marczych
marczych / gist:3882918
Created October 13, 2012 02:03
Vim: Take the word under the cursor, append the current buffer's extension, and open it using find.
nnoremap <silent> <C-o> :call FindFile()<CR>
function! FindFile()
" Get the word under cursor.
let cursorWord = expand("<cword>")
" Get the current file name and keep only the extension.
let currentFile = expand("%")
let extPos = stridx(currentFile, ".")
" Append an extension only if the current file has an extension.
@sturadnidge
sturadnidge / tmux-1.8-on-CentOS-6.x.txt
Last active May 10, 2021 18:31
Install tmux 1.8 on CentOS 6.x minimal (64bit)
# download latest libevent2 and tmux sources, and extract them somewhere
# (thx bluejedi for tip on latest tmux URL)
#
# at the time of writing:
# https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# http://sourceforge.net/projects/tmux/files/latest/download?source=files
#
# install deps
yum install gcc kernel-devel make ncurses-devel
@marczych
marczych / gist:10524654
Last active August 29, 2015 13:59
Tmux git-scripts functions
#!/bin/sh
# Convenience functions to set the tmux session name based on branches/pull
# numbers and switches branches based on the session name.
#
# Depends on tmux and https://github.com/iFixit/git-scripts.
# (feature|hotfix) switch based on the session name.
function tswitch {
BRANCH=$(tmux display-message -p '#S' | sed 's/|.*$//')
@nofxx
nofxx / errbit-unicorn.service
Created January 5, 2015 19:15
errbit unicorn systemd service
[Unit]
Description=Errbit Unicorn Server
Requires=mongodb.service
After=mongodb.service network.target
[Service]
# Change here: user, group and directory to errbit root
User=errbit
Group=errbit
WorkingDirectory=/var/www/apps/errbit