Skip to content

Instantly share code, notes, and snippets.

View thebinarypenguin's full-sized avatar

Ethan Zimmerman thebinarypenguin

View GitHub Profile
@thebinarypenguin
thebinarypenguin / monty-hall-proof.rb
Created March 24, 2014 12:01
An experimental proof of the Monty Hall problem in Ruby. Reference: http://en.wikipedia.org/wiki/Monty_Hall_problem
#!/usr/bin/env ruby
sample_size = 3000
stay_counter = 0
switch_counter = 0
sample_size.times do |i|
# Randomly create a scenario
winning_door = [1,2,3].sample
@thebinarypenguin
thebinarypenguin / promise-wrap-example.js
Last active August 29, 2015 14:04
An example of wrapping multiple dependent AJAX requests in a single promise using jQuery's Deferred object
/**
* Get a user's public GitHub activity using the GitHub API
* Returns a promise
*/
function GitHubActivity(username) {
var master, fetch, collectedData;
collectedData = [];
/**
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>xxxxxxxxxx</title>
<meta name="description" content="xxxxxxxxxx">
@thebinarypenguin
thebinarypenguin / jot.sh
Last active August 29, 2015 14:24
Simple script for quickly capturing notes
#!/bin/bash
# Usage
#
# jot.sh - Open today's jot file
# jot.sh <text> - Append text (with timestamp) to end of today's jot file
jotsDir=~/jots/
todaysFile=$jotsDir$(date +%F).jot
@thebinarypenguin
thebinarypenguin / node-hello-world.js
Created March 6, 2016 13:27
"Hello World" HTTP server using node.js
const http = require('http');
const name = 'node-hello-world';
const port = '8888';
const app = new http.Server();
app.on('request', (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('Hello World');
@thebinarypenguin
thebinarypenguin / sudoku-board.html
Created May 28, 2016 15:57
A sample Sudoku board in HTML and CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>HTML Sudoku Board</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">

A Tale of Two Scopes

Hi, I'm an ES6 enthusiast and I'm here to explain why the convenience of one set of scope rules in JavaScript has been replaced by the convenience of two sets of scope rules.

You're probably thinking, "Sure, more scope rules are great, and I don't mind paying the extra cognitive load, but how will I remember all those rules?"

https://repl.it/@thebinarypengui/Wiseperson-generator-drill
https://repl.it/@thebinarypengui/shouter-drill
https://repl.it/@thebinarypengui/text-normalizer-drill
https://repl.it/@thebinarypengui/area-of-a-rectangle-drill
https://repl.it/@thebinarypengui/temperature-conversion-drill
https://repl.it/@thebinarypengui/Is-divisible-drill
https://repl.it/@thebinarypengui/Traffic-lights-drill
https://repl.it/@thebinarypengui/Error-alert-drill