Skip to content

Instantly share code, notes, and snippets.

@LPGhatguy
LPGhatguy / output.json
Created July 22, 2023 20:33
Output of dyn upcasting survey
{"crate_name":"wgpu_core","trait_name":"hub::GlobalIdentityHandlerFactory","entries":"36","entries_ignoring_upcasting":"20","entries_for_upcasting":"16","upcasting_cost_percent":"80"}
{"crate_name":"num_traits","trait_name":"RefNum","entries":"23","entries_ignoring_upcasting":"13","entries_for_upcasting":"10","upcasting_cost_percent":"76.92307692307693"}
{"crate_name":"wgpu","trait_name":"context::ContextData","entries":"6","entries_ignoring_upcasting":"4","entries_for_upcasting":"2","upcasting_cost_percent":"50"}
{"crate_name":"num_traits","trait_name":"NumOps","entries":"12","entries_ignoring_upcasting":"8","entries_for_upcasting":"4","upcasting_cost_percent":"50"}
{"crate_name":"num_traits","trait_name":"NumAssignOps","entries":"12","entries_ignoring_upcasting":"8","entries_for_upcasting":"4","upcasting_cost_percent":"50"}
{"crate_name":"clap_builder","trait_name":"builder::ext::Extension","entries":"10","entries_ignoring_upcasting":"8","entries_for_upcasting":"2","upcasting_cost_percent":"25"}
{"crate_nam
@LPGhatguy
LPGhatguy / main.rs
Created April 7, 2019 22:44
What percentage of v4 UUIDs are valid UTF-8?
// uuid: 0.7.4 with "v4" feature enabled
// Valid UTF-8: 6868 / 100000000
// Valid %: 0.006868
//
// Sample strings:
//
// "2U6!>:N۸\u{1e}cUV3m%"
// "ɷ1e\r}AـΕ+3Wĭ"
// "aTA ?\u{17}KǺ\u{1f}\u{7}\u{19}\u{2}\u{c}\u{7}?"
@LPGhatguy
LPGhatguy / compareList.lua
Created June 12, 2018 18:13
A quick-and-dirty list comparison function in Lua that visualizes each list, handling sparse arrays correctly.
local function compareList(list, len)
-- We use varargs here since spare arrays make Lua upset
return function(...)
len = len or select("#", ...)
local hasDifference = false
local differentIndexes = {}
for i = 1, len do
if list[i] ~= select(i, ...) then
local Roact = require(script.Parent.Parent.Roact)
local WindowedView = Roact.PureComponent:extend("WindowedView")
function WindowedView:init()
self.state = {
viewStart = 1,
viewSize = 1,
paddingStart = 0,
}
@LPGhatguy
LPGhatguy / selector-example.lua
Created April 10, 2018 23:20
Copying the Reselect API in ~40 lines of code. Does not allocate on call. Untested.
local function applySelector(selector, ...)
if typeof(selector) == "string" then
return (...)[selector]
else
return selector(...)
end
end
local function listShallowEqual(a, b, len)
for i = 1, len do
@LPGhatguy
LPGhatguy / .cvimrc
Last active February 28, 2018 00:48
Configuration for cVim
set smoothscroll
unmap d u
let blacklists = ["*://mail.google.com/*", "*://play.google.com/*", "*://*.slack.com/*", "*://discordapp.com/*"]
@LPGhatguy
LPGhatguy / main.rs
Created June 3, 2017 08:56
Start program, attempt to move window, observe that window resizes
extern crate winit;
fn main() {
let events_loop = winit::EventsLoop::new();
let window = winit::WindowBuilder::new()
.with_dimensions(200, 200)
.with_max_dimensions(200, 200)
.build(&events_loop)
.unwrap();
@LPGhatguy
LPGhatguy / generate-community.html
Created May 24, 2017 06:38
Generate several 'community' emoji -- families construct with zero-width-joiners joined together. Renders most correctly on Windows 10 w/ Creators Update!
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
#output {
font-size: 3rem;
margin: 0;
padding: 0.5rem;
line-height: 1.2;
@LPGhatguy
LPGhatguy / gist:f4caed3b81e7f84bccb701eb953a59ee
Created May 24, 2017 06:12
Community emoji, rendered by GitHub
👩🏽‍🚒‍👩🏻‍👦🏻‍👶🏻‍👩🏻‍🍳‍👩🏼‍👧🏾‍👶🏾‍👩🏽‍🚀‍👨🏽‍👦🏽‍👦🏼‍👨🏾‍🏫‍👨🏼‍👶🏾‍👧🏽‍👨🏽‍✈️‍👨🏾‍👦🏾‍👦🏼‍👨🏼‍🚒‍👩🏼‍👧🏼‍👧🏾‍👨🏾‍🎨‍👨🏼‍👦🏾‍👧🏻‍👨🏾‍✈️‍👨🏾‍👶🏼‍👦🏼‍👨🏼‍🎨‍👩🏿‍👧🏾‍👧🏽‍👩🏿‍💻‍👨🏽‍👦🏽‍👧🏼‍👩🏿‍✈️‍👨🏾‍👧🏿‍👧🏻‍👩🏾‍🎨‍👨🏼‍👦🏼‍👧🏻‍👩🏻‍🌾‍👨🏽‍👧🏾‍👧🏾‍👩🏼‍⚕️‍👨🏽‍👧🏾‍👧🏼‍👨🏾‍🚒‍👨🏿‍👶🏽‍👧🏽‍👨🏻‍💻‍👨🏽‍👧🏾‍👶🏾‍👨🏽‍🚀‍👩🏽‍👧🏼‍👧🏽‍👨🏽‍🏭‍👩🏽‍👶🏼‍👦🏾‍👨🏼‍🚒‍👩🏽‍👶🏾‍👦🏻‍👨🏼‍✈️‍👨🏾‍👧🏽‍👧🏼‍👨🏼‍🏫‍👩🏾‍👧🏻‍👦🏾‍👨🏽‍🍳‍👩🏿‍👶🏾‍👦🏻‍👨🏻‍✈️‍👩🏼‍👶🏼‍👶🏻‍👩🏻‍✈️‍👨🏿‍👧🏻‍👧🏼‍👨🏾‍🎨‍👩🏼‍👶🏽‍👶🏽‍👩🏼‍🚀‍👩🏾‍👦🏼‍👧🏽‍👨🏽‍💻‍👩🏼‍👧🏼‍👦🏾‍👨🏾‍🎤‍👩🏾‍👧🏽‍👦🏾‍👨🏻‍🎨‍👨🏼‍👶🏼‍👧🏽‍👩🏼‍🎤‍👨🏻‍👧🏼‍👧🏾‍👩🏼‍🎓‍👨🏼‍👧🏼‍👧🏾‍👨🏾‍🚒‍👨🏾‍👧🏾‍👶🏿‍👨🏾‍💼‍👨🏾‍👧🏾‍👦🏾‍👩🏽‍🚒‍👩🏼‍👶🏿‍👧🏾‍👨🏿‍🍳‍👩🏽‍👧🏽‍👧🏾‍👩🏾‍🚀‍👩🏼‍👧🏾‍👧🏿‍👩🏿‍🍳‍👩🏽‍👧🏽‍👧🏼‍👨🏽‍🏭‍👨🏿‍👧🏾‍👧🏽‍👨🏽‍🍳‍👩🏼‍👦🏻‍👶🏻‍👨🏽‍🏫‍👩🏻‍👧🏼‍👧🏼‍👨🏻‍🔬‍👨🏿‍👧🏿‍👶🏾‍👩🏾‍🏫‍👨🏽‍👧🏼‍👧🏼‍👨🏼‍🎤‍👨🏽‍👦🏻‍👧🏼‍👨🏽‍🍳‍👩🏻‍👧🏾‍👧🏾‍👩🏻‍🔬‍👩🏾‍👧🏻‍👶🏼‍👨🏽‍🎨‍👩🏻‍👦🏽‍👶🏾‍👩🏻‍💼‍👨🏼‍👧🏽‍👶🏽‍👩🏾‍🎤‍👨🏽‍👶🏻‍👧🏾‍👩🏽‍🔬‍👩🏾‍👦🏽‍👧🏻‍👨🏿‍🎨‍👨🏼‍👧🏾‍👧🏼‍👩🏼‍🚒‍👩🏼‍👦🏾‍👧🏽‍👨🏽‍✈️‍👨🏿‍👧🏾‍👧🏿‍👨🏾‍🏭‍👩🏼‍👶🏾‍👶🏽‍👨🏽‍🎤‍👩🏼‍👶🏾‍👶🏽‍👨🏽‍🚀‍👨🏼‍👧🏿‍👶🏾‍👨🏾‍🏫‍👨🏼‍👶🏼‍👶🏼‍👨🏻‍🏭‍👩🏿‍👧🏼‍👧🏿‍👩🏽‍🎨‍👨🏽‍👶🏾‍👧🏾‍👨🏻‍🚀‍👨🏼‍👦🏾‍👶🏿‍👩🏽‍✈️‍👨🏾‍👦🏿‍👧🏾‍👨🏼‍💻‍👩🏽‍👧🏻‍👶🏼‍👨🏿‍🏭‍👨🏽‍👧🏾‍👧🏼‍👨🏻‍✈️‍👩🏾‍👦🏾‍👶🏽‍👩🏼‍🔬‍👩🏽‍👶🏾‍👶🏾‍👨🏽‍🏭‍👩🏾‍👶🏿‍👦🏾‍👨🏽‍🎤‍👩🏽‍👦🏼‍👶🏾‍👩🏾‍🍳‍👩🏽‍👦🏼‍👶🏾‍👩🏽‍🏫‍👩🏽‍👶🏾‍👧🏽‍👩🏽‍🎨‍👨🏾‍👧🏻‍👦🏽‍👨🏾‍🔬‍👨🏿‍👦🏼‍👧🏿‍👩🏽‍🌾‍👩🏼‍👶🏼‍👧🏽‍👨🏿‍🎓‍👩🏼‍👶🏽‍👶🏿‍👩🏿‍🚀‍👩
@LPGhatguy
LPGhatguy / keybase.md
Created March 7, 2017 21:39
Proving Keybase.io identity!

Keybase proof

I hereby claim:

  • I am lpghatguy on github.
  • I am lpghatguy (https://keybase.io/lpghatguy) on keybase.
  • I have a public key ASAlopNHLRvh_NYWSkVIlct6b9hEdlseTDB97NKEtjNUCgo

To claim this, I am signing this object: