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
| source 'https://rubygems.org' | |
| gem 'sinatra' | |
| gem 'sinatra-contrib', require: 'sinatra/streaming' | |
| group :development do | |
| gem 'thin' | |
| gem 'pry-rails' | |
| 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
| source 'https://rubygems.org' | |
| gem 'thin' | |
| gem 'eventmachine', '1.0.0.rc.4' | |
| gem 'sinatra' | |
| gem 'sinatra-contrib', :require => 'sinatra/contrib' | |
| gem 'sinatra-flash', :require => 'sinatra/flash' | |
| gem 'rack-protection' |
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
| source 'https://rubygems.org' | |
| gem 'sinatra' | |
| gem 'rack-fiber_pool', :require => 'rack/fiber_pool' | |
| group :development do | |
| gem 'thin' | |
| gem 'pry-rails' | |
| 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
| migration 1, :create_accounts do | |
| up do | |
| create_table :accounts do | |
| column :id, Integer, :serial => true | |
| column :name, String | |
| column :surname, String | |
| column :email, String | |
| column :crypted_password, String, :length => 64 | |
| column :role, String | |
| 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
| # include this in app file | |
| # this is for Role Based Access Controle, can be much shorter | |
| class Ability | |
| include CanCan::Ability | |
| def initialize account | |
| @abilities ||= {} | |
| allow [:any, :manager, :manufacturer, :admin] do |
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
| user app; | |
| worker_processes 2; | |
| error_log /home/app/logs/nginx.error.log info; | |
| events { | |
| worker_connections 1024; | |
| } | |
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
| def class_for_name name | |
| namespaces = name.split '::' | |
| base = Kernel | |
| namespaces.each do |namespace| base = base.const_get(namespace) end | |
| base | |
| 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
| 6 | |
| whale: big black water animal | |
| penguin: black white ice beak | |
| piano: keyboard black white wire | |
| jackboot: leather heel black | |
| train: rail wheel black | |
| rose: red green thorn | |
| 4 | |
| whale penguin piano jackboot train | |
| penguin piano |
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
| local function handler(sock_in) | |
| local line = sock_in:receive('*l') | |
| -- where to? | |
| local url = string.match(line, 'http://([%a%d\.-]+):*%d*/') | |
| local port = string.match(line, 'http://[%a%d\.-]+:(%d+)/') | |
| local sock_out = socket.connect(url, port or 80) | |
| repeat | |
| if line then sock_out:send(line..'\r\n') 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
| require 'util' | |
| require 'luarocks.require' -- http://www.luarocks.org/ | |
| local http = require 'socket.http' -- http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/ | |
| local bot_container = 'http://dozorni.heroku.com/whatnow' | |
| local body, status = http.request(bot_container, '') | |
| local json = require('json') -- http://luaforge.net/projects/luajson/ | |
| local dec = json.decode(body) |