Skip to content

Instantly share code, notes, and snippets.

View grimmdude's full-sized avatar
🪴

Garrett Grimm grimmdude

🪴
View GitHub Profile
@grimmdude
grimmdude / asciibin.js
Created October 26, 2016 15:11
A javascript function that converts a text string into binary and binary into a text string.
function asciibin(convert, type) {
//if this is binary...
if (type == 'binary') {
//strip any white space
convert = convert.replace(/ /g,'');
//remove any line breaks
convert = convert.replace(/\n/g,'');
@grimmdude
grimmdude / social_url_dump.php
Last active December 26, 2015 08:39
PHP script to pull share counts from Twitter and Facebook for a given url. Takes a csv list of urls to check for and outputs a csv with the urls/share counts.
<?php
/**
* Script to pull share counts from Twitter and Facebook for a given url. Takes a csv list of urls to check for and outputs a csv with the urls/share counts.
* @author Garrett Grimm 2012
* @param $input_csv Path to input csv.
* @param $output_csv Path to output csv.
*/
$input_csv = 'share_urls.csv';
$output_csv = 'share_urls_output.csv';
@grimmdude
grimmdude / remove_doop_comments.php
Last active September 23, 2018 18:26
Small script to delete duplicate post comments from a Wordpress database. Backup first bud.
<?php
# First select all comments
$query = "SELECT `comment_ID`, `comment_post_ID`, `comment_content` FROM ".$wpdb->comments." WHERE 1";
$comments = $wpdb->get_results($query);
# Array to hold keeper comment IDs so we don't delete them if there are doops
$keeper_comments = array();
# Now check if each comment has any matching comments from the same post
foreach ($comments as $comment) {