Skip to content

Instantly share code, notes, and snippets.

(defn lpf
[num]
(loop [div 2 lim num]
(cond
(< (/ lim div) 1) (do (println (str "Returning: " (dec div))) (dec div))
(= (rem lim div) 0) (do (println (str "Recurring:(frm match) " (inc div) " " (/ lim div)))(recur (inc div) (/ lim div)))
:else (do(println (str "Recurring:(frm else) " (inc div)" " lim))(recur (inc div) lim)))))
import java.net.*;
import java.io.*;
import java.util.*;
public class NetTest {
public static void main (String[] args) throws Exception{
String host = "acidrayne.net";
String pingResult = "";
try {
Runtime r = Runtime.getRuntime();
(ns ClojMidi
(:import (javax.sound.midi MidiSystem)))
(def channels (.getChannels (doto (MidiSystem/getSynthesizer) (.open))))
(defn play-note [pitch velocity time]
(.noteOn (first channels) pitch velocity)
(Thread/sleep time)
(.noteOff (first channels) pitch velocity))
@erik
erik / gist:478579
Created July 16, 2010 16:27
lol, efficiency
lispr> (time (range 1 100))
Evaluation took 0.23898 seconds
=> (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99)
lispr> (time (reduce + 0 (range 1 100)))
Evaluation took 52.748472 seconds
=> 4950
; block at: 0x885f028
; 20 registers
; constants (3)
0: (number) 1.000000
1: (number) 2.000000
2: (bool) false
; strings (2)
0: "a string"
1: "another string"
; locals (3)
~/Programming/C/bijou$ ./bijouc sample/function.s && ./bijou -d b.out
; block at: 0x8727198, (level 0)
; 1 registers
; constants (2)
0: (number) 0.000000
1: (null) NULL
; locals (0)
; upvals (0)
; code section (2 instructions)
loadk 0 0 ; R[0] = K[0]
~/Programming/C/bijou$ time ruby -e 'puts "A String!"'
A String!
real 0m0.009s
user 0m0.004s
sys 0m0.004s
~/Programming/C/bijou$ time python -c 'print("A String!")'
A String!
~/Programming/C/bijou$ (./bijouc sample/net.s && ./bijou -l lib/net.so b.out)
:calvino.freenode.net NOTICE * :*** Looking up your hostname...
:calvino.freenode.net NOTICE * :*** Checking Ident
:calvino.freenode.net NOTICE * :*** Found your hostname
:calvino.freenode.net NOTICE * :*** No Ident response
ERROR :Closing Link: 127.0.0.1 (Connection timed out)
(defplugin
(:bf
"Executes brainfuck."
["bf"]
[{:keys [irc bot channel args]}]
(let [[bf & input] args]
(doseq [x (-> bf
(compile-and-run input)
with-out-str
(#(.split % "\n")))]
@erik
erik / gost
Created August 26, 2010 23:40 — forked from Raynes/gost
src/sexpbot/plugins/brainfuck.clj | 4 +-
src/sexpbot/plugins/dynamic.clj | 6 ++--
src/sexpbot/plugins/eball.clj | 4 +-
src/sexpbot/plugins/fortune.clj | 16 ++++----
src/sexpbot/plugins/git.clj | 4 +-
src/sexpbot/plugins/google.clj | 6 ++--
src/sexpbot/plugins/leet.clj | 4 +-
src/sexpbot/plugins/lmgtfy.clj | 8 ++--
src/sexpbot/plugins/utils.clj | 72 ++++++++++++++++++------------------
src/sexpbot/plugins/weather.clj | 10 +++---