Skip to content

Instantly share code, notes, and snippets.

View albertpak's full-sized avatar

Albert Pak albertpak

View GitHub Profile

Fixing npm On Mac OS X for Homebrew Users

If you just want to fix the issue quickly, scroll down to the "solution" section below.

Explanation of the issue

If you're a Mac Homebrew user and you installed node via Homebrew, there is a major philosophical issue with the way Homebrew and NPM work together. If you install node with Homebrew and then try to do npm update npm -g, you will see an error like this:

$ npm update npm -g
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@albertpak
albertpak / Dev_tools
Created March 27, 2014 15:37
Links to useful tools for development
Alfred - http://alfredapp.com/
Moom - http://manytricks.com/moom
Sequel Pro - http://sequelpro.com/
iTerm 2 - http://iterm2.com/
PHPStorm - http://www.jetbrains.com/phpstorm/
@albertpak
albertpak / gist:8894205
Last active August 29, 2015 13:56 — forked from teejayvanslyke/gist:2569284
Simply paste this snippet into your document ready block to get started, then on any links you'd like to track, simply provide the data-mixpanel-tracker attribute: Specify custom properties in JSON using the data-mixpanel-properties attribute: <a href="/moon" data-mixpanel-tracker="he chose to go to the moon" data-mixpanel-properties="{agency: '…
$('a[data-mixpanel-tracker]').click ->
setTimeout (=> window.location.href = $(@).attr('href')), 300
tracker = $(@).attr('data-mixpanel-tracker')
properties = JSON.parse($(@).attr('data-mixpanel-properties') || '{}')
mixpanel.track tracker, properties
return false

Sublime Text 2 – Useful Shortcuts (Ubuntu)

General

Ctrl+KB toggle side bar
Ctrl+Shift+P command palette
Ctrl+` python console
Ctrl+N new file

Editing

Date

Year

%Y - Year with century (can be negative, 4 digits at least) -0001, 0000, 1995, 2009, 14292, etc.

  • %C - year / 100 (round down. 20 in 2009)
  • %y - year % 100 (00..99)
@albertpak
albertpak / fallback_local_CDN.js
Created January 8, 2014 22:44
YepNope http://yepnopejs.com/ Modernizr http://modernizr.com/ If you are using Modernizr and/or Yepnope, you can use this method to load your favorite library from the CDN and fall-back to your local version if the initial load fails. Src: https://coderwall.com/p/pmx_4w
//Load
yepnope([
{
load: [
'//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',
'//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js',
'//cdnjs.cloudflare.com/ajax/libs/raphael/1.5.2/raphael-min.js'
],
complete: function(){
<?php
//a simple script to check user agents to detemine device type and or redirect
//==============================================
//get userangent string
$userAgentraw = $_SERVER['HTTP_USER_AGENT'];
//convert to lowercase to make search strings simplier
$userAgent = strtolower ( $userAgentraw );
<?php
date_default_timezone_set('Europe/London'); // Set this to your local timezone - http://www.php.net/manual/en/timezones.php
/**
* The root directory where the repos live.
*
* @var string
*/
$root_dir = '/your/root/dir/';
<?php
function display_dynamic_pricing_table(){
global $post;
# see line 42 of woocommerce_pricing_by_product.class.php
$pricing_rule_sets = get_option('_a_category_pricing_rules', array());
$found = false;
if(count($pricing_rule_sets)){
global $woocommerce_pricing;
foreach ($pricing_rule_sets as $pricing_rule_set) {