Skip to content

Instantly share code, notes, and snippets.

@atiw003
atiw003 / gist:1075178
Created July 11, 2011 01:19 — forked from issackelly/gist:1075119
Show method_decorator on a Class Based View
from django.utils.decorators import method_decorator
from django.views.generic.base import TemplateView
from django.contrib.auth.decorators import login_required
class MaiView(TemplateView):
template_name = "mai/view.html"
@method_decorator(login_required)
def dispatch(self, request, *args, **kwargs):
@atiw003
atiw003 / node-and-npm-in-30-seconds.sh
Created August 8, 2011 08:08 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@atiw003
atiw003 / nginx-font-serving
Created August 8, 2011 14:57 — forked from sideshowcoder/nginx-font-serving
Nginx header write for serving fonts to firefox cross domain
For nginx,
location ~* \.(eot|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
Or better way inside virtual host location use,
Inside location use
if ($request_filename ~* ^.?/([^/]?)$)
@atiw003
atiw003 / crunchbase-api-v1.md
Created September 21, 2011 07:10 — forked from dominicsayers/crunchbase-api-v1.md
CrunchBase API v1

CrunchBase API v1 Documentation

Overview

The CrunchBase API provides JSON representations of the data found on CrunchBase. The API currently supports three actions: "show", "search", and "list", which are each described below.

The v/1/ components of the URLs below refer to the current version of the API, which is 1.

@atiw003
atiw003 / bootstrap.sh
Created October 27, 2011 03:10 — forked from anonymous/bootstrap.sh
Django on Heroku with Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
@atiw003
atiw003 / Scala.tmLanguage
Created November 2, 2011 13:20 — forked from jdegoes/Scala.tmLanguage
Scala syntax file for Sublime Text 2.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>scala</string>
</array>
<key>foldingStartMarker</key>
<string>/\*\*|\{\s*$</string>
@atiw003
atiw003 / tastypie_resource.py
Created November 7, 2011 01:34
Example of a custom django-tastypie Resource
from tastypie import fields
from tastypie.authentication import Authentication
from tastypie.authorization import Authorization
from tastypie.bundle import Bundle
from tastypie.exceptions import NotFound
from tastypie.resources import Resource
# a dummy class representing a row of data
class Row(object):
@atiw003
atiw003 / bootstraped-tumblr-theme.html
Created December 6, 2011 09:22 — forked from quickredfox/bootstraped-tumblr-theme.html
bootstrap tumblr theme for quickredthought.tumblr.com
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{Title}</title>
<link rel='icon' href='{Favicon}'>
<link rel='shortcut icon' href='{Favicon}'>
<link rel='alternate' type='application/rss+xml' href='{RSS}'>
<meta name='description' content='{MetaDescription}'>
<meta name='color:Link' content='#6699cc'>
@atiw003
atiw003 / list_repo_issues.py
Created December 8, 2011 18:41 — forked from deeplook/list_repo_issues.py
List number of issues for project repositories on BitBucket or GitHub.
#!/usr/bin/env python
"""List number of issues for project repositories on BitBucket or GitHub.
This will list the number of issues for public repositories of a given
member with a URL like https://github.com/okfn or https://github.com/okfn.
It was written with the idea of getting insight quickly into the "issue
activity" of all projects of a repository owner.
This script uses a really simple HTML scraping approach. For anything
@atiw003
atiw003 / test-coverage.py
Created December 17, 2011 16:15 — forked from acdha/test-coverage.py
A custom Django test runner with support for coverage.py and graceful handling for app selection and various testing gotchas
#!/usr/bin/env python
"""
Run Django Tests with full test coverage
This starts coverage early enough to get all of the model loading &
other startup code. It also allows you to change the output location
from $PROJECT_ROOT/coverage by setting the $TEST_COVERAGE_OUTPUT_DIR
environmental variable.
"""