Skip to content

Instantly share code, notes, and snippets.

View EmperorPenguin18's full-sized avatar

Sebastien MacDougall-Landry EmperorPenguin18

View GitHub Profile
@EmperorPenguin18
EmperorPenguin18 / gifthumbnail.sh
Created May 11, 2021 00:36
Display an animated gif in the terminal
#!/bin/sh
VIDEO="${1:-test.mp4}"
GIF="${2:-test.gif}"
ffmpeg -ss 61.0 -t 2.5 -i "$VIDEO" -filter_complex "[0:v] fps=12,scale=w=480:h=-1,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1" "$GIF"
chafa "$GIF"
@EmperorPenguin18
EmperorPenguin18 / subscribe.sh
Created May 11, 2021 00:31
Adds my ytrefresh script to cron
#!/bin/sh
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root"
exit 1
fi
USER=$(ls /home)
CHANNEL="$(echo $@ | awk -F '/' '{print $NF}')"
@EmperorPenguin18
EmperorPenguin18 / ytrefresh.sh
Created May 11, 2021 00:29
Download the most recent 15 videos from a YouTube channel
#!/bin/sh
USER=$(ls /home)
mkdir -p /home/$USER/YouTube
for I in $(curl -s "https://www.youtube.com/feeds/videos.xml?channel_id=$1" | awk -F '"' '/watch/ {print $4}')
do
FORMATS=$(youtube-dl -F $I)
TITLE="$(youtube-dl --get-title $I)"
@EmperorPenguin18
EmperorPenguin18 / web_scraper.cpp
Created May 10, 2021 23:38
Get only the text from a webpage
//Code that scrapes webpages
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
string url;
@EmperorPenguin18
EmperorPenguin18 / web_scraper.c
Created May 10, 2021 23:38
Get only the text from a webpage
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define SIZE 999999
#define WORD 255
int n;
int m;
@EmperorPenguin18
EmperorPenguin18 / virus.cpp
Created May 10, 2021 23:34
Prank your friends by running this in their terminal
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <thread>
#include <chrono>
#include <fstream>
#include <time.h>
#include <unistd.h>
using namespace std;
@EmperorPenguin18
EmperorPenguin18 / raspi.cpp
Created May 10, 2021 23:31
Automate setting up a RPI
//Raspberry pi configuration
#include <iostream>
#include <string>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
string name;
@EmperorPenguin18
EmperorPenguin18 / pokedex.cpp
Created May 10, 2021 23:29
Simple Pokedex in the terminal
//Code that scrapes veekun for pokedex data and displays it to user
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
#include <time.h>
#include <ctype.h>
@EmperorPenguin18
EmperorPenguin18 / graphics.cpp
Created May 10, 2021 23:24
Create an X window
#include <X11/Xlib.h>
#include <assert.h>
#include <unistd.h>
#define NIL (0)
Display *dpy = XOpenDisplay(NIL);
assert(dpy);
int blackColor = BlackPixel(dpy, DefaultScreen(dpy));
@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: