Skip to content

Instantly share code, notes, and snippets.

@IanDoarn
IanDoarn / game_of_life.py
Created May 6, 2020 18:21
Conway's Game of Life
import random
import copy
import os
# Game Settings
ALIVE = '*'
DEAD = ' '
class Point:
@IanDoarn
IanDoarn / 4QAM_simulation.m
Created April 24, 2020 15:16
Simulate 4QAM digital communication system using Uniform and Gaussian Noise
clear all variables;
clc;
N = 1e5;
A = randi(4, N, 1) - 1;
delta = 1;
psi = [0.1 0.5 1 1.5 2 2.5 5];
for p = 1:length(psi)
@IanDoarn
IanDoarn / debit_policy_2019_compliance.sql
Created May 21, 2019 13:24
This is a script that attempts to verify records that are push back to loan and extended. This means that the territory/distributor sent back a kit that was missing components. When this kit is macro-verified at the warehouse, missing components are pushed back to the loan. However there are times a distributor will do this on purpose to keep pr…
create or replace procedure debit_policy_2019_compliance()
language plpgsql
as
$$
declare
r RECORD;
rslt doarni.ci_stock_history%rowtype;
vitem varchar;
vlot varchar;
@IanDoarn
IanDoarn / PERSONA_CASES_AND_PARKED_BY_POLY.sql
Created September 25, 2018 15:29
Persona Poly implants by territory within 1 day fedex ground around warsaw indiana. Shows their usage and amount parked at accounts / territories.
WITH persona AS (
SELECT DISTINCT
(regexp_matches(p.product_number, '^42-\d{4}-\d{3}-\d{2}$')) [1] AS product_number,
p.id,
p.description,
CASE
WHEN p.description ~ '^.*(\sCR\s|\sCR)(.*)(?=(\sVE\s)).*$'
THEN 'Cruciate Retaining Vivacit-E (CR VE)'
WHEN p.description ~ '^.*(\sCR\s|\sCR)(.*)(?!(\sVE\s)).*$'
THEN 'Cruciate Retaining (CR)'
@IanDoarn
IanDoarn / kit_research.sql
Created September 25, 2018 15:28
Look up transfer history associated with given kit number and serial over a range of days
/*
finds last few transfers of kit, very broad detail
INPUTS:
DAY_RANGE : number of days to search back
KIT_NUMBER : kit product number
KIT_SERIAL : kit serial number
*/
WITH ITEM_TO_KIT AS (
SELECT
@IanDoarn
IanDoarn / lr_rotater.sv
Last active September 22, 2018 23:19
Left and Right 4 bit rotator written in SystemVerilog
`timescale 1ns/1ps
module left_rotator(
input x, y,
input logic [3:0] I,
output logic [3:0] b
);
always_comb
begin
@IanDoarn
IanDoarn / geomapper.py
Last active April 24, 2020 15:17
Given 2 address, returns the driving distance in kilometers
import pprint
import requests
import psycopg2
import json
from Objects import *
BING_API_KEY = 'Aly75a6j5FS44wxXKh1qCUqIoVwGEV8dKYWBPtOTHRK6AGNHKsj8pBVv4eyEY1VX'
CONNECTION_INFO = {
'USER': '',
using ItemLookUp.LookUp.Inventory;
using System;
using System.Collections.Generic;
using System.Text;
/// <summary>
/// Cannibalizer
/// This class takes information about objects that contain components and
/// builds a process to maximize the amount of valid kits that can be made
/// with the supplied kits.
@IanDoarn
IanDoarn / PriorityQueue.cs
Created December 8, 2017 12:31
Min Heap Priority Queue implemented in C#
using System;
using System.Collections.Generic;
using System.Linq;
namespace ItemLookUp.Tools
{
private interface IQueue<T>
{
bool isEmpty();