Skip to content

Instantly share code, notes, and snippets.

View adaedra's full-sized avatar

Thibault “Adædra” Hamel adaedra

View GitHub Profile
<?php
require 'vendor/autoload.php';
$template = <<<"HTML"
<dl>
{{#def "Wello horld"}}
Hello {{who}}
{{/def}}
</dl>
// Generated by CoffeeScript 1.8.0
var Handlebars, source, template;
Handlebars = require('handlebars');
Handlebars.registerHelper('def', function(title, options) {
return '<dt>' + title + '</dt><dd>' + options.fn(this) + '</dd>';
});
source = '<dl>{{#def \'Wello\'}}Hello {{who}}{{/def}}</dl>';
<?php
require('vendor/autoload.php');
$tmpfile = tempnam(sys_get_temp_dir(), 'hbs');
error_log($tmpfile);
$tmpl_src = <<<'HBS'
{{{test foo="bar"}}}
HBS;
$tmpl = LightnCandy::compile($tmpl_src, Array(
def  2
3
end
puts 2 + 2
@adaedra
adaedra / cookiebot.js
Created October 2, 2013 23:35
CookieBot
// Crafted cookies taste awful
var CookieBot = Array();
CookieBot.Function = function () {
var o = CookieBot.BuyNext();
Game.ClickCookie();
if (Game.Objects[o].price <= Game.cookies) {
Game.Objects[o].buy();
}
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#define PASSWORD_LENGTH 10
int main(void) {
@adaedra
adaedra / .zshrc
Last active December 17, 2015 09:29
My `.zshrc` file. This gist is used by the script itself to maintain itself up-to-date.
OPEN_SYMBOL="❮"
CLOSE_SYMBOL="❯"
PROMPT=" %F{cyan}%m: %B%n%b%F{cyan} \${CLOSE_SYMBOL}%f "
RPROMPT="\${STATUS_PROMPT}%F{blue}\${OPEN_SYMBOL} %B%1~%b%f"
LAST_RET=0
setopt PROMPT_SUBST
setopt TRANSIENT_RPROMPT
@adaedra
adaedra / foo.rb
Created January 15, 2013 23:33
Ruby fun :D
def false.to_s
"true"
end
@adaedra
adaedra / typescript
Created December 13, 2012 22:16
Apple's memory & valgrind fail
adaedra@pegasus % cd /tmp
adaedra@pegasus % echo "int main(void) { }" > memory_fail.c
adaedra@pegasus % gcc -o memory_fail memory_fail.c
adaedra@pegasus % valgrind ./memory_fail
==2086== Memcheck, a memory error detector
==2086== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==2086== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==2086== Command: ./memory_fail
==2086==
==2086== WARNING: Support on MacOS 10.8 is experimental and mostly broken.
@adaedra
adaedra / gist:3888306
Created October 14, 2012 11:34
Ruby implementations comparison
adaedra@pegasus % ./test.rb
Test "sinusTest" runned in 1.340s
Test "loopTest" runned in 6.249s
Test "arrayTest" runned in 1.810s
Test "randomTest" runned in 3.110s
Test "sortTest" runned in 1.774s
Test "threadsTest" runned in 5.762s
Total time run : 20.045s
adaedra@pegasus % rvm use jruby
Using /usr/local/rvm/gems/jruby-1.6.8