Skip to content

Instantly share code, notes, and snippets.

View trepmal's full-sized avatar
🍪

Kailey Lampert trepmal

🍪
View GitHub Profile
@trepmal
trepmal / editor_plugin.js
Created October 3, 2011 23:17
WordPress: TinyMCE button that wraps selection in given tag
// http://tinymce.moxiecode.com/wiki.php/API3:class.tinymce.Plugin
(function() {
tinymce.create('tinymce.plugins.WRAP', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished its initialization so use the onInit event
* of the editor instance to intercept that event.
*
@trepmal
trepmal / delet_tweets.md
Last active September 24, 2023 08:15 — forked from apsun/delet_tweets.md
Delete your old tweets with this disgusting bash script

100% free. Runs completely locally on your machine. Bypasses the 3200 tweet limit. May require some eye bleach for the script. Here's how to use it:

  1. Go to settings -> account -> your Twitter data and request a download. This may take a few hours. You'll get an email with a link to download a zip file. Extract the zip file and navigate to the data directory.

  2. Go to Twitter in a web browser and find any Tweet you want to delete. We're going to use it to extract your authentication credentials for the next step. Open developer tools, delete the tweet, and find the request

@trepmal
trepmal / gifintensifier.sh
Last active September 27, 2021 21:01
intensify your emojis
#!/bin/bash
#
# Call this script, passing an image filename
# Creates an intensified version
convert='/usr/local/bin/convert'
realpath='/usr/local/bin/realpath'
# flight check: must have imagemagick
if [ ! $(which $convert) ]; then
#!/bin/bash
convert='/usr/local/bin/convert'
# flight check: must have imagemagick
if [ ! $(which $convert) ]; then
echo 'Error: `convert` required'
exit;
fi;
@trepmal
trepmal / remote-login.php
Created June 21, 2012 20:49
[WordPress Plugin] Remote Login
<?php
/*
Plugin Name: Remote Login
Description: Log into the site with creds that work on remote site (as defined in plugin). The remote site must have XML-RPC enabled.
Author: Kailey Lampert
Author URI: http://kaileylampert.com/
THIS IS NOT COMPLETE - DO NOT USE IN PRODUCTION
The remote site (defined below in $server) is the "master" site.
@trepmal
trepmal / notepad.js
Created November 16, 2011 21:35
WordPress: Front-end editable notepad
jQuery(document).ready(function($) {
$('#notepad').click(function(e) {
tag = e.target.tagName;
if ( tag != 'TEXTAREA' && tag != 'INPUT' ) {
contents = $(this).html();
$(this).html( '<textarea style="display:block;width:98%;height:100px;">' + contents + '</textarea><input type="submit" class="save" style="position:relative;z-index:99" />' );
}
});
$('#notepad input.save').live( 'click', function() {
@trepmal
trepmal / gist:1c66dbe97e8f322bc107
Created December 19, 2014 22:42
wp-cli: reset all user passwords
#!/bin/bash
for uid in $(wp user list --field=ID)
do
pass=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32}`
wp user update $uid --user_pass="$pass"
done
@trepmal
trepmal / notes.md
Last active January 6, 2021 02:10
[WordPress Plugin] Simple Registration/Invite Codes
  1. Assumes "Anyone can register" is checked on wp-admin/options-general.php
  2. Create a code by creating a post at wp-admin/edit.php?post_type=invite_codes with the code in the title
  3. When a user registers at wp-login.php?action=register, they must provide a valid code. Code validation is fully dependent on get_page_by_title, so there is some loose matching
  4. When a code is succuessfully used, the code "post" will be marked as 'draft', and post meta will be added indicating who used it.
  5. Disabling the wp_update_post section will allow codes to be reused until manually marked as 'draft'
@trepmal
trepmal / sunrise.php
Created November 26, 2020 22:19
Testing scenarios for domain masking via sunrise.php in WordPress
<?php
// Mask Domain testing
$clientslug_custom_sunrise_domains = [
'mask.test',
];
// quickly switch testing scenarios
@trepmal
trepmal / resize-original-upload.php
Last active September 30, 2020 10:38
resize new uploads to fit max dimensions
<?php
/*
Plugin Name: Resize Original Upload
*/
add_filter('wp_handle_upload', 'max_dims_for_new_uploads', 10, 2 );
function max_dims_for_new_uploads( $array, $context ) {
// $array = array( 'file' => $new_file, 'url' => $url, 'type' => $type )
// $context = 'upload' || 'sideload'