Skip to content

Instantly share code, notes, and snippets.

@ab5w
ab5w / check_new_post.py
Last active May 24, 2021 17:24
check a subreddit for a new post and message discord with the title/link
#!/usr/bin/python3
import requests,json,config,os,sys,html
"""
Grab the latest post from the new queue and post to discord.
Puts the post id in a cache file, to prevent duplicates.
https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
config.py contents example;
import requests, json, config, time, datetime
"""
Script to delete your reddit history after a certain year.
For example it's 2021, so with -2 it will remove anything older than 2019
You need to get an API token as documented here https://github.com/reddit-archive/reddit/wiki/OAuth2
"""
def get_token():
base_url = 'https://www.reddit.com/'
@ab5w
ab5w / temper13_on_raspian.md
Created February 2, 2021 17:32
TEMPer2V3.1 or TEMPer2V3.3 (USB IDs 413D:2107)

TEMPer2V3.1 or TEMPer2V3.3 (USB IDs 413D:2107)

apt-get install libhidapi-dev libhidapi-hidraw0 cmake git g++
git clone https://gitlab.com/mulx/TEMPered/
cd TEMPered/
cmake .
make
make install
cp /usr/local/lib/libtempered* /usr/lib/
@ab5w
ab5w / vinyls.txt
Last active January 18, 2018 13:35
Flobots - Fight With Tools
Dillinja - Here Comes Trouble
Skinny Lister - Rollin' Over / Colours
Rag'n'Bone Man - Human
Kavinsky - OutRun
Charles Gerhardt / National Philharmonic Orchestra - Music From John Williams' Close Encounters Of The Third Kind / Star Wars
Lana Del Rey - Born To Die
Agnes Obel - Aventine
Agnes Obel - Citizen Of Glass
Agnes Obel - Philharmonics
@ab5w
ab5w / xerxes_mattermost.php
Last active January 15, 2018 15:06
example mattermost bot using an outgoing webhook and incoming webhooks.
<?php
//Example Xerxes mattermost bot with incoming/outgoing webhook use.
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//function to send the message payload to mattermost.
function send_to_mattermost($message) {
global $channel;
@ab5w
ab5w / ptrns
Created November 22, 2017 13:23
ptr ns lookup
#!/usr/bin/php
<?php
//PTR nameserver lookup
if (!isset($argv[1])) { exit(); }
$ip = exec("dig " . $argv[1] . " A +short");
$ip = explode('.', $ip);
#!/bin/bash
days="90"
now=$(date +%s)
days_in_seconds=$((60*60*24*${days}))
limit=$((${now} - ${days_in_seconds}))
for snap in $(zfs list -r -t snapshot | grep -v NAME | awk '{print $1}'); do
<?php
class lastfm {
private $userfile = 'lastfm.json';
private $api_key = '';
public function __construct() {
if (!file_exists($this->userfile)) { touch($this->userfile); chmod($this->userfile, 0755); }
#!/bin/bash
#kick httpd
while $(killall -9 httpd); do
:;
done
@ab5w
ab5w / swapusage.php
Last active December 29, 2015 17:21
Script to show what's using swap.
#!/usr/bin/php
<?php
//swap usage
$proc_dir = scandir("/proc");
foreach ($proc_dir as $proc_file) {
if (preg_match('/[0-9]/', $proc_file)) {