Skip to content

Instantly share code, notes, and snippets.

View omiq's full-sized avatar

Chris Garrett omiq

View GitHub Profile
@omiq
omiq / readability.py
Last active February 19, 2018 19:33
Readability
# these modules help us do the script
import html2text
import requests
import sys
# this is the important library that acutally does the work
from textstat.textstat import textstat
# this is an easy way to strip html
h = html2text.HTML2Text()
@omiq
omiq / bookmark-bot.py
Created February 21, 2018 21:03
Discord bookmark bot
import os
import sys
import discord
import subprocess
# discord client
client = discord.Client()
def process_message(message):
@omiq
omiq / readability.py
Created February 24, 2018 20:23
Version 2 - readability from a text file
# these modules help us do the script
import html2text
import requests
import sys
# this is the important library that acutally does the work
from textstat.textstat import textstat
with open('testfile.txt', 'r') as content_file:
test_string = content_file.read()
@omiq
omiq / upload-wp-image.py
Created March 20, 2018 18:17
Upload images to WordPress and copy web URL to clipboard
import sys
import os
import requests
import pyperclip
# did the user supply an image file?
if len(sys.argv) == 2:
image = sys.argv[1]
else:
input("You must supply an image file!")
@omiq
omiq / gyro.py
Created March 22, 2018 17:33
Example of using Grove sensors, displays and buttons with Python on Raspberry Pi
from LSM6DS3 import *
from time import sleep
from grove_rgb_lcd import *
import grovepi
# this is the chip the sensor is based on
mySensor = LSM6DS3()
# two buttons attached to digital 3 and 4
grovepi.pinMode(3, "INPUT")
@omiq
omiq / menu.py
Created March 26, 2018 18:30
A Raspberry Pi/Linux Start Menu
import os
import readchar
# place in your start up file:
# sudo nano ./.bashrc
def menu():
while True:
os.system('clear')
@omiq
omiq / serial.py
Created March 27, 2018 23:35
Example of sending strings to Arduino over USB
import serial
import time
from datetime import datetime
print("Starting ...")
# change the port to whichever shows in Arduino
tardis = serial.Serial('/dev/ttyACM0', baudrate=9600)
while(1):
@omiq
omiq / serial.c
Created March 27, 2018 23:38
Arduino example of listening for strings over serial
#include <Wire.h>
#include <I2C_LCD.h>
I2C_LCD LCD;
extern GUI_Bitmap_t bmlogo; //Declare bitmap data package.
uint8_t I2C_LCD_ADDRESS = 0x51; //Device address configuration, the default value is 0x51.
String instring;
void setup(void)
@omiq
omiq / qrscan.py
Created April 2, 2018 00:23
Demo of a QR scanner that repeatedly scans and looks for QR codes
import PIL
from PIL import Image
import pyzbar.pyzbar as pyzbar
import pygame
import pygame.camera
from pygame.locals import *
# set up the camera
pygame.init()
pygame.camera.init()
@omiq
omiq / qrscan.py
Created April 2, 2018 01:43
This version of the QRCode demo also displays on screen
import PIL
from PIL import Image
import pyzbar.pyzbar as pyzbar
import pygame
import pygame.camera
from pygame.locals import *
# set up the camera
pygame.init()
pygame.camera.init()