This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dirty way to completely remove the automatic escaping of html in rails helpers | |
# useful to get your Rails 2 -> 3 upgrade running to the point where the raw/.html_safe additions can be delegated | |
module CustomHtmlSafe | |
def html_safe? | |
true | |
end | |
end | |
class ActionView::OutputBuffer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######## | |
# Author: Henry Turner | |
# Project: to_string | |
# Description: A speedy algorithm to convert a string to a string | |
# License: MIT | |
######## | |
def to_string | |
# process the string | |
self.to_s | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# As root user | |
sudo su | |
# Update the OS | |
apt-get update -y | |
# Setup Hostname & TimeZone | |
echo "{{HOSTNAME}}" > /etc/hostname | |
hostname -F /etc/hostname |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strconv" | |
"crypto/sha256" | |
"encoding/base64" | |
) | |
func main(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install by getting the raw url from the github interface and run something like.. | |
# curl -L https//gist.github.com/blahblah | bash | |
mkdir -p ~/backups | |
mkdir -p ~/bin | |
# a backup for each day of the month overwritting old days | |
echo "mysqldump -u root --all-databases > ~/backups/all-`date +20XX-XX-%d`.sql" > ~/bin/backup_all_mysql_databases | |
chmod 777 ~/bin/backup_all_mysql_databases |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
project_path='~/apps/'$app'/current' | |
frontend_path=$project_path$subdir | |
cmd='' | |
cmd+='. ~/.bash_profile;' | |
cmd+='cd '$project_path';' | |
cmd+='git pull;' | |
cmd+='kill `cat '$frontend_path'/tmp/pids/unicorn.pid`;' | |
sleep 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Vundle Setup | |
set nocompatible " be iMproved | |
filetype off " required! | |
set rtp+=~/.vim/bundle/vundle/ | |
call vundle#rc() | |
" let Vundle manage Vundle | |
" required! | |
Bundle 'gmarik/vundle' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ tmp cat no_way.rb | |
def ☃ | |
puts "Oh look, it's a ☃" | |
end | |
☃ | |
➜ tmp ruby no_way.rb | |
Oh look, it's a ☃ | |
➜ tmp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://en.bitcoin.it/wiki/Proof_of_work | |
# usage: ProofOfWork.new("Hello World!", 3).nonce_and_hash | |
# In this example think of the "Hello World!" as a a collection of Bitcoin transactions waiting to be verified. | |
# 3 is the arbitary number that makes it harder to verify the transactions. Over time 3 goes up and up and the | |
# difficulty is exponential. | |
require 'digest' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def colour_combinations(colours=[]) | |
colours.flat_map{|x| colours.flat_map{|y| x <= y ? [[x, y]] : [] } } | |
end | |
require 'minitest/autorun' | |
require 'minitest/unit' | |
class TestColours < MiniTest::Unit::TestCase | |
def test_colour_combinations |
OlderNewer