Skip to content

Instantly share code, notes, and snippets.

View dflemstr's full-sized avatar

David Flemström dflemstr

View GitHub Profile
//Linear interpolation of a 2D double array
private double[,] Interpolate(double[,] matrix, int dim)
{
double[,] result = new double[dim, dim];
double sf = (double)(matrix.GetLength(0) - 1) / (double)(dim - 1d);
for (int x = 0; x < dim; x++)
{
for (int y = 0; y < dim; y++)
{
public class Card {
private int number, colors;
private static String[] Colors = { "Hearts", "Spades", "Diamonds", "Clubs" };
private static String[] Number = { "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Knave", "Queen", "King" };
Card(int Cardcolors, int Cardnumber){
this.number=Cardnumber;
this.colors=Cardcolors;
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is an example PXML file for an application named "Exaile", to
demonstrate how a PXML file is supposed to be structured. Feel free to
replace all of the field contents with your own data, and to remove these
comments afterwards, in order to get a working and valid PXML file.
Note that this file is MINIMAL aka. this is the information you SHOULD
specify if you're well-behaved (all of it isn't NEEDED per-se, though)-->
<!--
Select
items1.id as items1_id,
localizations3.itemId as localizations3_itemId,
localizations3.languageName as localizations3_languageName,
items1.id as items1_id,
localizations2.string as localizations2_string,
localizations2.itemId as localizations2_itemId,
localizations2.languageName as localizations2_languageName,
localizations3.string as localizations3_string,
localizations3.itemId as localizations3_itemId,
//This doesn't actually work, since function application has the highest precedence in Scala.
def repeat(self: String, times: Int) = self * times
val x = "ABC"
x~repeat(5)
@dflemstr
dflemstr / fibonacci.asm
Created November 22, 2011 20:54
INDA11 HT9
; Produces the fibonacci series in memory.
;.rodata
word count 11
;.data
word result0 1
word result1 1
word result 0
;let:
@dflemstr
dflemstr / test-compressed.css
Created January 4, 2012 07:17
Example of a difficult-to-parse CSS file
@import url("test.css");@import url("test2.css");@import url("test3.css");@import url("te st4.css");@media print,screen{a{}}@font-face{bla:"foo";}@media all and (min-width:500px){}@page {}@page :right{margin-left:4cm;margin-right:3cm;}*{margin:1em;}a{}a,li,em{border-radius:1px/2px;}a[rel]{}a[rel="youtube"]{}a[lang~="en"]{}a[b^="c"]{}a[b$="c"]{}a[b|="en"]{}.codesample[data-summary="helloWorld(){}"]{}svg|circle{}svg|circle[svg|class="bla"]{}a:root{}a:nth-child(12){}a:nth-child(2n + 3){}::f{}*::e(2){}a.bla{}a#b{}a:not(.b){}a:not(c.d > e[f|='g']){a:b;}a b c{}a.b c[d="e"] f#g .h>i~j.k+l [m="n"]{}.cl{i:url("../../images/close-map.png");j:no-repeat;k:0px 0px;}*{bla:gradient(more-gradient(3px solid red #000),rgb(122,233,355),"something with a } in it;");}
@dflemstr
dflemstr / template.tex
Last active December 24, 2015 21:39
Mitt template för formella dokument med pseudokod (Kompilera med `xelatex`, inte `latex`)
% Byt pappersstorlek och fontstorlek
\documentclass[a4paper,10pt]{article}
% Så att man kan skriva ä istället för typ \"a
\usepackage{xunicode}
% Bra grejer
\usepackage{xltxtra}
% Gör så att automatiska ordbrytningar blir svenska istället för engelska, t.ex. "mo-rot" istället för "mor-ot"
@dflemstr
dflemstr / fibonacci.hs
Created October 18, 2013 12:08
Fast fibonacci algorithm
module Main (main) where
import System.Environment (getArgs)
-- | Matrix multiplication
(×) :: Num a => (a, a, a, a) -> (a, a, a, a) -> (a, a, a, a)
(a11, a12, a21, a22) × (b11, b12, b21, b22) =
(a11 * b11 + a12 * b21, a11 * b12 + a12 * b22,
a21 * b11 + a22 * b21, a21 * b12 + a22 * b22)
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate quick_error;
quick_error! {
#[derive(Debug)]
pub enum ForeignA {
Foo {
description("foo")