Skip to content

Instantly share code, notes, and snippets.

View nzakas's full-sized avatar
💭
GitHub time is limited currently. Please be patient.

Nicholas C. Zakas nzakas

💭
GitHub time is limited currently. Please be patient.
View GitHub Profile
@nzakas
nzakas / inc.sh
Created July 2, 2015 18:07
Increment all numbers in the form "column: 1"
# This was used to update all column numbers in ESLint tests when we
# changed to 1-based columns from 0-based
$ perl -pi.bak -e "s/(column: *)([0-9]+)/\$1.(\$2+1)/e;" tests/lib/rules/*.js
//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 = "
SELECT ID
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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
nzakas / gist:655672
Created October 30, 2010 19:46
New behavior of arguments in ECMAScript 5
/* 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.
@nzakas
nzakas / gist:880432
Created March 21, 2011 23:08
Get updates list before merging
# 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
nzakas / DownloadYourEmail.sh
Created April 7, 2011 05:12
You can download your Google Apps email from a shell script
#Download your Google Apps-hosted email
wget --secure-protocol=TLSv1 --no-check-certificate --user=you@yourdomain.com --password=your_password https://mail.google.com/a/yourdomain.com/feed/atom
@nzakas
nzakas / gist:991430
Created May 25, 2011 17:29
Error log (npm)
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
nzakas / sprintf.js
Created June 8, 2011 02:56
Quick and dirty sprintf
/*
* 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
nzakas / .bashrc
Created July 13, 2011 23:21
Dead simple branch-in-prompt for Git
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="\w\$(parse_git_branch) $ "
@nzakas
nzakas / anyword.js
Created July 23, 2011 19:33
"Any word" filter for YUI Autocomplete
/*
* 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,