Skip to content

Instantly share code, notes, and snippets.

View hersonls's full-sized avatar

Herson Leite hersonls

View GitHub Profile
import os
import sys
INTERP = os.path.join(os.environ['HOME'], '.virtualenvs', 'project', 'bin', 'python')
if sys.executable != INTERP:
os.execl(INTERP, INTERP, *sys.argv)
sys.path.insert(1, os.getcwd()) # '[...]./'
sys.path.insert(1, os.path.join(os.getcwd(), 'project')) # '[...]/project/'
@hersonls
hersonls / placeholder_forms.py
Last active December 11, 2015 20:58
Django: How to add placeholder in Django fields
from django import forms
class PlaceholderForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(PlaceholderForm, self).__init__(*args, **kwargs)
for field in self.fields.values():
new_attrs = {
'placeholder': field.label
@hersonls
hersonls / mediagenerator_middleware.py
Created February 13, 2013 14:44
Middleware for django-mediagenerator to fix cache with development mode
from mediagenerator.settings import DEV_MEDIA_URL, MEDIA_DEV_MODE
# Only load other dependencies if they're needed
if MEDIA_DEV_MODE:
from mediagenerator.utils import _refresh_dev_names, _backend_mapping
from django.http import HttpResponse, Http404
from django.utils.cache import patch_cache_control
from django.utils.http import http_date
import time
@hersonls
hersonls / less_install.sh
Last active December 13, 2015 17:48
How to install less in DreamHost 1. Install node.js 2. Install npm 3. Install less
#!/bin/sh
git clone git://github.com/ry/node.git
cd node
./configure --prefix=~/.local/usr
make
make install
export npm_config_prefix=~/.local/usr && curl https://npmjs.org/install.sh | sh
@hersonls
hersonls / devitz2013_palestras.json
Last active December 14, 2015 13:08
#Devitz 2013 - Propostas de palestras
[
{
"tema": "Desenvolvimento mobile por onde começar?",
"autor": "Nonilton",
"objetivo": ""
},
{
"tema" : "(RWD) Responsive Web Design: Por uma interface na medida",
"autor": "Emmanuel",
"objetivo": "O objetivo seria conscientizar os novos desenvolvedores da importância do desenvolvimento responsivo e tornar claro aos que pretendem iniciar na programação web que o RWD é um caminho sem volta."
@hersonls
hersonls / dj_prod_server.sh
Last active October 22, 2021 05:02
How to install Django+Supervisor+Gunicorn+Nginx in a Ubuntu Server.Needed to adjust append settings, like append virtualenvwrapper settings in user .profile file.
#!/bin/env bash
# Update packages
apt-get update
# Installing services
echo "=============================="
echo "Install web services"
echo "=============================="
apt-get -y install nginx supervisor
from datetime import datetime
t1 = "09:30:00"
t2 = "13:45:00"
start_dt = datetime.strptime(t1, '%H:%M:%S')
end_dt = datetime.strptime(t2, '%H:%M:%S')
diff = (end_dt - start_dt)
@hersonls
hersonls / SublimeWorkflow.md
Created April 22, 2013 03:59
Markdown: Cool SublimeText Plugins

Cool sublime plugins

  • ZenCoding is now Emmet
  • Prefixr
  • AdvancedNewFile
  • SidebarEnhacements
  • SublimeLinter
  • Gist
  • DocBlockr - Only for Javascript, PHP, ActionScript, CoffeeScript, Java, Objective C, C and C++
@hersonls
hersonls / hersonls.zsh-theme
Last active December 16, 2015 14:29
ZSH: Hersonls zsh theme
#
# My new theme :D
#
PROMPT='%~ %(!.#.$) '
@hersonls
hersonls / osx_workflow.md
Last active December 16, 2015 16:10
MacOSX: Max OSX Workflow

Max OSX Workflow

Ambiente OSX

  • Melhorias no ambiente
    • Volocidade Magic Mouse

defaults write -g com.apple.mouse.scaling 2