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
import Control.Monad (guard) | |
import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT) | |
import Control.Monad.Error | |
import Data.Char | |
readBoth :: IO (Maybe String) | |
readBoth = runMaybeT $ do a <- funA2 | |
funB2 a | |
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
/** | |
* This function generates elements of lookup tables. It is assumed that we | |
* have two dimensional lookup tables with x and y axis each ranging from 0 | |
* to n (exclusive). For n, this means there are n^n^n possible | |
* permutations. <br /> | |
* Example table (n = 3, perm = 1) | |
* | |
* <pre> | |
* y | |
* 0 1 2 |
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
public static void main(String[] args) { | |
int n = 3; | |
int elems = (int) Math.pow(Math.pow(n, n), n); | |
Set<String> perms = new HashSet<String>(elems); | |
for(int perm = 0; perm < elems; perm++) { | |
String num = ""; | |
for (int x = 0; x < 3; x++) { | |
for (int y = 0; y < 3; y++) { | |
num = SmartMapper.lookup(x, y, perm, n) + num; | |
} |
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
#!/bin/sh | |
# | |
SEARCH_DIRS="application/ library/COP/" | |
declare -a names=("Zend_Debug" "var_dump" "die(") | |
for UNWANTED_CONTENT in "${names[@]}" | |
do | |
if git grep $UNWANTED_CONTENT $SEARCH_DIRS > /dev/null 2>&1 | |
then |
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
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <mqueue.h> | |
#include <pthread.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <assert.h> | |
#include <errno.h> |
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
-- contrived from the example in the cryptocipher API | |
module Main where | |
import Crypto.Cipher | |
import qualified Data.ByteString as BS | |
import qualified Data.ByteString.Char8 as CBS | |
main = do | |
let ctx = initAES256 key |
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
{-# LANGUAGE RecordWildCards #-} | |
import Control.Arrow (second) | |
import Control.Applicative ((<$>), (<*>)) | |
import Data.List (groupBy, genericLength) | |
import System.Console.GetOpt (ArgDescr(..), ArgOrder(..)) | |
import System.Console.GetOpt (OptDescr(..), getOpt, usageInfo) | |
import System.IO (hPutStrLn, stderr) | |
import System.Environment (getArgs) | |
import System.Exit (exitFailure) |
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 | |
// droid is coming from testnow.php | |
// all this app can do. corresponding functions are | |
// named do_XXX where XXX is the action | |
$actions = array('create', 'list', 'done', 'exit'); | |
// database as array. read when started, saved on exit. | |
$data = null; |
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
/** | |
* Provides Messages implicit and the default Guice-Container | |
* into the context for testing Play 2.4 applications. | |
* | |
* Sample: | |
* | |
* "use the overridden bindigs" in new WithFancyApp( | |
* lang = Lang("en", "US"), | |
* overrideModules = Seq(bind[MyInterface].to[MyImplementation]) | |
* ) { |
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
import java.util.concurrent.TimeUnit | |
import scala.concurrent.duration.Duration | |
import scala.concurrent.{Await, Future} | |
/** | |
* Test if Futures are cancelled once the duration of | |
* the await has timed out. | |
* | |
* This demonstrates, that even after the 'Await.result' |
OlderNewer