Skip to content

Instantly share code, notes, and snippets.

View lojic's full-sized avatar

Brian Adkins lojic

View GitHub Profile
@lojic
lojic / ncdhhs_downloader.rb
Created June 23, 2022 16:35 — forked from johaywood/ncdhhs_downloader.rb
Download data from NCDHHS COVID dashboards
#!/usr/bin/env ruby
# Install capybara and selenium-webdriver gems
#
# $ gem install capybara
# $ gem install selenium-webdriver
#
# Install chromedriver
#
# $ brew install chromedriver
@lojic
lojic / heap.rkt
Last active December 16, 2021 13:57
#lang racket
(require data/heap)
(define input (for/list ([ _ (in-range 115000) ])
(random-string 15)))
(define (with-heap)
(define obj (make-heap string<?))
7244905526470311611337745375360647070103318145091810475294443959205903269815432029594266166723714185361138590835216693116208284679621696954033110897534800579429466521604082415532604287932045158162595824996655193676123122999642590109125116750054446144751351034094448535449050903231651086011168322066940336519305828743362259968158287856254981663117325393100679512353241286969905855684823261263305491718845440574984949592731952014645531263799099412333314776225548860610909379015530065459784664128374526292482670023239647557311841929543464352496177741523126620505898932947212196942581407512794597968799736935372536952616345876007832357627296669040359534663242523772141528718782098843153045516344571543143156760034110345688765042977365823498261667173251989351238946743053267202809640911598773285954403972192887232987869919567325418630090367135402964516465269305495519916090051933005528194145375207978612602038720995965117226971322190235621924803801171071252432305251020009793057875025779634359577567241061391347408911384623302037
#lang racket/base
(require file/sha1
racket/list
racket/random)
(define N 1000000)
(define symbol-length 5)
(define (random-string n)
(define (application-controller connection request)
(output-response/method
connection
(response
200
#"OK"
(current-seconds)
TEXT/HTML-MIME-TYPE
empty
(λ (op) (write-bytes #"<html><body>Hello, World!</body></html>" op)))
(define (application-controller connection request)
(response
200
#"OK"
(current-seconds)
TEXT/HTML-MIME-TYPE
empty
(λ (op) (write-bytes #"<html><body>Hello, World!</body></html>" op))))
(serve
#lang racket
(provide main)
; Represent a position as a struct with x (file) and y (rank) members
(struct pos (x y) #:prefab)
; Indicate whether q1 is attacking q2
(define (is-attacking? q1 q2)
(let ([q1x (pos-x q1)] [q1y (pos-y q1)] [q2x (pos-x q2)] [q2y (pos-y q2)])
@lojic
lojic / parallel.rkt
Last active March 12, 2016 00:38
Comparing a sequential and parallel version of 13-Queens in Racket
#lang racket
(provide main)
; Represent a position as a struct with x (file) and y (rank) members
(struct pos (x y) #:prefab)
; Indicate whether q1 is attacking q2
(define (is-attacking? q1 q2)
(let ([q1x (pos-x q1)] [q1y (pos-y q1)] [q2x (pos-x q2)] [q2y (pos-y q2)])
use std::sync::{Mutex, Arc};
use std::thread;
struct Philosopher {
name: String,
left: usize,
right: usize,
}
impl Philosopher {
#lang racket
(define (memoize proc)
(define memo '())
(λ (x)
(cond [(assq x memo) => cdr]
[else (let ([result (proc x)])
(set! memo (cons (cons x result) memo))
result)])))