Skip to content

Instantly share code, notes, and snippets.


Santiago Espinosa Saigesp

View GitHub Profile
Saigesp / InputNumber.vue
Last active Jul 29, 2021
Vue2 ElementUI custom InputNumber to add "." as thousand separator and "," as decimal separator
View InputNumber.vue
inputNumberSize ? 'el-input-number--' + inputNumberSize : '',
{ 'is-disabled': inputNumberDisabled },
{ 'is-without-controls': !controls },
{ 'is-controls-right': controlsAtRight }
Saigesp / nginx-proxy-pass
Last active Jul 25, 2021
Nginx proxy pass example to avoid CORS on development
View nginx-proxy-pass
server {
listen 8008;
server_name localhost;
add_header 'Access-Control-Allow-Origin' '$http_origin';
# add_header 'Access-Control-Allow-Origin' 'http://localhost:8080';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,C$
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
Saigesp / pre-commit
Last active Jan 12, 2020
git pre-commit hook to run some tests and linters
View pre-commit
# Run django test before commit, abort if fails
python test || exit 1
# Run vue tests and linter before commit, abort if fails
npm run lint || EXIT_STATUS=$?
npm run test:unit || EXIT_STATUS=$?
Saigesp /
Created Jan 5, 2020
Custom TestRunner and APITestCase to work with django, mongodb and django rest framework
from django.test.runner import DiscoverRunner
from django.conf import settings
from mongoengine import connect, disconnect, get_connection
from pymongo import MongoClient
from rest_framework.test import APITestCase
class TestRunner(DiscoverRunner):
Custom test runner for mongoengine
Saigesp /
Last active Dec 11, 2019
Convert a 3 columns csv to a hierarchical json with d3 sunburst default format
import csv
import json
import itertools
Convert a 3 columns CSV to a hierarchical JSON
with d3 sunburst default format.
Duplicated CSV column values are nested on the JSON as follows:
input file (CSV):
Saigesp /
Last active Jan 27, 2021
SSH useful commands

SSH Useful commands

SCP Commands

Copy file from local to remote

scp file.txt <user>@<server>:/path/to/remote/folder

Copy folder from local to remote

Saigesp /
Last active Oct 20, 2019
Python script to get longitude and latitude from google maps API or transform from UTM (provided in file)
# -*- coding: UTF-8 -*-
import csv
import os
import sys
import json
import time
import pyproj
import argparse
from urllib import parse, request
if sys.version_info[0] < 3: raise Exception("Python 3 required")
Saigesp / activate.bat
Created Oct 4, 2019
Script with useful actions to work with virtualenvwrapper on windows
View activate.bat
:: Set variables
set "ENVIRONMENT=develop"
:: Change directory
:: Remove __pycache__ folders
for /d /r ".\API" %%a in (__pycache__) do if exist "%%a" rmdir /s /q "%%a"
Saigesp /
Last active Dec 4, 2020
Python script to resize images, with command line arguments. Adapted from
#!/usr/bin/env python
import os
import sys
import argparse
from PIL import Image
Reduce images size
Images are resized keeping the aspect ratio
Usage: python -d /home/images -o /home/output_dir -s 1024 768
Saigesp / .conkyrc
Last active Nov 2, 2019
Conky configuration file
View .conkyrc
background no
use_xft yes
xftalpha 0.1
update_interval 3.0
total_run_times 0
own_window yes
own_window_type normal
own_window_transparent yes