Skip to content

Instantly share code, notes, and snippets.

@behrica
behrica / gist:b09d159734a48bff3c7d
Created October 7, 2014 08:01
Clojure code for freeze / unfreeze of digitalocean droplet
(defn destroy-all-images [client-id api-key image-name]
(let [imgs (filter #(= (:name %) image-name) (all-images client-id api-key))]
(doseq [img imgs] (destroy-image client-id api-key (:id img)))))
(defn freeze
[client-id api-key droplet-name]
(let [droplet-id (:id (droplet-by-name client-id api-key droplet-name))]
(if (nil? droplet-id)
[:failed (str "Droplet " droplet-name " not existing")]
(do
@behrica
behrica / gist:d0f7d9c9e5293f0857a9
Created October 14, 2014 18:33
json output from "jsonf"
{
"coefficients": [
37.2851,
-5.3445
],
"residuals": [
-2.2826,
-0.9198,
-2.086,
1.2973,
lm(dist ~ speed,data=cars)
(ns icy-fog
(:require 'taoensso.nippy.utils)
)
(def l (list 1))
(def ll (repeat 2 l))
;;(taoensso.nippy.utils/serializable? ll)
@behrica
behrica / cider-nrepl-auto-erase-buffer.diff
Last active November 22, 2018 14:37
cider-nrepl-auto-erase patch
--- a/cider-repl.el
+++ b/cider-repl.el
@@ -396,6 +396,21 @@ client process connection. Unless NO-BANNER is non-nil, insert a banner."
;;; REPL interaction
+(defun cider--checked-insert-before-markers (string)
+
+ (message "Currrent cider repl buffer size is: %s "(buffer-size))
@behrica
behrica / maps.org
Last active August 15, 2021 09:51
Proof of concept for htmlwidget integration in org mode
renderDeps <- function(widget,dir=".",libdir="lib") {
  rendered <- htmltools::renderTags(widget)

  deps <- lapply(rendered1$dependencies, function(dep) {
    dep <- htmltools::copyDependencyToDir(dep, libdir, FALSE)
    dep <- htmltools::makeDependencyRelative(dep, dir, FALSE)
@behrica
behrica / bow.clj
Last active December 17, 2020 22:29
(ns sciloj.smile-nlp-example
(:require [clojure.string :as str]
[pppmap.core :as ppp]
[tablecloth.api :as tc]
[tablecloth.api.split :as split])
(:import smile.classification.Maxent
smile.nlp.normalizer.SimpleNormalizer
smile.nlp.stemmer.PorterStemmer
[smile.nlp.tokenizer SimpleSentenceSplitter SimpleTokenizer]
[smile.validation Accuracy ConfusionMatrix]))
(ns try-transform.transformers
(:require [tablecloth.api :as tc]
[tech.v3.dataset :as ds]
[tech.v3.dataset.math :as ds-math]
[tech.v3.dataset.modelling :as ds-mod]
[tech.v3.ml :as ml]))
;;; adapt exiting function to be transform compliant
(defn drop-rows [pipeline-context rows-selector]
(assoc pipeline-context
(ns sciloj.titanic
(:require [scicloj.metamorph.core :as morph]
[tablecloth.pipeline :as tc-mm]
[tablecloth.api :as tc]
[tech.v3.dataset.metamorph :as ds-mm]
[tech.v3.dataset :as ds]
[tech.v3.dataset.modelling :as ds-mod]
[tech.v3.ml.metamorph :as ml-mm]
[tech.v3.ml :as ml]
(ns sciloj.evaluate
(:require [tech.v3.dataset.modelling :as ds-mod]
[tech.v3.datatype.functional :as dfn]
[tech.v3.datatype.argops :as argops]
[tech.v3.dataset :as ds]
[tech.v3.datatype.errors :as errors]
[tech.v3.dataset.column-filters :as cf]
[tech.v3.ml.loss :as loss]
[clojure.tools.logging :as log]
[tech.v3.ml :as ml]