Skip to content

Instantly share code, notes, and snippets.

@oscarfonts
oscarfonts / serializers.py
Last active June 1, 2025 03:44 — forked from yellowcap/serializers.py
Django-parler and Django REST Framework integration
class ParlerModelSerializer(serializers.ModelSerializer):
"""https://gist.github.com/yellowcap/81c6d5f3ea1426689c80"""
def __init__(self, *args, **kwargs):
# Get list of translated fields
fields = self.Meta.model._parler_meta._fields_to_model
# Separate parler fields and scilent fields
parler_fieds = [x for x in self.Meta.fields if x in fields]
pas_parler_fields = [x for x in self.Meta.fields if x not in fields]
@oscarfonts
oscarfonts / docker-compose.yaml
Created October 6, 2022 12:21
Compose Geoserver + SSL proxy using letsencrypt
version: '3.9'
services:
proxy:
image: nginxproxy/nginx-proxy:1.0.1-alpine
restart: always
container_name: base-proxy
ports:
- 80:80
- 443:443
@oscarfonts
oscarfonts / hamster2toggl.sql
Created October 28, 2015 14:43
SQL query to export Hamster database to toggl time tracker
select
"user@example.com" as 'Email',
date(facts.start_time) as 'Start date',
time(facts.start_time) as 'Start time',
strftime('%H:%M:%S', strftime('%s',facts.end_time) - strftime('%s',facts.start_time), 'unixepoch') as 'Duration',
categories.name as 'Project',
activities.name as 'Description'
from
facts, categories, activities
where
@oscarfonts
oscarfonts / ecw_to_geotiff.sh
Last active October 21, 2020 10:19
ECW to GeoTIFF conversion with ginetto/gdal
FILENAME=Me1956
# fetch image
docker pull ginetto/gdal:2.4.1_ECW
# convert ecw to geotiff
docker run --rm -it --name gdalecw -v $PWD:/home/datafolder ginetto/gdal:2.4.1_ECW \
gdal_translate -co "TILED=YES" -co "COMPRESS=JPEG" -co "PHOTOMETRIC=YCBCR" -co "NUM_THREADS=ALL_CPUS" -co "BIGTIFF=YES" /home/datafolder/${FILENAME}.ecw /home/datafolder/${FILENAME}.tif
# add external overviews
#!/usr/bin/env bash
targetfilename="${1%.*}"
ffmpeg -i "${1}" -acodec mp2 -vcodec libx265 -crf 30 -vf "scale=iw/2:ih/2" "$targetfilename-compressed.mp4"
@oscarfonts
oscarfonts / image_utils.md
Last active May 4, 2020 06:08
Custom area screenshot & image optimization

Add Alt + PrintScreen keyboard shortcut

mate-screenshot -ai

image_half.sh

#!/usr/bin/env bash
mogrify -resize 50% "$@"

png8.sh

Install telegram

wget -O- https://telegram.org/dl/desktop/linux | sudo tar xJ -C /opt/
sudo ln -s /opt/Telegram/Telegram /usr/local/bin/telegram-desktop

Create menu entry

wget https://telegram.org/img/t_logo.png -O /usr/share/pixmaps/telegram.png

Create /usr/share/applications/telegram.desktop file with the following contents:

@oscarfonts
oscarfonts / gdal_ecw.sh
Created February 3, 2020 11:02 — forked from 1papaya/gdal_ecw.sh
Install GDAL 2.3 with ECW support on Ubuntu 18.04
#!/bin/bash
##
## Tested on: Ubuntu 18.04 & ECW 5.4 & GDAL 2.3.1
##
## Download the ERDAS ECW JP2 SDK v5.4 Linux
## https://download.hexagongeospatial.com/downloads/ecw/erdas-ecw-jp2-sdk-v5-4-linux
## Download GDAL v2.3 Source (ex. 2.3.1)
@oscarfonts
oscarfonts / gdal_ecw.sh
Created February 3, 2020 11:02 — forked from 1papaya/gdal_ecw.sh
Install GDAL 2.3 with ECW support on Ubuntu 18.04
#!/bin/bash
##
## Tested on: Ubuntu 18.04 & ECW 5.4 & GDAL 2.3.1
##
## Download the ERDAS ECW JP2 SDK v5.4 Linux
## https://download.hexagongeospatial.com/downloads/ecw/erdas-ecw-jp2-sdk-v5-4-linux
## Download GDAL v2.3 Source (ex. 2.3.1)
@oscarfonts
oscarfonts / 34M_17.bin
Created August 15, 2018 15:03 — forked from andrewharvey/34M_17.bin
Add 3D model to a Mapbox GL JS map
This file has been truncated, but you can view the full file.