Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Tom J Nowell tomjn

🎯
Focusing
View GitHub Profile
View build.sh
#!/bin/bash
# Takes a composer controlled repo and pushes a
# composed PACKAGE into a branch called "PACKAGE".
(
# SANITY CHECKS
# Check for uncommitted changes, and refuse to proceed if there are any
if [ -n "$(git ls-files . --exclude-standard --others)" ]; then
View composer.json
{
"name": "tomjn/composer-webtest",
"description": "tests for web based composer uis",
"license": "GPL-V2.0",
"authors": [
{
"name": "Tom J Nowell",
"email": "contact@tomjn.com"
}
],
@tomjn
tomjn / composer.json
Last active Aug 29, 2015
Checking if composer ran succesfully after the fact
View composer.json
{
"require": {
"justinrainsdasdfbow/json-schema": "~1.1"
},
"scripts": {
"post-update-cmd": "cftp\\composer_checker::post",
"post-install-cmd": "cftp\\composer_checker::post",
"pre-install-cmd": "cftp\\composer_checker::pre",
"pre-update-cmd": "cftp\\composer_checker::pre"
},
@tomjn
tomjn / loop.php
Created Oct 21, 2014
Thinking out loud on functional programming
View loop.php
<?php
global $wp_query;
array_walk( $wp_query->posts, function( $post, $key ) {
setup_postdata( $post );
the_title();
the_content();
});
@tomjn
tomjn / hodor.php
Created Apr 28, 2015
Hodor! Hodor hodor hodor, hodor? Hodor!
View hodor.php
<?php
/**
* Plugin Name: Hodor Translation Pack
* Description: Hodor hodor hodor. Hodor hodor?
* Version: 1.0
* Author: Tom J Nowell
* Author URI: http://tomjn.com/
* License: GPLv2+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
View junction-fix.php
<?php
/*
Plugin Name: Junction fixes for plugins
Plugin URI: http://interconnectit.com/
Description: Junctioning files into the WordPess plug-ins folder causes problems with php 5.3 for plugin_url, this tries to fix it. Place in the wp-content/mu-plugins folder so it loads before all other plugins.
Author: James R Whitehead
Version: 0.0.0.0.0.0.2
Author URI: http://interconnectit.com
*/
@tomjn
tomjn / gist:3425191
Created Aug 22, 2012
GDocs Spreadsheet Check WordPress Sites for Updates
View gist:3425191
function getWPVersion(url){
var newurl = url + "/readme.html";
var hdoc = null;
try{
hdoc = UrlFetchApp.fetch(newurl);
if(hdoc.getResponseCode() != 200){
return "Cannot retrieve version";
}
}catch(e){
return "Cannot retrieve version";
@tomjn
tomjn / gist:3871705
Created Oct 11, 2012
PHP Levenshtein distance methods
View gist:3871705
class Example {
public function length(){
return 5;
}
public function __call($name,$arguments){
$methods = get_class_methods($this);
$ldist = 9999;
$currmethod = $name;
foreach($methods as $m){
$distance = levenshtein($name,$m);
@tomjn
tomjn / notify-on-media.php
Created Oct 18, 2012
WP - Notify via Email on creation of Attachment
View notify-on-media.php
<?php
/*
Plugin Name: Notify on Attachment Creation
Plugin URI: http://www.tomjn.com
Description: Send a notification when an attachment is created
Version: 1.04
Author: Tom J Nowell
Author URI: http://www.tomjn.com
*/
@tomjn
tomjn / sellwirecsv.php
Last active Oct 13, 2015
Grab product orders from Sellwire in PHP
View sellwirecsv.php
require 'PHP-Browser/browser.class.php';
function get_sellwire_csv( $username, $password, $project_id ) {
$browser = new Browser( 'SellWire Browser' );
$browser->navigate( 'http://app.sellwire.net/logout' );
$browser->navigate( 'http://app.sellwire.net/login' );
$form = $browser->getForm( '//form[@method]' );
$form->setAction( 'http://app.sellwire.net/login' );
$form->setAttributeByName( 'username', $username )->setAttributeByName( 'password', $password );