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
(ns protohackers.challenge2-gloss | |
(:require | |
[aleph.tcp :as tcp] | |
[clojure.core.match :refer [match]] | |
[clojure.data.json :as json] | |
[clojure.math :as math] | |
[gloss.core :as gloss] | |
[gloss.io :as io] | |
[manifold.stream :as s])) |
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
(defpackage :challenge4 | |
(:use cl usocket) | |
(:export main) | |
(:import-from flexi-streams | |
:string-to-octets | |
:octets-to-string) | |
(:import-from serapeum | |
:fmt | |
:@ | |
:dict)) |
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
(defpackage :challenge5 | |
(:use cl usocket)) | |
(in-package :challenge5) | |
(defun replace-address (line) | |
(let ((address-matcher (ppcre:create-scanner | |
"# preceded by space or beginning of line | |
(\\s|^) | |
# address is 7 followed by 25-34 alphanumeric characters | |
7\\w{25,34} |
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
(use-package 'sb-bsd-sockets) | |
(defparameter *socket* | |
(make-instance 'inet-socket :type :stream :protocol :tcp)) | |
(socket-connect *socket* #(127 0 0 1) 1234) | |
(sb-thread:make-thread | |
(lambda () | |
(loop for buffer = (socket-receive *socket* nil 1) | |
for c = (elt buffer 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
(defpackage :challenge5 | |
(:use cl usocket)) | |
(in-package :challenge5) | |
(defun replace-address (line) | |
(let ((address-matcher (ppcre:create-scanner | |
"# preceded by space or beginning of line | |
(\\s|^) | |
# address is 7 followed by 25-34 alphanumeric characters | |
7\\w{25,34} |
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
(defpackage logged-stream | |
(:use cl trivial-gray-streams) | |
(:import-from flexi-streams make-in-memory-output-stream get-output-stream-sequence) | |
(:export make-logged-stream get-input get-ouput)) | |
(in-package logged-stream) | |
(defclass logged-stream (fundamental-binary-output-stream fundamental-binary-input-stream) | |
((stream :initarg :stream :accessor base-stream) | |
(input :initform (make-in-memory-output-stream) :accessor logged-input) | |
(output :initform (make-in-memory-output-stream) :accessor logged-output))) |
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
;;; langs/sly-threads.el -*- lexical-binding: t; -*- | |
(defun sly--fix-sexp-whitespace (&optional move-out) | |
"Fix whitespace after unwinding a threading form. | |
Optional argument MOVE-OUT, if non-nil, means moves up a list | |
before fixing whitespace." | |
(save-excursion | |
(when move-out (backward-up-list)) | |
(let ((sexp (bounds-of-thing-at-point 'sexp))) |
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
(in-package :ciel-user) | |
(use-package '(local-time periods)) | |
(import 'periods::do-times) | |
(defconstant +last-date-file+ "~/.irc-log-reader-last") | |
(defun fmt-date (date) | |
(format-timestring nil date :format +rfc3339-format/date-only+)) | |
(do-times (day (-> +last-date-file+ str:from-file str:trim parse-timestring) |