Skip to content

Instantly share code, notes, and snippets.

View dhotson's full-sized avatar

Dennis Hotson dhotson

View GitHub Profile
@dhotson
dhotson / screensaver.jl
Created February 25, 2013 03:19
A screensaver in Julia
pallete = Array(String, 93)
i = 1
for bg = 232:(255-1)
for char in [" ", "░", "▒", "▓"]
pallete[i] = "\e[38;5;$(bg+1)m\e[48;5;$(bg)m$(char)\e[0m"
i += 1
end
end
pallete[93] = "\e[48;5;$(255)m \e[0m"
# ccv_dense_matrix_t* image = 0
image = Array(Ptr{Void},0)
# int ccv_read_impl(const void* in, ccv_dense_matrix_t** x, int type, int rows, int cols, int scanline);
r = ccall(
(:ccv_read_impl, "libccv"),
Int32,
(Ptr{Uint8}, Ptr{Ptr{Void}}, Int, Int, Int, Int),
"/home/vagrant/dev/julia/test.png", image, 0x100 | 0x020, 0, 0, 0)
<?php
// Instructions: save this file to the base diretory of the kumite-moa repo..
require 'vendor/autoload.php';
/**
* Calculates the statistical significance of a boolean experiment over
* multiple events (e.g. contests), where the result for each event is
* a true/false outcome (e.g. contest was or was not refunded).
<?php
use Symfony\Component\HttpFoundation\Request;
class KelpieSymfonyAdaptor
{
public function __construct($app)
{
$this->_app = $app;
}
<?php
require_once __DIR__.'/../vendor/autoload.php';
require_once __DIR__.'/../lib/kelpie/lib/kelpie.php';
require_once 'KelpieSymfonyAdaptor.php';
$app = new Silex\Application();
$app->get('/hello/{name}', function ($name) use ($app) {
return 'Hello '.$app->escape($name);
});
<?php
function ($hello, $hello, $̀) {
echo "$hello$hello$̀\n";
}
("lolol", "trolo", "!");
<?php
function ($) {
echo "Hello $!\n";
}
("world");
function test($̀a) { echo $̀a; }
test("zomg!\n");
def fib
f0, f1 = 0, 1
loop do
f0, f1 = f1, (f0 + f1)
r = yield f1
return if !r
end
end
fib do |n|
# screen had it right, C-B is too hard to reach.
unbind C-b
set -g prefix `
# set -g prefix `
# http://blog.hawkhost.com/2010/06/28/tmux-the-terminal-multiplexer/
unbind %
bind | split-window -h
bind - split-window -v
@dhotson
dhotson / chipmunk.rb
Created June 22, 2012 13:23
Example of Chipmunk Physics library usage in Ruby
# See: https://github.com/beoran/chipmunk/tree/master/spec
# + http://chipmunk-physics.net/release/ChipmunkLatest-Docs/
require 'chipmunk' # gem install chipmunk
s = CP::Space.new
s.gravity = vec2(0,0)
b1 = CP::Body.new(5, 7)
b1.pos = vec2(400,600)
b1.v = vec2(30,1)