Skip to content

Instantly share code, notes, and snippets.

View chrisdev's full-sized avatar

Christopher Clarke chrisdev

View GitHub Profile
@chrisdev
chrisdev / django_project_notebook.py
Created November 20, 2012 16:57
IPython notebook extension for Django project
def setup_django_env(path):
import imp
import sys
from os.path import join
from django.core.management import setup_environ
f, filename, desc = imp.find_module('settings', [path])
project = imp.load_module('settings', f, filename, desc)
setup_environ(project)
from django.db import models
class M1(models.Model):
title = models.CharField(max_length=100)
img1 = models.ImageField(upload_to="static/")
def __unicode__(self):
return self.title
@chrisdev
chrisdev / .bash_profie
Last active August 29, 2015 13:57
A Simple OSX bash_profile
PS1='[\u@\h \W]\$ '
#better prompt for sudo
SUDO_PS1='[\u@\h \W]\$ '
export LANG="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_ALL=
## Colorize the ls output ##
alias cp='cp -iv' # Preferred 'cp' implementation
alias mv='mv -iv' # Preferred 'mv' implementation
@chrisdev
chrisdev / index.html
Last active August 29, 2015 14:03 — forked from anonymous/bGszx.markdown
Improving the UX of the submit button
UX improvement for Submitt Button
-----------------------------------
Forked from [Mark Hayes](http://codepen.io/mhayes)'s Pen [qdCAc](http://codepen.io/mhayes/pen/qdCAc/).
A [Pen](http://codepen.io/rafibomb/pen/bGszx) by [Rafi Benkual](http://codepen.io/rafibomb) on [CodePen](http://codepen.io/).
[License](http://codepen.io/rafibomb/pen/bGszx/license).
  • Update CHANGES.rst
  • Update version number in my_project/__init__.py
  • Update version number in setup.py
  • Install the package again for local development, but with the new version number:
python setup.py develop
  • Run the tests:
python setup.py test
@chrisdev
chrisdev / social-share-snippet.html
Created August 9, 2014 00:41
Social network share buttons
<section class="share">
<h4>Share this post</h4>
<div class="links">
<a class="icon-twitter-circled"
href="http://twitter.com/share?text={{title}}&url={{url absolute="true"}}"
onclick="window.open(this.href, 'twitter-share', 'width=550,height=235');return false;">
<span class="hidden">Twitter</span>
</a>
<a class="icon-facebook-circled"
@chrisdev
chrisdev / Color-Palette---Flexbox-Friday-Demo-2.markdown
Created February 13, 2015 16:53
Color Palette - Flexbox Friday Demo 2
@chrisdev
chrisdev / gist:b12bb316692cf5f0f004
Created May 19, 2015 15:56
Wagtail Adding Child pages
class TestStaticSitePaths(TestCase):
def setUp(self):
self.root_page = Page.objects.get(id=1)
# For simple tests
self.home_page = self.root_page.add_child(instance=SimplePage(title="Homepage", slug="home"))
self.about_page = self.home_page.add_child(instance=SimplePage(title="About us", slug="about"))
self.contact_page = self.home_page.add_child(instance=SimplePage(title="Contact", slug="contact"))
# For custom tests
@chrisdev
chrisdev / gist:46bf51de3919ab56b8a0
Created May 21, 2015 14:43
sent email with on mandrill with python
# install
# -------
pip install mandrill
# sending the email
# ----------
import mandrill
API_KEY = 'valid_api_key'
@chrisdev
chrisdev / email_address_extractor.py
Last active August 29, 2015 14:22
Extract email addresses from email messages via IMAPP
import imaplib, email
import getpass, imaplib, email, sets
def split_addrs(s):
#split an address list into list of tuples of (name,address)
if not(s): return []
outQ = True
cut = -1
res = []