Skip to content

Instantly share code, notes, and snippets.

View omichelsen's full-sized avatar

Ole Bjørn Michelsen omichelsen

View GitHub Profile
@omichelsen
omichelsen / .editorconfig
Last active March 8, 2016 19:03
Default editorconfig with tabs and 4 spaces
root = true
[*]
indent_style = tab
indent_size = 4
@omichelsen
omichelsen / logger.js
Last active March 5, 2016 21:10
JS: Logger
export const LogLevels = {
log : 0,
info : 1,
warn : 2,
error : 3
}
function clone(arr) {
return arr.map(a => JSON.parse(JSON.stringify(a)))
}
@omichelsen
omichelsen / gist:8464951
Created January 16, 2014 22:45
JavaScript async remote
(function (window, document) {
var settings = {
dataId: 'data-myModule-id',
url: '/api/mymodule/'
};
function load() {
var elems = document.querySelectorAll('[' + settings.dataId + ']');
if (!elems) {
@omichelsen
omichelsen / gist:8373905
Created January 11, 2014 17:28
jQuery formNavigtaion
(function ($) {
$.fn.formNavigation = function () {
$(this).each(function () {
$(this).find('input').on('keyup', function(e) {
switch (e.which) {
case 39:
$(this).closest('td').next().find('input').focus(); break;
case 37:
$(this).closest('td').prev().find('input').focus(); break;
case 40:
@omichelsen
omichelsen / index.html
Created December 28, 2013 11:24
Bootstrap Jumbotron Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">
@omichelsen
omichelsen / PHP: AtomFeed
Created November 24, 2015 08:50
Helper class for creating an Atom feed
class AtomFeed
{
private $xml;
function __construct()
{
$this->xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" />');
}
function setFeedHeader($title, $uri, $updated, $author_name, $author_email, $author_uri)
@omichelsen
omichelsen / feed.xml.jade
Created October 16, 2015 11:11
Jade: RSS
doctype xml
rss(version="2.0", xmlns:atom="http://www.w3.org/2005/Atom")
channel
title= title
link= url
description= description
language= language
atom:link(href="#{ url }feed.xml", rel="self", type="application/rss+xml")
each post, slug in public.blog._data
if slug !== 'index'
@omichelsen
omichelsen / unique.js
Created August 13, 2014 18:09
JS: unique
function unique(value, index, self) {
return self.indexOf(value) === index;
}
@omichelsen
omichelsen / gist:074ffaa3b52b3286afd1
Created August 7, 2014 20:17
JS: Cartesian Product
function cartesianProductOf() {
  return Array.prototype.reduce.call(arguments, function(a, b) {
    var ret = [];
    a.forEach(function(a) {
      b.forEach(function(b) {
        ret.push(a.concat([b]));
      });
    });
    return ret;
  }, [[]]);
@omichelsen
omichelsen / data.json
Last active August 29, 2015 14:04
Parse MediaDeviceService from LogEntries
[
{"r":"353a81d9-091e-479c-9b07-fc1e271d91a5","s":169359380359,"t":1406294298153,"m":"94.18.214.22 aog5x7dc INFO 'MediaDeviceService.getDevices.devices.video [\"FaceTime HD Camera (Display) (05ac:1112)\",\"FaceTime HD Camera (PUF6:VVDR)\"]'"},
{"r":"353a81d9-091e-479c-9b07-fc1e271d91a5","s":123643402383,"t":1406294317904,"m":"66.225.159.5 3197oner INFO 'MediaDeviceService.getDevices.devices.video []'"},
{"r":"353a81d9-091e-479c-9b07-fc1e271d91a5","s":71475116496,"t":1406294381007,"m":"69.14.193.178 qu2r7yz2 INFO 'MediaDeviceService.getDevices.devices.video [\"FaceTime HD Camera (Built-in) (05ac:8509)\"]'"},
{"r":"353a81d9-091e-479c-9b07-fc1e271d91a5","s":169458215047,"t":1406294454260,"m":"12.168.155.42 dolfhlfu INFO 'MediaDeviceService.getDevices.devices.video [\"Integrated Webcam (0c45:6433)\"]'"},
{"r":"353a81d9-091e-479c-9b07-fc1e271d91a5","s":123786187023,"t":1406294521582,"m":"69.14.193.178 qu2r7yz2 INFO 'MediaDeviceService.getDevices.devices.video [\"FaceTime HD Camera (Built-in) (05ac:8509)\"]'"},
{"r