Skip to content

Instantly share code, notes, and snippets.

View snuggs's full-sized avatar
👤
Committing

Ahmid-Ra snuggs

👤
Committing
View GitHub Profile
module Arel
class TwitterArray
include Relation
attr_reader :array, :attribute_names_and_types
include Recursion::BaseCase
ATTR_MAP = {
:twitter_name => Attributes::String,
:id => Attributes::Integer,
# (T) - Twitter Updates
# id = Arel::Attributes::Integer.new nil, :id
# update = Arel::Attributes::String.new nil, :update
# tuples = [[1, "Hai I can haz cheezburgerz"], [2, "Nom!"], [0, "What can you haz?"]]
# headers = [Arel::Attributes::Integer.new(nil, :id), Arel::Attributes::String.new(nil, :update)]
# updates = Arel::Array.new tuples, headers
# find_twitter_user_updates_predicate = Arel::Predicates::Equality.new updates[:id], 9
@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")
@charissa
charissa / bicycle.rb
Created March 10, 2011 15:31
Bicycle2 refactors Bicycle
#!/opt/local/bin/ruby1.9
include Math
class Bicycle
attr_accessor :wheel_size, :chainring, :cassette, :name
# Create the object
def initialize(name = "A Bicycle",wheel_size=27,chainring=42,cassette=[28,24,21,18,16,14,12,11])
@name = name
@wheel_size=wheel_size
@chrisjacob
chrisjacob / README.md
Created July 5, 2011 12:32
ViewSource.me - Starting a new viewsource.me.PROJECT repository.

Global .gitignore

We don't want to polute the repository with a .gitignore file... so you must add common OS files to your Global .gitignore. If you don't already have a global .gitignore then follow the instructions below (from: http://help.github.com/ignore-files/) or skip to the next section.

cd ~   
touch .gitignore_global   
mate .gitignore_global   
@travis
travis / gist:1084767
Created July 15, 2011 14:16
testing facebook connect with capybara and rspec
require 'mogli'
module FacebookIntegrationHelpers
shared_context "with unconnected facebook user" do
let(:fb_user) { create_test_user(installed: false) }
after { fb_user.destroy }
end
def app_client
Mogli::AppClient.new(AppConfig.facebook.access_token, AppConfig.facebook.app_id)
@dyba
dyba / application.html.haml
Created November 1, 2011 02:35
Jasmine YML file
!!! 5
%html
%head
%title TESTAPP
= stylesheet_link_tag "application"
= javascript_include_tag "application", "registration"
= csrf_meta_tag
%body
%header
%h1#logo
class User
attr_reader :item
def self.create(name)
User.new(TABLES['users'].items.create(id: name))
end
def self.all
TABLES['users'].items.to_a.map{|i| User.new(i)}
end
@mildmojo
mildmojo / left_join_arel_example.rb
Last active April 5, 2024 16:00
LEFT JOIN in ARel for ActiveRecord in Ruby on Rails
# Here's a contrived example of a LEFT JOIN using ARel. This is an example of
# the mechanics, not a real-world use case.
# NOTE: In the gist comments, @ozydingo linked their general-purpose ActiveRecord
# extension that works for any named association. That's what I really wanted!
# Go use that! Go: https://gist.github.com/ozydingo/70de96ad57ab69003446
# == DEFINITIONS
# - A Taxi is a car for hire. A taxi has_many :passengers.
# - A Passenger records one person riding in one taxi one time. It belongs_to :taxi.
@madrobby
madrobby / gist:9476733
Created March 10, 2014 23:34
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
curl -H 'Authorization: token INSERTACCESSTOKENHERE' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/owner/repo/contents/path