Skip to content

Instantly share code, notes, and snippets.

@rouge8
rouge8 / README.md
Last active December 9, 2015 22:48
Circles

Just some random circles.

Click to make them disappear! Or add more!

@rouge8
rouge8 / index.html
Last active December 12, 2015 00:39
<!DOCTYPE html>
<html lang="en">
<head>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.2.2/bootstrap.min.js"></script>
<style type="text/css">
.row-fluid > .sidebar {
width: 280px;
position: absolute !important;
@rouge8
rouge8 / filters.py
Last active December 14, 2015 23:39
active links
from django import template
register = template.Library()
@register.filter
def startswith(value, arg):
"""Usage, {% if value|starts_with:"arg" %}"""
return value.startswith(arg)
@rouge8
rouge8 / README.md
Last active December 16, 2015 10:49
vim formula that uses homebrew python
  1. Install Python

    brew install python --framework
    
  2. Link /usr/local/lib/python2.7/config

    ln -s /usr/local/Cellar/python/2.7.4/Frameworks/Python.framework/Versions/Current/lib/python2.7/config /usr/local/lib/python2.7/config
    
@rouge8
rouge8 / fields.py
Created April 23, 2013 16:28
Django REST Framework JSON Field
import json
from rest_framework import serializers
class JSONField(serializers.WritableField):
def to_native(self, obj):
return json.dumps(obj)
def from_native(self, value):
return json.loads(value)
@rouge8
rouge8 / fields.py
Created April 25, 2013 21:23
Django REST Framework DictField
from ast import literal_eval
class DictField(serializers.WritableField):
type_name = 'DictField'
def from_native(self, value):
if isinstance(value, basestring):
try:
value = literal_eval(value)
except SyntaxError:
class LatestVersionManager(models.Manager):
"""
Return only the latest version of each model in its default query set.
Subclasses must define `version` and `id`.
"""
version = 'version'
id = '_id'
def get_query_set(self):
@rouge8
rouge8 / example.js
Last active December 18, 2015 00:58
angular.module('plunker', ['ui.bootstrap']);
var PaginationDemoCtrl = function ($scope, $location) {
$scope.numPages = 7;
console.log('page should be', $location.search().page);
$scope.currentPage = $location.search().page;
};
  1. First, you're going to create a new branch to track the new feature. First, sync up to make sure your local copy has the latest production version of the website:

$ cd ~/git/project $ git fetch origin $ git checkout staging $ git reset --hard origin/staging


Then create the new feature branch:
@rouge8
rouge8 / conftest.py
Created August 1, 2013 18:47
py.test selenium fixtures
import os
import pytest
from selenium import webdriver
browsers = {
'firefox': webdriver.Firefox,
'chrome': webdriver.Chrome,
}
@pytest.fixture(scope='session', params=browsers.keys())