Skip to content

Instantly share code, notes, and snippets.

View houhoulis's full-sized avatar

Chris Houhoulis houhoulis

View GitHub Profile
@houhoulis
houhoulis / open_grapher.html
Created March 23, 2017 00:29
Highchart graph from URL search parameters
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<body>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container"></div>
<script>
@houhoulis
houhoulis / requirements_spec.rb
Created March 7, 2018 06:53
hypothetical feature spec for displaying auto-assign field in `spec/features/requirements_spec.rb`
require 'rails_helper'
RSpec.describe "Requirements" do
# ... skipping over what's already in this file....
describe "requirement index page" do
it "renders auto_assign field" do
event = create :event
task = create :task, event: event
@houhoulis
houhoulis / settings.js
Last active October 13, 2018 18:38
ms vs code customizations
{
"[rust]": {
"editor.tabSize": 4,
"editor.insertSpaces": true
},
"bracketPairColorizer.forceUniqueOpeningColor": false,
"bracketPairColorizer.forceIterationColorCycle": false,
"bracketPairColorizer.colorMode": "Consecutive",
//"bracketPairColorizer.scopeLineCSS": ["{color}"],
@houhoulis
houhoulis / methods.md
Last active April 30, 2018 23:43
How define a method with a default argument of `nil` that can detect whether `nil` or no argument was passed in?

How define a method which takes an optional argument w/ a default value, but you have to distinguish whether the default arg or no arg was passed in?

class Foo
  def bar(a = "whatevs")
    # Was "whatevs" passed in, or no arg?
  end
end

Two very different examples that distinguish between nil and no arg:

@houhoulis
houhoulis / cities.json
Created June 1, 2020 21:00 — forked from Miserlou/cities.json
1000 Largest US Cities By Population With Geographic Coordinates, in JSON
[
{
"city": "New York",
"growth_from_2000_to_2013": "4.8%",
"latitude": 40.7127837,
"longitude": -74.0059413,
"population": "8405837",
"rank": "1",
"state": "New York"
},
@houhoulis
houhoulis / weekly_release.py
Created September 22, 2020 20:47 — forked from alicegoldfuss/weekly_release.py
Weekly Release Script
#!/usr/local/bin/python3
import requests
import json
from twilio.rest import Client
HEADERS = {'Accept': 'application/vnd.github.inertia-preview+json'}
GH_TOKEN = "XXX" # Your auth token from https://github.com/settings/tokens
TW_SID = "XXX" # Your Account SID from twilio.com/console
TW_TOKEN = "XXX" # Your Auth Token from twilio.com/console
@houhoulis
houhoulis / trash_image_capture_dupes.rb
Created September 26, 2020 19:19
Find dupes that Apple's "Image Capture.app" is creating when importing photos from my camera, & move to trash. Compare dupes to the previous dupe (or original) via md5.
require 'digest'
def filenames
Dir.entries('.').sort
end
def digest filename
Digest::MD5.hexdigest File.read(filename)
end
@houhoulis
houhoulis / typing_accuracy.rb
Created January 6, 2021 16:48
Calculate approximate typing accuracy -- a % of words typed correctly -- from % accuracy figures on individual keys
# I have been learning touch-typing, largely using https://www.typingstudy.com.
# At the end of each drill, it breaks down your performance by % accuracy on each key. This is helpful.
# However, drills on some other sites report % word accuracy.
# This method calculates a crude approximation of word accuracy from a passed-in list of character
# accuracies, by considering all combinations of a specific word length (default 4) of the passed-in
# percentages.
# Each letter percentage is treated as equal.
# We don't generate repeated-letter combination beyond what's passed in, to reduce the exponential
# increase in possible combinations. In other words:
@houhoulis
houhoulis / settings.json.js
Last active September 14, 2022 20:57
vscodium
{
"installed.extensions.are": "Better TOML bungcip, Bracket Pair Colorizer 2 CoenraadS, Crystal Language crystal-lang-tools, Elm elmtooling, Gitlens, Highlight trailing white spaces ybaumes, indent-rainbow oderwat, Liqube Dark Code liqube, Solargraph castwide, Rust",
"[rust]": {
"editor.tabSize": 4,
"editor.insertSpaces": true
},
"[elm]": {
"editor.tabSize": 4,
@houhoulis
houhoulis / snow.rb
Last active March 18, 2023 01:33
Snowflakes falling in terminal in Ruby
# Seen on https://connectified.com/@ruby_discussions@mastodon.social/109993732600145441.
# Fixed data structure bug, added drift & other changes/improvements.
# Ruby version doing the same calculations as the elixir version in snow.exs
HEIGHT = `tput lines`.to_i
WIDTH = `tput cols`.to_i
SLEEP_DURATION = 0.5
LIFETIME = HEIGHT + 30
WIND_SPEED = [-2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0].sample * [-2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0].sample / 4.21