Skip to content

Instantly share code, notes, and snippets.

View danielcompton's full-sized avatar

Daniel Compton danielcompton

View GitHub Profile
@cgrand
cgrand / core.cljc
Last active October 14, 2020 12:18
Mixing macros and code in cljc and supporting clj, cljs and self-hosted cljs, see https://github.com/cgrand/macrovich
;; SEE: https://github.com/cgrand/macrovich
;; macros and code in a single cljc working across clj, cljs and self-hosted cljs
;; require clojurescript from master
(ns foo.core
#?(:cljs (:require-macros
[net.cgrand.meta-macros :refer [macros no-macros]]
[foo.core :refer [add]])
:clj (:require
@Risto-Stevcev
Risto-Stevcev / spectest.cljs
Last active October 31, 2019 18:53
Some functions to help integrate clojure.spec.test/check with cljs.test/deftest
(ns foo-test
(:require [cljs.spec :as s]
[cljs.spec.test :as stest]
[clojure.pprint :as pprint]
[cljs.test :refer-macros [deftest is]]))
;; Sample function and a function spec
(defn fooo [i] (+ i 20))
(s/fdef fooo
@steipete
steipete / ios-xcode-device-support.sh
Last active December 12, 2023 03:36
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)

Intercom user_hash

Remember that your secret key should never be exposed to the public

  • So Javascript code below should only be used for testing unless modified and used to run on a server
@sunng87
sunng87 / reflection.clj
Created November 20, 2015 10:04
clojure: access private field/method via reflection
(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))))
@igorlukanin
igorlukanin / RethinkDB.kt
Last active October 29, 2015 03:35
Using RethinkDB Java driver with Kotlin
/**
* Database.kt
*/
import com.rethinkdb.RethinkDB
import com.rethinkdb.gen.ast.ReqlExpr
import com.rethinkdb.net.Connection
import com.rethinkdb.net.ConnectionInstance
object Database {
private lateinit var db: String
@inexorabletash
inexorabletash / @ Indexed DB - N-Dimensional Select.md
Last active April 16, 2024 20:38
Indexed DB - N-dimensional selection

Indexed DB - N-Dimensional Selection

The problem

We have an index with keys of the form:

[ dim1, dim2, dim3, ... ]

e.g. created with:

@gja
gja / core.clj
Last active August 15, 2022 16:25
Building a lein uberjar without any compilation
(ns simplequest.core)
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!"))
= P:Cubed Clojure Language Learning Resources =
(Taken from P-Cubed internal wiki. Public site = www.p-cubed.co.za)
Clojure is a dynamic programming language that targets the Java Virtual Machine (and the CLR, and JavaScript).
It is designed to be a general-purpose language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming.
It also focusses a lot on handling concurrency elegantly.
Taster of the language: http://www.tryclj.com/
While it's dynamically typed by default, it can be optionally statically typed using core.typed.
@Deraen
Deraen / edn.cljx
Last active August 6, 2023 06:51
Transit / edn date/datetime serialisers
(ns metosin.common.edn
#+clj
(:require [clj-time.format :as f])
#+cljs
(:require [cljs-time.format :as f]
cljs.reader)
#+clj (:import [org.joda.time DateTime LocalDate]))
;;
;; #DateTime tagging