Skip to content

Instantly share code, notes, and snippets.

View rringler's full-sized avatar

Ryan Ringler rringler

  • Google
  • San Francisco, CA
View GitHub Profile
path=$(dirname "$1")
basename="animated"
filename="animated.gif"
counter="0"
while [ -e "$path/$filename" ]; do
((counter++))
filename="$basename ($counter).gif"
done
@rringler
rringler / keybase.md
Created December 6, 2017 20:23
Keybase Verification

Keybase proof

I hereby claim:

  • I am rringler on github.
  • I am rringler (https://keybase.io/rringler) on keybase.
  • I have a public key ASBqcATXxSioDtJfMXH7O-qQRe_Z-dH_wxpPg3wfSH-olAo

To claim this, I am signing this object:

@rringler
rringler / python-pid_controller
Created July 6, 2018 03:58 — forked from chaosmail/python-pid_controller
Simple PID Controller
def pid_controller(y, yc, h=1, Ti=1, Td=1, Kp=1, u0=0, e0=0)
"""Calculate System Input using a PID Controller
Arguments:
y .. Measured Output of the System
yc .. Desired Output of the System
h .. Sampling Time
Kp .. Controller Gain Constant
Ti .. Controller Integration Constant
Td .. Controller Derivation Constant
@rringler
rringler / pid.rb
Created July 21, 2018 18:25
Ruby PID Controller
class PID
attr_reader :delta_t,
:kp,
:ki,
:kd,
:output_p_prev,
:output_i_prev,
:output_min,
:output_max,
:setpoint,
require 'tsort'
class UndirectedGraph < Hash
include TSort
def initialize(size, edges)
super().tap do |hash|
(1..size).each { |i| hash[i] = [] }
edges.each do |(a, b)|
@rringler
rringler / quicksort.rb
Created September 30, 2018 20:29
Quicksort (Ruby)
def quicksort(array, left = 0, right = nil)
right ||= array.size - 1 # Sort the whole array be default
# NOTE: This is subtle; we only need to perform the sorting if `left` is less
# than `right`
if left < right
index = sort(array, left, right)
quicksort(array, left, index - 1) # Sort left sub_array
quicksort(array, index + 1, right) # Sort right sub_array