Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am nblumoe on github.
  • I am nblumoe (https://keybase.io/nblumoe) on keybase.
  • I have a public key ASBt8Y9xnzleLaIOwXoCP4YaZ9d8GbID1i0iV6k4ONcS9go

To claim this, I am signing this object:

View om_next_mutation_with_local_update.cljs
;; example for novelty:
{:user/verify {:db/id 1234 :being-verified false :verification-error :credentials-invalid}}
(defn merge-tree [old-state novelty]
(cond
(:user/verify novelty)
(let [novelty-props (:user/verify novelty)]
(update-in old-state [:users/by-id (:db/id novelty-props)] merge (dissoc novelty-props :db/id)))
View components.cljs
;;;; WORKS
(defui User
static om/IQuery
(query [this]
[:user/name :user/status])
Object
(render [this]
;; ....
))
@nblumoe
nblumoe / core.clj
Last active Sep 21, 2015
Example code for the problem of removing items from lazy sequences nested in a large Clojure tree and related issues. See http://stackoverflow.com/questions/32667778/removing-elements-from-lazy-sequences-in-a-large-clojure-tree-structure-avoidin for details
View core.clj
(ns large-tree.core
"Working example, also using XML."
(require [clojure.data.xml :as xml]))
(defn root' [content]
(fn []
(xml/map->Element {:tag :root :content (content)})))
(defn lazy-elements' [n tag content]
(repeatedly n (fn [] (xml/map->Element {:tag tag :content (content)}))))
@nblumoe
nblumoe / oc_backup.sh
Created Jun 7, 2015
ownCloud backup script
View oc_backup.sh
#!/bin/bash
# database
mysqldump --lock-tables -h localhost -u owncloud -p owncloud > owncloud-sqlbkp_`date +"%Y%m%d"`.bak
# directory
rsync -Aax /var/www/owncloud/ owncloud-dirbkp_`date +"%Y%m%d"`/
@nblumoe
nblumoe / gist:b7667ce2072f0d811196
Created Apr 19, 2015
piggieback issue when using cljs-time with boot
View gist:b7667ce2072f0d811196
$ boot dev
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
** WARNING: ~/.profile.boot is deprecated.
** Please use $BOOT_HOME/profile.boot instead.
** See: https://github.com/boot-clj/boot/issues/157
Writing boot_cljs_repl.cljs...
<< started reload server on ws://localhost:47769 >>
Writing boot_reload.cljs...
2015-04-19 08:36:10.786:INFO:oejs.Server:jetty-7.6.13.v20130916
2015-04-19 08:36:10.806:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:3000
View WP_filter_recentposts_by_id.php
add_filter('widget_posts_args','exclude_posts_abtests_variants');
function exclude_posts_abtests_variants( $args ){
// IDs von Beitragsvarianten
$args['post__not_in']= array(123,345);
return $args;
}
View clojure_opencv_face_detection.clj
(ns create-draw.opencv
(:import
org.opencv.core.Core
org.opencv.core.Mat
org.opencv.core.MatOfRect
org.opencv.core.Point
org.opencv.core.Rect
org.opencv.core.Scalar
org.opencv.highgui.Highgui
org.opencv.objdetect.CascadeClassifier))
@nblumoe
nblumoe / vim_fireplace_paredit_cheat_sheet.md
Created Apr 24, 2013
Simple cheat sheet for vim fireplace and paredit
View vim_fireplace_paredit_cheat_sheet.md

fireplace

  • cpr => (require ... :reload)
  • cpR => (require ... :reload-all)

Evaluation

  • :Eval (clojure code) => runs (clojure code) in repl
  • cpp => evaluate inn-most expessions under cursor
  • cp<movement> => evaluate text described by <movement>
  • cqp => opens quasi-repl
  • cqc => quasi-repl command line window
@nblumoe
nblumoe / angularjs_resource_tokenhandler.js
Created Jul 5, 2012
AngularJS service to send auth token with $resource requests
View angularjs_resource_tokenhandler.js
.factory('TokenHandler', function() {
var tokenHandler = {};
var token = "none";
tokenHandler.set = function( newToken ) {
token = newToken;
};
tokenHandler.get = function() {
return token;