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
// Examples of pure functions. No side effects. No mutations. | |
function square(x) { | |
return x * x; | |
} | |
function squareAll(items) { | |
return items.map(square); | |
} | |
// Examples of impure functions. |
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 FoosController < ApplicationController | |
def index | |
@collection = Foo.all | |
render json: @collection, fields: params[:fields] | |
end | |
end | |
class FooSerializer < ActiveModel::Serializer | |
cache key: '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
- Akon.perform | |
- content_for :javascript do | |
:javascript | |
window.sing(jQuery(jQuery("bill y'all"))); |
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
#!/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 |
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 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 |
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
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 | |
} | |
} | |
} |
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 | |
after_create :send_welcome_email | |
private | |
def send_welcome_email | |
UserMailer.welcome_email(self).deliver | |
end | |
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
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 |
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
"use strict" | |
var Promise = function () { | |
this.state = 'pending' | |
this.thenables = [] | |
} | |
Promise.prototype.resolve = function (value) { | |
if (this.state != 'pending') return | |
this.state = 'fulfilled' |
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
git checkout bcee89a90aad3877da531d6cb10ca91c6155d577 -- app/assets/images/sales |
NewerOlder