Skip to content

Instantly share code, notes, and snippets.

@phongnh
phongnh / macos-apps.sh
Created September 23, 2016 15:45 — forked from cstipkovic/install_my_env.sh
My Mac OS X setup script
#!/bin/sh
# homebrew-cask
brew tap phinze/homebrew-cask
brew install brew-cask
# browser
brew cask install firefox
# development
@phongnh
phongnh / projections.json
Created August 29, 2016 04:41 — forked from jsteiner/projections.json
Example Rails.vim projections for an Ember.js project.
{
"app/assets/javascripts/models/*.coffee": {
"command": "jmodel",
"alternate": "spec/javascripts/models/%s_spec.coffee",
"template": "App.%S = DS.Model.extend"
},
"app/assets/javascripts/controllers/*_controller.coffee": {
"command": "jcontroller",
"alternate": "spec/javascripts/controllers/%s_spec.coffee",
@phongnh
phongnh / .vimrc
Created August 29, 2016 03:15 — forked from jsteiner/.vimrc
Example .vimrc projections, including projections for Active Model Serializers, Draper, and FactoryGirl
let g:rails_projections = {
\ "config/projections.json": {
\ "command": "projections"
\ },
\ "spec/features/*_spec.rb": {
\ "command": "feature",
\ "template": "require 'spec_helper'\n\nfeature '%h' do\n\nend",
\ }}
let g:rails_gem_projections = {
@phongnh
phongnh / postgres_queries_and_commands.sql
Created July 11, 2016 23:21 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@phongnh
phongnh / gist:e00b14cd30c54c015c10ce14568a87c3
Created June 14, 2016 16:58 — forked from stuzart/gist:3169625
Simple init.d script for delayed_job
#!/bin/sh
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.
set -e
APP_PATH="/srv/rails/seek"
start_job() {
echo "Starting delayed job"
@phongnh
phongnh / delayed_job.conf
Created June 14, 2016 16:58 — forked from foliosus/delayed_job.conf
Upstart script to run delayed_job, with a weird rvm hack
# /etc/init/delayed_job.conf
# Note that you have to modify script/delayed_job's shebang line to have the correct ruby path
description "Delayed_job for a Rails app"
author "Brent Miller <[email protected]>"
start on started mysql
stop on stopping mysql
@phongnh
phongnh / delayed_job.conf
Created June 14, 2016 16:58 — forked from sasha-id/delayed_job.conf
Upstart delayed_job script
# Copy:
# /etc/init/delayed_job.conf
# Execute:
# ln -s /lib/init/upstart-job /etc/init.d/delayed_job
# Change user name
description "Start up the delayed_job service"
start on runlevel [2345]
stop on runlevel [06]
@phongnh
phongnh / puma.monitrc
Created June 14, 2016 08:25 — forked from sudara/puma.monitrc
Example config needed to use monit with puma, monitoring workers for mem.
# this monit config goes in /etc/monit/conf.d
check process puma_master
with pidfile /data/myapp/current/tmp/puma.pid
start program = "/etc/monit/scripts/puma start"
stop program = "/etc/monit/scripts/puma stop"
group myapp
check process puma_worker_0
with pidfile /data/myapp/current/tmp/puma_worker_0.pid
@phongnh
phongnh / pumaapp.conf
Created June 11, 2016 11:55 — forked from ordoghl/pumaapp.conf
Ubuntu upstart job for Puma w/ rbenv and application deployed to appuser home directory.
# /etc/init/puma.conf - Puma config
description "Puma App Service"
start on (local-filesystems and net-device-up IFACE=lo and runlevel [2345])
stop on (runlevel [!2345])
setuid appuser
setgid appuser
respawn
respawn limit 3 30
env HOME=/home/appuser
env PATH=/home/appuser/.rbenv/shims:/home/appuser/.rbenv/bin:/usr/local/bin:/usr/bin:/bin
@phongnh
phongnh / server.md
Created June 11, 2016 08:29 — forked from jtadeulopes/server.md
Server setup with ubuntu, nginx and puma for rails app.

Update and upgrade the system

sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoremove
sudo reboot

Configure timezone