Skip to content

Instantly share code, notes, and snippets.

@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active September 15, 2024 20:33
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@frankiejarrett
frankiejarrett / gist:5544469
Last active June 17, 2019 16:13
Return an attachment ID using a URL in WordPress
<?php
/**
* Return an ID of an attachment by searching the database with the file URL.
*
* First checks to see if the $url is pointing to a file that exists in
* the wp-content directory. If so, then we search the database for a
* partial match consisting of the remaining path AFTER the wp-content
* directory. Finally, if a match is found the attachment ID will be
* returned.
*
@rachelbaker
rachelbaker / install-yeoman-osx.md
Last active June 24, 2024 14:48
Instructions for installing Node NPM and Yeoman on OSX
@return1
return1 / trim_enabler.txt
Last active May 26, 2024 11:01
TRIM Enabler for OS X Yosemite 10.10.3
#
# UPDATE for 10.10.4+: please consider this patch obsolete, as apple provides a tool called "trimforce" to enable trim support for 3rd party SSDs
# just run "sudo trimforce enable" to activate the trim support from now on!
#
# Original version by Grant Parnell is offline (http://digitaldj.net/2011/07/21/trim-enabler-for-lion/)
# Update July 2014: no longer offline, see https://digitaldj.net/blog/2011/11/17/trim-enabler-for-os-x-lion-mountain-lion-mavericks/
#
# Looks for "Apple" string in HD kext, changes it to a wildcard match for anything
#
# Alternative to http://www.groths.org/trim-enabler-3-0-released/
@ev3rywh3re
ev3rywh3re / gist:2587766
Created May 3, 2012 18:10
Linux: grep command line notes
## Search for scary PHP stuff.
grep "((eval.*(base64_decode|gzinflate))|r57|c99|sh(3(ll|11)))" ./ -roE --include=*.php*
@ev3rywh3re
ev3rywh3re / gist:2587742
Created May 3, 2012 18:07
Linux: find command notes
## find hidden directories
find . -name '.*' -type d -print
## Change permissions recursively using FIND:
find /var/www/html/ -print -exec chmod <permissions> {} \;
find /var/www/html/ -print -exec chown <owner.group> {} \;
## For seLinux you should know wtf chcon does and modify appropriately.
@ev3rywh3re
ev3rywh3re / wp-fix-bad-win-latin-garbage.sql
Created May 3, 2012 17:52
WordPress: fix bad windows-latin garbage in database
update wp_posts
set post_content = replace(post_content,'’','\'');
update wp_posts
set post_content = replace(post_content,'…','...');
update wp_posts
set post_content = replace(post_content,'–','-');
update wp_posts
set post_content= replace(post_content,'“','"');
update wp_posts
set post_content= replace(post_content,'”','"');