This file contains 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
module MagicDot ((.)) where | |
import Prelude hiding ((.)) | |
import Control.Monad.Instances | |
(.) :: (Functor f) => (a -> b) -> f a -> f b | |
a . b = a `fmap` b | |
infixr 9 . |
This file contains 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
module Ternary where | |
-- | Ternary operator. | |
-- Usage: (i > 0) ? i $ 1 | |
(?) :: Bool -> a -> a -> a | |
True ? x = const x | |
False ? _ = id | |
-- | Higher order ternary operator. | |
-- Usage: (not . null) ?? "" $ "default" |
This file contains 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
#!/usr/bin/env php | |
<?php | |
// Konfiguration | |
$dir = NULL; // Mapp du vill räkna rader ur | |
$verbose = TRUE; // visa antal rader för varje fil | |
/* Arbetande kod | |
-------------------------------------------------------------------------*/ | |
$path = isset($argv[1]) ? $argv[1] : (is_null($dir) ? '.' : $dir); | |
$path = realpath($path); |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Self-expanding textarea</title> | |
</head> | |
<body> | |
<textarea id="expand" rows="8" cols="40"></textarea> | |
<script type="text/javascript" charset="utf-8"> | |
var textarea = document.getElementById('expand') | |
var div = document.createElement('div') |
This file contains 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
ack -l -Q 'gpl-3.0.txt' | xargs sed -i .bak 's#http://www.gnu.org/licenses/gpl-3.0.txt#http://sam.zoy.org/wtfpl/#g' |
This file contains 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 | |
require 'html.php'; | |
// Lite variabler | |
$page = isset($_GET['start']) ? max((int)$_GET['start'], 1) : 1; // nuvarande sida | |
$items_per_page = 25; // antal saker per sida | |
$total_items = 10000; // antal saker (totalt), fås troligtvis från en “SELECT COUNT(*) FROM …” query | |
$paging = paging($page, ceil($total_items / $items_per_page), 3); | |
// Paging innehåller nu all HTML som behövs för din paging, skriv ut den på rätt plats |
This file contains 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
-----BEGIN PGP PUBLIC KEY BLOCK----- | |
mQGiBEuLwZMRBACm0cVIw+vNU5ny8nBy28D6IVOJCm5YVAhyuISZLCmKs2u0zPkn | |
+35TKhjTBo0w9wflYa/nFfQjY3N6V9zVOCbDSlEfFwo+rSS0xAGYpu0y6r0R9FvK | |
h5LjAGIG+thFLYD9LJgRjuewlCu5bTJxznmzGV4Btq3p3uJPPA5CjAj9YwCgyyuA | |
uDOHvaRkJ/h6dIUjoyaGHjUEAIW0FyR4mrBpwBWUPWH8OyNWaf8C91ZspkRXABE7 | |
t2R1YHJz2Gbk6dhIpfSlkBPS80rWtbCZIPLbEImAWkkmLtsoiHkdLI9DEZ2XIP6q | |
SBCk6xCeJMLcBGfazbma7ADb5vi9V1tiurvWPBOVDPOUFRjU6JqYuOMK+tuDWHJN | |
UDNDA/9lKIInAYaL7NR+p2KTYbM3qv9Zcw059T/htbEwIFZ4Mywgl4WK8eZ54PCR | |
1dpr/5LI+nJEnPxCRkgZ+ald5loottS2gZYsVAertrdrON3ohrvxdJEdGw9+qQb9 |
This file contains 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 | |
class View | |
{ | |
private $_file; | |
private $_locals = array(); | |
/** | |
* Skapa en ny View med rätt fil och lokal data | |
* | |
* @param string sökväg till fil |
This file contains 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 | |
class Auth | |
{ | |
protected $_session; | |
protected static $_instance; | |
protected function __construct() | |
{ | |
// Hämta en sessionsinstans | |
$this->_session = Session::instance(); |
This file contains 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 | |
require './model.php'; | |
$model = new Namninsamling; | |
/** | |
* Returnerar det givna indexet ur en array om det finns, annars $default | |
* | |
* @param array | |
* @param mixed $index | |
* @param mixed $default |
OlderNewer