Skip to content

Instantly share code, notes, and snippets.

View williamn's full-sized avatar

William williamn

  • Jakarta, Indonesia
View GitHub Profile
<?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 / 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
@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 / basic.md
Last active August 29, 2015 14:02
Centos HowTos

Basic setup

Root login

Change your password

Create new user

Root privileges

Configure SSH

Reload and done

@williamn
williamn / RebuildAroShell.php
Created June 23, 2014 12:51
CakePHP ARO rebuild shell task
<?php
class RebuildAroShell extends AppShell {
public $uses = array('User', 'Group');
public function main() {
$groups = $this->Group->find('all');
$users = $this->User->find('all');
$aro = new Aro();
@williamn
williamn / before_filter.php
Created November 27, 2014 16:08
CakePHP multitenant routing
<?php
// Validates tenant
switch (isset($this->request->params['tenant'])) {
case true:
// The tennant should exist
$this->loadModel('Tenant');
if ($this->Tenant->isExist($this->request->params['tenant']) == 0) {
throw new NotFoundException();
}
@williamn
williamn / default-linux.conf
Last active October 12, 2018 02:37
CakePHP 2.5 virtual host configuration example on Apache 2.4 Windows 8.1
<VirtualHost *:80>
ServerName 10.10.0.3
DocumentRoot /home/vagrant/htdocs/apad2/app/webroot
<Directory /home/vagrant/htdocs/apad2/app/webroot>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error-apad.log
@williamn
williamn / upstreams.conf
Last active July 7, 2022 03:05
CodeIgniter on nginx using PHP FPM
upstream php5438 {
server 127.0.0.1:5438;
}
@williamn
williamn / solutions.js
Last active August 29, 2015 14:25
Elevator Saga
{
init: function(elevators, floors) {
var elevator = elevators[0]; // Let's use the first elevator
_.each(floors, function(floor) {
floor.on("up_button_pressed down_button_pressed", function() {
elevator.goToFloor(floor.floorNum());
});
});
@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 "