python3 -m pip install awscli python3 -m awscli configure # Get key from IAM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import time | |
MY_API_KEY = 'xxxx11234789012347891023478xxxxx' | |
def get_articles(api_key, category): | |
for i in range(0, 5): | |
url = 'http://api.nytimes.com/svc/search/v2/articlesearch.json' | |
url += '?/api-key=%s&fq=news_desk:("%s")&page=%s' % (api_key, category, i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Clean out the build/ directory. | |
* | |
* npm run clean | |
*/ | |
const fs = require('fs'); | |
const path = require('path'); | |
let buildDir = "build"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from flask import Flask, render_template | |
from picamera import PiCamera, Color | |
BASE_DIR = '/home/pi/pycammy' | |
app = Flask(__name__) | |
camera = PiCamera() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Take a picture with the Pi camera | |
# Set this script to run on a cron job | |
# crontab -e | |
# Every 5th minute | |
# */5 * * * /home/pi/timelapse_scripts/take_pic.sh 2>&1 | |
DATE=`date '+%Y-%m-%d-%H-%M-%S'` | |
echo "$DATE [*] Taking picture" | |
raspistill -o /home/pi/Pictures/image-${DATE}.jpg | |
DATE=`date '+%Y-%m-%d-%H-%M-%S'` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copy_recursive.py | |
import os | |
import shutil | |
import sys | |
from pathlib import Path | |
def copy_recursive(source_base_path, target_base_path): | |
""" | |
Copy a directory tree from one location to another. This differs from shutil.copytree() that it does not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires all 4 of the REST modules to be turned on | |
# HAL | |
# HTTP Basic Authentication | |
# RESTful Web Services | |
# Serialization | |
import requests | |
import json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See which packages take up the most space | |
rpm -qa --queryformat '%10{size} - %-25{name} \t %{version}\n' | sort -n | |
# or simply | |
rpm -qa --queryformat '%{size} %{name}\n' | sort -n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# local_play.yaml | |
- name: Local play | |
hosts: localhost | |
connection: local | |
tasks: | |
- name: Create a text file | |
command: touch test.txt | |
- name: Rename the file | |
command: mv test.txt test.md |