Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Nicholas C. Zakas nzakas

I may be slow to respond.
View GitHub Profile
View WordPressPostCategoriesExport
//snip from wordpress/wp-admin/includes/export.php
/*$where = '';
if ( $author and $author != 'all' ) {
$author_id = (int) $author;
$where = $wpdb->prepare(" WHERE post_author = %d ", $author_id);
$query = "
View ButtonDelayDemo.htm
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Button Example</title>
<link rel="stylesheet" type="text/css" href="yui/fonts/fonts-min.css" />
nzakas / gist:655672
Created Oct 30, 2010
New behavior of arguments in ECMAScript 5
View gist:655672
/* Section 10.6 Note 1 in ECMA-262, 5th Edition says:
* For non-strict mode functions the array index (defined in 15.4) named data
* properties of an arguments object whose numeric name values are less than
* the number of formal parameters of the corresponding function object initially
* share their values with the corresponding argument bindings in the function's
* execution context. This means that changing the property changes the
* corresponding value of the argument binding and vice-versa.
* Thus, the following function should work.
View make-array.js
* Pre-ECMAScript 1, JavaScript didn't have native arrays.
* Those who needed them frequently used functions such as the following.
* Also note that there was no special "undefined" value.
function makeArray(len){
var array = new Object();
nzakas / gist:880432
Created Mar 21, 2011
Get updates list before merging
View gist:880432
# I was trying to figure out how to get a list of changes made remotely on Git
# before applying. Here's what I came up with.
# First, get the latest data from the origin
git fetch origin
# Then, get the changes and output to a file
git log HEAD..origin/master > changes.txt
# Merge changes in
nzakas /
Created Apr 7, 2011
You can download your Google Apps email from a shell script
#Download your Google Apps-hosted email
wget --secure-protocol=TLSv1 --no-check-certificate --password=your_password
nzakas / gist:991430
Created May 25, 2011
Error log (npm)
View gist:991430
nicholas@nicholas-VirtualBox:~/share/yuitest/javascript/build/yuitest/npm$ cat npm-debug.log
info it worked if it ends with ok
verbose cli [ 'node', '/usr/local/bin/npm', 'link', 'yuitest' ]
info using npm@1.0.6
info using node@v0.4.0
verbose config file /home/nicholas/.npmrc
verbose config file /usr/local/etc/npmrc
info unbuild /home/nicholas/share/yuitest/javascript/build/yuitest/npm/node_modules/yuitest
verbose link symlinking /usr/local/lib/node_modules/yuitest to /home/nicholas/share/yuitest/javascript/build/yuitest/npm/node_modules/yuitest
verbose mkdir done: /home/nicholas/share/yuitest/javascript/build/yuitest/npm/node_modules 755
nzakas / sprintf.js
Created Jun 8, 2011
Quick and dirty sprintf
View sprintf.js
* Quick and Dirty sprintf
* Copyright 2011 Nicholas C. Zakas. All rights reserved.
* BSD licensed
* This function does not attempt to implement all of sprintf, just %s,
* which is the only one that I ever use.
nzakas / .bashrc
Created Jul 13, 2011
Dead simple branch-in-prompt for Git
View .bashrc
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
PS1="\w\$(parse_git_branch) $ "
nzakas / anyword.js
Created Jul 23, 2011
"Any word" filter for YUI Autocomplete
View anyword.js
* Use the following in the "resultFilters" option when creating a YUI 3 Autocomplete
* widget. This will return matches when *any* of the words in the query string match.
* This is opposed to the default "wordMatch", which matches *all* words in the
* query string.
function matchAnyWord(query, results) {
var WordBreak = Y.Text.WorkBreak,