Skip to content

Instantly share code, notes, and snippets.

View mager's full-sized avatar
🏠
Working from home

Mager mager

🏠
Working from home
View GitHub Profile
@mager
mager / medium-slackbot-4.js
Created December 29, 2015 00:13
Writing a Slackbot in 40 lines of code (Part 4)
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});
@mager
mager / medium-slackbot-3.js
Created December 28, 2015 23:59
Writing a Slackbot in 40 lines of code (Part 3)
app.post('/post', function(req, res){
var parsed_url = url.format({
pathname: 'https://api.genius.com/search',
query: {
access_token: process.env.GENIUS_ACCESS,
q: req.body.text
}
});
request(parsed_url, function (error, response, body) {
@mager
mager / medium-slackbot-2.js
Created December 28, 2015 23:57
Writing a Slackbot in 40 lines of code (Part 2)
app.set('port', (process.env.PORT || 9001));
app.get('/', function(req, res){
res.send('It works!');
});
@mager
mager / medium-slackbot-1.js
Last active December 28, 2015 23:56
Writing a Slackbot in 40 lines of code (Part 1)
var express = require('express');
var app = express();
var url = require('url');
var request = require('request');
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
@mager
mager / index.html
Last active November 30, 2015 23:40
This is just a test
<html>
<head>
<style>
html, body, #map_canvas {
height: 300px;
width: 300px;
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3&sensor=false"></script>
@mager
mager / get_delivery.json
Created September 2, 2015 22:34
Postmates API: Get the status of a delivery (/customers/:customer_id/deliveries/:delivery_id)
{
"status": "dropoff",
"dropoff": {
"phone_number": "646-234-2271",
"name": "Mager's House",
"notes": "",
"detailed_address": {
"city": "New York City",
"country": "US",
"street_address_1": "498 Central Park N",
/**
* Smart Alarm is a multi-zone virtual alarm panel, featuring customizable
* security zones. Setting of an alarm can activate sirens, turn on light
* switches, push notification and text message. Alarm is armed and disarmed
* simply by setting SmartThings location 'mode'.
*
* Please visit <http://statusbits.github.io/smartalarm/> for more
* information.
*
* Version 2.4.3 (7/7/2015)
@mager
mager / sonos.groovy
Created June 23, 2015 17:02
Controlling Sonos from SmartThings
preferences {
section("Title") {
input "player", "capability.musicPlayer", title: "music player", required: true, multiple: false
input "frontDoor", "capability.contactSensor", title: "front door", required: true, multiple: false
}
}
def installed() {
subscribe(frontDoor, "contact", myHandler)
}
@mager
mager / sms-hue.php
Last active August 29, 2015 14:23
SmartThings SmartApp Example: SMS to Hue script
<?php
$url = '<YOUR SMARTAPP ENDPOINT>';
$body = $_REQUEST['Body'];
$data = "{'value':'$body'}";
$options = array(
'http' => array(
'header' => "Authorization: Bearer <YOUR SMARTAPP TOKEN>\nContent-type: application/json",
'method' => 'PUT',
@mager
mager / twilio-to-smartapp.php
Created May 28, 2015 21:38
Twilio to SmartApp
<?php
$url = 'https://graph.api.smartthings.com/api/smartapps/installations/dc20d3c1-7573-4fe2-9e13-ac095c4eb20e/hue';
//$data = array('text' => 'color=orange');
$body = $_REQUEST['Body'];
$data = "{'value':'$body'}";
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(