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 / http_request_status_code.py
Last active August 29, 2015 13:57
HTTP Request STATUS CODE DICT
# source: http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
]
STATUS_CODE = {
100: "Continue",
101: "Switching Protocols",
102: "Processing",
103: "Checkpoint",
122: "Request-URI too long",
200: "OK",
<!DOCTYPE html>
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons' rel="stylesheet">
<link href="https://unpkg.com/vuetify/dist/vuetify.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
</head>
<body>
<div id="app">
<!DOCTYPE html>
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons' rel="stylesheet">
<link href="https://unpkg.com/vuetify/dist/vuetify.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
</head>
<body>
<div id="app">
<v-app id="inspire">
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
URL: http://localhost:8080/api/v1/project/?limit=2&offset=2
Result
-----
>> 7 reg total
```
{
@cadu-leite
cadu-leite / django_list_templates_dirs.py
Last active June 23, 2019 14:10
List all Django Templates Directories
# pyton3
# django2.1
import os
from django.apps import apps
from django.conf import settings
def get_templates_directories():
template_directories = []
# Getting templates in the templates directory
for template in settings.TEMPLATES:
@cadu-leite
cadu-leite / sheet_2_calendar.js
Created December 8, 2019 14:42
Script transfere eventos do google Sheet para Google Calendar
// formato da planilha
// Colunas
//Moderadores | dia inicio | duracao | titulo | palestrante | link | mail | data_inicio | data_fim | calendar.object.id
// conteudo a partir da linha 10 ou altere alinha
// ... var slots = sps.getRange("agenda-calendario!A10:K"+last_row+"").getValues();
// para
// ... var slots = sps.getRange("<NOME_SHEET>!A10:K"+last_row+"").getValues();
function slots_2_calendar() {
@cadu-leite
cadu-leite / point_shp_2_png.py
Created December 23, 2019 10:06
Draw PNG with points from a shapefile using PIL
import sys
from osgeo import gdal, ogr
from PIL import Image, ImageDraw
# Filename of input OGR file
vector_fn = 'RG2017_rgi_centroids.shp'
# Open the data source and read in the extent
datasource = ogr.Open(vector_fn)
@cadu-leite
cadu-leite / export-google-docs-to-restructured-text.js
Created June 20, 2020 10:33 — forked from simonw/export-google-docs-to-restructured-text.js
Google Apps script to convert a Google Docs document into reStructuredText
function onOpen() {
var ui = DocumentApp.getUi();
ui.createMenu('Convert to .RST')
.addItem('Convert to .RST and email me the result', 'ConvertToRestructuredText')
.addToUi();
}
// Adopted from https://github.com/mangini/gdocs2md by Renato Mangini
// License: Apache License Version 2.0
String.prototype.repeat = String.prototype.repeat || function(num) {
import math
s = 'Sample text'

import decimal
dn = decimal.Decimal(math.pi) # a decimal number
fn = math.pi  # a float number

print (f'{s}')
# "convert"or transform a Json to objet attributes
# converte ou transforma um Json em objeto com atributos
def _json_object_hook(d:Dict):
return namedtuple('X', d.keys(), rename=True)(*d.values())
def json2obj(data_json: str):
return json.loads(data_json, object_hook=_json_object_hook)