Skip to content

Instantly share code, notes, and snippets.

View goodevilgenius's full-sized avatar
🍕
Need fuel

Dan Jones goodevilgenius

🍕
Need fuel
View GitHub Profile
@goodevilgenius
goodevilgenius / membash.sh
Last active November 2, 2023 12:19 — forked from ri0day/memcache_cli.sh
[membash] BASH script which may be used to interact with memcache. All main memcache functions are supported. #memcache
View membash.sh
#!/bin/bash
# Gist: 11375877
# Url: https://gist.github.com/goodevilgenius/11375877
#
# All memcache functions are supported.
#
# Can also be sourced from other scripts, e.g.
# source membash.sh
# MCSERVER="localhost"
@goodevilgenius
goodevilgenius / fortune_variety_quotes.py
Last active October 28, 2023 05:09
[Variety fortune plugin] Plugin for Variety background changer that uses the UNIX fortune program as a quotes source
View fortune_variety_quotes.py
#!/usr/bin/python
from variety.plugins.IQuoteSource import IQuoteSource
import subprocess, re
from locale import gettext as _
class FortuneSource(IQuoteSource):
@classmethod
def get_info(cls):
return {
@goodevilgenius
goodevilgenius / cheat_sheet.org.sh
Last active October 22, 2023 12:25
[Linux cheat sheet] A succinct cheat sheet for newbie linux coders and system administrators, documenting some of the more obscure and useful gems of linux lore. Intended to be viewed in emacs org-mode, or VimOrganizer, though any text editor will suffice. #Linux #Unix #POSIX #cli
View cheat_sheet.org.sh
# cheat_sheet.org.sh
# The contents of this file are released under the GNU General Public License. Feel free to reuse the contents of this work, as long as the resultant works give proper attribution and are made publicly available under the GNU General Public License.
# Best viewed in emacs org-mode.
# Alternately, one can keep this cheat sheet handy by adding the following line to ~/.bashrc:
#
# alias cheatsheet="less ~/path_to_cheat_sheet.org.sh"
#
# Originally by WilliamHackmore: https://github.com/WilliamHackmore/linuxgems
# This version by goodevilgenius: https://gist.github.com/goodevilgenius/2d1c01251c524610a2cd
@goodevilgenius
goodevilgenius / ternary.go
Created September 25, 2023 11:20
A ternary function for go, because why doesn't it already have it?
View ternary.go
func Tern[V any](choice bool, one, two V) V {
if choice {
return one
}
return two
}
@goodevilgenius
goodevilgenius / empty-yt-playlist.js
Created August 24, 2023 18:00
Empty a YouTube playlist
View empty-yt-playlist.js
function clickRemove() {
const button = [...document.querySelectorAll('.yt-formatted-string')].find(el => el.innerText === 'Remove from ');
if (!button) {
console.log("Can't find remove button");
return;
}
button.click();
setTimeout(emptyList, 1);
}
@goodevilgenius
goodevilgenius / promise-queryable.js
Created August 21, 2023 15:16
A javascript promise that can tell you if it's been fulfilled.
View promise-queryable.js
Promise.prototype.getQueryable = function () {
if (this.isFulfilled) return this;
let isPending = true;
let isRejected = false;
let isFulfilled = false;
let value = undefined;
let error = undefined;
let result = this.then(v => {
@goodevilgenius
goodevilgenius / dl_json.js
Last active September 24, 2021 18:50
[Download JSON] Force browser to download a JavaScript object as a JSON file, using jQuery, or VanillaJS #webdev #browser #javascript
View dl_json.js
/* global $, data */
// data should be the object/array/etc to be JSON-ified.
// First, with jQuery
var $el = $('<a>');
$(document.body).append($el);
// If data is a jQuery selector, then do data = data.toArray()
@goodevilgenius
goodevilgenius / spy.php
Last active September 2, 2021 21:27
Class to access private/protected methods/properties without Reflections. Requires PHP 8 (could be rewritten to support 7)
View spy.php
<?php
/**
* Method for accessing private/protected properties/methods without Reflection.
*
* This is particularly useful when debugging from the command-line, for example, with psysh.
*
* Static methods/properties can be accessed by passing the class instead.
* Constants are not acccessible.
*
@goodevilgenius
goodevilgenius / pushover.sh
Last active May 15, 2021 23:32
[bash pushover] Command-line script to send a notification to your mobile device via Pushover. Requires curl. #pushover #notifications #obsolete
View pushover.sh
#!/bin/bash
# Assuming you name the file pushover.sh, place somewhere within your $PATH, then chmod +x /path/to/pushover.sh
# Invoke with: pushover.sh [-d device_name] [-t Title] [-u Url] [-ut URL Title] [-p] [-ts timestamp] "notifcation text"
token=""
user=""
test -f ~/.pushover && source ~/.pushover # Put your API token and user key here
@goodevilgenius
goodevilgenius / wordpress-rss-atom-updated.php
Last active February 3, 2020 11:09
[WP atom:updated] Wordpress Plugin to add atom:updated to rss feed #Wordpress #RSS
View wordpress-rss-atom-updated.php
<?php
/**
* @version 0.1
*/
/*
Plugin Name: Atom:Updated
Plugin URI: https://gist.github.com/goodevilgenius/9786001
Description: This plugin adds atom:updated to your RSS2 feed
Author: Dan Jones
Version: 0.1