Skip to content

Instantly share code, notes, and snippets.

View akirill0v's full-sized avatar

Alexander Kirillov akirill0v

View GitHub Profile
@akirill0v
akirill0v / list.md
Created December 24, 2013 18:38 — forked from niquola/list.md

Books

Concepts-Techniques-Models-Computer-Programming CMT это известная книжка CMT, за которой слава закрепилась не хуже чем у SICP

это из этой книжки классификация различных парадигм Если присмотришься, то увидишь, что Oz поддерживает большинство вариаций (с этой целью его и конструировали, чтобы можно было наглядно продемонстрировать различные подходы в одном языке)

@akirill0v
akirill0v / gist:9355039
Created March 4, 2014 20:34
serve current directory from command line
ruby -run -e httpd . -p 9090
def happy_number2?(num, buffer = [])
return true if num == 1
num = num.to_s.split(//).inject(0) do |col, item|
item = item.to_i
col +=(item * item)
end
return false if buffer.include?(num)
buffer << num
happy_number? num, buffer
end
class Kudos < AR
belongs_to :reciver #кто дает
belongs_to :target_user #кому дает
end
class KudosType < Kudos
# тут бует один инклуд, ссылка будет в переписке
def target_user=(user_email)
# найдем или построим пользователя

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

require 'rom'
require 'anima'
class User
include Anima.new(:id, :name, :tasks)
end
class Task
include Anima.new(:title)
end
diff --git a/Gemfile b/Gemfile
index 65641a8..794c14a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -25,6 +25,7 @@ gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/sp
gem 'polymer-rails', '~> 0.1.8'
+gem 'haml-rails'
irb(main):002:0> !!false
=> false
irb(main):003:0> !false.nil?
=> true
irb(main):004:0> !!true
=> true
irb(main):005:0> !true.nil?
=> true
@akirill0v
akirill0v / tmux_autoattach
Created January 15, 2015 10:47
Позволяет автоподключаться к терминалу при входе в папку
#!/bin/sh
#
# Attach or create tmux session named the same as current directory.
session_name="$(basename "$PWD" | tr . -)"
not_in_tmux() {
[ -z "$TMUX" ]
}