Skip to content

Instantly share code, notes, and snippets.

🤠
Howdy

aksel

🤠
Howdy
Block or report user

Report or block aksel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aksel
aksel / routes.js
Created Dec 1, 2017
Util function that recursively traverses routes, finding the component of a route.
View routes.js
const SomeComponent = () => <span>Hello world</span>
export default [
{
path: '/',
name: 'main',
component: SomeComponent,
},
{
path: '/parent',
name: 'parent',
@aksel
aksel / middlewares.js
Last active Jun 28, 2019
Route HTTP status code middleware for router5
View middlewares.js
import { startsWithSegment } from 'router5-helpers';
import { transitionPath } from 'router5';
// Reduces the activated routes, so the last status is used, defaulting to 200
// Reducingg instead of finding, assures that child routes determine the status codes, even when a parent has a different one.
export const statusCodeDecorator = routes => () => (toState, fromState) => {
const status = getActivatedRoutes(routes, toState, fromState).reduce((s, route) => route.status || s, 200);
return Promise.resolve({ ...toState, status });
};
@aksel
aksel / encryption.js
Last active Mar 19, 2018 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in Node.js
View encryption.js
'use strict';
const crypto = require('crypto');
const KEY_LENGTH = 32; // Must be 32 bytes
const IV_LENGTH = 16; // For AES, this is always 16
// Creates 32 byte key (for AES-256), buffer
const createKey = () => crypto.randomBytes(KEY_LENGTH);
@aksel
aksel / Kotlin Socket.IO example
Last active Nov 15, 2019
Kotlin Socket.IO example connection function.
View Kotlin Socket.IO example
import io.socket.client.IO
import io.socket.client.Socket
fun connect() {
val socket = IO.socket("http://localhost:4000?user=aksel")
socket.connect()
.on(Socket.EVENT_CONNECT, { println("connected") })
.on(Socket.EVENT_DISCONNECT, { println("disconnected") })
}
You can’t perform that action at this time.