Skip to content

Instantly share code, notes, and snippets.

View pcostesi's full-sized avatar

Pablo Alejandro Costesich pcostesi

View GitHub Profile
<?php
if(isset($_POST['img']) && !empty($_POST['img'])) {
$file = uniqid().".jpeg";
$data = explode(",", $_POST['img']);
$width = $_POST['width'];
$height = $_POST['height'];
$image=imagecreatetruecolor($width, $height) or die('no hay GD!');
$i = 0;
for($x=0; $x<=$width; $x++){
int cmp_for_sort(const void * c1, const void * c2){
return strcmp(*(char **) c1, *(char **) c2);
}
int cmp_for_search(const void * c1, const void * c2){
return strcmp((char *) c1, *(char **) c2);
}
int
getCommand()
@pcostesi
pcostesi / simples.py
Created October 5, 2011 04:46
S Interpreter
#!/usr/bin/env python
""" This is a simple and experimental version of an interpreter for the
S language. It doesn't aim to be complete, just correct.
"""
from collections import defaultdict
import re
TAG = r"\s*(\[\s*(?P<tag>[a-eA-E]\d+)\s*\])?\s*"
NXT = r"(?P<nxt>[a-eA-E]\d+)"
@pcostesi
pcostesi / ffek.py
Created November 23, 2011 03:12
FFEK, optimized a bit the bfs part and fixed a bug in the backtracking function
#!/usr/bin/env python
from collections import defaultdict, deque
class Edge(object):
def __init__(self, tail, head, capacity, name=None, flow=0):
self.name = tail + "-" + head if not name else name
self.tail = tail
self.head = head
self.flow = flow
self.capacity = capacity
@pcostesi
pcostesi / netstrings.c
Created March 4, 2012 04:17
Toy implementation of netstrings
#include <stdio.h>
#include <ctype.h>
#define MAX_BYTES 1 << 24
int
read_netstring(char * buffer, size_t limit, FILE * f){
size_t msgSize = 0;
size_t readSize = 0;
int c = 0;
@pcostesi
pcostesi / drop.py
Created May 21, 2012 03:16
Drop interaction in wx
class FileDropTarget(wx.FileDropTarget):
def __init__(self, window):
wx.FileDropTarget.__init__(self)
self.window = window
def OnDropFiles(self, x, y, filenames):
for name in filenames:
@pcostesi
pcostesi / cli.py
Created May 21, 2012 03:17
QRCode cli printer
import qrcode.image.base
BLACK = "\033[40m"
WHITE = "\033[107m"
DEFAULT = "\033[49m"
SPACER = " "
class CliImage(qrcode.image.base.BaseImage):
"""Cli image builder."""
@pcostesi
pcostesi / share.py
Created May 21, 2012 03:30
Share files locally with a mobile device. Requires python-qrcode.
#!/usr/bin/python
# filedrop.py
import qrcode
import sys
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import shutil
import os
@pcostesi
pcostesi / co.py
Created May 22, 2012 22:42
Share files through LAN (Broadcast)
#!/usr/bin/env python
import SocketServer
import struct
import shutil
import hashlib
import zlib
from StringIO import StringIO
import os
try:
import wx
class ThreadedMusicPlayer implements Runnable{
public ThreadedMusicPlayer(){
Thread thread = new Thread(this);
thread.start();
}
void run(){
while (true){
playMusic();
}