Skip to content

Instantly share code, notes, and snippets.

View ptb's full-sized avatar

Peter T Bosse II ptb

  • 23:29 (UTC -04:00)
View GitHub Profile
require ['jquery', 'calculator'], ($, Calculator) ->
$ ->
calc = new Calculator()
alert calc.add(4, 8)
calc.paint('#item')
# 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 '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']/
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]
@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
@ptb
ptb / gist:5886864
Last active December 19, 2015 02:59
token based ActiveRecord
SEED = 12345678901
def self.find_by_token(token)
id = token.reverse.to_i(36) - Thing::SEED
find(id)
end
def token(input = self.to_param)
(input.to_i + Thing::SEED).to_s(36).reverse
end
@ptb
ptb / reference.html.haml
Created January 17, 2014 16:33
CSS Reference
!!! 5
%html{:lang => 'en', :xmlns => 'http://www.w3.org/1999/xhtml'}
%head
%meta{:charset => 'utf-8'}/
%title CSS Reference and Sort Order
:sass
body
counter-reset: linenumbers
@ptb
ptb / reference.html
Created January 17, 2014 16:41
CSS Reference
<!DOCTYPE html>
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta charset='utf-8'>
<title>CSS Reference and Sort Order</title>
<style>
body {
counter-reset: linenumbers;
margin-left: 2em; }
.loading::after{display:inline-block;content:'';width:20px;height:20px;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg%20viewBox%3D'0%200%20120%20120'%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20xmlns%3Axlink%3D'http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink'%3E%3Cdefs%3E%3Cline%20id%3D'l'%20x1%3D'60'%20x2%3D'60'%20y1%3D'7'%20y2%3D'27'%20stroke%3D'%238c8c8c'%20stroke-width%3D'11'%20stroke-linecap%3D'round'%2F%3E%3C%2Fdefs%3E%3Cg%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(30%2060%2C60)'%2f%3e%3cuse%20xlink%3ahref%3d'%23l'%20opacity%3d'.27'%20transform%3d'rotate(60%2060%2c60)'%2f%3e%3cuse%20xlink%3ahref%3d'%23l'%20opacity%3d'.27'%20transform%3d'rotate(90%2060%2c60)'%2f%3e%3cuse%20xlink%3ahref%3d'%23l'%20opacity%3d'.27'%20transform%3d'rotate(120%2060%2c60)'%2f%3e%3cuse%20xlink%3ahref%3d'%23l'%20opacity%3d'.27'%20transform%3d'rotate(150%2060%2c60)'%2f%3e%3cuse%20xlink%3ahref%3d'%23l'%20opacity%3d'.37'%20transform%3d'r
@ptb
ptb / index.html
Last active August 29, 2015 13:56
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'/>
<title></title>
</head>
<body>
<div id='main'></div>
<script data-main='js/main.js' src='js/require.js'></script>
</body>