Skip to content

Instantly share code, notes, and snippets.

View EmperorPenguin18's full-sized avatar

Sebastien MacDougall-Landry EmperorPenguin18

View GitHub Profile
@EmperorPenguin18
EmperorPenguin18 / gif-greenscreen-converter.sh
Created May 10, 2021 23:05
Convert a colour in every frame of a GIF to another colour
#!/bin/bash
input=$1
file=$2
rmax=$3
gmax=$4
bmax=$5
[ "$input" = "" ] || [ "$file" = "" ] || [ "$rmax" = "" ] || [ "$gmax" = "" ] || [ "$bmax" = "" ] && echo "Missing arguments"; exit 1
cp $input $file
inc=1
r=00
@EmperorPenguin18
EmperorPenguin18 / installmac.sh
Created May 10, 2021 23:06
Automater script for macOS-Simple-KVM
sudo pacman -S qemu python python-pip
git clone https://github.com/foxlet/macOS-Simple-KVM
cd macOS-Simple-KVM
./jumpstart.sh --high-sierra
qemu-img create -f qcow2 MyDisk.qcow2 50G
echo ' -drive id=SystemDisk,if=none,file=MyDisk.qcow2 \' >> basic.sh
echo ' -device ide-hd,bus=sata.4,drive=SystemDisk \' >> basic.sh
sed -i '11d' basic.sh
sed -i '10a \ \ \ \ -m 8G \\' basic.sh
sed -i '13d' basic.sh
@EmperorPenguin18
EmperorPenguin18 / mtgwallpapers.sh
Created May 10, 2021 23:09
Download MTG art automatically
for i in {1..38}
do
lynx -listonly -nonumbers -dump https://www.artofmtg.com/set/page/$i | grep /art/ | xargs -L1 -i{} lynx -listonly -dump -nonumbers -image_links {} | grep jpg | grep -v "100x100" | xargs -L1 -i{} wget -nc {}
done
@EmperorPenguin18
EmperorPenguin18 / input.py
Created May 10, 2021 23:12
GPIO code for the RPI
import RPi.GPIO as GPIO
from time import sleep
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
BUTTON = 14
GPIO.setup(BUTTON, GPIO.IN)
LED = 18
GPIO.setup(LED, GPIO.OUT)
@EmperorPenguin18
EmperorPenguin18 / maze.py
Created May 10, 2021 23:13
Control a RPI vehicle with one letter commands
import RPi.GPIO as GPIO
from time import sleep
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
MOTOR1 = 14
MOTOR2 = 18
MOTOR3 = 24
MOTOR4 = 12
@EmperorPenguin18
EmperorPenguin18 / object_detection.py
Created May 10, 2021 23:15
Object detection algorithm for QSET
#QSET Object Avoidance
#By Sebastien MacDougall-Landry
import rospy
from sensor_msgs.msg import LaserScan
from geometry_msgs.msg import *
import math
def laserCallBack(msg):
global points
@EmperorPenguin18
EmperorPenguin18 / wave.py
Created May 10, 2021 23:16
Light show with LEDs and RPI
import RPi.GPIO as GPIO
from time import sleep
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
LED1 = 14
LED2 = 18
LED3 = 24
LED4 = 12
LED5 = 16
@EmperorPenguin18
EmperorPenguin18 / ascii.cpp
Created May 10, 2021 23:18
Convert image file to ASCII art
//Code that converts images to ascii images
#include <iostream>
#include <stdint.h>
#include <opencv/cv.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/opencv.hpp>
//#include <opencv2/core/types.hpp>
@EmperorPenguin18
EmperorPenguin18 / compile_opencv.cpp
Created May 10, 2021 23:19
Helper script to compile C++ programs that require OpenCV
#include <iostream>
#include <string>
using namespace std;
string input;
string input_clipped;
int i;
int main(int argc, char **argv)
{
@EmperorPenguin18
EmperorPenguin18 / covariance.cpp
Created May 10, 2021 23:23
Covariance class for QSET
//Covariance achieved with classes
#include <math.h> //Needed for pow() function
class Covariance {
static int cycles = 5; //Should change based on frequency of data collection
double sum1 = 0, sum2 = 0, arr1[cycles], arr2[cycles], var1 = 1, var2 = 1; //Initialize
int counter = 0;
public: