Oleg Andreev

Month
Filter by post type
All posts

Text
Photo
Quote
Link
Chat
Audio
Video
Ask

May 2009

Correct BlankSlate in Ruby
class BlankSlate
  class <<self; alias __undef_method undef_method; end
  alias __instance_eval instance_eval
  ancestors.inject([]){|m,a| m + a.methods }.uniq.
    each { |m| (__undef_method(m) rescue nil) unless m =~ /^__/ }
end

class MyProxy < BlankSlate; end

Note 1: ancestors.inject{…} ensures that all Kernel methods like :p are properly removed.

Note 2: alias __instance_eval could be safely removed if you don’t need this method.

May 30, 2009
#ruby #blankslate #code #example
Steve Dekorte on torturedekorte.com
May 29, 2009
#torture #quote #link
The most detailed description of graphd, the metaweb storage engineblog.freebase.com

“Giving every piece of data a fixed identity, is radically different from the relational model which deals only with sets of values and leaves the notion of identity up to the application. Working with identities as a first-class notion is essential if schema is to be flexible. Long before we can agree on the exact shape of the data used to represent a person or a building, we can agree that individual people or buildings exist and that they have certain obvious attributes that we might want to record: height, address, builder, etc.”

May 28, 2009
#metaweb #graphd
The End of an Architectural Era (It's Time for a Complete Rewrite)vldb.org
May 28, 2009
#paper #rdbms #db
Worlds/JSvpri.org

JavaScript transactional memory extension

May 28, 20091 note
#js #transactions #worlds #paper
MurmurHashmurmurhash.googlepages.com

“The name, if you’re wondering, comes from the simplest sequence of operations which will thoroughly mix the bits of a value - "x *= m; x = rotate_left(x,r);” - multiply and rotate. Repeat that about 15 times using ‘good’ values of m and r, and x will end up pseudo-randomized"

Austin Appleby.

May 27, 2009
#hash #algorithm #murmur #quote #link
“

HFS+ also has a few specific optimizations. When a file is opened on an HFS+ volume, the following conditions are tested:

— The file is less than 20 MB in size
— The file is not already busy
— The file is not read only
— The file is fragmented (the eighth extent descriptor in its extend record has a non-zero block count)
— The system uptime is at least 3 minutes

If all the above are satisfied, the file is relocated (de-fragmented) - on-the-fly.

”
—What Is Mac OS X?, Mac OS X Filesystems (Amit Singh)
May 24, 2009
#hfs #mac #paper #fs #optimization #defragmentation
The rsync algorithm tech reportsamba.org
May 24, 2009
#rsync #diff #algorithm #checksum
Play
May 23, 2009
Sorting algorithm animationssorting-algorithms.com

Thanks to gotsyk for the link.

May 22, 20091 note
#sort #algorithm #animation
The Little Manual of API Designchaos.troll.no

Thanks to julik for the link.

May 22, 20091 note
#api #design #manual #whitepaper
Human-friendly Base32 encoding by Douglas Crockfordcrockford.com

The encoding scheme is required to

— Be human readable and machine readable.
— Be compact. Humans have difficulty in manipulating long strings of arbitrary symbols.
— Be error resistant. Entering the symbols must not require keyboarding gymnastics.
— Be pronounceable. Humans should be able to accurately transmit the symbols to other humans using a telephone.

May 15, 2009
#encoding #base32 #crockford #link #quote
Recursive descent parser in JavaScript

Parser.js
JSONGrammar.js

The parser enables you to write BNF-like rules directly in JavaScript without need to compile the file (like with Ragel, YACC, Bison, ANTLR etc.)

The grammar is a JS function with 11 arguments (9 rules and 3 hooks). Each rule gets two arguments: text (string) and state (arbitrary value) and returns a tuple of new text and new state (or null if rule was not matched). Parser walks character by character from left to right. text is always a tail of the initial text. Generally, text is empty string when parser finishes.

All(rule1, rule2, …) — a sequence of rules. Example: All(Char(“[”), list, Char(“]”)) defines a JS array.

Any(rule1, rule2, …) — “OR” rule for any number of rules. Example: JSONValue = Any(StringRule, ObjectRule, ArrayRule, …)

Char(alphabet) — character matching rule. Example: digit = Char(“0123456789”)

NotChar(alphabet) — inverse of Char(). Any character — NotChar(“”).

Optional(rule) — tries to match rule and skips it if not matched. Example: optSpace = Optional(Char(“ \t\r\n”))

EOF — matches the end of the text. Fails if text != “”.

Terminator — terminates parser. That is, always returns empty text.

Y — Y-combinator for defining recursive rules. Example: X = Y(function(x) { return abc(x) } ), where x is equal to X. Google for more info on Y-combinator.

Hooks enable you to actually build some structures using your grammars. Every hook returns a new state value to use in further rules. You should avoid mutable state values because some rules may be thrown away if not matched later (remember: this is a recursive parser!). For example, use array.concat([value]) instead of array.push(value).

Capture(rule, function(buffer, state1){ return state2 }) — captures raw string buffer to store in the state2.

Before(rule, function(state1){ return state2 }) — creates a new state for the rule (e.g. creates empty array for array syntax).

After(rule, function(beforeState, afterState){ return newState }) — creates a new state after successful match. You can put nested values to the container if beforeState is a container before rule parsing, afterState is a nested value (after rule match) and newState is a new container with this value.

See usage examples in JSONGrammar.js

See the parser source code in Parser.js

May 11, 20092 notes
#parser #bnf #js #recursion
single-letter aliases for git commandsgithub.com
May 7, 2009
#git #aliases #bash #github
“

How to use Natural Order

Drop Natural Order into the System Folder and Restart your Mac.

”
—NaturalOrderSort.org
May 5, 2009
#link #sorting #algorithm #plugin #mac #quote
Next page →
20152016
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
201420152016
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
201320142015
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
201220132014
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
201120122013
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
201020112012
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
200920102011
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
200820092010
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
200720082009
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
200620072008
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
200520062007
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
200420052006
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
200320042005
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
200220032004
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
200120022003
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
200020012002
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
199920002001
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
199819992000
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
199719981999
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
199619971998
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
199519961997
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
199419951996
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
199319941995
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
199219931994
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
199119921993
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
199019911992
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
198919901991
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
198819891990
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
198719881989
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
198619871988
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
19861987
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December