Skip to content

Instantly share code, notes, and snippets.

View kennethkalmer's full-sized avatar

Kenneth Kalmer kennethkalmer

View GitHub Profile
@stuarthalloway
stuarthalloway / log_size.clj
Created August 7, 2015 18:49
(Rough) total JVM memory size of the log
;; bin/run log_size.clj DB-URI t
;; Estimates the total in-memory size of all log entries from t to end of data.
;; Scans log from t to the end, so run against a backup instead of production if possible!
(require
'[clojure.edn :as edn]
'[clojure.pprint :as pp]
'[datomic.api :as d]
'[datomic.memory-size :as size])
(let [dt #(-> (clj-time.core/date-time 2015 % %2)
clj-time.coerce/to-date)
now (d/db (d/connect (db/database-uri :main)))]
[(db/conn (db/database-uri :main))
(vec
(for [db [now ;; 29th July 2015
(-> now
(d/since (dt 2 1))) ;; 1st Feb 2015
(-> now
(d/as-of (dt 2 1))) ;; 1st Feb 2015
@honzabrecka
honzabrecka / bayesian.cljs
Last active February 20, 2017 10:14
Bayesian classifier implemented in Clojure (well, it's actually in ClojureScript).
;------------------------------------------------
; bayesian
(def empty-training-set {:features {} :categories {}})
(defn train
[features category]
(reduce #(assoc-in %1 [:features %2] {category 1})
(assoc-in empty-training-set [:categories category] 1)
features))
@code0100fun
code0100fun / app_controllers_sign-in.js
Created June 8, 2015 20:02
Ember Simple AUth + Ember CLI Mirage
// app/controllers/sign-in.js
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
signIn(){
this.set('errors', null);
var params = { identification: this.get('email'), password: this.get('password') };
// Redirects to index route on success (configurable in config/environment.js)
this.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', params);
@imjasonh
imjasonh / markdown.css
Last active May 17, 2024 07:30
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@scole-scea
scole-scea / systemd-reload.service
Last active August 29, 2015 14:17
Systemd reload hack for fleet
[Unit]
Description=Systemd Reload Hack for coreos fleet
After=fleet.service
# So: comments outside the script part itself, so I don't exceed
# command line length.
#
# The point here is to detect services which are stuck in "not-found"
# state when they shouldn't be. This failure originates from
# fleet-submitted unit files, so we try hard not to affect units
@Deraen
Deraen / edn.cljx
Last active August 6, 2023 06:51
Transit / edn date/datetime serialisers
(ns metosin.common.edn
#+clj
(:require [clj-time.format :as f])
#+cljs
(:require [cljs-time.format :as f]
cljs.reader)
#+clj (:import [org.joda.time DateTime LocalDate]))
;;
;; #DateTime tagging
@domenic
domenic / 0-github-actions.md
Last active April 8, 2024 23:35
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with GitHub Actions

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

A file below this one contains the steps for doing this with Travis CI. However, these days I recommend GitHub Actions, for the following reasons:

  • It is much easier and requires less steps, because you are already authenticated with GitHub, so you don't need to share secret keys across services like you do when coordinate Travis CI and GitHub.
  • It is free, with no quotas.
  • Anecdotally, builds are much faster with GitHub Actions than with Travis CI, especially in terms of time spent waiting for a builder.
@digital-wonderland
digital-wonderland / README.md
Last active April 6, 2022 17:22
Unit files to deploy an ElasticSearch cluster on CoreOS via Fleet
@joefiorini
joefiorini / rails.nix
Created September 18, 2014 06:16
Nix Expression for Running Rails Apps
with (import <nixpkgs> {});
stdenv.mkDerivation {
name = "717-app";
buildInputs = [ libiconv openssl ruby21 postgresql git nodejs ];
src = "/src/717";
builder = builtins.toFile "builder.sh" ''
set -e
source $stdenv/setup