Skip to content

Instantly share code, notes, and snippets.

View ghostrocket's full-sized avatar

Keith Fitzgerald ghostrocket

View GitHub Profile
@ghostrocket
ghostrocket / tweet-linkify.js
Created December 31, 2010 16:54
Linkify Tweet in Javascript
String.prototype.linkify_tweet = function() {
var tweet = this.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig,"<a href='$1'>$1</a>");
tweet = tweet.replace(/(^|\s)@(\w+)/g, "$1<a href=\"http://www.twitter.com/$2\">@$2</a>");
return tweet.replace(/(^|\s)#(\w+)/g, "$1<a href=\"http://search.twitter.com/search?q=%23$2\">#$2</a>");
};
@ghostrocket
ghostrocket / gist:799429
Created January 27, 2011 22:30
Cross Browser Date Parse for Twitter created_at
var date = new Date(Date.parse(twitter_response[0].created_at.replace(/( \+)/, ' UTC$1')));
@ghostrocket
ghostrocket / gist:801929
Created January 29, 2011 15:46
javascript curry
Function.prototype.curry = function curry() {
var fn = this, args = Array.prototype.slice.call(arguments);
return function curryed() {
return fn.apply(this, args.concat(Array.prototype.slice.call(arguments)));
};
};
// pulled from this stackoverflow.com post http://stackoverflow.com/questions/4674021/xhr-get-request-url-in-onreadystatechange
@ghostrocket
ghostrocket / site-packages
Created February 24, 2011 21:05
find site packages
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

A Backbone.js demo app (Sinatra Backend)

Oct 16 2010

Updates

  • 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments

In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].

@ghostrocket
ghostrocket / gist:2208270
Created March 26, 2012 18:13 — forked from shripadk/gist:652819
Express authentication using Redis for session store and Couchdb for database (in coffeescript!)
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'
@ghostrocket
ghostrocket / gist:6581566
Created September 16, 2013 14:39
Fix Busted Characters after converting mysql db from latin1_swedish to utf8
mysql -uroot --password= --skip-column-names -e "select concat('update ', a.table_name, ' set ', a.column_name, ' = convert(cast(convert(', a.column_name, ' using latin1) as binary) using utf8);') from information_schema.columns a where a.table_schema = '$DB_SCHEMA';" > fixutf8.sql
mysql -uroot --password= $DB_SCHEMA < fixutf8.sql
#!/bin/bash
# install setuptools
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python
# install pip
sudo easy_install pip
# install virtualenv
sudo pip install virtualenv
@ghostrocket
ghostrocket / ghostrocket-mou
Created January 20, 2014 21:33
my mou theme
editor
foreground: f5f5f5
background: 000000
caret: 000000
editor-selection
foreground: ffffff
background: ff4f92
H1
# put this file in /usr/local/etc/my.cnf
[mysqld]
max_connections = 10
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K