Skip to content

Instantly share code, notes, and snippets.

@RyanScottLewis
RyanScottLewis / Makefile
Last active September 14, 2017 00:22
Example Arduino Makefile
ARDMK_DIR = /usr/local/opt/arduino-mk
MONITOR_PORT = /dev/tty.usbmodem1421 # NOTE: This will have to be updated to the path of the Arduino device
ISP_PROG = arduino
ISP_PORT = $(MONITOR_PORT)
CFLAGS_STD = -std=gnu11
CXXFLAGS_STD = -std=gnu++11
CXXFLAGS += -pedantic -Wall -Wextra
OBJDIR = bin/$(BOARD_TAG)/$(CURRENT_DIR)
USER_LIB_PATH = lib
int points = 1000;
float xOffset = 0;
float yOffset = -1000;
float offsetStepIncrement = 0.01;
float offsetFrameIncrement = 0.002;
float size = 7000;
float sizeMultiplier = 0.99;
float noiseIncrement = 2;
float hue = 0;
float hueIncrement = 0.001;
#!/usr/bin/env ruby
# vim: syntax=ruby
# light v0.0.1
# Display a bright screen to use your device's screen as a light
#
# Created By: Ryan Scott Lewis <ryanscottlewis@gmail.com>
# License: MIT
# TODO
#!/usr/bin/env ruby
# Check to see if connected to the internet by checking if the oldest domain is resolveable via DNS
# and if not, restart a WiFi profile.
unless Process.uid.zero?
puts "ERROR: Must be run as a superuser"
exit
end
@RyanScottLewis
RyanScottLewis / ranger-cd.bash
Last active September 7, 2016 15:23
Ranger Bash/Zsh Integration
function ranger-cd {
tempfile="$(mktemp -t tmp.XXXXXX)"
$(which ranger) --choosedir="$tempfile" "${@:-$(pwd)}"
test -f "$tempfile" &&
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
cd -- "$(cat "$tempfile")"
fi
rm -f -- "$tempfile"
}
[-242942.0, 137291.5, -94339.6015625, 720213.25, 618422.9375, -484450.5625, -458720.3125, -711049.875, 449504.1875, -1770862.5, 2975486.0, 207335.796875, 215908.3125, 11305.52734375, 62522.6484375, 127898.765625, 664322.75, -269724.96875, 402957.0625, -97711.53125, -196356.75, 492522.9375, -429303.78125, 90851.3046875, 97209.375, -414716.15625, 151576.921875, 105870.46875, 26088.39453125, 138286.4375, 153877.59375, -2632.970703125, 28394.94140625, 75804.0546875, -990.9619140625, -88740.53125, -47794.9609375, -24309.380859375, 101186.3125, 11203.7890625, 20218.685546875, -193312.03125, 130143.8359375, -9540.03125, -18865.931640625, 37143.68359375, -83075.015625, -67459.65625, 44172.6640625, 130646.609375, 50461.34375, 33891.34375, 70996.8359375, 17823.6171875, 35496.921875, 48788.984375, -2605.65625, 69496.2265625, 104941.34375, 27142.48828125, 59214.484375, 9483.03125, 74139.125, -78937.625, -9227.671875, 103007.53125, 21385.90625, 12472.0625, -1495.0625, 5286.8125, 14058.15234375, 919.9375, -78964.703125, -1
RyBookPro:Desktop ryguy$ ./slop_iterm_example
{:terminal=>"iTerm", :help=>nil}
RyBookPro:Desktop ryguy$ ./slop_iterm_example --help
Usage: slop_iterm_example [options]
-t, --terminal Terminal to use. (default: iTerm)
-h, --help Display this help message.
RyBookPro:Desktop ryguy$ ./slop_iterm_example --terminal=MyTerm
{:terminal=>"MyTerm", :help=>nil}
RyBookPro:Desktop ryguy$ ./slop_iterm_example --terminal MyTerm
{:terminal=>"MyTerm", :help=>nil}
PubSub::Session#initialize(publisher_thread_limit=5, subscriber_thread_limit=5)
PubSub::Session#queue
PubSub::Session#publish(message) # Pull a thread from the publisher thread pool and in it, create a new Publisher instance and then push to the queue with it
PubSub::Session#wait # # Pull a thread from the subscriber thread pool and in it, create a new Subscriber instance and then pop from the queue with it, then perform the subscribers #on_message
PubSub::Session#publishers
PubSub::Session#subscribers
PubSub::Publisher#initialize(session)
PubSub::Publisher#session
PubSub::Publisher#publish(message)
require 'thread'
class Enumerator
def in_threads(threads=4, &block)
queue = Queue.new
each { |*args| queue << args }
threads.times.collect do
Thread.new { block.call(*queue.pop) until queue.empty? }
require 'pp'
class Middleware
def initialize(app)
@app = app
puts "=-=-=- Initializing #{self.class}"
pp app
end