This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'simpletest/autorun.php'; | |
function add($a, $b){ | |
return $a + $b; | |
} | |
function sayHi($name){ | |
return "Hello $name"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ckfinder/config.php | |
session_name("CAKEPHP"); | |
session_start(); | |
function CheckAuthentication() | |
{ | |
if(isset($_SESSION['Auth']['User'])){ | |
return true; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Project has many Tasks | |
Tasks belongs to Project | |
Tables: | |
projects [id, name, date] | |
tasks [id, description, project_id] | |
*/ | |
class Project extends AppModel { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |