Skip to content

Instantly share code, notes, and snippets.

View williamn's full-sized avatar

William williamn

  • Jakarta, Indonesia
View GitHub Profile
@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 / 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 / Rails CMS alternatives
Created January 29, 2010 07:28
Rails CMS alternatives
Rails CMS alternatives
======================
Note: project activity was checked on 11/26/09.
Active projects:
----------------
Railsyard
site: http://www.railsyardcms.org/
Last update: 02/07/12
repo: https://github.com/cantierecreativo/railsyardcms
@williamn
williamn / svn_ignore.sh
Created May 24, 2010 10:11
Rails svn ignores
#!/bin/sh
svn remove log/*
svn commit -m 'Removing log files'
svn propset svn:ignore "*.log" log/
svn update log/
svn commit -m 'Ignoring all files in /log/ ending in .log'
svn move config/database.yml config/database.example
svn commit -m 'Moving database.yml to database.example to provide a template for anyone who checks out the code'
svn propset svn:ignore "database.yml" config/
svn update config/
@williamn
williamn / rcov.rake
Created June 8, 2010 10:25
Shoulda and rcov the right way
#
# Original blog here http://honoluluhacker.com/2009/11/19/install-shoulda-and-rcov-the-right-way/
# Update your test/test_helper.rb, add
# require 'shoulda/rails'
#
require File.expand_path(File.dirname(__FILE__) + "/../../config/boot")
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
@williamn
williamn / Rakefile
Created September 6, 2010 07:32
Rakefile (shoulda + rcov)
## add this to test/test_helper.rb
require 'shoulda/rails'
## add this to Rakefile
require 'shoulda/tasks'
namespace :test do
desc 'Measures test coverage'
task :coverage do
rm_f "coverage"
rm_f "coverage.data"
@williamn
williamn / link_dump.rb
Created October 5, 2010 05:33
Dump your delicious.com posts
@williamn
williamn / .gitignore
Created October 7, 2010 04:50
Rails .gitignore
*.log
database.yml
tmp/