initial commit
This commit is contained in:
commit
126de096be
|
@ -0,0 +1,7 @@
|
||||||
|
*~
|
||||||
|
\#*
|
||||||
|
.\#*
|
||||||
|
*.zo
|
||||||
|
*.dep
|
||||||
|
/crossfire/compiled/
|
||||||
|
/crossfire/doc/
|
|
@ -0,0 +1,17 @@
|
||||||
|
# AScrossfire
|
||||||
|
|
||||||
|
hello world
|
||||||
|
|
||||||
|
## components
|
||||||
|
|
||||||
|
- base: #lang for configuration/definitions
|
||||||
|
- server: distribute jobs to workers
|
||||||
|
- base definitions of input classes and how to divide them
|
||||||
|
- dynamic slicing and scheduling based on agents' reported work rate
|
||||||
|
- fairly randomized distribution
|
||||||
|
- agent: accepts and runs jobs
|
||||||
|
- optional: containerization
|
||||||
|
- optional: appimage-like behavior
|
||||||
|
- required: run binary with infrastructure to get assigned brute force range, log and report
|
||||||
|
progress. via library interface as well as stdio interface
|
||||||
|
- client: submit jobs and view progress via command line (and maybe racket/gui and framework???)
|
|
@ -0,0 +1,10 @@
|
||||||
|
#lang info
|
||||||
|
|
||||||
|
(define pkg-desc "a package. whoa")
|
||||||
|
(define version "0.1")
|
||||||
|
(define pkg-authors '(haskal))
|
||||||
|
|
||||||
|
(define collection "crossfire")
|
||||||
|
(define deps '("base"))
|
||||||
|
(define build-deps '("scribble-lib" "racket-doc" "rackunit-lib"))
|
||||||
|
(define scribblings '(("scribblings/crossfire.scrbl" ())))
|
|
@ -0,0 +1,110 @@
|
||||||
|
#lang racket/base
|
||||||
|
|
||||||
|
(require racket/bool racket/function racket/match racket/set racket/vector
|
||||||
|
(for-syntax racket/base racket/syntax))
|
||||||
|
|
||||||
|
(module+ test
|
||||||
|
(require rackunit))
|
||||||
|
|
||||||
|
(module+ test
|
||||||
|
(check-equal? (+ 2 2) 4))
|
||||||
|
|
||||||
|
(module+ main
|
||||||
|
(require racket/cmdline)
|
||||||
|
(define who (box "world"))
|
||||||
|
(command-line
|
||||||
|
#:program "my-program"
|
||||||
|
#:once-each
|
||||||
|
[("-n" "--name") name "Who to say hello to" (set-box! who name)]
|
||||||
|
#:args ()
|
||||||
|
(printf "hello ~a~n" (unbox who))))
|
||||||
|
|
||||||
|
|
||||||
|
;; manifest.rkt processing
|
||||||
|
|
||||||
|
(define (string->charset str)
|
||||||
|
(for/set ([ch (in-string str)])
|
||||||
|
(char->integer ch)))
|
||||||
|
|
||||||
|
(define (range->charset a b)
|
||||||
|
(for/set ([i (in-range a b)]) i))
|
||||||
|
|
||||||
|
(define builtin-charsets
|
||||||
|
(hash "?l" (string->charset "abcdefghijklmnopqrstuvwxyz")
|
||||||
|
"?u" (string->charset "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||||
|
"?d" (string->charset "0123456789")
|
||||||
|
"?s" (string->charset " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~")
|
||||||
|
"?a" (range->charset 32 127)
|
||||||
|
"?b" (range->charset 0 256)))
|
||||||
|
|
||||||
|
(define (parse-manifest manifest-def)
|
||||||
|
(struct manifest [name mode command charsets pattern] #:transparent)
|
||||||
|
|
||||||
|
(define (eq/m x) (curry equal? x))
|
||||||
|
|
||||||
|
(define-syntax (check-false stx)
|
||||||
|
(syntax-case stx ()
|
||||||
|
[(_ what)
|
||||||
|
(with-syntax ([id (format-id stx "manifest-~a" #'what)]
|
||||||
|
[idsym #''what])
|
||||||
|
#'(when (false? (id mf))
|
||||||
|
(error "manifest attribute missing:" idsym)))]))
|
||||||
|
|
||||||
|
(define mf
|
||||||
|
(for/fold ([mf (manifest #f 'stdin #f builtin-charsets #f)])
|
||||||
|
([line (in-list manifest-def)])
|
||||||
|
(match line
|
||||||
|
[(list (? (eq/m 'name)) name) (struct-copy manifest mf [name name])]
|
||||||
|
[(list (? (eq/m 'mode)) mode) (struct-copy manifest mf [mode mode])]
|
||||||
|
[(list (? (eq/m 'command)) command) (struct-copy manifest mf [command command])]
|
||||||
|
[(list (? (eq/m 'charset)) name val)
|
||||||
|
(struct-copy manifest mf
|
||||||
|
[charsets (hash-set (manifest-charsets mf)
|
||||||
|
(symbol->string name) (string->charset val))])]
|
||||||
|
[(list (? (eq/m 'pattern)) pattern) (struct-copy manifest mf [pattern pattern])])))
|
||||||
|
|
||||||
|
(check-false name)
|
||||||
|
(check-false command)
|
||||||
|
(check-false pattern)
|
||||||
|
|
||||||
|
(define charsets (manifest-charsets mf))
|
||||||
|
(define pattern
|
||||||
|
(for/vector ([x (in-list (regexp-match* #rx"\\??." (manifest-pattern mf)))])
|
||||||
|
(if (= 1 (string-length x))
|
||||||
|
(list (char->integer (string-ref x 0)))
|
||||||
|
(set->list (hash-ref charsets x (lambda () (error "no such charset defined" x)))))))
|
||||||
|
(values (manifest-name mf) (manifest-mode mf) (manifest-command mf) pattern))
|
||||||
|
|
||||||
|
|
||||||
|
;; pattern processing
|
||||||
|
|
||||||
|
(define (pattern-count pattern)
|
||||||
|
(for/fold ([sum 1]) ([p (in-vector pattern)])
|
||||||
|
(* sum (set-count p))))
|
||||||
|
|
||||||
|
;; design recipe violations follow
|
||||||
|
;; (sorry)
|
||||||
|
;; (i wanted this to be fast so i try to avoid spamming the heap)
|
||||||
|
(define (pattern-generate pattern out-port)
|
||||||
|
(define len (vector-length pattern))
|
||||||
|
(define gen (make-bytes len))
|
||||||
|
(define (output gen)
|
||||||
|
(write-bytes gen out-port)
|
||||||
|
(printf "\n"))
|
||||||
|
(define (permute i gen)
|
||||||
|
(cond [(= i len) (output gen)]
|
||||||
|
[else
|
||||||
|
(for ([chr (in-set (vector-ref pattern i))])
|
||||||
|
(bytes-set! gen i chr)
|
||||||
|
(permute (add1 i) gen))]))
|
||||||
|
(permute 0 gen))
|
||||||
|
|
||||||
|
(define-values [name mode command pattern]
|
||||||
|
(parse-manifest
|
||||||
|
'((name "test")
|
||||||
|
(mode stdin)
|
||||||
|
(command ("meme"))
|
||||||
|
(pattern "test?dx?d"))))
|
||||||
|
|
||||||
|
(displayln (pattern-count pattern))
|
||||||
|
(pattern-generate pattern (current-output-port))
|
|
@ -0,0 +1,10 @@
|
||||||
|
#lang scribble/manual
|
||||||
|
@require[@for-label[crossfire
|
||||||
|
racket/base]]
|
||||||
|
|
||||||
|
@title{crossfire}
|
||||||
|
@author{haskal}
|
||||||
|
|
||||||
|
@defmodule[crossfire]
|
||||||
|
|
||||||
|
Package Description Here
|
Loading…
Reference in New Issue