Skip to content

Instantly share code, notes, and snippets.

View diegofer's full-sized avatar

Diego Fernando Bolivar diegofer

View GitHub Profile
@postrational
postrational / gunicorn_start.bash
Last active April 4, 2024 12:48
Example of how to set up Django on Nginx with Gunicorn and supervisordhttp://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
#!/bin/bash
NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name
@ChrisCinelli
ChrisCinelli / truncText.js
Last active July 1, 2016 07:11
Javascript: Truncate a paragraph to maxLength characters. It does not break a single words. ellipseText is optional (default: … ) It will not work on characters that are not a letter A-Z or number. It backtracks until there is a space and add the ellipseText.
function truncText (text, maxLength, ellipseText){
ellipseText = ellipseText || '…';
if (text.length < maxLength)
return text;
//Find the last piece of string that contain a series of not A-Za-z0-9_ followed by A-Za-z0-9_ starting from maxLength
var m = text.substr(0, maxLength).match(/([^A-Za-z0-9_]*)[A-Za-z0-9_]*$/);
if(!m) return ellipseText;
@mhulse
mhulse / admin.py
Created September 6, 2011 04:33
Django google maps v3 snipplet [via] admin example (tested in Django 1.4.x)
from django.contrib import admin
from myapp.models import Foo
from myapp.forms import FooForm
class FooAdmin(admin.ModelAdmin):
form = FooForm
prepopulated_fields = { 'slug': ['title'] }