This file contains hidden or 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
| (define (make-simple-generator iterable transformer) | |
| (define (re-entry return) | |
| (define (iter-action element) | |
| (define (escaper new-re-entry) | |
| (set! re-entry new-re-entry) | |
| (return ( transformer element))) | |
| (call-with-current-continuation escaper)) | |
| (for-each iter-action iterable) | |
| (return 'Let-it-end!)) | |
This file contains hidden or 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
| // | |
| // by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
| // MIT Style License | |
| // see also: http://wiki.ecmascript.org/doku.php?id=strawman:iterators | |
| // | |
| // --------------------------------------- | |
| // 1. Iteration via for-in loop | |
| // --------------------------------------- |
This file contains hidden or 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
| if RUBY_ENGINE == 'macruby' | |
| framework 'CoreServices' | |
| WATCHED_EXTS = "rb,builder,erb,nokogiri" | |
| PASSENGER_RESTART_FILE = File.expand_path(File.join(File.dirname(__FILE__), "..", "tmp", "restart.txt")) | |
| DELAY = 3 | |
| def modified_files(path) | |
| Dir.glob("#{File.expand_path(path)}/*.{#{WATCHED_EXTS}}").map do |filename| | |
| begin |
This file contains hidden or 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
| #### Monad - common code | |
| # bind takes a step and processor, | |
| # and combines them into a step | |
| # (S t) -> (t -> S u) -> (S u) | |
| bind = (step, processor) -> (container) -> | |
| result = step container | |
| (processor result.value) result.container | |
This file contains hidden or 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 logic.y | |
| (:refer-clojure :exclude [== reify inc]) | |
| (:use [clojure.core.logic minikanren prelude | |
| nonrel match])) | |
| (defna findo [x l o] | |
| ([_ [[?y :- o] . _] _] | |
| (project [x ?y] (== (= x ?y) true))) | |
| ([_ [_ . ?c] _] (findo x ?c o))) |
This file contains hidden or 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
| virtualenv --no-site-packages . | |
| source bin/activate | |
| bin/pip install Django psycopg2 django-sentry | |
| bin/pip freeze > requirements.txt | |
| bin/django-admin.py startproject mysite | |
| cat >.gitignore <<EOF | |
| bin/ | |
| include/ | |
| lib/ | |
| EOF |
This file contains hidden or 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
| $ bin/rbx compile -e 'def m(a) p a end' -B -N m | |
| ================== :m ================== | |
| Arguments: 1 required, 1 total | |
| Locals: 1: a | |
| Stack size: 3 | |
| Lines to IP: 1: -1..7 | |
| 0000: push_self | |
| 0001: push_local 0 # a |
This file contains hidden or 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 getDominantColor(aImg) { | |
| let canvas = document.createElement("canvas"); | |
| canvas.height = aImg.height; | |
| canvas.width = aImg.width; | |
| let context = canvas.getContext("2d"); | |
| context.drawImage(aImg, 0, 0); | |
| // keep track of how many times a color appears in the image | |
| let colorCount = {}; |
This file contains hidden or 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
| package ca.jbrains.junit; | |
| import static org.junit.Assert.assertTrue; | |
| import java.util.ArrayList; | |
| import java.util.LinkedList; | |
| import java.util.List; | |
| import org.junit.Test; |
This file contains hidden or 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 ded | |
| "Structural Data EDitor for Clojure with zippers. Inspired by Interlisp: http://larry.masinter.net/interlisp-ieee.pdf" | |
| (:require [clojure.zip :as z]) | |
| (:use [clojure.pprint :only (with-pprint-dispatch code-dispatch pprint)] | |
| [clojure.repl :only (source-fn)])) | |
| (defn print-hr | |
| "Prints 30 dashes and a newline." | |
| [c] | |
| (println (apply str (repeat 30 c)))) |