Skip to content

Instantly share code, notes, and snippets.

Avatar

Keith Irwin zentrope

View GitHub Profile
@zentrope
zentrope / register.rkt
Created Nov 26, 2020
Incomplete token registry service in Racket Lang
View register.rkt
#lang racket
(require db)
(require web-server/servlet)
(require web-server/servlet-env)
(require web-server/managers/none)
(define auth-token "3d99fd86-f62b-4583-a14c-e1151b093569")
(define db-name "register.sqlite")
View post.ss
(def (do-post)
(http-post "http://localhost:9515/session"
headers: '(("Content-Type" . "application/json; charset=utf-8")
("Accept-Encoding" . "identity")
("Accept" . "*/*"))
data: (json-object->string capabilities)))
(def (get-session)
(let (req (do-post))
(for-each (lambda (h) (printf "~s~%" h)) (request-headers req))
View gambit-static-link.sh
View resolve.scm
(define (http:resolve url)
(define resolved-url
(make-parameter (uri-reference url)))
(define (update-resolved-url r)
(resolved-url (request-uri r))
(default-prepare-request r))
(parameterize ((prepare-request update-resolved-url))
View resolve.scm
(define (http:resolve url)
(max-redirect-depth 0)
(let* ((uri (uri-reference url))
(request (make-request uri: uri headers: basic-headers)))
(display "calling\n")
(handle-exceptions exn
(lambda (exn)
View drafts-to-oo.js
let blurb = { "text": "", "date": "", "link": "", "title": "" }
const isValidDate = (d) => d instanceof Date && !isNaN(d)
draft.content.split("\n").forEach((text) => {
const line = text.trim()
if (line.startsWith("text:")) {
blurb.text = line.replace("text:", "").trim()
if (blurb.text.trim() == "") {
View splitview-grabber.swift
override func splitView(_ splitView: NSSplitView, additionalEffectiveRectOfDividerAt dividerIndex: Int) -> NSRect {
super.splitView(splitView, additionalEffectiveRectOfDividerAt: dividerIndex)
assert(splitViewItems.count == 2)
if splitViewItems.count != 2 { return .zero }
if !splitViewItems[1].isCollapsed { return .zero }
return NSMakeRect(splitView.bounds.maxX-6, 0, 6, splitView.bounds.height)
}
View format.swift
private func handleMessage(_ message: IRC.Message) {
if let storage = chatTextView.textStorage,
let render = format(message) {
storage.append(render)
//storage.insert(render, at: storage.length)
}
chatTextView.scrollToEndOfDocument(self)
}
private let chatFont = NSFont.systemFont(ofSize: 14)
View activity3.swift
import Cocoa
class ActivityManager {
var activityUpdate: NSBackgroundActivityScheduler?
var serialize = DispatchQueue(label: "sync", qos: .background)
func backgroundActivitiesSetup() {
print("Setting up activity runner.")
activityUpdate = NSBackgroundActivityScheduler(identifier: "")
View activity2.swift
var activityUpdate: NSBackgroundActivityScheduler?
func backgroundActivitiesSetup() {
activityUpdate = NSBackgroundActivityScheduler(identifier: "")
activityUpdate?.interval = 1 * 60 // every 1 minute
activityUpdate?.repeats = true
activityUpdate?.schedule { completion in
updateNewItems(completion)
}
}
You can’t perform that action at this time.