Skip to content

Instantly share code, notes, and snippets.

Avatar

BBB yxy

  • gggg
View GitHub Profile
@yxy
yxy / actions.py
Created Sep 9, 2017 — forked from mgerring/actions.py
"Export to CSV" action for django admin
View actions.py
import unicodecsv
from django.http import HttpResponse
def export_as_csv_action(description="Export selected objects as CSV file",
fields=None, exclude=None, header=True):
"""
This function returns an export csv action
'fields' and 'exclude' work like in django ModelForm
'header' is whether or not to output the column names as the first row
"""
@yxy
yxy / gist:b1fd18f84a925c6afc94577dcce9c70d
Created Jul 19, 2017 — forked from ymotongpoo/gist:1342656
extract AAC audio from flv, and convert aac to mp3 using ffmpeg
View gist:b1fd18f84a925c6afc94577dcce9c70d
# using libfaac on Mac OS X 10.6.8
# -vn : not copying video
# -acodec : specify codec used in flv file
# -ac : channels. 1 is for mono, 2 is for stereo
# -ab : specify bitrate for output file (note that rate is not kbps but bps)
# -ar : sampling frequency (Hz)
# -threads: number of threads for encoding
# "-strict experimental" is necessary to use libfaac
ffmpeg -y -i xxxxxxxxxxx.flv -vn -acodec aac -ac 2 -ab 128000 -ar 44100 -threads 4 -strict experimental xxxxx.m4a
@yxy
yxy / sample_usage.py
Created Jun 24, 2016 — forked from luke14free/sample_usage.py
Simple type checked objects in Python
View sample_usage.py
#!/usr/bin/env python
from type_checked_entities import entity_factory
Giraffe = entity_factory( # let's define what is a giraffe!
"giraffe",
name=str, # my name is a string
age=float, # my age is an int
eats=object, # I eat pretty much everything.
)
@yxy
yxy / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console