Skip to content

Instantly share code, notes, and snippets.

View jgabriellima's full-sized avatar

João Gabriel Lima jgabriellima

View GitHub Profile
@jgabriellima
jgabriellima / interprocedural control flow graph (ICFG)
Created April 3, 2024 21:25
Call graphs (CG) and control flow graphs (CFG) consist of nodes and edges. CG is interprocedural, nodes represent subroutines (methods, functions, ...), while edges represent the relationship caller-called between two subroutines (e.g., A->B, "A" is the caller subroutine, while "B" is the called subroutine). CFG is intraprocedural, nodes represe…
import ast
import jedi
import os
class CodeAnalyzer(ast.NodeVisitor):
def __init__(self, source_code, project_root, file_path, target_function):
self.source_code = source_code
self.file_path = file_path
self.project_root = project_root
@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):
@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 / mask.js
Created February 17, 2016 04:08
mascara javascript
var v_obj, v_fun;
function mascara(o, f) {
v_obj = o;
v_fun = f;
setTimeout("execmascara()", 1);
}
function execmascara() {
v_obj.value = v_fun(v_obj.value);
This file has been truncated, but you can view the full file.
type,datetime,open,high,low,close,ema,sma,rsi,bollow,bolhigh,macd,previous
USDJPY,2017-10-27 01:35:00,114.2020,114.2040,114.2000,114.2000,114.0367,114.0413,58.83,114.0094,114.2857,0.0323,114.1900
USDJPY,2017-10-27 01:30:00,114.1820,114.1820,114.1760,114.1810,114.0334,114.0377,56.72,114.0000,114.2780,0.0318,114.1890
USDJPY,2017-10-27 01:25:00,114.2140,114.2200,114.2110,114.2200,114.0304,114.0339,62.87,113.9907,114.2720,0.0327,114.2220
USDJPY,2017-10-27 01:20:00,114.1820,114.1960,114.1820,114.1900,114.0266,114.0297,59.75,113.9848,114.2556,0.0294,114.2550
USDJPY,2017-10-27 01:15:00,114.1880,114.2010,114.1880,114.1890,114.0233,114.0253,59.65,113.9779,114.2438,0.0278,114.1300
USDJPY,2017-10-27 01:10:00,114.2180,114.2240,114.2090,114.2220,114.0199,114.0212,64.82,113.9768,114.2294,0.0255,114.1580
USDJPY,2017-10-27 01:05:00,114.2400,114.2550,114.2320,114.2550,114.0158,114.0165,70.50,113.9873,114.2050,0.0188,114.0940
USDJPY,2017-10-27 01:00:00,114.1380,114.1390,114.1270,114.1300,114.0110,114.0117,57.36,114.0198,114.15
@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 / 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 / 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 / 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 / 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