Skip to content

Instantly share code, notes, and snippets.

@ramons03
ramons03 / gist:1398030
Created November 27, 2011 19:33
Devuelve el maximo valor de repeticiones de acuerdo a una propiedad del objeto
public static int contarRepetidos(ArrayList<Objeto> a) {
Map<Integer, Integer> freqMap = new HashMap<Integer, Integer>();
for (Objeto obj : a) {
freqMap.put(obj.getValor(), (freqMap.get(obj.getValor()) == null ? 1 : (freqMap.get(obj.getValor()) + 1)));
}
return Collections.max(freqMap.values());
}
@rmurphey
rmurphey / gist:3308827
Created August 9, 2012 23:02
Change the color of an LED based on accelerometer orientation
var five = require("../lib/johnny-five.js"),
board, distance, vibration, accel,
red, green, blue;
board = new five.Board();
board.on("ready", function() {
var status = new five.Led(13);
status.on();
@michaelfeathers
michaelfeathers / gist:3827233
Created October 3, 2012 14:33
Code volume
# A poor man's complexity measure for a file or group of files
puts ARGF.lines.grep(/^([ \t]*)/) { $1 }.map(&:length).reduce(0, :+)
def field_names
@field_names ||= @expression.flatten
.each_cons(2)
.select {|marker, _| marker == :@ivar }
.map {|_,name| field_name(name) }
end
--returns rows in random order
select * from sometable order by random();
--use '::' for casting
select '2013-01-01'::date;
-- date
--------------
-- 2013-01-01
select 1 / 10 as non_casted, 1::float8 / 10 as casted;
-- non_casted | casted
@bradley-holt
bradley-holt / calendar-of-tech-events.md
Last active December 22, 2015 20:28
A collection of community tech events in the greater Burlington area.
@rebcabin
rebcabin / gist:5657986
Last active January 8, 2016 14:40
Rx LINQ Operator Precis
Rx LINQ Operator Precis
Brian Beckman, May 2013
================================================================================
Introduction
================================================================================
This is a highly abbreviated "cheat-sheet" for the LINQ operators over Rx, the
Reactive Extensions. Its purpose is to TEACH by laying bare the regular and
tasteful structure of the API. This structure can be difficult to perceive from
ordinary documentation and source code because comparable and contrastable
@michaelfeathers
michaelfeathers / gist:1855765
Created February 17, 2012 22:19
Five lines that turn Ruby into a different language
class Object
def method_missing m, *args
Object.respond_to?(m, true) ? Object.send(m, self, *args) : super
end
end
@zhangxu
zhangxu / tmux everyday usage
Last active October 27, 2017 10:09
Tmux usage
default prefix: Ctrl+b
start new session: tmux
list sessions: tmux ls
attach to session: tmux attach [-t <session>]
attach to session forcely: tmux attach -d
detach: prefix then d
Windows:
@sferik
sferik / 1000 Twitter API Requests (JSON)
Created December 10, 2009 03:28
Twitter API Benchmarks
$ ab -n 1000 -c 10 http://twitter.com/help/test.json
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking twitter.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests