Skip to content

Instantly share code, notes, and snippets.

View folsen's full-sized avatar

Fredrik Harrysson folsen

View GitHub Profile
@folsen
folsen / Main.hs
Created March 1, 2013 14:21
JSON backend using Happstack
{-# LANGUAGE DeriveDataTypeable, OverloadedStrings #-}
module Main where
import qualified Data.ByteString.Lazy.Char8 as L
import Control.Monad.IO.Class (liftIO)
import Control.Monad (msum, mzero)
import Data.Data (Data, Typeable)
import Data.Maybe (fromJust)
import Data.Aeson
@folsen
folsen / gist:1252103
Created September 29, 2011 22:21
Plotting password strength
% Word passwords
w = @(x) 20000.^x;
% Letter passwords (big and small letters a-Z)
l = @(x) 54.^x;
% Alphanumeric passwords (0-9 a-Z and !"#€%&/()=?_-)
an = @(x) 77.^x;
X = 0:20;
semilogy(X,w(X),'b',X,l(X),'r',X,an(X),'k')
@folsen
folsen / gist:835233
Created February 19, 2011 18:08
test.tex.fleet
\documentclass[12pt]{article}
\usepackage{amsmath}
\title{\LaTeX}
\date{}
\begin{document}
\maketitle
\LaTeX{} is a document preparation system for the \TeX{}
typesetting program. It offers programmable desktop publishing
features and extensive facilities for automating most aspects of
typesetting and desktop publishing, including numbering and
@folsen
folsen / TeXTemplate.clj
Created February 19, 2011 18:01
TeXTemplate
(ns textemplate.core
(:use fleet))
(spit "output/test.tex" ((fleet [number] (slurp "test.tex.fleet")) 25))
(.. Runtime (getRuntime) (exec "pdflatex --output-directory=output output/test.tex"))
@folsen
folsen / svd.rb
Created December 27, 2010 18:14
A word-problem game from a swedish newspaper solved in very poor (old) ruby code.
def init_wordlist()
@wordlist = {}
file = File.new("sv_SE.dic", "r")
while content = file.gets
@wordlist[content.split("/")[0]] = 1
end
file.close
end
@folsen
folsen / svd.clj
Created December 27, 2010 18:12
A word-problem game from a swedish newpaper solved in clojure
(ns svd.core
(:use
clojure.contrib.combinatorics)
(:require
[clojure.contrib.duck-streams :as ds]
[clojure.contrib.str-utils :as str]))
(defn wordlist []
(set (map #(re-find #"[^/]*" %) (ds/read-lines "sv_se.dic"))))
function [coords, dof, ndof, edof, nelm, ex, ey] = geometry(gridsize)
if nargin==0
gridsize = 5;
end
b12 = @(y) .120 - y;
b16 = @(y) y - .020;
coords = [];
for y = 0:gridsize:.070;
for x = 0:gridsize:.100;
if(y < .010)
<div class="year-archive">
<h2>2006</h2>
<ul>
<?php wp_get_archives('year=2006&show_post_count=true'); ?>
</ul>
</div>
<div class="year-archive">
<h2>2007</h2>
<ul>
<?php wp_get_archives('year=2007&show_post_count=true'); ?>
function supportsBoxShadow() {
var s = document.body.style;
return s.WebkitBoxShadow !== undefined || s.MozBoxShadow !== undefined || s.boxShadow !== undefined;
}
function frame_pictures(){
// Exit if we don't have boxshadow support at all and fall back on wp-caption
if(!supportsBoxShadow()) return;
function unew = burger(u,d,dt,bdry)
N = length(u);
dx = 1/(N);
sup = d*dt/dx^2;
main = 1*ones(N,1)-u*dt/dx-2*d*dt/dx^2*ones(N,1);