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
graphFromFile :: String -> IO (Graph String) | |
graphFromFile f = do | |
contents <- readFile f | |
let info = map words $ lines contents | |
verts = nub . concat $ info | |
conns = map (\[a, b] -> (a, b)) info | |
graph = Graph verts conns | |
return graph |
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 | |
/* | |
* Get all 52 weeks of the year and work days given the first day of the January of current year | |
* @link http://stackoverflow.com/a/14147613/367456 | |
* @author hakre <http://hakre.wordpress.com/credits> | |
*/ | |
/** | |
* Filter a DatePeriod by year | |
*/ |
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
// This program is an example of how to run a command such as | |
// ps aux | grep root | grep sbin | |
// using C and Unix. | |
#include <stdlib.h> | |
#include <unistd.h> | |
int pid; | |
int pipe1[2]; | |
int pipe2[2]; |
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 (unfoldr, minimumBy) | |
import Data.Char (isSpace) | |
import Data.Function (on) | |
import Data.Maybe (mapMaybe, fromMaybe) | |
import System.Environment (getArgs) | |
import qualified Data.ByteString.Char8 as L | |
import qualified Data.IntMap as IM | |
type GraphData = (IM.IntMap (IM.IntMap [(Int, Int)]), Int) |
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
module GraphsAlgs | |
where | |
import List | |
import While | |
import Assert | |
import Reasoning (update,updates) | |
reachable :: Eq a => [(a,a)] -> a -> [a] |
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
SELECT * | |
FROM SOME_TABLE_ONE STO | |
WHERE EXISTS ( | |
SELECT * | |
FROM SOME_TABLE_TWO STT | |
WHERE STO.STT_ID = STT.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
<?php | |
/** | |
* Caching to filesystem using ZendCache | |
* Cache as much as possible, very convenient for dev (default ttl = 3600) | |
*/ | |
use Guzzle\Http\Client; | |
use Guzzle\Plugin\Cache\CachePlugin; | |
use Guzzle\Plugin\Cache\SkipRevalidation; | |
use Guzzle\Plugin\Cache\DefaultCacheStorage; |
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
$header = "..."; | |
$parsed = array_map(function($x) { return array_map("trim", explode(":", $x, 2)); },array_filter(array_map("trim", explode("\n", $header)))); |
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 | |
class KeyError extends Exception {}; | |
function filter_tree($tree, $fields) { | |
if (empty($fields)) | |
{ | |
return $tree; | |
} | |
$result = array(); |
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 NoMonomorphismRestriction #-} | |
import Text.ParserCombinators.Parsec | |
import Text.ParserCombinators.Parsec.Token hiding (parens) | |
import Text.ParserCombinators.Parsec.Expr | |
import Control.Applicative hiding ((<|>)) | |
import Control.Monad | |
import Prelude hiding (not) | |
data Expr = Not Expr | And Expr Expr | Or Expr Expr | Var Char | SubExpr Expr deriving Eq |