Skip to content

Instantly share code, notes, and snippets.

View vnys's full-sized avatar

Victor Nystad vnys

View GitHub Profile
@vnys
vnys / intellij-on-osx.md
Created November 12, 2014 08:38
IntelliJ on OS X

To force running under JDK 1.7 edit /Applications/.app/Contents/Info.plist file, change JVMVersion from 1.6* to 1.7* :

<key>JVMVersion</key>
<string>1.7*</string>
@vnys
vnys / jsonml_parser_for_legacy_browsers.js
Last active August 29, 2015 14:10
simple jsonml parser
(function() {
var wrapper = document.createElement('div');
var jsonml = [
['p', 'dette er kun tekst'],
['p', 'dette er', [ 'strong', 'bold' ], 'tekst'],
['p', 'dette er enda en linje med en', ['a', { 'href' : 'http://www.ba.no' }, 'link']]
];
@vnys
vnys / gist:1ec57ebdc099b8605485
Last active August 29, 2015 14:10 — forked from padolsey/gist:527683
ie detection with conditional comments in js
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@vnys
vnys / README.md
Last active August 29, 2015 14:10 — forked from mbostock/.block

First define the margin object with properties for the four sides (clockwise from the top, as in CSS).

var margin = {top: 20, right: 10, bottom: 20, left: 10};

Then define width and height as the inner dimensions of the chart area.

var width = 960 - margin.left - margin.right,
    height = 500 - margin.top - margin.bottom;

Lastly, define svg as a G element that translates the origin to the top-left corner of the chart area.

@vnys
vnys / bondage.js
Last active August 29, 2015 14:11
Bondage (bind lib)
var tag = document.createElement.bind(document),
txt = document.createTextNode.bind(document),
get = document.querySelector.bind(document),
getall = document.querySelectorAll.bind(document),
log = console.log.bind(console);
@vnys
vnys / 2015.01.18-2014.12.12.md
Last active August 29, 2015 14:13
askoyfk.no – google analytics

Perioden 12. desember 2014 til 18. januar 2015

  • 4146 sidevisninger fordelt på 1735 sesjoner, flest 14., 29. og 30. desember
  • 59,94% av alle besøk foretatt på mobile enheter (18,21% på tablet, 41,73% på mobil)
  • 76,1% av alle besøk endte på forsiden
@vnys
vnys / interop.md
Last active August 29, 2015 14:14 — forked from domenic/interop.md

module.exports = and ES6 Module Interop in Node.js

The question: how can we use ES6 modules in Node.js, where modules-as-functions is very common? That is, given a future in which V8 supports ES6 modules:

  • How can authors of function-modules convert to ES6 export syntax, without breaking consumers that do require("function-module")()?
  • How can consumers of function-modules use ES6 import syntax, while not demanding that the module author rewrites his code to ES6 export?

@wycats showed me a solution. It involves hooking into the loader API to do some rewriting, and using a distinguished name for the single export.

This is me eating crow for lots of false statements I've made all over Twitter today. Here it goes.

@vnys
vnys / inline-styles.js
Last active August 29, 2015 14:15
inline styles in javascript
/*
Quick and easy way to write inline styles in js
setAttribute is not used to avoid overwriting the styles attribute if present on the element
Implies you’re inside a constructor where this.el is the element to be styled
*/
var styles = [
['width', '100%'],
['height', '100%'],
['background', 'orange']
@vnys
vnys / example.js
Created March 4, 2015 11:41
jsonml
//<p class="txt-m">Congrats, <span class="icon icon--goldMedal" aria-hidden="true"></span> First place!</p>
[ 'p', { 'class' : 'txt-m' }, 'Congrats, ',
[ 'span', { 'class' : 'icon icon--goldMedal', 'aria-hidden' : 'true' } ],
'First place!'
]