Skip to content

Instantly share code, notes, and snippets.

@dansimau
dansimau / emoify.html
Created March 5, 2014 10:33
Instantly add emoji to any web app.
<script src="https://raw.github.com/hassankhan/emojify.js/master/emojify.min.js"></script>
<script>
(function() {
// Config
emojify.setConfig({
img_dir : '/emoji',
ignored_tags : {
'SCRIPT' : 1,
'TEXTAREA': 1,
'A' : 1,
@dansimau
dansimau / generate-class-code.sh
Created September 20, 2011 09:25
Test scripts for comparing the performance of declaring and instantiating classes dynamically in PHP using eval versus including from files.
#!/bin/bash
mkdir $1 || exit
c=0;
while [ $c -lt $1 ]; do
cat <<EOF >"$1/Foo_$c.php"
<?php
Class Foo_$c
{
function __construct() {
@dansimau
dansimau / daemon-launcher.sh
Created October 28, 2011 11:31
Launches program as a daemon and keeps it running. Adds log and pid file support to the program.
#!/bin/bash
#
# Daemoniser: starts a program as a daemon and relaunches it if it exits. Adds a pidfile and
# logfile capabilities.
#
# dsimmons@squiz.co.uk
# 2011-10-28
#
usage()
@dansimau
dansimau / pgclone.sh
Created January 18, 2012 12:52
Clones a new PostgreSQL standby server from master
#/bin/sh -x
#
# Restores a slave node from the specified master and sets up recovery.conf
# with streaming replication.
#
# dsimmons@squiz.co.uk
# 2012-01-24
#
if [ -z "$1" -o "$1" == "--help" ]; then
@dansimau
dansimau / reduce-backups.sh
Created January 20, 2012 09:57
Prunes Squiz CMS backups to the last X number of days. Will bail out if the backups have broken, to avoid deleting backups if they may be needed.
#!/bin/bash
#
# Reduces the total number of Squiz CMS backups to the last X days', whilst
# also ensuring at least X number of backups always exist.
#
# In other words, we want only the last X number of days' backups unless the
# backups have failed, in which case we'd prefer to keep the old ones until
# the backup is running again.
#
# dsimmons@squiz.co.uk
@dansimau
dansimau / showdown.js
Created February 28, 2012 10:12
Markdown-to-HTML file converter using showdown JS library (Node.js)
#!/usr/bin/env node
/**
* Takes specified Markdown files outputs them as HTML.
*
* Requires showdown:
*
* npm install showdown
*
* dan@dans.im
@dansimau
dansimau / nfs-remount.sh
Created July 17, 2012 15:33
Bash script to add psuedo-remount functionality to NFS mounts in Linux
#!/bin/bash
#
# Remount a filesystem with new options by unmounting it first (with umount)
# and mounting it again.
#
# Used for filesystems that do not support the -o remount option (eg. NFS).
#
# Compatible with Linux/bash only.
#
# 2012-07-17
@dansimau
dansimau / test-md5-bin.lua
Created August 23, 2012 03:22
Testing performance of md5 hash calculation in lua vs node
require("md5")
local testname = "lua md5 sum hash test (binary)"
function test()
-- Create object hash
local object_key_plain = [[
"0.0.0.0",
80,
"www.example.com",

Trying out HHVM (JIT)

Following instructions to set up Wordpress (from http://www.hiphop-php.com/wp/?p=113):

# /usr/bin/hhvm --mode server --user www-data --config /etc/hhvm.hdf
/home/sgolemon/dev/hiphop-php/src/runtime/vm/translator/asm-x64.cpp:79 (makeExecable): mprotect @(nil) 32768 bytes failed (Cannot allocate memory)
/home/sgolemon/dev/hiphop-php/src/runtime/vm/translator/asm-x64.cpp:79 (makeExecable): mprotect @(nil) 32768 bytes failed (Cannot allocate memory)
Aborted (core dumped)

@dansimau
dansimau / bar.go
Last active December 2, 2015 13:40
package foo
type Interface interface {
foo()
}