04
Nov 11

WP Options Pages make ugly code, this class makes it pretty

Few things I hate more about doing a WP plugin than coding up an options page. It seems no matter how many times I do it, it’s always drudgery. It sets off my procrastination instinct like nothing else, and it makes what could have otherwise been clean and simple code look gnarly.

No More!!

I put together this class to make it pretty and easy. so now it’s as simple as below:


$optionsPage = new WPAdminOptionsPage($getPageParam, $parentMenu, $menuTitle, $pageTitle, $minAccessLevel, $callback, $topLevel=FALSE);

$optionspage->add_script(array('jquery-ui-core'));
 $optionspage->add_script(array('jquery-ui-tabs'));
 $optionspage->add_script(array('jquery-ui-sortable'));
 $optionspage->add_script(array('custom_js_script_handle', 'http://url_to_scriptfile', array('handles, of, script, dependencies')));

$optionspage->add_style(array('stylesheet_handle', 'http://url_to_stylesheet'));
Enhanced by Zemanta

24
Oct 11

Awesome use of LCD, plus some common sense

This is just awesome:

Full details here

 

More than anything else, I love the masking at around 1:00. But this led me to a different question, something much simpler, that I cannot understand why I don’t already see implemented everywhere.

If you’re going to distort the on-screen keypad used to input a PIN # when it’s viewed from an oblique angle, (meaning by an onlooker,) obviously the keypad needs to be randomized, which in this demo it rightly is.

However, we don’t have this at ATMs as is. WHY NOT???

I remember reading some time ago about software that can translate video of typing at a keyboard into keystrokes with remarkable accuracy, and tested with high quality cameras at up to 100 feet away (tried like crazy to find the link, if anyone remembers this, possibly from hacker news, please leave it in the comments.)

One link I did find that’s just as relevant here, is this gizmodo article, basically disussing:

Researchers from UCSD pointed thermal cameras towards plastic ATM PIN pads and metal ATM PIN pads to test how effective they were at stealing PIN numbers. The thermal cams didn’t work against metal pads but on plastic pads the success rate of detecting all the digits was 80% after 10 seconds and 60% after 45 seconds. If you think about your average ATM trip, that’s a pretty wide window and an embarrassingly high success rate for thieves to take advantage of.

With stuff like this out there, and how dead simple and deadly effective a randomized on screen keypad would be as a secure means of entering your PIN, I just cannot understand why this isn’t at every ATM, PIN pad, electronic checkout, and anywhere else sensitive numeric codes are being entered.

Maybe we can get a petition going in the comments.

 

 

Enhanced by Zemanta

22
Oct 11

Regex is hard

This makes it easy - http://gskinner.com/RegExr/


16
Oct 11

Protesting silliness

No matter what you think about the “occupy” stuff going on right now, (I’m personally pretty indifferent,) you have to love the semantic somersaults people go through in their minds to justify acting stupid. Quoted from Dailykos.com:

Was just watching Global Revolution live stream where they were live at a Citibank in LaGuardia watching the police holding 30 customers in a Citibank branch where they were in line to close their bank accounts.  There was a large group of protesters outside chanting various rejoinders to the bank officals and the police, who seemed to be their in force.

And then the real story from Citibank:

Citibank Public Affairs issued the following statement regarding today’s incident: “A large amount of protesters entered our branch at 555 La Guardia Place around 2:00 PM today. They were very disruptive and refused to leave after being repeatedly asked, causing our staff to call 911. The Police asked the branch staff to close the branch until the protesters could be removed. Only one person asked to close an account and was accommodated.”

To be clear: no one was arrested for closing an account; we didn’t lock people in our branch – the police decided to close the branch; and we didn’t ask for anyone to be arrested –  that is a police decision.

I know plenty of conspiracy theorists will say that’s not how it really went down, but I’m definitely not one of them. Honestly I think many of these folks are just in it for the attention. Sadly their presence muddles the message and leads me to take the whole thing less seriously, writing them off as hippies.

Is it just me, or does this:

eerily resemble this:

Enhanced by Zemanta

25
Sep 11

OkMeGoNow.com: A fast and lightweight, mobile friendly way to get directions

I’m still a few months away from buying a car, which means I take the bus when I need to get somewhere.

What I find myself doing every time I’m waiting for a bus, is firing up Google Maps on my phone, and pulling up transit directions for my trip ahead so that I can see when the next bus is coming. It’s super useful, except that I use an “old” T Mobile G1 phone, only compatible with an older version of Android, and it is getting slow in its old age.

What’s worse, the Google Maps app requires me to input both my departing and destination address, with page loads after every click that take about 15 seconds each, and an average of about 7 page loads to get through. About half the time the app will crash during a page load and I have to start over. Even if it doesn’t I’m looking at spending at least a minute toying with my phone before I’ve got the info I’m after.

Now obviously the answer is to upgrade my phone, but I’m not eligible for a renewal discount til 2012. Beyond that, I just had a feeling that there is a better way to do this. Combine that with waking up early on a Sunday all caught up with work, and you get OkMeGoNow, a super fast and lightweight way to get transit, walking, or driving directions in your mobile or standard web browser.

To improve the lousy workflow that motivated me to create this, I’ve defaulted the page to detect your location and fill out the departing address for you (this can be overridden but normally won’t need to be,) and included a very persistent cookie to save past destination addresses, letting you re-run old searches with two clicks (this is a primary use case for me, since I’m usually just checking the time for the next bus.)

Fire it up in your web or mobile browser and enjoy!

Enhanced by Zemanta

19
Sep 11

snapInMethods PHP class: add methods to parent classes from child classes

I just had to create a singleton which would allow child classes to add methods to the parent instance.

While the end result turned out to be pretty simple use of user_func_array, the process was repetitive enough for each group of extendable methods that I ended up standardizing it in a separate class, and it’s a pretty handy thing to have.

To use it, include the class file and instantiate in the parent class as follows:

$this->_extendableMethods = new snapInMethods();

Access from the child class with

$this->_parent = parent::getInstance();

$this->_parent->_extendableMethods->add(‘handle’, ‘displayName’, __CLASS__, ‘callback’);  //creates a new method from the child class

$this->_parent->_extendableMethods->get(); //returns an associative array of added methods as Array( handle => Array(‘displayName’, ‘class’, ‘callback’))

$this->_parent->_extendableMethods->del(‘handle’); //removes specified method from extended methods

$this->_extendableMethods->exec(‘handle’, array($param1, $param2, $etc)); //runs the specified extended method, passing each array element as an argument. The purpose of the class is that you can run this from the parent class, and it will be aware of any methods that the children have added.

Here’s the class file:

<?php
/*
Class: snapInMethods
Description: Allows you to easily define a type of method which other classes can add methods to on a parent class. Best suited for a singleton where new classes need to be able to extend functionality.
Usage:

include_once('class.snapInMethods.php');
class parentClass
{

    public $_snapInMethods;

    method __construct()
    {
        $this->_snapInMethods = new snapInMethods();
    }

    method runSnapInMethods()
    {
        $methods = $this->_snapInMethods->get();
        foreach ($methods as $methodhandle => $data ) $this->_snapInMethods($methodhandle, array($param1, $param2, $etc ));
    }
}

class childMethod extends parentClass
{
    method __construct()
    {
        parent::_snapInMethods->add('handle', 'displayName', __CLASS__, 'callback');
    }

    method callback($parameters)
    {
        //process data sent when method is called by parent class.
    }
 }

 *************************************************************************************/

if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }

class snapInMethods
{
    protected $_methods = array();

    public function add($handle, $displayName, $className, $callback)
    {
        $this->_methods[$handle] = array('display' => $displayName, 'class' => $className, 'callback' => $callback);
    }

    public function get()
    {
        return $this->_methods;
    }

    public function del($handle)
    {
        if (isset($this->_methods[$handle])) unset($this->_methods[$handle]);
    }

    public function exec($handle, array $params)
    {
        return call_user_func_array(array($this->_methods[$handle]['classname'], $this->_methods[$handle]['callback']), $params);
    }
}
Enhanced by Zemanta

07
Sep 11

Randi Zuckerberg is a real man?

For anyone who didn’t know, Ashton Kutcher and Demi Moore have started the DNA Foundation, whose purpose is to eliminate child slavery and human trafficking. It’s a great cause and I’m glad to see them putting their resources towards it.

Which makes this blooper even funnier. I get that a non-profit has tight margins, but with such major backing, they could have at least touched this up post production.

Check out 50 seconds in, where Randi Zuckerberg goes from “preferring a real man” to being a real man. Randi have you watched this video yet??


25
Aug 11

Stock photography for web design – free resources

A friend of mine has been doing consulting work and just asked me if it makes sense to buy stock photog to have at your disposal. Personally I do much more development than design, so I only use stock images on occasion. I can see if you are design heavy that something like istockphotos would pay off, (I’ve bought one offs here and there, the quality is awesome,) but I’ve done really well with a list of free sources I’ve built over time.

I just put together this list  for him, so I figured I’d post it up here:

http://bridgeurl.com/v7x08d/all - (created with the Tabulate! Chrome Extension, which awesomely turns your open tabs into a list of links.)

And also, http://www.sxc.hu/ deserves special mention. I am always surprised at the quality and breadth of free stock images I find on that site.

Enhanced by Zemanta