Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Andrew Mager mager

🏠
Working from home
Block or report user

Report or block mager

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mager
mager / medium-slackbot-4.js
Created Dec 29, 2015
Writing a Slackbot in 40 lines of code (Part 4)
View medium-slackbot-4.js
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});
@mager
mager / medium-slackbot-3.js
Created Dec 28, 2015
Writing a Slackbot in 40 lines of code (Part 3)
View medium-slackbot-3.js
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 Dec 28, 2015
Writing a Slackbot in 40 lines of code (Part 2)
View medium-slackbot-2.js
app.set('port', (process.env.PORT || 9001));
app.get('/', function(req, res){
res.send('It works!');
});
@mager
mager / medium-slackbot-1.js
Last active Dec 28, 2015
Writing a Slackbot in 40 lines of code (Part 1)
View medium-slackbot-1.js
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 Nov 30, 2015
This is just a test
View index.html
<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 Sep 2, 2015
Postmates API: Get the status of a delivery (/customers/:customer_id/deliveries/:delivery_id)
View get_delivery.json
{
"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",
View smartthings-smart-alarm.groovy
/**
* 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 Jun 23, 2015
Controlling Sonos from SmartThings
View sonos.groovy
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 Aug 29, 2015
SmartThings SmartApp Example: SMS to Hue script
View sms-hue.php
<?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',
View twilio-to-smartapp.php
<?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(
You can’t perform that action at this time.