Skip to content

Instantly share code, notes, and snippets.

View nordbergm's full-sized avatar

Mattias Nordberg nordbergm

  • Elastic
  • Brisbane, Australia
View GitHub Profile
@nordbergm
nordbergm / auth.js
Last active December 24, 2015 15:39
(function() {
angular.module('k2.auth.services', [])
.service('authService', ['$rootScope', '$http', function($rootScope, $http) {
return {
buildRequestSignature: function (identity, request) {
var username = identity.username;
var client = identity.clientId;
var privateKey = identity.privateKey;
var ts = new Date().getTime();
var nonce = Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
@nordbergm
nordbergm / geo_sort.json
Created May 28, 2015 09:19
Elasticsearch geo_distance sort
PUT /geo_sort
{
"mappings": {
"place": {
"properties": {
"name": {
"type": "string"
},
"location": {
"type": "geo_point"
@nordbergm
nordbergm / InMemoryMessageBus.js
Created June 26, 2015 06:38
In-memory pub-sub message bus
import _ from 'lodash';
export class InMemoryMessageBus {
constructor() {
this.subscriptions = [];
}
publish(msgs) {
return new Promise((resolve, reject) => {
try {
@nordbergm
nordbergm / keybase.md
Last active September 24, 2020 05:24

Keybase proof

I hereby claim:

  • I am nordbergm on github.
  • I am nordbergm (https://keybase.io/nordbergm) on keybase.
  • I have a public key ASDkSe2xF2MJ7-zBmesnebd3Eoiw5DdFnv0Bh-KRgjtgcgo

To claim this, I am signing this object: