Skip to content

Instantly share code, notes, and snippets.

View danielbraun's full-sized avatar

Daniel Braun danielbraun

  • Tel-Aviv, Israel
View GitHub Profile
@danielbraun
danielbraun / Makefile
Last active April 17, 2020 16:08
My magic makefile to make everything happen
SPACY_MODEL ?= xx_ent_wiki_sm
PYTHONPATH ?= ~/django_home
DJANGO_SETTINGS_MODULE ?= django_home.settings
%.min.js: %.js
uglifyjs < $< > $@
%.xml: %.edn
edn2xml < $< > $@
<html dir="rtl"><head><meta content="width=device-width, initial-scale=1" name="viewport" /><meta charset="utf-8" /><script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script><link href="https://unpkg.com/leaflet@1.4.0/dist/leaflet.css" rel="stylesheet" type="text/css" /><link href="https://cdnjs.cloudflare.com/ajax/libs/leaflet-locatecontrol/0.66.1/L.Control.Locate.min.css" rel="stylesheet" type="text/css" /><style>
table img {
height: 3em;
}
</style></head><body><table border="1" render-header="rentals$eval42259$fn__42273@558941c1" style="margin: 0 auto;" width="50%"><thead><tr><th>כתובת</th><th>קישורים</th><th>סוג נכס</th><th>תמונות</th><th>חדרים</th><th>קומה</th><th>שטח</th><th>מחיר</th><th>מחיר למ״ר</th><th>מרחק מהכיכר ▼</th></tr></thead><tbody><tr><td>האלקושי</td><td><a href="https://www.yad2.co.il/item/lioamw" target="_blank">/item/lioamw</a></td><td>דירה</td><td><a href="https://
/*global L, document*/
document.querySelectorAll("[data-leaflet]").forEach(function(el) {
var data = JSON.parse(el.dataset.leaflet),
map = L.map(el, data);
data.tileLayers.forEach(function(layer) {
L.tileLayer(layer.urlTemplate, layer).addTo(map);
});
if (data.locate) {
map.locate(data.locate);
}
(ns ring-server-pg
(:require [ring.adapter.jetty :as jetty]
[clojure.java [jdbc :as jdbc]]
[clj-postgresql.core]
[ring.middleware.defaults :as defaults]))
(def db (System/getenv "DB_URL"))
(def last-request (atom nil))
openapi: 3.0.0
info:
title: Tasksheriff
version: 1.0.0
servers:
- url: 'https://api.tasksheriff.com'
components:
securitySchemes:
oAuth2:
type: oauth2
(let [per-page 25
page 2
page-count (sql/call :ceiling (sql/call :/ :%count.* per-page))
]
(-> {:select [[:%count.* :total_count]
[page-count :page-count]
[(sql/call :< page page-count) :has-next?]
[(sql/call :> page 1) :has-previous?]
[page :current_page]
]
(defn paginate
([coll] (paginate 1 coll))
([n coll] (paginate 25 n coll))
([per-page n coll]
(let [partitioned (vec (partition-all per-page coll))
page (or n 1)]
(some-> (get partitioned (dec page))
@danielbraun
danielbraun / enlive.clj
Last active May 13, 2016 17:18
two-column-table->map
(defn- two-column-table->map [table-dom]
(->> (enlive/select table-dom [:td])
(map (comp string/trim enlive/text))
(apply hash-map)
(map #(update % 0 string/replace ":" ""))
(into {})))
diff --git a/autoload/fireplace/nrepl.vim b/autoload/fireplace/nrepl.vim
index 5d081e7..15367e0 100644
--- a/autoload/fireplace/nrepl.vim
+++ b/autoload/fireplace/nrepl.vim
@@ -183,8 +183,10 @@ endfunction
function! s:extract_last_stacktrace(nrepl, session) abort
if a:nrepl.has_op('stacktrace')
let stacktrace = filter(a:nrepl.message({'op': 'stacktrace', 'session': a:session}), 'has_key(v:val, "file")')
- if !empty(stacktrace)
- return map(stacktrace, 'v:val.class.".".v:val.method."(".v:val.file.":".v:val.line.")"')
@danielbraun
danielbraun / gist:87384ea330053b3ffa83
Created November 27, 2014 14:03
Django Rest Framework + ImageField URL
When serializing models using DRF, the related ImageFields return the file system path instead of an absolute URL.
To solve it, define an instance variable on your model serializer:
class PersonSerializer(serializers.ModelSerializer):
image = serializers.Field('image.url')