Skip to content

Instantly share code, notes, and snippets.

View alcides's full-sized avatar

Alcides Fonseca alcides

View GitHub Profile
@alcides
alcides / Rakefile
Created April 4, 2012 17:49 — forked from rubenfonseca/Rakefile
Rakefile + CoffeeScript + Titanium Mobile example
DEV_PROVISIONING_UUID = "3E4D9E49-E44B-4B73-AFAD-248C720ECD53"
DEV_SIGN = "Ruben Fonseca"
DEV_APP_NAME = "My greatest app"
DEV_APP_ID = 'com.0x82.app'
TITANIUM_SDK_VERSION = '1.8.2'
IPHONE_SDK_VERSION = '5.0'
BUILDER_PATH = "/Library/Application Support/Titanium/mobilesdk/osx/#{TITANIUM_SDK_VERSION}/iphone/builder.py"
if File.exists?(BUILDER_PATH)
type DataStore = [(Int, Int)]
iter :: Int -> DataStore -> Int -> (DataStore, Int)
iter rem ks d = ( (d, rem `div` d):ks, rem `mod` d)
wrapper :: Int -> DataStore -> Int -> (DataStore, Int)
wrapper re ds 1 = (ds, re)
wrapper re ds d = wrapper re' ds' (d `div` 2)
where (ds', re') = iter re ds d
@alcides
alcides / py-randomizer.py
Created September 30, 2011 17:53 — forked from laginha/randomizer.py
Interface built over python module random
import random, math
MAX = 100
MIN = 10
class Randomizer:
def __init__(self):
self.choice = random.choice
self.list = lambda f,m: [ f() for i in self.range(0,m) ]
self.hash = lambda a,b: dict( zip( a(), b() ) )
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
if __name__ == "__main__":
public class JNotifyExample
public static void main(String[] args) throws InterruptedException, IOException
{
String dir = new File(args.length == 0 ? "." : args[0]).getCanonicalFile().getAbsolutePath();
JNotify.addWatch(dir, FILE_ANY, true, new JNotifyListener()
{
public void fileRenamed(int wd, String rootPath, String oldName,
String newName)
{
System.out.println("renamed " + rootPath + " : " + oldName + " -> " + newName);
@alcides
alcides / cat.c
Created September 4, 2011 21:02
A cat clone in naïve C.
#include <stdlib.h>
#include <stdio.h>
char *buffer;
void read(char* fname) {
FILE *fp = fopen(fname, "r");
if (fp != NULL) {
fseek(fp, 0L, SEEK_END);
long s = ftell(fp);
@alcides
alcides / gist:908411
Created April 7, 2011 18:46
Atempt to make a browser through xmpp. DOES NOT WORK.
require 'rubygems'
require 'xmpp4r/client'
require 'open-uri'
require 'sanitize'
include Jabber
class ClientB < Client
def main_loop
keepalive_loop
@alcides
alcides / App.scala
Created March 22, 2011 20:29
Example of Exception Handling in Actors.
package pt.uc.dei
import scala.collection.immutable.List
import scala.actors.Actor
import scala.actors.Actor._
case class MessageNotSent(val msg:String) extends Exception {
override def getMessage = msg
}
@alcides
alcides / gist:751384
Created December 22, 2010 10:59
Matlab text skelecton extraction
function im = thinning(img)
% THINNING Short description
% [IM] = THINNING(IMG)
im = img;
repeat = 1;
is_even = 0;
while repeat
repeat = 0;
@alcides
alcides / aegpumap.java
Created December 21, 2010 14:20
Example of the GPU-powered map API in AEminium
IntList output = (IntList) input.map(new Lambda<Integer,Integer>() {
@Override
public Integer call(Integer input) {
return 2 * input;
}
@Override
public String getSource() {
return "return 2 * input;";