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 / 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)
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 / 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
@bigtunacan
bigtunacan / tmux_session
Created April 14, 2014 16:39
tmux session script
#!/bin/bash
cd ~/code/eiacuc
tmux has-session -t eiacuc
if [ $? != 0 ]
then
tmux new -s eiacuc -n vim -d
tmux send-keys -t eiacuc 'vim' C-m
tmux split-window -v -p 20 -t eiacuc
tmux send-keys -t eiacuc:0.1 'cd ~/code/eiacuc' C-m
tmux new-window -n server -t eiacuc
require "peach"
mutex = Mutex.new
t=(1..500000).map{ rand};
a=0;
t2=t.pmap(4) do |z|
mutex.lock
a+=1;
mutex.unlock
@bigtunacan
bigtunacan / cylon-joystick error
Created October 10, 2014 07:02
After installing all SDL dependencies still getting errors from cylon-joystick on the Beaglebone Black
root@beaglebone:~/code/cylon# node main.js
I, [2014-10-10T07:01:35.775Z] INFO -- : Initializing connections.
I, [2014-10-10T07:01:35.798Z] INFO -- : Initializing connection 'joystick'.
D, [2014-10-10T07:01:35.805Z] DEBUG -- : Loading adaptor 'joystick'.
Error: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
@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
@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'
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
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