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 / gist:07604e7bd6f1650aa2e7
Last active August 29, 2015 14:10
django-storages + Amazon S3

For those of you trying to integrate django-storages with Amazon S3, don't select Frankfurt as the bucket region. Use the default region (US standard or something). You'll get into weird HTTP 400 errors otherwise.

Also, make sure that DEFAULT_FILE_STORAGE is 'storages.backends.s3boto.S3BotoStorage' The other engine mentioned, 'storages.backends.s3.S3Storage', is broken.

In addition, add AWS_QUERYSTRING_AUTH = False to your settings. Otherwise, django-storages breaks browser caching by default. SO Answer: http://stackoverflow.com/questions/15668443/django-storage-with-s3-boto-break-browser-cache/15710661#15710661

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 / 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 {})))
(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))
(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]
]
openapi: 3.0.0
info:
title: Tasksheriff
version: 1.0.0
servers:
- url: 'https://api.tasksheriff.com'
components:
securitySchemes:
oAuth2:
type: oauth2
(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))
/*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);
}
<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://
@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 < $< > $@