This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>World's Most Annoying Phone Input</title> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
max-width: 600px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Really this just figures out how many times [1, 2, 3].sample returns a given | |
# result vs the other two, which - shocker - is 1/3 (though that's kind of the | |
# point of the problem). But the output makes the result of _switching_ being | |
# the right decision a bit more intuitive to me. | |
class MontyHall | |
def initialize(num_games) | |
@num_games = num_games | |
@stand_pat_win_count = 0 | |
@switch_win_count = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Add or `ln -s` this into `/usr/local/bin/` | |
echo "Updating everything..." | |
echo "Updating Homebrew and all Homebrew packages" | |
brew update && brew upgrade && brew cleanup && brew doctor | |
echo "Updating all programming languages" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://thomasleecopeland.com/2017/04/20/shadowing-bug-in-the-wild.html | |
# https://docs.ruby-lang.org/en/2.4.0/syntax/assignment_rdoc.html#label-Local+Variables+and+Methods | |
# https://www.codinginthecrease.com/news_article/show/307337 | |
class Okay | |
def yep | |
"yep" | |
end | |
def nope |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker stop $(docker ps -qa); docker rm $(docker ps -qa); docker rmi -f $(docker images -qa); docker volume rm $(docker volume ls -q); docker network rm $(docker network ls -q) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Backup a folder to a remote address using borg. | |
# To restore: borg extract $BORG_REPO::computer-and-date | |
set -eu | |
# Will need a remote server setup with Borg, and a Borg repo first. | |
export BORG_REPO="<user>@<host>:<borg-repo>" | |
# Assuming you've installed Borg with Homebrew |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange | |
require "prime" | |
require "openssl" | |
class Client | |
def initialize | |
@private_key = rand(1..100000) | |
@clients = {} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1..100).each do |i| | |
[3, 5].each do |num| | |
define_method("klass_#{num}") do | |
Class.new do | |
if i % num == 0 | |
define_method("#{i}") do | |
call | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$styles: margin padding; | |
$directions: left right top bottom; | |
@each $style in $styles { | |
@for $i from 0 through 50 { | |
.#{$style}-#{$i} { #{$style}: #{$i}px; } | |
@each $direction in $directions { | |
.#{$style}-#{$direction}-#{$i} { #{$style}-#{$direction}: #{$i}px } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You'll probably want to Ctrl+C out of this one pretty quickly. | |
File.open($0, "r+") do |f| | |
content = f.read | |
puts content | |
f << content | |
f.close | |
sleep 5 | |
system "ruby", $0 |
NewerOlder