Skip to content

Instantly share code, notes, and snippets.

View tharmann's full-sized avatar

Tate Harmann tharmann

View GitHub Profile
@tharmann
tharmann / HiddenMickey.java
Last active January 7, 2019 20:34
A modified version of the java "Hidden Mickey" that plays a sound as java draws Mickey Mouse. Replace 'your_sound_byte_here.aiff' with your sound byte.
import java.awt.*;
import java.awt.Canvas;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.*;
import java.io.*;
import javax.sound.sampled.*;
import javax.swing.JButton;
import javax.swing.JFrame;
@tharmann
tharmann / recursive_mogrify.c
Last active January 7, 2019 20:37
A little C program that recursively resizes images with variable minimum edge and quality values. Also supports an optional 'dry_run' switch. Utilizes MagickWand.
#include <sys/types.h>
#include <stdlib.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <wand/MagickWand.h>
int count = 0;
void processdir(const char *name, const int min_edge, const int quality, const int dry_run) {
@tharmann
tharmann / additional-fields.php
Created April 19, 2018 16:02
Add upload field (for PDF Flyers attached to the Event) to Tribe Community Events with Events Pro - WordPress
<?php
/**
* Single Event Meta (Additional Fields) Template
*
* Override this template in your own theme by creating a file at:
* [your-theme]/tribe-events/pro/modules/meta/additional-fields.php
*
* @package TribeEventsCalendarPro
*/
@tharmann
tharmann / functions.php
Created February 15, 2018 15:20 — forked from mantismamita/functions.php
Force SSL for media library
function have_https_for_media( $url ) {
if ( is_ssl() )
$url = str_replace( 'http://', 'https://', $url );
return $url;
}
add_filter( 'wp_get_attachment_url', 'have_https_for_media' );
@tharmann
tharmann / teedy.php
Last active January 11, 2018 20:18
A tedious and inefficient line of php written by "anonymous" hehe
<?php
$items = array(
1 => array( 'item' => explode( '|', rgar( $entry, '20' ) ), 'title' => rgar( $entry, '5' ), 'name' => rgar( $entry, '7' ), 'company' => rgar( $entry, '8' ), 'position' => rgar( $entry, '9' ), 'address_1' => rgar( $entry, '10.1' ), 'address_2' => rgar( $entry, '10.2' ), 'city' => rgar( $entry, '10.3' ), 'state' => rgar( $entry, '10.4' ), 'zip' => rgar( $entry, '10.5' ), 'country' => rgar( $entry, '10.6' ), 'phone' => rgar( $entry, '33' ), 'fax' => rgar( $entry, '11' ), 'old_pos' => rgar( $entry, '13' ), 'emp_dates' => rgar( $entry, '14' ), 'contact_rel' => rgar( $entry, '15' ), 'new_pos' => rgar( $entry, '18' ), 'reason_left' => rgar( $entry, '16' ), 'last_sal' => rgar( $entry, '17' ), 'add_notes' => rgar( $entry, '21' ), 'rush' => explode( '|', rgar( $entry, '22.1' ) ), 'international' => explode( '|', rgar( $entry, '23.1' ) ) ),
2 => array( 'item' => explode( '|', rgar( $entry, '46' ) ), 'title' => rgar( $entry, '49' ), 'name' => rgar( $entry, '51' ), 'company' => rgar( $entry, '52'
@tharmann
tharmann / gw-gravity-forms-populate-field-value-into-subsequent-field.php
Created December 21, 2017 20:03 — forked from spivurno/gw-gravity-forms-populate-field-value-into-subsequent-field.php
Gravity Wiz // Gravity Forms // Populate Field Value from One Page to Field in Subsequent Page
/**
* Gravity Wiz // Gravity Forms // Populate Field from One Page to Field in Subsequent Page
* http://gravitywiz.com/
*/
// update "1074" to the ID of your form
add_filter( 'gform_pre_render_1074', function( $form ) {
foreach( $form['fields'] as &$field ) {
// update "2" to the field ID on the later page
<?php
function mail_from() {
$emailaddress = 'contact@1stwebdesigner.com';
return $emailaddress;
}
function mail_from_name() {
$sendername = "1stWebDesigner.com - Dainis";
return $sendername;
}
@tharmann
tharmann / wp_xml_replacer.py
Last active May 11, 2017 15:57
A little python script for notepad++. This searches through a WordPress xml export file and converts date strings to unix timestamps. Very useful when using wp-types for custom date fields. Requires the notepad++ python plugin..
import time
import datetime
editor.beginUndoAction()
def calculate(match):
epoch = datetime.datetime(1970, 1, 1)
s = "%s/%s/%s" % (match.group(1), match.group(2), match.group(3))
t = datetime.datetime.strptime(s, "%Y/%m/%d")
diff = t-epoch
<?php
function clear_jetpack_published() {
if(empty($_REQUEST['post'])) {
wp_die(__('Invalid post ID or action'));
}
global $wpdb;
$id = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : '';
@tharmann
tharmann / facebook-mass-deleter.php
Last active October 3, 2016 19:43
This is a simple snippet that I intent to complexify later. I used it to remove 1000+ posts that were created automatically (via a WordPress plugin) on a Facebook page. It takes a search string and looks for posts matching that string - then it deletes them. Keep in mind that you have to use FB's paging scheme to search through a large number of…
<?php
//make sure your page access token has the 'publish_actions' scope
$access_token = 'YOURACCESSTOKEN';
$pageid = 'YOURPAGEID';
//fb graph api only allows this to be up to 100
$limit = '100';
//retireve posts on specific page ID:
$fb_ret_url = 'https://graph.facebook.com/' . $pageid . '/posts?limit=' . $limit . '&access_token=' . $access_token;