Skip to content

Instantly share code, notes, and snippets.

View jcayzac's full-sized avatar

Julien Cayzac jcayzac

View GitHub Profile
@jcayzac
jcayzac / Gemfile
Created August 12, 2011 10:44
Git subcommand to create GitHub pull request (place it in your PATH)
source "http://rubygems.org"
octokit
@jcayzac
jcayzac / save_8bpp_image_as_PGM.cpp
Created September 3, 2011 12:46
Saving a 8bpp image to PGM
#include <ostream>
#include <algorithm>
void save_8bpp_image_as_PGM(
std::ostream& out,
const uint8_t* image_data,
size_t width,
size_t height,
size_t bytes_per_row
) {
@jcayzac
jcayzac / sketch.frag.c
Created September 4, 2011 09:37
"Sketch" OpenGL (ES) Fragment Shader
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 resolution;
uniform sampler2D tex0;
const vec4 luminance_vector = vec4(0.3, 0.59, 0.11, 0.0);
void main() {
@jcayzac
jcayzac / psycho_contours.frag.c
Created September 4, 2011 09:43
Edge detection fragment shader
precision mediump float;
uniform vec2 resolution;
uniform sampler2D tex0;
const vec2 n = vec2(1.0/1024.0, 1.0/512.0);
const vec4 luminance_vector = vec4(0.3, 0.59, 0.11, 0.0);
void main(void) {
vec2 uv = vec2(1.0) - (gl_FragCoord.xy / resolution.xy);
@jcayzac
jcayzac / activities.txt
Created September 18, 2011 08:33
List of common activities to share with friends
Afternoon break
Beer
Dinner
Lunch
PicNic
Tea
Esthe
Gym
Hammam
@jcayzac
jcayzac / ramdisk.py
Created September 21, 2011 03:43
RAM disk creation in Python
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""RAM disk creation (MacOS X only for now).
Usage:
with ramdisk(10240000, 'テスト1番') as x:
print "Mountpoint is: %s" % x.path
# use it
print 'Closing...'
@jcayzac
jcayzac / crotte.js
Created September 23, 2011 07:56
Crotte.js (my JS injector for blogger's mobile template)
(function() {
if (window.crotte_is_loaded) {
return;
}
window.crotte_is_loaded=true
var crotte_load_script = function(cnd, src, cb) {
if (cnd) {
var s = document.createElement('script');
s.type = 'text/javascript';
@jcayzac
jcayzac / iscroll.min.js
Created September 23, 2011 12:10
iScroll v3.6
var store = function(k,v) {
try {
localStorage[k] = v;
}
catch(e) { }
};
@jcayzac
jcayzac / GeoMath.cpp
Created September 25, 2011 13:19
GeoMath
/// @brief The usual PI/180 constant
static const double DEG_TO_RAD = 0.017453292519943295769236907684886;
/// @brief Earth's quatratic mean radius for WGS-84
static const double EARTH_RADIUS_IN_METERS = 6372797.560856;
/** @brief Computes the arc, in radian, between two WGS-84 positions.
*
* The result is equal to <code>Distance(from,to)/EARTH_RADIUS_IN_METERS</code>
* <code>= 2*asin(sqrt(h(d/EARTH_RADIUS_IN_METERS )))</code>
*
@jcayzac
jcayzac / SqrtLessSphereConeIntersectionTest.cpp
Created September 26, 2011 08:09
Sqrt-less sphere-cone intersection test
// V=(sphere.center - cone.apex_location)
// dotProduct_V_V = dotProduct(V, V)
// a = dotProduct(V, cone.direction_normal)
int cbloom_test(float dotProduct_V_V, float a, float sphere_radius, float cone_sin, float cone_cos) {
const float x(cone_cos*sqrt(dotProduct_V_V - a*a) - a*cone_sin);
return (fabsf(x)>=sphere_radius)?(x<0):-1;
}
int jcayzac_test(float dotProduct_V_V, float a, float sphere_radius, float cone_sin, float cone_cos) {
const float p(a*cone_sin);