Thursday, July 25, 2013

apps, native vs web and desktop vs mobile

A while back, someone on my twitter feed wondered about why people are always clamoring for standalone native apps on mobile, but on their PCs (OSX or Windows) it's difficult to get them to download an application.

I've been having the thought roll around in my brain a bit, and I've come up with two ideas:

1. Mobile apps provide a safe, sandboxed environment, and pages of attractive icons on mobile still have a bit of a UX zing in a way a desktop or laptop doesn't.  Plus, I think Windows gave the idea of downloading software a bad reputation; especially the bundling of additional promotional crapware.

2. Mobile devices are much more personal than PCs. People enjoy webapps because they get to them from home or work or at a friends computer etc, but a mobile device is on your person almost all of the time.

Ok, so that's not such rocket science, but still.

Friday, July 5, 2013

php 101 boilerplate

I grew up on Perl, especially for quick and dirty web things, and in general PHP didn't differentiate itself enough for me to switch. However, my team at work seems more comfortable with PHP, and actually PHP often has a lot of useful libraries baked-in that would me more of a pain to install on Perl.

But I always have to look up a ton of little things in PHP, so here is a trivial file editor in PHP that will show me some basic stuff like reading and writing a file, loading POST'd data, escaping HTML characters, catching errors, comparing strings, etc -- it even has a S00PER SEKRIT password function.

<!doctype html>
<meta charset="utf-8">
$secretpassword = "test";
$pass = $_POST["pass"];
$contents = $_POST["contents"];

if($pass != ""){
        if($pass == $secretpassword){
                if(file_put_contents("file.txt",$contents) !== FALSE){
                        echo "Wrote File";
        } else {
                echo "Incorrect Password";
$contents = htmlspecialchars(file_get_contents("file.txt"));

function customError($errno, $errstr) {
  echo "<b>Error:</b> [$errno] $errstr";


<form method="POST" action="admin.php">
<textarea ROWS="8" COLS="80" name="contents"><?php echo $contents ?></textarea>
Password: <input type="password" name="pass"><br/>
<input type="submit" value="update file">

Ain't rocket science, but might save me a few minutes in the future.