Skip to content

Instantly share code, notes, and snippets.

View arzumy's full-sized avatar

Arzumy MD arzumy

View GitHub Profile
@arzumy
arzumy / nginx
Created November 21, 2013 08:35
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
<?xml version="1.0"?>
<tree id="0">
<item child="1" id="0_0" text="D.R.01/2012 - Rang Undang-Undang Pengantaraan 2012 (Lulus) ">
<userdata name="myurl">#</userdata>
<item text="D.R.01/2012" id="0_0_1" child="0" im0="book_titel.gif" im1="book_titel.gif" im2="book_titel.gif">
<userdata name="myurl">'http://www.parlimen.gov.my/files/billindex/pdf/2012/DR012012.pdf'</userdata>
</item>
<item text="Dibentang Pada :02/04/2012" id="0_0_2" child="0"/>
<item text="Dibentang Oleh :Y.B. Datuk Liew Vui Keong, Timbalan Menteri di Jabatan Perdana Menteri" id="0_0_3" child="0"/>
<item text="Disokong Oleh :Y.B. Datuk Abdul Rahim Bakri, Timbalan Menteri Pengangkutan" id="0_0_4" child="0"/>
@arzumy
arzumy / control
Created May 16, 2011 03:52
Simple script to start/stop services using launchctl in OSX, with easy to remember service's name.
#!/bin/bash
# usage: control (start|stop) service_shortname
# simple script by @arzumy
# I use this in my .bashrc
#
# alias start='~/scripts/control start '
# alias stop='~/scripts/control stop '
#
# Then I'll just type 'start mysql' to start mysql
@arzumy
arzumy / gist:648281
Created October 27, 2010 02:24
Textmate Command to Change HTML Attributes to Ruby Options
#!/usr/bin/env ruby
def to_options(str)
str.gsub(/((\s|^)(\w+))(=)/i) {|v| ", :#{$3} #{$4}> "}
end
print to_options(STDIN.read)
@arzumy
arzumy / validatable.rb
Created September 8, 2010 03:43
gotcha for devise gem version 1.0.x, email is case-sensitive, this should fix it
# in resource model
# def self.find_for_authentication(conditions={})
# case ActiveRecord::Base.connection.adapter_name
# when 'PostgreSQL'
# find(:first, :conditions=>['UPPER(email) = ?', conditions[:email].upcase!])
# else
# find(:first, :conditions => conditions)
# end
# end
# Cheapskate solution so that delayed_job only kicks off in production
# Useful when you can't pass the development delayed_job in heroku cost to client
Delayed::DelayProxy.class_eval do
def method_missing(method, *args)
performable = Delayed::PerformableMethod.new(@target, method.to_sym, args)
if RAILS_ENV == "production"
Delayed::Job.create({
:payload_object => performable,
:priority => ::Delayed::Worker.default_priority
}.merge(@options))
#!/usr/bin/env ruby
# Textmate bundle command to change HTML attr to symbol
# I normally use this when working with html files from designer
# so line like this id="logo" class="left" converted to , :id => "logo", :class => "left"
def to_options(str)
str.gsub(/((\s|^)(\w+))(=)/i) {|v| ", :#{$3} #{$4}> "}
end
print to_options(STDIN.read)
export PS1="\[\033[00m\]\u@\h\[\033[00m\]:\[\033[00m\]\w\[\e[1;35m\] \`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`\[\033[00m\]$\[\033[00m\] "
#sample test for friendly_id for app with same name
require File.expand_path(File.dirname(__FILE__) + './../test_helper')
class AppsControllerTest < ActionController::TestCase
fast_context "GET to show" do
setup do
@app_one = Factory(:iphone_app, :name => "Tweetie")
@app_two = Factory(:iphone_app, :name => "Tweetie")
end
# Credit goes to Geoff Hankerson
# Original tutorial http://geoffhankerson.com/node/108
# This is a short version just for personal reference
# 1. Create key
sudo rndc-confgen -a
# 2. Add zone in named.conf
sudo vim /etc/named.conf