Skip to content

Instantly share code, notes, and snippets.

View alcides's full-sized avatar

Alcides Fonseca alcides

View GitHub Profile
PUT /users/{username}
GET /users/?user={username}&pass={password}
GET /problemas/
<problemas>
<problema>
<id>http://problemaki.com/problemas/p01</id>
<titulo>Buraco na estrada</titulo>
@alcides
alcides / deicoin.py
Created September 27, 2013 12:22
BitCoin cheap clone proof-of-concept
fibCache = [1, 1]
fibMax = 0;
def isFib(n):
global fibMax
if n <= 1:
return True
else:
while fibMax < n:
fibMax = sum(fibCache[-2:])
@alcides
alcides / gist:5363435
Created April 11, 2013 13:37
New kind of exception.
Exception in thread "WorkerStealingThread-22" java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.util.concurrent.ConcurrentLinkedQueue.offer(ConcurrentLinkedQueue.java:327)
at java.util.concurrent.ConcurrentLinkedQueue.add(ConcurrentLinkedQueue.java:296)
at aeminium.runtime.implementations.implicitworkstealing.scheduler.stealing.SequentialReverseScan.threadGoingToPark(Unknown Source)
#!/usr/bin/env ruby
# encoding: UTF-8
$VERBOSE = true # -w
$KCODE = "U" if RUBY_VERSION < "1.9" # -KU
require 'optparse'
require 'socket'
require 'tempfile'
require 'yaml'
@alcides
alcides / auth_source_ldap.rb
Created February 11, 2013 23:02
Redmine 2.2 auth_source_ldap.rb file to connect to DEI's LDAP.
# Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@alcides
alcides / fix_encodings.sh
Created February 11, 2013 20:34
Fix MySQL encodings. When migrating a UTF-8 database, encodings got f*ckd up, I had fix every field in all tables. This script automated the process.
#!/bin/bash
USERNAME="myuser";
DATABASE="mydb";
PASSWORD="mypass";
# Convert all fields in all databases using this trick
# convert(convert(convert(firstname USING latin1) USING binary) using utf8)
mysql -u $USERNAME -p$PASSWORD -B -N -e "SHOW TABLES" $DATABASE | while read table
@alcides
alcides / gist:3973181
Created October 29, 2012 12:00
Multi-Process Game of Life (One process per shape)
#!/usr/bin/python
import threading
from Tkinter import *
root = Tk()
class Shape(threading.Thread):
def __init__(self, grid, pos=(4,4)):
threading.Thread.__init__(self)
self.grid = grid
@alcides
alcides / setup.py
Created October 8, 2012 08:52
Install pgmagick mac os x 10.8 with homebrew
from setuptools import setup, find_packages, Extension
from distutils.sysconfig import get_python_inc
import glob
import os
import re
import sys
GMCPP_PC = 'GraphicsMagick++.pc'
IMCPP_PC = 'ImageMagick++.pc'
LIBRARY = 'GraphicsMagick' # default value
@alcides
alcides / GP.hs
Created May 25, 2012 22:14
Genetic Programming Framework in Haskell (incomplete)
{-# OPTIONS -Wall #-}
import Data.Map (Map, findWithDefault, fromList)
import LinReg (testData)
import Test.QuickCheck
import Test.QuickCheck.Gen
import System.Random
import GHC.Exts (sortWith)
data AST = Add AST AST
@alcides
alcides / blogspot_comment_id.html
Created May 1, 2012 21:08
Blogspot add comment sequential id.
<script type='text/javascript'>
// <![CDATA[
var addcomments = function() {
var ls = document.getElementsByClassName("comment");
for (i=0;i<ls.length;i++) {
if (ls[i].innerHTML.indexOf('comment_count') == -1)
ls[i].innerHTML = "<div class='comment_count' style='float:right; font-weight: bold;'>#" + (i+1) + "</div>" + ls[i].innerHTML;
}