Skip to content

Instantly share code, notes, and snippets.

View huitseeker's full-sized avatar

François Garillot huitseeker

View GitHub Profile
@huitseeker
huitseeker / comparebooks.py
Created December 28, 2010 14:03
{Chrome bookmarks} \ {Delicious bookmarks}
#!/usr/bin/python
#######################################################################
# This program 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 2 of the #
# License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
@huitseeker
huitseeker / mindeps.py
Created December 28, 2010 19:10
Minimizes a list of debian packages by removing those implied as dependencies of the others
#!/usr/bin/python
#######################################################################
# This program 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 2 of the #
# License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
@huitseeker
huitseeker / bookmooch_clear_save.py
Created January 7, 2011 17:34
Empty your save-for-later list on bookmooch
#!/usr/bin/python
import re
import mechanize
myuser = ""
mypassword = ""
br = mechanize.Browser()
br.add_password("http://bookmooch.com",myuser, mypassword)
br.set_handle_robots(False)
@huitseeker
huitseeker / awspages.py
Created January 28, 2011 20:37
Amazon AWS search for books less than 150 pages in the operating systems category
import ecs
ecs.setLicenseKey('FILLLICENSEKEYHERE')
ecs.setSecretAccessKey('FILLSACCESSKEYHERE')
ecs.setLocale('us')
# O.S. books : node 3756
ecssearch = ecs.ItemSearch('', SearchIndex='Books',
ResponseGroup='Medium',BrowseNode='3756')
for i in range (1,100):
try:
if (int(ecssearch[i].NumberOfPages) < 150):
@huitseeker
huitseeker / prime_dvd_bin_exp,v
Created April 29, 2011 16:24
Ideas about generalizing prime_dvd_bin
Lemma ltn_pfactor : forall n k p, prime p -> 0 < k < p^n -> logn p k < n.
Proof.
move=> n k p p_pr; case/andP=> k_gt0 ltn_k_pn.
by rewrite ltnNge -(pfactor_dvdn n p_pr k_gt0) (gtnNdvd k_gt0 ltn_k_pn).
Qed.
Lemma primek_dvd_bin : forall n k p, prime p -> 0 < k < p^n -> p %| 'C(p^n, k).
Proof.
move=> n k p p_pr gt0kpn; case/andP: (gt0kpn)=> k_gt0 lt_k_pn.
have def_pn := ltn_predK lt_k_pn; have logpk_ltn := (ltn_pfactor p_pr gt0kpn).
@huitseeker
huitseeker / karatsuba.py
Created August 14, 2011 22:30
Karatsuba with strings
import string
# http://stackoverflow.com/questions/2267362/convert-integer-to-a-string-in-a-given-numeric-base-in-python/2267446#2267446
digs = string.digits + string.lowercase
def int2base(x, base):
if x < 0: sign = -1
elif x==0: return '0'
else: sign = 1
x *= sign
digits = []
@huitseeker
huitseeker / mergebench.py
Created August 15, 2011 11:27
Merge sort benches
import timeit
def badmergeSort(array):
if len(array) <= 1:
return array
else:
left = array[:len(array)/2]
right = array[len(array)/2:]
return badmerge(badmergeSort(left),badmergeSort(right))
@huitseeker
huitseeker / recstream.scala
Created January 1, 2012 22:44
Every single freshman CS question in ˜80 lines of Scala
import Stream._
object Curryfication {
def curry [A,B,C](f:Pair[A,B] ⇒ C) = (x:A) ⇒ (y:B) ⇒ f (x,y)
def uncurry [A,B,C](f: A ⇒ B ⇒ C) = (x:Pair[A,B]) ⇒ f (x._1) (x._2)
}
trait Curried[S,R] {
type Fun
def curry : (S ⇒ R) ⇒ Fun
@huitseeker
huitseeker / insynthcompillog.txt
Created January 29, 2013 16:31
Compilation log of Insynth in Scala 2.10.1-SNAPSHOT
[INFO] Scanning for projects...
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[INFO] Computing target platform for MavenProject: ch.epfl:ch.epfl.insynth:1.0.0 @ /home/huitseeker/Scala/insynth/ch.epfl.insynth.build/ch.epfl.insynth/pom.xml
[INFO] Adding repository http://download.scala-ide.org/nightly-update-master-trunk
[INFO] Adding repository http://download.scala-ide.org/nightly-update-master-trunk
[INFO] Fetching p2.index (0B of 96B at 0B/s) from http://download.eclipse.org/releases/indigo/
@huitseeker
huitseeker / insynth_issue.txt
Created January 30, 2013 07:50
Insynth Issue log
huitseeker➜Scala/insynth/ch.epfl.insynth.build(issue10✗)» mvn -Dscala.version=2.10.1-SNAPSHOT -Pscala-ide-master-scala-trunk -DtestClassArg=ch.epfl.insynth.test.completion.InSynthCompletionTests clean install
[INFO] Scanning for projects...
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[INFO] Computing target platform for MavenProject: ch.epfl:ch.epfl.insynth:1.0.0 @ /home/huitseeker/Scala/insynth/ch.epfl.insynth.build/ch.epfl.insynth/pom.xml
[INFO] Adding repository http://download.scala-ide.org/nightly-update-master-trunk