Skip to content

Instantly share code, notes, and snippets.

@Jauny
Jauny / facebook.cpp
Created May 24, 2012 12:37 — forked from anonymous/facebook.cpp
Facebook interview solution
//Solution à l'interview de Facebook
//Edmond La Chance UQAC 2012
//02:10 2012-05-24
//Énoncé : http://pastebin.com/4FNndtNV
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
@Jauny
Jauny / README.txt
Created June 1, 2012 23:34
Multiple SimpleModal
This is a modified version of Eric Martin's Simplemodal jQuery popup to allow you to easily add multiple links/popups on the same page.
http://www.ericmmartin.com/projects/simplemodal/
I am a noob and had trouble finding material on how to do that... so here is my version :)
Thanks to Eric Martin for making that amazing jQuery function,
Thanks to Alex, a friend, to help me with his magic to make everything work!
Cheers!
@Jauny
Jauny / arraymode
Created August 16, 2012 19:19
calculate the mode of an array
def mode(array)
h = Hash.new
array.uniq.each do |x|
h[x] = array.count(x)
end
h.select{|k,v| v == h.values.max }.map{|i| i[0] }
end
.hidden {
display: hidden;
}
.normal:hover .hidden {
display: block;
}
-> a = []
=> []
-> a << a
=> [[...]]
-> a.first == a
=> true
nodes = { a:[], b:[], c:[], d:[] }
nodes[:a] << nodes[:a]
nodes[:a] << nodes[:b]
nodes[:b] << nodes[:a]
nodes[:b] << nodes[:c]
p nodes
#=> {:a=>[[[...], []], [...]], :b=>[[[...], [...]], []], :c=>[], :d=>[]}
def increment(x, y)
n = 1
while n < x
puts n
n += y
end
end
// with option to choose from where it starts
# Put your answers here!
@Jauny
Jauny / gist:3869758
Created October 11, 2012 02:13
Hash#sort

#Sorting a Hash I wanted to understand what happened under the hood when something like

hash.sort { |a, b| b[1] <=> a[1] }

is called. If you can't answer, you might want to read.
I'll be as basic as possible (I don't know much anyway...) so it should be understandable.


First let's begin by saying that we will be working on this hash

@Jauny
Jauny / gist:3876531
Created October 12, 2012 00:08
Understanding blocks, Procs and lambda!

#Understanding blocks, Procs and lambdas. I think blocks, Procs and lambdas are working in a really counter-intuitive way when you
first try to understand how they work, and most of the (amazing) resources one can find online
are too complicated to allow to understand how they work without frustration...

So here is my take on it; I'll try to make it as simple and concise as possible,
and will focus on how it is used, instead of how it works under the hood.

##Blocks A block is simply a piece of code that will (usually) execute something;