James Miller bensie

View postmark_scrape.rb
1 2 3 4 5 6 7 8 9 10
require "mechanize"
require "nokogiri"
require "json"
 
emails = []
 
a = Mechanize.new
a.get("https://postmarkapp.com/login") do |login_page|
servers_page = login_page.form_with(:id => 'new_user_session') do |form|
form.send "user_session[login]", ARGV[0]
View product.json
1 2 3 4 5 6 7 8 9 10
"products" : {
"product" : {
"properties" : {
"id" : {
"type" : "string",
"index" : "not_analyzed"
},
"product_name" : {
"type" : "string",
"analyzer" : "keyword"
View base.rb
1 2 3 4 5 6 7 8 9 10
require "sinatra/base"
require "sinatra/namespace"
require "multi_json"
 
require "api/authentication"
require "api/error_handling"
require "api/pagination"
 
module Api
class Base < ::Sinatra::Base
View gphoto2-single
1 2 3 4 5 6 7 8 9 10
james@ubuntu:~$ time gphoto2 --capture-image-and-download --force-overwrite --filename='foo.jpg' --frames=3 --interval=5
Time-lapse mode enabled (interval: 5s).
Capturing frame #1/3...
New file is in location /capt0000.jpg on the camera
Saving file as foo.jpg
Deleting file /capt0000.jpg on the camera
Deleting 'capt0000.jpg' from folder '/'...
Waiting for next capture slot 3 seconds...
Capturing frame #2/3...
New file is in location /capt0001.jpg on the camera
View ghuser.rb
1 2 3 4 5 6 7 8 9
require "test/unit"
class GHUserTest < Test::Unit::TestCase
def setup
@user = GHUser.new("bensie")
end
 
def test_has_a_name
assert_equal "James Miller", @user.name
end
View gist:3830814
1 2 3 4 5 6 7 8 9
require "bundler/setup"
 
require "nokogiri"
 
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
xml.name "James" do
xml.number 1234
end
end
View sinatra_catch_all.rb
1 2 3 4 5 6 7 8 9 10
# Any unmatched request within the /api/ namespace should render 404 as JSON
# Stop the request here so that JSON gets returned instead of having it
# run through the whole Rails stack and spit HTML.
get "/*" do
halt_with_404_not_found
end
 
post "/*" do
halt_with_404_not_found
end
View celluloid.rb
1 2 3 4 5 6 7 8 9 10
require "celluloid"
 
class Runner
include Celluloid
 
def initialize
if block_given?
puts "starting instance run"
yield self
puts "finished instance run"
View time.rb
1 2 3 4 5 6 7
class Time
def self.iso8601(time)
formatter = NSDateFormatter.alloc.init
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
formatter.dateFromString time
end
end
View dup.sql
1 2 3
# Assumes you're looking to add a unique index to [:field1, :field2] and want to find duplicates to remove/fix them
 
SELECT id, field1, field2, count(*) FROM table GROUP BY field1, field2 HAVING count(*) > 1
Something went wrong with that request. Please try again.