This file contains hidden or 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
| // This method gives you an easier way of calling super | |
| // when you're using Backbone in plain javascript. | |
| // It lets you avoid writing the constructor's name multiple | |
| // times. You still have to specify the name of the method. | |
| // | |
| // So instead of having to write: | |
| // | |
| // User = Backbone.Model.extend({ | |
| // save: function(attrs) { | |
| // this.beforeSave(attrs); |
This file contains hidden or 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
| # Server App | |
| # This file must be in lib/myapp/api.rb | |
| module MyApp | |
| module Entities | |
| class Products < Grape::Entity | |
| expose :id, :code, :name, :short_description | |
| expose :description, :unless => { :collection => true } | |
| expose (:category) { |model, options| model.category.name } | |
| expose (:brand) { |model, options| model.brand.name } | |
| end |
This file contains hidden or 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
| # put this in /lib/resque.rb | |
| require 'mail' | |
| module Emailer | |
| class Send | |
| @queue = :issue_mailer | |
| def self.perform(addressee, subject, body) |
This file contains hidden or 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
| /*! | |
| * quantize.js Copyright 2008 Nick Rabinowitz. | |
| * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php | |
| */ | |
| // fill out a couple protovis dependencies | |
| /*! | |
| * Block below copied from Protovis: http://mbostock.github.com/protovis/ | |
| * Copyright 2010 Stanford Visualization Group | |
| * Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php |
This file contains hidden or 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
| <?php | |
| // Originally by Andrew Moore | |
| // Src: http://stackoverflow.com/questions/4795385/how-do-you-use-bcrypt-for-hashing-passwords-in-php/6337021#6337021 | |
| // | |
| // Heavily modified by Robert Kosek, from data at php.net/crypt | |
| class Bcrypt { | |
| private $rounds; | |
| private $prefix; |
This file contains hidden or 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
| <?php | |
| // secure hashing of passwords using bcrypt, needs PHP 5.3+ | |
| // see http://codahale.com/how-to-safely-store-a-password/ | |
| // salt for bcrypt needs to be 22 base64 characters (but just [./0-9A-Za-z]), see http://php.net/crypt | |
| $salt = substr(strtr(base64_encode(openssl_random_pseudo_bytes(22)), '+', '.'), 0, 22); | |
| // 2y is the bcrypt algorithm selector, see http://php.net/crypt | |
| // 12 is the workload factor (around 300ms on my Core i7 machine), see http://php.net/crypt |
This file contains hidden or 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
| PADRINO_ENV = 'test' unless defined?(PADRINO_ENV) | |
| require 'rubygems' | |
| require 'spork' | |
| Spork.prefork do | |
| # Loading more in this block will cause your tests to run faster. However, | |
| # if you change any configuration or code from libraries loaded here, you'll | |
| # need to restart spork for it take effect. | |
This file contains hidden or 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 | |
| ### BEGIN INIT INFO | |
| # Provides: unicorn | |
| # Required-Start: $local_fs $remote_fs mysql | |
| # Required-Stop: $local_fs $remote_fs | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: unicorn initscript | |
| # Description: Unicorn is an HTTP server for Rack application | |
| ### END INIT INFO |
This file contains hidden or 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
| <html> | |
| <head> | |
| <style> | |
| html,body {margin:0;padding:0;} | |
| #app { | |
| height:100%; | |
| display: -webkit-box; | |
| -webkit-box-orient: vertical; | |
| -webkit-box-align:stretch; |
This file contains hidden or 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
| #content | |
| .left.column | |
| %h2 Welcome to our site! | |
| .right.column | |
| #users | |
| {{#users}} | |
| %p {{user}} | |
| {{/users}} |