Skip to content

Instantly share code, notes, and snippets.

View david-hodgetts's full-sized avatar

david hodgetts david-hodgetts

View GitHub Profile
// test code for project exquis -> https://github.com/gongfuio/Exquis
// setup
this.TO_RADIANS = Math.PI/180;
this.buffer = document.createElement('canvas');
this.buffer.width = context.canvas.width;
this.buffer.height = context.canvas.height;
this.bufferCtx = this.buffer.getContext("2d");
this.rotation = 0;
@david-hodgetts
david-hodgetts / LP_updateInfoNote.py
Created December 6, 2013 09:34
robofont script. Opens a textEditor allowing edition of CurrentFont().info.note
from vanilla import Window, SquareButton, TextEditor
import vanilla
import mojo
def onSubmit(sender):
CurrentFont().info.note = window.textEditor.get()
window.close()
if CurrentFont() is None:
vanilla.dialogs.message("there is no current font, operation aborted")
@david-hodgetts
david-hodgetts / destroyOnRaycastHit
Created November 15, 2013 16:12
destruction d'un gameobject dont le collider rentre en intersection avec un rayon. (cours sae) (unity3d)
using UnityEngine;
using System.Collections;
public class Caster : MonoBehaviour {
void Update(){
Vector3 rayOrigin = transform.position; // l'origine du rayon: la position du gameobject
Vector3 rayDirection = transform.up; // la direction du rayon: l'axe local y positif
@david-hodgetts
david-hodgetts / custom.css
Created October 21, 2013 19:15
reveal css (rails workshop)
p, li, h1, h2, h3, ul {
text-align: left;
}
table.files {
font-family: verdana,arial,sans-serif;
font-size:18px;
color:#333333;
border-width: 1px;
border-color: #999999;
@david-hodgetts
david-hodgetts / convert_showoff.rb
Created October 21, 2013 19:14
convert md from showoff to reveal
#!/usr/bin/env ruby
# encoding: utf-8
class Proc
def self.compose(f, g)
lambda { |*args| f[g[*args]] }
end
def *(g)
Proc.compose(self, g)
@david-hodgetts
david-hodgetts / very naive plane
Created September 4, 2013 14:32
unity 3d script for a very unrealistic flight model
using UnityEngine;
using System.Collections;
public class VeryNaivePlane : MonoBehaviour {
public float flightSpeed = 20;
public float rotationSpeed = 60;
void Update () {
transform.position += transform.forward * flightSpeed * Time.deltaTime;
@david-hodgetts
david-hodgetts / buildDictFromUnicodeToGlyphname
Created August 8, 2013 13:55
robofont script function. creates a dictionary mapping unicode values to glyphNames
import vanilla
import mojo
from mojo.UI import getDefaultCharacterSet, getCharacterSets
def buildDictFromUnicodeToGlyphname():
"HACK: builds a dict from unicode to glyphnames"
defaultCharSet = getCharacterSets()[getDefaultCharacterSet()]
font = NewFont()
result = {}
for glyphName in defaultCharSet:
@david-hodgetts
david-hodgetts / naive_macros
Created August 4, 2013 19:59
macros to help printf-style debugging in clojure
(defmacro print-symbol [expr]
`(println
(str (name '~expr)
" -> "
(eval ~expr))))
(defmacro print-map-property [property aMap]
`(println
(str (name '~property)
" -> "
class Node
def accept visitor
raise NotImplementedError.new
end
end
module Visitable
def accept visitor
visitor.visit self
end
(fn myComp [& fs]
(let [ordered-fs (reverse fs)]
(fn[& args]
(loop [f-list (rest ordered-fs)
v (apply (first ordered-fs) args)]
(if (not (seq f-list)) v
(recur (rest f-list) ((first f-list) v)))))))