Skip to content

Instantly share code, notes, and snippets.

@darwingr
darwingr / linked_list_traversal_pointer2pointer.cpp
Last active August 18, 2021 09:14
Pointer to pointer: Unexpected way it simplified my linked list code. See comments for visualization.
// Nice way to traverse a linked list,
// makes it easier to implement methods like deleteIthNode(i),
// as was done in assignment 2 and Lab 3 of CSCI 255.
// I never thought a "pointer to a pointer" would have ever
// made my code simpler to read and reason about but here we are.
struct node {
int info = 0;
node* next = nullptr;
node(int el=0, node* n = nullptr) :
@darwingr
darwingr / heap.py
Last active November 30, 2016 01:15
#! /usr/bin/env python
class MinHeap(object):
"""A min heap with a zero based index
"""
def __init__(self, arr=[]):
self.arr = arr
self.size = 0
self.build_min_heap()
@darwingr
darwingr / e-xact.php
Last active September 16, 2015 23:40
Initial testing with e-xact's public templates for processing payments for registrations on March 12, 2015
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<title>
Hosted Checkout: Sample PHP Payment Form
</title>
<style type="text/css">
label {
@darwingr
darwingr / move_attributes_to_registrant_model.rb
Last active September 12, 2015 07:50
Moving columns to a new empty table, the foreign keys are already in place.
class MoveAttributesToRegistrantModel < ActiveRecord::Migration
def up
Payment.find_each do |payment|
registrant = Registrant.create! email: payment.email,
first_name: payment.first_name,
last_name: payment.last_name
payment.registrant_id = registrant.id
payment.save!
end
<!-- javascript and CSS for dropdown at the top -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
var $j = jQuery.noConflict();
$j(document).ready(function() {
$j("#flip").click(function() {
$j("#panel").slideDown("slow");
});
});