Skip to content

Instantly share code, notes, and snippets.

@sedouard
sedouard / blank_vhd.py
Last active June 11, 2018 22:40
Create Blank VHD for Microsoft Azure
import datetime
import uuid
from azure.storage import BlobService
def generate_vhd_footer(size):
# Fixed VHD Footer Format Specification
# spec: https://technet.microsoft.com/en-us/virtualization/bb676673.aspx#E3B
# Field Size (bytes)
# Cookie 8
# Features 4
@sedouard
sedouard / SAStoken.cs
Created July 10, 2015 02:15
Generates a SAS Token for Azure REST Api Calls (Particularly for Service Bus Services like Event Hub & Queues)
/// <summary>
/// Code for generating of SAS token for authorization with Service Bus
///
/// This handy function can be found on this helpful blog post:
/// http://developers.de/blogs/damir_dobric/archive/2013/10/17/how-to-create-shared-access-signature-for-service-bus.aspx
/// </summary>
/// <param name="resourceUri"></param>
/// <param name="keyName"></param>
/// <param name="key"></param>
/// <returns></returns>
@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
@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 / canvast-toblob.js
Created September 17, 2016 00:56
Canvas.js ToBlob
canvas.toBlob(function(blob) {
var fs = require('fs'),
out = fs.createWriteStream(__dirname + '/chart.png');
out.write(jsdom.blobToBuffer(blob));
}, "image/png");
@sedouard
sedouard / canvas-chartjs.js
Created September 17, 2016 00:54
Using Canvas.js in Node.js
// Using the node canvas module
var fs = require('fs');
var jsdom = require("jsdom");
jsdom.defaultDocumentFeatures = {
FetchExternalResources: ["script"],
ProcessExternalResources: true
};
jsdom.env('<html><body><div id="chart-div" style="font-size:12; width:800px; height:800px;"><canvas id="myChart" width="400" height="400" style="width:400px;height:400px"></canvas>></div></body></html>',
['https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.2.2/Chart.js'],
function (err, window) {
@sedouard
sedouard / chartjs-example.js
Created September 17, 2016 00:53
Chart.js Example
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
@sedouard
sedouard / chartjs-object
Created September 16, 2016 23:23
ChartJS Object
{ chart:
{ config: { type: 'bar', data: [Object], options: [Object] },
ctx:
CanvasRenderingContext2D {
canvas: HTMLCanvasElement {},
createPattern: [Function],
drawImage: [Function],
lastFontString: 'normal 12px \'Helvetica Neue\', \'Helvetica\', \'Arial\', sans-serif',
lastTextAlignment: 'right',
lastBaseline: 'middle' },
@sedouard
sedouard / chartjs-node.js
Created September 16, 2016 23:22
Trying to use Chart.js sever-side
var Canvas = require('canvas')
, Image = Canvas.Image;
var fs = require('fs');
var jsdom = require("jsdom");
jsdom.defaultDocumentFeatures = {
FetchExternalResources: ["script"],
ProcessExternalResources: true
};
global.Canvas = Canvas;
global.Image = Canvas.Image;
@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;