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
#Session Setup | |
Warden::Manager.serialize_into_session do |user| | |
puts '[INFO] serialize into session' | |
user.id | |
end | |
Warden::Manager.serialize_from_session do |id| | |
puts '[INFO] serialize from session' | |
User.find(id) | |
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
module M | |
def method | |
puts "hello" | |
end | |
end | |
def execute(current_module, &block) | |
Object.new.tap do |o| | |
o.extend(current_module) | |
o.instance_eval &block |
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
# encoding: UTF-8 | |
%w[rubygems digest/md5 sinatra haml sass warden rack/flash mongo mongo_mapper uri].each{ |gem| require gem } | |
require 'sinatra/reloader' | |
configure do | |
MongoMapper.connection = Mongo::Connection.new('staff.mongohq.com', 10083) | |
MongoMapper.database = 'hkbase' | |
MongoMapper.database.authenticate('hksklep', '****') | |
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
# encoding: UTF-8 | |
require 'sinatra' | |
require 'haml' | |
require 'sass' | |
require 'warden' | |
require 'rack/flash' | |
require 'sinatra/activerecord' | |
require 'active_record' | |
require 'date' | |
require_relative 'setup_env' |
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
def book | |
if params[:date].present? && params[:room].present? && current_user | |
room = Room.find_by_id(params[:room]) | |
date = DateTime.strptime(params[:date],"%d-%m-%Y-%H-%M") | |
unless date > Date.today+8.days || date.past? | |
unless Book.user(current_user.id).room(room.id).period(room.period).first | |
unless Book.room(room.id).free(date,date+room.duration.minutes).first | |
stop = (date+room.duration.minutes).strftime("%H:%M") == "00:00" ? "23:59" : (date+room.duration.minutes).strftime("%H:%M") | |
unless Book.room(room.id).cyclic.dayoftheweek(date.wday).onlytimefree(date.strftime("%H:%M"),stop).first |
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
require 'faraday' | |
require 'forwardable' | |
module Soup | |
class Agent | |
extend Forwardable | |
def initialize(domain = 'https://www.soup.io/') | |
@agent ||= faraday(domain) | |
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
Ride coordination board: Singe Table Inheritance | |
Database: ads | |
:title | |
:price | |
:content | |
:username | |
:from | |
:to |
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
" Configure vim to suck less | |
let softab = "on" | |
let tabsize = 2 | |
let arrowkeys = "on" | |
let gui_font = "Monaco\ 11" | |
let mapleader = "," | |
let $LANG = 'en' | |
set langmenu=none | |
source ~/.vimrc-defaults | |
source ~/.vimrc-helpers |
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
= simple_form_for @ad, :html=>{:multipart => true } do |f| | |
=f.input :title | |
=f.input :price | |
=f.input :category_id | |
= render :partial => "categories/bar" | |
= f.input :name | |
= f.input :email | |
= f.input :phone_number | |
= f.input :ad_content |
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
require 'faraday' | |
require 'forwardable' | |
module Soup | |
class Agent | |
extend Forwardable | |
def initialize(domain = 'https://www.soup.io/') | |
@agent ||= faraday(domain) | |
end |