Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name JPDB Yes, keep going!
// @namespace http://tampermonkey.net/
// @version 0.7
// @description Makes "Yes, keep going!" the default button.
// @author boccato
// @match https://jpdb.io/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=jpdb.io
// @grant none
// ==/UserScript==
@boccato
boccato / hspec-wai-connection.hs
Created March 22, 2017 02:33
combine the with app and around withRollback
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Exception (bracket)
import Network.Wai
import Network.HTTP.Types (status200)
import Test.Hspec
import Test.Hspec.Wai
-- https://begriffs.com/posts/2014-10-19-warp-server-controller-test.html
mkApp :: FilePath -> Application
mkApp p = fileServer $ pack p
withApp :: ActionWith Application -> ActionWith FilePath
withApp action path = do
action (mkApp path)
withTempFolder :: ActionWith FilePath -> IO ()
spec :: Spec
spec = with app $ do
describe "DELETE" $ do
it "responds with 200" $ do
a <- liftIO (withTempFile "." "bla.txt" $ \file _ -> do return (delete "bla"))
a `shouldRespondWith` 200
import System.IO.Temp (withTempDirectory, withTempFile)
import Test.Hspec
import Test.Hspec.Wai
app :: IO Application
app = pure myApplication
spec :: Spec
spec = with app $ do
describe "DELETE" $ do
module Main where
import Control.Monad
import System.Random
nSimulations = 100
nCurrentReposts = 1
takeDistinct :: Eq a => Int -> [a] -> [a]
takeDistinct n xs = sample n xs []
create table discussoes (id number, assunto_id number);
insert into discussoes values (1, 6);
insert into discussoes values (2, 7);
insert into discussoes values (3, 8);
create table seguidor_assunto (usuario_id number, assunto_id number);
insert into seguidor_assunto values (95, 7);
create table seguidor_discussao (usuario_id number, discussao_id number);
insert into seguidor_discussao values (95, 1);