Skip to content

Instantly share code, notes, and snippets.

Avatar

João Gabriel Lima jgabriellima

View GitHub Profile
@jgabriellima
jgabriellima / openai_code-reviewer.py
Created December 19, 2022 20:56
Request OpenAI through code-reviewer.vercel.app
View openai_code-reviewer.py
import requests
cookies = {
'locale': 'en',
}
headers = {
'authority': 'code-reviewer.vercel.app',
'accept': 'application/json, text/plain, */*',
'accept-language': 'en-US,en;q=0.9,pt-BR;q=0.8,pt;q=0.7',
@jgabriellima
jgabriellima / docker-compose.yml
Created March 26, 2022 20:07 — 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 February 22, 2022 17:13 — 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 February 16, 2022 18:42 — 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 October 1, 2021 00:52 — 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 September 14, 2021 16:05 — 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 June 14, 2019 20:49 — 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 July 27, 2018 12:53 — 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);