Skip to content

Instantly share code, notes, and snippets.

-- | JSON array parsing in Haskell
-- Input data in JSON format (3 elements): "[1, 2, \"abc\"]"
-- Output data: (SChange (Int 1) (Int 2) (String "abc"))
{-# LANGUAGE OverloadedStrings #-}
module ParseArray (
main
) where
module STMTransfer (
main
) where
import Data.TCache
import Control.Concurrent (forkIO, forkOS, ThreadId, threadDelay)
import Control.Concurrent.STM
import Control.Monad (mapM, void)
import System.Random (getStdRandom, randomR)
module Fork (
main
) where
import Control.Concurrent (forkIO, forkOS, ThreadId, threadDelay)
import Control.Monad (mapM, void)
import System.Random (getStdRandom, randomR)
second :: Int
@AlexanderAA
AlexanderAA / Fork.hs
Last active December 27, 2015 15:39
module Fork (
main
) where
import Control.Concurrent (forkIO, ThreadId, threadDelay)
import Control.Concurrent.STM
import Control.Monad
import Control.Monad.IO.Class (liftIO)
import System.Random

Virtualenv's bin/activate is Doing It Wrong

I'm a Python programmer and frequently work with the excellent [virtualenv][] tool by Ian Bicking.

Virtualenv is a great tool on the whole but there is one glaring problem: the activate script that virtualenv provides as a convenience to enable its functionality requires you to source it with your shell to invoke it. The activate script sets some environment variables in your current environment and defines for you a deactivate shell function which will (attempt to) help you to undo those changes later.

This pattern is abhorrently wrong and un-unix-y. activate should instead do what ssh-agent does, and launch a sub-shell or sub-command with a modified environment.

Problems

def get_request_token(self, callback_url):
""" Get request token.
Request token will be used to construct authorization URL later.
Args:
callback_url - basestring, not urlencoded.
Example: http://entrecard.com/oauth/callback
Returns:
request_token of type oauth2.Token