Copy file from local to remote
scp file.txt <user>@<server>:/path/to/remote/folder
Copy folder from local to remote
# -*- coding: utf-8 -*- | |
# Create multiple responsive images to generate a srcset | |
# | |
# Usage example: | |
# b64_image = base64.b64decode(b64_image.split(",")[1]) # from base64-encoded image | |
# file_name = "lorem.ipsum.jpeg" | |
# srcset_results = [] | |
# for img in create_srcset_images(BytesIO(b64_image), widths): | |
# srcset_name = f'{".".join(file_name.split(".")[:-1])}-{img["width"]}w.{img["format"]}' | |
# result = upload_file_to_external_service(img["image"], srcset_name) # <--- it must return a URL |
[ | |
{ | |
"name": "Afghanistan", | |
"flag": "🇦🇫", | |
"code": "AF", | |
"dial_code": "+93" | |
}, | |
{ | |
"name": "Åland Islands", | |
"flag": "🇦🇽", |
import csv | |
from pathlib import Path | |
ROOT = Path(__file__).resolve().parent | |
INPUT_OLD = ROOT / "old.csv" | |
INPUT_NEW = ROOT / "new.csv" | |
OUTPUT = ROOT / "final.csv" | |
# csv data format: | |
# email,zip_code |
import os | |
import csv | |
DATA_FOLDER = os.path.join('data') | |
class CsvDB: | |
def __init__(self, dbname: str, verbose: bool=True): | |
self.verbose = verbose | |
self.dbname = dbname | |
os.makedirs(os.path.join(DATA_FOLDER, self.dbname), exist_ok=True) |
<template> | |
<div | |
@dragstart.prevent | |
:class="[ | |
'el-input-number', | |
inputNumberSize ? 'el-input-number--' + inputNumberSize : '', | |
{ 'is-disabled': inputNumberDisabled }, | |
{ 'is-without-controls': !controls }, | |
{ 'is-controls-right': controlsAtRight } | |
]"> |
server { | |
listen 8008; | |
server_name localhost; | |
add_header 'Access-Control-Allow-Origin' '$http_origin'; | |
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,Cache-Control,Content-Type,Content-Range,Range'; | |
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH'; | |
location / { |
# 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 |
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 | |
""" |
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): |