This file contains 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
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine | |
# This is how I upload my new Sol Trader builds (http://soltrader.net) | |
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash | |
S3KEY="my aws key" | |
S3SECRET="my aws secret" # pass these in | |
function putS3 | |
{ | |
path=$1 |
This file contains 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
#!/usr/bin/env ruby | |
require 'webrick' | |
class NonCachingFileHandler < WEBrick::HTTPServlet::FileHandler | |
def prevent_caching(res) | |
res['ETag'] = nil | |
res['Last-Modified'] = Time.now + 100**4 | |
res['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0' | |
res['Pragma'] = 'no-cache' | |
res['Expires'] = Time.now - 100**4 |
This file contains 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
Fiduciary License Agreement 2.0 | |
based on the | |
Individual Contributor exclusive License Agreement | |
(including the TRADITIONAL PATENT LICENSE OPTION) | |
Thank you for your interest in contributing to Think Code Learn Ltd t/a Revelation Games's Tiny King ("We" or "Us"). | |
The purpose of this contributor agreement ("Agreement") is to clarify and document the rights granted by contributors to Us. To make this document effective, please follow the instructions at ____________________. | |
0. Preamble |
This file contains 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 assert_equal(expected, actual) | |
print expected == actual ? "." : "Expected #{expected}, but got #{actual}\n" | |
end | |
class PriceRule | |
def initialize(code, price) | |
@code = code | |
@price = price | |
end |
This file contains 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
#!/usr/bin/env bash | |
# call like this on the target server: | |
# NODENAME='foo' CHEF_ENV='production' RUNLIST='["role[foo]","recipe[bar]"]' CHEFREPO='git@example.com:repo.git' bash <( curl -L https://raw.github.com/gist/1026628 ) | |
# You will need to ensure that the ssh key is already set up on the server. | |
set -e | |
export CHEF_DIR="${HOME}/chef" | |
sudo rm -rf $CHEF_DIR | |
mkdir -p "$CHEF_DIR" |
This file contains 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 plus(num) | |
(1..num).to_a.map {|x| yield(x) }.join | |
end | |
p plus(3) { "ding" } | |
p plus(3) { |x| "...#{x}" } | |
p plus(5) { |x| (x + 2).to_s } | |
def sandwich(layers = 1, &block) |
This file contains 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 assert_equal(expected, actual) | |
print expected == actual ? "." : "Expected #{expected.inspect} but got #{actual.inspect}\n" | |
end | |
Discount = Struct.new(:amount, :value) do | |
def apply(basket, item) | |
(basket.count(item)/amount) * value | |
end | |
end |
This file contains 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
#!/bin/bash | |
TITLE_BG=title-bg.png | |
EL_BG=el-circle.png | |
OUT=achievements.png | |
# A colon-seperated rewards list. | |
# First column is the type of reward: | |
# <text> - a text number. | |
# Columns are alpha divisor (eg 4 is 25%), percentage complete, big number, smaller label and text description. |
This file contains 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 assert_equal(expected, actual) | |
print expected == actual ? "." : "Expected #{expected.inspect} but got #{actual.inspect}\n" | |
end | |
class SummingRule | |
def initialize(item, price) | |
@item = item | |
@price = price | |
end |
This file contains 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
class Checkout | |
def initialize | |
@total = 0 | |
end | |
PRICES = { "Apple" => 30, "Banana" => 50 } | |
def scan(item) | |
@total += PRICES[item] | |
end |
NewerOlder