Skip to content

Instantly share code, notes, and snippets.

View johndavidback's full-sized avatar
😀
Gerard Sychay's archnemesis

John David Back johndavidback

😀
Gerard Sychay's archnemesis
  • Cincinnati, Ohio
View GitHub Profile
@johndavidback
johndavidback / consumers.py
Created November 2, 2016 19:09
Basic consumers to connect, start a scraper, and that's it.
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
@johndavidback
johndavidback / analyze.py
Created August 13, 2014 14:35
A quick text analysis of the most often repeating words in a block of text
# 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()
@johndavidback
johndavidback / gist:fe17dc2a861fbf755691
Created July 17, 2014 14:38
Bootstrap Char Field for Django Form
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)
# 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/',
# )
@johndavidback
johndavidback / stupidmilestone.js
Last active December 14, 2015 02:48
Trying to remove a milestone and then the reference to the milestone from an event
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
@johndavidback
johndavidback / get_plus_ones.py
Created August 30, 2012 23:51
Get Google Plus Ones
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
@johndavidback
johndavidback / googlebiz.py
Created June 6, 2012 17:30
Google Places for Business scraper
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'