Skip to content

Instantly share code, notes, and snippets.

View dkvasnicka's full-sized avatar

Daniel Kvasnička dkvasnicka

View GitHub Profile
@katox
katox / smt.clj
Created September 28, 2019 18:34
From elegance to speed (Clojure version)
;;
;; http://johnj.com/from-elegance-to-speed.html
;;
;; The Clojure version
;; -------------------
(ns smt
(:require [net.cgrand.xforms :as x]
[criterium.core :as c :refer [quick-bench]]))
@oseme-techguy
oseme-techguy / Correct_GnuPG_Permission.sh
Last active December 12, 2024 04:42
This fixes the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error while using Gnupg .
#!/usr/bin/env bash
# To fix the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error
# Make sure that the .gnupg directory and its contents is accessibile by your user.
chown -R $(whoami) ~/.gnupg/
# Also correct the permissions and access rights on the directory
chmod 600 ~/.gnupg/*
chmod 700 ~/.gnupg
@ataggart
ataggart / left-join.clj
Last active April 12, 2022 20:15
left-join analog of clojure.set/join
(defn left-join
"When passed 2 rels, returns the rel corresponding to the natural
left-join. When passed an additional keymap, joins on the corresponding
keys."
([xrel yrel]
(if (and (seq xrel) (seq yrel))
(let [ks (intersection (set (keys (first xrel)))
(set (keys (first yrel))))
idx (index yrel ks)]
(reduce (fn [ret x]
@gschmutz
gschmutz / docker-compose.yml
Last active November 12, 2024 19:44
Docker Compose with Kafka Single Broker, Connect, Schema-Registry, REST Proxy, Kafka Manager
version: '2'
services:
zookeeper:
image: confluentinc/cp-zookeeper:3.3.0
hostname: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
@vtajzich
vtajzich / gist:a38fe74230b12cd366b0
Last active August 29, 2015 14:24
How to download a movies form regiojet train server :-)
class Movie {
String name
URL url
}
def downloads = new File('downloads')
downloads.mkdirs()
"http://portal.regiojet.cz/files/movies/".toURL().text.findAll(~/(?<=href=")([\S^"]*)(?=")/)
.parallelStream()
@yoavniran
yoavniran / ultimate-ut-cheat-sheet.md
Last active December 13, 2024 03:17
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
@tonyg
tonyg / fusion-caselambda.rkt
Created January 24, 2015 22:28
Experiments with fusable streams and transducers in Racket
#lang racket
;; Fusable Streams, after Coutts, Leshchinskiy and Stewart 2007.
;; Haskell:
;; data Stream a where Stream :: (s -> Step s a) -> s -> Stream a
;; data Step s a = Yield a s | Skip s | Done
;; Clojure transducers support:
;; - early termination
;; - completion cleanup
@john2x
john2x / 00_destructuring.md
Last active August 23, 2024 07:45
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@soheilhy
soheilhy / nginxproxy.md
Last active November 27, 2024 08:14
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@kballenegger
kballenegger / react.js.wisp
Last active December 6, 2016 12:41
ReactJS macro in wisp
; note: this iteration doesn't work properly.
; looks like i don't understand exactly how react.js works for settings dom element properties
(set! exports {})
; react macros...
(defmacro hash-map-pairs
"make a hash map from its arguments. each argument is a tuple (key value)"