# sessions_controller.rb
class Api::V1::SessionsController < ApplicationController
def create
user = User.authenticate(params[:email], params[:password])
if user
token = user.generate_token_for("auth_token")
/* | |
Parallel processing with ordered output in Go | |
(you can use this pattern by importing https://github.com/MarianoGappa/parseq) | |
This example implementation is useful when the following 3 conditions are true: | |
1) the rate of input is higher than the rate of output on the system (i.e. it queues up) | |
2) the processing of input can be parallelised, and overall throughput increases by doing so | |
3) the order of output of the system needs to respect order of input | |
- if 1 is false, KISS! |
if Rubber::Util.has_asset_pipeline? | |
# load 'deploy/assets' | |
_cset :asset_env, "RAILS_GROUPS=assets" | |
_cset :assets_prefix, "assets" | |
_cset :assets_role, [:web] | |
_cset :normalize_asset_timestamps, false | |
before 'deploy:finalize_update', 'deploy:assets:symlink' |
## open class | |
class Array | |
def second_last | |
self[-2] | |
end | |
end | |
class Array | |
def first |
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' | |
gem 'arel', github: 'rails/arel' | |
gem 'sqlite3' | |
GEMFILE | |
system 'bundle' | |
end |
var five = require("johnny-five"), | |
board, photoresistor; | |
var exec = require('child_process').exec; | |
board = new five.Board(); | |
board.on("ready", function() { | |
// Create a new `photoresistor` hardware instance. | |
photoresistor = new five.Sensor({ |
http://railscasts.com/episodes/347-rubber-and-amazon-ec2?view=asciicast | |
https://github.com/rubber/rubber/wiki/Commands | |
cap rubber:create #creates instances - but - sometimes, depending on the AMI, and the *mood* of the EC2 gods, you can't establish that initial SSH session .. | |
Eventually though, they should be setup. | |
Good trick, if, you can start the instance creation, but, it times out. You can kill that process, and restart the instance a few times until you can SSH to it standalone. |
FROM base | |
MAINTAINER Marc-Andre Cournoyer "[email protected]" | |
RUN apt-get -y update | |
RUN apt-get install -y -q curl | |
RUN curl -L https://get.rvm.io | bash -s stable --ruby | |
RUN /bin/bash -l -c rvm requirements |
I haven't set up an install guide for the latest ubuntu release, largely because the last set of instructions worked pretty closely with the latest and greatest Ubuntu, 12.04 Precise Pangolin, however when installing today, I found that there were enough differences in the way that I configure my setup to justify an update, so here it goes. Yes, I'm late to the party, but a quick google search didn't find anything that I felt was as complete for my requirements as my previous install guides, so here I go.
As always with my install guides, I have included here is just about everything you'll need (and then some) to get started with ruby on rails development with Ubuntu 12.04 as a platform. These are my settings and preferences, and this is certainly not the only way of doing things, so keep that in mind.
sudo apt-get update && sudo apt-get upgrade
class User < ActiveRecord::Base | |
alias :devise_valid_password? :valid_password? | |
def valid_password?(password) | |
begin | |
devise_valid_password?(password) | |
rescue BCrypt::Errors::InvalidHash | |
return false unless Digest::SHA1.hexdigest(password) == encrypted_password | |
logger.info "User #{email} is using the old password hashing method, updating attribute." | |
self.password = password |