Skip to content

Instantly share code, notes, and snippets.

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

Alexander Bondarenko dpwiz

👁️‍🗨️
🌈
View GitHub Profile
@dpwiz
dpwiz / haskell.nanorc
Last active August 29, 2015 14:02
DIY Haskell IDE
## include "/path/to/haskell.nanorc"
syntax "haskell" "\.hs$"
color green "(\||@|!|:|_|~|=|\\|;|\(|\)|,)"
color magenta "(True|False|==|/=|&&|\|\||<|>|<=|>=)"
color green "(->|<-|!)"
color red "[\n\t](as|case|of|class|data|default|deriving|do|forall|foreign|hiding|if|then|else|import|infix|infixl|infixr|instance|let|in|mdo|module|newtype|qualified|type|where)[ \n\t]"
color brightblue "'.'"
color brightblue "'\\[ntfr]'"
color brightblue ""[^\"]*""
@dpwiz
dpwiz / README
Last active August 29, 2015 14:02
rest-* documentation builder
The script utilizes `cabal sandbox` to keep the guts from spilling into system packages.
The documentation builder is `standalone-haddock`[1] so you have to install it and put on your PATH first. A `hscolour` have to be installed to provide source links.
[1]: https://hackage.haskell.org/package/standalone-haddock
[2]: https://hackage.haskell.org/package/hscolour
@dpwiz
dpwiz / watch.sh
Created June 6, 2014 14:33
cabal build --watch --exec
while true; do
clear && cabal build && $@
inotifywait -qq -e modify -r src/ *.cabal
done
@dpwiz
dpwiz / Hedis.hs
Last active August 29, 2015 14:01
Scotty application skeleton
module Hedis
(
-- * Application classes
HasRedis(..)
-- * App-wrapped redis runner
, redis
-- * Re-export other stuff from "Database.Redis"
, module R
) where
{-# LANGUAGE TemplateHaskell #-}
module CNth where
import Language.Haskell.TH
import Data.List
cnth :: Int -> Q Exp
cnth n = dotE qs
where
qs = head . reverse . take n . drop 1 $ ads
@dpwiz
dpwiz / test.txt
Last active December 18, 2015 18:29
http://www.reddit.com/r/programming/
lol
Юникод лол, смотрите, ЮНИКОД!
@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 / 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 / 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 / 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}