Skip to content

Instantly share code, notes, and snippets.

View onlyshk's full-sized avatar

Kuleshov Alexander onlyshk

View GitHub Profile
erl -boot start_sasl
Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:8:8] [rq:8] [async-threads:0] [kernel-poll:false]
=PROGRESS REPORT==== 3-Feb-2012::06:18:01 ===
supervisor: {local,sasl_safe_sup}
started: [{pid,<0.35.0>},
{name,alarm_handler},
{mfargs,{alarm_handler,start_link,[]}},
{restart_type,permanent},
dhclient eth0
route add default gw 192.168.1.1
=CRASH REPORT==== 28-Dec-2011::08:05:03 ===
crasher:
initial call: ejabberd_http:init/2
pid: <0.360.0>
registered_name: []
exception exit: {aborted,
{no_exists,
[reg_users_counter,
[{{reg_users_counter,"localhost",'$1'},
[],
@onlyshk
onlyshk / gist:1523833
Created December 27, 2011 14:37
exmpp build error
$ make
(CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash /home/exmpp/ac-aux/missing --run autoheader)
rm -f stamp-h1
touch config.h.in
cd . && /bin/bash ./config.status config.h
config.status: creating config.h
config.status: config.h is unchanged
make all-recursive
make[1]: Entering directory `/home/exmpp'
@onlyshk
onlyshk / gist:1455279
Created December 10, 2011 14:22
Json encoding
{-# LANGUAGE OverloadedStrings #-}
module Test where
import Data.Aeson
import Data.ByteString.Lazy.Char8 as B
data Auto = Auto {firm :: String, year :: Int, price :: Int, sellers :: [String]}
deriving (Show)
instance ToJSON Auto where
toJSON (Auto firm year price sellers) = object [ "firm" .= firm,
"year" .= year,
"price" .= price,
"sellers" .= sellers
]
@onlyshk
onlyshk / gist:1455234
Created December 10, 2011 14:02
Auto data type
data Auto = Auto {firm :: String, year :: Int, price :: Int, sellers :: [String]}
deriving (Show)
@onlyshk
onlyshk / gist:1455218
Created December 10, 2011 13:54
JSON data
{
"firm":"Firm1",
"year":2000,
"price":8000,
"sellers":[
"Firm1",
"Firm2,
"Firm3"
]
}
@onlyshk
onlyshk / gist:1441866
Created December 7, 2011 07:29
MonadTrans lifting
class MonadTrans t where
lift :: Monad m => m a -> t m a -- lifts a value from the inner monad m to the transformed monad t m
-- could be called lift0
@onlyshk
onlyshk / gist:1441857
Created December 7, 2011 07:27
Liftable
{-# OPTIONS -fglasgow-exts #-}
{-# LANGUAGE AllowUndecidableInstances #-}
import Control.Monad
instance (Functor m, Monad m) => Liftable m where
zipL = liftM2 (\x y -> (x,y))
zeroL = return ()