Skip to content

Instantly share code, notes, and snippets.

@fallwith
fallwith / phone_number.rb
Created April 22, 2022 21:43
Annotated submission for the 'phone-number' Exercism exercise
# Any variable starting with a capital letter (including a class name!) is a
# constant in Ruby. For static values like this one, Rubyists typically use all
# caps for the variable name.
#
# %w = word array, use spaces without commas to delimit values
#
# #freeze, available on any instance of an object, prevents a value from being
# modified after it has been frozen. There is no #thaw or #unfreeze, but the
# value itself can be overwritten later if need be.
INVALID_CODES = %w[0 1].freeze
@fallwith
fallwith / challenge.rs
Last active December 28, 2020 07:39
A Rust attempt at a Ruby challenge
use chrono::{DateTime, Local};
use std::collections::HashMap;
use std::env;
use std::process;
use std::time::SystemTime;
const VERSION: &str = "0.1.0";
// a Rust attempt at the following Ruby coding challenge:
// https://gist.github.com/fallwith/00aa5f7a0d5c192e91fa6468e7434048
@fallwith
fallwith / ruby_challenge.md
Last active December 20, 2020 02:59
Ruby Challenge

Ruby Challenge

Introduction

This is a simple test of basic Ruby programming concepts. To complete this challenge, you will need to install Ruby 1.8.6 or later on your system. Rails is not required for this test.

This test is open book, and you may use whatever resources you need to complete it.

Instructions

@fallwith
fallwith / rainbow_colors.rb
Created September 24, 2019 19:02
Preview all of the Rainbow gem's supported colors
#!/usr/bin/env ruby
# frozen_string_literal: true
require "rainbow"
ansi_colors = %w[black red green yellow blue magenta cyan white]
x11_colors = %w[aliceblue antiquewhite aqua aquamarine azure beige bisque
blanchedalmond blueviolet brown burlywood cadetblue
chartreuse chocolate coral cornflower cornsilk crimson
darkblue darkcyan darkgoldenrod darkgray darkgreen darkkhaki
@fallwith
fallwith / view.rb
Created June 20, 2019 00:49
View - a simple terminal image viewer
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'base64'
#
# View is a simple terminal image viewer
#
# NOTE: currently only iTerm is supported
#
@fallwith
fallwith / gruvbox-dark.conf
Created March 18, 2019 07:45
Kitty terminal emulator colorschemes
# gruvbox-dark colorscheme for kitty
# snazzy theme used as base
# https://gist.github.com/lunks/0d5731693084b2831c88ca23936d20e8
foreground #ebdbb2
background #272727
selection_foreground #655b53
selection_background #ebdbb2
url_color #d65c0d
@fallwith
fallwith / colortest24bit.sh
Created January 13, 2019 22:00
Colors and images in the terminal
#!/bin/bash
# This file was originally taken from iterm2 https://github.com/gnachman/iTerm2/blob/master/tests/24-bit-color.sh
#
# This file echoes a bunch of 24-bit color codes
# to the terminal to demonstrate its functionality.
# The foreground escape sequence is ^[38;2;<r>;<g>;<b>m
# The background escape sequence is ^[48;2;<r>;<g>;<b>m
# <r> <g> <b> range from 0 to 255 inclusive.
# The escape sequence ^[0m returns output to default
@fallwith
fallwith / cafmpeg
Created December 3, 2018 23:10
Run caffeinate for the duration of an ffmpeg process
#!/usr/bin/env bash
set -euo pipefail
ffmpeg_pid=$(ps auwx | grep ffmpeg | grep -v grep | awk '{print $2}')
if [ "$ffmpeg_pid" == "" ]; then
echo "Cannot find an ffmpeg pid!"
exit -1
fi
@fallwith
fallwith / mp4it.sh
Last active January 15, 2019 00:48
ffmpeg sweet spot settings for x265
#!/usr/bin/env bash
set -euo pipefail
NAME=mp4it
VERSION=0.0.12
#
# mp4it
#
# ffmpeg front-end to take an input source (likely in mkv or m2ts format)
# and produce an h.265 formatted mp4 output file at the given location
@fallwith
fallwith / names.c
Last active March 1, 2018 01:16
Parallel processing examples
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
void *greet(void *name_ptr) {
sleep(1);
printf("Hello, %s\n", name_ptr);
return NULL;
}