Skip to content

Instantly share code, notes, and snippets.

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

Alexander Bondarenko dpwiz

👁️‍🗨️
🌈
View GitHub Profile
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module Main where
import Apecs
import Apecs.Physics

Keybase proof

I hereby claim:

  • I am dpwiz on github.
  • I am icrbow (https://keybase.io/icrbow) on keybase.
  • I have a public key whose fingerprint is DB13 7C80 CB83 D703 C813 97C1 47DA E604 896D 2914

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am wiz on github.
  • I am icrbow (https://keybase.io/icrbow) on keybase.
  • I have a public key ASDRadknOBC70474T10SGyu5lcwZ6uN7HsfkBSahuXWErAo

To claim this, I am signing this object:

@dpwiz
dpwiz / RegisterOrHandoff.hs
Last active February 25, 2016 14:01
Check local registry for a process and spawn one if necessary.
import Control.Distributed.Process
import Control.Distributed.Process
spawnLocalOrHandoff :: String -> Process () -> Process ProcessId
spawnLocalOrHandoff regKey proc = do
(pidTo, pidFrom) <- newChan
pid <- spawnLocal $ registerOrHandoff regKey pidTo proc
withMonitor pid $ receiveWait
[ matchChan pidFrom $ either die pure
module Room
( roomProcess
, roomService
-- Client API
, joinRoom
, partRoom
, sendRoom
, listRoom
-- Server API is private
) where

distributed-process-0.6.0

2016-02-18 Facundo Domínguez [email protected] 0.6.0

  • Have nsendRemote skip the transport for local communication.
  • Unsafe primitives for usend and nsendRemote.
  • Stop using the transport for local communication.
  • Skip the transport for whereisRemoteAsync and registerRemoteAsync.
  • Have nsendRemote skip the transport for local communication.
  • Have runProcess forward exceptions.
@dpwiz
dpwiz / hostname.conf
Last active January 30, 2016 07:12
nginx multihost http2 config with a+ rating
server {
listen 80;
server_name hostname.tld *.hostname.tld;
location / {
return 301 https://$host$request_uri;
}
location /.well-known/acme-challenge {
root /ext/www/public_html/le-challenge;
@dpwiz
dpwiz / dumpdata.sh
Last active June 2, 2016 06:43
dump django data for later loading into empty db (e.g. server migration)
./manage.py dumpdata --exclude=auth.permission --exclude=contenttypes --exclude sessions --exclude admin --natural-foreign --indent=2 | xz -9 > dump-`date +%Y%m%d`.json.xz
@dpwiz
dpwiz / FiraCode-caret.sh
Created November 16, 2015 13:03
Patch FiraCode back into Caret after updates.
cp ~/Downloads/FiraCode-Regular.ttf ~/Extensions/fljalecfjciodhpcledpamjachpmelml/*/css/
cp ~/Extensions/fljalecfjciodhpcledpamjachpmelml/*/css/caret-dark.css /tmp/caret-dark.css
echo '
@font-face {
font-family: FiraCode;
src: url(FiraCode-Regular.ttf);
}
' > ~/Extensions/fljalecfjciodhpcledpamjachpmelml/*/css/caret-dark.css
cat /tmp/caret-dark.css >> ~/Extensions/fljalecfjciodhpcledpamjachpmelml/*/css/caret-dark.css
# via: http://blog.codinghorror.com/sorting-for-humans-natural-sort-order/
import re
def sort_nicely_inplace(l):
""" Sort the given list in the way that humans expect.
P.S. Beware of unicode and other i18n crap!
"""
convert = lambda text: int(text) if text.isdigit() else text
alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ]