Skip to content

Instantly share code, notes, and snippets.

View bigtunacan's full-sized avatar

Joiey Seeley bigtunacan

  • The University of Iowa
View GitHub Profile
@bigtunacan
bigtunacan / onehundredpoint.txt
Last active April 22, 2021 01:24
Cognoa Word Calculator
abactinally
abrogative
absinthol
acclimation
accumulate
acenaphthene
achroous
acknowledge
acriflavine
acromegaly
loop do
pid = fork do
puts 'foo'
exit 99
end
#ret_pid = waitpid(pid) # Tried this, but it blocks
ret_pid = wait2(pid, Process::WNOHANG) # Tried this, but it never gets a value
if ret_pid
puts 'got a returned pid'
@bigtunacan
bigtunacan / pdf.c
Last active December 12, 2015 02:28
Create a PDF from a webpage on iOS
- (NSString *)generatePDFFromWebView
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *pdfPath = [fileManager applicationSupportDirectory];
pdfPath = [pdfPath stringByAppendingPathComponent:@"exportedData.pdf"];
self.PDFCreator = [NDHTMLtoPDF createPDFWithURL:[NSURL URLWithString:@"www.cnn.com"]
pathForPDF:pdfPath
delegate:self
pageSize:kPaperSizeA4
require 'uri'
#require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
module WithinHelpers
def with_scope(locator)
locator ? within(locator) { yield } : yield
end
end
World(WithinHelpers)
@bigtunacan
bigtunacan / capybara_steps.rb
Created October 26, 2012 22:01
Capybara generic steps
require 'uri'
#require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
module WithinHelpers
def with_scope(locator)
locator ? within(locator) { yield } : yield
end
end
World(WithinHelpers)
@bigtunacan
bigtunacan / gosu-tk.rb
Created September 1, 2015 03:32
Show Gosu and Tk running side by side so we can add tradition UI along with Gosu apps.
require 'gosu'
require 'tk'
class GameWindow < Gosu::Window
def initialize
super 640, 480
self.caption = "Gosu Tutorial Game"
@frog = Gosu::Image.new("./frog_cling_1.png")
@x = 0
def wait_for_ajax
max_ajax_wait = 60
time_limit, interval = (Time.now + max_ajax_wait), 0.5
loop do
break if page.evaluate_script("(typeof(jQuery) !== 'undefined' && jQuery.active === 0)")
sleep interval
fail "Wait for AJAX timed out after waiting for #{max_ajax_wait} seconds" if Time.now > time_limit
end
end
require 'artoo'
connection :sphero, :adaptor => :sphero, :port => '/dev/tty.Sphero-YBB-AMP-SPP'
device :sphero, :driver => :sphero
connection :keyboard, adaptor: :keyboard
device :keyboard, driver: :keyboard, connection: :keyboard
def keypress(sender, key)
case key
@bigtunacan
bigtunacan / artoo_sphero_api.rb
Last active August 29, 2015 14:16
Artoo Sphero Access through API
require 'artoo'
#connection :loop
#device :passthru
connection :sphero, :adaptor => :sphero, :port => '/dev/tty.Sphero-YBB-AMP-SPP'
device :sphero, :driver => :sphero
api :host => '127.0.0.1', :port => '4321'
@bigtunacan
bigtunacan / sinatra_array_routes
Created October 10, 2014 15:43
Basic sample showing how routes could be created by enumerating over an array.
require 'sinatra'
enable :sessions
$foo = ['foo', 'bar']
$foo.each do |vi|
get '/' + vi do
erb :hello
end