Skip to content

Instantly share code, notes, and snippets.

View jamesstout's full-sized avatar

James Stout jamesstout

View GitHub Profile
@jamesstout
jamesstout / find_zombies.sh
Last active January 6, 2017 08:34
Xcode/clang: error: unable to execute command: posix_spawn failed - How to check for zombie processes on Mac OS X
#!/bin/bash
# to check for zombie processes on Mac OS X
for pid in `ps -v -u james | awk '{print $1, $2}' | grep Z | awk '{print $1}'`;
do
ps -o command="" -p $pid >> ~/zombies.txt;
done
# Detect if file exists
@jamesstout
jamesstout / verifyReceipt.php
Last active August 5, 2021 08:49
Verify iOS in-app purchase receipts
<?php
include("/var/www/vhosts/xxxxxcom/httpdocs/PHPUtils/dbConfig.php");
include("/var/www/vhosts/xxxxxcom/httpdocs/PHPUtils/DButils.php");
// verifies receipt from iOS in-app purchase
// returns:
// 0 - if params missing
// 1 - if receipt is valid
// 2 - if invalid receipt, or invalid response from verification server
// or bundle/in-app IDs are incorrect
@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 / process.py
Last active July 12, 2021 07:24
add tz param to https://github.com/mwaterfall/alfred-datetime-format-converter to get the time in your location. Some testing done.
# -*- coding: utf-8 -*-
import alfred
import calendar
import time
import math
from delorean import utcnow, parse, epoch
# global var to see if user
# has a time offset
@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 / allTZ.sh
Created April 24, 2013 21:05
Get the current time in all the timezones known to your machine
#!/bin/bash
# Error logging
e_error() {
printf "$(tput setaf 1)x %s$(tput sgr0)\n" "$@"
}
# only do this if you know how to set it back
# set date/time to 10:00 AM PDT
# export TZ=PST8PDT
@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",