Skip to content

Instantly share code, notes, and snippets.

View williamn's full-sized avatar

William williamn

  • Jakarta, Indonesia
View GitHub Profile
@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 / 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 / example.feature
Created November 12, 2010 08:20
Feature/story example
Story: Account Holder withdraws cash
As an Account Holder
I want to withdraw cash from an ATM
So that I can get money when the bank is closed
Scenario 1: Account has sufficient funds
Given the account balance is \$100
And the card is valid
And the machine contains enough money
@williamn
williamn / output.txt
Created October 9, 2013 03:01
Output of `brew doctor`
Warning: Setting DYLD_* vars can break dynamic linking.
Set variables:
DYLD_FALLBACK_LIBRARY_PATH
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
@williamn
williamn / staging.rb
Last active December 23, 2015 05:59
Laravel deployment recipe
set :stage, :staging
server "example.com", roles: [:app, :web, :db]
set :ssh_options, {
user: "william",
forward_agent: true
}
set :deploy_to, "/home/william/htdocs/#{fetch(:application)}"
set :deploy_via, :remote_cache
<?php
// The Slim Framework helps you map resource URIs to callback functions
// for specific HTTP request methods (e.g. GET, POST, PUT, DELETE, OPTIONS or HEAD).
// A Slim application will invoke the first route that matches
// the current HTTP request’s URI and method.
// If the Slim application does not find routes with URIs that match
// the HTTP request URI and method, it will automatically
// return a 404 Not Found response.
@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 "