Skip to content

Instantly share code, notes, and snippets.

View wilmoore's full-sized avatar

Wil (₩) Moore III wilmoore

View GitHub Profile
@haschek
haschek / .jshintrc
Created May 4, 2012 16:08
JSHint Configuration, Strict Edition
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true
@cowboy
cowboy / tab-indent-rant.js
Created May 3, 2012 19:18
JavaScript: tab indents
// Coders, if your goal is to align foo and bar, using a <tab> character is
// incorrect. If your goal, however, is to create an additional level of
// indentation, then go you. Either way, with a tab size other than 4, this
// looks like shit.
var foo = 1,
bar = 2;
@wilmoore
wilmoore / sinatra.sh
Created May 2, 2012 23:03
Contributing to Ruby-based projects should always be this easy
# Obtain the project (assumes you've forked it)
% cd ~/projects
% git clone [email protected]:wilmoore/sinatra.git && cd sinatra
% bundle install
# Run Tests
% bundle exec rake test
@wilmoore
wilmoore / tests.html
Created April 30, 2012 21:47
YUI3 Test Skeleton Setup: for testing your YUI3 powered modules
<!doctype html>
<html>
<title>Test Console</title>
<body class="yui3-skin-sam">
<div id="test-console"></div>
<script src="http://yui.yahooapis.com/3.5.0/build/yui/yui-min.js"></script>
<script src="tests.js"></script>
</body>
</html>
@wilmoore
wilmoore / limitations.md
Created April 30, 2012 17:24
YUI Resources for TDD/BDD w/ YUI3 Test

YUI3 Test Limitations

  • YUI3 Test does not support Data Providers for Parameterized Testing. You are welcome to use the extremely hacky solution that I came up with.
  • Because checking for failures (errors/exceptions) must be defined as a separate hash by name, you end up with a lot of duplication and potential for errors if you forget to rename the item in the "error" hash after renaming the test method.
  • Because checking for failures (errors/exceptions) must be defined as a separate hash by name, you lose the ability to dynamically check for errors/exceptions.
@unclebob
unclebob / apology.
Created April 27, 2012 12:19
Apology to Women Programmers.
Today I gave a keynote at ACCU in Oxford. In the midst of it I made two (count them) two statements that I should have known better than to make. I was describing the late '70s, and the way we felt about the C language at the time. My slide said something like: "C was for real men." Emily Bache, whom I know and hold in high regard, spoke up and said "What about women?". And I said something like: "We didn't allow women in those days." It was a dumb crack, and should either not have been said, or should have been followed up with a statement to the effect that that was wrong headed.
The second mistake I made was while describing Cobol. I mentioned Adm. Grace Hopper. I said something like "May she rest in peace." I don't know that any of the words were actually demeaning, but the tone was not as respectful as it should have been to an Admiral in the United State Navy, and one who was so instrumental in our industry; despite what I feel about Cobol.
I am a 59 year old programmer who was brought up
@wilmoore
wilmoore / user_tz_to_utc.php
Created April 5, 2012 16:48
Playing with DateTime and DateTimeZone
<?php
// assume these preferences came from a database as-is
$userTimezonePreference = 'America/Denver';
$userStoredDateTime = '2012-04-02 00:15:40';
$dateTime = new DateTime($userStoredDateTime, new DateTimeZone($userTimezonePreference));
echo 'ORIG: ', $dateTime->format(DateTime::RFC2822), PHP_EOL;
$dateTime->setTimezone(new DateTimeZone('UTC'));
echo 'USER: ', $dateTime->format(DateTime::RFC2822), PHP_EOL;
@wilmoore
wilmoore / width_71.php
Created March 21, 2012 05:29
80 character limit is unreasonable and unattractive
// breaks on 71st character -- breaking on 7x characters seems unreasonable
public function setAuthSubPrivateKeyFile($file, $passphrase = null,
$useIncludePath = false) {
@wilmoore
wilmoore / with_5.4.php
Created March 20, 2012 19:23 — forked from ruprict/build_params.php
Retrieve whitelisted set of parameters
<?php
function filter_params(array $params = [], array $whitelist = []) {
return array_map('trim', array_intersect_key($params, array_flip($whitelist)));
}
$params = ['is_admin' => 1, 'name' => ' Bob', 'surname' => 'Smith '];
$whitelist = ['name', 'surname'];
// these are your whitelisted parameters (please don't forget to filter/validate before persisting)
@wilmoore
wilmoore / jQuery.ScrollTo.js
Created March 9, 2012 17:09
Various Anchor Scroll Implementations
// SEE: http://demos.flesler.com/jquery/scrollTo/