Skip to content

Instantly share code, notes, and snippets.

;; http://rosettacode.org/wiki/Averages/Pythagorean_means
;; according to the python solution.
(use '[clojure.contrib.math :only (expt)])
(defn a-mean [coll]
(/ (reduce + coll) (count coll)))
(defn g-mean [coll]
(expt (reduce * coll) (/ (count coll))))
Status: Connecting to nhydra.birc.pitt.edu:33...
Response: fzSftp started
Command: open "marlene@nhydra.birc.pitt.edu" 33
Error: Connection timed out
Error: Could not connect to server
protected MyObject overlapSearch(Comparable start,Comparable end) {
MyObject leftSubTreeOverlap, rightSubTreeOverlap;
leftSubTreeOverlap = rightSubTreeOverlap = null;
if (this.getData().overlap(start, end)) {
return this.getData();
}
else if ((((Integer) this.getData().getKeyData()).compareTo((Integer) end) <= 0)
&& (this.getRight() != null)) {
rightSubTreeOverlap = this.getRight().overlapSearch(start, end);
return rightSubTreeOverlap;
@lxmonk
lxmonk / gist:1134231
Created August 9, 2011 14:44
logfile
Tue Aug 9 15:01:00 IDT 2011
--------- beginning of /dev/log/system
I/Vold ( 1920): Vold 2.1 (the revenge) firing up
D/Vold ( 1920): usb_configuration switch is not enabled in the kernel
D/Vold ( 1920): Volume sdcard state changing -1 (Initializing) -> 0 (No-Media)
D/Vold ( 1920): Volume sdcard state changing 0 (No-Media) -> 2 (Pending)
D/Vold ( 1920): Volume sdcard state changing 2 (Pending) -> 1 (Idle-Unmounted)
I/SystemServer( 2138): Entered the Android system server!
I/SystemServer( 2138): Entropy Service
I/SystemServer( 2138): Power Manager
@lxmonk
lxmonk / gist:1134269
Created August 9, 2011 14:57
short log
V/WifiStateTracker( 2138): New network state is CONNECTED
D/WifiStateTracker( 2138): DHCP renewal started
I/ActivityThread( 2827): Pub call_log: com.android.providers.contacts.CallLogProvider
I/ActivityManager( 2138): No longer want com.cyanogenmod.cmparts (pid 2671): hidden #16
D/dalvikvm( 2827): GC_CONCURRENT freed 161K, 48% free 2965K/5639K, external 0K/0K, paused 6ms+2ms
D/GTalkService( 2271): [GTalkConnection.25] EVENT_REQUEST_ROSTER: not connected
D/szipinf ( 2827): Initializing inflate state
D/szipinf ( 2827): Initializing inflate state
D/szipinf ( 2827): Initializing inflate state
D/szipinf ( 2827): Initializing inflate state
Debugger entered--Lisp error: (error "Python: Emacs: \"(error \\\"Key sequence C-x p k starts with non-prefix key C-x p\\\")\"
")
signal(error ("Python: Emacs: \"(error \\\"Key sequence C-x p k starts with non-prefix key C-x p\\\")\"\n"))
pymacs-report-error("Python: %s" "Emacs: \"(error \\\"Key sequence C-x p k starts with non-prefix key C-x p\\\")\"\n")
(if success (pymacs-report-error "Python: %s" value) (pymacs-report-error "%s" value))
(cond ((eq action (quote eval)) (if success (setq action "return" inserter (\` (pymacs-print-for-eval (quote (\, value))))) (setq action "raise" inserter (\` (let ((pymacs-forget-mutability t)) (pymacs-print-for-eval (\, value))))))) ((eq action (quote expand)) (if success (setq action "return" inserter (\` (let ((pymacs-forget-mutability t)) (pymacs-print-for-eval (\, value))))) (setq action "raise" inserter (\` (let ((pymacs-forget-mutability t)) (pymacs-print-for-eval (\, value))))))) ((eq action (quote return)) (if success (setq done t) (pymacs-report-error "%s
@lxmonk
lxmonk / WHY???
Created December 31, 2011 17:31
the repl is not pure!!
> (define last-pair
(lambda (x)
(if (null? (cdr x)) x
(last-pair (cdr x)))))
> (last-pair '(a b c d e))
(e)
> (define foo
(lambda ()
In toplevel form:
url/url.el:166:1:Error: No setf-method known for url-use-cookies
make[2]: *** [url/url.elc] Error 1
make[2]: Leaving directory `/home/lxmonk/git/emacs/lisp'
make[1]: *** [compile-main] Error 2
make[1]: Leaving directory `/home/lxmonk/git/emacs/lisp'
make: *** [lisp] Error 2
from cPickle import dump
import justext
import nltk
import requests
from google import search
def main():
pages_used = 0
for url in search('aeron chair', stop=30):
text = ""
@lxmonk
lxmonk / hw2.py
Created June 10, 2012 07:06
hw2.py
def generateDataset(N, f, sigma):
"""
The function generateDataset(N, f, sigma) should return a tuple
with the 2 vectors x and t. for example:
ti = y(xi) + Normal(mu, sigma)
# where the xi values are equi-distant on the [0,1] segment (that
is, x1 = 0, x2=1/N-1, x3=2/N-1..., xN = 1.0)
mu = 0.0
sigma = 0.03