Skip to content

Instantly share code, notes, and snippets.

View williamn's full-sized avatar

William williamn

  • Jakarta, Indonesia
View GitHub Profile
@williamn
williamn / code-changes.sh
Created April 1, 2021 04:46
Use the Git History to Identify Pain Points in Any Project
git log --format=format: --name-only | egrep -v '^$' | sort | uniq -c | sort -rg | head -10
@williamn
williamn / README.md
Last active November 23, 2018 04:06
dante-stories local installation
  1. install ruby 2.4.0
  2. install bundler
  3. git clone [email protected]:michelson/dante-stories.git
  4. cd dante-stories
  5. bundle install
@williamn
williamn / spec.md
Created December 8, 2017 05:30
Notejam API

Notejam API

Application overview

Inspired by komarserjio/notejam

Notejam is a web application which allows user to sign up/in/out and create/view/edit/delete notes. Notes are grouped in pads. There will 2 part of the application. First is the backend which is provide HTTP API for the second part: the frontend which handles the UI.

Task overview

@williamn
williamn / application_controller.rb
Created February 10, 2017 05:35
HTTP Basic authentication
class ApplicationController < ActionController::Base
if ENV["DISALLOW_ALL_WEB_CRAWLERS"].present?
http_basic_authenticate_with(
name: ENV.fetch("BASIC_AUTH_USERNAME"),
password: ENV.fetch("BASIC_AUTH_PASSWORD"),
)
end
end
@williamn
williamn / seed.rb
Created January 10, 2017 12:15
Capistrano task to run `rails db:seed`
namespace :deploy do
desc "reload the database with seed data"
task :seed do
on roles(:all) do
within current_path do
execute :bundle, :exec, 'rails', 'db:seed', 'RAILS_ENV=production'
end
end
end
end
@williamn
williamn / webapp.conf
Created May 18, 2016 09:40
NGINX site with PHP FPM
server {
root /path/to/webapp/public;
index index.php index.html index.htm;
server_name webapp.local;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
@williamn
williamn / www.conf
Created May 18, 2016 09:27
PHP FPM pool conf for NGINX and PHPBrew
; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[www]
; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
@williamn
williamn / Vagrantfile
Last active May 16, 2016 09:35
Minimalistic Ubuntu 14.04 vagrant provision script
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.box_check_update = false
config.vm.network "forwarded_port", guest: 22, host: 2222, id: 'ssh'
config.vm.network "private_network", ip: "10.10.0.2"
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
end
config.vm.provision "shell", path: "script.sh"
end
@williamn
williamn / myapp.conf
Last active May 13, 2016 04:37
Rails 4, nginx and Passenger
server {
listen 80;
server_name ums.harukaeduapps.com;
# Tell Nginx and Passenger where your app's 'public' directory is
root /home/deploy/htdocs/ums/current/public;
# Turn on Passenger
passenger_enabled on;
@williamn
williamn / bira.zsh-theme
Created December 16, 2015 05:28
oh-my-zsh bira theme with phpbrew current PHP version support
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
local ruby_version='%{$fg[red]%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$reset_color%}'
local git_branch='$(git_prompt_info)%{$reset_color%}'
local php_version='%{$fg[blue]%}‹$(phpbrew_current_php_version | sed -e "s/[-a-z][^0-9]*//g")›%{$reset_color%}'
PROMPT="╭─${user_host} ${current_dir} ${ruby_version} ${php_version} ${git_branch}
╰─%B$%b "