Skip to content

Instantly share code, notes, and snippets.

View belyak's full-sized avatar

Andrey Belyak belyak

  • Russian Federation, Saint-Petersburg
View GitHub Profile
@whizkydee
whizkydee / ffmpeg.md
Created July 17, 2018 12:17 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@wolever
wolever / reverseadmin.py
Last active June 21, 2023 06:48 — forked from mzbyszewska/reverseadmin.py
Forked from https://gist.github.com/mzbyszewska/8b6afc312b024832aa85 , updated to work with Django 1.8
'''
adminreverse from here http://djangosnippets.org/snippets/2032/
changed for working with ForeignKeys
'''
'''
reverseadmin
============
Module that makes django admin handle OneToOneFields in a better way.
A common use case for one-to-one relationships is to "embed" a model
inside another one. For example, a Person may have multiple foreign
@pstoica
pstoica / OnBlurComponent.jsx
Last active August 1, 2023 21:00
onBlur for entire react element
function OnBlurComponent({ onBlur }) {
const handleBlur = (e) => {
const currentTarget = e.currentTarget;
// Check the newly focused element in the next tick of the event loop
setTimeout(() => {
// Check if the new activeElement is a child of the original container
if (!currentTarget.contains(document.activeElement)) {
// You can invoke a callback or add custom logic here
onBlur();
@syrusakbary
syrusakbary / django_efficient_queryset.py
Created December 16, 2013 05:18
Django efficient queryset iterator (by dividing in chunks). Taked from https://djangosnippets.org/snippets/1949/
import gc
def queryset_iterator(queryset, chunksize=1000):
'''''
Iterate over a Django Queryset ordered by the primary key
This method loads a maximum of chunksize (default: 1000) rows in it's
memory at the same time while django normally would load all rows in it's
memory. Using the iterator() method only causes it to not preload all the
classes.
@robcowie
robcowie / test_example.py
Created December 7, 2013 15:03
py.test fixtures for testing tornado apps
def test_root_output(client):
resp = client.fetch('/')
assert resp.code == 200
assert resp.body == 'Hello, world'
def test_async_output(client):
resp = client.fetch('/async')
assert resp.code == 200