Mateusz Stawecki

Personal Site

Posts from the ‘Uncategorized’ category

Úll Conf iOS app

Úll Conf iOS app

This year at Úll Conf I had the pleasure of working with the organisers on creating the Úll iOS app. In order to build and publish the application we used Glide – an app creation platform, which I’m working on with Chris Harris. While the key feature of Glide is easy content collation via Dropbox – which allowed us to easily publish the schedule, photographs and speaker information – we’ve been recently experimenting with Apple’s iBeacons.

The conference took place at the Lyrath hotel, in charming Kilkenny, Ireland. The venue was quite large and had several interesting facilities, that we wanted to expose to the participants of the conference.

On Tuesday morning we’ve sent out a notification and published several clues linked to each place. In each room we’ve setup a kontakt.io beacon. We configured our content to post a notification when the beacon was ranged and unlock content related to the room, which included beautiful illustrations done by Carolina Buzio.

2014-05-04 21.45.36

Overall, everything went well. A few takeaways from the experiment:

  • detecting another beacon in the same region doesn’t usually wake up the app again. One of the workarounds I’m using is continuing to range beacons in background, by requesting a background task. That obviously only works for a finite amount of time.
    Another solution is to use multiple beacons regions, but rememeber that you can track up to 20. You’ll also need re-programmable beacons! As Apple points out, you could reconfigure which regions you’re tracking based on where you are.
  • make sure people have Bluetooth turned on. Biggest “oops!” of the experiment. The app didn’t inform the users to switch on bluetooth.
  • Beacons.

    We used kontakt.io beacons supplied by @dermdaly

    dissapearing beacon bug: one of the bugs that I noticed was that often ranged beacons dissapeared several scans after they were initially ranged. In our case this wasn’t a huge problem, we just needed to range it once, but if you’re depending on the beacon to stick around on that list (while you’re actually in range), it’s a problem.

  • beacons not working until device reboot: it’s 2014 and some people still had to restart their phones in order for beacons to work. No comments here.

 


All iBeacons aside, I highly recommend both Úll Conf and Lyrath :)

 

Lyrath

Leave a comment

Especially with the recent budget cuts, welfare has been a hot topic in the media. However, it’s pretty clear that there is a bit of confusion around what “welfare” really is.

If you’ve studied in the UK as a UK or EU resident just like me, you’ve received between £10,500 – £30,000 of government welfare in form of subsidised tuition. This is something many students don’t even realise and certainly don’t question their entitlement to.

When thinking about welfare and poverty, let’s be clear – we’re all on the same boat. Some of us are just less lucky and more stigmatised for receiving very basic help. Moreover, the money distribution points at a serious inequality issue.

The following video was created by The #GlobalPOV Project in the context of US welfare, but the concepts apply globally. If you feel like you’re the sort of a person who cares about inequality at least a little, I highly recommend you watch it. With economic inequality getting worse every year, this is not an issue which will just go away on its own.

Spread the word:

Leave a comment

If you feel disappointed due to the lack of a new iPhone or a TV – don’t be. WWDC – Apple’s World Wide Developers Conference was always software centric and while there are hardware announcements included, the Keynote was packed with fantastic software updates. After enjoying the whole conference, I’m pleased to report that Apple has “brought it”. What I’m seeing is a consistently strong rate of innovation in both iOS, OS X and even the Web services. Focusing not only on new features, but refining the current set and improving reliability. Even Apple won’t get everything right the first time, but they’ve shown that they can improve instead of abandoning, which can’t be said for a lot of other products and tech companies.

iOS7

The most noticeable change in iOS7 to most people is obviously the user interface overhaul. While the new look is a bit shocking for some and many people are still making up their mind, it’s nice to see that Apple is taking risks and coming up with things the tech community is not comfortable with. The real question is how will the consumers respond, but the most basic interface patterns persist, so I believe that it shouldn’t be a big issue.

Some of the new looks in iOS7 might even seem similar to other existing platforms, but this is not about being unique – it’s about providing users with the best possible experience. To make that happen Apple has introduced many changes to the platform which are unique, hard to execute ideas: a physics-based dynamic and motion aware graphic user interface (which was hinted many times before), and the replacement of old metaphors with more visual depth and simplified controls. Many of these changes are truly stunning, yet the iOS team is not just showing off, the designs feel very purpose-driven and focused on the principal that content comes before the UI. This design direction doesn’t just apply to Apple’s work, it should guide app developers when thinking about their own app designs. It’s a direction we at OTHER media strongly believe in.

Chris Harris and Craig Federighi. Wonders App.

While the details are restricted until Fall (as usual), my feeling is that changes to iOS7 will also have a strong impact on what the app developers can achieve with the platform. That means a new range of apps, which can be implemented on the platform and of course new kinds of solutions to support new and existing businesses. The icing on the cake to these new goodies is as Tim Cook highlighted during the keynote: iOS has an extremely high adoption rate with over 90% of users running the latest version, which means these future features can be used in production very soon after the official release of iOS7.
As a developer, I’m particularly pleased by Apple’s commitment to delivering further improvements to the tools we use. Many are based on feedback left by the developers themselves, which makes the latest releases really great and more efficient to use.

If you round up all these changes, think about the timeframe and last year’s political shifts at Apple, it’s staggering how much this company managed achieve and deliver. All of that makes iOS and OS X still the two strongest platforms out there. The community is excited as always. Apple engineers were very helpful in the labs as always. Overall, WWDC2013 was again a highlight of my year.

Screen Shot 2013-06-23 at 21.46.11

Leave a comment

UPDATE: This is an old piece, you probably want: phantom.js and casper.js

In this post I’ll show you how to remotely control your Google Chrome browser using JavaScript and scrape some data, even if it’s on an AJAX powered website or behind HTTPS authentication. Nice? I LOVE WebKit and now it got even sweeter. Very recently there was a small buzz about a new feature: WebKit Remote Debugging that allows to use Element Inspector remotely! (since it’s essentially just a web page and some javascript + websockets). What’s the real icing on the cake for me, is the ability to plug-in a different interface. I wrote a simple interface that can execute several pieces of JavaScript and return the values back to you. Here’s how to set it up. Open Terminal and find the Google Chrome executable. To use remote debugging, run it with a special parameter:

$ cd /Applications/Google Chrome.app/Contents/MacOS/ $ ./Google Chrome –remote-debugging-port=9222

If you get:

[0513/205852:FATAL:foundation_util.mm(102)] Check failed: bundle. Failed to load the bundle at /Applications/Google Chrome.app/Contents/MacOS/Versions/11.0.696.68/Google Chrome Framework.framework

Try symlinking Versions:

$ ln -s ../Versions/ ./Versions

The browser should start normally. Now go to a different browser, e.g. Safari and check out: http://localhost:9222 Select a page and you should see the Inspector. That’s all nice and neat. But let’s see my remote script: http://gist.github.com/972742 – To connect to the debugger, we’re using WebSockets. Change the page number based on the link from http://localhost:9222 . Every “Tab” has a different “Page” number.

	// Set page number!
	var host = "ws://localhost:9222/devtools/page/5";
	socket = new WebSocket(host);

- To execute JavaScript I wrapped a JSON-RPC-like command into a method with callback. More protocol schema here.

function remoteEval(scriptString,callback) {
	seqCallback[seqNo] = callback;
	socket.send('{"seq":'+seqNo+',"domain":"Runtime",'+
	'"command":"evaluate","arguments":{"expression":"'+
	scriptString.replace(/["]/g,'\"')
	+'","objectGroup":"console","includeCommandLineAPI":false}}');
	seqNo++;
}

- And this is how a sample script works:

remoteOnLoad = function(result) {

// We might've ended up on the login page, so let's log in!
if (remoteURL.indexOf("ServiceLogin") > 0 )
remoteEval( " document.getElementById('Email').value = 'username'; "+
	" document.getElementById('Passwd').value = 'password'; "+
	" document.getElementsByTagName('form')[0].submit(); "
	, function(result) { alert(result); } );

	// We're home!
	if (remoteURL.indexOf("mail.google.com/mail/") > 0 )
	remoteEval( " try { document.getElementById('canvas_frame')"+
".contentWindow.document.getElementsByClassName( 'md' )[0].innerText } catch(e) { -1 }"
	, function(result) {  // Waiting for AJAX. Try again in 2 sec.
	if (result == -1) { setTimeout(remoteOnLoad,2000); }
				else { alert(result); } } );
				// This should return scraped information
				// about your data usage on gmail!
				// E.g. You're currently using 150MB out of 7000MB
			} ;

// This happenes first:
remoteEval(" location.href = 'http://gmail.com' ");
//Let's go to Gmail!

Don’t know how about you, but I just wanna wrap it in Node.js, run it somewhere on Linux with a dummy X11 server for Chrome and write lot’s of crazy tasks, so it does it all for me! Imagine e.g. that instead of that alert(result) you make it a WebHook or a service?

Leave a comment

Name: Web Form Analyzer
Motto: Simple form analyzer from URL

Link: http://formanalyzer.net/

Summary:
A very simple web form analyzer! Just enter the form’s URL or HTML code and you’ll see a nice print out of different forms and values submitted on the website.

Had a bit of time and need for a simple tool like that. Dead simple, very clear to read. Nicer than ‘view source’, if you’re just interested in what and where is being posted from a website or piece of code. Enjoy.

Leave a comment

Ever had this problem? You were so excited to see, if some piece of code works on your live system, that you forgot to change database access configuration and file paths? Probably not, because we’re all respected professionals here *wink* and the case is usually: it’s 10pm, still at the office and x product is launching tomorrow and you accidentally overwritten the configuration, because you didn’t have time to finish the deployment script :P. Or maybe you have to deploy your application to even more than two machines? Well, here’s a small cheat sheet.

The lazy way


switch (php_uname('n')) {
    case 'livedevhost04':
		$dbhost = 'sql.example.com'; $dbuser = 'myapp_user';
		$dbpass = 's7d6y3726ye86'; $db = 'myappdb';
		break;
    case 'Mateusz-Laptop.local':
		$dbhost = 'localhost'; $dbuser = 'root';
		$dbpass = ''; $db = 'testdb';
    	break;
    default:
       echo 'No configuration found for host: '.php_uname('n'); exit;
}

This way is quite nice for most scenarios. Very convenient. Get the machine’s hostname, add a “case” to the switch with server’s configuration and you’re good! If you’re deploying through some sort of SFTP/WebDAV protocol, you can easily upload files without any additional modification before running the script. The same with deployment techniques like Deploy using Git.
The only problem is that you’re slightly exposing configuration settings for all your boxes. If you don’t feel comfortable with this, try a different technique like symlinks to a local configuration file.
Personally, I use it quite often. It’s better and way less annoying than swapping commented settings.

The ‘bash’ way

This can be used for many different scenarios. Not just files, but also directories. Here’s a very nice and readable script for symlinking stuff based on local hostname:

#!/bin/bash

targetfile=webroot/config.php
fromscheme=webroot/config._HOST_.php

fromfile=${fromscheme/_HOST_/`hostname`};

if [ -e $fromfile ]
then
 rm $targetfile
 ln -s $fromfile $targetfile
 echo $fromfile == $targetfile
else
 echo [ERROR] Local configuration file not found: $fromfile
fi

Additionally, you might want to execute a custom script that will do something for you after retrieving a configuration set.
Notice the “webroot/”, please keep sensitive scripts outside your document root, mkaay? Maybe even clean them up after deploy and keep them in repo!

You’re only in trouble, if you don’t have access to a bash shell on your hosting server (use first method) or you’re running Windows (you can try cygwin if you’re mad enough ;] )

A JavaScript Bonus

You’d be surprised how many times, I almost did something very silly on a deployed version of an ajax based application. As a bonus, here’s a script you can put in your app, to help you identify, which build you’re currently working on. Especially useful, when running on iOS in web app mode.

<div style='display:none;color:red;' id='devnotification'>TEST SERVER</div>


var currentHost = location.href.split('/')[2];
if (currentHost == 'localhost' || currentHost == 'dev.example.com')
document.getElementById('devnotification').style.display = 'block';

Enjoy! And remember to run your tests kids!

1 Comment

This scenario is for people who want to put their Macs to sleep after a certain activity that you know will take ‘x’ amount of time, like: watching a movie, downloading a file.

In other words: auto shutdown Mac after certain amount of time.

There’s quite a few apps that might do this for you, but I’m going to show you how to do it the geeky way using the Terminal :)

Let’s say you’re going to watch a 2h movie and you want your Mac to go to sleep right after it finishes. Open your Terminal and write:

sleep $[120*60]; osascript -e ‘tell application “System Events” to sleep’

The first part with ‘sleep’ calculates the number of seconds in 120 minutes using bash’s arithmetic expressions and passes it to the ‘sleep’ function. After ‘sleep’ wakes up, we run a simple script that puts your Mac to sleep. Of course you can put any amount of time you need (it’s usually better to put too much than too little ;) )

If you plan on using this quite often, it’s best to write a short script:

#!/bin/bash
d=$1
while [ -z $d ]; do
read -p “Duration (minutes): ” d
done
sleep $[$d*60]
echo “. . . z z z Z Z Z”
osascript -e ‘tell application “System Events” to sleep’

Save it somewhere in your path, if you can (enabling and using “root” user in Mac OS X), remember to do a ‘chmod +x’ on the file and you’re ready to go.
If you don’t want to use “root”, put it somewhere in your user directory e.g. make a directory “scripts” in “Library” and put your script there.
Create a “.bash_login” script file that will append your private scripts directory to the current path:

#!/bin/bash
PATH=$PATH:/Users/mateusz/Library/scripts

If you’re ready, just pass the number of minutes as an argument (I called my script “sleepafter”):

bash-3.2$ sleepafter 120

The “while” loop in my script makes sure that “sleep” has a value to work with. This way you can easily run the script from Spotlight:

bash-3.2$ sleepafter
Duration (minutes): 60

If you are invoking a task that ends the application process after finishing, then simply add the “put to sleep” script at the end. E.g. when compiling something:

make; make install; sleepafter now

E.g. when using applications like ‘wget’ for downloading files:

wget “http://server/bigfile.bin&#8221;; sleepafter now

Let me know, if you have any good ideas on modifying that script!
That is all :)

Leave a comment
Follow

Get every new post delivered to your Inbox.