This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
extern NSString *addressBookErrorDomain; | |
typedef NS_ENUM(NSInteger, AddressBookError) { | |
AddressBookErrorOK, | |
AddressBookErrorNoAddressBook, | |
AddressBookErrorNoAccess | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "spec_helper" | |
describe ExampleController do | |
context "GET #index" do | |
let(:resources) { FactoryGirl.create_list(:resource) } | |
before do | |
get :index | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS foo; | |
CREATE TEMPORARY TABLE foo (x FLOAT); | |
INSERT INTO foo VALUES (1); | |
INSERT INTO foo VALUES (2); | |
INSERT INTO foo VALUES (3); | |
INSERT INTO foo VALUES (4); | |
INSERT INTO foo VALUES (100); | |
SELECT avg(x), tmean(x, 2.0), tmean(x, 1.5) FROM foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.filter('bytes', function() { | |
return function(bytes, precision) { | |
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-'; | |
if (typeof precision === 'undefined') precision = 1; | |
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'], | |
number = Math.floor(Math.log(bytes) / Math.log(1024)); | |
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number]; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In spec_helper: | |
# RSpec.configure do |config| | |
# ... | |
# config.include(MockGeocoder) | |
# end | |
# | |
# In your tests: | |
# it 'mock geocoding' do | |
# mock_geocoding! # You may pass additional params to override defaults (i.e. :coordinates => [10, 20]) | |
# address = Factory(:address) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Api::RegistrationsController < Api::BaseController | |
respond_to :json | |
def create | |
user = User.new(params[:user]) | |
if user.save | |
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
return | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (window, document, $, undefined) { | |
if (!$.Deferred) throw 'jQuery 1.5 is required to use the jQuery.oauth script!'; | |
function require(name, url) { | |
if (window[name] === undefined) | |
return $.ajax({ type: 'GET', cache: true, dataType: 'script', url: url }); | |
} | |
$.oauth = function (options) { | |
var d = $.Deferred(); |