Skip to content

Instantly share code, notes, and snippets.

View Saigesp's full-sized avatar
🙄

Santiago Espinosa Saigesp

🙄
View GitHub Profile
@Saigesp
Saigesp / activate.bat
Created October 4, 2019 12:55
Script with useful actions to work with virtualenvwrapper on windows
set "VIRTUAL_ENV=C:\Users\YOURUSER\Envs\YOURENVNAME"
:: Set variables
set "ENVIRONMENT=develop"
:: Change directory
cd C:\Users\YOURPROJECTPATH
:: Remove __pycache__ folders
for /d /r ".\API" %%a in (__pycache__) do if exist "%%a" rmdir /s /q "%%a"
@Saigesp
Saigesp / geolocorutm.py
Last active October 20, 2019 19:06
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
Saigesp / .conkyrc
Last active November 2, 2019 23:06
Conky configuration file
background no
font Snap.se:size=8
xftfont Snap.se:size=8
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
@Saigesp
Saigesp / csv_to_hierarchical_json.py
Last active December 11, 2019 21:55
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
Saigesp / django.mongo.testsutils.py
Created January 5, 2020 15:42
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
Saigesp / pre-commit
Last active January 12, 2020 23:14
git pre-commit hook to run some tests and linters
# Run django test before commit, abort if fails
python manage.py test || exit 1
# Run vue tests and linter before commit, abort if fails
EXIT_STATUS=0
npm run lint || EXIT_STATUS=$?
npm run test:unit || EXIT_STATUS=$?
exit $EXIT_STATUS
@Saigesp
Saigesp / image_resize.py
Last active December 4, 2020 15:53
Python script to resize images, with command line arguments. Adapted from https://gist.github.com/ihercowitz/642650/f01986c0b1ebd04be588b196eb3ffefe9853e113
#!/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 image_resize.py -d /home/images -o /home/output_dir -s 1024 768
@Saigesp
Saigesp / ssh.md
Last active January 27, 2021 12:03
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
Saigesp / .block
Last active July 9, 2021 00:36
D3v4 Warming stripes
eda813560c801474904004d6b6b1cc4c
@Saigesp
Saigesp / InputNumber.vue
Last active July 29, 2021 11:14
Vue2 ElementUI custom InputNumber to add "." as thousand separator and "," as decimal separator
<template>
<div
@dragstart.prevent
:class="[
'el-input-number',
inputNumberSize ? 'el-input-number--' + inputNumberSize : '',
{ 'is-disabled': inputNumberDisabled },
{ 'is-without-controls': !controls },
{ 'is-controls-right': controlsAtRight }
]">