Skip to content

Instantly share code, notes, and snippets.

View guimello's full-sized avatar

Guilherme da Silva Mello guimello

  • Jundiaí, São Paulo - Brazil
View GitHub Profile
@guimello
guimello / pom.xml
Created August 14, 2013 19:45
Pom GAE spring file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<groupId>br.com.tagview</groupId>
<artifactId>taskapp</artifactId>
// derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
function map() {
emit(1, // Or put a GROUP BY key here
{sum: this.value, // the field you want stats for
min: this.value,
max: this.value,
count:1,
diff: 0, // M2,n: sum((val-mean)^2)
});
@guimello
guimello / decorators.py
Created July 11, 2013 01:48
Decorators examples in python.
from time import time
# Decoratoring with a class
class Benchmark(object):
def __init__(self, function):
self.function = function
def __call__(self, *args, **kwargs):
t1 = time()
result = self.function(*args, **kwargs)
@guimello
guimello / go_horse_grooveshark_resume_playback.js
Created April 16, 2012 20:01
Go horse grooveshark resume playback bug :(
$('#lightbox_footer .right button').removeAttr('disabled').trigger('click');
@guimello
guimello / jquery_load_any_page.js
Created September 20, 2011 01:11
Load jquery on any page through console
javascript:void((function(){j=document.createElement("SCRIPT");j.src="http://code.jquery.com/jquery-latest.pack.js";document.getElementsByTagName("HEAD")[0].appendChild(j);})())
# monkey-patch irb. see: http://jameskilton.com/2009/04/02/embedding-irb-into-your-ruby-application/
#
require 'irb'
module IRB # :nodoc:
def self.start_session(binding)
unless @__initialized
args = ARGV
ARGV.replace(ARGV.dup)
IRB.setup(nil)
@guimello
guimello / Random in objective-c
Created August 30, 2011 01:05
objective_c_random.m
(arc4random() % 8)
@guimello
guimello / navigation_tool_bar_color.m
Created August 9, 2011 21:01
Tint color your navigation tool bar [ios]
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:(102.0/255.0) green:(20.0/255.0) blue:(11.0/255.0) alpha:1];
/* So I never need to look for it anymore... :) */
- (void)viewDidLoad
{
[super viewDidLoad];
aTextField.delegate = self;
}
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField