Skip to content

Instantly share code, notes, and snippets.

View mdobson's full-sized avatar
😺
Petting a cat

Matthew Dobson mdobson

😺
Petting a cat
View GitHub Profile
/******
Header
******/
#ifndef ADAFRUIT_CC3000_UDP_SERVER_H
#define ADAFRUIT_CC3000_UDP_SERVER_H
#include "Adafruit_CC3000_UDP_Server.h"
#include "Adafruit_CC3000_ClientRef.h"
#include "Server.h"
#include "utility/socket.h"
@mdobson
mdobson / gist:8160051
Created December 28, 2013 14:31
udpserver.c
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#define BUFLEN 512
#define PORT 9930
@mdobson
mdobson / gist:8116084
Created December 24, 2013 17:41
Updated php sample
<?php
date_default_timezone_set('America/Detroit');
//include autoloader to make sure all files are included
include '../autoloader.inc.php';
usergrid_autoload('Apigee\\Usergrid\\Client');
//initialize the SDK
$client = new Apigee\Usergrid\Client('crainsdetroit','cdbapp');
//Need to login before doing anything for the sake of permissions
$client->login("USERNAME","PASSWORD");
@mdobson
mdobson / 1.js
Last active January 1, 2016 05:39
UDP Server Notes in Nodejs
var dgram = require('dgram');
var UDPServer = function() {
};
UDPServer.prototype.createServer = function(msgCallback) {
var sock = dgram.createSocket('udp4');
this.sock = sock;
sock.on('message', function(msg, rinfo){
@mdobson
mdobson / 1.js
Created December 16, 2013 14:05
Acitivity Feeds work around
//We can use Apigee.Collection or Usergrid.Collection objects in the place of some built in functions to get query goodness.
var activities = new Apigee.Collection({
type:"users/mdobs/feed",
client:apigee,
qs: {
ql: "where actor.displayName='mdobs'"
}
});
@mdobson
mdobson / gist:7964426
Last active December 31, 2015 08:59
Create docker bridge for API within container

##Use network interfaces to allow docker to speak to it's API via containers

###Daemon and host side config

  1. Add a new network hardware called api0 ip link add api0 type bridge
  2. Bring it up using ip link set api0 up
  3. Give it an IP Address ip addr add 192.168.0.1/16 dev api0
  4. Restart docker daemon on that IP address docker -d -H 192.168.0.1:4243 -d

###Docker side config

package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/hijack", func(w http.ResponseWriter, r *http.Request) {
@mdobson
mdobson / 1.js
Created December 6, 2013 15:51
getLoggedInUser docs
var apigee = new Apigee.Client({
orgName:"mdobson",
appName:"sandbox"
});
//getLoggedInUser
//An async function to get the currently authenticated user via token we store in localstorage
apigee.getLoggedInUser(function(err, data, user){
//err is error flag
//Data is raw return from api
@mdobson
mdobson / index.html
Last active December 30, 2015 09:18
Updating an entity in Apigee
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>Museums</title>
<script src="js/apigee.js"></script>
<script>
@mdobson
mdobson / 1.sh
Created December 5, 2013 14:16
SSH Command interception
#!/usr/bin/env bash
set -eo pipefail;
case "$1" in
git-hook)
APP=$2
while read oldrev newrev refname
do
# Only run this script for the master branch. You can remove this