This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (hsv-to-rgb hue saturation value) | |
(let* ([C (* saturation value)] | |
[A (abs (- (modulo (/ hue 60) 2) | |
1))] | |
[X (* (- 1 A))] | |
[m (- value C)] | |
[rgb-prime | |
(cond | |
[(<= 0 hue 59) `(,C ,X 0)] | |
[(<= 60 hue 119) `(,X ,C 0)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn ram [start length & {:keys [paged-in bank tag] | |
:or {paged-in false | |
bank 0}}] | |
;; I want to check here if :tag was added or not. But also i don't want to because style | |
(make-memory start length paged-in bank :text (vec (replicate length 0)) :writable true)) | |
(defn- make-memory [start length paged-in bank & {:keys [text writable tag]}] | |
;; TODO: Maybe check that length and end - start are the same; fill with zeros if not. | |
{:start start | |
:end (+ start length) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bogosort(source): | |
"""Sort by shuffling the input until it's in order. relies on probability allowing that (assuming a healthy shuffling algorithm), | |
eventually the list will appear in order""" | |
def in_order(source, iter): | |
sorted = True | |
i = 0 | |
print("(%d) in_order[%d]: %d < %d: %s :: %d <= %d: %s" %\ | |
(iter, i, i, len(source), i<len(source), source[i], source[i+1], source[i] <= source[i+1])) | |
while i < len(source)-1 and source[i] <= source[i+1]: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Disassembly of section .text.x86_io__io_wait: | |
c0100798 <x86_io__io_wait>: | |
c0100798: e6 80 out %al,$0x80 | |
c010079a: c3 ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns jna-test.core | |
(:import (com.sun.jna "Native"))) | |
(gen-interface | |
:name jna.CLibrary | |
:extends [com.sun.jna.Library] | |
:methods [[printf [String] Integer]]) | |
(def glibc (Native/loadLibrary "c" jna.CLibrary)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn bayes [a b-given-a b-given-c] | |
; p(a|b ) = p(b | a) * p(b) / p(a) | |
(let [c (- 1.0 a)] ; Complementary event of a | |
(/ (* b-given-a a) | |
(+ (* b-given-a a) (* b-given-c c))))) | |
(def plots (take 20 (iterate #(+ % 0.005) 0.005))) | |
(println "Accuracy of a drug test that is 99% sensitive, 99% specific") | |
(println "(eg. 99% true positive for users, 99% true negative for non-users)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defroutes app-routes | |
(GET "/" [] (render-page :status-page)) | |
(GET "/pages/:page" [page] (render-page (keyword page))) | |
(context "/create" [] | |
(POST "/metric" {params :params} (new-metric params)) | |
(POST "/server" {params :params} (new-server params))) | |
(context "/response" [] | |
(GET "/up/:id" [id] (views/up-file id)) | |
(GET "/down/:id" [id] (views/down-file id))) | |
(route/resources "/") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; incboot.s | |
; Incrementally build a boot block for x86 | |
; I'm going to keep adding bits to this one step at a time from | |
; boot-and hang to hopefully loading a kernel | |
; Here we go. | |
; We're implementing a FAT12 file system for the boot disk. This file system is well | |
; documented so it shouldn't be a hard ask for a first-timer like me. | |
; There is a certain order required for the metadata appearing at the top of the | |
; boot block below the jump to start, we'll introduce each as we go. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<INITIAL>{QUOTE} { BEGIN STRCONST; string_buf_ptr = string_buf; } | |
<STRCONST>{QUOTE} { BEGIN 0; | |
cool_yylval.symbol = stringtable.add_string(string_buf); | |
reset_buffer(); | |
return STR_CONST; | |
} | |
<STRCONST>[^\\\"\n\0]+ { add_to_buffer(yytext); } | |
<STRCONST>\\\n { if(!add_to_buffer("\n")) { BEGIN 0; return ERROR; } } | |
<STRCONST>\\n { if(!add_to_buffer("\n")) { BEGIN 0; return ERROR; } } | |
<STRCONST>\\\\ { if(!add_to_buffer("\\")) { BEGIN 0; return ERROR; } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro create-subdir (path subdir) | |
`(ensure-directories-exist | |
(merge-pathnames (make-pathname :directory `(:relative ,,subdir) :name "ignored") ,path)))) |
NewerOlder