Skip to content

Instantly share code, notes, and snippets.

View pjdietz's full-sized avatar

PJ Dietz pjdietz

View GitHub Profile
@pjdietz
pjdietz / spotlight.md
Last active October 5, 2016 09:29
Remove Developer section from Spotlight

Source

  • Open Terminal. You will need to convert the file to XML (from binary) so you can edit it in TextEdit. The command you need is plutil -convert xml1 ~/Library/Preferences/com.apple.spotlight.plist
  • Edit this file in a text editor. Just before at the bottom, add the following:
<dict>
    <key>enabled</key>
    <false/>
 name
@pjdietz
pjdietz / httptest.php
Last active December 25, 2015 00:59
Test an HTTP request. Respond with information about the request.
<?php
// Return information about the request sent to this script.
$request = array(
'protocol' => $_SERVER['SERVER_PROTOCOL'],
'method' => $_SERVER['REQUEST_METHOD'],
'host' => $_SERVER['HTTP_HOST'],
'path' => $_SERVER['REQUEST_URI'],
'queryString' => $_SERVER['QUERY_STRING'],
'headers' => apache_request_headers(),
@pjdietz
pjdietz / compareByProperty.js
Created October 28, 2013 19:13
Return a compare function to sort objects by a given property
/**
* Return a compare function to sort objects by a given property.
* @param {string} property Name of the property to sort by.
* @return {function} A compare function
*/
function compareByProperty(property) {
return function (a, b) {
if (a !== undefined && b !== undefined && property in a && property in b) {
if (a[property] !== b[property]) {
return a[property] < b[property] ? -1 : 1;
@pjdietz
pjdietz / convertToAscii.php
Created November 6, 2013 19:37
PHP Functions for converting string to ASCII
<?php
/**
* Normalize non-ASCII characters to ASCII counterparts where possible.
*
* @param string $str
* @return string
*/
function squashCharacters($str)
{
@pjdietz
pjdietz / .profile
Created November 6, 2013 20:38
Profile file for OSX
# Add ~/bin and /usr/local/bin to the PATH
export PATH=$HOME/bin:/usr/local/bin:$PATH
launchctl setenv PATH $PATH
# Add color
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
@pjdietz
pjdietz / config.nanorc
Created November 15, 2013 20:24
Syntax Highlighting for configuration files in Nano
# From https://bbs.archlinux.org/viewtopic.php?id=133595
# To use, store to /usr/share/nano/conf.nanorc
# Add the following line to ~/.nanorc
# include include /usr/share/nano/conf.nanorc
# config file highlighting
syntax "conf" "(\.(conf|config|cfg|cnf|rc|lst|list|defs|ini|desktop|mime|types|preset|cache|seat|service|htaccess)$|(^|/)(\w*crontab|mirrorlist|group|hosts|passwd|rpc|netconfig|shadow|fstab|inittab|inputrc|protocols|sudoers)$|conf.d/|.config/)"
# default text
@pjdietz
pjdietz / permissions.bash
Created November 19, 2013 19:23
Set file and directory permissions with find, xargs, chmod
# Set all directories to 755, all files to 644.
find -type d -print0 | xargs -0 chmod 755
find -type f -print0 | xargs -0 chmod 644
@pjdietz
pjdietz / pallyheal
Last active January 2, 2016 22:59
Weakaurs Paladin Healing Bars
dOZ1faGljW2iLzIimBb3MsDtLi6Ukr4Bs0Pr1oryVWUv0(fs9tsQHrQghv1Lv1qrKgSe0Wvshui6Ws6yuPZPsTqvYsvcPflewUOEiIONsSmfEostKeQPsXKPKPl1fvIQFlYZOIRtv2ij6Xc1MrX2vcvFujsojjKPPIVRemsLi1NvQrtcgVqYLuIYTijxdLopI6TkH4VsOxRekdxyGuHbnekKrb6f4aXgIfelyGeLAgg63G44YwGUU7r74FCkzHqwndd9BOuZrZ3PKv74OFy999bJQZbc9dmKM4ZgYLAJr9ssILR0aj)BEAAiV(q25K3kKPNTjZ37ptbHleUfesRHa5OlCP)AasivTGbsofEyGy7fAomOrJgYh1ADA9w4cnKyyaHlmqIsndd9BOu1TUoR)44RXo01gLdWOIDaPZ89(ZWajTWu9mqgxqMv7NcdiCHCvPnpnJUWet0fUuHuMmAiXE0ozxubU1dP52VfAiruZKmfszyaHlu67RXERF7ZE0000goGrfRdiCaHlAiR50o)ukP5pMt5Pji0HesvlyG4r)IXHkLIli5u4HbITxO5WGgne66hddekFUdpigqS9cnhgqmWfA0q8OFX4KDe1gxqIdvkfgiu(ChEiKgjjIuXkIanAitpBtMV3FMccxi0UgVyusMcPmmGWfkpSd3HMUV(WP8U8EagvA6GyacD0qY)MNMgYRpKQxUgrndHBb5QsBEAcXItxdvYMpQEr5BfAilBn6cxKLrxcivllEZtZAOyN579NPWGgcz1mm0VbHEb666USdw)s)BDTblAqmGbsuQzyOFdcv6fCFF7xwEpU18lzH0z(E)zyGKwyQEgiJliZQ9tHbeUqwE)5zneDHkdv7hnKypANSlQa36H0C73cnKiQzsMcPmmGyaLALUUJJgRUdRZGv)agvSoOHSMt78tPKM)yoLNMGqhsivTGbIh9lghQukUGKtHhgi2EHMddA0q8OFX4KDe1gxqORFmmqO85o8GyaX2l0CyaXaxOrdjouPuyGq5
@pjdietz
pjdietz / pally_ret_inquitision
Created January 11, 2014 16:35
Weakauras Retribution Paladin Inquisition Bar
dGZ0faGlveTnIQ9jKYmLQA2s6MQi8nsu7ef7f2nPUTc)KKAyc14ujoTQgQqCzQgUu5GQKopfCmk6CQuTquQLkiTyb1Yv6HQi9uKLrcphvtKePPsyYcmDrxKOuxLOKEMkCDj2irXXfs2mrSDvuEmk57cIPrKMhrjgjjIpROrtHmEvuDsvk3Ic11ij3tiv)vQYHLYVP0WecqniqcIdsXjJp5bObOaqbqa6C1sKW9eYixLCZlxUl)YDvhsLkxkKySuPGmOwIeUNqg5svyAkv(Ldfsvoo2uoKySuPG4Evse7RtqSvleQprFzlJa06Z3Qfg6CqZ1w6aPldX(ZPVCWyc6daDthv55F(wnOQTfabO1wDiank18HajsKG8Z7A6apaHrcIfeGXecq5(ZPVqaA9bOJyq2q0Q1vdGniDB4CiaJjOB6Okp)Z3QrcA9H6oFBPDbfTOdQW9q9bydIvHN2rpJ(ahu(dpajOWT9uB1UqagtWedgfGXemhqgvhYVC)UYkIvCrH844diXyvYrcQBTZ158iRZ65VvdMyqvBlacqfU3JvTX5GnO1wDiank18Hajsq8oNfeG4VEwDWCaAuQ5dbyoaBKibXQ24CiaXF9S6GICT)vLEJbjsq6YqS)C6lhmMGwF(wTWqNdQv2w42c6daPKFAesWOacq5(ZPVqaA9bOJyq2q0Q1vdGniDB4CiaJjOB6Okp)Z3QrcIvHN2rpJ(ahu(dpa06d1D(2s7cswav4EO(aSrckCBp1wTleGrbKrzLpuP6Uu5QKgRSPCLvbjgR6ajOU1oxNZJSoRN)wnyIbvTTaiav4Epw1gNd2GwB1Ha0OuZhcKibX7CwqaI)6z1bZbOrPMpeG5aSrIeeRAJZHae)1ZQdkY1(xv6ngKibT(8TAHHohuRSTWTf0ha6eEWxgGAbbF(wDR2l3Fo9LdbymHauU)C6leGsdDoOwzBG4LW(zUoPIej)5G6D6vs0JexdvaYgIwTUAaSb5N56eKs8wnnceVe2pZ1zK1L8NdIIi7(9bf4
@pjdietz
pjdietz / slugify
Last active January 15, 2024 15:24
Rename a file to a URL-friendly version of the filename
#!/usr/bin/env python
import os
import os.path
import re
import shutil
import sys
# Help message
HELP = """Slugify