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
import trio | |
async def sleeper(): | |
try: | |
await trio.sleep(30) | |
except KeyboardInterrupt: | |
print("KBInterrupt") | |
async def test(): | |
with trio.open_cancel_scope() as cancel_scope: |
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
(use '[clojure.walk :only [walk]]) | |
(def ^:dynamic ^:private *frame*) | |
(defn- new-frame [] (atom {})) | |
(defn- collect-frame [ast] | |
(case (:op ast) | |
:constant | |
{:constants [{:value (:form ast)}]} |
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
(use 'clojure.java.io) | |
(def string-url "http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html") | |
(defonce text (let [writer (java.io.StringWriter.)] | |
(copy (-> (java.net.URL. url) .openStream) writer) writer)) | |
(defonce jdoc-pattern #"(?s)<A NAME=\"(\w*)\((.*?)\).*?</A>.*?<PRE>(.*?)</PRE>(.*?)<HR>") | |
(def html-entities |
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
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); | |
gtk_widget_show(offscreenWindow); | |
force_draw(widget); |
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
(defprotocol Base | |
(test-foo [o])) | |
(deftype Impl [] | |
Base | |
(test-foo [_] "test")) | |
(defprotocol Base) | |
(defprotocol Base |
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
(defmulti url (fn [key &_] key)) | |
(defmethod url :username [_ user] (str "/" user)) | |
(defmethod url :home [_ _] "/") | |
(defmethod url :item [_ item] (str "/media/" item)) |
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
(doto (javax.swing.JFrame.) | |
(.setSize 100 100) | |
(.addKeyListener (proxy [java.awt.event.KeyAdapter] [] (keyPressed [e] (println "hello")))) | |
(.setVisible true)) |
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
; Also need to add (java.io StringReader) to :import at the top of the file | |
(defn- eval-opt | |
"Evals expressions in str, prints each non-nil result using prn" | |
[str] | |
(let [eof (Object.) | |
reader (LineNumberingPushbackReader. (StringReader. str))] | |
(loop [input (read reader false eof)] | |
(when-not (= input eof) | |
(let [value (eval input)] |
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 leiningen.repl | |
"Starts a REPL using the project's classpath." | |
(:use [leiningen.compile :only [eval-in-project find-lib-jars]]) | |
(:require [clojure.main]) | |
(:import [java.net URL URLClassLoader] | |
[java.io File FilenameFilter])) | |
(def *project*) | |
(def *classpath*) |
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
(defn files-in-dir | |
([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)))) |
NewerOlder