This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from BeautifulSoup import BeautifulSoup | |
import urllib2 | |
import re | |
def grab_apple_icon(url): | |
def scrape(url): | |
print 'start scrape '+url | |
#scrape page for link rel to icon | |
#fake iphone user agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{HTTP_HOST} !blog.nickserra.com$ [NC] | |
RewriteRule ^(.*)$ http://blog.nickserra.com/$1 [L,R=301] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import Client | |
import simplejson as json | |
class JsonBaseClient(Client): | |
""" | |
Add content_json to response object from client. | |
""" | |
def get(self, path, data={}, **extra): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.cache import cache | |
from tastypie.resources import ModelResource | |
class ResponseCacheResource(ModelResource): | |
""" | |
Tastypie response cached resource. | |
Caches full responses on detail and list views | |
using Resource.Meta.cache_key. | |
Does no invalidation, just quick raw caching |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.cache.backends.memcached import BaseMemcachedCache | |
class UltraMemcachedCache(BaseMemcachedCache): | |
"An implementation of a cache binding using python-ultramemcached" | |
def __init__(self, server, params): | |
import ultramemcache | |
super(MemcachedCache, self).__init__(server, params, | |
library=ultramemcache, | |
value_not_found_exception=ValueError) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[ok] => ASSEMBLY_COMPLETED | |
[message] => The assembly was successfully completed. | |
[assembly_id] => 30c97c5886ea629c7a2b3924b11aa658 | |
[assembly_url] => http://api2.mahek.transloadit.com/assemblies/30c97c5886ea629c7a2b3924b11aa658 | |
[bytes_received] => 27903 | |
[bytes_expected] => 27903 | |
[client_agent] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17 | |
[client_ip] => 127.0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# grab vim plugins and write .vimrc | |
# this will probably overwrite current vim setup | |
# curl https://gist.githubusercontent.com/nicholasserra/4999143/raw/6e2fab00a9f39f659e3cfc39e26d997e3299eaeb/vim.sh | bash | |
echo "Make .vim dir structure" | |
mkdir -p ~/.vim/autoload ~/.vim/bundle; | |
echo "Grab vim-pathogen" | |
curl -Sso ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import threading | |
import base64 | |
from django.core.mail.backends.base import BaseEmailBackend | |
class EmailBackend(BaseEmailBackend): | |
def __init__(self, *args, **kwargs): | |
self.stream = kwargs.pop('stream', sys.stdout) | |
self._lock = threading.RLock() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.hashers import BasePasswordHasher | |
from django.utils.crypto import constant_time_compare | |
from django.utils.translation import ugettext_noop as _ | |
from django.utils.datastructures import SortedDict | |
class DummyPasswordHasher(BasePasswordHasher): | |
""" | |
A dummy plaintext password hashing algorithm (not recommended) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.staticfiles.urls import staticfiles_urlpatterns | |
urlpatterns = patterns('', | |
url(r'^admin/', include(admin.site.urls)), | |
url(r'^api/', include(v1_api.urls)) | |
) | |
#Use django to serve static when in development environment. | |
urlpatterns += staticfiles_urlpatterns() |
OlderNewer