Skip to content

Instantly share code, notes, and snippets.

View edthix's full-sized avatar
💭
Online

Edham Arief Dawillah / edthix edthix

💭
Online
View GitHub Profile
# objective-j & ruby comparison - Methods
@implementation Person:CPObject
{
CPString name;
-(void) setName: (CPString)aName
{
name=aName;
}
# objective-j
@implementation Person : CPObject
{
CPString name;
}
@end
# ruby
class Person < CPObject
attr_reader :namer
@edthix
edthix / ruby-bindings.rb
Created October 23, 2009 12:15
Ruby bindings with robots!
def robot_internals
arm = "mechanical hydraulics"
return binding
end
binded = robot_internals
arm = "five fingers"
eval "puts arm" # five fingers
eval "puts arm", binded # mechanical hydraulics
# Robots with class_eval
class Robot
end
def add_machinegun_to_robots
Robot.class_eval %Q(
def machine_guns
p "I'm loaded with machine gun"
end
)
/*
Project has many Tasks
Tasks belongs to Project
Tables:
projects [id, name, date]
tasks [id, description, project_id]
*/
class Project extends AppModel {
! put in ~/.xmodmap
! Swap Caps_Lock and Control_L
!
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
<?php
// ckfinder/config.php
session_name("CAKEPHP");
session_start();
function CheckAuthentication()
{
if(isset($_SESSION['Auth']['User'])){
return true;
}
# Warning - 2AM Work!
# I'm too lazy for better approach (and too sleepy)
@newgems = []
strips = [".", ",", "(", ")"]
(0..9).to_a.each{ |x| strips << x.to_s }
File.open "gems", "r" do |f|
f.each do |line|
strips.each{|x|
@edthix
edthix / functions_test.php
Created November 15, 2010 19:14
Testing via simpletest
<?php
require_once 'simpletest/autorun.php';
function add($a, $b){
return $a + $b;
}
function sayHi($name){
return "Hello $name";
}
@edthix
edthix / gist:2376586
Created April 13, 2012 12:22
remove devise sign in layout
# apply to application_controller.rb
# add to before_filter
before_filter ....., :remove_sign_in_layout
def remove_sign_in_layout
if params[:controller] == 'devise/sessions'
render :layout => nil
end