Skip to content

Instantly share code, notes, and snippets.

with x as (select r.oid
, r.relname
, a.attnum
, a.attname
, a.atttypid
, a.attlen
, a.attnotnull
from pg_catalog.pg_class r
join pg_catalog.pg_attribute a on a.attrelid = r.oid
where r.relnamespace = 'my_schema'::regnamespace
with recursive plates(weight, thickness, price) as (
select 5::int, 35::int, 269.00::numeric(15,2)
union
select 10, 51, 369.90
union
select 15, 70, 554.00
union
select 20, 83, 739.80)
, plate_sets(weight, thickness, price, plate_set) as (
select * from (
package com.portoitapoa.boleto.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
@jean-lopes
jean-lopes / Preprocessor.hs
Created November 10, 2018 21:17
Preprocessor for Java like languages
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE OverloadedStrings #-}
module Preprocessor
( Preprocessed(..)
, preprocess )
where
import Control.Monad (void)
import Data.Char
import Data.Data (Data)
import Data.Text (Text)
@jean-lopes
jean-lopes / saga.java
Last active August 19, 2018 18:03
Saga DSL
SagaDefinition saga = SagaDefinitionImpl.builder()
.name("", "")
.initialize("", "")
.startGroup(GroupType.SEQUENTIAL)
.step("", "")
.process(null)
.successListener()
.domain(null)
.service(null)
.event(null)

Java 8 Method Signatures Cheatsheet

Uma função que recebe como argumento uma instancia de T e retorna uma instância de R.

Convencional:
<T, R> R foo(T a) {
    return null; //Retorno com tipo R
}
@jean-lopes
jean-lopes / purge-all-queues.sh
Created July 20, 2018 20:23
Purge all queues from RabbitMQ
#!/bin/bash
[[ ! -f rabbitmqadmin ]] && curl -s $BROKER_HOST:15672/cli/rabbitmqadmin > rabbitmqadmin
alias rabbit='python rabbitmqadmin --host=$BROKER_HOST --username=$BROKER_USER --password=$BROKER_PASS'
rabbit list queues | tail -n +3 | sort -r | tail -n +3 | cut -d '|' -f 2 | cut -d ' ' -f 2 | sort |
while read -r QUEUE; do
echo "Purging $QUEUE"
rabbit -q purge queue name=$QUEUE
done
#!/bin/bash
COUNT=$(wget -qO- reddit.com/r/haskell | cat | grep -Eo '<span class="subscribers"><span class="number">[0-9,]+</span>' | grep -Eo "[0-9,]+" | sed s/,// | head -1)
NOW=$(date +%F)
echo "$NOW $COUNT" > haskellers.txt
@jean-lopes
jean-lopes / Calculator.hs
Created August 18, 2017 16:28
Simple calculator using megaparsec
module Calculator
where
import Control.Monad (void)
import Text.Megaparsec
import Text.Megaparsec.String (Parser)
import qualified Text.Megaparsec.Lexer as Lexer
data Expr
= Value Int
| Nested Expr
11:32:31.172: CPU Name: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
11:32:31.172: CPU Speed: 3492MHz
11:32:31.173: Physical Cores: 4, Logical Cores: 8
11:32:31.173: Physical Memory: 16271MB Total, 11442MB Free
11:32:31.173: Windows Version: 10.0 Build 15063 (revision: 296; 64-bit)
11:32:31.173: Running as administrator: false
11:32:31.173: Aero is Enabled (Aero is always on for windows 8 and above)
11:32:31.173: Portable mode: false
11:32:31.180: OBS 19.0.3 (64bit, windows)
11:32:31.180: ---------------------------------