Skip to content

Instantly share code, notes, and snippets.

View tylerjohnst's full-sized avatar
:fishsticks:

Tyler Johnston tylerjohnst

:fishsticks:
  • GitHub Staff
  • Saint Petersburg, FL
View GitHub Profile
@tylerjohnst
tylerjohnst / resizer.rb
Last active July 26, 2022 17:49
Ruby script that resizes the height of a chrome window by a fixed amount of pixels. Useful for debugging CSS/JS animation issues.
require 'shellwords'
def tell_chrome_to(*commands)
tell(%Q(application "System Events" to tell application process "Google Chrome"), *commands)
end
def tell(target, *commands)
["tell #{target}", *commands.flatten, 'end tell']
end
{
"openapi": "3.0.1",
"info": {
"title": "Claims API",
"version": "v1",
"description": "This is the Claims API top level description. \n\nEdit me in /lib/tasks/open_api.rake.\n"
},
"paths": {
"/api/v1/notices/claims": {
"post": {
@tylerjohnst
tylerjohnst / gist:21ba9c17fe1ce5004889532b4c61d62c
Created February 19, 2019 15:59
node-alpine installation diff
C /usr
A /usr/include
A /usr/include/node
A /usr/include/node/node_buffer.h
A /usr/include/node/node_object_wrap.h
A /usr/include/node/uv
A /usr/include/node/uv/win.h
A /usr/include/node/uv/aix.h
A /usr/include/node/uv/android-ifaddrs.h
A /usr/include/node/uv/errno.h
@tylerjohnst
tylerjohnst / wait-for
Last active February 12, 2019 17:26
Ability have the shell wait until a script returns a non zero
#!/usr/bin/env ruby
require 'optparse'
options = {
retries: 10,
delay: 1
}
parser = OptionParser.new do |opts|
@tylerjohnst
tylerjohnst / maybe.rb
Last active February 8, 2019 21:32
Don't do this in production, or do. I'm not your parent.
class Maybe
attr_reader :value
# @returns [Maybe]
def self.empty
@empty ||= new(nil)
end
def initialize(value, &block)
@value = value.is_a?(Maybe) ? value.value : value
version: '2'
services:
test:
environment:
ENV_TWO: 'overridden'
class Command
def initialize(command, target, script, uses_bash)
@command, @target, @script, @uses_bash = command, target, script, uses_bash
end
def result
command == :exec ? exec_command : run_command
end
def exec_command
Foo
Bar
Baz
Bing
/var/folders/5y/csxbdjv156n4fl25975s1x4w0000gn/T/ruby-build.20160921182951.4002 ~/.rbenv/versions
/var/folders/5y/csxbdjv156n4fl25975s1x4w0000gn/T/ruby-build.20160921182951.4002/ruby-2.3.1 /var/folders/5y/csxbdjv156n4fl25975s1x4w0000gn/T/ruby-build.20160921182951.4002 ~/.rbenv/versions
checking for ruby... /usr/local/bin/ruby
config.guess already exists
config.sub already exists
checking build system type... x86_64-apple-darwin16.0.0
checking host system type... x86_64-apple-darwin16.0.0
checking target system type... x86_64-apple-darwin16.0.0
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
def insertion_sort(collection)
collection.count.times do |i|
index = i
next if index.zero?
right_value = collection[i]
while index > 0
index -= 1
left_value = collection[index]
if right_value < left_value