Skip to content

Instantly share code, notes, and snippets.

View jgabriellima's full-sized avatar

João Gabriel Lima jgabriellima

View GitHub Profile
from nltk.tokenize import word_tokenize
import pickle
import pprint
import json
"""
(heads, descs, keywords) = ([headline], [description], )
"""
@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
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@jgabriellima
jgabriellima / persist.js
Created June 14, 2019 20:49 — forked from benjick/persist.js
mobx-state-tree persist PoC
/* 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 / media-query-template.css
Created September 14, 2021 16:05 — forked from mavieth/media-query-template.css
Media Query Template for Basic 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 / encrypt.html
Created October 1, 2021 00:52 — forked from LucaLanziani/encrypt.html
AES encryption, equivalent implementation in python (PyCrypto) and Javascript (CryptoJS)
<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 / reset.sql
Created February 16, 2022 18:42 — forked from tbarbugli/reset.sql
reset all sequences on a postgres db
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 / contextmanager.md
Created February 22, 2022 17:13 — forked from bgilbert/contextmanager.md
Python context managers

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 / docker-compose.yml
Created March 26, 2022 20:07 — forked from zhunik/docker-compose.yml
docker-compose Postgres health-check
version: "3"
services:
postgress:
....
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
app:
@jgabriellima
jgabriellima / openai_code-reviewer.py
Created December 19, 2022 20:56
Request OpenAI through code-reviewer.vercel.app
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 / call_flow_graph.py
Last active May 9, 2023 16:22
This code create a call flow graph from a package
import ast
import base64
import networkx as nx
import matplotlib.pyplot as plt
import subprocess
import os
class FlowchartAnalyzer(ast.NodeVisitor):