February 2010
22 posts
2 tags
O’Reilly Ruby Best Practices →
Because we value our craft, its important to know the difference between code that is agile, and code that is fragile.
Chapter 1 - Driving Code Through Tests
Chapter 2 - Designing Beautiful APIs
Chapter 3 - Mastering the Dynamic Toolkit
Chapter 4 - Text Processing and File Management
Chapter 5 - Functional Programming Techniques
Code examples from Ruby Best Practices
1 tag
Functional Javascript →
Functional is a library for functional programming in JavaScript. It defines the standard higher-order functions such as map, reduce (aka foldl), and select (aka filter). It also defines functions such as curry, rcurry, and partial for partial function application; and compose, guard, and until for function-level programming. And all these functions accept strings, such as 'x -> x+1', 'x+1',...
2 tags
Сколько секунд было в 2008 году?
С одной стороны
3600*24*366+1=31622401
т.к. 31 декабря была введена очередная секунда координации.
Но подвох тут - в географии. Дополнительная секунда координации вводится в полночь по гринвичу (UTC time). Соответственно в восточном полушарии это был уже 2009 год, а в западном еще 2008.
Итак, полный ответ в 2008 году - 31622401 секунд в западном полушарии, и 31622400 в восточном.
По...
2 tags
EventMachine Protocol Implementations →
3 tags
Ruby Quicktips: Conditional Validation using... →
When you have a model that requires additional information, if a certain condition is met and you need to validate this attribute, this little trick can help.
Say we have a user model that needs to validate the truck_serial attribute if the user has the role of driver:
class User <...
1 tag
Hg Init: a Mercurial tutorial →
Пособие по Mercurial от Joel Spolsky
3 tags
SyncEnumerator in ruby
SyncEnumerator creates an Enumerable object from multiple Enumerable objects and enumerates them synchronously
Example
require 'generator'
s = SyncEnumerator.new([1,2,3], ['a', 'b', 'c'])
# Yields [1, 'a'], [2, 'b'], and [3,'c']
s.each { |row| puts row.join(', ') }
ruby-doc
1 tag
Трекинг заказных писем по СНГ →
Россия, Украина, Казахстан, Узбекистан
1 tag
Python Tips, Tricks, and Hacks →
Переводы статьи на Хабре
Python: советы, уловки, хаки (часть 1)
Python Tips, Tricks, and Hacks (часть 2)
Python Tips, Tricks, and Hacks (часть 3)
1 tag
Материалы продвинутого уровня по Питону →
2 tags
Interesting refactoring #1
A code that lets you define a date by using syntax like Feb[28][2010].
require 'date'
FancyDate = Hash.new do |hash, month|
Hash.new do |hash, day|
Hash.new do |hash, year|
Date.new(year, month, day)
end
end
end
Date::ABBR_MONTHNAMES[1..-1].each_with_index do |name,index|
Object.const_set(name, FancyDate[index+1])
end
refactor my code
3 tags
Offline rss reader
Идея сервиса навеяна статьей на хабре
Создать утилиту/сайт, которая(ый) бы на основе Google Reade’a генерил новостной pdf/fb2/txt и синхронизировался с ридером/нетбуком/коммуникатором.
В генерируем документе не должно ката, все что под катом должно вытягиваться автоматически и вставляться в документ в том или ином виде.
Основа корректной синхронизации, генерируемые скрытые файлы на...
2 tags
Linkdump #1
Срез от developers.org.ua
Современная версия “RU.PROGRAMMING FAQ” на reddit, reddit.com: FAQ — Must-read programming books? 220+ comments (best comment: “Yes, you must.”)
JavaScript на сервере, CommonJS/JSGI: The Emerging JavaScript Application Server Platform
Учебник по JavaScript, Contents — Eloquent JavaScript
Большая подборка тулов для веб-разработки под Firefox, IE, Opera, Codefusion Lab:...
1 tag
Реактивные веб-сайты. Электронные версии / Книги...
Целью данной книги является показать важность (иногда по-настоящему критическую) клиентской оптимизации и ключевые моменты и проблемные места. Очень хочется верить, что после прочтения книги у читателей сложится целостное представление о мире, находящемся между страницей в браузере пользователя и серверными мощностями. О том, что происходит, когда в адресной строке браузера вводится адрес или...
3 tags
ActiveRecord, method_missing и stack level too...
Переопределяя у ActiveRecord модели #method_missing важно помнить, что методы чтения атрибутов генерятся через сам #method_missing
Так, например, код
class Appearance < ActiveRecord::Base
serialize :prefereneces, HashWithIndifferentAccess
def method_missing(name, *args)
preferences[name] || super
end
end
вывалит Exception SystemStackError: stack level too deep
Обойти это можно,...
1 tag
Dummy Image генерирует графические заглушки...
http://dummyimage.com/480×240
4 tags
AASM & Acts as Audited
Let’s say you’re implementing rails app for a snowboard rental store.
A given snowboard can be in one of 3 states:
away for maintenance
available at store X
on loan to customer Y
The company needs to be able to view a rental history for
a particular snowboard
a particular customer
The rental history needs to include temporal data (e.g. Sally rented snowboard 0123 from Dec. 1,...
Формирование льда обычно происходит вокруг какой-то мусоринки или пылинки. Если...
– Получение льда нагреванием воды
2 tags
Через пару месяцев использования Сафари начинает отжирать 200% CPU на 30-60...
– http://levgem.livejournal.com/271531.html
С маками тоже проблема — жуткие тормоза. И при просмотре видео и вообще при...
– MythBusters: Правда и вымысел о Flash
(fab) a pure javascript DSL for building async web... →
Syntax is similar to Sinatra in Ruby
( fab )
( "/hello", function() {
return [
200,
{ "Content-Length": 6, "Content-Type": "text/plain" },
"hello!"
];
})
( fab )
3 tags
HOWTO protect against malicious images and other... →