Skip to content

Instantly share code, notes, and snippets.

@mxhold
mxhold / 20141130_railsbridge_curriculum.md
Last active August 29, 2015 14:10
Rails Bridge Curriculum notes

Volunteer-Student interactions

  • When doing introductions, have volunteers write the names of the student on the board? Spatially grouped by experience or background?

  • Remind volunteers to ask students how it's going since they may not all raise their hands when they get stuck

Skill levels

  • Use BridgeTroll to track/group students' skill levels.
require 'open3'
command = '$stderr.puts("X" * 70_000); $stdout.puts("X" * 70_000)'
full_command = "ruby -e '#{command}'"
Open3.popen3(full_command) do |_in, out, err, _t|
out.each { |line| $stdout.puts line }
err.each { |line| $stderr.puts line }
end
@mxhold
mxhold / no-trailing-slashes-nginx-and-middleman.md
Last active January 21, 2019 00:10
Prevent trailing slashes in URLs with Middleman and Nginx

So you want to have pretty URLs with no trailing slash or .html like:

http://mysite.com/blog/my-new-kitten

not like:

http://mysite.com/blog/my-new-kitten/

or

if(pointsRight === 5){
console.log("<p><p><h1><color="green">Congratulations! You got them all right! You've won the gold crown! Aren't you smart?</p>");
} else if(pointsRight === 4 || pointsRight === 3){
console.log("<p>Congratulations! You got " + pointsRight " right! Here's a silver crown!"</p>);
} else if(pointsRight === 2 || pointsRight === 1){
console.log("<p>Congratulations! You got " + pointsRight " right! Here's a bronze crown!"</p>);
else{
console.log(<p>"Congratulations! You got " + pointsRight " right and " + pointsWrong " wrong here's your nega-crown.</p>");
}
@mxhold
mxhold / followers_in_common
Last active August 29, 2015 14:27
Find the followers in common between two Twitter users
#!/usr/bin/env ruby
# Usage:
# ./followers_in_common maxholder sandimetz
# You'll need to `gem install twitter`
require 'twitter'
# see: https://dev.twitter.com/oauth/overview/application-owner-access-tokens
client = Twitter::REST::Client.new do |config|
@mxhold
mxhold / twitter_intersect
Last active August 29, 2015 14:27
Shows the interesting intersections of followers between two Twitter users
#!/usr/bin/env ruby
# Usage:
# ./twitter_intersect username1 username2
# You'll need to `gem install twitter`
require 'twitter'
# see: https://dev.twitter.com/oauth/overview/application-owner-access-tokens
@client = Twitter::REST::Client.new do |config|

Elixir list vs tuple benchmark

Lists

Length

  size             i/s             μ/i
   10k        28051.11           35.65
  100k         3251.63          307.54

1m 512.33 1951.87

@mxhold
mxhold / rust_wtf.md
Created October 29, 2016 16:32
Rust WTF moments

This compiles:

extern crate hyper;
use std::{thread, time};

use hyper::server::{Server, Request, Response};
use hyper::uri::RequestUri::*;

fn hello(req: Request, res: Response) {
@mxhold
mxhold / rust_integers.md
Last active February 17, 2017 20:00
Integers in Rust
Type Length (bits) Minimum value Maximum value
u8 8 0 255
i8 8 -128 127
u16 16 0 65,535
i16 16 -32,768 32,767
u32 32 0 4,294,967,295
i32 32 -2,147,483,648 2,147,483,647
u64 64 0 18,446,744,073,709,551,615
i64 64 -9,223,372,036,854,775,808 9,223,372,036,854,775,807
# this is an example of the Uber API
# as a demonstration of an API spec in YAML
swagger: '2.0'
info:
title: Pastebin
description: A simple pastebin service
version: "1.0.0"
host: localhost:8000
schemes: