Skip to content

Instantly share code, notes, and snippets.

View syntacticsugar's full-sized avatar
🎯
Focusing

RomyRomy syntacticsugar

🎯
Focusing
View GitHub Profile
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta http-equiv="encoding" content="utf-8">
</head>
<canvas id="canvas" width="1490" height="512" style="border:1px dashed">
CA canvas
</canvas>
<script type="text/javascript">
var canvas = document.getElementById("canvas");
@syntacticsugar
syntacticsugar / around_the_world.js
Created April 14, 2013 04:32
learning about the unit circle. trigonometry exercises for javascript canvas stuffs.
var canvas = document.getElementById("exercises"),
context = canvas.getContext("2d"),
width = canvas.width,
height = canvas.height;
// midpoints
var midX = canvas.width/2, midY = canvas.height/2;
// trigonometry
var TAU = Math.PI * 2,
@syntacticsugar
syntacticsugar / magic_maths.html
Last active December 16, 2015 07:29
magic mathz...
<!DOCTYPE html>
<html lang="en">
<head>
<title>-=( magic maths )=-</title>
<link rel="stylesheet" href="" />
</head>
<body bgcolor="#040404">
<canvas id="canvas" width=960 height=700>
</canvas>
<script src="magic_maths.js"></script>
console.log("hello");
function LazySeq(head, tail) {
this.head = head; // value
this.tail = tail; // thunk || null
}
function ints(n) {
return new LazySeq(n, function() { return ints(n+1); });
}
(ns hs-js-clj.core)
(def foo {:bar 1})
(defn fooify [n] (str "foo" n))
(defn commaify [[x y]]
(str x ", " y))
(define menu
(lambda (x y)
(conde
[(== x 'tea) (== y 'biscuit)]
[(== x 'coffee) (== y 'cookie)])))
(define conso
(lambda (x y o)
(== `(,x . ,y) o)))
$array = []
module Collatz
def self.how_many n
if n == 1
($array.push n).length
elsif n.even?
$array.push n
n = n / 2
how_many n
class Fixnum
def ordinal
%w[first second third fourth fifth sixth seventh eighth ninth tenth eleventh twelfth][self - 1]
end
# Use #to_word rather than #to_s, so it doesn't break any other printing of numbers.
def to_word
%w[one two three four five six seven eight nine ten eleven twelve][self - 1]
end
end
@syntacticsugar
syntacticsugar / church_encoding.rb
Created November 22, 2013 00:28
"Let there be light." Thus spoke Alonzothrustra.
# proccc
def one proccc, x
proccc.(x)
end
def two proccc, x
proccc.(proccc.(x))
end
@syntacticsugar
syntacticsugar / project_euler_36.rb
Created December 29, 2013 01:52
project euler #36, first pass.
class String
def palindrome?
self == self.reverse
end
end
class Integer
def palindrome?(b=10)
self.to_s(b).palindrome?
end