This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package br.com.rponte.gist.util.tlv; | |
| import static org.apache.commons.lang3.StringUtils.isBlank; | |
| import static org.apache.commons.lang3.StringUtils.join; | |
| import static org.apache.commons.lang3.StringUtils.leftPad; | |
| import java.math.BigDecimal; | |
| import java.util.LinkedHashMap; | |
| import java.util.Map; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT count(*), state FROM pg_stat_activity GROUP BY 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ApplicationScoped | |
| public class TransferenciaEntreContasDeMesmoCpf { | |
| @Inject | |
| public ContasDoCliente contas; | |
| @Transactional | |
| public void transfere(Integer origemId, Integer destinoId, BigDecimal valor) { | |
| Conta origem = contas.buscaPorId(origemId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Let's say you have a table full of work: | |
| CREATE TABLE tasks ( | |
| id UUID PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(), | |
| status TEXT NOT NULL DEFAULT 'pending', | |
| payload JSON NOT NULL, -- or just have meaningful columns! | |
| created_at TIMESTAMP NOT NULL DEFAULT NOW() | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SET timezone TO 'America/Fortaleza'; | |
| SET timezone TO 'America/Sao_Paulo'; | |
| select now() as "now()" | |
| , now()::timestamp as "now()::timestamp" | |
| , now()::timestamptz as "now()::timestamptz" | |
| , now() at time zone 'utc-0' as "now() - utc-0" | |
| , now() at time zone 'America/Fortaleza' as "now() - fortaleza" | |
| , now() at time zone 'America/Sao_Paulo' as "now() - sao paulo" | |
| , localtimestamp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select sum(heap_blks_read) as heap_read | |
| ,sum(heap_blks_hit) as heap_hit | |
| ,sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) as ratio | |
| from pg_statio_user_tables | |
| ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with deleted_rows as | |
| ( | |
| delete | |
| from tweet.users | |
| where not exists | |
| ( | |
| select 1 | |
| from tweet.message | |
| where userid = users.userid | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .bashrc | |
| # Source global definitions | |
| if [ -f /etc/bashrc ]; then | |
| . /etc/bashrc | |
| fi | |
| # User specific aliases and functions | |
| tail-color() { | |
| ## |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HowToDecryptAPIN { | |
| /** | |
| * Using fake data | |
| */ | |
| public static void main(String[] args) { | |
| // PAN and PIN informed by the user (ie.: via POS or ATM) | |
| String pan = "4000340000000500"; // card number | |
| String encryptedPin = "FA8EA4D3FCB5466E"; // pin=2020 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package cz.monetplus.mnsp.tools.misc; | |
| import org.apache.commons.codec.DecoderException; | |
| import org.apache.commons.codec.binary.Hex; | |
| import org.apache.commons.lang.StringUtils; | |
| /** | |
| * Tools for encoding a decoding pinblock | |
| * | |
| * @author Tomas Jacko <tomas.jacko [at] monetplus.cz> |