Jason Reposa http://www.jasonreposa.com Most recent posts at Jason Reposa posterous.com Thu, 19 Jan 2012 06:50:00 -0800 PHP: Preserve Keys in array_splice http://www.jasonreposa.com/php-preserve-keys-in-arraysplice http://www.jasonreposa.com/php-preserve-keys-in-arraysplice

array_splice is a wonderful little function. Unfortunately it doesn't preserve the keys if they're numeric. I've tried many combinations of array_shift, array_slice and even array_reverse and array_pop. Here's my solution that preserves numeric keys.

1
2
3
4
5
6
7
8
9
function array_psplice(&$array, $offset = 0, $length = 1) {
$return = array_slice($array, $offset, $length, true);

foreach ($return as $key => $value) {
unset($array[$key]);
}

return $return;
}

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Wed, 26 Oct 2011 07:09:27 -0700 Add a nofollow link to a Wordpress caption and remove the forced width http://www.jasonreposa.com/add-a-nofollow-link-to-a-wordpress-caption-an http://www.jasonreposa.com/add-a-nofollow-link-to-a-wordpress-caption-an

Due to some additional licensing requirements we've been required to add a source to some of our images on MyBankTracker.com. Unfortunately Wordpress captions don't support links, so I wrote a quick filter that you can add to your functions.php file.

Additionally it removes the forced width that Wordpress applies as well.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Originally built for http://www.mybanktracker.com/bank-news/
function mbt_img_caption_shortcode($val, $attr, $content = null) {
extract(shortcode_atts(array(
'id' => '',
'align' => 'alignnone',
'width' => '',
'caption' => ''
), $attr));

// if it contains a pipe character, we know it's ours
if (strpos($caption, '|') === FALSE) {
return;
}

$tokens = explode('|', $caption);
$caption = array_shift($tokens);
$href = implode('|', $tokens);
if (!empty($href)) {
$caption .= ' <a href="' . $href . '" rel="nofollow">source</a>';
}

if ( 1 > (int) $width || empty($caption) )
return $content;

if ( $id ) $id = 'id="' . esc_attr($id) . '" ';

return '<div ' . $id . 'class="wp-caption ' . esc_attr($align) . '">'
. do_shortcode( $content ) . '<p class="wp-caption-text">' . $caption . '</p></div>';
}

// what is 10, 3 for?
add_filter('img_caption_shortcode', 'mbt_img_caption_shortcode', 10, 3);

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Tue, 25 Oct 2011 10:57:00 -0700 ReferenceError: java is not defined - Mac OS X - Firefox 4, 5, 6, 7+ http://www.jasonreposa.com/java-not-defined-mac-os-x-firefox-4-5-6-7 http://www.jasonreposa.com/java-not-defined-mac-os-x-firefox-4-5-6-7

For grabbing screenshots we often use iOpus' wonderful Firefox plugin iMacros. Today I opened an old macro and it failed to run. It turns out that it uses the global java object (via LiveConnect) to read and write files, and the global java object was no longer available.

Other error message you may see include, "ReferenceError: java is not defined (Error code: 991)" from iMacros, or simply "ReferenceError: java is not defined" from Firebug or the browser itself.

The simple solution is to check "Enable applet plug-in and Web Start applications" in the Java Preferences app. Use spotlight to find it.

Screen_shot_2011-10-25_at_2
Then restart Firefox and try to run the macro again and it should work. If you're using Firebug, you can easily test to see if it's installed correctly by typing "java" into the console. If installed you should see "[Java Package "java"]" as output.

Screen_shot_2011-10-25_at_2

Theories why this happened? Most likely it's because Java for browsers is disabled by default in Mac OS X Lion, so I only noticed this after I upgrade from Snow Leopard.

Another source that confirms my suspicion:

http://sniptools.com/mac-osx/making-java-work-in-browsers-on-mac-osx-lion

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Sun, 10 Jul 2011 17:58:00 -0700 Turn Off New Facebook Chat http://www.jasonreposa.com/turn-off-new-facebook-chat http://www.jasonreposa.com/turn-off-new-facebook-chat

Update: The old method won't work. Here's the new method to kill Facebook chat. The solution is to...

First, Click on "Try It Now" in the chat area.

Screen-shot-2011-07-10-at-9

Second, In the options drop down unselect "Available to Chat".

Screen_shot_2011-07-10_at_9

 

Original post:

I logged in to my Facebook account tonight and found that I was also logged into chat. I really hate chat, so I searched how to turn off the new Facebook chat. It's really simple, so I hope that Facebook doesn't kill this link. Also, all your chat messages are stored in your inbox.


First, click on this link:
http://www.facebook.com/presence/popout.php

Second, click on the options drop down and go offline!

Screen_shot_2011-07-10_at_9

Bye Bye FB Chat!

Whatever you do...

Do not click on the chat area at the bottom of the screen or you'll be logged in again!

Screen_shot_2011-07-10_at_9

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Wed, 15 Jun 2011 13:39:29 -0700 AirPlay Button Missing on iPhone 4? http://www.jasonreposa.com/airplay-button-missing-on-iphone-4 http://www.jasonreposa.com/airplay-button-missing-on-iphone-4 I just ran into this issue when testing out a new mobile app we're creating over at AD60. All that was necessary was to...

1. Open the Settings app
2. In General > International change language to Français
3. Wait for restart
4. Back in General > International change language back to English
5. Optionally remove the French keyboard from General > International

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Fri, 03 Sep 2010 09:45:25 -0700 3 Options for Upgrading to the Asynchronous Google Analytics Tracker Code from the old pageTracker http://www.jasonreposa.com/3-options-for-upgrading-to-the-asynchronous-g http://www.jasonreposa.com/3-options-for-upgrading-to-the-asynchronous-g I ran into an issue last night when I went to upgrade to the new Google Analytics asynchronous tracking code. It turns out that the pageTracker object no longer exists as a global variable.

Instead of using pageTracker._trackEvent(...) to track events, you must instead use _gaq.push(['_trackEvent', ...]).

There are three different options I could have chosen. I ended up choosing the last option.

1. Rewrite all my old pageTracker code to use the new syntax. I.e., change pageTracker._trackEvent(...) calls to _gaq.push(['_trackEvent', ...]);

2. Recreate the pageTracker (which I never verified if this code actually worked)

1
2
3
4
5
var pageTracker = null;
_gaq.push(function() {
 pageTracker = _gat._getTracker('UA-XXXXXXX-X');
});

3. Create a wrapper.

1
2
3
4
5
6
7
8
9
if (typeof pageTracker === 'undefined') {
  pageTracker = {};
  pageTracker._trackEvent = function() {
    var args = Array.prototype.slice.call(arguments);
    args.unshift('_trackEvent');
    _gaq.push(args);
  };
}

This is the option I went with for one simple reason. I already use a variation of this code for logging tracking events when I debug on my localhost. Here is my full version.

1
2
3
4
5
6
7
8
9
10
11
12
13
if (typeof pageTracker === 'undefined') {
  pageTracker = {};
  pageTracker._trackEvent = function() {
    var args = Array.prototype.slice.call(arguments);
    args.unshift('_trackEvent');
    _gaq.push(args);

    if (typeof console !== 'undefined' && typeof console.log !== 'undefined') {
      console.log('_gaq.push(["' + args.join('", "') + '"])');
    }
  };
}

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Wed, 04 Aug 2010 10:18:52 -0700 Job Posting on Craigslist is a Waste of Time http://www.jasonreposa.com/job-posting-on-craigslist-is-a-waste-of-time http://www.jasonreposa.com/job-posting-on-craigslist-is-a-waste-of-time
Craigslist is no longer an essential stop in my hiring process. I've been using it over the last few years with a few different companies, and have seen it get progressively worse. Just recently, I posted a job on Craigslist to fill a need for a web engineer position at AD:60. Over a week later and we have 19+ companies (on and off shore) and 1 woefully under-qualified applicant.

Hiring managers, does this look familiar?

Junkmail

What part of "Please do not contact job poster about other services, products or commercial interests." don't these spammers understand? Ok, so I've accepted the fact that I'll get spam from job posts on Craigslist. And, yes, hiring is hard. I accept that also. But all spam, and no one qualified?!

The worst part is that craigslist implies that it's much better than Monster and Career Builder for the price. I'd have more faith in that assertion if the studies they cite weren't from 2000 and 2006.

Are there solutions? Does Craigslist care enough?

I will admit one little secret though, I've got the best candidates from an impromptu post on Hacker News.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Mon, 26 Jul 2010 15:40:00 -0700 Wordpress code: Find parent category of blog post http://www.jasonreposa.com/wordpress-code-find-parent-category-of-blog-p http://www.jasonreposa.com/wordpress-code-find-parent-category-of-blog-p
On MyBankTracker.com we introduced a new category structure. For reasons I won't get into, I needed to find the parent category of the current post's category. But, finding the parent category was surprisingly difficult using standard Wordpress functions. Anyways, this code is based on get_category_parents() which can be found in wp-includes/category-template.php. Note: this is tail recursive, so it could be rewritten to be iterative. Feel free to copy and redistribute.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
// Recursively traverse the parent child relationships of categories, returning when found the parent with no parents
// $id is the child category, ignore $visited on the first call (based on get_category_parents() in category-template.php)
// Used on: http://www.mybanktracker.com/bank-news/

function mbt_get_category_parent( $id, $visited = array() ) {
$parent = &get_category( $id );

if ( is_wp_error( $parent ) )
return $parent;

if ( $parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited ) ) {
$visited[] = $parent->parent;
return mbt_get_category_parent( $parent->parent, $visited );
}

return $parent;
}

Usage:
1
2
3
4
5
<?php
// put this somewhere in "The Loop" http://codex.wordpress.org/The_Loop
$category = get_the_category();
$parent = mbt_get_category_parent($category[0]->term_id);

As expected, use this code at your own discretion. No support or liability implied by sharing this.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Tue, 20 Jul 2010 06:55:00 -0700 Yojimbo + Dropbox + sleepwatcher http://www.jasonreposa.com/yojimbo-dropbox-sleepwatcher http://www.jasonreposa.com/yojimbo-dropbox-sleepwatcher

There is a great post on the Yojimbo google group about how to get Yojimbo working on Dropbox. This allows you to synchronize your notes/passwords/etc over more than one computer.

http://groups.google.com/group/yojimbo-talk/msg/9465b1c53650a2b9

The one snag is that you can only have Yojimbo running on one machine at a time. In order to work around this limitation, I've used the command line tool sleepwatcher to monitor when a computer goes idle. I modified the example plist to configure sleepwatcher to run a script that tells Yojimbo to quit after 10 minutes of idling. 

Download sleepwatcher http://www.bernhard-baehr.de/ and follow the basic instructions in the readme.

Here are the scripts to do it.

The AppleScript code to quit Yojimbo: (place in your home directory ~/)

1
2
#!/bin/bash
osascript -e 'tell application "Yojimbo" to quit'

After installing sleepwatcher according to the readme, and creating the above script, we test to see if sleepwatcher is working correctly by issuing the following command. Make sure Yojimbo is open, otherwise it won't close.

$ /usr/local/sbin/sleepwatcher --verbose --idle ~/quit_yojimbo.sh -t 100

This should quit Yojimbo after 10 seconds. Next on to the launch agent.

The launchctl plist to run sleepwatcher on launch. (place in ~/Library/LaunchAgents/)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>de.bernhard-baehr.sleepwatcher</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/sbin/sleepwatcher</string>
<string>-V</string>
<string>-i ~/quit_yojimbo.sh</string>
<string>-t6000</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>

Note: -t is for time, which is in units of 0.1 seconds; meaning 10 minutes is 6000, not 600. To install the launch agent, run this command (note: no sudo).

$ launchctl load ~/Library/LaunchAgents/de.bernhard-baehr.sleepwatcher-20compatibility-localuser.plist

Update: one additional side note.

If you have OS X 10.6 and Adobe products on your machine, you may see an error when running osascript for the ~/quit_yojimbo.sh script. If that's the case you can ignore the error, or follow the instructions here: http://kb2.adobe.com/cps/516/cpsid_51615.html

It shouldn't matter either way.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Fri, 29 Jan 2010 10:50:01 -0800 Bill Gates' Generosity http://www.jasonreposa.com/bill-gates-generosity http://www.jasonreposa.com/bill-gates-generosity I've purchased Windows 3.1, 95, 98, 2000 and XP. I'm finally at peace with that now that I know that part of the money has gone to people really who need it.

http://www.timesonline.co.uk/tol/life_and_style/health/article7007734.ece

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Thu, 28 Jan 2010 07:57:00 -0800 Do you need a seed investment to get VC? http://www.jasonreposa.com/do-you-need-a-seed-investment-to-get-vc http://www.jasonreposa.com/do-you-need-a-seed-investment-to-get-vc

I posted this question on Hacker News.

We're profitable. We've done our homework. We have proven the business model and customer validation. It's scalable and repeatable. But, we'll need a big investment to grow at the scale we want.

We understand that seed investment can open up doors by giving us introductions and preference when finding the right VC, but our revenue is greater than any seed investment that I've seen.

We're more than willing to give up some equity to grow. We just want the right partnership.

Do you need seed investment if your revenue is greater than what a seed can offer? If you skip getting a seed, how likely is it that you'll get the right VC?

http://news.ycombinator.com/item?id=1084083

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Wed, 27 Jan 2010 15:30:00 -0800 T.M. Lewin I still can't log in http://www.jasonreposa.com/tm-lewin-i-still-cant-log-in http://www.jasonreposa.com/tm-lewin-i-still-cant-log-in

This little blog-o-mine is turning into a rant site. Anyways, I want to order a new suit, but I can't log in using my email address.

Yes. My email address TLD is 4 characters. This just doesn't seem possible that my .name email address is rejected. I first complained about this issue nearly 9 months ago.

http://www.tmlewin.co.uk/

Pastedgraphic-9

i'm out.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Wed, 02 Sep 2009 07:37:58 -0700 Optimum online password http://www.jasonreposa.com/optimum-online-password http://www.jasonreposa.com/optimum-online-password Who conned Optimum into limiting their passwords to 8 characters? Does it really take up that much more CPU to validate a longer one or that much hard disk space to store it? Why does this issue still persist on highly trafficked consumer facing websites?
Pastedgraphic-4

It could mean one of two things:

  1. The password field in the database is only 8 characters wide. But, that would also mean that the password is store in clear text.
  2. Optimum made the decision to save users from hurting themselves. Someone from their information/systems architecture group: "Oh noes I can't remember passwords longer than 8 characters, so I bet nobody else can either."

Whip that person.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Thu, 27 Aug 2009 08:11:00 -0700 Gary Vaynerchuk (aka Kevin Rose) at Sprout Up NYC http://www.jasonreposa.com/gary-vaynerchuk-aka-kevin-rose-at-sprout-up-n http://www.jasonreposa.com/gary-vaynerchuk-aka-kevin-rose-at-sprout-up-n
Thanks to @garyvee for giving a shout out to MyBankTracker.com!

His book is Crush It! and you can buy it today.

Here he is posing as Kevin Rose:

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Wed, 13 May 2009 19:53:00 -0700 i hope posterous will solve my internets http://www.jasonreposa.com/i-hope-posterous-will-solve-my-internets http://www.jasonreposa.com/i-hope-posterous-will-solve-my-internets

To the above aforementioned parties hereto within heredoc. ...um... heredoc?

Anywho, this post will mean nothing to anyone except myself, which is all that matters. But, share the love.

Also, a picture...

Why can't all CMSs work over email?

Much respect, Jason

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa
Wed, 13 May 2009 19:23:45 -0700 me on posterous http://www.jasonreposa.com/me-on-posterous-2 http://www.jasonreposa.com/me-on-posterous-2
3519635159_d34cf2f53a

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/660490/35738_432608839318_539044318_5829316_1438851_n.jpg http://posterous.com/users/15T7ctl8BRT Jason Reposa Jason Jason Reposa