Let Slack tell you what songs are currently playing in the office

At Earth People, there’s always music in the air (and the birds sing a pretty song).
Most of the stuff we play is fairly unknown to most of us, and in many cases only played once, ever.

To get rid of all the “Hey what’s this song”-chatter or Slack, I made a litte script which we run as a Slack Command.
The script just checks all the Last.fm-feeds of the people usually playing music, and returns what’s on.

Screenshot 2014-10-15 16.51.02

By no means magic, but adds another bit of homey feeling to Slack.
Here’s the Gist, be our guest.



require 'vendor/autoload.php';

use GuzzleHttp\Pool;
use GuzzleHttp\Client;

$client = new Client();

$users = array('suprape','musikmarskinen','dafeather','brunobrandstrom','Algoritm','mjelle','hjalle','johannagrip','tumde');

$requests = array();
foreach($users as $user){
	$requests[] = $client->createRequest('GET', 'http://ws.audioscrobbler.com/2.0/', [
		'query' => array(
			'method' => 'user.getrecenttracks',
			'limit' => '5',
			'api_key' => 'GetThisFromLastFm',
			'format' => 'json',
			'nowplaying' => 'true',
			'user' => $user

$results = Pool::batch($client, $requests);
$nowplaying = array();
foreach ($results->getSuccessful() as $response) {
	$recenttracks = json_decode($response->getBody()->getContents());
		foreach($recenttracks->recenttracks->track as $track){
				$temp = new StdClass();
				$temp->artist = $track->artist->{"#text"};
				$temp->title = $track->name;
				$temp->album = $track->album->{"#text"};
				$temp->image = $track->image[3]->{"#text"};
				$nowplaying[] = $temp;

header('Content-type: text/plain;charset=utf-8');
echo "Verkar som att ".count($nowplaying)." låtar spelas på kontoret just nu:\n";
foreach($nowplaying as $track){
	echo '- "'.$track->artist.' - '. $track->title.'"';
		echo ' från skivan "'.$track->album.'"';
	echo "\n";

Slack integrations so far; deploys, doorbells, reddit and lunch menus

On Earth People, we recently fell in love with Slack (Oh yes that’s an affiliate link that will give us both 100 dollar credit). It got us off Skype (which we didn’t really love anyway) and on to something that felt fresh. What really got us hooked was all the integrations we could do. Here’s a couple we’ve done so far:

1. When the doorbell rings, an Arduino triggers a HTTP request to some shitty PHP script we’ve written, which checks GoogleCal for meetings and pings the chatroom with what’s at the door.

Hey open the door, says Slack

2. Lunch is obviously a big thing for us hoomans. We’ve made a little Curl based bot which checks what the nearby restaurants serve for lunch by typing /zum or /stadsmissionen.

Slackbot responds to /stadsmissionen

3. Whenever someone deploys to a production server, Slack will let everyone know.

Slackbot lets everyone know when we have a deploy to production

4. /reddit <any word> will try to fetch an image from a corresponding subreddit. And post it to everyone… yeah, we’ll see how long this one gets to live. Depends on when someone starts fetching NSFW stuff I guess…

Screen Shot 2014-03-20 at 21.35.36

Right now we’re working on a crappy little Raspberry-integration for our Moccamaster. Wouldn’t it just be great to be able to ask Slack if there’s any coffee…

Relaying push notifications to your own API

We recently made a campaign for Loka mineral water, where users together reveal the new flavors. This is done by using Snapchat. We send users snaps containing puzzle pieces, and when they make a screen grab of a specific piece – we put that piece in the puzzle on the website.

Because of legal reasons we aren’t allowed to use the Snapchat API, but we still need to have some automation. For example we wanted to know immediately when a user made a screen grab of our puzzle piece snap, so we got around the problem by building an Android application.

In the latest Android SDK 4.4 (API 19) the “NotificationListenerService” was released. Using it, we can listen for incoming push notifications on our Nexus tablet. In the app, we’re just checking if the package name from the StatusBarNotification equals “com.snapchat.android” and if the notification ID matches the ID you get when someone is screenshoting your snap.

Then we post the username to our API, and cancel the notification from the NotificationListenerService.

code example:

   public void onNotificationPosted(StatusBarNotification statusBarNotif) {

       Notification notif = statusBarNotif.getNotification();

       if (notif != null){

           Bundle extras = notif.extras;
           Intent intent = new Intent(MainActivity.INTENT_NOTIFICATION);

           Bundle intentExtras = intent.getExtras();
           String notifTitle = intentExtras.getString(Notification.EXTRA_TITLE);
           CharSequence notifText = intentExtras.getCharSequence(Notification.EXTRA_TEXT);

           int notificationId = statusBarNotif.getId();

           //Check if the notification is from snapchat, and the id matches the printscreen id from notification.
               if(notificationId == printScreenId){
                   //Split the String to get the username. 
                   String arr[] = notifText.toString().split(" ", 2);
                   String userName = arr[0];
                   //Send to api.
                   //Cancel all notifications.
               Log.i("Other", "Another type of notification.");


SXSW lineup helper

We’re going to Austin again in March, for SXSW. It’s beyond great when it comes to live music. And tacos. But their official schedule is impossible to use due to the shear amount of gigs.

Two years ago we created a little tool for ourselves and our friends called LASTSX.WS which mashed the lineup with their last.fm account. This got shut down by the SXSW lawyers due to brand infringement in the URL. So when setting it up this year we removed any references to SXSW in the URL.

The end product is far from perfect, but it was a quick hack and it works on our machines™. Enjoy!


(Ok this is a tech blog so here’s what we used: PHP5.5, Nginx, Memcached, Curl.)

Place-a-pet, your animal shelter placeholder image service.

We’ve been using Placekitten.com for some time, and really love it. This service has two major flaws however:

a) who are these cats? And do I really care?
b) dogs are also nice. It doesn’t have dogs.

The day before christmas, two years ago, we made a WordPress plugin which replaces the standard WordPress 404 page with a homeless dog.
This year we give you Place-a-pet. (Service has been taken offline since…)

We’re scraping pictures of dogs and cats from Hundstallet and Stockholms Katthem, to give you placeholder images in any size. Service is built on NGINX, only. Merry christmas to you and all dogs and cats. We like you alot.



What WP plugins does a site use? Our tool have the answer!

We at Earth People have a bunch of WordPress plugins that we have developed over the years. Some of them are even pretty usable! That’s why whenever we hear about a new WordPress site being released here in Sweden, we eagerly try to find out if any of our plugins are being used.


Previously that meant that we manually checked the site for our plugins. Yes. Manually. One after another we checked the site to find traces of our plugins (CSS files or readme files and so on).

It was boring. It was time consuming. And finally we gave up and decided to do something about it.

So we built the WordPress plugin checker. A simple automatic tool where we – and now also you! – can check any WordPress site for plugins. We have been using the tool internally for a while and it’s been working pretty good.

It’s kinda fun and exiting to see what plugins a site is using. What don’t you go and try it to see for yourself?

Let us now what you think in the comments for this post or at @earthpeople. Oh! And if you find any of our plugins on a site please let us know. It makes us so happy and proud.

/The lab rats

More node.js game action

This small game idea felt like fun – there is a man walking at the bottom of your browser window. Adjust the size of the browser window to make the man walk into the green area, i.e. live on.


Try the game here: http://nodelab.earthpeople.se:1112

The man walks faster and faster and more green doors appear. To this you could add extra lives and power packs to catch along the ride. Also control the game in other ways by tampering with your browser, like jump if you scroll down rubber band style.

Anyway, someone said “what about multi-player?” So time for more node.js. When the man exits he simply walks over at the next persons screen, and walks from screen to screen. We made this a player vs. player game, but it could also be a collab. Keep the man alive for as long as possible, and keep track on how far he’s been walking and what part of the world he is in right now.

What we are doing is simply saving the player ids in an array, and walking through the array round robin style.

node.js server code example:

io.sockets.on('connection', function(socket) {
   clients[socket.id] = socket;

      io.sockets.emit('newUser', {});
      if (ids.length == 1){
         clients[ids[0]].emit('manComes', {});

   socket.on('failed', function(){

   socket.on('disconnect', function() {

   function remove(user){
      delete clients[user];
      var i = ids.indexOf(user);
      if (i > -1) {
         ids.splice(i, 1);

   function nextUser(){
      if (userInTurn = ids.shift()){
         clients[userInTurn].emit('manComes', {});

Quiz buttons in node.js

For our recent fall party we made a music quiz, and if you’re quizzin you gotta have some buttonpressin. We looked for quiz buttons at teknikmagasinet, surprisingly we didn’t find anything. So www what do you have to offer? Nothing? Well ok, let’s build some buttons in node.js. Real time web!

5 teams, connected to the same wifi, visit the laptop where node.js is running. They choose a team color (from #A0A to #EE0), and that team color is then removed from the other players screens to choose.

If one team push their button no one else can push theirs until the quiz show host resets. On the laptop we see the scores and who pushed first.

Super simple code. The client tells the server that i pushed:

socketio.emit('ipushed', { team : myteam});

And on the server side, change a state and tell the scoreboard to dim the losers:

   if (state == 'open'){
      state = 'locked';

Blue is winning!

The music questions were pretty nice ones too. Pop songs reworked in different ways – DJ Premierified, Brian Enofied, Bad youtube cover-ified, Dubified etc. This Enofied one was a hit.

Web audio music game

After we did the rhythm experiment at Music Hackday we fooled around a bit more with the web audio synthesizer. It’s pretty amazing that they got a built in synth in Chrome, and if you got some knowledge of synthesizers the different audio experiments out there (googles own minimoog for example) actually seems pretty straight forward, when you look at the api.

You basically just create an oscillator instance:
oscillator = context.createOscillator()
Give it some properties:
oscillator.frequency.value = 440
Create a filter:
filter = context.createBiquadFilter()
Choose filter type:
filter.type = 'LOWPASS'

It then works a lot like a modular synthesizer, where you connect all these boxes into each other to tamper with the audio signal before it hits the speaker. Like:


This is a simple game built with this chrome audio api. All sound is generated on the fly, and it only works in Chrome. You hear a melody, which then get split up into pieces – represented by boxes. You can click on a box to hear the part, and you should then move the boxes in the correct order of the original melody. It gets really hard pretty quickly, maybe some musical einstein could go up to 20 points or something.

Try it here: http://earthpeople.se/game_neworder

beer hacking

Screen Shot 2013-05-03 at 10.11.41 AM

today it’s ready: our own brew that puts “real” microbreweries to shame.
this is a mere 12 bottles of what we hope is a fairly hoppy american pale ale.

making it was easy. 2 pots and 2 hours. and a kit from köksbryggeriet.