Skip to content

Instantly share code, notes, and snippets.

@phamonyut
phamonyut / Upstart.conf
Last active December 19, 2015 03:37 — forked from bradleyayers/gist:1660182
/etc/dbus-1/system.d/Upstart.conf
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- Only the root user can own the Upstart name -->
<policy user="root">
<allow own="com.ubuntu.Upstart" />
</policy>
# config/application.rb
module MyRailsApp
class Application < Rails::Application
# ...
unless Rails.env.test?
log_level = String(ENV['LOG_LEVEL'] || "info").upcase
config.logger = Logger.new(STDOUT)
# 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
@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'
@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 / 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'
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 / 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;
@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 / 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