Skip to content

Instantly share code, notes, and snippets.

View alcides's full-sized avatar

Alcides Fonseca alcides

View GitHub Profile
# Reason a project was crashing the machine.
Thread(target=fun1).start()
def fun1():
do_a_network_call_that_takes_10s_or_raises_some_weird_exception()
some_gui_and_os_related_code()
fun1()
@alcides
alcides / Fib.java
Created June 14, 2010 11:59
Fibonnaci example implemented on the Aeminium Runtime
package aeminiumruntime.examples.fjtests;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.Callable;
import aeminiumruntime.Runtime;
import aeminiumruntime.Task;
import aeminiumruntime.Body;
import aeminiumruntime.simpleparallel.ParallelRuntime;
@alcides
alcides / WatchDog.cs
Created June 19, 2010 14:26
A simple watchdog that every 30seconds checks for unresponsive tasks and kills them.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace WatchDog
{
class Program
{
import jsr166y.*;
@SuppressWarnings("serial")
class Fib extends RecursiveAction {
public volatile int number;
private int THREASHOLD = 12; //(12 works)
private static int TARGET = 12;
Fib(int n) { number = n; }
@alcides
alcides / benchmark.bat
Created July 23, 2010 16:53
How to run a program with different number of cores.
@echo off
set A=0
:BEGIN
set /a A=1+%A%
echo Changing number of cores to %A%
import os
import datetime
import foursquare
from orm.models import *
from utils import geo
username = os.environ.get('FS_USER','')
passw = os.environ.get('FS_PASS','')
import re
import urllib
import urllib2
import os
import sys
import time
USERNAME = os.environ.get("WOCU","")
PASSWORD = os.environ.get("WOCP","")
@alcides
alcides / gist:599093
Created September 27, 2010 14:12
Running every hour via cronjob
#!/usr/bin/env python
import imaplib
import datetime
from tumblr import Api
import sys
BLOG='perolasdoaniceto.tumblr.com'
USER='myusername'
x = long_function()
y = another_long_function()
z = x + y
@alcides
alcides / boot.bat
Created October 18, 2010 21:28
Processing exports an app that spawns a new javaw. This code launches it embedded on a python/windows batch script.
:: Processing exports a stub for windows that starts a new javaw process and closes itself
:: Below is a python launcher that parses args.txt, runs the app, waits for it to finish and prints the stdout.
python -c "import os;from subprocess import *;f = open('lib/args.txt');flags = f.readline().strip().split();mainclass = f.readline().strip();classpath = f.readline().strip().replace(',',';');args = ['java','-classpath', classpath] + flags + [mainclass];path = os.path.join(os.getcwd(),'lib');print Popen(args,stdout=PIPE, cwd=path).communicate()[0]