Skip to content

Instantly share code, notes, and snippets.

View ptb's full-sized avatar

Peter T Bosse II ptb

View GitHub Profile
@ptb
ptb / template.rb
Last active December 18, 2015 16:09
rails new myappname -J -T -m ~/Dropbox/template.rb
# https://gist.github.com/ptb/5809531
# rvm use --create ruby-2.1.1@#{app_name}
# gem install rails
# rails new app -J -T -m ~/Dropbox/template.rb
run 'gem update'
create_file '.ruby-version' do <<-RUBY_VERSION
2.1.1
define ->
class Detect
ios: ->
if @ipad() or @ipod()
# supports iOS 2.0 and later: <http://bit.ly/TJjs1V>
v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/)
return [true, parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)]
else
return [false]
- require 'date'
- require 'active_support'
- @d = Date.today
- @week1 = @d.beginning_of_month.beginning_of_week(:sunday)
- @weekn = @d.end_of_month.end_of_week(:sunday)
- @weeks = (@week1..@weekn).to_a.in_groups_of(7)
- content_for :head do
link[href='/test/table/calendar2.css' rel='stylesheet']/
# http://blog.jambura.com/2013/03/27/test-your-websites-features-in-firefox-safari-and-chrome-using-rspec-and-capybara-with-selenium/
# brew install go
# git clone --depth 1 https://github.com/SeleniumHQ/selenium.git
# https://developer.apple.com/account/safari/certificate/
# selenium/go safari
# open build/javascript/safari-driver/
# Safari > Develop > Show Extension Builder > Add Extension
Capybara.register_driver :safari do |app|
Capybara::Selenium::Driver.new(app, :browser => :safari)
end
require ['jquery', 'calculator'], ($, Calculator) ->
$ ->
calc = new Calculator()
alert calc.add(4, 8)
calc.paint('#item')
@ptb
ptb / ioscssclasses.js
Last active December 10, 2015 23:58
On iOS devices, add CSS classes to <html> element for Retina display support, iPod or iPad device class, and iOS version. iPod touches and iPhones both use the 'ipod' class for brevity. Example result: <html class='ios1 ios2 ios3 ios4 ios5 ios6 ipod online portrait retina transform3d'>
/*! gist.github.com/4512971 | (c) 2013 Peter T Bosse II | Apache license */
/*! Portions from: jqtouch.com | (c) 2009-2013 Sencha Labs | MIT license */
/*jshint camelcase:true, curly:true, eqeqeq:true, quotmark:single, unused:true, laxbreak:false, onevar:true, latedef:true, trailing:true, indent:2, white:true, strict:true, browser:true, devel:true, jquery:true, prototypejs:true, undef:true */
(function () {
'use strict';
function iPod() {
return (/iP(hone|od)/.test(navigator.platform));
}
@ptb
ptb / hideurltextfield.js
Last active December 10, 2015 21:18
On iPhone and iPod touch, automatically hide Mobile Safari's URL text field on page load, orientation changes, and resize.
/*! gist.github.com/4494626 | (c) 2013 Peter T Bosse II | Apache license */
/*jshint camelcase:true, curly:true, eqeqeq:true, quotmark:single, unused:true, laxbreak:false, onevar:true, latedef:true, trailing:true, indent:2, white:true, strict:true, browser:true, devel:true, jquery:true, prototypejs:true, undef:true */
(function () {
'use strict';
// Inspired by: <http://www.apress.com/9781430230458>
// Beginning iPhone & iPad Web Apps: Scripting with HTML5, CSS3, & JS
// Chapter 4: Pages 85-86: Hiding Mobile Safari's Address Bar
@ptb
ptb / iOSVersion.js
Created January 8, 2013 20:33
Javascript function returns an array of iOS 2.0 and later version integers.
var iOSversion = function() {
if (/iP(hone|od|ad)/.test(navigator.platform)) {
// supports iOS 2.0 and later: <http://bit.ly/TJjs1V>
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
}
};
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
String one = "Target Temp";
String two = "Current Temp";
byte degreesf[8] = {
0b11000,
0b11000,
@ptb
ptb / postflight.sh
Created August 8, 2011 14:58
Mac OS X Lion setup
#!/bin/sh