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
@edthix
edthix / gist:6147624
Created August 3, 2013 19:11
Some perspective on Clojure's quote, ' (single quote) and syntax quote ` (back quote)
(ns my-app.core)
;; Clojure 1.5
(quote hello 1 2 3 we are martians) ;; returns hello
'(hello 1 2 3 we are martians) ;; returns (hello 1 2 3 we are martians)
`(hello 1 2 3 we are martians) ;; (my-app.core/hello 1 2 3 my-app.core/we my-app.core/are my-app.core/martians)
@edthix
edthix / gist:3687488
Created September 9, 2012 21:41
Pick a state
private int get_state_index(string state) {
if(state == "AL")
return 0;
if(state == "AK")
return 1;
if(state == "AZ")
return 2;
if(state == "AR")
return 3;
if(state == "CA")
@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
@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";
}
# 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|
<?php
// ckfinder/config.php
session_name("CAKEPHP");
session_start();
function CheckAuthentication()
{
if(isset($_SESSION['Auth']['User'])){
return true;
}
! 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
/*
Project has many Tasks
Tasks belongs to Project
Tables:
projects [id, name, date]
tasks [id, description, project_id]
*/
class Project extends AppModel {
# 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
)
@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