Skip to content

Instantly share code, notes, and snippets.

View Rovanion's full-sized avatar

Rovanion Luckey Rovanion

View GitHub Profile
(ns tove.specs.generators
"Based on https://github.com/dm3/clojure.joda-time/blob/master/test/joda_time/generators.clj"
(:require [clojure.test.check.generators :as gen]
[clojure.string :as string]
#?(:clj [java-time :as jt]
:cljs [cljs-time.core :as jst]))
#?(:clj (:import [java.time LocalDate LocalDateTime ZonedDateTime]
[java.time.chrono IsoChronology])))
(defun elisp-showdoc (f)
(interactive (list (thing-at-point 'symbol t)))
(message
"%s"
(let* ((doc-list (split-string (documentation (intern f)) "\n"))
(number-lines (min (- (floor (* max-mini-window-height (frame-height))) 2)
(- (length doc-list) 2)))
(subset (concatenate 'list
(last doc-list)
'("")
@Rovanion
Rovanion / rewrite-history.sh
Created April 25, 2018 14:12
Rewrite git history
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="[email protected]
CORRECT_NAME="a"
@Rovanion
Rovanion / utils.ts
Created April 17, 2018 09:19
A semitransparent print or log function for TypeScript or JavaScript
let fnNameMatcher = /([^(]+)@|at ([^(]+) \(/;
function fnName(str: string) {
let regexResult = fnNameMatcher.exec(str) as string[];
if (regexResult) {
return regexResult[1] || regexResult[2];
} else { return ''; }
}
export function log(...messages: any[]) {
@Rovanion
Rovanion / cyd.liu.se
Created September 6, 2017 11:39
Nginx-conf for CYD
server {
listen 443;
server_name cyd.liu.se;
include includes/cyd.liu.se-commons;
include includes/security;
ssl_certificate /etc/ssl/certs/cyd.liu.se.crt;
ssl_certificate_key /etc/ssl/private/cyd.liu.se.key;
}
@Rovanion
Rovanion / assert.clj
Created June 30, 2017 08:08
Modified spec/assert for improved error reporting
(require '[clojure.spec.alpha :as spec])
;;; Spec does not report the name of the predicate when not wrapped in a spec.
(spec/assert number? nil)
;; Spec assertion failed val: nil fails predicate:
;; :clojure.spec.alpha/unknown :clojure.spec.alpha/failure
;; :assertion-failed
@Rovanion
Rovanion / key-count.dat
Last active June 1, 2017 09:48
The number of times different leiningen project map keywords are used
count name
14697 :description
12007 :url
136 :mailing-list
5 :mailing-lists
11641 :license
24 :licenses
1821 :min-lein-version
14154 :dependencies
2 :managed-dependencies
@Rovanion
Rovanion / fn-specs.clj
Created May 3, 2017 15:09
Useful function specs for Clojure Spec
(spec/fdef ::predicate
:args (spec/cat :arg any?)
:ret boolean?)
(spec/fdef ::nullary-fn
:args (spec/cat)
:ret any?)
(spec/fdef ::unary-fn
:args (spec/cat :first any?)
@Rovanion
Rovanion / test-clojar-projects.clj.bash
Last active March 7, 2017 10:40
Fetches all projects from clojure-toolbox.com and runs lein-master on them, define lein-master in your PATH for this to work.
#!/usr/bin/env bash
lst="$(curl -s http://www.clojure-toolbox.com/ \
| sed -n 's/.*href="\([^"]*\).*/\1/p' \
| grep -F 'https://github.com' | sort | uniq)"
dir="$PWD"
mkdir -p toolbox-projects
cd toolbox-projects
\usepackage[utf8]{inputenc}
\usepackage[swedish]{babel}
\usepackage{url}
%\usepackage{fullpage}
%\topmargin = 1pt %20pt
%\headsep = 25pt %25pt
%\usepackage[top=85pt]{geometry}
\usepackage[colorlinks=true, linkcolor=black, urlcolor=blue]{hyperref}
\usepackage[T1]{fontenc}
\usepackage{lmodern}