Skip to content

Instantly share code, notes, and snippets.

View ksemel's full-sized avatar

Katherine Semel-Munson ksemel

View GitHub Profile
@timclegg
timclegg / gist:3e6be984b534eeb239aed84c62977bd0
Created August 22, 2017 21:10
Installation of AWS CLI on MacOS Sierra (10.12.6)
sudo pip install awscli --ignore-installed six
@ksemel
ksemel / code_sniffer.sh
Created January 23, 2017 21:41
Install PHP CodeSniffer and other dependencies
#!/bin/bash
# Install PHP Code Sniffer and related modules
TMP_PATH=/tmp/
BIN_PATH=/usr/local/bin/
cd $TMP_PATH
# PHPCS
# PHP Code Sniffer
@ak4n
ak4n / foreach_vs_array_asterix
Last active December 20, 2018 13:00
Benchmarking execution time of PHP constructs (list / each, foreach) vs (array_walk, array_map, array_reduce, array_filter)
<?php
/**
* Execution time check for: (list/each,foreach) vs (array_walk, array_map, array_reduce, array_filter)
* @docs to read
* http://www.giorgiosironi.com/2010/02/stop-writing-foreach-cycles.html
* http://www.pastie.org/829318
* http://php.net/manual/en/function.array-walk.php#112722
* http://zaemis.blogspot.com/2013/06/building-array-with-arrayreduce.html
* (!) http://stackoverflow.com/questions/2473989/list-of-big-o-for-php-functions/2484455#2484455
* http://www.faieta.net/wp/performance-implications-of-closures-in-php/
@ksemel
ksemel / orphans-post_meta.sql
Last active October 5, 2015 18:25
Delete WordPress Orphans in post_meta and taxonomy tables
# Delete Orphaned Post Meta
# Selects all postmeta where the post_id does not exist
SELECT * FROM wp_postmeta WHERE post_id NOT IN (SELECT DISTINCT ID FROM wp_posts) AND meta_id BETWEEN 1 AND 500000;
# Use an offset to avoid super massive queries!
# Make sure to offset the META_ID ( not the post_ID ) or you'll delete good data
# Set 1
DELETE FROM wp_postmeta WHERE post_id NOT IN (SELECT DISTINCT ID FROM wp_posts) AND meta_id BETWEEN 1 AND 500000;
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"