Skip to content

Instantly share code, notes, and snippets.

View danielbraun's full-sized avatar

Daniel Braun danielbraun

  • Tel-Aviv, Israel
View GitHub Profile
@scttnlsn
scttnlsn / core.cljs
Last active July 2, 2016 07:36
Om/Secretary nested routing
(ns nested-routing.core
(:require-macros [om.core :as om]
[secretary.core :refer [defroute]])
(:require [om.dom :as dom]
[om.core :as om]
[secretary.core :as secretary]
[goog.events :as events]
[goog.history.EventType :as EventType])
(:import goog.History))
@malyn
malyn / vim-fireplace-figwheel.diff
Created February 20, 2015 21:12
vim-fireplace patches/hack for compatibility with Figwheel
diff --git a/plugin/fireplace.vim b/plugin/fireplace.vim
index 6c32caa..a415bf8 100644
--- a/plugin/fireplace.vim
+++ b/plugin/fireplace.vim
@@ -232,7 +232,9 @@ function! s:repl.piggieback(arg, ...) abort
else
let arg = ' :repl-env ' . a:arg
endif
- let response = connection.eval('(cemerick.piggieback/cljs-repl'.arg.')')
+ "let response = connection.eval('(cemerick.piggieback/cljs-repl'.arg.')')
@sgrove
sgrove / curl->clj.clj
Last active August 18, 2021 14:27
Convert Chrome's `copy-as-curl` to clj-http calls
(defn curl->clj*
"Given a (single) curl string from Chrome's copy-as-curl, convert it either
into a clj-http call, a task-based http entry, or a shortened
task-based entry"
([curl-str]
(curl->clj* curl-str {}))
([curl-str conv-opts]
(let [clean-opts (:clean conv-opts)
merge-opts (:merge conv-opts)
headers (->
@stuarthalloway
stuarthalloway / Nil Finder
Created January 15, 2015 20:51
Finding those nested nils
(ns user)
(def app
"Intenal Helper"
(fnil conj []))
(defprotocol PathSeq
(path-seq* [form path] "Helper for path-seq"))
(extend-protocol PathSeq
@bzerangue
bzerangue / iCal.xsl
Created November 3, 2011 04:54
[XSLT] iCal utility
<?xml version="1.0" encoding="utf-8"?>
<!--
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
X-WR-TIMEZONE;VALUE=TEXT:US/Central
METHOD:PUBLISH
PRODID:-//Park Cities Presbyterian Church\(PCA\)//iCal 1.0//EN
X-WR-CALNAME;VALUE=TEXT:Park Cities Presbyterian Church Events Feed
VERSION:2.0
BEGIN:VEVENT
@tomysmile
tomysmile / brew-java-and-jenv.md
Last active April 20, 2022 16:14
How To Install Java 8 on Mac

Install HomeBrew first

brew update
brew tap caskroom/cask
brew install brew-cask

If you get the error "already installed", follow the instructions to unlink it, then install again:

@adeel
adeel / push-notifications.clj
Created July 26, 2011 01:03
Example of sending Apple push notifications with Clojure.
; Depends on [com.notnoop.apns/apns "0.1.6"].
(:import ('com.notnoop.apns APNS))
(defn send-push-notification [device-token message]
(let [service (.build (.withSandboxDestination
(.withCert (APNS/newService) "resources/apns-dev-cert.p12" "password")))
payload (.build (.alertBody (APNS/newPayload) message))]
(.push service device-token payload)))
@bmcbride
bmcbride / LeafletToWKT.js
Last active June 7, 2022 02:17
Leaflet layer to WKT
function toWKT(layer) {
var lng, lat, coords = [];
if (layer instanceof L.Polygon || layer instanceof L.Polyline) {
var latlngs = layer.getLatLngs();
for (var i = 0; i < latlngs.length; i++) {
latlngs[i]
coords.push(latlngs[i].lng + " " + latlngs[i].lat);
if (i === 0) {
lng = latlngs[i].lng;
lat = latlngs[i].lat;
@molotovbliss
molotovbliss / xslt-tips.md
Last active May 9, 2023 17:22
XSLT/XML - CLI tricks with xsltproc and xmllint

Tricks from the Command Line: xsltproc and xmllint

Often, when writing an XSLT file, you’ll want to test it quickly, without contacting a FileMaker Server or otherwise accessing the rest of the world. On Linux and OS X, you can use the command-line utility, ‘xsltproc’, to run XSLT programs quickly:

xsltproc transform.xsl input.xml

This applies the stylesheet in the file transform.xml to the XML in input.xml, and writes the output to your terminal. You can instead write the output to a file:

xsltproc transform.xsl input.xml > output.xml

@swannodette
swannodette / inference.md
Last active August 7, 2023 16:13
Externs Inference

Externs Inference

Integrating third party JavaScript libraries not written with Google Closure Compiler in mind continues to both be a source of error for users when going to production, and significant vigilance and effort for the the broader community (CLJSJS libraries must provide up-to-date and accurate externs).

In truth writing externs is far simpler than most users imagine. You only need externs for the parts of the library you actually intend to use from ClojureScript. However this isn't so easy to determine from Closure's own documentation. Still in the process of writing your code it's easy to miss a case. In production you will see the much dreaded error that some mangled name does not exist. Fortunately it's possible to enable some compiler flags :pretty-print true :pseudo-names true to generate an advanced build with human readable names. However debugging missing externs means compiling your production build for each missed case. So much time wasted for such simple mistakes damages our sen