Skip to content

Instantly share code, notes, and snippets.

View cadu-leite's full-sized avatar
🐍

Carlos C. Leite cadu-leite

🐍
View GitHub Profile
@cadu-leite
cadu-leite / fswatch_test_python.sh
Last active August 9, 2020 22:23
BASH fswatch for tests python projects
fswatch -l 45 -r . -e ".*" -i "\\.py$" -o | xargs -n1 -I{} python -m unittest
fswatch -l 15 -r . -e ".*" -i "\\.py$" -o | xargs -n1 -I{} python -m unittest --verbose
@cadu-leite
cadu-leite / gist:8236f4c16dc756eb1eb578784b9bdd5e
Created September 7, 2020 21:45 — forked from joshuapowell/gist:e209a4dac5c8187ea8ce
Setup Postgres.app to use PostGIS on OS X

Download and Install Postgres.app

Before we can setup PostGIS we need to have a local version of Postgresql installed and running. The most effecient way to do this is to download and install Postgres.app.

Spatially Enable your Postgres Database

Once Postgres.app is installed in your computers /Applications directory. Open the Terminal and enter the following two commands

psql -d DATABASE_NAME -f /Applications/Postgres.app/Contents/Versions/9.3/share/postgresql/contrib/postgis-2.1/postgis.sql
@cadu-leite
cadu-leite / postgres_queries_and_commands.sql
Created September 12, 2020 15:37 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@cadu-leite
cadu-leite / get_key_dot_path.py
Last active October 31, 2022 17:40
Nested Dictionary values through dot path
'''
get key values based on dot path
based on dict or json
d = {
'd1': 1,
'd2': {
'a': 2, 'b': 3, },
@cadu-leite
cadu-leite / ajax_XMLHttpRequest.js
Last active May 4, 2022 00:30
JavaScript XMLHttpRequest GET and POST forms js - good to go with Django Python
// http://localhost:8080/contact/form/
// oReq.open("GET", "http://localhost:8080/contact/form");
// id_SubmitContact
var container = "header";
var formId = "id-contactform";
var url_post = "/contact/form/"
function callBackLoad(){
@cadu-leite
cadu-leite / mocks_py_xmletree.py
Created November 3, 2022 18:29
Python XML Etree MOCKs
import unittest
import xml
from unittest.mock import Mock, patch
import modulo1
from modulo1 import get_tag_content
class TestMockXML(unittest.TestCase):