Skip to content

Instantly share code, notes, and snippets.

View rponte's full-sized avatar
🏠
Working from home

Rafael Ponte rponte

🏠
Working from home
View GitHub Profile
@nathanl
nathanl / postgresql_serializable_isolation.sql
Last active October 25, 2024 15:05
PostgreSQL Serializable Isolation - false positives
-- (This code was run in PostgreSQL 9.6.1)
-- Demonstration of how serializable isolation for PostgreSQL, which detects possible
-- interference between concurrent transactions, can produce false positives
-- in psql, create the following table
CREATE TABLE users(
id SERIAL NOT NULL PRIMARY KEY,
username VARCHAR NOT NULL
);
@adrianoalmeida7
adrianoalmeida7 / template_amp.html
Last active December 22, 2022 14:31
HTML Básico para AMP
<!doctype html>
<html amp lang="pt-BR">
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<link rel="canonical" href="http://caminho_do_arquivo_original/arquivo.html">
<title>Página compatvel com AMP</title>
<link rel="canonical" href="http://example.ampproject.org/article-metadata.html" />
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{
@joshlong
joshlong / TestApplication.java
Last active June 9, 2022 09:49
an example demonstrating Spring's new `InjectionPoint` support
package com.example;
import org.springframework.beans.factory.InjectionPoint;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@rgl
rgl / add-virtualbox-5.1-support-to-vagrant.sh
Created July 16, 2016 14:18
Add VirtualBox 5.1 support to Vagrant 1.8.4
# see https://github.com/mitchellh/vagrant/pull/7574
curl -s https://github.com/mitchellh/vagrant/commit/b57b0e0d48fe8b4196ca6b7e01bb6c1ecb4b69f9.patch \
| sudo patch -p1 -d /opt/vagrant/embedded/gems/gems/vagrant-1.8.4
@juanplopes
juanplopes / Main.java
Created February 18, 2016 12:51
Object Pool example
package example;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
public class Main {
public static void main(String... args) throws Exception {
ObjectPool<ExpensiveObject> pool = new ObjectPool<ExpensiveObject>() {
@Override
@Gilmor
Gilmor / PinblockTool.java
Created January 5, 2016 09:58
Pinblock ISO 9564 format 0
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>
@alexandreaquiles
alexandreaquiles / ClienteRest.java
Last active September 14, 2017 21:30
Exemplo simples de autenticação por token com JAX-RS.
package br.com.caelum.livraria.rest;
import java.io.Serializable;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
@alexandreaquiles
alexandreaquiles / README.md
Last active July 9, 2018 10:50
Field selectors em uma API REST

Imagine que queremos obter nome e email de uma pessoa na API do Linkedin. Chamamos:

GET http://api.linkedin.com/v2/people/123

Teríamos como resposta:

<person uri=“urn:linkedin:v2:people/123” key=“123”>
  <id>123</id>
 Reid Hoffman
@alexandreaquiles
alexandreaquiles / Autorizador.java
Created December 4, 2015 19:33
Autorizador usando SOAPHandler.
package br.com.caelum.estoque.ws.handler;
import java.util.Iterator;
import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.soap.Node;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;