Skip to content

Instantly share code, notes, and snippets.

Avatar
💓
Loving Clojure

Jakub Holy holyjak

💓
Loving Clojure
View GitHub Profile
@caskolkm
caskolkm / logging.cljc
Last active Mar 14, 2019
Simple Clojurescript logging using Google Closure logging tools, now in cljc :)
View logging.cljc
(ns app.logging
(:refer-clojure :exclude [time])
(:require #?(:clj [clojure.tools.logging :as log]
:cljs [goog.log :as glog]))
#?(:cljs (:import goog.debug.Console)))
#?(:cljs
(def logger
(glog/getLogger "app")))
@tuxfight3r
tuxfight3r / socat-forward-tcp.sh
Created Apr 18, 2019 — forked from drmalex07/socat-forward-tcp4-to-tcp6.sh
Tunnel TCP traffic via socat. #socat
View socat-forward-tcp.sh
#!/bin/bash
PUBLIC_IP4_IFACE=eth2
LISTEN_IFACE=${PUBLIC_IP4_IFACE}
listen_address=$(ip -f inet addr show dev ${LISTEN_IFACE} | grep -Po 'inet \K[\d.]+')
listen_port=${1}
target_host=${2}
target_port=${3}
View defwrapper.clj
(ns defwrapper
(:require [clojure.string :as str]))
(set! *warn-on-reflection* true)
(defn class-methods [^Class class]
(seq (.getMethods class)))
(defn constructors [^Class klazz]
(.getDeclaredConstructors klazz))
@sunng87
sunng87 / reflection.clj
Created Nov 20, 2015
clojure: access private field/method via reflection
View reflection.clj
(defn invoke-private-method [obj fn-name-string & args]
(let [m (first (filter (fn [x] (.. x getName (equals fn-name-string)))
(.. obj getClass getDeclaredMethods)))]
(. m (setAccessible true))
(. m (invoke obj args))))
(defn private-field [obj fn-name-string]
(let [m (.. obj getClass (getDeclaredField fn-name-string))]
(. m (setAccessible true))
(. m (get obj))))
@ericnormand
ericnormand / 00_script.clj
Last active Dec 29, 2020
Boilerplate for running Clojure as a shebang script
View 00_script.clj
#!/bin/sh
#_(
#_DEPS is same format as deps.edn. Multiline is okay.
DEPS='
{:deps {clj-time {:mvn/version "0.14.2"}}}
'
#_You can put other options here
OPTS='
@vvvvalvalval
vvvvalvalval / datomic-erasing-data-migration.clj
Created Apr 25, 2018
Erasing data from Datomic via a manual data migration
View datomic-erasing-data-migration.clj
;; # EMULATING DATOMIC EXCISION VIA MANUAL DATA MIGRATION
;; *************************************
;; ## Introduction
;; *************************************
;; This Gist demonstrates a generic way to migrate an entire Datomic database
;; from an existing 'Origin Connection' to a clean 'Destination Connection',
;; while getting rid of some undesirable data and otherwise preserving history.
@jasongilman
jasongilman / atom_clojure_setup.md
Last active Jan 17, 2021
This describes how I setup Atom for Clojure Development.
View atom_clojure_setup.md

Atom Clojure Setup

This describes how I setup Atom for an ideal Clojure development workflow. This fixes indentation on newlines, handles parentheses, etc. The keybinding settings for enter (in keymap.cson) are important to get proper newlines with indentation at the right level. There are other helpers in init.coffee and keymap.cson that are useful for cutting, copying, pasting, deleting, and indenting Lisp expressions.

Install Atom

Download Atom

The Atom documentation is excellent. It's highly worth reading the flight manual.

@teasherm
teasherm / s3_multipart_upload.py
Last active Feb 18, 2021
boto3 S3 Multipart Upload
View s3_multipart_upload.py
import argparse
import os
import boto3
class S3MultipartUpload(object):
# AWS throws EntityTooSmall error for parts smaller than 5 MB
PART_MINIMUM = int(5e6)