Skip to content

Instantly share code, notes, and snippets.

View AlexeyRaga's full-sized avatar

Alexey Raga AlexeyRaga

  • Arbor Networks
  • Sydney, Australia
View GitHub Profile
@AlexeyRaga
AlexeyRaga / cabal.nix
Created August 8, 2018 13:01 — forked from codebje/cabal.nix
Build a multi-project Cabal application with Nix
with builtins; rec {
cabalProjects = listToAttrs (if pathExists ./cabal.project
then projectParse
else [ { name = baseNameOf ./.; value = ./.; } ] );
projectParse = let
contents = readFile ./cabal.project;
trimmed = replaceStrings ["packages:" " "] ["" ""] contents;
packages = filter (x: isString x && x != "") (split "\n" trimmed);
package = p: substring 0 (stringLength p - 1) p;
paths = map (p: let p' = package p; in { name = p'; value = toPath (./. + "/${p'}"); } ) packages;
@AlexeyRaga
AlexeyRaga / Main.hs
Created September 9, 2017 20:35 — forked from rahulmutt/Main.hs
Fast coproducts for Haskell & Eta
#!/usr/bin/env stack
{- stack
--resolver lts-6.27
--install-ghc
runghc
--package containers
-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
@AlexeyRaga
AlexeyRaga / SimpleEchoServer.hs
Created May 30, 2017 10:52 — forked from rhwlo/SimpleEchoServer.hs
simple echo server in Haskell
import GHC.IO.Handle (Handle, hGetLine)
import GHC.IO.Handle.FD (stdout)
import Network
import Text.Printf
main :: IO ()
main = withSocketsDo $ do
listenSock <- listenOn $ PortNumber 9999
(listenHandle, clientHost, clientPort) <- accept listenSock
@AlexeyRaga
AlexeyRaga / gist:0e422563dcafa6282133
Created September 27, 2015 11:43 — forked from nikita-volkov/gist:6977841
Anonymous records. A solution to the problems of record-system.

#Anonymous records. A solution to the problems of record-system.

Please, beware that the proposal that follows has been implemented as a library.

The current record system is notorious for three major flaws:

  1. It does not solve the namespacing problem. I.e., you cannot have two records sharing field names in a single module. E.g., the following won't compile:

data A = A { field :: String }

<RaceCondition> can I use Scalaz to get exhaustion checks when matching on numeric values? Scala obviously doesn't do that
<RaceCondition> ! 1.1 match { case x if 0.0 <= x && x < 0.5 => "bad"; case x if 0.5 <= x && x <= 1.0 => "good" }
<dibblego> doubt it
<multibot_> scala.MatchError: 1.1 (of class java.lang.Double)
<multibot_> ... 38 elided
<dibblego> use types though?
<RaceCondition> wdym?
<dibblego> use a type to note each range
<dibblego> you want a floating-point between 0.0 and 1.0?
<RaceCondition> wouldn't that just move the problem to a different stage?
--- srclib/stdio.in.h.orig 2011-08-07 16:42:06.000000000 +0300
+++ srclib/stdio.in.h 2013-01-10 15:53:03.000000000 +0200
@@ -695,7 +695,9 @@
/* It is very rare that the developer ever has full control of stdin,
so any use of gets warrants an unconditional warning. Assume it is
always declared, since it is required by C89. */
-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+#endif
{-# LANGUAGE TypeFamilies #-}
import Data.Function (on)
import Control.Applicative
data EventData e = EventData {
eventId :: Int,
body :: Event e
}
namespace Topshelf
[<AutoOpen>]
module Topshelf =
open System
open Topshelf.HostConfigurators
open Topshelf.Runtime
let configureTopShelf f =

Tuning Storm+Trident

Tuning a dataflow system is easy:

The First Rule of Dataflow Tuning:
* Ensure each stage is always ready to accept records, and
* Deliver each processed record promptly to its destination

Better Git log

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

create an alias git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

git lg

git lg -p