Skip to content

Instantly share code, notes, and snippets.

View gskoljarev's full-sized avatar

Goran Školjarev gskoljarev

View GitHub Profile
@gskoljarev
gskoljarev / raw_as_qs.py
Last active March 22, 2017 13:40 — forked from carymrobbins/raw_as_qs.py
Django - Execute a raw query and return a QuerySet
from django.db import connection, models
class MyManager(models.Manager):
def raw_as_qs(self, raw_query, params=()):
"""Execute a raw query and return a QuerySet. The first column in the
result set must be the id field for the model.
:type raw_query: str | unicode
:type params: tuple[T] | dict[str | unicode, T]
:rtype: django.db.models.query.QuerySet
"""
@gskoljarev
gskoljarev / split.sh
Created July 19, 2018 15:33
Split .flac files via .cue file
shnsplit -f file.cue -t %n-%t -o flac file.flac
@gskoljarev
gskoljarev / ramerdouglaspeucker.py
Last active June 13, 2020 09:16
Python implementation of Ramer-Douglas-Peucker (RDP) algorithm; ported from JavaScript code at https://gist.github.com/msbarry/9152218; uses desired number of points instead of using a threshold.
# -*- coding: utf-8 -*-
import math
import time
def timenow():
return int(time.time() * 1000)
def sqr(x):