Skip to content

Instantly share code, notes, and snippets.

View igorbrigadir's full-sized avatar

Igor Brigadir igorbrigadir

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@igorbrigadir
igorbrigadir / snowflake.py
Created February 26, 2019 16:41
Extract Tweet ID components
#!/usr/bin/env python3
# This small script shows how to deconstruct a Twitter tweet id into its
# various components. The tweet_components method accepts a tweet id and
# returns a dict object with key / values representing the various
# components of a tweet id. Each component has its own method detailing
# how values are extracted from the tweet id.
def melt_snowflake(snowflake_id):
"""return tuple of snowflake components given a tweet id"""
{"help":{},"notifications":{},"search":{},"user":{},"about":{},"activity":{"list":[{"id":"58e254099261d229616c2846","api":{"privacy":"public","created_at":"2016-06-09T12:41:46.586Z","logo":"https://web.archive.org/web/20170423142454/https://c.hitchhq.net/-/logos/5853d667dc99eb000f4f05d6","name":"Twitter","slug":"twitter","published":true,"owner":"hitch","media_type":"api","capabilities":["support","web-assistant"],"assistant_token":"d8a799cc09fd290dcf8e2d31c587264f383aef33078cb9f3a6a21dd4eed89044","machine_readable_url":"https://web.archive.org/web/20170423142454/https://trello-attachments.s3.amazonaws.com/5841a5a6e86182bb8a4f2bb8/58987c5306ed9f47815c036c/696a4365bdb0a4f676b2eca8c9561f24/twitter.json","website":"https://web.archive.org/web/20170423142454/https://dev.twitter.com/","id":"5759640a27ae7e100025908a","description":"Real-time information network.","team":""},"activity":{"name":"GET accounts/:account_id/features Twitter Developers","published":"2017-04-03T13:51:35.841Z","url":"https://web.archive.or
{
"created_at": "Mon Sep 27 19:06:05 +0000 2010",
"id": 25712847277,
"id_str": "25712847277",
"text": "This Tweet from @benshapiro has been withheld in Germany, France based on local law(s). Learn more.",
"truncated": false,
"entities": {
"hashtags": [],
"symbols": [],
"user_mentions": [],
@igorbrigadir
igorbrigadir / 169006017261219840.json
Last active February 12, 2019 16:05
Suspicious Verified Accounts
{
"created_at": "Mon Feb 13 10:32:29 +0000 2012",
"id": 169006017261219840,
"id_str": "169006017261219840",
"text": "RT @SivartDeshawn: Jada Pinkett in \"A Low Down Dirty Shame\"...haha love her.",
"truncated": false,
"entities": {
"hashtags": [],
"symbols": [],
"user_mentions": [],
{
"created_at": "Mon Feb 13 10:32:29 +0000 2012",
"id": 169006017261219840,
"id_str": "169006017261219840",
"text": "RT @SivartDeshawn: Jada Pinkett in \"A Low Down Dirty Shame\"...haha love her.",
"truncated": false,
"entities": {
"hashtags": [],
"symbols": [],
"user_mentions": [],
{
"created_at": "Thu Mar 15 23:17:12 +0000 2018",
"id": 974424304560590848,
"id_str": "974424304560590848",
"text": "RT @abinneheet: @twcdaveschwartz القصيم كنز يبحث عن من يكتشفه وسمو امير المنطقة المحبوب الامير الدكتور فيصل بن مشعل اكبر داعم وصانع للفرص ب…",
"truncated": false,
"entities": {
"hashtags": [],
"symbols": [],
"user_mentions": [
# [How to add an image to a gist](https://remarkablemark.org/blog/2016/06/16/how-to-add-image-to-gist/)
1. Create or find a [gist](https://gist.github.com) that you own.
2. Clone your gist (replace `<hash>` with your gist's hash):
```sh
# with ssh
git clone [email protected]:<hash>.git mygist
# with https
git clone https://gist.github.com/<hash>.git mygist
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
@igorbrigadir
igorbrigadir / user_timeline_520942405.json
Created January 13, 2017 22:14
Tweets from the twitter user with impossible spaces and % in their screen name: https://api.twitter.com/1.1/statuses/user_timeline.json?count=200&user_id=520942405
[
{
"created_at": "Thu Jul 25 14:30:36 +0000 2013",
"id": 360406734927433700,
"id_str": "360406734927433730",
"text": "#",
"truncated": false,
"entities": {
"hashtags": [],
"symbols": [],