- In pg_hba.conf file change line
- restart postgreSQL by /etc/init.d/postgresql restart
- login as postgres by psql -U postgres
- change password by issuing the query ALTER USER postgres with encrypted password 'secret';
- undo changes done in step1
- restart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- file: ch19/ParseInt.hs | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
import Data.Char | |
import Control.Monad | |
import Control.Monad.Error | |
import Control.Monad.State | |
import qualified Data.ByteString.Char8 as B | |
data ParseError = NumericOverflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
import System.Exit | |
import System.IO | |
import Control.Exception (bracket_) | |
import System.Process (readProcessWithExitCode) | |
import Control.Monad.Error (MonadError, ErrorT, runErrorT, throwError, lift) | |
import Control.Monad.IO.Class | |
newtype Shell a = Shell { runShell :: ErrorT String IO a } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# before install lens, install zlib development package | |
sudo apt-get install zlib1g-dev | |
cabal install lens |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
from http://lukepalmer.wordpress.com/2008/08/10/mindfuck-the-reverse-state-monad/ | |
also look at https://github.com/luqui/backward-state | |
-} | |
module RState where | |
newtype RState s a = RState { runRState :: s -> (a,s) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} | |
module StateB where | |
import Control.Monad.State | |
newtype StateB s a = StateB {runStateB :: s -> (a,s)} | |
instance Monad (StateB s) where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# install ghc-terminfo-dev | |
sudo apt-get install libghc-terminfo-dev | |
# install alex from hackage | |
cabal update; cabal install alex | |
# install idris from hackage | |
cabal install idris |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# from http://stackoverflow.com/questions/1471571/how-to-configure-postgresql-for-the-first-time | |
# | |
# debian jessie | |
# PostgreSQL 9.3 | |
sudo apt-get install postgresql postgresql-client | |
# connect to standard system database template1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad | |
import Control.Monad.ST | |
import Data.Array.ST | |
import Data.Array.Unboxed | |
primesUpto :: Int -> [Int] | |
primesUpto n = [p | (p, True) <- assocs $ sieve n] | |
sieve :: Int -> UArray Int Bool | |
sieve n = runSTUArray $ do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad | |
main :: IO () | |
main = forM_ [1..100] $ \n -> do | |
let f n = case (n `mod` 2, n `mod` 5) of | |
(0,0) -> "fizzbuzz" | |
(0,_) -> "fizz" | |
(_,0) -> "buzz" | |
_ -> show n | |
putStrLn $ f n |
OlderNewer