Skip to content

Instantly share code, notes, and snippets.

@nikialeksey
nikialeksey / WtfCreator.java
Last active December 14, 2022 07:05
Joshua Bloch Wtf.java break-in
import org.apache.commons.math3.analysis.interpolation.NevilleInterpolator;
public class WtfCreator {
public static void main(String[] args) {
var text = "Hello, world!\n";
double[] x = new double[text.length() + 1];
double[] y = new double[text.length() + 1];
for(var i = 0; i < text.length(); i++) {
x[i] = i;
@roman01la
roman01la / clojurescript-repl-workflow.md
Last active October 22, 2022 12:07
ClojureScript REPL Workflow

ClojureScript REPL Workflow

Short write up on using REPL when developing UIs in ClojureScript.

Hot-reload on save or Eval in REPL?

Everyone's standard approach to hot-reloading is to use a tool (Figwheel or shadow-cljs) that reloads changed namespaces automatically. This works really well: you change the code, the tool picks up changed files, compiles namespaces and dependants, notifies REPL client which then pulls in compiled changes, and re-runs a function that re-renders UI.

The other approach is to use ClojureScript's REPL directly and rely only on eval from the editor. This more or less matches Clojure style workflow. This approach might be useful when you don't want tools overhead or hot-reloading becomes slow for you or you just used to this style of interactions. Also changing code doesn't always mean that you want to reload all the changes. On the other hand it is very easy to change a couple of top-level forms and forget to eval one of them.

Getting Started with Clojure on Windows

Clojure is an amazingly powerful language. Using it (and watching Rich Hickey videos) has changed the way I think about programming, and the way I code in general. Once I learned the basics of the language, which was a relatively quick process, I fell in love and couldn't look back. I hope this post can help others who are new to Clojure get up and running quickly and painlessly.

This post is opinionated in the sense that I'll suggest certain tools to help those who are new to this scene get on their feet. The things you'll need are:

  • Leiningen (pronounced LINE-ing-en) - This is like a package manager, build tool, task manager, and more in one tool. Think npm or nuget, but with more capabilities. There is at least one other build tool for Clojure (boot), but Leiningen is the most widely used.
  • JDK - Clojure runs on Java. Throw out any qualms you may have about Java, we aren't coding in Java (though we can through Clojure, and sometimes tha
@mfikes
mfikes / README.md
Last active February 24, 2024 13:43
Playing with BigInt in ClojureScript

Usage

Fire up a REPL using any of the following forms.

Node

clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:git/url "https://github.com/mfikes/clojurescript" :sha "ed1e7373a9ecd8b52084dc438e6c21d23dba47ca"}}}' -m cljs.main -re node
@bhb
bhb / blockchain-w-spec.md
Last active July 1, 2022 11:24
Building a blockchain, assisted by Clojure spec

Building a blockchain, assisted by Clojure spec

In an effort to gain at least a superficial understanding of the technical implementation of cryptocurrencies, I recently worked my way through "Learn Blockchains by Building One" using Clojure.

This was a good chance to experiment with using spec in new ways. At work, we primarily use spec to validate our global re-frame state and to validate data at system boundaries. For this project, I experimented with using instrumentation much more pervasively than I had done elsewhere.

This is not a guide to spec (there are already many excellent resources for this). Rather, it's an experience report exploring what went well, what is still missing, and quite a few unanswered questions for future research. If you have solutions for any of the problems I've presented, please let me know!

You don't need to know or care about blockchains to understand the code be

The project can be built using Lumo

npm install -g lumo-cljs
lumo build.cljs
@ohpauleez
ohpauleez / service.clj
Last active August 29, 2015 14:03
Pedestal 0.3.0 example with SSE
;; In Pedestal 0.3.1, you won't have to use an atom.
;; You'll pass the channel into the SSE creation function (instead of it passing one back to you)
(def event-ch (atom nil))
(defn home-page
[request]
(ring-resp/response "Hello World!"))
(defroutes routes
[[["/" {:get home-page}
@philandstuff
philandstuff / euroclojure2014.org
Last active February 19, 2024 05:12
Euroclojure 2014

EuroClojure 2014, Krakow

Fergal Byrne, Clortex: Machine Intelligence based on Jeff Hawkins’ HTM Theory

  • @fergbyrne
  • HTM = Hierarchical Temporal Memory
  • Slides

big data

  • big data is like teenage sex
    • noone knows how to do it
    • everyone thinks everyone else is doing it
@allgress
allgress / reagent_datascript.cljs
Last active February 16, 2023 21:16
Test use of DataScript for state management of Reagent views.
(ns reagent-test.core
(:require [reagent.core :as reagent :refer [atom]]
[datascript :as d]
[cljs-uuid-utils :as uuid]))
(enable-console-print!)
(defn bind
([conn q]
(bind conn q (atom nil)))