Skip to content

Instantly share code, notes, and snippets.

View gre's full-sized avatar
3 cups required

@greweb gre

3 cups required
View GitHub Profile
@gre
gre / git.sh
Last active August 29, 2015 14:03
resolve git config contextually (find a .gitconfig in the PWD tree)
#!/bin/bash
# Put this script in ~/bin/git.sh and `chmod +x` it
# in your .bash_profile add: alias git=$HOME/bin/git.sh
###### DO NOT USE IT #####
##### it doesn't seem to work properly... git commit still put the wrong git config even if git config say something else ######
function upsearch () {
slashes=${PWD//[^\/]/}
@gre
gre / catchall
Created July 16, 2014 10:32
Nginx catchall site
server {
listen 80 default_server;
server_name _;
return 404;
}
@gre
gre / recent.glsl
Last active August 29, 2015 14:04 — forked from glslioadmin/TEMPLATE.glsl
/!\ **DEV ONLY** - GLSL.io Transition (v1) used for the development
// TEST
// This template should ONLY be used for DEVELOPMENT
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D from, to;
uniform float progress;
uniform vec2 resolution;
@gre
gre / SimpleMinimax.scala
Created July 31, 2014 08:59
minimax algorithm with alpha-beta pruning
package fr.greweb.ai
import scala.annotation.tailrec
object SimpleMinimax {
type Score = Double
// First impl of minimax, no track of the path
trait Node {
@gre
gre / annotate_photos.sh
Last active August 29, 2015 14:10
Annotate photos with the date. in white. corner bottom right. size of the font relative to the photo resolution.
out=`pwd`/OUT
rm -rf $out
mkdir $out || exit;
for d in raw/*; do
if [ -d $d ]; then
cd $d || exit;
mkdir $out/$d || exit;
for f in *; do
echo "$f => $out/$d/$f";
@gre
gre / App.js
Last active August 29, 2015 14:14
var m = require("mithril");
var Qajax = require("qajax");
var Header = require("./Header");
var Library = require("./Library");
var Viewer = require("./Viewer");
var Timeline = require("./Timeline");
function App () {
var self = this;
(ns channels.core
(:require
[clojure.core.async :as async :refer [>! <! filter< alts! sliding-buffer tap mult chan thread timeout go go-loop alts!!]]
)
(:gen-class))
(defn filtered-channel [chan-input predicate & [buf-or-n]]
(let [c (if buf-or-n (chan buf-or-n) (chan))]
(tap chan-input c)
(filter< predicate c)))
@gre
gre / time-bufferize.clj
Last active August 29, 2015 14:14
Time Bufferizing using core.async in Clojure
(defn time-bufferize [in t]
(let [c (chan)]
(go
(loop
[buf []
timer (timeout t)]
(let [[value port] (alts! [in timer])
timed-out (= port timer) ]
(if (= port timer) ; timed out
[Error: unexpected EOF at line 5]
GLSL:
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;const vec2 center=vec2(0.5,0.5);float quadraticInOut(float t){float p=2.0*t*t;return t<0.5?p:-p+(4.0*t)-1.0;}float rand(vec2 co){return fract(sin(dot(co.xy,vec2(12.9898,78.233)))*43758.5453);}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;if(progress==0.0){gl_FragColor=texture2D(from,p);}else if(progress==1.0){gl_FragColor=texture2D(to,p);}else{float x=progress;float dist=distance(center,p);float r=x-min(rand(vec2(p.y,0.0)),rand(vec2(0.0,p.x)));float m=dist<=r?1.0:0.0;gl_FragColor=mix(texture2D(from,p),texture2D(to,p),m);}}
[Error: expected `)`, got `/* pi */` at line 7]
var through = require("through")
var extract = require("glsl-extract")
require("glsl-transitions").forEach(function (t) {
var e=null;
console.error = function (msg) {
e = msg;
};
getExports(t.glsl); // for some reason this doesn't break but log using console.error (so I hacked console.error!)