Skip to content

Instantly share code, notes, and snippets.

View NV's full-sized avatar

Nikita Vasilyev NV

View GitHub Profile
@NV
NV / README.markdown
Created September 26, 2012 14:19
Jekyll plugin for creating an alternative view (e.g. print view) for a post
@NV
NV / most_used_css_property_names.js
Created September 19, 2012 18:47
PhantomJS script to collect most used CSS property names (supported by WebKit)
// phantomjs --web-security=no most_used_css_property_names.js
var urls = [
'http://google.com',
'http://facebook.com',
'http://youtube.com',
'http://yahoo.com',
'https://github.com/',
'http://twitter.com/',
'http://en.wikipedia.org/wiki/Main_Page',
@NV
NV / css_properties.txt
Created September 14, 2012 00:21
All (301) CSS properties in Chrome 23
-webkit-align-content
-webkit-align-items
-webkit-align-self
-webkit-animation
-webkit-animation-delay
-webkit-animation-direction
-webkit-animation-duration
-webkit-animation-fill-mode
-webkit-animation-iteration-count
-webkit-animation-name
@NV
NV / Readme.mdown
Created May 14, 2012 17:31
Dropbox command-line shortcuts

I have 2 Macbooks: one at work and one at home. I sync them using Dropbox. I sync lots of things: iTunes library, dotfiles, some ~/Library/Preferences/.

For example, I have a ~/.profile file in my home machine. I want to have the same file in my work machine. So I do the following:

$ cp ~/.profile ~/Dropbox/Mac/Users/nv/.profile 

On the work machine I do:

$ cp ~/Dropbox/Mac/Users/nv/.profile  ~/.profile
@NV
NV / hack.sh
Created May 10, 2012 17:30 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@NV
NV / README.mdown
Created December 18, 2011 21:40
Trying to make coa (https://github.com/veged/coa) shell command auto-completion work.
  1. I've made a coa-completion-dummy
  2. ➤ ./coa-completion-dummy --ve
  3. Press Tab and nothing happens

I guess I have to generate some shell script first and then put source some_script.sh in my .bashrc. README.md doesn't mention any of those, instead it says:

Cmd.completable Adds shell completion to command, adds "completion" subcommand, that makes all the magic.

@NV
NV / tail_call_factorial.js
Created December 8, 2011 23:49
Is it tail call or not?
function fact(x) {
return _f(1, x);
function _f(acc, x) {
return x === 0 ?
acc :
_f(acc * x, x - 1);
}
}
/*
Yes, it is!
@NV
NV / clone_object_with_circular_references.js
Created November 26, 2011 18:22
Clone an Object with all its circular references. Take that jQuery.extend!
function cloneObject(object) {
return extendObject({}, object);
}
function extendObject(base, object) {
var visited = [object];
// http://en.wikipedia.org/wiki/Adjacency_list_model
var set = [{value: base}];
@NV
NV / context-preserving.js
Created November 16, 2011 00:54
There is absolutely no way to make a callWithOriginalContext function, right?
var obj = {
getX: function() {
return this.x
},
x: 1
}
callWithOriginalContext(obj.getX) // 1
//There is absolutely no way to make a callWithOriginalContext function, right?
@NV
NV / detect_indent_style.js
Created October 17, 2011 20:11
Guess indent style used in JS file (i.e. tabs, 2 spaces, 4 spaces)
var sample = "'use strict';\n\
\n\
/**\n\
* @param {string} selector\n\
* @nosideeffects\n\
* @return {Element|null}\n\
*/\n\
HTMLElement.prototype.up = function(selector) {\n\
var element = this;\n\
while (element = element.parentElement) {\n\