Skip to content

Instantly share code, notes, and snippets.

View Florents-Tselai's full-sized avatar

Florents Tselai Florents-Tselai

View GitHub Profile
@Florents-Tselai
Florents-Tselai / daily_newspapers_in_your_pocket.sh
Last active September 2, 2020 12:34
Want to have daily editions of the NYTimes, WSJ, Washington Post and the Economist daily in your Pocket ? Add this script as cron at 0 7 * * *
#!/usr/bin/env bash
for url in https://www.nytimes.com/section/todayspaper https://www.washingtonpost.com/todays_paper/updates https://economist.com https://www.wsj.com/news/types/bookshelf https://www.nytimes.com/section/books https://www.economist.com/books-and-arts/ https://newyorker.com https://theatlantic.com https://www.prospectmagazine.co.uk/category/arts-and-books https://www.washingtonpost/entertainment/books https://news.ycombinator.com/best; do
curl -L -H "Content-Type: application/json; charset=UTF-8" -H "X-Accept: application/json" \
-d "{\"url\": \"$url\", \"consumer_key\": \"$POCKET_CONSUMER_KEY\",\"access_token\": \"$POCKET_ACCESS_TOKEN\"}" \
-X POST "https://getpocket.com/v3/add"
done
# WSJ requires special care
@Florents-Tselai
Florents-Tselai / foties_tweets.py
Created July 29, 2018 14:24
Script that searches tweets written in Greek and containing specific hashtags relevant to the recent wildfires in Greece. Also outputs twitter profiles created during the last few days just to tweet those tweets [Info & context here: https://www.facebook.com/f.tselai/posts/1981587568532277 ]
import tweepy
from datetime import datetime
auth = tweepy.OAuthHandler('CONSUMER_KEY', 'CONSUMER_SECRET')
auth.set_access_token('ACCESS_TOKEN', 'ACCESS_SECRET')
api = tweepy.API(auth, wait_on_rate_limit=True)
def parse_ts(ts):
# Fundamentals
ipython
jupyter
pip
virtualenv
# Data/Scientific Related packages
pandas
numpy
scikit-learn
@Florents-Tselai
Florents-Tselai / pip_upgrade_all_parallel.sh
Created April 24, 2015 22:24
Upgrades in parallel all packages in the current python (virtual) environment
# Adapted from http://stackoverflow.com/a/3452888
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | parallel pip install -U {}
#!/usr/bin/env python
import urllib2
import re
import sys
from itertools import imap, ifilter
if __name__ == "__main__":
in_url = sys.argv[1]
current_dir = "/".join(in_url.split('/')[:-1])
all_urls = re.findall(r'href=[\'"]?([^\'" >]+)', urllib2.urlopen(in_url).read())