Skip to content

Instantly share code, notes, and snippets.

View tarnfeld's full-sized avatar

Tom Arnfeld tarnfeld

View GitHub Profile
<?php
function diff($hours, $minutes)
{
// get the degrees for each part
$hour_deg = 360/12;
$min_deg = 360/60;
// calculate the position
$hour_hand = $hour_deg*$hours;
@tarnfeld
tarnfeld / README.md
Created April 9, 2012 22:26
Riak Bootstrap for Ubuntu 11.10

Riak Bootstrap for Ubuntu 11.10

Fire up a new Ubuntu 11.10 instance (I'm using EC2 for this) and log in. Move into the home directory (you should be there already at login) and run the following command to bootstrap this instance and get riak up and running.

$ curl -0 https://raw.github.com/gist/2347065/riak-bootstrap.sh | sh
@tarnfeld
tarnfeld / Answer.php
Created June 7, 2012 15:07 — forked from JeffreyWay/gist:2889230
Simple PHP Quiz
<?php
$string = "January 5th, 2012";
list($month, $day, $year) = array_map(function($v) { return trim($v, ","); }, explode(" ", $string));
var_dump($month, $day, $year);
// string(7) "January"
// string(3) "5th"
// string(4) "2012"
/**
* Live updating API JS client side class
* @author Tim Davies
*/
function LiveupdatingClient (container)
{
/**
* Set up, include handlebars and setup template
*/
var endpoint = 'liveupdating.php';
@tarnfeld
tarnfeld / error
Created January 2, 2013 11:52 — forked from m4tthumphrey/error
Exception
NoMethodError
Error
undefined method `id' for nil:NilClass
/home/gitlab/gitlab/app/models/project.rb:104:in `find_with_namespace'
/home/gitlab/gitlab/app/workers/post_receive.rb:9:in `perform'
@tarnfeld
tarnfeld / gist:4534175
Created January 14, 2013 22:36
Create a bezier path with rounded corners based on a radius and existing frame. Most useful if you want to add in other shapes into the path while still maintaining rounded corners (for example, an arrow).
- (UIBezierPath *)roundedPathFromRect(CGRect)f
{
UIBezierPath *path = [[UIBezierPath alloc] init];
NSInteger radius = 4.0;
// Draw the path
[path moveToPoint:CGPointMake(radius, 0)];
[path addLineToPoint:CGPointMake(f.size.width - radius, 0)];
[path addArcWithCenter:CGPointMake(f.size.width - radius, radius)
radius:radius
var a = [], i = 0;
function addPart(part, callback) {
setTimeout(function(part) {
a.push(part);
callback();
}, 200);
};
function init(callback) {
function check() {
"""
Test:
Given two strings, `a` and `b`. Sort the letters in `a` by the order of letters in `b`.
For example:
a = "ssttexeste"
b = "test"
result = "ttteeesssx"
"""
def a_by_b(a, b):
docker build
>> built XXXXX
docker tag registry/test/FOOBAR:my-tag
docker push registry/test/FOOBAR
>> pushes XXXXX to registry/test/FOOBAR (uploaded)
docker build
>> built XXXX1
@tarnfeld
tarnfeld / readme.md
Last active August 29, 2015 14:01
Lightweight containers with Docker

I was curious to find out if there was a way of maintaing docker's great user experience, while being able to enjoy the simplicity of cgroups on their own.

This has it's benefits, as there's no need to transfer any data in an image that isn't required for your individual service. You can also more easily share packages and installations with the host operating system.

Launch a container with all of the important host stuff mounted

$ sudo docker run -d \
    -v /bin:/bin:ro \
    -v /dev:/dev:ro \