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
var serializer = new XMLSerializer(), | |
html = serializer.serializeToString(document); |
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
# https://warehouse.python.org/project/pypi-cli/ | |
$ sudo pypi stat tendenci-case-studies | |
Fetching statistics for 'http://pypi.python.org/pypi/tendenci-case-studies'. . . | |
Download statistics for tendenci-case-studies | |
============================================= | |
Downloads by version | |
1.0.0 13/02/25 [ 1,000 ] ******************************************* |
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
# Alternatively don't use slog but something else. I just like that more. | |
[alias] | |
slog = log --pretty=format:"%C(auto,yellow)%h%C(auto)%d\\ %C(auto,reset)%s\\ \\ [%C(auto,blue)%cn%C(auto,reset),\\ %C(auto,cyan)%ar%C(auto,reset)]" | |
addprx = "!f() { b=`git symbolic-ref -q --short HEAD` && \ | |
git fetch origin pull/$1/head:pr/$1 && \ | |
git fetch -f origin pull/$1/merge:PR_MERGE_HEAD && \ | |
git rebase --onto $b PR_MERGE_HEAD^ pr/$1 && \ | |
git branch -D PR_MERGE_HEAD && \ | |
git checkout $b && echo && \ | |
git diff --stat $b..pr/$1 && echo && \ |
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 os | |
import StringIO | |
# import the request module | |
import requests | |
from PIL import Image | |
# Storing the image URL in a constant variable | |
IMAGE_URL = 'http://www.distractify.netdna-cdn.com/wp-content/uploads/2014/08/slugsolos-1-620x.jpg' |
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 is_none(d): | |
"""Returns True if dictionary contains | |
all None type objects | |
""" | |
for i in d.itervalues(): | |
if i is not None: | |
return False | |
return True |
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
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
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.models import User | |
from django.db.models.fields import FieldDoesNotExist | |
# Used for user import feature. | |
# There's no form validation; so we validate max_length this way. | |
# loop through user properties; truncate at max_length | |
for key, value in user.__dict__.items(): | |
max_length = None | |
try: |
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.validators import email_re | |
def is_email_valid(email): | |
""" Check if valid email via Django regex """ | |
return bool(email_re.match(email)) |
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 re | |
import HTMLParser | |
from django.core.management.base import BaseCommand | |
class Command(BaseCommand): | |
""" | |
Converts title and content html entities to unicode | |
""" |
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.management import setup_environ | |
try: | |
import settings | |
except ImportError: | |
import sys | |
sys.stderr.write("Couldn't find the settings.py module.") | |
sys.exit(1) | |
setup_environ(settings) |
OlderNewer