Skip to content

Instantly share code, notes, and snippets.

View ponzao's full-sized avatar

Vesa Marttila ponzao

  • Helsinki, Finland
View GitHub Profile
@yogthos
yogthos / gist:506564
Created August 3, 2010 15:36
tetris in Clojure
(ns tetris
(:import
(javax.swing JFrame)
(java.awt Canvas Graphics Color Toolkit)
(java.awt.event ActionListener KeyListener KeyEvent))
(:gen-class))
(def *cols* 10)
(def *rows* 20)
(def *width* 300)
(comment "
SpeedNotes Clojure script, by Torbjørn Marø.
Version 1.1 - 2010.08.18
Clojure version 1.1 (w/Contrib)
======================================================================
Always have it running in a console window to quickly note down stuff
you need to remember - thoughts and ideas you don't want to loose,
but don't want to steal focus away from what you are currently doing
either.
@fcalderan
fcalderan / inception-javascript.js
Created November 2, 2010 09:42
inception explained as a 4 nested javascript closures
/*
* Fabrizio Calderan, twitter @fcalderan, 2010.11.02
* I had an idea: could Inception movie be explained by a few javascript closures
* and variable resolution scope (just for fun)?
*
* Activate javascript console =)
*/
<script>
console.group("inception movie");
@netzpirat
netzpirat / 0_README.md
Created November 12, 2010 10:42
Continuous CoffeeScript testing with Guard and Jasmine

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@stevedonovan
stevedonovan / StringAccessor.lua
Created December 20, 2010 08:38
A Lua class for accessing individual characters in a string
--[[ Example:
sa = StringAccessor 'hello'
for c in sa:iter() do
print(c)
end
print(sa[1],sa[3])
print('end',sa[-1])
--]]
@ayourtch
ayourtch / gist:752460
Created December 23, 2010 02:19
Programming Challange from Erann Gat
-- Andrew Yourtchenko - Programming Challange from Erann Gat:
-- http://www.flownet.com/ron/papers/lisp-java/
-- Given a list of words and a list of phone numbers, find all the ways that
-- each phone number can be expressed as a list of words.
-- No batteries included. We have to define our own split() function.
function string:split(sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
; The New Year in Snowflakes
; A Clojure doodle by Chouser
(import '(java.awt Color Graphics Frame RenderingHints))
(defonce draw-agent (agent nil))
(defonce halt (atom false))
(defmacro ui-thread [& body]
`(javax.swing.SwingUtilities/invokeAndWait (fn [] ~@body)))
@weavejester
weavejester / gist:1001206
Created May 31, 2011 20:27
Clojure on Heroku
~/$ lein new ring-on-heroku
Created new project in: /home/jim/Development/ring-on-heroku
~/$ cd ring-on-heroku
~/ring-on-heroku$ echo 'web: lein run -m ring-on-heroku.core' > Procfile
~/ring-on-heroku$ cat > src/ring_on_heroku/core.clj
(ns ring-on-heroku.core
(:use ring.util.response
ring.adapter.jetty))
(defn app [req]
@alandipert
alandipert / fb.clj
Last active December 20, 2017 03:17
FizzBuzz, the fib of pattern matching
;; FizzBuzz, the fib of pattern matching
;; with https://github.com/clojure/core.match
(require '[clojure.core.match :refer [match]])
(doseq [n (range 1 101)]
(println (match [(mod n 3) (mod n 5)]
[0 0] "FizzBuzz"
[0 _] "Fizz"
[_ 0] "Buzz"
@alexander-yakushev
alexander-yakushev / tetris.clj
Created September 10, 2011 00:28
Tetris implementation in Clojure
(ns tetris.core
(:import (java.awt Color Dimension BorderLayout)
(javax.swing JPanel JFrame JOptionPane JButton JLabel)
(java.awt.event KeyListener))
(:use clojure.contrib.import-static deflayout.core
clojure.contrib.swing-utils)
(:gen-class))
(import-static java.awt.event.KeyEvent VK_LEFT VK_RIGHT VK_DOWN VK_UP VK_SPACE)