Skip to content

Instantly share code, notes, and snippets.

View netsprout's full-sized avatar
🌻
Working on automating my food computer...

Aaron Fry netsprout

🌻
Working on automating my food computer...
View GitHub Profile
@netsprout
netsprout / bubble_sort.rb
Last active August 5, 2020 05:48
My bubble sort
#!/bin/ruby
require 'json'
require 'stringio'
def count_swaps(sort_me)
is_sorted = false
swap_count = 0
while is_sorted == false
@netsprout
netsprout / closures.rb
Created March 26, 2019 18:00
Fun with Ruby Closures
def aclosure(outer)
-> (inner) {inner + outer}
end
add3 = aclosure(3)
add10 = aclosure(10)
puts add3.call(5)
puts add10.call(5)
@netsprout
netsprout / dev_branch_naming.sh
Last active March 8, 2016 07:18
Standardize Development Branches
function branchit() {
if [ $# -lt 3 ]
then
echo "Usage : habitbranch [b|f|c|r|p] description pivotalID"
return
fi
local category="$1"
local description="$2"
local pivid="$3"
@netsprout
netsprout / git_cleanup_shell_aliases.sh
Created March 8, 2016 06:11
Git Branch Cleanup Shell Aliases
## Git branch cleanup
# remove remote branches merged into my local development
alias gitcleanupremote='git branch --merged development | grep -v "\*" | grep -v "master*" | grep -v "developoment" | xargs -I {} git push origin :{}'
# rename for deletion local branches merged into my local development
alias gitcleanup='git branch --merged development | grep -v "\*" | grep -v "master*" | grep -v "developoment" | xargs -I {} git branch -m {} "DELETEME-{}"'
# Delete branches marked for delete
alias gitdestroy='git branch | grep DELETEME- | xargs -n 1 git branch -d'
@netsprout
netsprout / inject_splash_css.js
Last active November 6, 2015 23:24
DK Interstitial CSS Hacks: Hacking the splash ad css and injecting it into the DOM on the console
$('.interstitial-ad iframe:visible')
.contents()
.find('head')
.append("<style type='text/css'> body { background: red; } </style>")
$('.interstitial-ad iframe:visible')
.contents()
.find('head')
.append("<style type='text/css'>#ad-button { height: 26px !important; top: 212px !important; left: 270px !important; } </style>")
@netsprout
netsprout / phone_dial_combinations.rb
Last active August 29, 2015 14:19
Phone Dial Combinations
keypad = {
'2': ['A','B','C'],
'3': ['D', 'E', 'F'],
'4': ['G','H','I'],
'5': ['J','K','L'],
'6': ['M','N','O'],
'7': ['P','Q','R','S'],
'8': ['T','U','V'],
'9': ['W','X','Y','Z']
@netsprout
netsprout / max_profit.rb
Created April 7, 2015 06:45
Max Profit In Single Day Stock Prices
# There is an array stock_prices_yesterday where:
# * The indices are the time in minutes past trade opening time, which was 9:30am local time.
# * The values are the price in dollars of Apple stock at that time.
# For example, the stock cost $500 at 10:30am, so stock_prices_yesterday[60] = 500.
# Write an efficient algorithm for computing the best profit I could have made from 1 purchase and 1 sale of 1 Apple stock yesterday.
# No "shorting"—you must buy before you sell. You may not buy and sell in the same time step (at least 1 minute must pass).
def get_max_profit(stock_prices_yesterday)
@netsprout
netsprout / generate_multi_table.rb
Created March 28, 2015 05:05
Generate HTML Multiplication Table
# AngelList Interview
# March 27, 2015
# create HTML table given width and height
#
# Example:
# w = 2
# h = 3
# would generate:
# - 1 2
# 1 1 2
@netsprout
netsprout / tic_tac_toe.rb
Last active December 17, 2015 11:29
Tic Tac Toe Command Line Game... who needs an iPhone when you can fire up a terminal window :)
# Command Line Tic Tac Toe Game
#
# On the command line:
#
# $ ruby tic_tac_toe.rb
# Class that controlls the game.
#
# Examples
#
@netsprout
netsprout / minitest_helper.rb
Created May 17, 2013 23:39
Sample helper file for minitest and minitest/spec running with rspec/mocks and simplecov (in a rails engine)
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"
if ENV['COVERAGE']
require 'simplecov'
SimpleCov.start do
add_filter '/test/'
end
end
require File.expand_path("../dummy/config/environment.rb", __FILE__)