Skip to content

Instantly share code, notes, and snippets.

View filipelenfers's full-sized avatar

Filipe Pais Lenfers filipelenfers

View GitHub Profile
@pmargreff
pmargreff / reassign_owner.sql
Last active October 30, 2019 18:35
Create queries to reset postgres database owners (excluding protected schemas/tables).
SELECT 'ALTER TABLE '|| schemaname || '.' || tablename ||' OWNER TO username;'
FROM pg_tables WHERE NOT schemaname IN ('pg_catalog', 'information_schema')
ORDER BY schemaname, tablename;
SELECT 'ALTER SEQUENCE '|| sequence_schema || '.' || sequence_name ||' OWNER TO username;'
FROM information_schema.sequences WHERE NOT sequence_schema IN ('pg_catalog', 'information_schema')
ORDER BY sequence_schema, sequence_name;
SELECT 'ALTER VIEW '|| table_schema || '.' || table_name ||' OWNER TO username;'
FROM information_schema.views WHERE NOT table_schema IN ('pg_catalog', 'information_schema')
@davideicardi
davideicardi / README.md
Last active March 8, 2023 15:05
Write and read Avro records from bytes array

Avro serialization

There are 4 possible serialization format when using avro:

@smithclay
smithclay / index.js
Created June 16, 2017 18:30
"Hello World" AWS Lambda + Terraform Example
// 'Hello World' nodejs6.10 runtime AWS Lambda function
exports.handler = (event, context, callback) => {
console.log('Hello, logs!');
callback(null, 'great success');
}
@deehzee
deehzee / psycopg2_sshtunnel.py
Last active September 13, 2023 08:09
How to Connect To PostgreSQL Using SSHTunnelForwarder and Psycopg2
import psycopg2
from sshtunnel import SSHTunnelForwarder
# For interactive work (on ipython) it's easier to work with explicit objects
# instead of contexts.
# Create an SSH tunnel
tunnel = SSHTunnelForwarder(
('128.199.169.188', 22),
ssh_username='<username>',
@arunsrinivasan
arunsrinivasan / tweet_reply.md
Last active July 27, 2018 04:38
automatic indexing vs between() on integer ranges

Updated June 16 with latest devel

data.table's automatic indexing:

Generating some data first:

# R version 3.3.0
require(data.table) ## 1.9.7, commit 2433, github
require(dplyr) ## devel, commit 3189, github
@stonegao
stonegao / rest.scala
Created October 9, 2011 16:05 — forked from robi42/rest.scala
Basic RESTful service with Finagle
class Respond extends Service[Request, Response] with Logger {
def apply(request: Request) = {
try {
request.method -> Path(request.path) match {
case GET -> Root / "todos" => Future.value {
val data = Todos.allAsJson
debug("data: %s" format data)
Responses.json(data, acceptsGzip(request))
}
case GET -> Root / "todos" / id => Future.value {