Skip to content

Instantly share code, notes, and snippets.

View LarryWachira's full-sized avatar

Lawrence Wachira LarryWachira

View GitHub Profile
@LarryWachira
LarryWachira / newssearch.py
Created February 3, 2020 19:10
Fetch recent google news articles matching a keyword
''' Script to fetch recent google news articles matching a keyword
* Utilizes Google News RSS feed
Requirements:
requests - pip install requests
newspaper - pip install newspaper3k
'''
import json
import re
@LarryWachira
LarryWachira / python_crontab.py
Last active March 17, 2021 04:31
Working with python-crontab
import os
import sys
from crontab import CronTab # naturally, this needs to be pip installed
def cronjobs(delete=False):
"""Add or remove cron jobs"""
cron = CronTab(user=True)
success_ops_comment = 'success ops weekly pending logged activities' \
@LarryWachira
LarryWachira / aliens.py
Last active October 28, 2019 10:50
A `command line application` that uses a public API that reports data on the number of people in space. One of my first lines of Python.
if answer == 'Y' or answer == 'y':
print("Well, what are you waiting for? Guess how many humans are in space right now:\n> ")
answer = input()
if answer == info["number"]:
print("Of course. Google, right? \n\n:( ")
else:
print("Wrong! There are {} people in space right now.".format(info["number"]))
print("\n That'll be one billion dollars. I'll take cash.")