Skip to content

Instantly share code, notes, and snippets.

View ysbaddaden's full-sized avatar

Julien Portalier ysbaddaden

View GitHub Profile
@ysbaddaden
ysbaddaden / console.txt
Created February 10, 2010 14:38
PHP's serialize() is slower than json_encode()
Results:
json_encode: 14.230s | 392 Ko
serialize: 50.383s | 540 Ko
json_decode: 36.503s
unserialize: 40.666s
@ysbaddaden
ysbaddaden / com.apple.ibooks.display-options.xml
Created April 12, 2013 16:31
Fixes code samples in Jesse Storimer's Working With Ruby Threads epub when readed on iBooks. iBooks defaults to using a user-specified font to display the book, which kills the monospaced font of code samples, because they're pygmented with spans, ans iBooks enforces the its font in spans. To fix it, you need to tell iBooks to enable a default m…
<?xml version="1.0" encoding="UTF-8"?>
<display_options>
<platform name="*">
<option name="specified-fonts">true</option>
</platform>
</display_options>
@ysbaddaden
ysbaddaden / Gemfile
Created April 16, 2014 21:51
Magnum CI Web Hook to report build status back to GitHub
source 'https://rubygems.org'
gem "json"
gem 'sinatra', "~> 1.3.5"
gem "octokit", "~> 3.0"
@ysbaddaden
ysbaddaden / api.md
Last active August 29, 2015 14:02
An API in JSON with relationships
  • Get a single resource: GET /posts/1
{
  "id": 1,
  "body": "...",
  "author": {
    "id": 2,
    "name": "Lucy",
    "_links": { "self": "/authors/2" }
 },
@ysbaddaden
ysbaddaden / js-screen-height-directive.js
Created September 22, 2014 20:12
js-screen-height-directive.js
// Fixes the height of an element to be at least the height of the current
// screen, minus it's current offset (so it fills the screen vertically).
powell.directive('jsScreenHeight', function () {
var $window = angular.element(window);
return {
restrict: 'C',
link: function (scope, element) {
var resize = function () {
// TODO: don't require jquery just for computing the offset
@ysbaddaden
ysbaddaden / v102.ofx
Created October 7, 2014 14:06
Example OFX with multiple accounts
FXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
@ysbaddaden
ysbaddaden / prax_sig_segfault.txt
Last active August 29, 2015 14:15
Prax Signal Segfault
Program received signal SIGPIPE, Broken pipe.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffcd7f2700 (LWP 9702)]
0x0000000000000001 in ?? ()
(gdb) bt
#1 0x0000000000418491 in *Signal::handler<Int32>:(Nil | Void) () at /home/github/crystal/src/signal.cr:57
#2 <signal handler called>
#3 0x00007ffff772135d in write () at ../sysdeps/unix/syscall-template.S:81
diff --git a/src/thread/lib_pthread.cr b/src/thread/lib_pthread.cr
index 5094260..96f2530 100644
--- a/src/thread/lib_pthread.cr
+++ b/src/thread/lib_pthread.cr
@@ -17,6 +17,7 @@ lib LibPThread
fun create = pthread_create(thread : Thread*, attr : Void*, start : Void* ->, arg : Void*) : Int32
fun exit = pthread_exit(value : Void*)
+ fun yield = pthread_yield() : Int32
fun join = pthread_join(thread : Thread, value : Void**) : Int32
@ysbaddaden
ysbaddaden / adjectives.txt
Created March 7, 2016 18:34
Generate Ubuntu-like release names
abandoned
able
absolute
adorable
adventurous
academic
acceptable
acclaimed
accomplished
accurate
@ysbaddaden
ysbaddaden / 001.txt
Last active May 25, 2016 08:45
Geographical Distances Benchmarks (Crystal)
# Benchmark run with Crystal 0.17.3 (LLVM 3.6) on "Intel Core i7-4712HQ CPU @ 2.30GHz" CPU
Brooklin (block)
haversine: 0.144098
sqrt: 0.19007 (+31.904%)
spheroid: 0.144098 (+1.59146e-09%)
ellipsoid: 0.188279 (+30.6604%)
Paris -> Marseille
haversine: 660.815