Skip to content

Instantly share code, notes, and snippets.

View alcides's full-sized avatar

Alcides Fonseca alcides

View GitHub Profile
@alcides
alcides / gist:708202
Created November 20, 2010 21:49
AJAXy history hack.
/**
* The history class is in charge of the browser
* history and URL's.
*/
TT.history = {};
/** */
TT.history.TABLE_OF_CONTENTS = 'table-of-things';
TT.history.HOME = 'home';
TT.history.FOREWORD = 'foreword';
//
// ManualSexualViewController.m
// ManualSexual
//
// Created by Alcides Fonseca on 11/11/10.
// Copyright (c) 2010 __MyCompanyName__. All rights reserved.
//
#import "ManualSexualViewController.h"
@alcides
alcides / MapExample.java
Created November 4, 2010 00:27
An example of converting an array to the double, using AeminiumParallel library.
package aeminium.gpu.examples;
import aeminium.gpu.lists.*;
public class Test {
public static void main(String[] args) {
IntList input = new IntList();
for (int i=0; i<20; i++) {
input.add(new Integer(i));
@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]
x = long_function()
y = another_long_function()
z = x + y
@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'
import re
import urllib
import urllib2
import os
import sys
import time
USERNAME = os.environ.get("WOCU","")
PASSWORD = os.environ.get("WOCP","")
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','')
@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 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; }