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
#!/usr/bin/env bash | |
# memusg -- Measure memory usage of processes | |
# Usage: memusg COMMAND [ARGS]... | |
# | |
# Author: Jaeho Shin <[email protected]> | |
# Created: 2010-08-16 | |
############################################################################ | |
# Copyright 2010 Jaeho Shin. # | |
# # | |
# Licensed under the Apache License, Version 2.0 (the "License"); # |
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
"""Multisite - individual site for request""" | |
from django.conf import settings | |
from threading import local | |
def make_tls_property(default=None): | |
"""Creates a class-wide instance property with a thread-specific value.""" | |
class TLSProperty(object): | |
def __init__(self): | |
self.local = local() |
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 ldap | |
def check_credentials(username, password): | |
"""Verifies credentials for username and password. | |
Returns None on success or a string describing the error on failure | |
# Adapt to your needs | |
""" | |
LDAP_SERVER = 'ldap://xxx' | |
# fully qualified AD user name | |
LDAP_USERNAME = '%[email protected]' % username |
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
# dropping a database via pymongo | |
from pymongo import Connection | |
c = Connection() | |
c.drop_database('mydatabase') | |
# drop a collection via pymongo | |
from pymongo import Connection | |
c = Connection() | |
c['mydatabase'].drop_collection('mycollection') |
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
/* if portrait mode is detected, rotate the entire site -90 degrees to hint rotating to landscape */ | |
@media (orientation: portrait) { | |
body { | |
-webkit-transform: rotate(-90deg); | |
-moz-transform: rotate(-90deg); | |
-o-transform: rotate(-90deg); | |
-ms-transform: rotate(-90deg); | |
transform: rotate(-90deg); | |
} | |
} |
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 urlparse | |
import re | |
from django.db import models | |
from django import forms | |
def validate_youtube_url(value): | |
'''El patron lo saque de http://stackoverflow.com/questions/2964678/jquery-youtube-url-validation-with-regex''' | |
pattern = r'^http:\/\/(?:www\.)?youtube.com\/watch\?(?=.*v=\w+)(?:\S+)?$' |
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
{ | |
"firstName": "Reginald", | |
"lastName": "Fake", | |
"gender": "Male", | |
"dob":"1983-01-01", | |
"email":"[email protected]", | |
"address": { | |
"streetAddress": "21 Fake Street", | |
"city": "New York City", | |
"state": "NY", |
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
def content_add(request, template_name='content/content_add.html', extra_context=None): | |
extra_context = extra_context or {} | |
extra_context['submit'] = 'Add' | |
return content_edit(request, template_name=template_name, extra_context=extra_context) | |
def content_edit(request, content_id=None, template_name='content/content_edit.html', extra_context=None): | |
data = instance = None | |
extra_context = extra_context or {} | |
if request.method == 'POST': |
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 urlparse | |
import re | |
from django import forms | |
from django.db import models | |
from django.utils.translation import ugettext_lazy as _ | |
def validate_youtube_url(value): | |
'''El patron lo saque de http://stackoverflow.com/questions/2964678/jquery-youtube-url-validation-with-regex''' |
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 paramiko | |
import socket | |
import socks | |
# set up SOCKS proxy | |
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, proxy_details['host'], | |
proxy_details['port'], True, proxy_details['username'], | |
proxy_details['password']) | |
socket.socket = socks.socksocket |
OlderNewer