Skip to content

Instantly share code, notes, and snippets.

@andresmrm
andresmrm / update_vue-i18n_locale_files.py
Last active March 31, 2019 21:29
[vue-18n] Extracts i18n keys from vue files and add them to the locale files. Supports only "v-t" method keys (not "$t") and json locale files (not yaml).
#!/usr/bin/env python3
'''
BEWARE: Poorly tested. Use at your own risk.
It replaces json files content. Backup first!
For use with https://github.com/kazupon/vue-i18n
Extracts i18n keys from vue files and add them to the locale files.
Supports only "v-t" method keys (not "$t") and json locale files (not yaml).
Doesn't support dynamic keys (v-t="var"), only static (v-t="'word'").
@andresmrm
andresmrm / app.py
Created April 20, 2018 14:19
Flask-SocketIO debug test
#!/usr/bin/env python
from threading import Lock
from flask import Flask, render_template, session, request
from flask_socketio import SocketIO, emit, join_room, leave_room, \
close_room, rooms, disconnect
# Set this variable to "threading", "eventlet" or "gevent" to test the
# different async modes, or leave it set to None for the application to choose
# the best option based on installed packages.
async_mode = None
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Based on:
# https://docs.python.org/3/library/email-examples.html
import sys
import os
import tempfile
import mimetypes
#!/usr/bin/env python
'''
----------------------------------------------------------------------
Copyright (C) 2016 Andrés M. R. Martano
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
@andresmrm
andresmrm / postgis_openshift.sh
Created April 7, 2016 12:47
Install PosgreSQL 9.4 with PostGIS on OpenShift, configure to use only unix domain socket.
# Postgres
cd $OPENSHIFT_DATA_DIR
wget https://ftp.postgresql.org/pub/source/v9.4.7/postgresql-9.4.7.tar.gz
tar xf postgresql-9.4.7.tar.gz
mkdir $OPENSHIFT_DATA_DIR/root
cd postgresql-9.4.7
./configure --prefix=$OPENSHIFT_DATA_DIR/root
make
make install
cd $OPENSHIFT_DATA_DIR
var loaderUtils = require("loader-utils");
var mime = require("mime");
module.exports = function(content) {
this.cacheable && this.cacheable();
var query = loaderUtils.parseQuery(this.query);
var limit = (this.options && this.options.url && this.options.url.dataUrlLimit) || 0;
if(query.limit) {
limit = parseInt(query.limit, 10);
}
var mimetype = query.mimetype || query.minetype || mime.lookup(this.resourcePath);
{
"$schema": "http://interagent.github.io/interagent-hyper-schema",
"definitions": {
"account-feature": {
"description": "An account feature represents a Heroku labs capability that can be enabled or disabled for an account on Heroku.",
"$schema": "http://json-schema.org/draft-04/hyper-schema",
"stability": "production",
"strictProperties": true,
"title": "Heroku Platform API - Account Feature",
"type": [
(env)➜ utils python import_revenue.py
2015-02-06 10:17:57,664 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
2015-02-06 10:17:57,664 INFO sqlalchemy.engine.base.Engine ()
2015-02-06 10:17:57,664 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2015-02-06 10:17:57,664 INFO sqlalchemy.engine.base.Engine ()
2015-02-06 10:17:57,665 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2015-02-06 10:17:57,686 INFO sqlalchemy.engine.base.Engine INSERT INTO revenue (code, description, date, monthly_predicted, monthly_outcome, economical_category, economical_subcategory, source, rubric, paragraph, subparagraph) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?,
INSERT INTO "revenue_code" VALUES('1.9.2.2','Restituições');
INSERT INTO "revenue_code" VALUES('1.9.2.1','Indenizações');
INSERT INTO "revenue_code" VALUES('1.6.0.0.99','Outros Serviços');
INSERT INTO "revenue_code" VALUES('1.2.1.0.29.17','Contribuição do Servidor Ativo Civil, oriunda do Pagamento de Sentenças Judiciais');
INSERT INTO "revenue_code" VALUES('1.2.1.0.29.16','Contribuição Patronal, oriunda do Pagamento de Sentenças Judiciais');
INSERT INTO "revenue_code" VALUES('1.2.1.0.29.15','Contribuição Previdenciária em Regime de Parcelamento de Débitos');
INSERT INTO "revenue_code" VALUES('1.2.1.0.29.13','Contribuição Previdenciária para Amortização do Déficit Atuarial');
INSERT INTO "revenue_code" VALUES('1.6.0.0.5.5','Serviços de Assistência à Saúde Suplementar do Servidor Civil');
INSERT INTO "revenue_code" VALUES('1.2.2.0.6.3','Receita de Distribuição de Conteúdos Audiovisuais por Prestadores de Serviço de Acesso Condicionado');
INSERT INTO "revenue_code" VALUES('1.3.1.4','Laudêmios');
{
"mapping": {
"orgao": {
"description": null,
"label": "\u00d3rg\u00e3o",
"facet": true,
"key": true,
"attributes": {
"name": {
"column": "\u00d3rg\u00e3o (Cod)",