Skip to content

Instantly share code, notes, and snippets.

View littlepea's full-sized avatar

Evgeny Demchenko littlepea

View GitHub Profile
class memorize(dict):
def __init__(self, func):
self.func = func
def __call__(self, *args):
return self[args]
def __missing__(self, key):
self[key] = self.func(*key)
return self[key]
@littlepea
littlepea / crud-test.md
Created October 28, 2015 02:58
This test is for a simple Django CRUD views to add, edit and display tour leaders.

Tour Lead CRUD Test

Overview

This test is for a simple Django CRUD views to add, edit and display tour leaders.

UI mockup is in crud-test.html.

Just implement as much functionality as you can in a time-box of 2 hours focusing fist on quality rather than quantity.

@littlepea
littlepea / evernote-clearly.css
Last active October 27, 2015 03:18 — forked from Edditoria/evernote-clearly.css
Customized CSS theme for the Evernote Clearly browser extension based on Notable with XL font size
/**
* CSS theme for the Clearly browser extension by Evernote.
* See: www.evernote.com/clearly/
*
* Options used alongside this CSS:
* Body font: "Adelle", Georgia, 微軟正黑體, Helvetica, Arial, sans-serif
* Header font: Soho-condensed, PT Serif, 微軟正黑體, Helvetica
* Monospace font: 微軟正黑體Mono, Inconsolata, Consolas, Droid Sans Mono
* Background: #FFFFFF
* Foregound: #333333
@littlepea
littlepea / proxy.py
Created July 29, 2013 11:28
Get a random proxy from a cached remote list
import random
import urllib2
import os
from django.conf import settings
from django.core.cache import cache
""" JS to get proxies from http://hidemyass.com/proxy-list/
arr = []
Here's a telnet attempt:
$ telnet heroku.com 22
Trying 50.19.85.154...
Trying 50.19.85.156...
Trying 50.19.85.132...
telnet: Unable to connect to remote host: Connection timed out
Same for GitHub (no problem):
@littlepea
littlepea / README.rst
Last active December 16, 2015 11:39
How to quick start your GoScale CMS Project using bootstrap template: http://littlepea12.tumblr.com/post/48512420391/how-to-quick-start-your-goscale-cms-project-using

I've created a very handy GoScale CMS bootstrap template for quick and easy creation of new CMS projects.

It is a template project for GoScale CMS (GitHub repository).

If you start your Django project from this template you'll have a boostraped ready to go CMS installation that you can immediately run and build your project based on!

How to install

Change project_name to your actual project name.

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
@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>
@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 / munin.rst
Last active April 18, 2019 06:08
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 ''''''''''''' :