Skip to content

Instantly share code, notes, and snippets.

####
# Get tweepy set up
import tweepy
from tweepy import Cursor
consumer_key="change-me"
consumer_secret="change-me"
access_token="change-me"
access_token_secret="change-me"
@rachelmyers
rachelmyers / Chromebook_setup.md
Last active October 19, 2024 04:52
How I set up my Chromebooks' dev environment

Chromebook Setup Options

Option 1: Stay in Chrome OS

If you're writing bare-bones javascript for the browser, creating Chrome Apps and Extensions, or using remote coding apps like cloud9, Koding, or Nitrous, you may not need to install Ubuntu. Some tutorials can be done entirely within the browser. The tradeoff is that you won't have a full-featured command line, and you may hit a point where you can't install something that you need.

To start coding within Chrome OS, install Text or Caret as a text editor. (Text stores files in Google Docs and Caret stores the files locally on your machine, which may help you choose.) After that, you're good to go, since Chromebooks come with a browser installed.

Optio

from gensim import models
sentence = models.doc2vec.LabeledSentence(
words=[u'so`bme', u'words', u'here'], tags=["SENT_0"])
sentence1 = models.doc2vec.LabeledSentence(
words=[u'here', u'we', u'go'], tags=["SENT_1"])
sentences = [sentence, sentence1]
class LabeledLineSentence(object):
@rothnic
rothnic / collect_articles.py
Created September 25, 2015 00:42
Asyncio with ProcessPool to collect and process data about urls, using Newspaper
"""Collect article metadata and associate it with url dimension.
Currently the url dimension includes a domain and url, but there is
a higher level grouping that we care about. What is the outlet,
who authored the article, what kind of site is it, when was
it published, etc.
"""
import os
var map = function() {
var summary = this.message_soup_text;
if (summary) {
// quick lowercase to normalize per your requirements
summary = summary.toLowerCase().split(" ");
for (var i = summary.length - 1; i >= 0; i--) {
// might want to remove punctuation, etc. here
if (summary[i]) { // make sure there's something
emit(summary[i], 1); // store a 1 for each word
}
@hwaldstein
hwaldstein / TwitterScraper.py
Last active May 3, 2020 23:00
An updated version of https://gist.github.com/JnBrymn/6f84d42dc6ac5e251047 which uses tweepy and py2neo to scrape information from Twitter into a neo4j database. Verified to work with version 2.x of neo4j and python 3.4. Exact reproduction of each function's actions from the original file is not guaranteed, but was the intent.
import time
import sys
####
# Get tweepy set up
import tweepy
from tweepy import Cursor
consumer_key=""
consumer_secret=""
@tokestermw
tokestermw / preprocess-twitter.py
Last active January 2, 2023 07:16
Python version of Ruby script to preprocess tweets for use in GloVe featurization http://nlp.stanford.edu/projects/glove/
"""
preprocess-twitter.py
python preprocess-twitter.py "Some random text with #hashtags, @mentions and http://t.co/kdjfkdjf (links). :)"
Script for preprocessing tweets by Romain Paulus
with small modifications by Jeffrey Pennington
with translation to Python by Motoki Wu
Translation of Ruby script to create features for GloVe vectors for Twitter data.
@timothyrenner
timothyrenner / tweet_utils.py
Last active July 29, 2021 22:32
Python Utilities for Tweets
from datetime import datetime
import string
from nltk.stem.lancaster import LancasterStemmer
from nltk.corpus import stopwords
#Gets the tweet time.
def get_time(tweet):
return datetime.strptime(tweet['created_at'], "%a %b %d %H:%M:%S +0000 %Y")
@rtt
rtt / tinder-api-documentation.md
Last active August 6, 2025 20:54
Tinder API Documentation

Tinder API documentation

Note: this was written in April/May 2014 and the API may has definitely changed since. I have nothing to do with Tinder, nor its API, and I do not offer any support for anything you may build on top of this. Proceed with caution

http://rsty.org/

I've sniffed most of the Tinder API to see how it works. You can use this to create bots (etc) very trivially. Some example python bot code is here -> https://gist.github.com/rtt/5a2e0cfa638c938cca59 (horribly quick and dirty, you've been warned!)

@lucasmcastro
lucasmcastro / mongoloide
Created March 20, 2014 00:40
mongo + pymongo + mongolab
>>> from pymongo import MongoClient
>>> import datetime
post = {"author": "Mike","text": "My first blog post!","tags": ["mongodb", "python", "pymongo"], "date": datetime.datetime.utcnow()}
>>> uri = "mongodb://pyladies:[email protected]:27167/series4ladies"
>>> client = MongoClient(uri)
>>> client
MongoClient('dbh16.mongolab.com', 27167)
>>> client.series4ladies
Database(MongoClient('dbh16.mongolab.com', 27167), u'series4ladies')
>>> db = client.series4ladies