Skip to content

Instantly share code, notes, and snippets.

View apg's full-sized avatar
🐢
Turtle

Andrew Gwozdziewycz apg

🐢
Turtle
View GitHub Profile
@apg
apg / core.clj
Created August 24, 2010 11:37
selector for hiccup
(defn hiccup-zip
"Returns a zipper for hiccup"
[root]
(zip/zipper
; branch?
(fn [x] (and (vector? x)
(not (empty? x))
(keyword? (first x))))
; children
(fn [x]
(defun let-me-google-that-for-you (beg end)
(interactive "r")
(kill-new (format "http://lmgtfy.com/?q=%s" (url-hexify-string (buffer-substring beg end)))))
;;; thumb-through.el --- Plain text reader of HTML documents
;; Copyright (C) 2010 Andrew Gwozdziewycz <git@apgwoz.com>
;; Version: 0.1
;; Keywords: html
;; This file is NOT part of GNU Emacs
;; This is free software; you can redistribute it and/or modify it under
@apg
apg / syl.py
Created September 2, 2010 13:03
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Lingua::EN::Syllable::syllable() estimates the number of syllables in
the word passed to it.
Note that it isn't entirely accurate... it fails (by one syllable) for
about 10-15% of my /usr/dict/words. The only way to get a 100% accurate
count is to do a dictionary lookup, so this is a small and fast alternative
where more-or-less accurate results will suffice, such as estimating the
@apg
apg / haiku.el
Created September 2, 2010 14:48
;; Lingua::EN::Syllable::syllable() estimates the number of syllables in
;; the word passed to it.
;; Note that it isn't entirely accurate... it fails (by one syllable) for
;; about 10-15% of my /usr/dict/words. The only way to get a 100% accurate
;; count is to do a dictionary lookup, so this is a small and fast alternative
;; where more-or-less accurate results will suffice, such as estimating the
;; reading level of a document.
;; I welcome pointers to more accurate algorithms, since this one is
@apg
apg / life.clj
Created September 8, 2010 10:38
game of life
;;;; Conway's game of life
;;; certainly not the best implementation, but it works...
(ns life.core
(:import (java.awt Color Dimension)
(javax.swing JPanel JFrame Timer JOptionPane)
(java.awt.event ActionListener KeyListener)))
(def width 50)
(def height 50)
@apg
apg / core.clj
Created September 10, 2010 22:32
same-game functional merge board-left
(ns dummy.core
:use [[clojure.contrib.seq-utils :only [indexed]]])
(defn find-all
[coll x]
(keep-indexed #(if (= x %2) %1) coll))
(defn merge-left-row [coll idx]
(let [front (map second
(filter #(not (contains? idx (first %)))
(ns samegame
(:use [clojure.set :only (union)]
[clojure.contrib.math :only (floor)]
[clojure.contrib.seq-utils :only (indexed)])
(:import (java.awt Color Dimension)
(javax.swing JPanel JFrame Timer JOptionPane)
(java.awt.event ActionListener KeyListener MouseListener)))
(def colors [(Color. 255 0 0) (Color. 0 255 0) (Color. 0 0 255)])
(def blank-color (Color. 0 0 0))
By Shriram Krishnamurthi
Posted to comp.lang.scheme on January 17, 1996, for Scheme's twentieth
birthday:
((I m a g i n e)
(shriram@cs.rice.edu)
(((Imagine there's no FORTRAN)
(It's easy if you try)
(No SML below us) (Above us only Y)
One day I got bored of Java. So I learned a little Lisp and what I
found was a surprise (the land of lisp): It is the language so unique
and so expressive, so that coding never looks the same within my eyes.
Now I eat parentheses for breakfast. And if my program isn't done, I
eat parentheses for lunch (the land of lisp). They might look funny
but they have semantic power, that gives your program lots of brevity
and punch!
Simple but refined guaranteed to blow your mind (the land of lisp).
Minimal and sleek, but still so clever you will freak (the land of