Skip to content

Instantly share code, notes, and snippets.

@phamonyut
phamonyut / upstart_script.conf
Created December 19, 2015 03:40
ตัวอย่าง upstart script
#/etc/init/<your_app>.conf
description "Your App"
author "Phamon <[email protected]>"
start on virtual-filesystems
stop on runlevel [06]
env PATH=/opt/www/<your_app>/current/bin:/usr/local/rbenv/shims:/usr/local/rbenv/bin:/usr/local/bin:/usr/bin:/bin
env RAILS_ENV=production
env RACK_ENV=production
@phamonyut
phamonyut / rack-attack.rb
Created October 29, 2015 08:43
Example Config Rack Attack
class Rack::Attack
### Configure Cache ###
# If you don't want to use Rails.cache (Rack::Attack's default), then
# configure it here.
#
# Note: The store is only used for throttling (not blacklisting and
# whitelisting). It must implement .increment and .write like
# ActiveSupport::Cache::Store
@phamonyut
phamonyut / unicorn.rb
Created October 19, 2015 10:50
example unicorn script
# config/unicorn.rb
# Use at least one worker per core if you're on a dedicated server,
# more will usually help for _short_ waits on databases/caches.
worker_processes 4
# Since Unicorn is never exposed to outside clients, it does not need to
# run on the standard HTTP port (80), there is no reason to start Unicorn
# as root unless it's from system init scripts.
# If running the master process as root and the workers as an unprivileged
@phamonyut
phamonyut / deploy.rb
Created October 19, 2015 10:48
example mina deploy.rb
# config/deploy.rb
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv'
set :rbenv_path, '/usr/local/rbenv'
set :domain, '<your_ip>'
set :deploy_to, '<your_deploy_path>'
@phamonyut
phamonyut / default
Last active October 20, 2015 05:17
example ngnix
# /etc/nginx/sites-available/default
upstream symbolet {
server unix:/tmp/unicorn.<your_unicorn_sock>.sock fail_timeout=0;
}
server {
server_name symbolet.com www.symbolet.com;
listen 80;
doctype html
html
head
title
| Shopper2
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'application', 'data-turbolinks-track' => true
= csrf_meta_tags
body
@phamonyut
phamonyut / application.css.sass
Last active November 12, 2015 03:50
Workshop application.css.sass
$navbar-default-bg: #fff
$navbar-default-border: #fff
$border-radius-small: 1px
$border-radius-base: 2px
$border-radius-large: 3px
$nprogress-color: #5434B7
@import 'bootstrap-compass'
@import 'bootstrap-sprockets'
@import 'bootstrap'
@phamonyut
phamonyut / application.js
Last active November 12, 2015 03:50
Workshop application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require nprogress
//= require nprogress-turbolinks
//= require_tree .
@phamonyut
phamonyut / Gemfile
Last active November 12, 2015 15:26
Workshop Gemfile
source 'https://rubygems.org'
# source 'https://rails-assets.org'
# ruby '2.2.3'
gem 'rails', '4.2.4'
# gem 'mysql2', '~> 0.3.13'
gem 'pg'
# js & css
gem 'compass-rails', '~> 2.0.1'
# train_service.rb
# Graph data structure is contain from, to and distance
class Graph
attr_accessor :from, :to, :distance
def initialize(from, to, distance)
@from = from
@to = to
@distance = distance.to_i
end