Skip to content

Instantly share code, notes, and snippets.

View grantwinney's full-sized avatar

Grant grantwinney

View GitHub Profile
@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() ->
@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 / url-updater.py
Last active June 20, 2018 17:12
Reads in a list of URLs (from a CSV file), writes any redirected URLs to a new CSV file, and prints out missing (404) URLs to the console
import csv
import urllib2
with open('urls.csv', 'rb') as f:
reader = csv.reader(f)
with open('urls-output.csv', 'w') as g:
writer = csv.writer(g, delimiter=',')
for row in reader:
url = row[0]
try:
@grantwinney
grantwinney / whatcomments2.cs
Created August 3, 2018 21:07
an example for a blog post - comments on what, revisited
public static void Main(string[] args)
{
var accountId = "1234";
ValidateUser(accountId);
var action = GetTransactionType(accountId);
var amount = GetTransactionAmount(accountId);
ShowTransactionAndBalance(accountId, action, amount);
@grantwinney
grantwinney / whatcomments1.cs
Created August 3, 2018 21:08
an example for a blog post - comments on what
public static void Main()
{
// get account details
var accountId = "1234";
var name = "Grant";
var balance = 100m;
var secretAnswer = "42";
// validate the user in secretive fashion
var answer = "";
@grantwinney
grantwinney / mentor.sh
Last active August 7, 2018 11:11
A script to make mentoring C# solutions on Exercism a little easier
#!/bin/bash
### check for proper usage
if [ $# -ne 1 ]; then
echo $0: usage: uuid_for_solution
exit 1
fi
cd ~
@grantwinney
grantwinney / se-simplified.json
Last active October 23, 2019 01:10
A Stylus template for hiding all the cruft on the StackExchange / StackOverflow network
[
{
"enabled": true,
"updateUrl": null,
"md5Url": null,
"url": null,
"originalMd5": null,
"installDate": 1571792931541,
"name": "SE Simplified",
"sections": [
@grantwinney
grantwinney / twitter-tamer.css
Created February 12, 2020 18:40
Hide elements of the Twitter UI
@-moz-document url-prefix("https://twitter.com") {
/* LEFT COLUMN NAVIGATION */
header[role="banner"], /* HIDE ENTIRE COLUMN */
[aria-label="Twitter"], /* logo */
[data-testid="AppTabBar_Home_Link"], /* home */
[data-testid="AppTabBar_Explore_Link"], /* explore */
[data-testid="AppTabBar_Notifications_Link"], /* notifications */
[data-testid="AppTabBar_DirectMessage_Link"], /* messages */
[aria-label="Bookmarks"], /* bookmarks */
[aria-label="Lists"], /* lists */
var _ac=["\x61\x6a\x5f\x69\x6e\x64\x78\x5f\x74\x61\x63\x74","\x62\x69\x6e\x64","\x64\x72\x69\x76\x65\x72","\x64\x6f\x65\x5f\x63\x6e\x74","\x6d\x6f\x75\x73\x65\x64\x6f\x77\x6e","\x42\x61\x74\x61\x6e\x67","\x63\x6c\x69\x65\x6e\x74\x48\x65\x69\x67\x68\x74","\x65\x6d\x69\x74","\x69\x6e\x64\x65\x78\x4f\x66","\x65\x6e\x52\x65\x61\x64\x44\x6f\x63\x55\x72\x6c","\x50\x61\x6c\x61\x74\x69\x6e\x6f","\x66\x70\x56\x61\x6c\x73\x74\x72","\x6f\x6e\x70\x6f\x69\x6e\x74\x65\x72\x75\x70","\x22","\x64\x6d\x5f\x65\x6e","\x2f\x67\x65\x74\x5f\x70\x61\x72\x61\x6d\x73","\x72\x56\x61\x6c","\x72\x65\x74\x75\x72\x6e\x2f\x2a\x40\x63\x63\x5f\x6f\x6e\x21\x40\x2a\x2f\x21\x31","\x2d\x31\x2c\x32\x2c\x2d\x39\x34\x2c\x2d\x37\x30\x2c","\x68\x74\x74\x70\x3a\x2f\x2f","\x73\x74\x6f\x72\x61\x67\x65","","\x6f\x6e\x6b\x65\x79\x70\x72\x65\x73\x73","\x6e\x61\x76\x69\x67\x61\x74\x6f\x72","\x6d\x6e\x5f\x75\x70\x64\x61\x74\x65\x5f\x63\x68\x61\x6c\x6c\x65\x6e\x67\x65\x5f\x64\x65\x74\x61\x69\x6c\x73","\x6b\x65\x79\x64\x6f\x77\x6e","\x73\x70\x61\x77\x6e","\x62\
@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)).