This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns drag.core | |
(:use [jayq.core :only [$ bind]] | |
[cljs.core.async :only [chan put! <!]]) | |
(:require-macros [cljs.core.async.macros :refer [go]])) | |
(defn create-canvas | |
[& {:keys [width height]}] | |
(let [canvas ($ "<canvas>") | |
context (-> canvas (aget 0) (.getContext "2d"))] | |
(doto canvas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
template<class T, size_t N> | |
struct Vector { }; | |
template<class T> | |
struct Vector <T,1> | |
{ | |
union { | |
T e[1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
markdown_name = sys.argv[1] | |
name = markdown_name.split(".")[0] | |
latex_name = name + ".tex" | |
os.system("pandoc -f markdown -t latex %s -o %s" % (markdown_name, latex_name)) | |
with open(latex_name, "r") as latex_file: | |
latex_content = latex_file.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_operator(symbol): | |
return isinstance(symbol, basestring) | |
def to_infix(postfix): | |
stack = [] | |
for symbol in postfix: | |
if is_operator(symbol): | |
operand2 = stack.pop() | |
operand1 = stack.pop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Char (toUpper) | |
import Control.Monad (liftM, mapM_) | |
import System.Random | |
readLines :: String -> IO [String] | |
readLines = liftM lines . readFile | |
boundaries :: [a] -> (Int, Int) | |
boundaries xs = (0, length xs - 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
var adjectives = [], | |
nouns = []; | |
var any = function(coll) { | |
var index = Math.floor(Math.random() * coll.length); | |
return coll[index]; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Your story begins. You wake up. Reach the village. Cross the volcano. You defeat the dragon. You save the prince! Your story ends. | |
Your story begins. Your father dies. Reach the village. Find the three mages. You defeat the sorcerer. You save the world! Your story ends. | |
Your story begins. Your father dies. Reach the village. Find the sage. Find the three mages. You defeat the dragon. You save the prince! Your story ends. | |
Your story begins. Your father dies. Reach the village. Find the one orbs. Find the island. You defeat the witch. You save the princess! Your story ends. | |
Your story begins. You wake up. Reach the village. Cross the forest. Find the island. You defeat the witch. You save the prince! Your story ends. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns grammar.core) | |
(defprotocol LHS | |
(=> [this rules] "Returns a vector of terminal elements according to the provided rules.")) | |
(extend-protocol LHS | |
; Simply returns a singleton vector containing itself | |
String | |
(=> [this _] [this]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lisp, for reference | |
(if something? | |
(if something-else? | |
"double true" | |
"true and false") | |
"just false") | |
// Let's try something javascript-y | |
{tag: if, | |
what: something, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns break.rules | |
(:require [ame.entities.sets :as ent-sets] | |
[ame.input :as input]) | |
(:use [ame.util :only [contains-all? +-when]])) | |
(input/define :up :vk-w :vk-up) | |
(input/define :down :vk-s :vk-down) | |
(input/define :left :vk-a :vk-left) | |
(input/define :right :vk-d :vk-right) |