Skip to content

Instantly share code, notes, and snippets.

View omiq's full-sized avatar

Chris Garrett omiq

View GitHub Profile
@omiq
omiq / esp32wifi.ino
Last active April 16, 2017 21:51
Connect to a website and shine an LED using ESP32
// wifi library
#include <WiFi.h>
// WiFi network name and password:
const char * networkName = "YOUR_WIFI_HERE";
const char * networkPswd = "PASSWORD_HERE";
// The domain to request from:
const char * hostDomain = "chrisg.org";
const int hostPort = 80;
@omiq
omiq / send_ip.py
Created May 2, 2017 19:23
Send IP address via Python / Mailgun
import subprocess
import requests
# load API key from file
inFile = open('/home/pi/mailgun-api.txt', 'r')
api_key = inFile.readline().rstrip()
inFile.close()
# get host and IP
this_host = subprocess.check_output("hostname", shell=True).rstrip()
@omiq
omiq / cam.sh
Created May 2, 2017 19:30
Raspberry Pi Webcam to Dropbox
#!/bin/bash
# Set the date variable to the current date and time
DATE=$(date +"%Y-%m-%d_%H%M")
# Take the picture and save with the date as filename
raspistill --rotation 270 -w 1024 -h 768 -o /home/pi/pics/$DATE.jpg
# Add the date caption
convert /home/pi/pics/$DATE.jpg -pointsize 32 -fill red -annotate +700+700 $DATE /home/pi/pics/$DATE.jpg
@omiq
omiq / push.py
Created May 2, 2017 19:43
Data.Sparkfun/Phant example
import phant
import time
log = phant.writer_factory(
'http://data.sparkfun.com/input/qwerty10987?private_key=abcdefgh12345',
key=str,
value=int
)
i = 0
@omiq
omiq / download_sets.php
Created June 23, 2017 00:42
Backup your Flickr photographs and photosets
<?php
/*
PHP SCRIPT TO BACK UP FLICKR PHOTOSETS
Arguments:
APIKEY, SECRET, FLICKER_USER
*/
@omiq
omiq / blink.py
Created September 15, 2017 02:40
Feather ESP8266 Blink example
@omiq
omiq / rando-lights
Created October 31, 2017 20:13
Random lights
void setup() {
// put your setup code here, to run once:
pinMode(A0,OUTPUT);
pinMode(A1,OUTPUT);
randomSeed(42);
}
void loop() {
// put your main code here, to run repeatedly:
int bright;
@omiq
omiq / rando_backlight.ino
Created January 23, 2018 22:12
Grove i2c LCD with random backlight colour
// libraries for i2c and the specific display
#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd;
void setup() {
// make sure the random is random
randomSeed(analogRead(0));
@omiq
omiq / thumb.py
Created January 24, 2018 20:16
How to Automagically Create Thumbnail Images Using Python
import glob
from PIL import Image
# get all the jpg files from the current folder
for infile in glob.glob("*.jpg"):
im = Image.open(infile)
# convert to thumbnail image
im.thumbnail((128, 128), Image.ANTIALIAS)
# don't save if thumbnail already exists
@omiq
omiq / discord-bot.py
Created February 18, 2018 20:22
Discord Bot
import discord
# discord client
client = discord.Client()
# create a new event
@client.event
async def on_ready():