Skip to content

Instantly share code, notes, and snippets.

@LPGhatguy
LPGhatguy / digest.js
Last active January 5, 2024 13:47
Half-baked HTTP/HTTPS Digest Authentication for node.js.
var http = require("http");
var https = require("https");
var crypto = require('crypto');
function HTTPDigest(username, password, use_https) {
this.username = username;
this.password = password;
this.use_https = use_https;
}
@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 / luajit-curl.lua
Last active March 19, 2023 09:53
A cURL binding for LuaJIT. Missing some constants presumably, but functional
--[[
LuaJIT-cURL
Lucien Greathouse
LuaJIT FFI cURL binding aimed at cURL version 7.38.0.
Copyright (c) 2014 lucien Greathouse
This software is provided 'as-is', without any express
or implied warranty. In no event will the authors be held
liable for any damages arising from the use of this software.
@LPGhatguy
LPGhatguy / game.html
Last active September 29, 2019 01:18
Reglike: A simple roguelike written in Regex!
<!DOCTYPE html>
<html>
<head>
<title>Reglike</title>
<style>
*, *::before, *::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
@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 / 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/*"]