Skip to content

Instantly share code, notes, and snippets.

@khle
khle / jwtaadUtils.js
Created October 23, 2016 06:19
JWT ADD Utils
import jsonwebtoken from 'jsonwebtoken';
export function getTenantId(jwtString) {
var decodedToken = jsonwebtoken.decode(jwtString);
if(decodedToken) {
return decodedToken.tid;
} else {
return null;
}
}
@khle
khle / jwtNodeAzureAD.js
Created October 23, 2016 06:40
JWT Node Azure AD
import {Observable} from 'rx';
import http from 'http';
import restler from 'restler'
import * as jwtaadUtils from './jwtaadUtils';
function get(url) {
return Observable.create(observer => {
restler.get(url).on('complete', (result) => {
if (result instanceof Error) {
observer.onError(result);
@khle
khle / out.txt
Created October 23, 2016 07:04
Output from running JWT Node Azure AD
cb45....-....-....-....-......ad4fe2
{ decoded:
{ aud: 'http://someurl.azurewebsites.net',
iss: 'https://sts.windows.net/cb45....-....-....-....-......ad4fe2/',
iat: 1477204898,
nbf: 1477204898,
exp: 1477208798,
acr: '1',
amr: [ 'pwd' ],
appid: '.........',
@khle
khle / LineEntry.cs
Created January 2, 2017 16:16 — forked from davidtavarez/LineEntry.cs
Xamarin.Forms Entry just with bottom border.
using Xamarin.Forms;
namespace YOUTNAMESPACE
{
public class LineEntry : Entry
{
public static readonly BindableProperty BorderColorProperty =
BindableProperty.Create<LineEntry, Color> (p => p.BorderColor, Color.Black);
public Color BorderColor {
@khle
khle / variance.md
Created January 10, 2017 21:53 — forked from maiermic/variance.md
Description of the four kinds of variance: covariance, contravariance, invariance and bivariance.

Variance

The term variance describes how subtyping between higher kinded types is related to subtyping relations of their type arguments.

Higher Kinded Types

A higher kinded type composes type arguments to a new type. I use square bracket notation to define a higher kinded type:

C[T] // The higher kinded type `C` composes type argument `T` to a new type `C[T]`.

The same works with multiple type arguments:

@khle
khle / DivideBy5
Created February 9, 2017 13:29
Elm DivideBy5
import Html exposing (text)
main =
divideBy5 140
|> toString
|> text
divideNumber: Float -> Float -> Float
divideNumber divisor divident =
divident / divisor
var byMonth = R.groupBy(R.prop('Month'));
var byAuthor = R.groupBy(R.prop('Author'));
var royalty_key = 'Royalty (SUM)';
var months_keys = R.uniq(R.map(R.prop('Month'), data)).sort();
var monthly_revenue =
R.map((group) =>
R.reduce((acc, record) => acc + parseMoney(record[royalty_key]), 0, group),
byMonth(data));
@khle
khle / .eslintrc
Created February 19, 2017 14:31
.eslintrc
module.exports = {
"env": {
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"installedESLint": true,
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
{
"route":{
"name":"Westwinds Night & Weekend",
"tag":"westwindsnw",
"color":"4575b4",
"max_lat":"41.66357",
"max_lng":"-91.53527",
"min_lat":"41.6375193",
"min_lng":"-91.57829",
"agencyname":"Iowa City Transit",
@khle
khle / App.js
Created March 11, 2017 02:32
App.js
export default class App extends Component {
constructor(props, context) {
super(props, context);
this.state = {
active: 'Today',
};
}
static navigationOptions = {