Skip to content

Instantly share code, notes, and snippets.

View littlepea's full-sized avatar

Evgeny Demchenko littlepea

View GitHub Profile
@littlepea
littlepea / demorest - place details
Created February 22, 2012 12:29
/api/v1/places/1?lat=111&lng=111
{
"response": {
"meta": {},
"data": {
"distance": 0,
"name": "北京",
"lat": 111,
"lng": 111,
"checkins": [
{
@littlepea
littlepea / demorest - place checkin
Created February 22, 2012 12:39
/api/v1/places/1/checkin
{
"response": {
"status": "success",
"meta": {},
"data": {
"checkin": {
"time": 6,
"id": null,
"user": {
"username": "yy",
@littlepea
littlepea / kill.sh
Created February 1, 2013 07:25
shell
echo "Kill processes containing '$1'"
ps aux | grep $1 | grep -v grep | awk '{print$2}' | xargs kill -9
from fabric.api import run, local, task
@task(alias='hd')
def heroku_deploy(scale='yes', runtime='no', runtime_version=None):
"""
Deploys heroku app
Usage examples:
@littlepea
littlepea / middleware.py
Created March 9, 2013 01:47
SEO fix for Django 1.4 LocaleMiddleware based on this article: http://blog.yawd.eu/2012/impact-django-page-redirects-seo/
from django.conf import settings
from django.core.urlresolvers import is_valid_path
from django.http import HttpResponsePermanentRedirect
from django.middleware.locale import LocaleMiddleware
from django.utils import translation
from django.utils.cache import patch_vary_headers
class UpdatedLocaleMiddleware(LocaleMiddleware):
def process_response(self, request, response):
@littlepea
littlepea / munin.rst
Last active June 8, 2024 15:42
Munin setup for monitoring Django on EC2 Ubuntu instance with nginx

This is a short tutorial on setting up munin to monitor your Django website on ec2.

We're gonna be using Nginx instead of apache here because it's more lightweight and popular between Django developers.

Step by step tutorial

1. Install munin

@littlepea
littlepea / pypi_howto.rst
Last active December 15, 2015 08:58
PyPI packaging instructions
  1. Fork the repo and clone the fork into PipDiff:

    git clone git@github.com:littlepea/pipdiff.git PipDiff
    
  2. Test that the utility is working:

    cd pipdiff/
    ./pipdiff.py
    
    Django==1.4.5                            PyPI:Django==1.5
    
@littlepea
littlepea / paymo.html
Last active December 16, 2015 01:09
Paymo Timer bookmarklet
<p>Drag this bookmarklet to your bookmarks bar to install:</p>
<a href="javascript:(function start_client(){newwnd=window.open("https://app.paymo.biz/timetracker/client.html","client","height=490,width=340,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes");if(!newwnd){alert("Turn off popup blocker to access this feature")}return false})();">Paymo Timer</a>
<p>Then each time you click it a popup window will open with your timer, no need to go to Paymo website first!</p>
class Post(models.Model):
link = models.URLField(blank=True, null=True, db_index=True) # link is also unique identifier for each entry
updated = models.DateTimeField(blank=True, null=True, db_index=True) # last updated
published = models.DateTimeField(blank=True, null=True, db_index=True) #pubDate
title = models.CharField(max_length=250, blank=True, null=True) #short title, text without HTML
description = models.TextField(blank=True, null=True) #universal text/html representation of entry
class GoscaleCMSPlugin(CMSPlugin):
"""
Common base abstract class for all the GoScale plugins