Skip to content

Instantly share code, notes, and snippets.

View grantwinney's full-sized avatar

Grant grantwinney

View GitHub Profile
@grantwinney
grantwinney / utils.erl
Last active April 1, 2021 04:48
Erlang utilities. Concatenates mixed list of values (binaries/strings/atom/integer/float) into a single binary or string.
-module(utils).
-export([concat/2]).
%% EXTERNAL
concat(Words, string) ->
internal_concat(Words);
concat(Words, binary) ->
list_to_binary(internal_concat(Words)).
@grantwinney
grantwinney / ghost_edit_bookmarklet.txt
Last active April 13, 2018 13:51
A little "edit page" bookmarklet if you're using the Ghost blog. Redirects URL to /edit. Just save it as a new bookmark.
javascript:let%20u=window.location.href;if(u.indexOf('grantwinney.com')!==-1&&!(u.endsWith('.com/'))&&u.indexOf('ghost/#/editor')===-1){window.location.href=window.location.protocol+window.location.pathname+'/edit';}
@grantwinney
grantwinney / scaling.erl
Created April 24, 2017 02:25
Small example of scaling up processes to handle an increased workload
-module(scaling).
-export([start_router/0, init_router/0, process_message/1]).
-define(MESSAGE_LIMIT, 3).
start_router() ->
register(scaling, spawn(scaling, init_router, [])).
init_router() ->