Skip to content

Instantly share code, notes, and snippets.

View cameronism's full-sized avatar

Cameron Jordan cameronism

View GitHub Profile
@cameronism
cameronism / index.html
Created September 30, 2020 00:00
Super Mario Maker 2 Bingo
<div>
<h1>Super Mario Maker <em>2</em> Bingo</h1>
<table></table>
<fieldset>
<legend>Options</legend>
<textarea rows=24></textarea>
<label>Seed <input type=number></label>
<button class=run>Let's Go</button>
<button class=reset>Start Over</button>
#include <iostream>
#include <Windows.h>
#include <string>
#include <codecvt>
// https://stackoverflow.com/questions/14762456/getclipboarddatacf-text
std::wstring GetClipboardText()
{
// Try opening the clipboard
if (!OpenClipboard(nullptr))
@cameronism
cameronism / TakeDescending.cs
Created February 27, 2019 01:48
Take top n items from IEnumerable<> efficiently
public static IReadOnlyCollection<T> TakeDescending<T, TKey>(IEnumerable<T> source, Func<T, TKey> keySelector, int count)
where TKey : IComparable<TKey>
{
var index = 0;
var keys = new TKey[count];
var values = new T[count];
TKey min = default;
var minIndex = 0;
foreach (var item in source)
@cameronism
cameronism / jsondiff.cs
Last active March 14, 2018 04:36
JObject based JSON diff
void Main()
{
var pairs = new (object, object)[]
{
(new {}, new {}),
(new { a = 1 }, new { a = "1" }),
(new { a = "1", b = 2 }, new { a = 1 }),
(new { a = "1", c = 2 }, new { a = 1, c = 2 }),
(new { a = "1", c = new {} }, new { a = 1, c = new {} }),
(new { a = new { a = 1 } }, new { a = new {} }),
@cameronism
cameronism / .luacheckrc
Created August 12, 2017 17:33
pico-8 luacheck configuration file (luacheckrc)
std = {
-- these globals can be set and accessed.
globals = { "_init", "_draw", "_update", "_update60" },
-- these globals can only be accessed.
read_globals = {
--[[
copy(
`-- from ${location.href} ${(new Date()).toISOString()}\n` +
[].slice.call($('#WikiaMainContent').find('ul>li>a,.mw-headline'))
@cameronism
cameronism / Demo.cs
Created May 11, 2017 16:48
ShallowValueComparer
void Main()
{
// http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethashcode
Demo(new { }, new { });
Demo(null, new { });
Demo(new { }, null);
Demo(new { a = 1 }, new { a = 1 });
//new { _1 = HashInt(1), _2 = HashInt(2) }.Dump();
Demo(new { a = 1 }, new { a = 2 });
@cameronism
cameronism / dev-tools-ftw.js
Created February 12, 2017 22:38
streamline photopass downloads
// 1. pay for all your photos
// 2. scroll through the entire album and ensure all previews have loaded
// 3. open dev tools
var stopDownloadPlease = false;
var downloadPlease = () => { setTimeout(() => {$(".icon-button.download").click(); setTimeout(() => { $(".arrow-next .icon.ng-binding.wdw.size-l.rotate-0").click(); if (!stopDownloadPlease) { downloadPlease() }; }, 4000)}, 700) };
downloadPlease();
// 4. watch downloads folder until duplicates start showing up (or some other way to make sure you got them all)
// 5. `stopDownloadPlease = true;`
@cameronism
cameronism / LICENSE
Created October 12, 2016 01:30
Extension functions on JDBC Connection and ResultSet
Copyright 2016 Cameron Jordan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
set -g mouse on
set-window-option -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
set -g @batt_color_full_charge '#[fg=colour64]' #green
set -g @batt_color_high_charge '#[fg=colour64]' #green
set -g @batt_color_medium_charge '#[fg=colour136]' #orange
set -g @batt_color_low_charge '#[fg=colour160]' #red
There are only two hard problems in distributed systems:
2. Guaranteed order of messages
1. Exactly-once delivery
2. Guaranteed order of messages
*adapted from <https://twitter.com/mathiasverraes/status/632260618599403520>*