Skip to content

Instantly share code, notes, and snippets.

View NV's full-sized avatar

Nikita Vasilyev NV

View GitHub Profile
@NV
NV / never-use-cd-.sh
Created August 24, 2011 12:28
Never write cd - in Bash scripts
pwd # ~/tmp
(
mkdir foo
cd foo
pwd # ~/tmp/foo
)
pwd # ~/tmp
@NV
NV / webkit_crash_log
Created June 28, 2011 19:36
WebKit Nightly doesn't work
Process: Safari [61170]
Path: /Applications/WebKit.app/Contents/MacOS/WebKit
Identifier: org.webkit.nightly.WebKit
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: launchd [151]
Date/Time: 2011-06-28 23:34:13.885 +0400
OS Version: Mac OS X 10.6.7 (10J869)
Report Version: 6
@NV
NV / run-safari-fails
Created June 24, 2011 16:39
WebKit/Tools/Scripts/run-safari fails
Process: Safari [25546]
Path: /Applications/Safari.app/Contents/MacOS/Safari
Identifier: Safari
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: perl5.10.0 [25535]
Date/Time: 2011-06-24 20:28:58.876 +0400
OS Version: Mac OS X 10.6.7 (10J869)
Report Version: 6
@NV
NV / object_keys.js
Created May 30, 2011 07:11
How can I get all keys of an object (including enumerable:false)?
var obj = {};
Object.defineProperty(obj, "x", {value: 42, enumerable: false});
Object.defineProperty(obj.__proto__, "y", {value: 63, enumerable: false});
for (var key in obj) console.log(key)
// nothing
Object.keys(obj)
// []
@NV
NV / object-specific_classes.js
Created January 30, 2011 19:18
Object-Specific Classes in Ruby and JavaScript (via non-standard __proto__)
rectangle = {
width: 10,
height: 8
}
rectangle.__proto__ = {
area: function() {
return this.width * this.height
}
}
@NV
NV / user-defined vars.js
Created October 14, 2010 12:27
Get user-defined variables
var snapshot = {};
for (var k in window) {
snapshot[k] = window[k]
}
var a = 1;
var diff = {};
for (var k in window) {
@NV
NV / README.mdown
Created October 8, 2010 12:27
UserJS: Bugzilla attachments preview
@NV
NV / magic_namespace.js
Created September 22, 2010 15:46
Is it possible to implement this magicNamespace function?
var myModule = {};
magicNamespace(myModule, function(){
var a = 1;
});
myModule.a // 1
@NV
NV / namespacing_question.js
Created September 22, 2010 13:45
Is that Magic exists?
var O = {};
// Magic begins
var a = 1;
// Magic ends
a // undefined
O.a // 1
// Re: http://twitter.com/pepelsbey/status/24410437437
var a = 10;
loop = setInterval( fadeout, 1000 );
function fadeout() {
console.log(a / 10);
if( a > 0 ) {
a -= 2;
} else {
clearInterval( loop );