Skip to content

Instantly share code, notes, and snippets.

@derekkwok
derekkwok / encode.py
Last active December 5, 2020 12:14
Simple python script to encode videos using ffmpeg
"""
This python script encodes all files that have the extension mkv in the current
working directory.
Sources:
http://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide
"""
import subprocess, os
#-------------------------------------------------------------------------------
@derekkwok
derekkwok / storage.py
Created November 29, 2012 07:47
A subclass of FileSystemStorage that checks if content.file has attribute 'temporary_file_path'
import errno, os
from django.conf import settings
from django.core.files import locks
from django.core.files.move import file_move_safe
from django.core.files.storage import FileSystemStorage
class CustomStorage(FileSystemStorage):
"""
This storage class tries to move files instead of copy when saving via
@derekkwok
derekkwok / async-server.py
Created February 2, 2016 19:36
Python 3.5 async "Hello World" server
import asyncio
import socket
SERVER_ADDRESS = (HOST, PORT) = '', 8888
REQUEST_QUEUE_SIZE = 5
http_response = b"""\
HTTP/1.1 200 OK
Hello, World!
"""
@derekkwok
derekkwok / encode.go
Last active December 17, 2015 09:49
This is the Go version of encode.py written for Windows 7
// This is a go script that encodes all files with mkv extension in the current
// working directory.
//
// NOTE: To use this script on Windows, you must download the fontconfig file
// which can be found at:
// http://ffmpeg.zeranoe.com/forum/viewtopic.php?f=10&t=318&start=10
//
//
// Sources:
// http://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide