Skip to content

Instantly share code, notes, and snippets.

View kamal's full-sized avatar

Kamal Fariz Mahyuddin kamal

View GitHub Profile
module ActiveResource
class Base
def to_xml_with_methods(options)
methods = Array(options.delete(:methods))
methods.each do |m|
attributes[m] = send(m)
end
to_xml_without_methods(options)
end
alias_method_chain :to_xml, :methods
kamal@ubuntu:/etc/apt$ sudo apt-get install rubygems ohai chef chef-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
rubygems is already the newest version.
ohai is already the newest version.
chef is already the newest version.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
#
# Cookbook Name:: hosts
# Recipe:: default
#
# Copyright 2009, Bitfluent
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# Auto-generated by chef for <%= @node[:fqdn] %>
#
127.0.0.1 localhost <%= @localhost["fqdn"] %> <%= (@localhost["dns_aliases"] || []).sort.join(" ") %>
<% @hosts.keys.sort.each do |ip| %>
<%= ip %> <%= @hosts[ip]["fqdn"] %> <%= (@hosts[ip]["dns_aliases"] || []).sort.join(" ") %>
<% end %>
#!/usr/bin/env ruby
#
# Create a custom chef index for deb packages on the system
require "rubygems"
require "chef"
require "chef/rest"
require "open4"
require "ohai"
#!/bin/sh
echo "Copying opscode.list to /etc/apt/sources.list.d"
sudo cp install/opscode.list /etc/apt/sources.list.d/opscode.list
echo "Adding opscode GPG key"
curl http://apt.opscode.com/[email protected] | sudo apt-key add -
echo "Installing chef client"
sudo apt-get update
require "rack/openid"
require "warden"
use Rack::OpenID
use Warden::Manager do |manager|
Warden::Strategies.add(:openid) do
def authenticate!
if resp = env["rack.openid.response"]
case resp.status
when :success
class Article < ActiveRecord::Base
belongs_to :author
searchable do
text :title, :boost => 2.0
text :body
text :author_name do
author.name
end
time :updated_at # for sorting by recent
# config/environment.rb
config.gem "bitfluent-activemerchant", :lib => "activemerchant"
@kamal
kamal / routes.rb
Created August 9, 2010 15:03 — forked from akomba/routes.rb
resources :channels do
shallow do
resources :posts do
member do
put :disable
put :toggle_stickiness
put :add_channel
end
resources :replies, :only => [:index, :new, :create, :show]
end