Skip to content

Instantly share code, notes, and snippets.

View niwinz's full-sized avatar

Andrey Antukh niwinz

View GitHub Profile
@niwinz
niwinz / javaslang-and-clojure-bench.clj
Last active April 4, 2016 11:19
Javaslang and Clojure persistent data structures benchmark
#!/usr/bin/env boot
;; BOOT_CLOJURE_NAME=org.clojure/clojure
;; BOOT_CLOJURE_VERSION=1.8.0
;; BOOT_VERSION=2.5.5
;; BOOT_JVM_OPTIONS="-Xms4g -Xmx4g -XX:+UseG1GC -XX:+AggressiveOpts -server"
(set-env! :dependencies '[[criterium "0.4.4"]
[io.javaslang/javaslang "2.0.2"]])
@niwinz
niwinz / README.md
Created March 30, 2016 06:03 — forked from olivergeorge/Nicer Assert README.md
Assert macro patch to show details about failed assertions.

This is an attempt to make assert more friendly by including more details in the assertion error.

  • show the result of the assertion expression
  • show local variable values used in assertion form

In other words, this should make assertion errors easier to reason about:

AssertionError Assert failed: Should be equal
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.logging.Level;
@niwinz
niwinz / strint.clj
Created August 9, 2016 13:22 — forked from cemerick/strint.clj
BSD-licensed string interpolation for clojure
;;; strint.clj -- String interpolation for Clojure
;; originally proposed/published at http://cemerick.com/2009/12/04/string-interpolation-in-clojure/
;; Copyright (c) 2009, 2016 Chas Emerick <[email protected]>
;;
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
@niwinz
niwinz / mapread.c
Created August 12, 2016 09:06 — forked from marcetcheverry/mapread.c
mmap and read/write string to file
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
int main(int argc, const char *argv[])
{
(require '[lentes.core :as l])
;; Lets define a simple lense that compoes:
;; - a lense that focuses to the (get-in [:foo :bar] ...) on the data struct
;; - a lense that just applies the inc transformation
;; This is in some mode analogous to: #(inc (get-in % [:foo :bar]))
;; but generalized as a composable lense.
(def my-lens
(comp (l/in [:foo :bar])
#!/usr/bin/env boot
;; BOOT_CLOJURE_NAME=org.clojure/clojure
;; BOOT_CLOJURE_VERSION=1.8.0
;; BOOT_VERSION=2.5.5
;; BOOT_JVM_OPTIONS="-Xms1g -Xmx1g -XX:+UseG1GC -XX:+AggressiveOpts -server -Dclojure.compiler.direct-linking=true"
(set-env! :repositories #(conj % ["bintray" {:url "http://dl.bintray.com/nitram509/jbrotli"}]))
(set-env! :dependencies '[[criterium "0.4.4"]
@niwinz
niwinz / README.md
Created October 26, 2016 09:10
How to enable SecureBoot with own keys in KVM and on a laptop (T450s)

UEFI SecureBoot on ArchLinux

For KVM and Laptop

Rationale

I want full control what boots the computer to avoid the so called evil maid attack. That requires setting SecureBoot with only my own keys.

Intro

@niwinz
niwinz / core.clj
Created November 25, 2016 11:02 — forked from mikeball/core.clj
Postgres listen/notify in Clojure using http://impossibl.github.io/pgjdbc-ng/
; Postgres listen/notify in Clojure using http://impossibl.github.io/pgjdbc-ng/
; in project.clj dependencies
; [com.impossibl.pgjdbc-ng/pgjdbc-ng "0.5"]
(ns pglisten.core
(:import [com.impossibl.postgres.jdbc PGDataSource]
[com.impossibl.postgres.api.jdbc PGNotificationListener]))
@niwinz
niwinz / leaflet.cljs
Created January 9, 2017 08:37 — forked from attentive/leaflet.cljs
Adapting React components in Rum
(ns project.leaflet
(:require-macros [project.macros :as m])
(:require [rum.core :as rum]
cljsjs.react-leaflet)) ;; js/ReactLeaflet
(m/adapt-react leaflet-map js/ReactLeaflet.Map)
(m/adapt-react tile-layer js/ReactLeaflet.TileLayer)
(m/adapt-react marker js/ReactLeaflet.Marker)
(m/adapt-react popup js/ReactLeaflet.Popup)