Skip to content

Instantly share code, notes, and snippets.

View hrs's full-sized avatar

Harry R. Schwartz hrs

View GitHub Profile
@hrs
hrs / aws-ssh.tf
Created April 11, 2023 17:05
Minimal Terraform configuration to create an SSH server on AWS.
# This builds a publicly available SSH server on EC2.
#
# Make sure to edit the path to your public SSH key.
#
# Log in:
#
# $ ssh ubuntu@$(terraform output -raw public_ip)
terraform {
required_providers {
require "nokogiri"
require "open-uri"
require "optparse"
require "set"
MAX_DEPTH = 2
class Page
def initialize(body:, url:)
@body = body
require "rspec/autorun"
# An implementation of an immutable binary search tree in Ruby, with a small
# suite of tests. Supports #==, #insert, #delete, and #to_a (an in-order
# traversal).
#
# To run the tests, just evaluate the file: `ruby binary_search_tree.rb`
class Leaf
def ==(other)
@hrs
hrs / update.sh
Created July 18, 2017 12:59
Updating your dsss17 repo while preserving your changes
# Supposing that you're starting on the master branch...
# Create a new branch and switch to it:
git checkout -b my-work
# Commit your changes on that branch:
git add .
git commit -m "My work so far!"
# Update the master branch:
@hrs
hrs / alligators.cpp
Last active December 26, 2015 03:38
the alligators are heading east, unobfuscatedly.
int even_sum = 0;
int input = 0;
bool is_even = false;
cin >> input;
while (input > 0) {
is_even = ! (input % 2);
if (is_even) {
@hrs
hrs / random_emoji.rb
Created September 25, 2013 21:23
Generate a random GitHub emoji.
#!/usr/bin/env ruby
# Because sometimes you need a script that generates a random
# Github-compatible emoji.
emoji = %w{+1 -1 100 1234 8ball a ab abc abcd accept aerial_tramway
airplane alarm_clock alien ambulance anchor angel anger angry
anguished ant apple aquarius aries arrow_backward arrow_double_down
arrow_double_up arrow_down arrow_down_small arrow_forward
arrow_heading_down arrow_heading_up arrow_left arrow_lower_left
@hrs
hrs / obfuscated_christmas.c
Last active September 26, 2015 09:18
An Obfuscated Christmas
#include <stdio.h>
main(t,_,a)
char *a;
{
return!0<t?t<3?main(-79,-13,a+main(-87,1-_,main(-86,0,a+1)+a)):
1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13?
main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l+,/n{n+,/+#n+,/#\
;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \
q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;#\
@hrs
hrs / fizzbuzz.rb
Created March 31, 2015 21:49
Design Pattern Frolics!
class MessageDispatcher
def initialize
@observers = []
end
def register(observer)
@observers << observer
end
def dispatch(message)
@hrs
hrs / process_tree.rb
Created January 16, 2015 22:36
Generate a graph of the process tree
#!/usr/bin/env ruby
class UnixProcess
attr_reader :uid, :pid, :ppid, :cmd
def initialize(uid:, pid:, ppid:, cmd:)
@uid = uid
@pid = pid
@ppid = ppid
@cmd = cmd
@hrs
hrs / say_repl.rb
Created July 21, 2014 01:25
REPL for Say
#!/usr/bin/env ruby
class SayRepl
attr_reader :voice
def initialize(voice)
@voice = voice
end
def go