Skip to content

Instantly share code, notes, and snippets.

View proppy's full-sized avatar

Johan Euphrosine proppy

View GitHub Profile
(in /home/proppy/Desktop/playground/watir-webdriver)
All dependencies seem to be installed.
trying 0.0.0.0:2000...
[2010-08-23 19:31:16] INFO WEBrick 1.3.1
[2010-08-23 19:31:16] INFO ruby 1.8.7 (2010-01-10) [x86_64-linux]
trying 0.0.0.0:2000...
trying 0.0.0.0:2000...
trying 0.0.0.0:2000...
trying 0.0.0.0:2000...
trying 0.0.0.0:2000...
var assert = require('assert');
var s = '';
var append_char = function(arg) {
s+= arg;
};
function rendezvous(callback) {
return {
callbacks: [],
callback: function(cb) {
proppy@unubore:~/Desktop/mape$ cat connectform.js
var connect = require('connect');
var form = require('connect-form');
var server = connect.createServer(
form({ keepExtensions: true }),
function(req, res, next){
// Form was submitted
if (req.form) {
// Do something when parsing is finished
// and respond, or respond immediately
ok:
00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 .PNG........IHDR
00000010: 0000 00e3 0000 00cc 1002 0000 005e 865f .............^._
00000020: bb00 0000 096f 4646 7300 0002 5b00 0001 .....oFFs...[...
00000030: bf00 4963 8793 0000 0009 7048 5973 0000 ..Ic......pHYs..
corrupted:
00000000: efbf bd50 4e47 0d0a 1a0a 0000 000d 4948 ...PNG........IH
00000010: 4452 0000 00ef bfbd 0000 00ef bfbd 1002 DR..............
00000020: 0000 005e efbf bd5f efbf bd00 0000 096f ...^..._.......o
#include <assert.h>
#include <fcntl.h>
int main(int argc, int argv) {
int in, out, n;
char data[1024];
char header[1];
header[0] = 0x89;
in = open("/tmp/corrupted.png", O_RDONLY);
out = open("/tmp/corrupted2.png", O_CREAT|O_WRONLY);
@proppy
proppy / count.hs
Created May 18, 2011 13:20
How to count in haskell
count1 c (x:xs) = count1' (c == x) + count1 c xs
count1 c [] = 0
count1' True = 1
count1' False = 0
count2 c (x:xs) | c /= x = 0 + count2 c xs
| otherwise = 1 + count2 c xs
count2 c [] = 0
count3 c (x:xs) = (if c == x then 1 else 0) + count3 c xs
[[('A',0,1),('B',0,1),('A',0,1)], [('A',0,1),('B',0,1),('B',1,1)],
[('A',0,1),('B',0,1),('A',2,2)], [('A',0,1),('B',0,1),('B',4,1)],
[('A',0,1),('A',1,1),('A',0,1)], [('A',0,1),('A',1,1),('B',1,1)],
[('A',0,1),('A',1,1),('A',2,2)], [('A',0,1),('A',1,1),('B',4,1)],
[('A',0,1),('B',2,2),('A',0,1)], [('A',0,1),('B',2,2),('B',1,1)],
[('A',0,1),('B',2,2),('A',2,2)], [('A',0,1),('B',2,2),('B',4,1)],
[('A',0,1),('A',4,1),('A',0,1)], [('A',0,1),('A',4,1),('B',1,1)],
[('A',0,1),('A',4,1),('A',2,2)], [('A',0,1),('A',4,1),('B',4,1)],
[('B',1,2),('B',0,1),('A',0,1)], [('B',1,2),('B',0,1),('B',1,1)],
[('B',1,2),('B',0,1),('A',2,2)], [('B',1,2),('B',0,1),('B',4,1)],
@proppy
proppy / gist:1042754
Created June 23, 2011 15:26
appengine-java-marketplace-openid-handler
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
public class AuthServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) {
UserService userService = UserServiceFactory.getUserService();
@proppy
proppy / depy.sh
Created August 10, 2011 12:49
depy: hack to vendor a python library and its dependencies
set -e
[ $# -ge 2 ] || (echo 'usage: depy PACKAGES... DIRECTORY' ; false)
PACKAGES=${@:1:$(($#-1))}
DESTINATION=${!#}
TMPDIR=/tmp/depy.$$
pip install -E $TMPDIR $PACKAGES
find $TMPDIR -type f -name "*.pyc" -delete
PACKAGES=$(pip freeze -E $TMPDIR | cut -d '=' -f 1 | xargs -n 1 -I @package@ find $TMPDIR -ipath '*/@package@/__init__.py' | sed -e s/__init__\.py//)
mkdir -p $DESTINATION
cp -R $PACKAGES $DESTINATION
@proppy
proppy / EntityToKeyIterable.java
Created August 11, 2011 13:23
Convert Iterable<Entity> to Entity<Key>
import java.util.Iterator;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
public class EntityToKeyIterable implements Iterable<Key> {
Iterable<Entity> iterable;
public EntityToKeyIterable(Iterable<Entity> iterable) {
this.iterable = iterable;
}
@Override