Skip to content

Instantly share code, notes, and snippets.

@mrampton
mrampton / download_aws_iam_auth.sh
Last active August 31, 2018 22:44
download aws-iam-authenticator and symlink as heptio-authenticator-aws
curl -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-07-26/bin/darwin/amd64/aws-iam-authenticator
curl -o aws-iam-authenticator.sha256 https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-07-26/bin/darwin/amd64/aws-iam-authenticator.sha256
openssl sha -sha256 aws-iam-authenticator
cat aws-iam-authenticator.sha256
chmod +x ./aws-iam-authenticator
cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$HOME/bin:$PATH
ln -s $HOME/bin/aws-iam-authenticator $HOME/bin/heptio-authenticator-aws
class PathFinder
def initialize(maze, start_pos=nil, end_pos=nil)
@maze = maze # NxN, [row][col]
@visited_pos = {} # pos => entry_pos
@start_pos = (start_pos || [0,0])
@end_pos = (end_pos || [@maze.length - 1 , @maze[0].length - 1])
end
def find_path
@mrampton
mrampton / HMap.rb
Last active October 26, 2016 19:28
class HMap
attr_accessor :values
@values
def initialize
@values = {}
end
def set(args)
@mrampton
mrampton / 3203_grade.rb
Created May 15, 2015 17:41
Asks for your hw and exam scores, calculates your 3203 grade
#!/usr/bin/env ruby
if __FILE__ == $PROGRAM_NAME
hw_weights = [ 40.0, 50.0, 40.0, 36.0, 37.0, 38.0 ]
hw_scores = []
hw_scores = hw_weights.each_with_index.collect do |max, i|
print "Enter hw #{i+1} score: "
(gets.to_f / max) * 20
@mrampton
mrampton / ocrify.sh
Created March 7, 2015 19:34
bash script to convert a PDF of images into a searchable PDF
#!/bin/bash
if [ ""$#"" -ne 1 ]; then
echo "usage: ocrify <filename.pdf>"
exit 0
fi
FILENAME=$1
OCRFILE=${FILENAME//./_OCR.}
#!/usr/bin/ruby
# example using problem 4.28 from Halliday Physics book
# ••28 In Fig. 4-34, a stone is pro-jected at a cliff of height h
# with an initial speed of 42.0 m/s directed at angle u0 􏰀 60.0° above
# the horizontal. The stone strikes at A, 5.50 s after launching. Find
# (a) the height h of the cliff, (b) the speed of the stone just before
# impact at A, and (c) the maximum height H reached above the ground.
class Fixnum
@mrampton
mrampton / weekchooser.js.coffee
Created March 16, 2012 01:04
working code example of jquery datepicker working as weekpicker
weekchooser = ->
$('#datepicker').datepicker({
dateFormat: "M d, yy",
altFormat: "M d, yy",
altField: "#actualdate",
selectWeek: true,
firstDay: 1,
showOtherMonths: true,
selectOtherMonths: true,
beforeShow: ->
@mrampton
mrampton / syncPodcasts.sh
Created April 11, 2011 18:42
Simple one line shell command to create symlinks for Dropbox -> iTunes/Podcasts folder
#!/bin/bash
HOME=/Users/username #replace username with your actual username
ITDIR=$HOME/Music/iTunes/iTunes\ Media/Podcasts/
DBDIR=$HOME/Dropbox/Podcasts/
rm -rf $DBDIR/* find “$ITDIR” -type f -size -39999k -print0 | xargs -0 -I file ln -s file $DBDIR