Skip to content

Instantly share code, notes, and snippets.

View mikaturunen's full-sized avatar

Mika Turunen mikaturunen

View GitHub Profile

Keybase proof

I hereby claim:

  • I am mikaturunen on github.
  • I am mikaturunen (https://keybase.io/mikaturunen) on keybase.
  • I have a public key ASC7i2yfk0IGzu9ClXoYa2esH5qsujf2gQnOfR93F88Hygo

To claim this, I am signing this object:

@mikaturunen
mikaturunen / calculateHmac.js
Last active January 25, 2023 08:11
Example of calculating hmac in node.js
import * as crypto from 'crypto'
const merchantSecret = 'secret'
const hash = 'sha256'
const encoding = 'base64'
const payload = {
id: 123,
somethingElse: 'not 123'
}
@mikaturunen
mikaturunen / gist:f0b45def06bc83ccea9e
Created January 31, 2015 09:45
One way of hooking a callback from Angulars specific scope to HTML elements onload event
// There is no direct way of binding angular to elements onload event as commonly the HTML elements onload="" attribute looks into the
// Javascript global name space (window.*) which is a big no-no. It used to be the norm back in the day of how to do things but with
// modern frameworks like AngularJs and the such the approach has changed a lot.
// This is just one example (and by no means the only way) of how to get Angular behave nicely with HTML elements onload event. As
// <iframe onload="test()"> looks into window.test for a callback we need to bound the onload event to look into provided angular scope
// for the callback.
// NOTE: Written in ES6