Skip to content

Instantly share code, notes, and snippets.

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

Alexander Bondarenko dpwiz

👁️‍🗨️
🌈
View GitHub Profile
@dpwiz
dpwiz / fix-fias.json
Created December 9, 2012 10:52
Импорт DBF ФИАС в PostgreSQL
{
"actstat": {
"convert": {
"actstatid": "int"
}
},
"addrobj": {
"null": [
"actstat",
"nextid",
@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 / 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 / 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 / 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 / base.tex
Last active August 7, 2017 18:50
Render LaTeX code generated with Django templates to a PDF response.
\documentclass[a4paper]{article}
% Cyrillic support
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,russian]{babel}
\DeclareSymbolFont{T2Aletters}{T2A}{cmr}{m}{it}
% PDF search & cut'n'paste
\usepackage{cmap}
@dpwiz
dpwiz / scrape_li.py
Created March 27, 2013 06:06
http://eax.me/scala-regular-expr/ -- RE and HTML just don't match!
>>> scrape("eax.me")[:5]
[['books-issue-2/', '33', '9.2%', '148', '8.5%', '0', '0.0%', '102', '6.4%'],
['/', '24', '6.7%', '121', '6.9%', '108', '6.2%', '108', '6.8%'],
['goodbye-freebsd/', '23', '6.4%', '115', '6.6%', '25', '1.4%', '136', '8.6%'],
['books-issue-1/', '23', '6.4%', '78', '4.5%', '58', '3.3%', '84', '5.3%'],
['scala-regular-expr/', '16', '4.5%', '3', '0.2%', '0', '0.0%', '1.6', '0.1%']]
@dpwiz
dpwiz / Main.hs
Last active December 15, 2015 12:39
http-conduit with client certificate example
module Main where
import Network.TLS (PrivateKey)
import Network.TLS.Extra as TLS
import Network.HTTP.Conduit
import Data.Certificate.X509 (X509)
import qualified Data.ByteString.Lazy.Char8 as LBS
import System.Environment (getArgs)
@dpwiz
dpwiz / controllers.js
Last active May 7, 2016 23:10
AngularJS + WebSocket + JSON RPC 2.0
function WSTestCtrl($scope, ws) {
$scope.method = 'ping'
$scope.params = '[]'
$scope.reply = 'None yet.'
$scope.reply_class = 'info'
$scope.go = function(){
ws.call($scope.method, JSON.parse($scope.params)).then(function(d){
$scope.reply = JSON.stringify(d)
@dpwiz
dpwiz / test.txt
Last active December 18, 2015 18:29
http://www.reddit.com/r/programming/
lol
Юникод лол, смотрите, ЮНИКОД!