View up_yours_capybara.rb
source = page.all('.item').last | |
target = page.all('.item').first | |
while source.nil? | |
source = page.all('.item').last | |
end | |
while target.nil? | |
target = page.all('.item').first | |
end |
View harmful_callbacks.rb
class User < ActiveRecord::Base | |
after_create :send_welcome_email | |
private | |
def send_welcome_email | |
UserMailer.welcome_email(self).deliver | |
end | |
end |
View types.swift
let jsonObject : AnyObject! = NSJSONSerialization.JSONObjectWithData(dataFromTwitter, options: NSJSONReadingOptions.MutableContainers, error: nil) | |
if let statusesArray = jsonObject as? NSArray{ | |
if let aStatus = statusesArray[0] as? NSDictionary{ | |
if let user = aStatus["user"] as? NSDictionary{ | |
if let userName = user["name"] as? NSDictionary{ | |
//Finally We Got The Name | |
} | |
} | |
} |
View create_project.rb
class CreateProject | |
include Interactor | |
def call | |
context.project = context.controller.current_user.projects.build(context.project_params) | |
if context.project.save | |
context.notice = 'Your project was created successfully.' | |
send_emails_for(context.project) | |
else |
View uninstall_homebrew.sh
#!/bin/sh | |
# Just copy and paste the lines below (all at once, it won't work line by line!) | |
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY! | |
function abort { | |
echo "$1" | |
exit 1 | |
} | |
set -e |
View akon.html.haml
- Akon.perform | |
- content_for :javascript do | |
:javascript | |
window.sing(jQuery(jQuery("bill y'all"))); |
View ams_endpoint.rb
class FoosController < ApplicationController | |
def index | |
@collection = Foo.all | |
render json: @collection, fields: params[:fields] | |
end | |
end | |
class FooSerializer < ActiveModel::Serializer | |
cache key: 'foo' | |
View spotifyapigist.js
// Loading a Track | |
var track = Track.fromURI(uri, function(track) { | |
console.log(track.name + " loaded!"); | |
if (track.playable) | |
// handle case in which some tracks are not playable | |
[...] | |
}); | |
// Loading an Album |
View gitgoggles.js
var GitGoggles = { | |
getRepos: function(callback) { | |
this._get('repositories', callback); | |
}, | |
getRepo: function(repo, callback) { | |
this._get('repository/' + repo, callback); | |
}, | |
View iOSRecipes15-1.m
static NSString *CellID = @"CustomCell"; | |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID]; | |
if (cell == nil) { | |
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID]; | |
UIImage *rainbow = [UIImage imageNamed:@"rainbow"]; | |
UIImageView *mainImageView = [[UIImageView alloc] initWithImage:rainbow]; | |
UIImageView *otherImageView = [[UIImageView alloc] initWithImage:rainbow]; | |
CGRect iconFrame = (CGRect) { { 12.0, 4.0 }, rainbow.size }; |
OlderNewer