Skip to content

Instantly share code, notes, and snippets.

View Torthu's full-sized avatar

Torstein Thune Torthu

View GitHub Profile
@Torthu
Torthu / pilsprog-roadmap-spring-2013.md
Created November 30, 2012 16:18 — forked from nilsnh/pilsprog-roadmap-spring-2013.md
A roadmap for pils & programmering spring 2013

Concepts:

  • Event med 50 oppmøtte!
  • Umbrella: Tv-show (will be marketed against NRK's kulturstripen) (looking for product owner)
  • FNL: Friday Night Lightning. The second Friday every month. roduct Owner: Eivind (Torstein skaffer rom)
  • SatHack: Hackathons (Snorre)
  • Rekruttering/PR
    • Snakke med fagutvalg (møte opp i introfag)
      • Infomedia/informatica
      • HiB
  • Informatikk
@Torthu
Torthu / ds.css
Last active December 16, 2015 08:49
Twitch.tv dualstream
body {
margin:0;
padding:0;
}
.half-width {
width: 50%;
height: 100%;
float:left;
box-sizing:border-box;
padding-right: 1px;
@Torthu
Torthu / getImages.js
Created November 6, 2013 15:48
Download and save an array of images from a JSON file.
var http = require('http'),
fileJSON = require('./images.json'),
fs = require('node-fs'),
options,
assets = fileJSON.imageArr;
options = {
host: 'url.com',
port: 80,
path: 'path/to/images'
@Torthu
Torthu / LocalisedShortData.coffee
Created January 30, 2014 14:13
Very naive class for getting localised "short dates" on the form "30. jan" when you cannot trust locale.
DateUtil = {
getShortDate: ->
date = new Date()
return date.getDate() + '. ' + @_monthName(date.getMonth()).substring(0,3).toLowerCase()
_monthName: (monthId) ->
@months = {
0: 'Januar'
1: 'Februar'
2: 'Mars'
@Torthu
Torthu / Spotify Next
Created February 7, 2014 10:23
Automator script for Spotify next/prev (for instance for use on windows keyboards)
on run {input, parameters}
tell application "Spotify"
next track
end tell
end run
@Torthu
Torthu / addTextToG.js
Created February 12, 2014 13:30
Add textNode to g-element in SVG
// textToDisplay = whatever you want to fill the textnode with
// elementId g element id (that the textnode will be appended to)
function addTextToG(textToDisplay, elementId) {
// create svg text node
var textNode = document.createElementNS("http://www.w3.org/2000/svg","text");
textNode.appendChild(document.createTextNode(textToDisplay));
// append created textnodes to g nodes
document.getElementById(elementId).appendChild(textNode);
}
@Torthu
Torthu / UrlParam.js
Created February 12, 2014 14:08
Class for getting URL parameters in native Javascript
function UrlParam() {
this.params = {};
var self = this;
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m,key,value) { self.params[key] = value });
this.get = function (param) {
if(this.params[param]) {
return this.params[param];
} else {
@Torthu
Torthu / deepClone.coffee
Created June 11, 2014 07:57
Simple deep clone
# Simple deep clone function
deepClone = (originalObject) ->
JSON.parse(JSON.stringify(originalObject))
clone = deepClone
a: 'a'
b:
c: 'c'
@Torthu
Torthu / autosize.coffee
Created August 11, 2014 09:55
SVG autosize image
# Pseudo, you'll need a library to get .attr()
autosizeImage = (imgSrc, imgElem) ->
# Load image and get size.
img = new Image
img.src = imgSrc
img.onload = ->
imgElem.attr('height', @height)
.attr('width',@width)
.attr('xlink:href', @src)
@Torthu
Torthu / BetterAngularModule.js
Last active August 29, 2015 14:08 — forked from hiddentao/gist:7300694
Make Angular module definition independent of file order.
/**
* Workaround to make defining and retrieving angular modules easier and more intuitive.
* Original: https://gist.github.com/hiddentao/7300694 // http://www.hiddentao.com/archives/2013/11/04/an-improved-angular-module-split-your-modules-into-multiple-files/
*/
(function(angular) {
var origMethod = angular.module;
var alreadyRegistered = {};