Skip to content

Instantly share code, notes, and snippets.

@lsmag
lsmag / keybase.md
Created September 3, 2019 11:43
keybase.md

Keybase proof

I hereby claim:

  • I am lsmag on github.
  • I am lsmagalhaes (https://keybase.io/lsmagalhaes) on keybase.
  • I have a public key ASCicowUDG4KnShfu7XtfyhPZLOnCnkO8dOGNdZfXQjGyQo

To claim this, I am signing this object:

#!/bin/bash
xmain() {
local source_branch="$1"; shift
local source_commit=$(git merge-base HEAD "$source_branch")
git rebase -i \
--exec 'docker-compose run --rm magalu-entregas make lint' \
--exec 'docker-compose run --rm magalu-entregas make test' \
"$source_commit" \
#!/bin/bash
main() {
local source_branch="$1"; shift
local source_commit=$(git merge-base HEAD "$source_branch")
git rebase -i \
--exec 'make lint' \
--exec 'make test' \
"$source_commit" \
import asyncio
import time
SECONDS = 1
def sync_sleep(worker_id):
for _ in range(3):
print(f'{worker_id} preparing to sync sleep for {SECONDS} seconds')
time.sleep(SECONDS)
print(f'{worker_id} sync sleeped for {SECONDS} seconds')
envDatabaseURL <- liftIO $ lookupEnv "DATABASE_URL"
d <- nestSnaplet "db" db $
pgsInit' . pgsDefaultConfig . pack . fromMaybe defaultDatabaseURL $ envDatabaseURL
-------------------------------------------------------
-- BEFORE THE FIX
-------------------------------------------------------
-- this is the default code created by snap
-- | Render login form
handleLogin :: Maybe T.Text -> Handler App (AuthManager App) ()
handleLogin authError = heistLocal (I.bindSplices errs) $ render "login"
where
handleLoginSubmit = loginUser "login" "password" rememberField errorHandler successHandler
where
rememberField = Nothing
errorHandler _ = handleLogin (Just "Unknown user or password")
successHandler = do
toPage <- getQueryParam "to"
redirect . fromMaybe "/" $ toPage
loginRequired = requireUser auth handleRedirect
where
-- this is the cleanest way (afaik) to write it
handleRedirect = withRequest (redirect . append "/login?to=" . rqURI)
-- that handleRedirect can be rewritten in a more imperative way:
handleRedirect = withRequest (\rq -> redirect (append "login?to=" (rqURI rq)))
-- or
handleRedirect = withRequest (\rq -> redirect . append "login?to=" . rqURI $ rq)
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
##
## Check this url for the original reference:
## https://github.com/12foo/dotfiles/blob/master/tag-x11/config/herbstluftwm/topbar.py
## https://github.com/krypt-n/bar
##
##
import asyncio
import sys
from asyncio import Queue
TAG_ALIGN_LEFT = '%{l}'
TAG_ALIGN_CENTER = '%{c}'
TAG_ALIGN_RIGHT = '%{r}'
UNDERLINE_OPEN = '%{+u}'
UNDERLINE_CLOSE = '%{-u}'