Skip to content

Instantly share code, notes, and snippets.

trump = load_tweets_from_mongodb(dbname='TrumpTweets')
obama = load_tweets_from_mongodb(dbname='ObamaTweets')
def load_tweets_from_mongodb(dbname, collection='tweet'):
df = odo('mongodb://localhost/{}::{}'.format(dbname, collection),
pd.DataFrame)
df.drop(['user_id', 'usernameTweet', 'url'], axis=1, inplace=True)
df = df.replace(0, np.NAN)
df.dropna(how='any', inplace=True)
df['reply_to_retweet_ratio'] = np.divide(df['nbr_reply'],
df['nbr_retweet'])
df['reply_to_like_ratio'] = np.divide(df['nbr_reply'],
df['nbr_favorite'])
@spdustin
spdustin / refugee.md
Created February 18, 2017 23:54
Arnessa (@Rrrrnessa): How I Became a Refugee

FROM TWEETS STARTING HERE: HTTPS://TWITTER.COM/RRRRNESSA/STATUS/667019978550317056

I am going to tell you guys the process of how I became an refugee admitted to the United States of American and how long it actually is. But I'd like you to keep in mind that the process to admit Syrian refugees to the U.S.A is even more complex.

Okay so first things first you apply for refugee status with a U.N agency. The application process isn't just a piece of paper. You have to submit ALL your documents. Birth certificates, report cards from school, IDs, driver licenses, passports, old utility bills. If you're displaced, you have to provide proof that you are displaced. That your house was bombed/burned or that there are squatters in it.

You have to write down your story. All your family members do. Where you were born, where you are now, what you're doing, everything.

You have to provide them with names of ALL your family members, dead and alive. All your friends, neighbors, teachers. Everyone. You have to provide t

@spdustin
spdustin / keybase.md
Created February 11, 2017 19:03
keybase.md

Keybase proof

I hereby claim:

  • I am spdustin on github.
  • I am spdustin (https://keybase.io/spdustin) on keybase.
  • I have a public key whose fingerprint is 9B35 3773 83BE E600 AEAA 8601 95B3 F539 33A5 D864

To claim this, I am signing this object:

@spdustin
spdustin / baselineSPListRequest.js
Last active July 18, 2016 23:30
Sample (and verbose) boilerplate for accessing SharePoint list data
/**
* Note: This example is _purposefully verbose_, for ease of reading.
*
* In an ideal world, your generic function would return the list items, and
* another function would actually be enqueued in the SOD call that calls
* (in IE9) just Array.forEach() through them for one-by-one processing,
* for example. Hope this helps!
*/
// This function will console.log items from the list you specify in the
@spdustin
spdustin / README.md
Last active July 15, 2016 06:42
HN Styles

HN Styles

Just some simple CSS styles for Hacker News that I use to keep the default look and feel, but improve usability a bit.

@spdustin
spdustin / demo.scss
Created March 22, 2016 20:05
demo.scss
$bgColor: #DEDBEE;
%clear {
*zoom: 1;
&:before, &:after {
content: ' ';
display: table;
}
&:after {
clear: both;
@spdustin
spdustin / cars.xsl
Last active March 1, 2016 17:35
cars.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" />
<xsl:template match="/">
<table>
<thead>
<tr>
<th>Year</th>
<th>Make</th>
<th>Model</th>
</tr>
@spdustin
spdustin / cars.xml
Created March 1, 2016 17:25
cars.xml
<cars>
<car year="1972" make="Ford" model="Pinto" explodes="yes"/>
<car year="2016" make="Toyota" model="Prius"/>
<car year="1996" make="Nissan" model="Sentra"/>
</cars>
@spdustin
spdustin / spo_contacts.css
Last active November 19, 2015 22:26
SharePoint Online Contacts List CSS
.ms-formtable td.ms-formbody, /* cell containing all form fields */
.ms-formtable td.ms-formlabel /* cell containing all form labels */
{
display: block;
width: auto;
padding: .5em 1em;
}
.ms-formtable td * /* resize everything inside the cells */
{