Skip to content

Instantly share code, notes, and snippets.

View tinnet's full-sized avatar
🐼

Martin Contento tinnet

🐼
View GitHub Profile
public class Main {
static interface InterfaceA {
public void speak();
}
static interface InterfaceB extends InterfaceA {
public void sit();
}
@tinnet
tinnet / timed_runner.py
Created February 26, 2012 17:50
runs another python module for a maximum time
import imp
import os
import sys
import threading
USAGE = "python %s YOUR_MODULE TIMEOUT_IN_SECONDS arg1 arg2 arg3" % sys.argv[0]
class ModuleRunner(threading.Thread):
def __init__(self, module_name):
threading.Thread.__init__(self)
@tinnet
tinnet / namespaces.php
Created December 13, 2011 16:46
using namespaces to override global functions(?)
<?php
namespace FOO;
function strlen($arg) {
return 42;
}
// "my" strlen
echo strlen('lala'), "\n";
@tinnet
tinnet / gist:1343179
Created November 6, 2011 17:02
anti-mongodb rant (mirror from pastebin)
Don't use MongoDB
=================
I've kept quiet for awhile for various political reasons, but I now
feel a kind of social responsibility to deter people from banking
their business on MongoDB.
Our team did serious load on MongoDB on a large (10s of millions
of users, high profile company) userbase, expecting, from early good
experiences, that the long-term scalability benefits touted by 10gen
@tinnet
tinnet / radio7.py
Created September 7, 2011 16:42
radio7 watcher...
import time
import urllib2
from BeautifulSoup import BeautifulSoup
from pygame import mixer
log = open("radio7.log", "a")
mixer.init()
alert = mixer.Sound('alarm.wav')
lastpic = ""
@tinnet
tinnet / dateblacklist.py
Created July 6, 2011 08:07
string compare vs. precompiled regex
#Took: 6.605544 seconds
#Took: 15.969022 seconds
#Took: 4.270395 seconds
#Took: 3.229852 seconds
import re
import time
DATETIME_BLACKLIST = ['1970-01-01 01:00:00', '1970-01-01 00:00:00', '0000-00-00 00:00:00']
@tinnet
tinnet / gist:1026668
Created June 15, 2011 07:59
mysql timestamp fun
CREATE TABLE `mails` (
`id` bigint(20) NOT NULL auto_increment,
`email` varchar(250) NOT NULL,
`type` char(6) NOT NULL,
`time` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`),
KEY `time` (`time`),
KEY `type` (`type`)
) ENGINE=MyISAM;
@tinnet
tinnet / zpipe.c
Created May 25, 2011 11:25
zpipe.c with modified magic numbers
/* zpipe.c: example of proper use of zlib's inflate() and deflate()
Not copyrighted -- provided to the public domain
Version 1.2 9 November 2004 Mark Adler */
/* Version history:
1.0 30 Oct 2004 First version
1.1 8 Nov 2004 Add void casting for unused return values
Use switch statement for inflate() return values
1.2 9 Nov 2004 Add assertions to document zlib guarantees
1.3 6 Apr 2005 Remove incorrect assertion in inf()