Skip to content

Instantly share code, notes, and snippets.

View williamn's full-sized avatar

William williamn

  • Jakarta, Indonesia
View GitHub Profile
@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 / Number.php
Created July 20, 2011 04:56
Terbilang - Konversi bilangan menjadi kalimat dalam Bahasa Indonesia
<?php
class Number
{
function spell($number)
{
$words = array(
"", "Satu", "Dua", "Tiga", "Empat", "Lima", "Enam", "Tujuh",
"Delapan", "Sembilan", "Sepuluh", "Sebelas"
);
@williamn
williamn / gist:2894205
Created June 8, 2012 07:24 — forked from JonathanTron/gist:361875
Steps to mirror a Git repository
# go to your repository
cd my_project
# check your existing remote
git remote -v
# origin git@mydomain.tld:my_project.git (fetch)
# origin git@mydomain.tld:my_project.git (push)
# Add a new remote, a github.com private repository for example
# the --mirror flag is what's different from a simple new remote
@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 / 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 / enviroment.rb
Created June 16, 2011 05:02
Fixing "undefined local variable or method `version_requirements' for #<Rails::GemDependency:0x...> (NameError)"
# Phillip Koebbe from Ruby on Rails suggested inserting following code between the "bootstrap" and
# "initialize" sections of enviroment.rb. This hack fixes the problem.
if Gem::VERSION >= "1.3.6"
module Rails
class GemDependency
def requirement
r = super
(r == Gem::Requirement.default) ? nil : r
end
@williamn
williamn / to_kmlcolor.rb
Created June 21, 2011 08:30
Converting HEX color (RRGGBB) to KML color (AABBGGRR)
# Taken from http://rcos.cs.rpi.edu/projects/flagship-safety/commit/converting-hex-color-rrggbb-to-kml-color-aabbggrr/
#
# Generates a KML color given a hex color string.
# Converts the format from #RRGGBB to AABBGGRR.
# The alpha channel defaults to ff.
def to_kmlcolor(color="#000000", alpha = "ff")
alpha + color[5,3] + color[3,2] + color[1,2]
end
@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 git@github.com:michelson/dante-stories.git
  4. cd dante-stories
  5. bundle install
@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 / 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