Skip to content

Instantly share code, notes, and snippets.

View gist:fac512ac534cefc7ab4ae5421e4d4917
import trio
async def sleeper():
await trio.sleep(30)
except KeyboardInterrupt:
async def test():
with trio.open_cancel_scope() as cancel_scope:
remleduff / gist:1876575
Created Feb 21, 2012
Simplified AST processing code from CinC
View gist:1876575
(use '[clojure.walk :only [walk]])
(def ^:dynamic ^:private *frame*)
(defn- new-frame [] (atom {}))
(defn- collect-frame [ast]
(case (:op ast)
{:constants [{:value (:form ast)}]}
View gist:415019
(use '
(def string-url "")
(defonce text (let [writer (]
(copy (-> ( url) .openStream) writer) writer))
(defonce jdoc-pattern #"(?s)<A NAME=\"(\w*)\((.*?)\).*?</A>.*?<PRE>(.*?)</PRE>(.*?)<HR>")
(def html-entities
View gist:414786
GtkOffscreenWindow* offscreenWindow;
GtkPixmap* snapshotWidget(GtkWidget* widget) {
// Caching doesn't work, must create a new one every time (the widget parameter is gtk_widget_destroy'ed by the caller)
// if (!offscreenWindow)
offscreenWindow = gtk_offscreen_window_new();
gtk_container_add(offscreenWindow, widget);
View gist:410416
(defprotocol Base
(test-foo [o]))
(deftype Impl []
(test-foo [_] "test"))
(defprotocol Base)
(defprotocol Base
View gist:388872
(defmulti url (fn [key &_] key))
(defmethod url :username [_ user] (str "/" user))
(defmethod url :home [_ _] "/")
(defmethod url :item [_ item] (str "/media/" item))
View gist:387448
(doto (javax.swing.JFrame.)
(.setSize 100 100)
(.addKeyListener (proxy [java.awt.event.KeyAdapter] [] (keyPressed [e] (println "hello"))))
(.setVisible true))
View Fixed main.clj
; Also need to add ( StringReader) to :import at the top of the file
(defn- eval-opt
"Evals expressions in str, prints each non-nil result using prn"
(let [eof (Object.)
reader (LineNumberingPushbackReader. (StringReader. str))]
(loop [input (read reader false eof)]
(when-not (= input eof)
(let [value (eval input)]
View gist:336731
(ns leiningen.repl
"Starts a REPL using the project's classpath."
(:use [leiningen.compile :only [eval-in-project find-lib-jars]])
(:require [clojure.main])
(:import [ URL URLClassLoader]
[ File FilenameFilter]))
(def *project*)
(def *classpath*)
View gist:336602
(defn files-in-dir
(let [dirFile (File. dir)]
(.list dirFile)))
([dir suffix]
(let [dirFile (File. dir)
fileFilter (proxy [FilenameFilter] []
(accept [dir name] (.endsWith name suffix)))]
(.list dirFile fileFilter))))
You can’t perform that action at this time.