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:

@Override
   public void onNotificationPosted(StatusBarNotification statusBarNotif) {

       Notification notif = statusBarNotif.getNotification();

       if (notif != null){

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

           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(statusBarNotif.getPackageName().equals(snapchatPackageName)){
               if(notificationId == printScreenId){
                  
                   //Split the String to get the username. 
                   String arr[] = notifText.toString().split(" ", 2);
                   String userName = arr[0];
                   
                   //Send to api.
                   runHttpPost(userName);
                  
                   //Cancel all notifications.
                   NLService.this.cancelAllNotifications();
               }
           }
           else{
               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!

http://artistsyoumightlikeinaustinmarch2014.earthpeople.se

(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.

http://placeapet.earthpeople.se

 

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.

wordpress-plugin-checker

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.

manmanbg

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;
   ids.push(socket.id);
   socket.on('manLeaving',function(data){
      nextUser();
   });

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

   socket.on('failed', function(){
      remove(socket.id);
      nextUser();
   });

   socket.on('disconnect', function() {
      remove(socket.id);
   });

   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', {});
         ids.push(userInTurn);
      }
   }
});

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.

socket.on('claim_team',function(data){
   io.sockets.emit("remove_team",data);
});
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:

socket.on('ipushed',function(data){
   if (state == 'open'){
      state = 'locked';
      io.sockets.emit("they_pushed",data);
   }
});

buttons
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'
etc.

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:
oscillator.connect(filter)
filter.connect(gain)

neworder

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.

How we created an API to our coffee machine and how we abused the 418 I’m a teapot

We needed(?) a REST API to our coffee machine. So I put a Twine next to it, and made it call back over HTTP to a webhook on one of our servers. This webhook logs all the temperature changes, and now anyone can query the dataset via our REST API. It just returns if the coffee is hot or cold in beautiful JSON.

http://earthpeople.se/api/coffee

Then, just for the hell of it, I set up an API to our teapot too.

http://earthpeople.se/api/tea

(It actually only returns that it is a teapot, according to the HTCPCC. Which is probably abusing the meaning of the status code, since it’s in the 400 Bad Request-range…)