Skip to content

Instantly share code, notes, and snippets.

View NV's full-sized avatar

Nikita Vasilyev NV

View GitHub Profile
@NV
NV / parse-css.js
Created November 3, 2013 03:44
Parse CSS in a browser
var style = document.createElement('style')
var iframe = document.createElement('iframe')
document.body.appendChild(iframe)
iframe.contentDocument.documentElement.appendChild(style)
iframe.style.display = 'none'
style.textContent = 'a {color: red}'
style.sheet // CSSStyleSheet
style.sheet.cssRules[0].cssText // 'a { color: red; }'
style.sheet.cssRules[0].selectorText // 'a'
@NV
NV / Google search domains
Created April 2, 2010 20:55
All checked manually
google.ac
google.ae
google.af
google.ag
google.am
google.com.ar
google.as
google.at
google.com.au
google.az
@NV
NV / ligatweet.user.js
Created December 1, 2009 00:38
Script for tweet shortening using unicode ligatures and other compound symbols
// ==UserScript==
// @name ligatweet
// @namespace http://leaverou.me/demos/ligatweet/
// @description Script for tweet shortening using unicode ligatures and other compound symbols
// @include htt*://twitter.com/*
// @author Lea Verou (UserJS by Nikita Vasilyev)
// @version 1.0
// @license Licensed under the MIT license http://www.opensource.org/licenses/mit-license.php
// ==/UserScript==
@NV
NV / TemperatureConverter.js
Last active October 7, 2016 05:45
React.js temperature converter sample app http://bl.ocks.org/NV/193d039f286bf56f9c01
/**
* @jsx React.DOM
*/
function c2f(c) {
return 9 / 5 * parseFloat(c) + 32;
}
function f2c(f) {
return 5 / 9 * (f - 32);
}
@NV
NV / isLikelyMinified.js.carbide.md
Created August 24, 2016 23:42
isLikelyMinified.js

isLikelyMinified.js

@NV
NV / named-arguments.js
Created December 13, 2013 01:25
JavaScript named arguments
callWithNamed({one: 1, two: 2, three: 3}, function(three, one, two) {
console.log(one, two, three);
});
function callWithNamed(dict, fn, context) {
var newArgs = [];
var parsedArgs = parseArgs(fn);
for (var i = 0; i < parsedArgs.length; i++) {
var name = parsedArgs[i];
@NV
NV / connect.js
Last active December 26, 2015 00:29
2 Rectangles Convex Hull, e.g. find minimum polygon that wraps any two rectangles.
attachPair(document.getElementById('a'), document.getElementById('b'), createPolygon());
attachPair(document.getElementById('c'), document.getElementById('d'), createPolygon());
attachPair(document.getElementById('e'), document.getElementById('f'), createPolygon());
function attachPair(a, b) {
var polygon = createPolygon();
draggable(a, {
onMove: function(e) {
update(a, b, polygon);
}
@NV
NV / README.markdown
Last active December 22, 2015 03:09
Command-line tool for pow!

Serve static files in a current directory and create $current_dir.dev host name.

Usage

~/Sites/usercss.ru ➤ pow
open http://usercss.ru.dev/

~/Sites/n12v.com/static ➤ pow n12v