Skip to content

Instantly share code, notes, and snippets.

import sys
import random
if __name__ == "__main__":
code = random.choices([1, 2, 3, 4, 5, 6], k=4)
print(f"{code=}")
turns_remaining = 10
# Follow https://techcommunity.microsoft.com/t5/virtualization/sneak-peek-taking-a-spin-with-enhanced-linux-vms/ba-p/382415
# xrdp.service not starting because address already in use: https://github.com/microsoft/linux-vm-tools/issues/94
# Get the scripts from GitHub
sudo apt-get update
sudo apt install git
git clone https://github.com/Microsoft/linux-vm-tools.git ~/linux-vm-tools
cd ~/linux-vm-tools/ubuntu/18.04/
#Make the scripts executable and run them...
func doSomething(foo: SomeFoo?) {
guard let foo = foo else {
return
}
// foo now unwrapped outside of guard scope.
foo.bar
}
(ns mappings.core)
(def alphabet " -=qwertyuiop[]asdfghjkl;'zxcvbnm,./_+QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>?")
(def dvorak
{\space \space, \A \A, \a \a, \" \_, \B \X, \b \x, \C \J, \c \j, \D \E, \d \e, \E \>, \e \., \F \U, \f \u, \' \-, \G \I, \g \i, \H \D, \h \d, \I \C, \i \c, \J \H, \j \h, \+ \}, \K \T, \k \t, \, \w, \L \N, \l \n, \- \[, \M \M, \m \m, \. \v, \N \B, \n \b, \/ \z, \O \R, \o \r, \P \L, \p \l, \Q \", \q \', \R \P, \r \p, \S \O, \s \o, \T \Y, \t \y, \U \G, \u \g, \V \K, \v \k, \W \<, \w \,, \X \Q, \x \q, \Y \F, \y \f, \: \S, \Z \:, \z \;, \; \s, \[ \/, \{ \?, \< \W, \= \], \] \=, \} \+, \> \V, \? \Z, \_ \{})
(def colemak
;; TODO!
)
(defn take-while-plus-one [f [x & rest :as coll]]
(when (seq coll)
(if (f x)
(cons x (take-while-plus-one f rest))
(list x))))
(ns wlhn-nov-13.core)
;; Wilson's algorithm
;; 1) Randomly pick a location and mark it as visted
;; 2) Randomly pick a location not yet visited
;; 3) Perform a random walk starting from the newly picked location until you stumble on a location that is visited—if you pass through a location more than once during the random walk, always remember the direction you take to leave it.
;; 4) Mark all the locations of the random walk as visited, and remove walls according to the last known “exit direction.”
;; 5) Repeat from 2.
(defn merge-index [index [a b]]
@t-ob
t-ob / west.clj
Last active December 19, 2015 15:39
(ns genetic.core)
(def letters
(conj (map (comp char
(partial + 97))
(range 26))
\space))
(defn random-string [source]
(let [length (count source)]
Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at org.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:601)
at org.eclipse.jetty.util.log.JettyAwareLogger.warn(JettyAwareLogger.java:425)
at org.eclipse.jetty.util.log.Slf4jLog.warn(Slf4jLog.java:74)
at org.eclipse.jetty.util.component.AbstractLifeCycle.setFailed(AbstractLifeCycle.java:199)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at ring.adapter.jetty$run_jetty.invoke(jetty.clj:85)
at ring.server.standalone$serve$fn__1557.invoke(standalone.clj:98)
at ring.server.standalone$try_port.invoke(standalone.clj:16)
at ring.server.standalone$serve.doInvoke(standalone.clj:95)
@t-ob
t-ob / gist:4722378
Last active December 12, 2015 05:29
(defn random-bits []
(->> (repeatedly #(rand-int 2))
(take (+ 5 (rand-int 10)))
vec))
(def config
{:base 2
:codon-bits 8
:point-mutation-rate 1
:crossover-rate 0.3
(def tob-feed-ids ["180893462012339" "289169977804676"])
(def tob-interval {:from (parse (formatters :date) "2012-12-10"), :to (now)})
(defn get-attr-count [attr post]
(or (get-in post [attr :count]) 0))
(def tob-query-result
(io/with-fs-tmp [_ tmp]