As configured in my dotfiles.
start new:
tmux
start new with session name:
# operators.io | |
OperatorTable addAssignOperator("->", "setLambda") | |
# code.io | |
Object setLambda := method( | |
slot_name := call message arguments at(0) name asMutable replaceSeq("\"","") | |
block_body := call message arguments at(1) | |
object := call target | |
object setSlot(slot_name, block( |
#include <stdio.h> | |
#include <stdlib.h> | |
struct db_element { | |
int id; | |
char* key; | |
char* value; | |
void* next; | |
struct db_element_collection* db; | |
}; |
without squeel `where(:id => 1).where_values` returns arel nodes. But with squeel i get hash. | |
irb(main):013:0> User.where(:id => 1).class | |
=> ActiveRecord::Relation | |
irb(main):012:0> User.where(:id => 1).where_values | |
=> [{:id=>1}] | |
but all is okay then i use scopes: |
# Как и ожидалось: | |
irb(main):151:0> User.where(:id => [1,2]).where(:id => [3,4]).to_sql | |
=> "SELECT \"users\".* FROM \"users\" WHERE \"users\".\"id\" IN (1, 2) AND \"users\".\"id\" IN (3, 4)" | |
# Теперь определяем скоуп: | |
irb(main):148:0> User.instance_eval { scope :with_ids, ->(ids) { where(:id => ids) } } | |
# И имеем полнешую хуйню: | |
irb(main):150:0> User.with_ids([1,2]).with_ids([3,4]).to_sql |
# encoding: utf-8 | |
namespace :migrator do | |
def db | |
connection_string = ENV['DB'] | |
default_connection_string = 'mysql://root:*****@localhost:3306/******' | |
@connection ||= Sequel.connect(connection_string || default_connection_string) | |
@connection |
describe "#method_a" do | |
# ... | |
end # describe "#method_a | |
describe "#method_b" do | |
# ... |
1) О культуре написания кода очень хорошо здесь - http://www.amazon.com/The-Readable-Code-Theory-Practice/dp/0596802293 | |
Есть море аналогов (которые я все перечитал), к примеру: | |
http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882 | |
http://www.ozon.ru/context/detail/id/4187085/ | |
Но "art of redable code" показался мне самым интересным изданием, как в плане содеражтельности, так и в плане оформления :) | |
2) Очень важно прочесть Фаулера и особенно его http://martinfowler.com/books/eaa.html | |
Если интересно, то про рефакторинг - http://martinfowler.com/books/refactoring.html, я честно скажу, там все идеи очень простые, поэтому бежать можно буквально по верхушкам и особо не вникать, потому что он там часто простые идеи описывает 5-ую страница текста. |
// Protection for ui-router states | |
// | |
// usage: | |
// | |
// app.run(function($stateConstraints) { | |
// | |
// $stateConstraints.protect({ | |
// state : 'myState', | |
// guard : function($currentUser) { // <- any service | |
// // guard should return FALSE if transition to state should be cancelled |
# encoding: utf-8 | |
namespace :migrator do | |
def db | |
connection_string = ENV['DB'] | |
default_connection_string = 'mysql://root:***@localhost:3306/***' | |
@connection ||= Sequel.connect(connection_string || default_connection_string) | |
@connection |
As configured in my dotfiles.
start new:
tmux
start new with session name: