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
;;; The idea here is to be able to determine velocity and distance | |
;;; attained as a function of time. | |
;; some physical constants/definitions. | |
(defconstant +g+ 9.81) | |
(defconstant +C+ 2.998e8) | |
;; Helper to determine if we've hit C (we'll use 99.9% as the cutoff) | |
(defun velocity-cap (velocity accel) | |
(if (<= (+ velocity accel) (* +C+ 0.999)) |
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
;; The following two functions are equivalent: | |
(loop repeat 10 for x = 0 then y and y = 1 then (+ x y) collect y) ; ===> (1 1 2 3 5 8 13 21 34 55) | |
(BLOCK NIL | |
(LET ((#:LOOP-REPEAT-876 (CEILING 10)) (X NIL) (Y NIL)) | |
(DECLARE (TYPE INTEGER #:LOOP-REPEAT-876)) | |
(SB-LOOP::WITH-LOOP-LIST-COLLECTION-HEAD (#:LOOP-LIST-HEAD-877 | |
#:LOOP-LIST-TAIL-878) | |
(SB-LOOP::LOOP-BODY NIL |
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)))) |
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
; 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
(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
(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
(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
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
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]: |
OlderNewer