Skip to content

Instantly share code, notes, and snippets.

@csmatt
csmatt / gbranchdate.sh
Last active August 25, 2023 12:39
gbranchdate
git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short)'
@csmatt
csmatt / pandoraThumbsUp.js
Created March 16, 2018 17:18
Newer script to pull thumbs ups from Pandora. Can't seem to get past 100 or so songs :/
var doc = document, titlesAndArtists = new Set();
var scrollIntervalMs = 500;
var thumbsUpCount = doc.querySelector(".ProfileNav__count").textContent;
var scrollInterval = window.setInterval(function() {
if (titlesAndArtists.size < thumbsUpCount) {
var prevCount = titlesAndArtists.size;
doc.querySelectorAll(".UserProfile__ThumbUps__list .UserProfile__ThumbUps__list__item").forEach((e) => {
var song = doc.querySelector(".MediaListItem__primaryText", e).textContent;
var artist = doc.querySelector(".MediaListItem__secondaryText", e).textContent;
titlesAndArtists.add(song + " - " + artist);
@csmatt
csmatt / thingiverse_fixes.js
Last active March 7, 2018 15:22
Greasemonkey/Tampermonkey script that fixes some annoying things about Thingiverse
// ==UserScript==
// @name Thingiverse Part Name Display Fixes
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Fixes some annoying things about Thingiverse
// @author Matt Defenthaler
// @match http://tampermonkey.net/index.php?version=4.5&ext=dhdg&updated=true
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @include https://www.thingiverse.com/thing:*
// @grant none
@csmatt
csmatt / fan.py
Last active November 25, 2017 07:41
Code for controlling my Hunter fan with a Raspberry Pi
#!/usr/bin/python
# Code for controlling a Hunter fan with a Raspberry Pi rather than the remote with FCC ID: IN2TX31
# Use: python fan.py COMMAND where COMMAND is light, fan_off, fan1, fan2, fan3
# Truth be told, I'm new at this radio stuff. The code below works, but the method might be a misunderstanding of the protocol/signal. I'd love to understand it better if anyone can help.
# Visit http://csmatt.com/notes/?p=189 for more information
# That said, here's my understanding:
#
# Sending a command consists of a 'part' of a command (a sequence of bits) that is made up of a preamble followed by the part's specific binary sequence
@csmatt
csmatt / gist:89a141063d25e0d26715
Created December 31, 2014 01:42
Pull song titles and artists from Pandora
var titlesAndArtists = []; $("#track_like_pages .infobox-body").each(function(elem){
titlesAndArtists.push($(this).find(".first").text() + "," +
$($(this).find("p.s-0.line-h-1_4>a")[0]).text()); });
for(var i = 0; i < titlesAndArtists.length; i++){console.log(titlesAndArtists[i]);}
@csmatt
csmatt / CourseraLectureVideoLinkCreator.js
Created November 19, 2014 18:20
Produces right-click-save-as links for Coursera courses. Only works for the Software Security course at the moment.
// While logged in, go to https://class.coursera.org/softwaresec-001 and select a week under Weekly Content.
// Run this script in the dev console and it'll put links at the top of the page that you can right-click-save-as
var lectLink = $("a[href^='https://class.coursera.org/softwaresec-001/lecture/view?lecture_id=']"),
prefix = location.pathname.split(/.*\/wiki\//)[1],
vidLinkContainer = $("<div id='vidLinkContainer'/>");
$("#vidLinkContainer").remove();
$("body").prepend(vidLinkContainer);
lectLink.each(function(index) {
var lectTitle = $(this).text(),
lectHref = $(this).attr("href");
import ObjdumpHandler
import Utils
objdump_functions = None
def get_objdump_functions(file_path):
global objdump_functions
if objdump_functions is None:
@csmatt
csmatt / Exploit.py
Last active September 19, 2016 07:17
Full Exploit.py script for my tutorial on using Bowcaster to exploit a MIPS buffer overflow http://csmatt.com/notes/?p=96
#!/usr/bin/python
from bowcaster.development.overflowbuilder import SectionCreator, OverflowBuffer
from bowcaster.common.support import LittleEndian
from bowcaster.payloads.mips.connectback_payload import ConnectbackPayload
from bowcaster.encoders.mips import MipsXorEncoder
qemu_libc_base=0x2aadc000
badchars = ['\0','\n']
SC=SectionCreator(LittleEndian, base_address=qemu_libc_base, badchars=badchars)
sections=[]
@csmatt
csmatt / lgSerial.py
Last active May 3, 2019 22:33
A simple python script to send commands to the LG AN-WL100 Wireless Media Kit through its TRS service port. Requires serial library. Tested with Python 2.7
import sys, re, serial
def showHelp():
print ""
print "\t%s COM_PORT_NUMBER COMMAND" % sys.argv[0]
print "\t\t commands can have spaces (xb 00 70) or not (xb0070)"
print ""
def getDeviceFromStr(deviceArg):
# if it's just an int, we'll assume it's a windows COM port
@csmatt
csmatt / panasonicTvControl.c
Created December 31, 2012 20:07
Arduino program that receives an 8-byte command to be received by a Panasonic TV over infrared.
#include <IRremote.h>
IRsend irsend;
void setup() {
pinMode(3, OUTPUT);
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop() {