Skip to content

Instantly share code, notes, and snippets.

(declaim (optimize (speed 3) (debug 0) (space 0) (safety 0)))
(defun build-btree (item depth)
(declare (fixnum item depth))
(if (zerop depth) (list item)
(let ((item2 (+ item item))
(depth-1 (1- depth)))
(declare (fixnum item2 depth-1))
(cons item
(cons (build-btree (the fixnum (1- item2)) depth-1)
@lxmonk
lxmonk / ml.pyx
Created September 1, 2012 07:46
the file ml.pyx from the easy-first parser
## Copyright 2010 Yoav Goldberg
##
## This file is part of easyfirst
##
## easyfirst is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## easyfirst is distributed in the hope that it will be useful,
@lxmonk
lxmonk / easyfirst.py
Created August 25, 2012 15:48
easyfirst parser by Yoav Goldberg
## Copyright 2010 Yoav Goldberg
##
## This file is part of easyfirst
##
## easyfirst is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## easyfirst is distributed in the hope that it will be useful,
@lxmonk
lxmonk / session.py
Created June 10, 2012 07:11
session.ipy
# this is an Ipython session (http://ipython.org/)
%run code/hw2.py
# generating the scatter plot for generateDataset(50,sin,0.03):
from numpy import sin; import pylab
data = generateDataset(50,sin,0.03)
scatter(data[0],data[1], marker='+', facecolor='g')
grid()
@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
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 = ""
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
@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 ()
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 / 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