Skip to content

Instantly share code, notes, and snippets.

View TeriPastorino's full-sized avatar

Teri Pastorino TeriPastorino

  • East Bay Area, CA
View GitHub Profile
<%= f.check_box :vote, :checked => true, :style => 'visibility: hidden' %>
import urllib2
import json
import re
response = urllib2.urlopen('http://api.embed.ly/v1/api/services/python')
services = json.loads(response.read())
url = 'http://soundcloud.com/dociler/dociler-futuricity'
for service in services:
for regex in service['regex']:
if re.match(regex, url):
print "Matched %s to %s" % (url, service['displayname'])
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created March 23, 2012 03:39
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@mark-ellul
mark-ellul / gist:3531320
Created August 30, 2012 15:45
Email Boilerplate as HAML with yield to use as layout in Rails actionmailer
!!! Strict
%html{:xmlns => "http://www.w3.org/1999/xhtml"}
%head
%meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}/
%meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}/
%title Your Message Subject or Title
:css
/* Based on The MailChimp Reset INLINE: Yes. */
/* Client-specific Styles */
#outlook a {padding:0;} /* Force Outlook to provide a "view in browser" menu link. */
@andyj
andyj / glyphicon_example.html
Created September 26, 2013 23:38
If you use Bootswatch files from the bootstrap CDN then to get the Glyphicons working you need to include glphicons css file @ http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css
<html>
<head>
<link href="//netdna.bootstrapcdn.com/bootswatch/3.0.0/flatly/bootstrap.min.css" rel="stylesheet">
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
</head>
<body>
<span class="alert alert-danger">Glyphicon example</span>
<hr>
<div class="the-icons">
<span class="glyphicon glyphicon-glass"></span>
@randalmaile
randalmaile / Loops checkpoint
Last active December 30, 2015 18:19
Loops checkpoint
# Each loop (non-assignment practice)
[1] pry(main)> a = ["red", "blue", "green"]
=> ["red", "blue", "green"]
[2] pry(main)> a.each do |color|
[2] pry(main)* p "The color is #{color}"
[2] pry(main)* end
"The color is red"
"The color is blue"
"The color is green"
@randalmaile
randalmaile / Advanced Classes checkpoint
Last active December 30, 2015 22:39
Advanced Classes checkpoint
#Inheritance
class Shape
attr_accessor :color
def initialize(color = nil)
@color = color || "Red"
end
def can_fit?(shapeInstance)
if self.area >= shapeInstance.area
# application_helper.rb
def bookmark_thumbnail(metadata)
image_tag(metadata[:thumbnail_url] || "thumb.png", width: "260")
end
# migration
add_column :bookmarks, :metadata, :text
# bookmark model
after_save :get_embedly_data
@oneawayman
oneawayman / advancedclasses
Created February 6, 2014 13:19
Bloc Web Development Advanced Classes Checkpoint
## Inheritance ##
class Shape
attr_accessor :color
def initialize(color = nil)
@color = color || 'Red'
end
def larger_than?(shape)