Skip to content

Instantly share code, notes, and snippets.

@sedouard
sedouard / gist:7623912
Created November 24, 2013 06:08
This sample (from the FiddlerCorApi sample) shows how you can create a "Mock" http service for your app. This allows you to "record" traffic between the target process and the web service. Then you can "replay" mode the "Mock" service will respond with the same exact responses the actual service did. The real awesome thing here is that you can t…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Fiddler;
using System.IO;
using System.Diagnostics;
using Newtonsoft.Json;
using MockHttpServer.Data;
import com.microsoft.windowsazure.messaging.*;
import com.microsoft.windowsazure.notifications.*;
//full source at https://github.com/sedouard/AMSCrossPlatPush/blob/master/GoogleAndriod/CrossPlatformPush/src/com/example/crossplatformpush/MainActivity.java
public class MainActivity extends ActionBarActivity {
private final String PROJECT_NUMBER = "<YOUR PROJECT NUMBER FROM GOOGLE PLAY>";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
package com.example.crossplatformpush;
import android.content.Context;
import com.microsoft.windowsazure.notifications.NotificationsHandler;
import com.microsoft.windowsazure.messaging.*;
public class Handler extends NotificationsHandler {
@Override
var azure = require('azure');
//call POST https://<service-name>.azure-mobile.net/api/<endpoint name> with the tag you want in the query parameter
exports.post = function(request, response) {
var hub = azure.createNotificationHubService("crossplatpushdemohub", "Endpoint=sb://crossplatpushdemohub-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=AGeyP6352Hg585VK88XkjrXwKy37st/dp4xVGrpdyO4=");
var sendMessage = function(tag, message){
Windows.Security.Authentication.Web.WebAuthenticationBroker
.authenticateAsync(Windows.Security.Authentication.Web.WebAuthenticationOptions.default, startURI, endURI)
.then(function(result){
console.log('handle your provider specific token inside ' + result.responseData);
}, function(error){
console.error(error);
@sedouard
sedouard / gist:4362b0e809cee4fa4669
Last active August 29, 2015 14:01
Example of oauth AndContinue for Windows Phone 8.1 (javascript)
try{
//Windows 8/8.1
Windows.Security.Authentication.Web.WebAuthenticationBroker
.authenticateAsync(Windows.Security.Authentication.Web.WebAuthenticationOptions.default, startURI, endURI)
.then(function(result){
console.log('handle your provider specific token inside ' + result.responseData);
}, function(error){
@sedouard
sedouard / continuationhandler.js
Created May 23, 2014 20:19
This is an example of continuing oauth authentication with Windows Phone 8.1 (javascript)
app.addEventListener("activated", function (args) {
if (args.detail.kind == activation.ActivationKind.webAuthenticationBrokerContinuation) {
//take oauth response and continue login process
mobileSerivce.login(args.detail.webAuthenticationResult);
}
//Handle normal activiation...(hidden)
}
@sedouard
sedouard / sendToEventHub.py
Created November 13, 2014 04:09
Generate SAS Token for eventhub from Python
import urllib
import time
import hmac
import hashlib
import base64
def _sign_string(uri, key, key_name):
'''
100000 = milsecond expiry
'''
@sedouard
sedouard / dokku-dockerfile-nodejs
Created January 27, 2015 05:51
An example of using Dockerfile for Nodejs with Dokku on an Ubuntu container
FROM ubuntu:trusty
MAINTAINER Steven Edouard <steven.edouard1@gmail.com>
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -y
RUN apt-get -qq update -y
RUN apt-get install -y nodejs npm -y
#install any specific things you need on this ubuntu box
import DS from 'ember-data';
import serializer from '../serializers/azure-storage';
import accountUtils from '../utilities/account';
export default DS.Adapter.extend({
serializer: serializer.create(),
nodeServices: Ember.inject.service(),
find: function (store, type, snapshot) {
var blobService = this.get('azureStorage').createBlobService(store.account_name, store.account_key);
return new Ember.RSVP.Promise(function (resolve, reject) {
blobService.getBlobProperties(snapshot.get('container').name, snapshot.get('name'), function (error, result) {