- [X] task 1
- [X] task 2
- [ ] task 3
This file contains 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
function sitegen | |
cd /home/public | |
rm *.html | |
cd /home/public/posts | |
set posts (ls) | |
ser webdir /home/public | |
set header $webdir/conf/header.html | |
set footer $webdir/conf/footer.html | |
for post in $posts | |
if test (echo $post | sed "s/.*\.//") = md |
This file contains 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
pattern = """ | |
\b # new word boundary | |
NCC # Match NCC | |
( ?-? ?) # Match '-' | |
([0-9][0-9]+) # Match registry number | |
( ?-? ?) # Match optional '-' | |
([A-Z]?) # Match optional suffix | |
\b # end word boundary | |
""" |
This file contains 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
#lang racket | |
(provide | |
(contract-out | |
[make-coinage (-> (listof positive-integer?) list?)])) | |
(define (positive-integer? x) | |
(and (positive? x) | |
(integer? x))) |
This file contains 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
require("clicks-in-new-buffer.js"); | |
require("page-modes/google-search-results.js"); | |
require("page-modes/wikipedia.js"); | |
require("session.js"); | |
require("block-content-focus-change.js"); | |
require("favicon"); | |
require("content-policy.js"); | |
require("index-webjump.js"); | |
xkcd_add_title = true; |
This file contains 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
#' Clever chunking algorithm into roughly equal parts | |
#' http://stackoverflow.com/questions/2130016/splitting-a-list-of-arbitrary-size-into-only-roughly-n-equal-parts | |
chunk <- function(x, k) { | |
n <- length(x) | |
q <- n %/% k | |
r <- n %% k | |
lapply(seq.int(1, k), function(i) { | |
x[seq(from = (i - 1)*q + min(i - 1, r) + 1, to = i * q + min(i, r))] | |
}) | |
} |
This file contains 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
#' My function for doing cross validation (creating the splits before hand) | |
xvalidate <- function(f, formula, data, bin, ...) { | |
fold <- length(bin) | |
xs <- seq.int(1, fold) | |
lapply(xs, function(x) { | |
train <- data[unlist(bin[-x]),] | |
test <- data[bin[[x]],] | |
model <- f(formula, data = train, ...) |
This file contains 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
on_circle_iter <- function(theta) { | |
if(theta < 2*pi) theta else on_circle(theta - 2*pi) | |
} | |
on_circle <- function(theta) Vectorize(on_circle_iter, SIMPLIFY = FALSE) | |
all(on_circle(pi*seq(0, 8, by = 2) == 0) |
This file contains 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
# all.equal does a lot, nearly_equal does little. | |
nearly_equal <- function(x, y, tol = sqrt(.Machine$double.eps)) y < x + tol & y > x - tol | |
# syntax can be confusing to beginners | |
which_is <- function(x, test) x[which(test)] | |
x <- seq(0, 2*pi, by = 0.01) | |
library(magrittr) | |
x %>% which_is(nearly_equal(sin(x), 0.5, tol = 0.005)) |
This file contains 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
#!/usr/bin/env racket | |
#lang racket/base | |
(require racket/vector) | |
;; Capture the command line args sent to this script | |
(define args | |
(current-command-line-arguments)) | |
OlderNewer