Skip to content

Instantly share code, notes, and snippets.

View ilebedie's full-sized avatar

Ivan Lebediev ilebedie

View GitHub Profile
@ilebedie
ilebedie / chain_django_qs.py
Created August 14, 2018 14:22
Combine django querysets
def chain_qs(*querysets):
class CombinedQuerySet:
def __init__(self, *querysets):
self.qs_list = querysets
def __next__(self):
return chain(self.qs_list)
def __iter__(self):
return self
@ilebedie
ilebedie / frame_conv_numpy.py
Created October 29, 2015 16:44
Convert rgba 10bit to 8 bit, cut last vertical and horizontal lines and changing channel layout
import numpy as np
x = np.fromfile(r'1920x1080BGRA16.raw', np.uint16)
y = x/256
z= y.astype(np.uint8)
z.tofile('1920x1080BGRA.raw')
w= np.zeros((1919*1079*4), np.uint8)
for i in range(1079):
#cut with reordering BGRA -> ARGB
for j in range(1919):
w[j*4 + 1919*4*i ] = z[j*4 + 3 + 1920*4*i]
@ilebedie
ilebedie / txt
Last active October 29, 2015 10:31
ffmpeg_cheatsheet
-list all available formats
>ffmpeg -formats
-how to get aac
>ffmpeg -i e:\Tasks2\Audio_start\wombat_128.mp3 -c:adts aac -strict experimental -vbr -y e:\Tasks2\Audio_start\wombat_128.m4a
-instead of <adts> put <aac> for raw stream
>ffmpeg -i e:\Tasks2\Audio_start\wombat_128.mp3 e:\Tasks2\Audio_start\wombat_128.aac
-how to check
@ilebedie
ilebedie / stl_howto.cpp
Last active November 1, 2015 13:53
stl_howto
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <fstream>
#include <iterator>
#include <map>
#include <set>
@ilebedie
ilebedie / python_like_print.hpp
Created July 14, 2015 10:28
Python-like print in c++
#include <iostream>
using namespace std;
void print(){cout<<'\n';}
template<typename T, typename ...TAIL>
void print(const T &t, TAIL... tail)
{
cout<<t<<' ';
#define UNICODE
#include <windows.h>
#include <dbghelp.h>
#include <shellapi.h>
#include <shlobj.h>
#include <Strsafe.h>
int GenerateDump(EXCEPTION_POINTERS* pExceptionPointers)
{
BOOL bMiniDumpSuccessful;