Skip to content

Instantly share code, notes, and snippets.

😎

Guilherme Simoes guilhermesimoes

😎
Block or report user

Report or block guilhermesimoes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@guilhermesimoes
guilhermesimoes / .block
Last active Nov 12, 2017 — forked from HarryStevens/.block
Box and Whisker
View .block
license: gpl-3.0
@guilhermesimoes
guilhermesimoes / .block
Last active Aug 14, 2017
D3 V4 join & enter
View .block
license: gpl-3.0
@guilhermesimoes
guilhermesimoes / .block
Last active Apr 19, 2017 — forked from mbostock/.block
D3 V3 join & enter
View .block
license: gpl-3.0
@guilhermesimoes
guilhermesimoes / loop_starting_at_index_one_benchmark.rb
Created Apr 7, 2017
Ruby Benchmark: Starting a loop at index 1
View loop_starting_at_index_one_benchmark.rb
# gem install benchmark-ips
require "benchmark/ips"
Benchmark.ips do |x|
x.report("range") { (1..100).each { |i| i } }
x.report("upto") { 1.upto(100).each { |i| i } }
x.report("times plus one") { 100.times { |i| i + 1 } }
@guilhermesimoes
guilhermesimoes / .block
Last active Feb 8, 2017
D3.js: Animating a pie chart
View .block
license: gpl-3.0
@guilhermesimoes
guilhermesimoes / last_uri_path_benchmark.rb
Last active Nov 30, 2016
Ruby Benchmark: Determining the last part of a URI
View last_uri_path_benchmark.rb
# gem install benchmark-ips
require "benchmark/ips"
uri = "http://twitter.com/user/statuses/1234567891011121314"
Benchmark.ips do |x|
x.report("file.basename") { File.basename(uri) }
x.report("split('/').last") { uri.split("/").last }
@guilhermesimoes
guilhermesimoes / .block
Last active Jan 26, 2017
D3.js: Encoding values as circles
View .block
license: gpl-3.0
@guilhermesimoes
guilhermesimoes / .block
Last active Jan 16, 2018 — forked from mbostock/.block
D3.js: Automatic text sizing using em units
View .block
height: 760
license: gpl-3.0
@guilhermesimoes
guilhermesimoes / authentication.md
Last active Oct 15, 2016
How authentication should work (in my mind)
View authentication.md
Page / User State Logged Out Logged In
/public-page Go to /public-page Go to /public-page
/page-requiring-auth
  1. Redirect to /login
  2. After successful login redirect to /page-requiring-auth
Go to /page-requiring-auth
/login
  1. Go to /login
  2. After successful login redirect to /
Redirect to /
/logout Redirect to /
  1. Log out the user
  2. Redirect to /
@guilhermesimoes
guilhermesimoes / detect-private-browsing.js
Created Dec 12, 2015 — forked from cou929/detect-private-browsing.js
Detect private browsing mode (InPrivate Browsing or Incognito).
View detect-private-browsing.js
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
You can’t perform that action at this time.