Skip to content

Instantly share code, notes, and snippets.

View paulerickson's full-sized avatar

Paul Erickson paulerickson

View GitHub Profile
@paulerickson
paulerickson / unzip.go
Last active February 25, 2024 13:23
Golang unzip implementation
package unzip
import "archive/zip"
/**
* Extract a zip file named source to directory destination. Handles cases where destination dir…
* - does not exist (creates it)
* - is empty
* - already has source archive extracted into it (files are overwritten)
* - has other files in it, not in source archive (not overwritten)
<!doctype html>
<script type="module">
import './myuw-help.mjs';
let numberOfHelpDialogs = 0;
const defaultCheckbox = document.body.appendChild(document.createElement('input'));
defaultCheckbox.type = 'checkbox';
defaultCheckbox.title = 'default?';
const createButton = document.body.appendChild(document.createElement('button'));
createButton.textContent = 'Create New Help Element';
<!DOCTYPE html>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/tota11y/0.1.6/tota11y.min.js"></script>
<!-- Polyfill loader -->
<script src="https://unpkg.com/@webcomponents/[email protected]/webcomponents-bundle.js"></script>
<script type="module">
<!doctype html>
<script type="module">
import 'https://cdn.my.wisc.edu/@myuw-web-components/myuw-help@PR-18/myuw-help.min.mjs';
let numberOfHelpDialogs = 0;
const defaultCheckbox = document.body.appendChild(document.createElement('input'));
defaultCheckbox.type = 'checkbox';
defaultCheckbox.title = 'default?';
const createButton = document.body.appendChild(document.createElement('button'));
createButton.textContent = 'Create New Help Element';
@paulerickson
paulerickson / removeExpiredElementsFromCollection.lua
Last active November 20, 2017 23:32
Removes members from set if no corresponding key can be found (assuming "widgets" / "widget:99" naming convention)
local collectionKey = KEYS[1].."s"
local members = redis.call("smembers", collectionKey)
for _, id in ipairs(members) do
if redis.call("exists", KEYS[1]..":"..id) == 0 then
redis.call("srem", collectionKey, id)
end
end
return redis.call("scard", collectionKey)

Keybase proof

I hereby claim:

  • I am paulerickson on github.
  • I am paulerickson (https://keybase.io/paulerickson) on keybase.
  • I have a public key ASAoOaLPVNTwXUZ0DoU1tGRSYwqgxuZyMmI1hXXXa1Ap-go

To claim this, I am signing this object:

import random
def stumble(size):
x = int(size / 2)
y = int(size / 2)
count = 0
while -1 < x < size and -1 < y < size:
x += random.randint(-1, 1)
y += random.randint(-1, 1)
count += 1
//
//I compulsively reformat as I read, so don't expect the line numbers to match yours
//
1 import java.awt.*;
2 import java.awt.event.*;
3
4 public class ThePanel extends Panel{
5 private int boardsInList;
6 private PegBoard[] list;
7
//in ThePanel.java...
int r = 0, c = 0;
do{
r = (int)(Math.random() * 5); //I wouldn't expect this to cause problems,
c = (int)(Math.random() * 5); //but Math.random() is a double, and 5 is an int
} //it would be better form to use 5.0, which is a double
while (r + c >= 5);
...
1 PROJ = PG4
2 CSW = -O3 -Wall
3 ARCH := $(shell uname)
4 ifneq (,$(filter $(ARCH),OpenBSD Linux))
5 >-CC = g++
6 >-EXT =
7 >-LSW =
8 else
9 >-CC = gpp
10 >-EXT = .exe