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 / 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 / gist:5379036
Created April 13, 2013 16:18
Move all files from a directory structure into a single directory
#!/bin/sh
find . -maxdepth 100 -type f -exec mv {} /path/to/destination \
@kfriend
kfriend / gist:5379046
Created April 13, 2013 16:20
Allow "unsupported" volume type with Time Machine
#!/bin/bash
defaults write /System/Library/LaunchDaemons/com.apple.backupd-auto TMShowUnsupportedNetworkVolumes 1
@kfriend
kfriend / gist:5579653
Created May 14, 2013 21:21
50 States array
<?php
array(
'AL' => 'Alabama',
'AK' => 'Alaska',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
@kfriend
kfriend / gist:5625241
Created May 22, 2013 04:27
PHP flattening function. Turns a record into a dot-delimited array, converting both nest arrays and objects
<?php
function flatten($record, $prepend = '', $delimiter = '.')
{
$results = array();
foreach ($record as $key => $value)
{
if (is_array($value) or is_object($value))
{
@kfriend
kfriend / gist:5709227
Last active December 18, 2015 02:09
Simple regex for matching empty HTML tags
#<([a-z])[^(>|\/>)]*>(\s)*<\/\1[^>]*>#i
@kfriend
kfriend / gist:5966561
Last active December 11, 2018 21:59
wget command tasks
# Scape a site w/ a few retries
wget -m -r --tries=5 "http://foo.bar"
# Scape a site w/o images
wget -m -r --tries=5 -R jpg,jpeg,png,gif,bmp "http://foo.bar"
@kfriend
kfriend / gist:6020523
Created July 17, 2013 13:23
Vagrant share fix
lsmod | grep vboxsf
sudo /etc/init.d/vboxadd setup
@kfriend
kfriend / gist:6041800
Last active December 20, 2015 00:29
JavaScript: Function to detect if user agent is a "touch" device
<script>
// Detect if user agent is on a "touch" device
// http://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript
function isTouchDevice() {
return !!('ontouchstart' in window) // works on most browsers
|| !!('onmsgesturechange' in window); // works on ie10
}
if (isTouchDevice()) {
document.documentElement.className += ' touch';
@kfriend
kfriend / gist:6041953
Last active December 20, 2015 00:29
Windows rearm: Bump trail period time
:: Windows XP
rundll32.exe syssetup,SetupOobeBnk
:: Windows Vista or newer
slmgr –rearm