Skip to content

Instantly share code, notes, and snippets.

class Node
attr_accessor :children
attr_accessor :title
def general_deep_copy
Marshal.load(Marshal.dump(self))
end
def specific_deep_copy
Node.new(@title,children.map(&:specific_deep_copy))
on the client side's HTML HEAD tag you include:
<script src="/dictionary.js" type="text/javascript" charset="utf-8"></script>
<script>
var current_language = "italian";
</script>
you manage current_language variable according to user's langauge
and where translated text is needed you use the amazing <dictkey> tag:
require 'active_support/all'
class AktivRekord
def self.has_many what
define_method(what.to_s.pluralize) do
what.to_s.classify.constantize.find_by_id(self.send("#{what.to_s.singularize}_id"))
end
end
end
class Person < AktivRekord
@dorkalev
dorkalev / iloveyou.rb
Created December 3, 2012 07:47
i ♥ you
# encoding: utf-8
def i(what)
"I #{what}"
end
def ♥(who)
"LOVE #{who}"
end
def you
@dorkalev
dorkalev / אני אוהב אותך.rb
Created December 3, 2012 07:57
אני אוהב אותך
# encoding: utf-8
def אני(what)
"I #{what}"
end
def ♥(who)
"LOVE #{who}"
end
def אותך
@dorkalev
dorkalev / a start
Last active December 23, 2015 08:29
sentence = "there is a wild rose"
letters = sentence.gsub(' ','').split(//)
package main
import (
"fmt"
)
func fibonaci(l uint) {
var fibo func(arr []uint, l uint)
fibo = func(arr []uint, l uint) {
if l == 0 {
package main
import "fmt"
func fibonaci(l uint) uint {
var fibo func(arr []uint, l uint) uint
var ret uint
fibo = func(arr []uint, l uint) uint {
if l > 2 {
ret = fibo([]uint{arr[1], (arr[0] + arr[1])}, l-1)
@dorkalev
dorkalev / gist:9923752
Last active August 29, 2015 13:57
trying modules instead of classes for the actions
module Action
end
module Carry
include Action
end
module ShowOff
include Action
end
hello