Skip to content

Instantly share code, notes, and snippets.

{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript,typescriptreact",
@maranomynet
maranomynet / extinction-rebellion-logo.svg
Last active April 24, 2019 23:16
Extinction Logo (w. flair)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maranomynet
maranomynet / isValidKennitala.js
Created February 19, 2018 23:23
Simple JavaScript module to validate Icelandic kennitalas
export default function isValidKennitala(kt) {
// Trim and remove optional "-" or " " separators
kt = kt.trim().replace(/\s|-/, '');
// Alternatively only allow separator as 7th character
// kt = kt.replace(/^(.{6})[\s-]/, '$1');
// Must be 10 digits, ending in either 0 or 9 (note Y2.1k problem!)
if ( kt.length !== 10 && !/^\d{9}[90]$/.test(kt) ) {
return false;
}
@maranomynet
maranomynet / README.md
Last active April 19, 2017 16:42
Minimal Stylus setup

Einfalt Stylus setup

Þú þarft að vera búinn að installa nodejs. (Yfirleitt öruggast að velja nýjustu LTS útgáfuna, því allra, allra nýjasta nýjasta útgáfa er stundum pínu experimental og bögguð.)

Búa til nýtt verkefni.

cd myprojectfolder
npm init
@maranomynet
maranomynet / thisamericanlive-archive.js
Last active July 7, 2021 17:36
This American Life - RSS Archive Builder
// Usage:
// 1. Visit http://www.thisamericanlife.org/radio-archives
// 2. Paste this script into the developer console of your browser.
// 3. Wait...
// 4. Copy-paste the resulting XML into a file.
//
(function(){
var jQuery = window.jQuery;
var doc = document;
@maranomynet
maranomynet / mithril-mu.md
Last active August 29, 2015 14:25
Feature wrapper for Mithril.js
@maranomynet
maranomynet / sort-mithril-routes.js
Last active August 29, 2015 14:22
Sorting mithril-style routes logically
// https://gist.github.com/maranomynet/b3070a9aa08219566508
var _sortRoutes = function ( routes ) {
var sortedRoutes = {};
var tokens = {};
var tokenize = function (str) {
var token = tokens[str];
if ( token == null )
{
token = tokens[str] = str
// Sort order: ? < n < s < v < …
@maranomynet
maranomynet / array.sortISL.js
Last active May 29, 2016 15:01
Sort an array
/*
array.sortISL.js -- (c) 2014 Hugsmiðjan ehf. - MIT/GPL
Written by Már Örlygsson - http://mar.anomy.net
Original at: https://gist.github.com/maranomynet/9972930
Install via npm:
npm install gist:9972930
Use with CommonJS:
@maranomynet
maranomynet / throttlefn.js
Last active December 26, 2015 04:09
basic function throttling utility function
// returns a throttled function that never runs more than every `delay` milliseconds
// the returned function also has a nice .finish() method.
$.throttleFn = function (func, skipFirst, delay) {
if ( typeof skipFirst === 'number' )
{
delay = skipFirst;
skipFirst = false;
}
delay = delay || 50;
var throttled = 0,