Advanced GitHub issue filtering

A little over a year ago, I posted about using dotjs to add buttons for advanced issue filtering on GitHub. With GitHub’s launch of their revamped Issues page, or dotjs code is no longer needed! Issue filtering is where it’s at:

Filters

Example filter on Twitter Bootstrap’s GitHub page

Example: all bugs that aren’t labeled as “help wanted”

If you are looking at Twitter Bootstrap CSS issues, but don’t want to see items that are awaiting QA, add -label:"help wanted" to the Filter box. It should look like this:

is:open is:issue label:css -label:"help wanted"

Example: involving mdo with more than 2 comments

To get all open CSS issues on Twitter Bootstrap that have involved mdo in some way and have >2 comments:

is:open is:issue label:css involves:mdo comments:>2

Useful links

That’s just the tip of the iceberg for what can be done with the new Filter UI. GitHub has some docs that are worth a read:

Discovering the events attached to elements in jQuery

If you have a need to find what events are attached to an element in jQuery, here’s what you do:

Finding events attached to the document:


jQuery._data( jQuery( document )[0], 'events' );

Finding events attached to an element with an ID of bacon:


jQuery._data( jQuery( '#bacon' )[0], 'events' );

Here’s a snippet I’ve been using in the console:

var events = jQuery._data( jQuery( document )[0], 'events' );
for ( var i in events.click ) {
  console.log( 'click ' + i + ' :: ' + events.click[ i ].selector );
}

Bringing back the console API on Netflix and Facebook

Facebook and Netflix have implemented some code that breaks the console API in Chrome by changing the getter/setter for the console property on the window object. The purpose is noble – to help avoid a social engineering attack - but as a developer it irks me. I want my console when and where I want it.  In short order, Zach and I had a fix in place that unbreaks the console.

Using dotjs – which I’ve written about at Gigaom Kitchen - we can run the following code before the console-breaking code executes (here’s my dotjs file):

var s = document.createElement('script');
s.innerHTML = 'Object.defineProperty(window, "console", {writable: false});';
document.head.appendChild( s );

MDN writes on the writable property:

When the writable property attribute is set to false, the property is said to be “non-writable”. It cannot be reassigned.

Now I get my console :)

Setting /etc/hosts on an Android Emulator using a Mac

Testing sites on mobile devices is a necessity. When you find a bug that needs some loving and you want to do the code tweaks on your localhost, the Android emulator balks. It doesn’t know anything about your localhost. Luckily, you can resolve this by editing the emulator’s /system/etc/hosts/ file. Here’s what to do:

First, start your emulator setting a partition size so the emulator doesn’t throw an out of memory error:

$ emulator -avd nameOfAvd -partition-size 512

Next – in another shell window/tab – check what devices are running (so you can edit the one you want):

$ adb devices

List of devices attached
emulator-5554 device

The emulator-5554 is the device I started with the emulator command. Right now it is in read-only mode. Remount the device to make it writable

$ adb -s emulator-5554 remount

remount succeeded

Now that it is remounted, grab the hosts file and put it somewhere on your filesystem (I use the Desktop):

$ adb -s emulator-5554 pull /system/etc/hosts ~/Desktop/

6 KB/s (25 bytes in 0.003s)

Edit the ~/Desktop/hosts file as needed with the editor of your choice:

127.0.0.1        localhost
192.168.1.100    bacon.local

Finally, push that hosts file onto your emulator:

$ adb -s emulator-5554 push ~/Desktop/hosts /system/etc/hosts

45 KB/s (249 bytes in 0.005s)

BAM! The emulator can now access sites using the hosts specified in the newly edited hosts file.

Useful docs: emulator and managing AVDs

Activating BuddyPress for PHPUnit WordPress-tests

I have found myself writing PHPUnit tests for WordPress plugins lately (using wordpress-tests) and the code that I’m working with has a dependency on BuddyPress.  Enabling BuddyPress for WordPress unit testing requires a bit of hoop jumping because you can’t use the wp_tests_options global variable as you would any other plugin in your local bootstrap file (which is configured in phpunit.xml):

$GLOBALS['wp_tests_options'] = array(
  'active_plugins' => array(
    'wp-debug-robot/wp-debug-robot.php'
  ),
);

Instead, run the following within your bootstrap file after you’ve included the wordpress-tests bootstrap:

  // activate the buddypress plugin for your network (if you aren't running MULTISITE, the third parameter should be FALSE)
  activate_plugin( WP_CONTENT_DIR . '/plugins/buddypress/bp-loader.php', '', TRUE, TRUE );

  // set the components that you want to activate
  $active_components = array(
    'activity' => TRUE,
    'friends' => FALSE,
    'groups' => FALSE,
    'messages' => TRUE,
    'xprofile' => TRUE,
    'blogs' => TRUE,
  );

  // update your site's bp-active-components option with your configured settings
  update_option( 'bp-active-components', $active_components );

  // include the file that contains the logic you need to create BuddyPress tables
  require_once WP_CONTENT_DIR . '/plugins/buddypress/bp-core/admin/bp-core-schema.php';

  // run the installer
  bp_core_install();

With that in place, your tests should have BuddyPress classes & functions available to you – complete with BP tables in your database!

Bypassing Output Buffering in PHP

I’ve been developing with PHP for over a decade and I just love it when I learn a new trick.

Perhaps you are working on a command line script and want some feedback, but you’re output buffering to generate a fancy report (or something).  You can bypass the output buffering with this little trick

<?php

ob_start();

echo "BOOM!\n";

fwrite( STDOUT, "You smell funky\n" );

echo ob_get_clean();

Result:

You smell funky
BOOM!

Chromedriver doesn’t run in tmux and here’s how to fix it

Aw, Snap ScreenshotIf you are attempting to run Selenium using the Chromedriver while in a tmux session, you may have encountered some issues with chromedriver.  Specifically, this error:

Aw, Snap!

Something went wrong while displaying this webpage. To continue, reload or go to another page.

If you’re seeing this frequently, trie these suggestions.

A simple solution is to just execute the Selenium jar in a shell session outside of your good friend, tmux.

java -jar ~/bin/selenium-server-standalone-2.33.0.jar -browserSessionReuse -Dwebdriver.chrome.driver=bin/chromedriver

One of my friends, however, alerted me to this article that has a solution:

  • Get Homebrew, if you don’t already have it.
  • brew install reattach-to-user-namespace
  • Add the following line to your .tmux.conf file: set-option -g default-command "reattach-to-user-namespace -l zsh" (replace zsh with bash if you use that)

This fix also resolves the issue that prevents pbcopypbpaste, etc from working in tmux!

Guild Wars 2 for the Mac Without Re-downloading the Whole Game

Today, ArenaNet announced Guild Wars 2 for the Mac (beta).  As excited as I was for that announcement, I wasn’t looking forward to downloading the client all over again.  With some digging, I discovered that I could simply copy my GW2.dat file from my windows installation to the mac install.  Here’s how:

  1. Make your Windows client GW2.dat file available some how (mine is on an external drive)
  2. Download the Mac client.
  3. Run the installer.
  4. When the login window/downloader shows its ugly face, close the window.
  5. In your Finder window, navigate to your Guild Wars 2 install.
  6. Right click the Guild Wars 2 application and select “Show Package Contents”.
  7. Navigate to: Contents > Resources > transgaming > c_drive > GW2
  8. Copy your GW2.dat file from step 1 over the top of the GW2.dat file in the Finder window.
  9. Run the game and it’ll download any updates!

Easy!

Preparing a Site for SOPA Blackout with .htaccess

BorkWeb, like a number of other sites, will be going black this Wednesday as a protest to SOPA.  Legends of the Sun Pig has an excellent article on this exact topic.  Martin writes:

Google recommends using HTTP 503 “Service Unavailable” status codes. The 503 code indicates that the service (or page, or site) is temporarily unavailable, but that it is expected back again soon. This is better than using the 404 (not found), 302 ( moved temporarily), or 301 (moved permanently) codes, because it tells web crawlers that they should just come back and try again later.

Because I have no desire to manually make the cut-over to a SOPA Blackout .htaccess file at midnight (because I’m lazy), I took his .htaccess settings and made a modification to enable the settings for the tomorrow.  Here’s what I have:

<IfModule mod_rewrite.c>

# =====================
# SOPA Blackout
# =====================

# Set a custom error document for 503 errors
ErrorDocument 503 /503_sopa.html

# Cause all requests (except images) to generate a 503 error,
# which will produce the custom 503 error document
RewriteEngine on
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} !=503
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteCond %{REQUEST_URI} !robots\.txt$ [NC]
RewriteCond %{TIME_YEAR} ^2012
RewriteCond %{TIME_MON} ^01
RewriteCond %{TIME_DAY} ^18
RewriteRule ^ - [L,R=503]

# =====================
# NOT SOPA Blackout
# =====================

# My other rewrite magic goes here.
</IfModule>

Additionally, I’ve shamelessly stolen the php.net SOPA 503 page because it is awesome.

Vim Undo Magic

Ever have a time when you are happily editing a script in vim and you realize you made a mistake over the course of editing? Luckily, Vim supports back in time undos.

You want to go back 10 minutes?

:earlier 10m

You want to go forward in time by 5 seconds?

:later 5s

Sweet cuppin’ cakes that’s ballsy. Armed with this tool, you step forward and backwards in your undo/redo adventure, you make an accidental edit. Whoops. Now all the code you’ve edited in the 10 minutes that you rolled back with the handy-dandy <code>:earlier</code> command is gone…right?

Nope! Undo branching is where the real awesomeness of Vim shines. If you realize your mistake, you can find a list of undo branches like so:

:undolist

Which will show you something like this:

number changes when saved

3 3 08:59:35
4 2 09:00:13

To jump to one of those branches, you can type:

:undo 3 or :undo 4

I <3 Vim

(via Life Hacker)

Sites Not Reachable After Linode Restart

I have recently moved the majority of my sites over to my CentOS Linode VPS and I was experience some load issues that prevented me from gaining SSH access.  As such, I decided to restart my VPS.  After the restart, I found that my sites were not reachable…lame.

First, I checked the firewall found here:

/usr/bin/system-config-securitylevel-tui

So…the firewall was fine.  Next, I attempted to restart the network via:

/etc/init.d/network restart

I was surprised to receive the following error:

Bringing up interface eth0: Device eth0 has different MAC address than expected, ignoring. [FAILED]

Alrighty…bizarre.  So with the help of this article, I was able to determine that eth0′s MAC address:

/sbin/ifconfig eth0

was different than the MAC address found in:

/etc/sysconfig/network-scripts/ifcfg-eth0

A simple edit to the above file and a quick network restart solved my problem and brought my sites back up! w00t!

Star Wars: Death Troopers

Death Troopers, a novel by Joe Schreiber will be released on Tuesday (October 13, 2009) and takes place just before “A New Hope”. What is it? A Star Wars horror book. That is something that I didn’t expect to ever see. I’m interested enough that I just might read it. Here’s the plot:

When the Imperial prison barge Purge breaks down in a distant, uninhabited part of space, its only hope seems to lie with a Star Destroyer found drifting, derelict and seemingly abandoned. But when a boarding party is sent to scavenge for parts, only half of them come back — bringing with them a horrific disease so lethal that within hours, nearly all aboard the Purge will die. And death is only the beginning.

For aboard the Star Destroyer, amid its vast creaking emptiness that isn’t really empty at all, the dead are rising, soulless, unstoppable, and unspeakably hungry.

What is awesome is that there are a number of fans that have come up with trailers for the book. This post has a large number of them, but here’s my favorite.

Pretty creepy.

Heroes of Newerth: Patch 0.1.39 Released

Heroes of Newerth has released patch 0.1.39 that brings in 2 new heroes (I’ve updated my HoN/DotA equivalents post appropriately)!


Wretched Hag
Equivalent of the Queen of Pain in DotA

Succubus
Equivalent of the Bane Elemental in DotA

For those interested, the full changeset is as follows:

Version 0.1.39
————–

General:
- Added PSR and clan information to the in-game player stats screen
- Changed requirements for Remake vote to pass
* It now requires the total number of players minus 2 to vote yes. If less than 4 people are voting, it requires
* If more than 4 people are voting, (total players – 2) votes are required to pass. If more than 2 people are voting, (total players – 1) votes required. Otherwise, 100% required to pass.
- Restricted game data not relevant to a players’ team
* This will prevent map hacks from working in HoN
- Fixed several effects showing up through the fog of war
- Updated Portuguese translation

New heroes:
- Wretched Hag, based on DOTA’s Akasha, the Queen of Pain
- Succubus, based on DOTA’s Bane Elemental

General Gameplay:
- Added team-based skills, Demonic Fortification for Hellbourne and Fortification of Sol for Legion
* These skills are accessed by clicking on any team structure then clicking on the corresponding button in the info pane in the lower right of the screen
* These skills share a global cool down time. Anyone on the team may activate them, but then they go into cool down for everyone
* When used, these skills apply +9999 armor to all allied structures

Arachna:
- Slightly increased visual size of the Spiderling
- Fixed a bug causing Spider Sting to not hit stealth units if they go stealth before the projectile hits them

Behemoth:
- Fixed some issues with fissure not impacting properly on higher level terrain or impacting units standing near the behemoth

Magmus:
- Added more detailed cast effects to Eruption and modified the animation. It should now be clearer when Magmus starts this skill

Pebbles:
- Reworked Chuck, it should now deal its damage consistently
- Units affected by Chuck will now take double the damage from Stalagmites
- Chuck will no longer be greyed out when no valid units are nearby to throw
- Reworked Stalagmites to properly delay based on distance
- Stalagmites now has a 600 base cast range, to match its DOTA counter-part
* Enlarge still increases the range of this skill by 50/100/150, making the maximum range now 750, from 700

Pestilence:
- Fixed a bug causing Swarm to not hit stealth units if they go stealth before the projectile hits them

Swiftblade:
- Swift Slashes will no longer hit siege units or gadgets

Bug fixes:
- Fixed a missing icon for Kongor’s Cheese

Heroes of Newerth: DotA Hero Equivalents

hon_logo

As I’ve posted many times on this blog, I’m a huge fan of DotA (Defense of the Ancients). It is only right that I suddenly become enamored with Heroes of Newerth (HoN), a game by S2Games currently in beta that matches the functionality of DotA and adds a layer of awesomeness on top.

I’ve played a number of games so far and have found one of my biggest hurdles is re-learning the heroes in HoN. Luckily, many of the heroes are simply ports of DotA heroes but learning who is who is also a slow process. Here are heroes in HoN with their DotA equivalents:

Legion: Agility | Intelligence | Strength

Hellbourne: Agility | Intelligence | Strength

Legion Agility Heroes

Back To Quick Links

HoN Hero

DotA Hero


Night Hound
=
Stealth Assassin

Swiftblade
=
Juggernaut

Magebane
=
Anti-Mage

Moon Queen
=
Moon Rider (Luna)

Valkyrie
=
Priestess of The Moon (Mirana)

Wildsoul
=
Lone Druid (Syllabear)

Scout
= No Equivalent

Legion Intelligence Heroes

Back To Quick Links

HoN Hero

DotA Hero


Blacksmith
=
Ogre Magi

Thunderbringer
=
Lord of Olympia (Zeus)

Ophelia
=
Holy Knight (Chen)

Pollywog Priest
=
Rhasta

Pyromancer
=
Slayer (Lina Inverse)

Tempest
=
Enigma

Nymphora
= No Equivalent

Zephyr (Owlman)
= No Equivalent

Legion Strength Heroes

Back To Quick Links

HoN Hero

DotA Hero


Armadon
=
Bristleback

Behemoth
=
Earthshaker

Hammerstorm
=
Rogue Knight (Sven)

Jereziah
~=
Omniknight

Legionnaire
=
Axe

Pebbles
~=
Stone Giant (Tiny)

Keeper of the Forest
~=
Treant Protector

Predator
= No Equivalent

Hellbourne Agility Heroes

Back To Quick Links

HoN Hero

DotA Hero


Chronos
=
Faceless Void

Slither
=
Venomancer

Blood Hunter
=
Bloodseeker

Soulstealer
=
Shadow Fiend

Arachna
= No Equivalent

The Madman
= No Equivalent

The Dark Lady
= No Equivalent

Hellbourne Intelligence Heroes

Back To Quick Links

HoN Hero

DotA Hero


Defiler
=
Death Prophet (Krobelus)

Demented Shaman
=
Shadow Priest

Glacius
~=
Crystal Maiden

Hellbringer
~=
Warlock

Succubus
=
Bane Elemental

Torturer
~=
Tormented Soul (Leshrac)

Voodoo Jester
~=
Witch Doctor

Wretched Hag
=
Queen of Pain

Puppet Master
= No Equivalent

Hellbourne Strength Heroes

Back To Quick Links

HoN Hero

DotA Hero


Accursed
=
Lord of Avernus (Abaddon)

Devourer
=
Butcher (Pudge)

Magmus
=
Sand King

Pharaoh
=
Clockwerk Goblin

Pestilence
=
Slithereen Guard (Slardar)

Warbeast
=
Lycanthrope

Electrician
= No Equivalent

Kraken
= No Equivalent