Skip to content

Instantly share code, notes, and snippets.

View vnys's full-sized avatar

Victor Nystad vnys

View GitHub Profile
@vnys
vnys / streams.js
Last active February 2, 2016 13:04
streams
const stream = require('stream');
let readable = new stream.Readable({
objectMode: true,
read: function() {
let arr = [ { a: 1 }, { b: 1 }, { c: 1 } ];
arr.forEach( item => { this.push(item) });
this.push(null);
}
}).on('end', function() {
@vnys
vnys / reverse.js
Created January 11, 2016 13:05
Reverse text on webpage
(function(body) {
var text = [],
treewalker = document.createTreeWalker(body, NodeFilter.SHOW_TEXT, null, false);
while(treewalker.nextNode()) {
if (treewalker.currentNode.nodeValue.charAt(0) !== '\n') {
text.push(treewalker.currentNode);
}
};
@vnys
vnys / cors.nginxconf
Created January 6, 2016 14:34 — forked from pauloricardomg/cors.nginxconf
Nginx configuration for CORS-enabled HTTPS proxy with origin white-list defined by a simple regex
#
# Acts as a nginx HTTPS proxy server
# enabling CORS only to domains matched by regex
# /https?://.*\.mckinsey\.com(:[0-9]+)?)/
#
# Based on:
# * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html
# * http://enable-cors.org/server_nginx.html
#
server {
cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/
git clone git://github.com/wbond/sublime_package_control.git Package\ Control
cd Package\ Control
git checkout python3
# restart Sublime Text 3 and you should have Package Control working
@vnys
vnys / star-new.svg
Created December 4, 2015 09:02
star
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vnys
vnys / weekendCustomFormula.md
Created December 3, 2015 16:25
google spreadsheets

How to add background colour to weekends in a vertical calendar

Apply to range: A2:D176 Custom formula: =OR(WEEKDAY($A:$A)=7, WEEKDAY($A:$A)=1)

@vnys
vnys / css-nesting.md
Last active December 1, 2015 08:21
css-nesting

###css nesting polyfill

Input

.main {
	@nest & a {
		text-decoration: none;
	}
}
@vnys
vnys / exiftool.md
Last active October 14, 2016 05:51
exiftool

Navngi filer med samme konvensjon som brukes av DropBox i Camera Upload.

cd <photo-directory>
exiftool "-FileName<CreateDate" -d "%Y-%m-%d %H.%M.%S%%-c.%%le" .
@vnys
vnys / cellar.svg
Last active November 11, 2015 20:55
Cellar
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vnys
vnys / regex.js
Created November 8, 2015 08:41
Treningslog regex
'3 x 10 x 10 min 2kg '.match(/(\d+\s?[x|min|kg]+)/g).forEach(match => console.log(match.replace(/\s/,'').match(/(\d+)(\w+)/)))