Skip to content

Instantly share code, notes, and snippets.

View dpwiz's full-sized avatar
👁️‍🗨️
🌈

Alexander Bondarenko dpwiz

👁️‍🗨️
🌈
View GitHub Profile
@dpwiz
dpwiz / twitsearch.hs
Last active April 11, 2017 09:23
Haskell version of http://eax.me/scala/
import Data.Aeson
import Network.HTTP
import System.Environment (getArgs)
import Control.Monad (mapM_)
import Data.Maybe (fromMaybe)
import qualified Data.ByteString.Lazy.Char8 as LBS
import qualified Data.Text as T
import qualified Data.HashMap.Strict as HM
@dpwiz
dpwiz / scotty-amqp.hs
Created February 28, 2013 08:32
Auto-recovering AMQP session using Data.Pool from resource-pool package.
{-# LANGUAGE OverloadedStrings #-}
import Web.Scotty
import Network.AMQP
import Control.Monad.Trans (liftIO)
import qualified Control.Exception as E
import qualified Data.Text.Lazy as TL
import qualified Data.ByteString.Lazy.Char8 as LBS
@dpwiz
dpwiz / gist:5004655
Last active December 14, 2015 01:18
-- | Little helper to apply default service namespace to a node and it's descendants.
-- This removes the necessity to flood your code with {http://vendor.silly.web/Service.spamx} in element names.
flowNS :: Maybe Text -> Node -> Node
flowNS ns (NodeElement (Element (Name local Nothing prefix) as cs)) = NodeElement $ Element (Name local ns prefix) as $ map (flowNS ns) cs -- update element ns and continue
flowNS ns (NodeElement (Element name@(Name _ ns' _) as cs)) = NodeElement $ Element name as $ map (flowNS ns') cs -- switch to new namespace and continue
flowNS ns node = node -- ignore non-element nodes
@dpwiz
dpwiz / gist:4373333
Created December 25, 2012 13:49
Сортировка по говну, отдельно от палок.
fias=> SELECT housenum FROM house ORDER BY substring(housenum FROM '\d+')::int, housenum;
housenum
----------
1/1
2
3
@dpwiz
dpwiz / fix-fias.json
Created December 9, 2012 10:52
Импорт DBF ФИАС в PostgreSQL
{
"actstat": {
"convert": {
"actstatid": "int"
}
},
"addrobj": {
"null": [
"actstat",
"nextid",
#!../venv/bin/python
import pika, pprint, json
import time
import logging
logging.basicConfig()
def jsonlog(channel, method_frame, header_frame, body):
msg = json.loads(body)
import Graphics.UI.Gtk
main :: IO ()
main = do
initGUI
window <- windowNew
button <- buttonNew
set window [ containerBorderWidth := 10
, containerChild := button ]
set button [ buttonLabel := "Hello World" ]
@dpwiz
dpwiz / gist:4148047
Last active October 13, 2015 05:38
haskell.sublime-project
{
"folders":
[
{
"path": "",
"folder_exclude_patterns": ["cabal-dev", "dist"]
}
],
"build_systems":
[
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{42}
\author{Jane Doe}
\date{June 2011}
\usepackage{natbib}
\usepackage{graphicx}
-- * Stuff
import Database.SQL (connectDB, dbquery)
import Database.Cache (cacheGet, cacheSet)
import Network.SOAP (soap)
import Control.Monad (guard)
type Oven = String
type Product = String