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
| #:sdk Microsoft.NET.Sdk.Web | |
| #:property TargetFramework=net10.0 | |
| #:package MQTTnet.AspNetCore@5.2.0.1603 | |
| using MQTTnet.AspNetCore; | |
| var builder = WebApplication.CreateBuilder(args); | |
| builder.WebHost.UseKestrel(options => | |
| { | |
| options.ListenAnyIP(1883, listen => listen.UseMqtt()); // plain MQTT over TCP | |
| options.ListenAnyIP(8080); // HTTP, serves the websocket endpoint |
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
| #:sdk Microsoft.NET.Sdk.Web | |
| #:property TargetFramework=net10.0 | |
| #:package DotNext.AspNetCore.Cluster@6.14.0 | |
| using DotNext.Net.Cluster.Consensus.Raft; | |
| using DotNext.Net.Cluster.Consensus.Raft.Http; | |
| using Microsoft.AspNetCore.Connections; | |
| var ports = new[] { 8081, 8082, 8083 }; | |
| var hostTasks = new List<Task>(); |
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
| ;; Fast cardinality of C# BitArray from Clojure because for some reason BitArray lacks this (see java.util.BitSet) | |
| (import '[System.Collections BitArray] '[System.Reflection BindingFlags FieldInfo]) | |
| (def field-info (-> BitArray (.GetField "m_array" (enum-or BindingFlags/NonPublic BindingFlags/Instance)))) | |
| (defn get-cardinality | |
| [^BitArray ba] | |
| (let [array (.GetValue ^FieldInfo field ba) | |
| n (count array)] |
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
| (require '[clojure.zip :as zip]) | |
| (defn breadth-first-search [z] | |
| (letfn [(zip-children [loc] | |
| (when-let [first-child (zip/down loc)] | |
| (take-while (comp not nil?) | |
| (iterate zip/right first-child))))] | |
| (loop [ret [] | |
| queue (conj clojure.lang.PersistentQueue/EMPTY z)] | |
| (if (seq queue) |
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
| # apache-tvm==0.14.dev273 | |
| # numpy==1.26.4 | |
| # pytest==8.3.5 | |
| from __future__ import absolute_import, print_function | |
| import tvm | |
| import tvm.testing | |
| from tvm import te | |
| import numpy as np |
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
| using java.net; // yes this is weird, it is IKVM magic | |
| var homeDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | |
| var workDir = Environment.CurrentDirectory; | |
| var urls = new URL[] { | |
| new URL($"file:{homeDir}/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar"), | |
| new URL($"file:{homeDir}/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar"), | |
| new URL($"file:{homeDir}/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar"), | |
| }; |
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
| using java.net; // yes this is weird, it is IKVM magic | |
| var homeDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | |
| var workDir = Environment.CurrentDirectory; | |
| var urls = new URL[] { | |
| new URL($"file:{homeDir}/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar"), | |
| new URL($"file:{homeDir}/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar"), | |
| new URL($"file:{homeDir}/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar"), |
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
| ;; Using proj from ClojureCLR on .NET 8 for fun and profit (at your own risk, no implied warranty etc) | |
| ;; | |
| ;; Inspired by https://ericsink.com/entries/native_library.html | |
| ;; Tested on Ubuntu 22.04 with libproj-dev 8.2.1 | |
| ; | |
| ;<Project Sdk="Microsoft.NET.Sdk"> | |
| ; <PropertyGroup> | |
| ; <OutputType>Exe</OutputType> | |
| ; <TargetFramework>net8.0</TargetFramework> | |
| ; <ImplicitUsings>enable</ImplicitUsings> |
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
| ;; <PackageReference Include="AwsSignatureVersion4" Version="4.0.1" /> | |
| (ns get_from_s3 | |
| (:import [Amazon.Runtime EnvironmentVariablesAWSCredentials SessionAWSCredentials] | |
| [System.Net.Http HttpClient GetAsyncExtensions HttpCompletionOption] | |
| [System Uri]) | |
| ;(:use clojure.pprint clojure.repl clojure.reflect) | |
| (:require [clojure.clr.io :as io])) | |
| ;(assembly-load "AWSSDK.Core") | |
| ;(assembly-load "AwsSignatureVersion4") |
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
| ;; clj -Sdeps '{:deps {org.clojure/data.csv {:mvn/version "1.1.0"} org.clojure/data.json {:mvn/version "2.5.0"}}}' --main gzipper | |
| (ns gzipper | |
| (:require [clojure.java.io :as io] | |
| [clojure.walk :as walk] | |
| [clojure.string :as string] | |
| [clojure.data.json :as json] | |
| [clojure.data.csv :as csv]) | |
| (:import [java.net InetSocketAddress HttpURLConnection] | |
| [java.util.zip GZIPOutputStream] |
NewerOlder