Skip to content

Instantly share code, notes, and snippets.

View NV's full-sized avatar

Nikita Vasilyev NV

View GitHub Profile
@NV
NV / file_join_shortcut.rb
Created March 15, 2010 21:57
Shortcut for File.join
class String
# Shortcut for File.join
# Usage
# '..'/'foo' -> '../foo'
def /(path)
File.join(self, path.to_s)
end
end
@NV
NV / .bashrc
Created March 14, 2010 21:51
dotfiles: .zshrc .bashrc .vimrc
# /usr/local ➤ ls
PS1="\[\e[0;33m\]\W ➤ \[\e[0m\]"
# http://github.com/mbrubeck/compleat
source /usr/local/share/compleat-1.0/compleat_setup
@NV
NV / README.md
Created February 23, 2010 20:51
CSS hot reloading
@NV
NV / README.md
Created February 22, 2010 19:53
DOM navigator.mimeTypes WTF
@NV
NV / opera.document.all.js
Created February 22, 2010 19:43
Opera document.all WTF
>>> typeof document.all
"undefined"
>>> document.all
[object HTMLCollection]
>>> typeof document.all[0]
"object"
/
([a-zA-Z][-+.a-zA-Z\d]*): (?# 1: scheme)
(?:
((?:[-_.!~*'()a-zA-Z\d;?:@&=+$,]|%[a-fA-F\d]{2})(?:[-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]]|%[a-fA-F\d]{2})*) (?# 2: opaque)
|
(?:(?:
\/\/(?:
(?:(?:((?:[-_.!~*'()a-zA-Z\d;:&=+$,]|%[a-fA-F\d]{2})*)@)? (?# 3: userinfo)
(?:((?:(?:(?:[a-zA-Z\d](?:[-a-zA-Z\d]*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:[-a-zA-Z\d]*[a-zA-Z\d])?)\.?|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[(?:(?:[a-fA-F\d]{1,4}:)*(?:[a-fA-F\d]{1,4}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|(?:(?:[a-fA-F\d]{1,4}:)*[a-fA-F\d]{1,4})?::(?:(?:[a-fA-F\d]{1,4}:)*(?:[a-fA-F\d]{1,4}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))?)\]))(?::(\d*))?))?(?# 4: host, 5: port)
|
@NV
NV / Array.reduce.js
Created January 30, 2010 23:27
String argument for Array reduce function
var A_reduce = [].reduce;
Array.prototype.reduce = function reduce (callback, initialValue) {
var operator = callback;
return typeof operator == 'string' && /^[ +*/%-><!&|^?,.]/.test(operator)
? eval(this.join(operator))
: A_reduce.apply(this, arguments)
};
[1,2,3,4].reduce('+') // 10
[1,2,3,4].reduce('*') // 24
@NV
NV / README.md
Created January 22, 2010 08:29 — forked from ucnv/README.md

This script is also available at .

function Markdown(value) {
this.value = value || '';
this.length = this.value.length;
};
Markdown.prototype = new String;
// Instance methods
Markdown.prototype.toString = Markdown.prototype.valueOf = function(){return this.value};
Markdown.prototype.toHTML = function(){return Markdown.decode(this)};
num = 1;
(function () {
alert(num || 2); // 1, Obviosly
})();
(function () {
var num = num || 2;
alert(num); // 2!
})();