Skip to content

Instantly share code, notes, and snippets.

@dmjio
dmjio / gist:330f02e2279446f4b4bf
Last active Aug 28, 2015 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis
View gist:330f02e2279446f4b4bf
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
View SearchAlgos.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace algos
{
class MainClass
{
public static void Main (string[] args)
@dmjio
dmjio / Base36.hs
Last active Aug 29, 2015
Base 36 number system
View Base36.hs
{-# LANGUAGE FlexibleInstances #-}
import Control.Monad (liftM4)
import Data.Maybe
data Nums = Zero | One | Two | Three | Four | Five | Six | Seven | Eight
| Nine | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O
| P | Q | R | S | T | U | V | W | X | Y | Z deriving (Ord, Eq, Enum)
type GUID = (Nums, Nums, Nums, Nums)
@dmjio
dmjio / pali.hs
Created Feb 27, 2014
parallel longest palindrome checker
View pali.hs
import Control.Parallel.Strategies
import Data.List (maximumBy, subsequences)
import Data.Ord
isPalindrome :: Eq a => [a] -> Bool
isPalindrome xs = xs == reverse xs
-- * note while subsequences is correct, it is asymptotically
-- inefficient due to nested foldr calls
@dmjio
dmjio / gist:9296317
Created Mar 1, 2014
cabal hell salvation
View gist:9296317
resourcet-0.4.9 blaze-builder-0.3.3.0 http-conduit-2.0.0.4 http-client-tls-0.2.1.1 http-client-conduit-0.2.0.1 http-client-0.2.2.2 cookie-0.4.0.1 aeson-0.6.2.1 http-types-0.8.3 conduit-1.0.9.3
@dmjio
dmjio / facCheck.hs
Created Mar 8, 2014
QuickCheck test
View facCheck.hs
import Test.QuickCheck
fac :: Integer -> Integer
fac n | n < 1 = 1
| otherwise = n * fac (n - 1)
greaterThan0 :: Integer -> Bool
greaterThan0 n = not $ (fac n) < 1
main :: IO ()
@dmjio
dmjio / gist:9712416
Last active Aug 29, 2015
installing under windows
View gist:9712416
cabal sandbox init (from msdos prompt)
cabal install text-1.1.0.1
cabal install network-2.4.1.2 --configure-option -host=i386-unknown-mingw32
cabal install HsOpenSSL --extra-include-dirs=\"C:/OpenSSL-Win32/include\" --extra-lib-dirs=\"C:/OpenSSL-Win32/\"
cabal install -j
cabal configure
cabal build worker
@dmjio
dmjio / networkinst.sh
Created Mar 24, 2014
ghc network on windows
View networkinst.sh
WHICHGHC=`which ghc` && PATH=`dirname $WHICHGHC`/../mingw/bin:$PATH &&
cabal install network --configure-option --host=i386-unknown-mingw32 --global --enable-library-profiling
@dmjio
dmjio / gist:9774983
Created Mar 26, 2014
"cabal install HsOpenSSL --extra-include-dirs=\"C:/OpenSSL-Win32/include\" --extra-lib-dirs=\"C:/OpenSSL-Win32/\"
@dmjio
dmjio / gist:9774995
Last active Aug 29, 2015
boo hsopenssl
View gist:9774995
Loading package HsOpenSSL-0.10.4 ... <command line>: can't load .so/.DLL for: eay32.dll (addDLL: could not load DLL) ghc.exe: eay32: The application has failed to start because its side-by-side configuration is incorrect. Please see the applica tion event log or use the command-line sxstrace.exe tool for more detail. cabal.exe: Error: some packages failed to install: