Skip to content

Instantly share code, notes, and snippets.

View kfriend's full-sized avatar

Kevin Friend kfriend

  • 742 Evergreen Terrace
View GitHub Profile
@kfriend
kfriend / wordpress_key_gen.sh
Created July 28, 2016 13:14
Generate PHP Dotenv vars for Wordpress's hashes and keys
php -r 'eval(file_get_contents("https://api.wordpress.org/secret-key/1.1/salt/"));foreach(explode(" ","AUTH_KEY AUTH_SALT LOGGED_IN_KEY LOGGED_IN_SALT NONCE_KEY NONCE_SALT SECURE_AUTH_KEY SECURE_AUTH_SALT")as$n){echo "WP_{$n} = '\''".constant($n)."'\''".PHP_EOL;}'
@kfriend
kfriend / gist:5272308
Last active July 10, 2016 14:24
OS X Keychain dumping script written in PHP. Dumps keychains to JSON.
#!/usr/bin/php
<?php
/**
* OS X Keychain Dump to JSON
*
* Big thanks to Romeo for outlining the initial steps for this:
* http://romeotheriault.blogspot.com/2009/01/exporting-mac-os-x-keychain-access.html
*
* Notes:
@kfriend
kfriend / get_unique_tags.php
Created March 9, 2016 04:15
Quick and dirty way to get all HTML/XML tags in a string
<?php
function get_unique_tags($data) {
preg_match_all('/<([^>]+)>/i', $data, $matches);
$matches = $matches[1];
foreach ($matches as $i => $match) {
$matches[$i] = trim($match, '/');
}
@kfriend
kfriend / gist:6396197
Created August 31, 2013 04:16
AppleScript: Create file w/ prompt
-- Get the currently selected item
tell application "Finder"
set currentFile to selection as text
end tell
set container to GetParentPath(currentFile)
display dialog "File name and extension" default answer "New File.txt"
set fileName to text returned of result
@kfriend
kfriend / gist:079ea35f6f496d053a5f
Last active March 5, 2016 22:44
Wordfence Falcon Homepage Workaround
<?php
// Wordfence Cache Workaround
// Apache 2.4.? - 2.4.8 contains a bug between mod_dir and mod_rewrite that prevents Wordfence's Falcon
// caching from working on the homepage, but just the homepage. This is a workaround for that issue.
$targetDomain = 'www.yourdomain.com';
// We'll need to check cookie existence to determine if the visitor is logged in. Some WP cookie names
// include a unique hash at the end, so we'll need to check by collecting all the cookie names, and
// passing them through a regex.
@kfriend
kfriend / gist:7415462
Last active December 28, 2015 00:39
.gitignore
# Annoying Files
.AppleDouble
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon^M^M
Thumbs.db
ehthumbs.db
@kfriend
kfriend / Repository.php
Last active December 25, 2015 10:59
PHP: Simple repository classes
<?php
// Todo
// - Add arrary-like iterating capabilities
class Repository
{
protected $attributes = array();
public function __construct(array $attributes = array())
@kfriend
kfriend / gist:6833594
Created October 4, 2013 22:05
PHP: time_to_second() helper. Converts HH:MM:SS format to seconds. Can leave out hours or minutes.
<?php
function time_to_seconds($time = 0)
{
list($secs, $mins, $hours) = array_pad(array_reverse(explode(':', $time)), 3, 0);
return ($hours * 3600) + ($mins * 60) + $secs;
}
on run
tell application "Numbers" to tell front document
set tPath to (POSIX file (get path)) as string
tell tPath to if it ends with ".numbers" then set tPath to text 1 thru -9 -- remove extension
save as "LSDocumentTypeCSV" in file tPath -- Numbers automatically adds the ".csv"
end tell
return tPath as alias -- return the path of the CSV file to the next action
end run
@kfriend
kfriend / gist:6396200
Last active December 22, 2015 01:28
AppleScript: Start screensaver
tell application "ScreenSaverEngine" to activate