Vor einiger Zeit haben ich den HuCon-Roboter-Bausatz erhalten. Der HuCon wird mit Blockly und Python programmiert. Ich programmiere schon lange auf PCs (vor allem Java und Clojure), aber mit Microcontrollern habe ich nur wenig Erfahrung. Als erstes habe ich mich mit der Installation von OpenWrt
This file contains hidden or 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
| ;;=============== play with flow ============== | |
| (require '[clojure.core.async :as async] | |
| '[clojure.core.async.flow :as flow] | |
| '[clojure.pprint :as pp] | |
| '[clojure.datafy :as d]) | |
| (set! *warn-on-reflection* true) | |
| (defn monitoring [{:keys [report-chan error-chan]}] | |
| (prn "========= monitoring start") |
This file contains hidden or 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
| // bookmarklet: | |
| // javascript:(function()%7Bconst%20blob%3Dnew%20Blob(%5BJSON.stringify(localStorage)%5D%2C%7Btype%3A'application%2Fjson'%7D)%3Bconst%20link%3Ddocument.createElement('a')%3Bconst%20url%3DURL.createObjectURL(blob)%3Blink.href%3Durl%3Blink.download%3D'local_storage.json'%3Blink.style.display%3D'none'%3Bdocument.body.appendChild(link)%3Blink.click()%3BsetTimeout(()%3D%3E%7BURL.revokeObjectURL(url)%3Bdocument.body.removeChild(link)%3B%7D%2C250)%3B%7D)()%3B | |
| function exportLocalStorage(){ | |
| const blob = new Blob([JSON.stringify(localStorage)],{type:'application/json'}); | |
| const link = document.createElement('a'); | |
| const url = URL.createObjectURL(blob); | |
| link.href = url; | |
| link.download = 'local_storage.json'; | |
| link.style.display='none'; | |
| document.body.appendChild(link); |
This file contains hidden or 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
| bin dann auch erstmal wech ... | |
| gibt hier wieder einen, der ein ungutes gefühl verbreitet und das muss ich mir nicht antun. | |
| wenn ich auf hassprediger stehen würde, würde ich bsw, afd oder den IS wählen 😁 | |
| abgesehen davon, ist das hier sogut wie abgeschlossen und ich bin nicht hierauf angewiesen 😁 | |
| vllt später nochmal öffnen, falls ich doch mal wieder nen antreib/grund finde ... 😁 | |
| abschließend verweise ich noch auf folgendes: |
This file contains hidden or 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 bb | |
| (ns script | |
| (:require [clojure.java.io :as io] | |
| [clojure.string :as s] | |
| [clojure.pprint :as pprint] | |
| [clojure.java.shell :refer [sh with-sh-dir]] | |
| [cheshire.core :as json])) | |
| (defn prsh | |
| ([sh] |
This file contains hidden or 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 bb | |
| #_" -*- mode: clojure; -*-" | |
| ;; Based on https://github.com/babashka/babashka/blob/master/examples/image_viewer.clj | |
| (ns http-server | |
| (:require [babashka.fs :as fs] | |
| [clojure.java.browse :as browse] | |
| [clojure.string :as str] | |
| [clojure.tools.cli :refer [parse-opts]] | |
| [org.httpkit.server :as server] |
Digit search
This is one of those weird programming puzzles with no real point except practice. But it's considered Very Hard in JavaScript. Let's see how we do in Clojure.
Write a function that takes a sequence of integers. You're trying to get all 10 digits by looking through the numbers sequentially. When you have found one instance of every decimal digit, return whatever number you were on when you found the last one. If you get to the end of the sequence without finding all the digits (for instance, maybe there was no 9), then just return nil.
Example
(digit-search [5175 4538 2926 5057 6401 4376 2280 6137]) ;=> 5057
This file contains hidden or 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
| DROP TABLE IF EXISTS pgbench_generic_log; | |
| CREATE TABLE pgbench_generic_log ( | |
| mtime timestamptz not null default now(), | |
| action char not null check (action in ('I', 'U', 'D')), | |
| username text not null, | |
| table_name text not null, | |
| row_data jsonb not null | |
| ); | |
| CREATE INDEX ON pgbench_generic_log USING brin (mtime); |
I looked into the state of GraalVM and Clojure and wrote some small work-related scripts.
- Downloaded GraalVM and set $GRAALVM_HOME
- Found two main libraries for building GraalVM CLIs - https://github.com/luchiniatwork/cambada#packaging-as-a-native-image and https://github.com/taylorwood/clj.native-image (or https://github.com/taylorwood/lein-native-image for the lein equivalent). I chose clj.native-image as it seemed more focused on doing one thing well.
- First tried its template example which was easy to follow.
- Then added a graalvm build to one of our small cli tools
- Found it to be pretty straightforward except for a stdout flushing issue that was trivial to fix
This file contains hidden or 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
| {:paths ["."] | |
| :deps {time-literals/time-literals {:mvn/version "0.1.5"} | |
| com.cognitect/transit-clj {:mvn/version "0.8.319"} | |
| com.cognitect/transit-cljs {:mvn/version "0.8.256"} | |
| }} |
NewerOlder