Skip to content

Instantly share code, notes, and snippets.

@liamcurry
liamcurry / convert.py
Created November 7, 2011 21:52
Converting fonts with fontforge and python
import fontforge
import os.path
filename = 'the-filename'
basename, ext = os.path.splitext(filename)
desired_formats = ['otf', 'eot']
font = fontforge.open(filename)
for desired_format in desired_formats:
font.generate('%s.%s' % (basename, desired_format))
@liamcurry
liamcurry / Coercion.js
Created May 4, 2012 16:58
HTMl/CSS/JS quickies
/* String to Number */
var hello = '1234'
parseInt(hello) // Use this when speed is a concern (see http://jsperf.com/parseint-vs-unary)
// 1234
+hello // unary operator -- use this when file size is a concern
// 1234
+hello++ // Converts `hello` to a number and adds 1 to it
@liamcurry
liamcurry / Linkify Tweet.js
Created August 16, 2012 19:23
Nice JS Snippets
// Converts #hashtags, @usernames, and http://regularlin.ks
var tweet = 'Final day for the 2 @nvidia *INSTANT ACCESS* @PlanetSide2 #BetaKeys. RT: https://t.co/gKpxu1eY and/or Follow: http://t.co/3ryWGeEz to enter!';
tweet = tweet
.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, '<a target=_blank href="$1">$1</a>')
.replace(/(^|\s)@(\w+)/g, '$1<a target=_blank href=//twitter.com/$2>@$2</a>')
.replace(/(^|\s)#(\w+)/g, '$1<a target=_blank href=//twitter.com/search?q=%23$2>#$2</a>');
@liamcurry
liamcurry / bootstrap.sh
Created August 23, 2012 01:09
Bootstrap EC2
# curl -L https://raw.github.com/gist/3431015/bootstrap.sh | sh
USERNAME=$(id -un)
COMMON_PKGS="curl vim git zsh autojump tmux"
command_exists () {
type "$1" &> /dev/null ;
}
if command_exists apt-get ; then
@liamcurry
liamcurry / Setting up deployment via git.md
Created August 23, 2012 06:49
Setting up deployment via git

Setting up deployment via git

Add this entry to your local .git/config:

[remote "prod"]
  url = amazon:/path/to/repo.git
  fetch = +refs/heads/*:refs/remotes/amazon/*
@liamcurry
liamcurry / ubuntu-desktop.sh
Last active October 10, 2015 22:28
Bootstrap
# Packages
sudo apt-get install curl vim git zsh autojump tmux python-gpgme g++ libssl-dev apache2-utils
# Dotfiles
git init
git remote add -f origin git://github.com/liamcurry/dotfiles.git
git submodule update --init --force
git config status.showuntrackedfiles no
chsh -s /bin/zsh
@liamcurry
liamcurry / logger.js
Created October 3, 2012 03:12
A small logging function to share between the client and server, inspired by winston
/* This needs some work, and is probably pretty broken at the moment. Will come back to this later. */
define([
'underscore'
], function (
_
) {
console.log(this);
var root = this;
@liamcurry
liamcurry / Snippets.md
Created November 10, 2012 16:26
Maintenance snippets

Start/Restart/Stop MySQL

mysql.server [stop|start|restart]

Create a MySQL database

create database db_name;
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
wget https://github.com/elasticsearch/elasticsearch/archive/v0.20.1.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@liamcurry
liamcurry / eventemitter.js
Created June 19, 2013 21:06
Simple Client-side EventEmitter implementation
function EventEmitter() {}
EventEmitter.prototype.on =
EventEmitter.prototype.addListener = function (event, callback) {
this._events = this._events || {};
this._events[event] = this._events[event] || [];
this._events[event].push(callback);
return this;
};