Skip to content

Instantly share code, notes, and snippets.

Avatar

João Gabriel Lima jgabriellima

View GitHub Profile
@jgabriellima
jgabriellima / docker-compose.yml
Created Mar 26, 2022 — forked from zhunik/docker-compose.yml
docker-compose Postgres health-check
View docker-compose.yml
version: "3"
services:
postgress:
....
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
app:
@jgabriellima
jgabriellima / contextmanager.md
Created Feb 22, 2022 — forked from bgilbert/contextmanager.md
Python context managers
View contextmanager.md

Context managers

In Python, a context manager is an object that can be used in a with statement. Here's a context manager that reports the total wall-clock time spent inside a with block:

import time

class Timer(object):
    def __init__(self, msg):
        self._msg = msg
@jgabriellima
jgabriellima / reset.sql
Created Feb 16, 2022 — forked from tbarbugli/reset.sql
reset all sequences on a postgres db
View reset.sql
SELECT 'SELECT SETVAL(' ||quote_literal(S.relname)|| ', MAX(' ||quote_ident(C.attname)|| ') ) FROM ' ||quote_ident(T.relname)|| ';'
FROM pg_class AS S, pg_depend AS D, pg_class AS T, pg_attribute AS C
WHERE S.relkind = 'S'
AND S.oid = D.objid
AND D.refobjid = T.oid
AND D.refobjid = C.attrelid
AND D.refobjsubid = C.attnum
ORDER BY S.relname;
@jgabriellima
jgabriellima / encrypt.html
Created Oct 1, 2021 — forked from LucaLanziani/encrypt.html
AES encryption, equivalent implementation in python (PyCrypto) and Javascript (CryptoJS)
View encrypt.html
<html>
<head>
<script src="/javascripts/CryptoJS/rollups/aes.js"></script>
<script src="/javascripts/CryptoJS/components/mode-cfb-min.js"></script>
<script src="/javascripts/encrypt.js"></script>
</head>
<body>
</body>
</html>
@jgabriellima
jgabriellima / media-query-template.css
Created Sep 14, 2021 — forked from mavieth/media-query-template.css
Media Query Template for Basic CSS
View media-query-template.css
/**
* Basic CSS Media Query Template
* TODO: I should probably use Sass...
* Author: Michael Vieth
* ------------------------------------------
* Responsive Grid Media Queries - 1280, 1024, 768, 480
* 1280-1024 - desktop (default grid)
* 1024-768 - tablet landscape
* 768-480 - tablet
* 480-less - phone landscape & smaller
@jgabriellima
jgabriellima / persist.js
Created Jun 14, 2019 — forked from benjick/persist.js
mobx-state-tree persist PoC
View persist.js
/* globals localStorage */
import { onSnapshot, applySnapshot } from 'mobx-state-tree';
import Storage from './storage';
export const persist = (name, store, options, schema = {}) => {
let hydrated = false;
let storage = options.storage;
if (typeof localStorage !== 'undefined' && localStorage === storage) {
@jgabriellima
jgabriellima / Git remove folder
Created Jul 27, 2018 — forked from sabarasaba/gist:3080590
Remove directory from remote repository after adding them to .gitignore
View Git remove folder
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
View to_pickle.py
from nltk.tokenize import word_tokenize
import pickle
import pprint
import json
"""
(heads, descs, keywords) = ([headline], [description], )
"""
View flatten_array_js
function flatten(data){
return [].concat.apply([],[].concat.apply([],data))
}
var result = flatten([[1,2,[3]],4]);
console.log(result);
View python_code_test_carto.md