Skip to content

Instantly share code, notes, and snippets.

🦄

Enzzo souenzzo

🦄
Block or report user

Report or block souenzzo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@borkdude
borkdude / http-socket-server.clj
Last active Jan 6, 2020 — forked from souenzzo/http-socket-server.clj
tiny http server via java sockets in babashka
View http-socket-server.clj
#!/usr/bin/env bb
(import (java.net ServerSocket))
(require '[clojure.string :as string] '[clojure.java.io :as io])
(with-open [server-socket (new ServerSocket 8080)
client-socket (.accept server-socket)]
(loop []
(let [out (io/writer (.getOutputStream client-socket))
in (io/reader (.getInputStream client-socket))
@borkdude
borkdude / js_parser.clj
Last active Sep 7, 2019
Parse JavaScript in Clojure using the Google Closure Compiler
View js_parser.clj
#!/bin/sh
#_(
"exec" "clojure" "-Sdeps" "{:deps {org.clojure/clojurescript {:mvn/version \"1.10.520\"}}}" "$0" "$@"
)
;; running js_parser.clj "function foo(x) { var y = x + 1; }" will print:
;; [{:type :function, :name "foo", :body [{:variable-statement [{:lvalue "y", :initializer {:type :binary-op, :left "x", :operator "+", :right "1"}}]}], :params ["x"]}]
View error
Error building classpath. Failed to read artifact descriptor for com.datomic:ion:jar:0.9.28
org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for com.datomic:ion:jar:0.9.28
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:276)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:192)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:253)
at clojure.tools.deps.alpha.extensions.maven$eval685$fn__687.invoke(maven.clj:82)
at clojure.lang.MultiFn.invoke(MultiFn.java:243)
at clojure.tools.deps.alpha$expand_deps.invokeStatic(alpha.clj:183)
at clojure.tools.deps.alpha$expand_deps.invoke(alpha.clj:165)
at clojure.tools.deps.alpha$resolve_deps.invokeStatic(alpha.clj:228)
@kennyjwilli
kennyjwilli / README.md
Last active Nov 9, 2018
Delete leftover Datomic resources
View README.md

Delete Leftover Datomic Cloud Resources

If you delete a Datomic Cloud system, it will leave some resources in AWS. To entirely delete all resources created by Datomic Cloud, you must follow these steps. Because we love automation, this script performs all these steps for you so you don't need to navigate the AWS Console UI.

Prerequisites

@gfredericks
gfredericks / frobnicate.clj
Last active Mar 1, 2019
Self-contained clojure file with deps
View frobnicate.clj
#!/usr/bin/env bash
#! top-of-file comments can be written using more #! lines, which
#! is a valid comment in both clojure and bash
":";# alternately this works too
#! The construction below uses cross-language syntactic hackery to
#! specify the -Sdeps arg in a part of the file that's interpreted
#! by clojure as clojure syntax (i.e., not a line comment), so it
@mfikes
mfikes / graal-cc.md
Last active Mar 6, 2019
Testing perf of GraalVM version of Google Closure Compiler for ClojureScript cljs.core
View graal-cc.md
git clone https://github.com/clojure/clojurescript
cd clojurescript
script/bootstrap
script/test

Ctrl-C when it logs

Applying optimizations :advanced to 344 sources
@mhuebert
mhuebert / Readme.md
Last active Feb 5, 2020
material-ui's CSS-in-JS with Reagent. (see https://material-ui.com/customization/css-in-js/)
View Readme.md

material-ui allows for customizing CSS via a higher-order component called withStyles. Like many higher-order components which expect render props, the purpose of withStyles is to accept some parameters, and then introduce a new variable into the scope of the component tree.

One succinct and simple way to translate the concept of scope into Clojure is via a custom let macro. Usage of such a macro is demonstrated here:

(:require [material-ui.styles :as m])

(m/let [{:keys [leftPad]} {:leftPad 
                           {:paddingLeft 8}}]
  ;; `leftPad` is now the _className_ associated with {:paddingLeft 8}                             
@athos
athos / deps.edn
Last active Dec 26, 2019
Try `clojure -Sdeps '{:deps {hello-clojure {:git/url "https://gist.github.com/athos/b68b15b08efedffaf14d8c020b125202" :sha "1c9a05106171f97f9b8e8ac8f58c7bd8dbe021f9"}}}' -m hello-clojure` on your terminal
View deps.edn
{:paths ["."]
:deps {clansi {:mvn/version "1.0.0"}}}
@iperdomo
iperdomo / maps.cljs
Last active Jan 11, 2018
Google Maps delete vertex sample in ClojureScript
View maps.cljs
;; https://developers.google.com/maps/documentation/javascript/examples/delete-vertex-menu
;; New implementaion based on comments by Andre Rauh (@rauh) in #clojurescript on clojurians.slack.com
;;
(defn delete-vertex-menu
[label]
(this-as this
@gdeer81
gdeer81 / spec-coercion.clj
Last active Jan 23, 2017 — forked from Deraen/spec-coercion.clj
Clojure.spec coercion test
View spec-coercion.clj
(ns spec-test.core
(:require [clojure.spec :as s]))
(defn x-integer? [x]
(if (integer? x)
x
(if (string? x)
(try
(Integer/parseInt x)
(catch Exception e
You can’t perform that action at this time.