Skip to content

Instantly share code, notes, and snippets.

@cheecheeo
cheecheeo / rabbitmqbrowse.hs
Created December 28, 2011 23:14
RabbitMQ Browsing
{-
- Read n messages from a queue and then put them back on the queue:
- rabbitmqbrowse <hostname> <queue_name> <count_of_messages_to_read>
- Example usage:
- runhaskell rabbitmqbrowse.hs localhost my_queue 3
-
- cabal install network amqp
-}
import qualified System.Environment as Env
@cheecheeo
cheecheeo / arc-push
Created January 20, 2012 01:45
arcanist+git pushing and cleanup
#!/bin/bash -x
# Assuming you're using the 'mutable history' workflow (rebases everywhere),
# run this script from a branch that's been accepted in Differential to
# 'arc amend' the branch, rebase the code onto master, push up the changes,
# and delete the branch.
current_branch=$(git name-rev --name-only HEAD)
git fetch && git checkout master && git pull -r &&
git checkout $current_branch &&
@cheecheeo
cheecheeo / bean_dump.sh
Created March 14, 2012 19:46
JMX MBean dumper
#!/bin/bash
function usage() {
cat <<USAGE
usage: $0 options
Dump all beans (and values) from a JMX server.
OPTIONS:
-h Show this message
@cheecheeo
cheecheeo / cassandra_maintainence.sh
Created June 8, 2012 18:45
Manual Cassandra compaction
#!/bin/bash
# Usage:
# ./cassandra_maintenance.sh
# or
# CASSANDRA_HOME=/path/to/cassandra ./cassandra_maintenance.sh
# Some useful logging commands:
#nodetool -h localhost compactionstats
#while true; do date | perl -pe 's/\n/ /g' >> /tmp/cassandra.log 2>&1 && nodetool -h localhost compactionstats >> /tmp/cassandra.log 2>&1 && sleep 10s; done &
@cheecheeo
cheecheeo / allpaths.hs
Created June 26, 2012 01:54
All paths
module Main where
-- | All paths from the first row down
--
-- >>> allPaths [[4,5]]
-- [[4],[5]]
-- >>> allPaths [[3], [4, 5]]
-- [[3,4],[3,5]]
-- >>> allPaths [[1,2], [3], [4,5]]
-- [[1,3,4],[1,3,5],[2,3,4],[2,3,5]]
@cheecheeo
cheecheeo / rats.hs
Created August 17, 2012 23:44
Rationals in Haskell
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
module Main where
import Data.Ratio
import Data.List
import Data.Maybe
import Data.Tuple
@cheecheeo
cheecheeo / SafeLists.hs
Last active October 9, 2015 05:17
Safe lists in Haskell
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}
module SafeList where
data Nat :: * where
Z :: Nat
S :: Nat -> Nat
@cheecheeo
cheecheeo / applicativeSudoku.hs
Created December 6, 2012 22:53
Applicative functors exercise
{-# LANGUAGE TypeOperators, ScopedTypeVariables #-}
-- http://stackoverflow.com/questions/10239630/where-to-find-programming-exercises-for-applicative-functors
-- http://stackoverflow.com/a/10242673/1019205
import Control.Applicative (Applicative, pure, (<$>), (<*>))
import Data.Foldable (Foldable, foldMap)
import Data.Traversable (Traversable, sequenceA)
import Data.Monoid ((<>))
data Triple a =
@cheecheeo
cheecheeo / parallelStreams.hs
Created December 6, 2012 22:55
Infinite lists and parallelism in Haskell
module Main where
import qualified Data.List as L
import qualified System.Random as R
import qualified Data.Numbers.Primes as P
import Control.Parallel.Strategies (NFData, ($||))
import qualified Control.Parallel.Strategies as S
#!/bin/bash -x
# Based on: https://coderwall.com/p/vqp_yw and
# http://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python
sudo apt-get install rubygems1.8
cd $@
python -m SimpleHTTPServer