Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Nkansah Rexford seanmavley

🏠
Working from home
Block or report user

Report or block seanmavley

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Convert videos from terminal
# What this command literally does is this:
# It iterates through directory in which the command is executed selecting .mp4 files only
# It then runs avconv command conversion on them
# See the parameters from avconv manual for details.
for i in *.mp4; do avconv -i "$i" -c:v h264 -crf 18 -c:a mp3 -r 30 "out-$i.mp4" ; done
View fields.py
from django import forms
# import models here from django and subclass
from django.db import models
from django.template.defaultfilters import filesizeformat
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
class RestrictedFileFieldModel(models.FileField):
def __init__(self, *args, **kwargs):
self.content_types = kwargs.pop('content_types', None)
@seanmavley
seanmavley / gist:4076fe6908b0c9b89dcb
Created Apr 29, 2015
Simulate Production Server on Local PC, Django-Nginx
View gist:4076fe6908b0c9b89dcb
First all, have DEBUG = True in your settings.py
Nginx should be installed. After nginx install, restart PC, if not already.
Create a new file in /etc/nginx/sites-available/<file_name>
Put in this. I called mine noodles
/etc/nginx/sites-available/noodles
upstream app_server {
View admin.py
from django.contrib import admin
from django.contrib.flatpages.models import FlatPage
# Note: we are renaming the original Admin and Form as we import them!
from django.contrib.flatpages.admin import FlatPageAdmin as FlatPageAdminOld
from django.contrib.flatpages.admin import FlatpageForm as FlatpageFormOld
from django import forms
from ckeditor.widgets import CKEditorWidget
@seanmavley
seanmavley / Nginx working conf
Created May 13, 2015
If it works... Keep it!
View Nginx working conf
upstream app_server {
server 127.0.0.1:9000 fail_timeout=0;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
# root /usr/share/nginx/html;
root /home/portfolio;
@seanmavley
seanmavley / Optimize via Nginx
Last active Aug 29, 2015
Optimize content delivery via Nginx
View Optimize via Nginx
# This decleared upstream app_server is referenced
# below. Its a declare once, use many times kinda thing
upstream app_server {
server 127.0.0.1:9000 fail_timeout=0;
}
# server configurations begins
server {
@seanmavley
seanmavley / FlatPage with Ckeditor
Created Jun 16, 2015
Add RichTextField from ckeditor to your FlatPages
View FlatPage with Ckeditor
# Note: we are renaming the original Admin and Form as we import them!
from django.contrib.flatpages.admin import FlatPageAdmin as FlatPageAdminOld
from django.contrib.flatpages.admin import FlatpageForm as FlatpageFormOld
from django import forms
from ckeditor.widgets import CKEditorWidget
class FlatpageForm(FlatpageFormOld):
content = forms.CharField(widget=CKEditorWidget())
@seanmavley
seanmavley / gunicorn.conf
Last active Aug 29, 2015
Gunicorn Conf in 'The Trio'
View gunicorn.conf
description "Gunicorn daemon for Django project"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [!12345]
# If the process quits unexpectadly trigger a respawn
respawn
# by default DO has user django
setuid django
@seanmavley
seanmavley / datalize.py
Last active Aug 29, 2015
Data URI for template images
View datalize.py
# templatetags/dataURI.py
from mimetypes import guess_type
from django import template
from base64 import b64encode
from django.contrib.staticfiles import finders
register = template.Library()
You can’t perform that action at this time.