This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Läs in PDF-dokument och konvertera till base64 | |
$pdf = file_get_contents('test.pdf'); | |
$b64 = base64_encode($pdf); | |
// Läs in mail-mall | |
ob_start(); | |
include 'mail-tpl.php'; | |
$mail = ob_get_clean(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pages :: Int -> Int -> [(Int, Int)] | |
pages 1 n = [(1, n)] | |
pages m n = (m, n `div` m) : pages (m `div` 2) (n `mod` m) | |
result :: Int -> [(Int, Int)] | |
result n = pages 16 n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTs, EmptyDataDecls, ExistentialQuantification #-} | |
module RBTree where | |
-- Node color | |
data Red | |
data Black | |
-- Node depth |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List(find) | |
findSum :: Num a => a -> [a] -> Bool | |
findSum s ns = find (sumIs s) (pairs ns) | |
where | |
sumIs :: Num a => a -> (a, a) -> Bool | |
sumIs s (x, y) = x+y == s | |
pairs :: [a] -> [(a, a)] | |
pairs [] = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
firstNonRep :: String -> Maybe Char | |
firstNonRep cs = fmap fst $ find (\(c, n) -> n == 1) $ foldl count [] cs | |
where | |
count [] c = [(c, 1)] | |
count (p@(c', n) : ps) c | c == c' = (c', n+1) : ps | |
| otherwise = p : count ps c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class Loader | |
{ | |
abstract public function load(); | |
} | |
class PaymentLoader extends Loader | |
{ | |
protected $id; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Tree t = EmptyTree | |
| Node t (Tree t) (Tree t) | |
deriving Show | |
nivel :: Int -> Int | |
nivel n = nivel' n 0 | |
where | |
nivel' 0 _ = 0 | |
nivel' 1 x = x | |
nivel' n x = nivel' (n `div` 2) (x + 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Att stödja en regeringen är inte samma sak som att sitta i regeringen. Flyborg påstod att MP var "i regeringsställning", vilket betyder att man verkligen sitter i regeringen. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Recursive version | |
function isMeasurable(target, weights) | |
{ | |
if (weights.length == 0) | |
return target == 0; | |
var first = weights.shift(); | |
return | |
isMeasurable(target-first, weights) || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var M = function() { }; | |
M.prototype = { | |
m : function() { return 42 } | |
}; | |
var inst = new M(); | |
inst.f = function() { return 42 }; |