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 channels import Group | |
from channels.sessions import channel_session | |
from channels.auth import channel_session_user_from_http, channel_session_user | |
from scraper.tasks import scrape_twitter | |
from django.conf import settings | |
import json | |
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
# Usage: | |
# $ python analyze.py somefile.txt | |
# Easy breezy. | |
import sys | |
import string | |
import operator | |
# These I just grabbed the top 50 from wikipedia: http://en.wikipedia.org/wiki/Most_common_words_in_English | |
COMMON_WORDS = 'the be to of and a in that have I it for not on with he as you do at this but his by from they we say her she or an will my one all would there their what so up out if about who get which go me'.split() |
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 import forms | |
class BootstrapCharField(forms.CharField): | |
def __init__(self, *args, **kwargs): | |
# Grab the placeholder from the kwargs if it exists | |
placeholder = kwargs.pop('placeholder') if 'placeholder' in kwargs else u'' | |
# Build all the defaults | |
super(BootstrapCharField, self).__init__(*args, **kwargs) |
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://gist.github.com/1035190 | |
# See also: Snippets 85, 240, 880 at http://www.djangosnippets.org/ | |
# | |
# Minimally, the following settings are required: | |
# | |
# SSL_ENABLED = True | |
# SSL_URLS = ( | |
# r'^/some/pattern/', | |
# ) |
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
app.post('/milestone/:action', function(req, res) { | |
// Get the action | |
if( req.params.action == 'delete' ) { | |
// Get the POST variables | |
var milestone_id = req.body.milestone_id; | |
var event_id = req.body.event_id; | |
// We need to delete the milestone |
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 urllib2 import urlopen | |
import re | |
def get_plus_ones(url): | |
""" | |
Get Google Plus ones | |
""" | |
# Build the url | |
url = 'https://plusone.google.com/_/+1/fastbutton?url=' + url |
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 scrapy.spider import BaseSpider | |
from scrapy.contrib.spiders import CrawlSpider, Rule | |
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor | |
from scrapy.http import FormRequest | |
from scrapy.selector import HtmlXPathSelector | |
from tutorial.items import GoogleItem | |
# This is the class that does work. | |
class LoginSpider(BaseSpider): | |
name = 'google-login' |