Skip to content

Instantly share code, notes, and snippets.

View paulerickson's full-sized avatar

Paul Erickson paulerickson

View GitHub Profile
bool node::del(node*& p, string n) {
83 if (n < name) //to the left
84 if (l)
85 return l->del(l, n);
86 else
87 return 0;
88
89 if (n > name) //to the right
90 if (r)
91 return r->del(r, n);
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
//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);
...
//
//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
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

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:

@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)
<!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';
<!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/webcomponentsjs@2.3.0/webcomponents-bundle.js"></script>
<script type="module">
<!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';