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 / Random in objective-c
Created August 30, 2011 01:05
objective_c_random.m
(arc4random() % 8)
# 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 / 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);})())
@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 / 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)
// 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 / 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>
// Browsers behave differently when dbl clicking to select
// a range.
//
// Chrome and IE use the text node that contains the selected text
// as the startContainer with an offset to exclude any whitespace
// characters at the start of the node.
//
// Firefox will use a text node *before* the selected text
// as the startContainer, with a positive offset set to the end
// of the node. If there is no previous sibling of the selected text
@guimello
guimello / README.md
Last active August 29, 2015 14:26 — forked from jxson/README.md
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation