Skip to content

Instantly share code, notes, and snippets.

View mikedll's full-sized avatar

Michael Rivera mikedll

View GitHub Profile
@mikedll
mikedll / implementation.py
Last active July 14, 2018 01:09
Red-Black Trees in Python with Visual Output
class Node:
def __init__(self, val, color = 'B'):
self.val = val
self.color = color
self.left = None
self.right = None
self.parent = None
def grandparent(self):
if self.parent != None:
@mikedll
mikedll / purchase_orders.html
Created October 8, 2018 17:18
A couple of pages of HTML I've made. While doing webapps.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta content="HTML Tidy for Linux (vers 25 March 2009), see www.w3.org" name="generator">
<title>
Purchase Orders - Page 1
</title>
<meta content="authenticity_token" name="csrf-param">
<meta content="7g2N04MLk8aWMpRjaQlf+ikSI1GAGo//d5K7rRSyo/4MJiaip03zW07nfmZ6N3ZI/zI0UzZBKiui5NQetx0BpA==" name="csrf-token">
<meta name="csp-nonce">
@mikedll
mikedll / pos.sql
Last active October 9, 2018 21:15
Sample PostgreSQL schema based on ActiveRecord's concept of datatype mappings
-- This is to use as a reference for creating PostgreSQL tables.
-- It comes from a Rails database, so these statements are from
-- activerecord's idea of how to map Decimal, Datetime, and string
-- fields to SQL data types. The version of activerecord used was 5.2.x.
-- The live application from which this code came is at
-- https://pinvvue.herokuapp.com/
-- The app code for it is at
-- https://github.com/mikedll/PInvVue
@mikedll
mikedll / DbWrapper.cs
Last active October 30, 2018 00:14
SQL Server Schemas and non-EF way of working with db data.
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
namespace DScrib2.Models
{
public class User
{
@mikedll
mikedll / parse.el
Last active February 24, 2019 03:54
Parse lines of a file.
(defun get-lines()
(let* ((mine-file (concat settings-dir "/common/emacs/mike/mine.txt"))
(cur-line nil)
(files-to-load (list))
(my-configs-buf (find-file-noselect mine-file)))
(with-current-buffer my-configs-buf
(goto-char (point-min))
@mikedll
mikedll / file.json
Created April 1, 2019 14:48
Promises exercise
{
"id": 1,
"name": "Michael",
"lastname": "Rivers"
}
    create_table :users do |t|
      t.string  :name
      t.bigint  :remote_id
      t.decimal :salary
      t.text :introduction
      t.timestamps
    end
@mikedll
mikedll / Exercise.md
Last active February 16, 2024 03:09
Libretext Kwong Example 7.4.3

Show that "divides" (|) is a partial ordering of the positive integers $\mathbb{Z}^+$. Explain why $(\mathbb{Z}^*, |)$ is not a posit.

Let S = ($\mathbb{Z}^+$,|)

Reflexive:

Every number divides itself with quotient 1. So xRx for all x in $\mathbb{Z}^+$.

Antisymmetric:

@mikedll
mikedll / Exercises14.1.md
Last active March 7, 2024 02:16
CLRS Chapter 14.1 Exercises

Exercise 14.1-1

Here is the recursive CutRod algorithm:

CutRod(p, n)
  if n == 0
    return 0
   
 q = -1
@mikedll
mikedll / Exercises.md
Last active April 27, 2024 11:27
CLRS Chapter 2 Exercises

Exercise 2.1-2

At the start of the for loop, sum contains the sum of values in the subarray A[1:i-1].

Initialization: i=1, and sum is 0, so it contains the sum of the empty array A[1:0].

Maintenance: sum increases by A[i]. So If it held A[1:i-1], then it now holds