# 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")
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
defmodule Runlength do | |
def encode(<< first :: binary-size(1) , rest :: binary>>) do | |
encode({first, 1}, rest, "") | |
end | |
def encode({letter, count}, << letter :: binary-size(1) , rest :: binary>>, result) do | |
encode({letter, count + 1}, rest, result) | |
end | |
def encode({letter, count}, << diff :: binary-size(1) , rest :: binary>>, result) do | |
result = result <> to_string(count) <> letter |
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
defmodule Parser do | |
require Record | |
Record.defrecord :xmlElement, Record.extract(:xmlElement, from_lib: "xmerl/include/xmerl.hrl") | |
Record.defrecord :xmlText, Record.extract(:xmlText, from_lib: "xmerl/include/xmerl.hrl") | |
Record.defrecord :xmlAttribute, Record.extract(:xmlAttribute, from_lib: "xmerl/include/xmerl.hrl") | |
def run(xml) do | |
run(xml, '//response') | |
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
#= Bouncers.Bouncer.check_entry(conn, %MyApp.User{}) | |
#=> true | |
defmodule Bouncers.Bouncer do | |
alias Bouncers.Areas | |
def check_entry(conn, resource) do | |
verify(resource, conn.path_info) | |
end |
In the controller action
change_img_params(params[:background_image])
def change_img_params(img)
begin
Base64.decode64(params[:user][img])
if params[:user][img]
params[:user][img] = file_decode(params[:user][img].split(',')[1],
params[:user][:screen_name] )
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
/* Requirements install git and curl */ | |
/* installing rbenv */ | |
curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash | |
/* add this instead of generated stuff "PREPEND" the echo wordings to ~/.profile */ | |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile | |
echo 'eval "$(rbenv init -)"' >> ~/.profile |
NewerOlder