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 User < ActiveRecord::Base | |
has_many :columns | |
def as_json(options={}) | |
attributes.slice(:id, :email, :uuid).merge(:columns => columns) | |
end | |
end | |
class Column < ActiveRecord::Base | |
belongs_to :user | |
has_many :boxes |
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
// | |
// OLD AND BUSTED | |
// | |
if ([self.zoomingDelegate respondsToSelector:@selector(zoomingWindow:didZoomOutViewController:)] == YES) | |
{ | |
// Do something important. | |
} | |
// |
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
# ActiveRecord refuses to enable query caching _unless_ you have the following setup | |
# 1) you _must_ use ActiveRecord::Base.configurations to store your auth details | |
# 2) you _must_ include the ActiveRecord::QueryCache middleware | |
# 3) you _must_ inherit from the _Base_ connection -- abstract models don't | |
# cache without a bit of hacking, it only query caches anything from AR::Base | |
require 'sinatra' | |
require 'active_record' | |
# query caching requires that you use AR::Base.configurations to store your |
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
// utils/computed/search.js | |
import Ember from 'ember'; | |
var computed = Ember.computed; | |
export default function search(dependentKey, propertyKey, searchQueryKey, returnEmptyArray) { | |
returnEmptyArray = (typeof returnEmptyArray === "undefined") ? false : returnEmptyArray; | |
return computed("" + dependentKey + ".@each." + propertyKey, searchQueryKey, function() { | |
var items, query; | |
if (returnEmptyArray && !this.get(searchQueryKey)) { | |
return Ember.A([]); |
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
// General purpose timer service | |
import Ember from 'ember'; | |
export default Ember.Service.extend({ | |
interval: 5000, | |
// Schedules function `f` to be executed on interval | |
schedule(f, interval) { | |
const time = interval || this.get('interval'); | |
return Ember.run.later(this, function() { |
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
# Terminal Progress Indicators. Four examples are included: percentage, | |
# spinner, progress bar, and combined. This script has been tested on | |
# Mac OS X 10.8 with Ruby 1.8.7, 1.9.1, 1.9.2, and 1.9.3 | |
class Spinner | |
include Enumerable | |
def each | |
loop do | |
yield '|' | |
yield '/' |
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 SwiftUI | |
import PlaygroundSupport | |
struct whatsNewRow: View { | |
var icon: String | |
var title: String | |
var description: String | |
var body: some View { | |
HStack (spacing: 24) { |
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
cassettes |
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
#Deploy and rollback on Heroku in staging and production | |
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
namespace :deploy do | |
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU' | |
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU' | |
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag] | |
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on] |
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
# Step 1 | |
def create_subscription(email, plan_id, payment_method_id) do | |
with %User{customer_id: nil, name: name} = user <- | |
Repo.get_by(User, email: email), | |
{:ok, %Stripe.Customer{id: customer_id}} <- | |
Stripe.Customer.create(%{ | |
name: name, | |
email: email, | |
payment_method: payment_method_id, |
OlderNewer