Skip to content

Instantly share code, notes, and snippets.

View seanmavley's full-sized avatar

KhoPhi seanmavley

View GitHub Profile
@seanmavley
seanmavley / Material Design'ish Hover & Click Effect.markdown
Created July 8, 2015 23:30
Material Design'ish Hover & Click Effect
@seanmavley
seanmavley / gunicorn.conf
Last active August 29, 2015 14:23
Gunicorn Conf in 'The Trio'
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 / FlatPage with Ckeditor
Created June 16, 2015 22:08
Add RichTextField from ckeditor to your FlatPages
# 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 / Optimize via Nginx
Last active August 29, 2015 14:21
Optimize content delivery 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 / Nginx working conf
Created May 13, 2015 22:30
If it works... Keep it!
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 / admin.py
Last active August 29, 2015 14:20 — forked from elidickinson/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 / gist:4076fe6908b0c9b89dcb
Created April 29, 2015 00:41
Simulate Production Server on Local PC, Django-Nginx
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 {
# models.py
from django.db import models
class Recipe(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
class Ingredient(models.Model):
@seanmavley
seanmavley / fields.py
Last active August 29, 2015 14:19 — forked from chriskief/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)
# 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