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: sudo apt-get install mencoder | |
# To set it up to run on a cron job once per day at 5am: | |
# crontab -e | |
# 0 5 * * * /home/pi/timelapse_scripts/stitch_video.sh | |
DATE=`date '+%Y-%m-%d %H:%M:%S'` | |
echo "$DATE [*] Creating timelapse video" | |
cd /home/pi/Pictures | |
ls *.jpg > image_list.txt |
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
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
/** | |
* 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 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
require 'selenium-webdriver' | |
browser = Selenium::WebDriver.for :firefox | |
# Load a page | |
begin | |
browser.navigate.to 'http://www.devdungeon.com' | |
rescue | |
puts 'Error loading page.' | |
end |
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
#is_jpeg.py - Does the file have a JPEG binary signature? | |
import sys | |
import binascii | |
jpeg_signatures = [ | |
binascii.unhexlify(b'FFD8FFD8'), | |
binascii.unhexlify(b'FFD8FFE0'), | |
binascii.unhexlify(b'FFD8FFE1') | |
] |
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
# find_ascii_in_binary.py - Identify ASCII characters in binary files | |
import sys | |
from functools import partial | |
chunk_size = 1 | |
with open(sys.argv[1], 'rb') as in_file: | |
for data in iter(partial(in_file.read, chunk_size), b''): | |
x = int.from_bytes(data, byteorder='big') | |
if (x > 64 and x < 91) or (x > 96 and x < 123) : |
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
# create_stego_zip_jpg.py - Hide a zip file inside a JPEG | |
import sys | |
# Start with a jpeg file | |
jpg_file = open(sys.argv[1], 'rb') # Path to JPEG | |
jpg_data = jpg_file.read() | |
jpg_file.close() | |
# And the zip file to embed in the jpeg |