This file contains 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 mmap | |
import posix_ipc | |
import os | |
import sys | |
def create_shared_mem(sm_name, size): | |
sm = posix_ipc.SharedMemory(sm_name, flags=posix_ipc.O_CREX, size=size) | |
return mmap.mmap(sm.fd, sm.size) | |
def open_shared_mem(sm_name): |
This file contains 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
class term(object): | |
def __init__(self,**args): | |
for k in self.vals: | |
self.__setattr__(k,args[k]) | |
def __str__(self): | |
return self.__class__.__name__+"("+(", ".join([k+'='+str(self.__getattribute__(k)) for k in self.vals]))+")" | |
class const(term): vals = ['val'] | |
class add(term): vals = ['e1', 'e2'] | |
class let(term): vals = ['name','exp', 'body'] |
This file contains 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 urllib2 as u | |
import BeautifulSoup as bs | |
url='https://www.fourmilab.ch/cgi-bin/Hotbits?nbytes=128&fmt=hex&npass=1&lpass=8&pwtype=3' | |
print bs.BeautifulSoup(u.urlopen(url).read()).body.pre.text |
This file contains 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
(* Coq proof that "less than" is well-founded *) | |
Require Le. | |
Lemma well_founded_lt : well_founded lt. | |
Proof. | |
intro a. | |
induction a; | |
constructor; | |
intros y H. |
This file contains 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
#!/usr/bin/env python | |
# Plot a graph of Data which is comming in on the fly | |
# uses pylab | |
# Author: Norbert Feurle | |
# Date: 12.1.2012 | |
# License: if you get any profit from this then please share it with me | |
import pylab | |
from pylab import * | |
xAchse=pylab.arange(0,100,1) |
This file contains 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
# Lars.Rasmusson@gmail.com, 2015-03-03 | |
# Using llvmlite from https://github.com/numba/llvmlite branch llvm3.6 | |
# and llvm from http://llvm.org/git/llvm.git branch release_36 | |
# and clang from http://llvm.org/git/clang.git branch release_36 | |
# (when building llvmlite, I had to remove -flto in ffi/Makefile.linux | |
# because I was lazy and ld-gold was not setup correctly on my machine) | |
from llvmlite import binding as llvm | |
from llvmlite.llvmpy import core as llvmpy |
This file contains 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
# -*- coding: utf-8 -*- | |
""" | |
John McCarthy, who discovered Lisp, attributes this puzzle to Hans Freudenthal: | |
We pick two numbers a and b, so that 99 ≥ a ≥ b ≥ 2. | |
We tell Mr. P. the product a × b and Mr. S. the sum a + b. | |
Then Mr. S. and Mr. P. engage in the following dialog: | |
Mr. P.: I don’t know the numbers. |
This file contains 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 os | |
def headerconstant(includefiles,name): | |
w,r = w,r=os.popen2("rm -f prog; gcc -x c -o prog -") | |
includes="\n".join(["#include <%s>"%x for x in includefiles]) | |
s = ("""\ | |
#include <stdio.h> | |
%s | |
int main() { | |
printf("%%ld", (long)%s); |
This file contains 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
game = """ | |
. . . . . . 9 . . | |
7 . . 9 . . . 3 . | |
. . . . 3 . 1 . 7 | |
. . . . . . . . . | |
4 . 3 1 . . 2 5 . | |
. . 6 . . . . . . |
This file contains 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 ctypes | |
class Tspi: | |
def __init__(self): | |
self.hContext = ctypes.c_uint32(0) | |
self.tspi = ctypes.CDLL('libtspi.so.1') | |
e = self.tspi.Tspi_Context_Create(ctypes.pointer(self.hContext)) | |
assert e==0,'Error: %x' % e | |
def err(self,e): |
OlderNewer