Skip to content

Instantly share code, notes, and snippets.

View jamesstout's full-sized avatar

James Stout jamesstout

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jamesstout on github.
  • I am stouty (https://keybase.io/stouty) on keybase.
  • I have a public key whose fingerprint is 8E09 B47D 6297 FBD2 ED28 7BAC 32A1 D7DD 8361 0D0F

To claim this, I am signing this object:

@jamesstout
jamesstout / dbConfig.php
Created March 12, 2013 01:11
dbConfig array
<?php
$dbConfig = array();
$dbConfig['xxxxxx']['server'] = 'localhost';
$dbConfig['xxxxxx']['user'] = 'username';
$dbConfig['xxxxxx']['password'] = 'password';
$dbConfig['xxxxxx']['database'] = 'database';
?>
@jamesstout
jamesstout / DButils.php
Last active December 14, 2015 19:58
connectToDBMYSQLI()
<?php
function connectToDBMYSQLI($dbConfig, $script, $die = true){
$link = mysqli_connect($dbConfig['server'], $dbConfig['user'], $dbConfig['password'], $dbConfig['database'] );
if (!$link) {
if($die == true){
die("$script script Connect Error (" . mysqli_connect_errno() . ') ' . mysqli_connect_error());
@jamesstout
jamesstout / checkDodgyIPs.php
Last active December 15, 2015 04:09
Script to look up the location of a list of IP addresses. Uses ipinfodb.com. Writes known IP info to a file to prevent repeat lookups.
<?php
// URL is http://api.ipinfodb.com/v3/ip-city/?key=xxxxxxxxxx&ip=74.125.45.100
/* response should be something like
{
"statusCode" : "OK",
"statusMessage" : "",
"ipAddress" : "180.169.76.237",
-- tip of the hat to Paul Calnan http://www.paulcalnan.com
-- for his Open Terminal Here extension that inspired this one
-- in fact half the code is nicked from him
set finderPath to ""
tell application "Finder"
try
set finderFolder to (folder of the front window as alias)
on error
@jamesstout
jamesstout / class-admin.php
Last active December 16, 2015 12:29
Fix for v4.3.3 class-admin.php "Cannot use string offset as an array" error. Upload this to [wordpress dir]/wp-content/plugins/google-analytics-for-wordpress/admin/ - then go to [WordPress Address]/wp-admin/options-general.php?page=google-analytics-for-wordpress - it should load without the string offset error. Click "Re-authenticate with Google…
<?php
/*
* Admin User Interface
*/
require_once plugin_dir_path( __FILE__ ) . 'yst_plugin_tools.php';
require_once plugin_dir_path( __FILE__ ) . '/wp-gdata/wp-gdata.php';
$options = get_option( 'Yoast_Google_Analytics' );
@jamesstout
jamesstout / checkDodgyIPs.php
Created April 29, 2013 13:21
Script to look up the location of a list of IP addresses. Uses ipinfodb.com. Writes known IP info to a file to prevent repeat lookups.
<?php
// URL is http://api.ipinfodb.com/v3/ip-city/?key=526979f6d541396cee8be6452c39419e6d7eff9433febf55fe0bb1c27b14bb95&ip=74.125.45.100
/* response should be something like
{
"statusCode" : "OK",
"statusMessage" : "",
"ipAddress" : "180.169.76.237",
@jamesstout
jamesstout / lastfm-tabs-nofollow.diff
Created May 18, 2013 14:45
Patch to Last.fm-Tabs to add the option to add rel="nofollow"' to links [http://wordpress.org/extend/plugins/lastfm-tabs/]
Index: lastfm_options.php
===================================================================
--- lastfm_options.php (revision 714873)
+++ lastfm_options.php (working copy)
@@ -346,6 +346,15 @@
'type' => 'checkbox',
'section' => 'general'
);
+
+ $this->settings['nofollow'] = array(
@jamesstout
jamesstout / availableLocaleIdentifiers.mm
Last active December 17, 2015 18:59
List Lithuanian locales in OS X
NSArray *test = [NSLocale availableLocaleIdentifiers];
for (int i = 0; i < [test count]; i++) {
NSLocale *tmpLocale = [[[NSLocale alloc] initWithLocaleIdentifier:[test objectAtIndex:i]] autorelease];
NSString *localeIdentifier = [tmpLocale objectForKey: NSLocaleIdentifier];
NSString *localeIdentifierDisplayName = [tmpLocale displayNameForKey:NSLocaleIdentifier value:localeIdentifier];
@jamesstout
jamesstout / CocoaStandard.sdef.xml
Created May 28, 2013 07:28
CocoaStandard.sdef (not.xml - just for syntax highlighting) - Cocoa Standard Suite - Common classes and commands for all applications.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
<dictionary title="Standard Terminology">
<suite name="Standard Suite" code="????" description="Common classes and commands for all applications.">
<command name="open" code="aevtodoc" description="Open a document.">
<direct-parameter description="The file(s) to be opened.">
<type type="file"/>