Skip to content

Instantly share code, notes, and snippets.

View flashingpumpkin's full-sized avatar
🏠
Working from home

Alen Mujezinovic flashingpumpkin

🏠
Working from home
View GitHub Profile
@flashingpumpkin
flashingpumpkin / debug.clj
Created December 27, 2011 00:39 — forked from ato/debug.clj
Simpler debug-repl that works with unmodified Clojure
;; Inspired by George Jahad's version: http://georgejahad.com/clojure/debug-repl.html
(defmacro local-bindings
"Produces a map of the names of local bindings to their values."
[]
(let [symbols (map key @clojure.lang.Compiler/LOCAL_ENV)]
(zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols)))
(declare *locals*)
(defn eval-with-locals
@flashingpumpkin
flashingpumpkin / ants.clj
Created December 27, 2011 18:00 — forked from michiakig/ants.clj
Clojure ant sim from Rich Hickey
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
; which can be found in the file CPL.TXT at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
;dimensions of square world
@flashingpumpkin
flashingpumpkin / importer.clj
Created January 5, 2012 21:42
Importing static methods / fields into defns and defs
(ns gltut.importer
(:import [java.lang.reflect Method Field]))
(defn get-methods
"Return all the methods on a class"
[#^Class cls]
(into [] (. cls getMethods)))
(defn get-fields
"Return all the fields on a class"
; A set of functions that generates Clojure code which in turn imports
; static methods from a class. Depends on importer.clj
(ns gltut.macro-generator
(:use [gltut.importer])
(:require [clojure.string :as s]
[clojure.java.io :as io])
(:import [org.lwjgl.opengl GL11 GL12 GL13 GL14 GL15 GL20 GL21 GL30 GL31 GL32
GL33 GL40 ]))
@flashingpumpkin
flashingpumpkin / glapi.clj
Created January 6, 2012 01:22
The LWJGL API wrapped in Clojure
; Depends on importer.clj
(ns gltut.glapi (:use [gltut.importer]))
(import-method org.lwjgl.opengl.GL11 glArrayElement gl-array-element)
(import-method org.lwjgl.opengl.GL11 glLineStipple gl-line-stipple)
(import-method org.lwjgl.opengl.GL11 glDrawArrays gl-draw-arrays)
(import-method org.lwjgl.opengl.GL11 glDrawElements gl-draw-elements)
(import-method org.lwjgl.opengl.GL11 glBlendFunc gl-blend-func)
(import-method org.lwjgl.opengl.GL11 glDrawPixels gl-draw-pixels)
// @name HN Black Font
// @description Make text black on HN
// @homepage https://gist.github.com/1600378/
// @match https://news.ycombinator.com/*
// @match http://news.ycombinator.com/*
// @run-at document-start
(function() {
var css, head, node;
css = "td { color: #000000; }";
// @name Gumtree location folder
// @description Unfold the location navigation on gumtree
// @match http://www.gumtree.com/*
// @run-at document-start
(function() {
var css, head, node;
css = "#location-tree { display: block !important; } .expandable-tree {visibility: visible !important;}";
try {
head = document.getElementsByTagName("head")[0];
@flashingpumpkin
flashingpumpkin / gist:1684093
Created January 26, 2012 18:06 — forked from leafo/gist:1683661
screenshot sharing
#!/bin/bash
scrot '%Y-%m-%d_%H-%M-%S.png' -s -e 'scp $f [email protected]:www/shotsnb;echo -n "http://leafo.net/shotsnb/$f" | xclip; rm $f'
notify-send -u normal -t 1000 'Screenshot Ready'
@flashingpumpkin
flashingpumpkin / coroutine.py
Created March 1, 2012 16:55
Decorator for coroutine usage.
def coroutine(func):
"""
A decorator that turns a function with normal input into a coroutine.
This decorator takes care of priming the coroutine, doing the looping and
handling the closing.
The first argument of any decorated function is what was received when
data was sent to the coroutine via the ``.send`` method. All the other
``*args`` and ``**kwargs`` are what was passed to the decorated function
when instantiating the coroutine.
@flashingpumpkin
flashingpumpkin / hack.sh
Created March 31, 2012 16:10 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#