Skip to content

Instantly share code, notes, and snippets.

View johnrichardrinehart's full-sized avatar

John Rinehart johnrichardrinehart

View GitHub Profile
// This code is an attempt to solve (probslem description below) https://leetcode.com/explore/challenge/card/september-leetcoding-challenge/555/week-2-september-8th-september-14th/3459/
// A more efficient solution can be devised using dynamic programming: https://www.geeksforgeeks.org/count-ways-reach-nth-stair/
// ----- START Problem Description -----
// You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.
// Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.
// Example 1:
@johnrichardrinehart
johnrichardrinehart / broker_server.go
Created May 14, 2020 18:46
An HTTP server managing one subscription broker per URL path
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"time"
@johnrichardrinehart
johnrichardrinehart / broker.go
Last active May 14, 2020 18:48
A message broker using two concurrency primitives (channels and mutexes) in Go
package broker
import (
"sync"
"time"
"github.com/rs/zerolog/log"
)
type (

Keybase proof

I hereby claim:

  • I am johnrichardrinehart on github.
  • I am fuzzybear3965 (https://keybase.io/fuzzybear3965) on keybase.
  • I have a public key ASAXywmzufkBfQrO1_FWdcAIIZYJy8z2DqfA114HODQamAo

To claim this, I am signing this object:

@johnrichardrinehart
johnrichardrinehart / session.bash
Created September 24, 2019 05:13
An example output of a bash session describing an "issue" with Go modules
johnrinehart@modie test $ tree -L 3
.
├── folder
│ └── pkg
│ └── pkg.go
└── go.mod
2 directories, 2 files
johnrinehart@modie test $ go test ./...
folder/pkg/pkg.go:4:2: git ls-remote -q https://github.com/a/folder in /Users/johnrinehart/go/pkg/mod/cache/vcs/0924eb5d08e2c012fe
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 28 2017 20:53:07)
MS-Windows 64-bit GUI version with OLE support
Included patches: 1-685
Compiled by hp@HP-PC
Huge version with GUI. Features included (+) or not (-):
+acl +eval +mouse +syntax
+arabic +ex_extra +mouseshape +tag_binary
+autocmd +extra_search +multi_byte_ime/dyn +tag_old_static
+balloon_eval +farsi +multi_lang -tag_any_white
+browse +file_in_path +mzscheme/dyn +tcl/dyn
# Obtained from https://en.wikipedia.org/wiki/Telegrapher%27s_equations#Lossy_transmission_line
"
telegrapher(L,C,R=0,G=0,n=100)
returns an array of differential equations that can be
used to solve for the travelling voltages and currents as a function of time.
All quantities are expected to be per-length quantities (in S.I. units).
The problem is solved by discretizing the transmission line into n sections. If
the solution is too coarse then try changing n.
@johnrichardrinehart
johnrichardrinehart / Parallel Write
Created July 2, 2017 00:00
JuliaParallelWrite.jl
@sync @parallel for i = 1:length(x)
for j = 1:length(y)
grid[i,j] =
Cubature.hcubature(integrand(3,x[i],y[j]),[1e-2,0],[10,2*pi])[1]
end
end
@johnrichardrinehart
johnrichardrinehart / Problem5Plot.jl
Created June 27, 2017 21:44
A plot of a cat state |3> + |-3> for PHYS776 (Resch, Spring 2017) - Assignment 2, Problem 5
import Plots
Plots.plotly()
function f(B)
return function (a,b)
(2/pi)*(
2*e^(-2*(a^2+b^2))*cos(4*b*B)
+
e^(-2*((a+B)^2+b^2))*(1+e^(8*a*B))
)
import motor.motor_asyncio
import asyncio
client = motor.motor_asyncio.AsyncIOMotorClient('localhost', 27017)
db = client['testDB']
async def do_insert(user, collection_name):
document = {'user': user}
result = await db[collection_name].insert_one(document);
print('Added user %s' % user)