Skip to content

Instantly share code, notes, and snippets.

@dmjio
dmjio / gist:330f02e2279446f4b4bf
Last active August 28, 2015 00:48 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@dmjio
dmjio / SearchAlgos.cs
Created February 5, 2014 07:49
searching
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 August 29, 2015 13:56
Base 36 number system
{-# 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 February 27, 2014 01:34
parallel longest palindrome checker
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 March 1, 2014 20:07
cabal hell salvation
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 March 8, 2014 21:02
QuickCheck test
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 August 29, 2015 13:57
installing under windows
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 March 24, 2014 06:31
ghc network on windows
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 March 26, 2014 01:07
"cabal install HsOpenSSL --extra-include-dirs=\"C:/OpenSSL-Win32/include\" --extra-lib-dirs=\"C:/OpenSSL-Win32/\"
fff
@dmjio
dmjio / gist:9774995
Last active August 29, 2015 13:57
boo hsopenssl
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: