Skip to content

Instantly share code, notes, and snippets.

from twython import Twython
twitter = Twython(APP_KEY, APP_SECRET,
OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
#Courtesy of https://gist.github.com/videlais/10d2e4648c7429cbb55b/
import tweepy
class TwitterAPI:
def __init__(self):
consumer_key = ""
consumer_secret = ""
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
access_token = ""
access_token_secret = ""
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
import pandas as pd
import numpy as np
iris = load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)
df['is_train'] = np.random.uniform(0, 1, len(df)) <= .75
df['species'] = pd.Categorical.from_codes(iris.target, iris.target_names) #change from pd.Factor(), which has been deprecated
df.head()
@richarddunks
richarddunks / key_setup.sh
Created March 7, 2023 03:23 — forked from datapolitan/key_setup.sh
Multiple keys for Github account
#create an ssh key for the second account
ssh-keygen -t rsa -C "your_email@youremail.com"
#when prompted, make sure you name the file something other than the default
#"Enter file in which to save the key (/Users/you/.ssh/id_rsa): /Users/you/.ssh/id_rsa2"
#add the second key to the ssh agent
ssh-add ~/.ssh/id_rsa2
#copy public key to the clipboard
cd ~/.ssh/
touch config
@richarddunks
richarddunks / ssh_config_example.sh
Created March 7, 2023 03:23 — forked from datapolitan/ssh_config_example.sh
Example SSH config file
#user1 account
Host github.com-user1
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
#user2 account
Host github.com-user2
HostName github.com
User git
git remote set-url origin git@github.com:user1/your-repo-name.git
@richarddunks
richarddunks / example_git_remote_alias.sh
Created March 7, 2023 03:23 — forked from datapolitan/example_git_remote_alias.sh
replacing host in git remote command
git remote set-url origin git@github.com-user1:user1/your-repo-name.git
@richarddunks
richarddunks / cartodb_template.html
Created March 7, 2023 03:22 — forked from datapolitan/cartodb_template.html
A template for getting started integrating CartoDB into your interactive web mapping project.
<!DOCTYPE html>
<!-- Based on an example from Chris Whong's class on creating a basic interactive map with JavaScript. See the CartoDB Academy for a step-by-step tutorial: http://docs.cartodb.com/tutorials/create_map_cartodbjs.html -->
<html>
<head>
<title>Your Title Here</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
@richarddunks
richarddunks / load_dmp_2_cartodb.sh
Created March 7, 2023 03:21 — forked from datapolitan/load_dmp_2_cartodb.sh
Use Postgres dump files to populate CartoDB instance
#!/bin/bash
#------------------------------------------------------------
# We assume the dump files have been generated using pg_dump:
#
# pg_dump -a --column-inserts -x -O -t table_name database_name -f /tmp/dmp_file_name
#
#------------------------------------------------------------
# Provide details of your CartoDB account: