Skip to content

Instantly share code, notes, and snippets.

View birkir's full-sized avatar
👋
Howdy

Birkir Gudjonsson birkir

👋
Howdy
View GitHub Profile
@birkir
birkir / Gruntfile.js
Created May 15, 2014 15:33
Grunt task to save compiled file as Lisa SupportFile
watch: {
// ...
less: {
files: 'less/*.less',
// tasks: 'less',
tasks: ['less', 'save-support-file']
}
}
// ...
@birkir
birkir / next.prev.newsitems.xml
Created June 4, 2014 13:34
Next/Prev News Items Navigation
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:control="lisa:ControlInfo" xmlns:lisa="lisa:XsltExtensions" exclude-result-prefixes="lisa control">
<xsl:output method="html" omit-xml-declaration="yes" indent="yes"/>
<xsl:param name="query-string"/>
<xsl:param name="NewsPageId"/>
<xsl:variable name="newsid" select="$query-string/param[@name = 'NewsId']" />
<xsl:template match="News">
<xsl:for-each select="Item">
<xsl:sort select="Start" order="ascending"/>
<xsl:if test="NewsItemId = $newsid">
@birkir
birkir / priceVolume.php
Last active August 29, 2015 14:05
Get most efficient amount of product by volume and price
<?php
function vol_price ($needed) {
$table = array(
array(250, 0.90),
array(330, 1.30),
array(500, 2.20),
array(1000, 2.50),
array(1500, 3.00),
@birkir
birkir / results.md
Last active August 29, 2015 14:08
Support Ticket benchmark results

List tickets


Laravel

Queries

@birkir
birkir / christmastree.js
Created December 1, 2014 16:06
Jóladagatal 1/24 - Christmas Tree
function tree(w) {
return "\n" + Array.apply(null, Array(w)).map(function (_, x) {
return Array.apply(null, Array(w*2)).map(function (_, y) {
if (y === w-x && x === 0) return 'X';
if (y > (w-x) && y < (w+x)) return (Math.random() > 0.7) ? '@' : '.';
return (y === w-x) ? '/' : ((y === w+x) ? '\\' : ' ');
}).join('');
}).join("\n");
}
@birkir
birkir / santa-said-merry-christmas.js
Last active August 29, 2015 14:10
Jóladagatal 2/24 - Jólakveðja
/**
* Circulate santas saying merry christmas to each other
* @param int Numer of santas
* @return String
*/
function santaSaidMerryChristmas(n) {
// vars
var santas = Array.apply(null, Array(n)).map(function (_, i) { return (i + 1); }),
i = 0;
@birkir
birkir / spegilord.js
Created December 4, 2014 10:27
Jóladagatal 4/24 - Spegilorð
// HTTP 200 www.foo.is /ord
// paste in console
var words = document.body.children[0].innerText.toLowerCase().split("\n"),
count = 0;
for (var i = 0; i < words.length; i++) {
for (var p = Math.floor(words[i].length / 2); p >= 0; p--) {
if (words[i][p] !== words[i][words[i].length - p - 1]) break;
if (p === 0) count++;
@birkir
birkir / results-1B.txt
Created December 9, 2014 10:51
Jóladagatal 9/24 - Skrítnar tölur
81
2.025
3.025
9.801
494.209
998.001
24.502.500
25.502.500
52.881.984
60.481.729
@birkir
birkir / factorial.js
Created December 11, 2014 17:48
Jóladagatal 11/24 - Umturnun á stafrófi
// get factorial by iteration (faster than recursive)
Math.factorial = function (n) {
var a = 1;
for (var i = 2; i < n; i++) {
a *= i;
}
return a;
}
// setup test case
@birkir
birkir / word-by-elements.js
Created December 19, 2014 16:32
Jóladagatal 16/24 - Lotukerfið
// HTTP 200 www.foo.is /ord
// paste in console
// parameters
var singles = 'hbcnofpskvyiwu'.split(''),
doubles = 'helibenenamgalsiclarcascticrmnfeconicuzngageassebrkrrbsrzrnbmotcrurhpdagcdinsnsbtexecsbalaceprndpmsmeugdtbdyhoertmybluhftareosirptauhgtlpbbipoatrnfrraacthpanppuamcmbkcfesfmmdnolrrfdbsgbhhsmt'.match(/.{1,2}/g),
elements = singles.concat(doubles),
words = document.querySelector('pre').innerHTML.split('\n');
// sort words by length