Skip to content

Instantly share code, notes, and snippets.

@goodevilgenius
goodevilgenius / my_memory.php
Last active October 26, 2017 14:12
[MyMemory Translate] This PHP script will take the text from stdin, and pass it through the translation service at MyMemory. #translation
#!/usr/bin/php
<?php
$totranslate = file_get_contents('php://stdin');
if (strlen($totranslate) > 1500) {
file_put_contents("php://stderr", "Truncating text to 1500 characters");
$totranslate = substr($totranslate, 0, 1500);
}
@goodevilgenius
goodevilgenius / desc_to_cont_rss.php
Last active October 26, 2017 14:13
[RSS description to content] Transforms an RSS feed, making the content:encoded the same as description #RSS
<?php
/**
To use, place desc_to_cont_rss.php somewhere within your webroot. Then point your browser to http://localhost/desc_to_cont_rss.php?rss=http://example.com/feed.rss
Adjust the paths appropriately for your setup. You may need to urlescape the path to the feed, e.g. http%3A%2F%2Fexample.com%2Ffeed.rss
*/
$rss = $_GET['rss'];
if (empty($rss)) {
$http = "400 Bad Request";
@goodevilgenius
goodevilgenius / media-categories.php
Last active October 26, 2017 14:15
[WP Media Categories] Wordpress plugin to add categories and tags to media items #Wordpress
<?php
/**
* Plugin Name: Media Categories and Tags
* Plugin URI: https://gist.github.com/goodevilgenius/755bc2e7b78ee0b26890
* Description: Adds categories to media
* Version: 0.3.0
* Author: Dan Jones
* Author URI: http://danielrayjones.com/
* License: MIT
*/
@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
#!/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 / 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
<?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
@goodevilgenius
goodevilgenius / reddit_rss_relinker.php
Last active October 26, 2017 14:16
[Reddit RSS Relinker] Modifies Reddit RSS feeds so that the links go to the original URL, rather than the comments page. Also adds author. Can optionally filter based on regular expressions. #RSS #Reddit
<?php
$url = $_GET['url'];
if (!preg_match('@http://(www\.)?reddit\.com/r/([A-Za-z0-9]+)\.rss@', $url)) {
header("HTTP/1.0 400 Invalid Reddit RSS URL");
exit;
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:. `,:;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;` ``;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::,` `,::;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:``:;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;..;;;;;;;;;;;;;
;;;;;;;;.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,,;;;;;;;;;;;;;
;;;;;;;;.;;;;;;;
@goodevilgenius
goodevilgenius / shrinkMKV.sh
Last active October 26, 2017 14:35
[vid shrinker] This shrinks videos. The result is a 320x240 mkv with xvid video and ogg audio. Good for putting on a device with a small screen and limited memory. #video #obsolete
#!/bin/sh
while [ "$#" -ne 0 ]; do
EXT="${1##*.}"
FILENAME=`basename "$1" .${EXT}`
TMP=`mktemp`
ffmpeg -i "$1" -s 320x240 -vcodec xvid -an "${TMP}.avi"
ffmpeg -i "$1" -vn "${TMP}.wav"
@goodevilgenius
goodevilgenius / wmctrlplus.sh
Last active October 26, 2017 14:35
[wmctrlplus] A convenience script to make some things easier with wmctrl. Probably your window manager can do this stuff already, though. I don't use it anymore #desktop #obsolete
#!/bin/sh
function GetNext() {
CURR=$(wmctrl -d | grep '^[[:digit:]]*[[:blank:]]*\*' | sed 's/^\([[:digit:]]*\).*/\1/')
LAST=$(wmctrl -d | tail -1 | sed 's/^\([[:digit:]]*\).*/\1/')
TOTAL=$(expr $LAST + 1)
NEXT=$(expr $(expr $CURR + 1) % $TOTAL)
echo $NEXT
}
@goodevilgenius
goodevilgenius / addfortune.sh
Last active October 26, 2017 14:36
[Add fortune] Add a "fortune" to a fortune file, to be used with the Unix fortune program. fortune is read from stdin, and any arguments are taken to be the source of the quote. #obsolete
#!/bin/bash
# Now included in https://github.com/goodevilgenius/fortune-drj/
DIR="${HOME}/.fortune/files"
FILE="quotes-$(date +%Y-%m)"
quote=`mktemp`
[ ! -d "$DIR" ] && mkdir -p "$DIR"