Skip to content

Instantly share code, notes, and snippets.

View matthewrobertson's full-sized avatar
🦖

Matthew Robertson matthewrobertson

🦖
  • Google
  • Vancouver, BC
View GitHub Profile
@matthewrobertson
matthewrobertson / issue_token.swift
Created December 2, 2020 21:28
Issue an ACS user access token in Swift
// Script to issue an ACS user token via HMAC auth as described in this doc:
// https://docs.microsoft.com/en-us/azure/communication-services/concepts/authentication?tabs=csharp#sign-an-http-request
import UIKit
import Foundation
import CryptoKit
struct FetchTokenResult: Codable {
var identity:String
var token:String
var expiresIn: Int
curl --header "Content-Type: application/json" --header "Authorization: SpoolSAS qGmX/SF1OmX81jLQVYrJ61xX9tE3Gq7JnRchs/eDfkaaJwdiIL/kUW8hQnGdwdtcJeHxQlvibyfM3i8r9WwwLg==" --request POST --data '{"senderId": "+17086676628", "recipientId": "+12126712234", "contents": "Hi, this is a test message."}' -v -k https://localhost:9998/rtc/telephony/sms
curl --header "Content-Type: application/json" \
--header "Authorization: SpoolSAS eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJydW5uZXItZGV2LWV1cyIsInJlczpyZ24iOiJlYXN0dXMiLCJzYXM6YXJlYXMiOiJhZG1pbiJ9.dbEbZdJKKPqLzwitDvHg-mDDtvRQXhy-TXSK1wQyiSY" \
--header "X-Forwarded-Host: runner-dev-eus.eastus.dev.spool.azure-int.net" \
--header "accept: application/json" \
-d "{\"senderId\":\"+17086676628\",\"recipientId\":\"+12126712234\",\"contents\":\"test\"}" \
--request POST -v -k https://localhost:9998/rtc/telephony/sms
@matthewrobertson
matthewrobertson / gist:7699048
Created November 28, 2013 22:38
generate oauth tokens
require 'oauth'
require 'forwardable'
module Sredder
WRIKE_OAUTH_OPTIONS = {
:site => 'https://www.wrike.com',
:authorize_path => '/rest/auth/authorize',
:access_token_path => '/rest/auth/access_token',
:request_token_path => '/rest/auth/request_token'
@matthewrobertson
matthewrobertson / base_serializer.rb
Last active June 14, 2016 07:16
A simple pattern for creating classes that encapsulate JSON serialization logic. Simply inherit from the `BaseSerializer` and override the hook methods as necessary.
# An abstract base class used to create simple serializers
# for ActiveRecord objects
class BaseSerializer
include Rails.application.routes.url_helpers
attr_reader :serialized_object
def initialize(serialized_object)
@serialized_object = serialized_object
end
@matthewrobertson
matthewrobertson / gist:5265684
Created March 28, 2013 18:33
RB relative file path
File.expand_path("../../config/application.yml", __FILE__)
@matthewrobertson
matthewrobertson / gist:5241184
Created March 25, 2013 21:57
JS angular factory
(function() {
'use strict';
angular.module('medeo.services').
factory('DesktopVidyoApi', ['$rootScope',
function ($rootScope) {
}
]);
@matthewrobertson
matthewrobertson / gist:5239643
Created March 25, 2013 18:59
JS angular controller
(function() {
"use strict";
angular.module('medeo.controllers').
controller('ControllerCtl', ['$scope',
function ($scope) {
}
]);
@matthewrobertson
matthewrobertson / gist:5218277
Created March 22, 2013 01:30
JS Angularjs Directive Scaffold
(function() {
"use strict";
angular.module('caseShow')
.directive('timeAgo', function($timeout) {
var directiveDefinitionObject = {
priority: 0,
template: '<div></div>',
templateUrl: 'directive.html',
replace: false,
(function() {
"use strict";
})();
@matthewrobertson
matthewrobertson / gist:4053020
Last active October 12, 2015 16:08
GIT delete all local merged branches
git branch --merged | grep -v 'master$' | xargs git branch -d