Skip to content

Instantly share code, notes, and snippets.

View sveri's full-sized avatar

sveri

View GitHub Profile
mod config {
use serde::Deserialize;
#[derive(Debug, Default, Deserialize)]
pub struct ExampleConfig {
pub server_addr: String,
pub pg: deadpool_postgres::Config,
}
}
use ::config::Config;
@sveri
sveri / gradle_tests_report.gradle
Created July 29, 2020 16:00 — forked from lwasyl/gradle_tests_report.gradle
Gradle tests logging #loggingpost
import groovy.time.TimeCategory
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
rootProject {
ext.testsResults = [] // Container for tests summaries
allprojects { project ->
tasks.withType(Test) { testTask ->
@sveri
sveri / clojure_spec_output.md
Last active June 9, 2019 13:37
Spec error output in web (immutant) and clj console

In the last days I have been trying to track down how error output works with clojure spec. These are my findings so far.

I am using tools.deps and have the following deps.edn file:

{:paths ["src/clj" "resources"]    
 :deps  {    
         org.clojure/clojure                 {:mvn/version "1.10.1"},
         org.clojure/spec.alpha              {:mvn/version "0.2.176"},

org.immutant/web {:mvn/version "2.1.10"}}

I bundled these up into groups and wrote some thoughts about why I ask them!

If these helped you, I'd love to hear about it!! I'm on twitter @cvitullo or send me an email carl.vitullo@gmail.com

Onboarding and the workplace

https://medium.com/@cvitullo/questions-to-ask-your-interviewer-82a26e67ce6c

  • How long will it take to deploy my first change? To become productive? To understand the codebase?
  • What kind of equipment will I be provided? Will the company pay/reimburse me if I want something specific?
alexmiller [9:27 PM]
```(set! s/*explain-out*
(fn [explain-data]
(binding [*print-length* 3]
(s/explain-printer explain-data))))```
`*explain-out*` is a dynamic variable holding the function that prints explain data
^^ that will work at the repl, but you might need to use `with-bindings` to make it work in your code
`s/explain-printer` is the default print function
@sveri
sveri / gist:e588bec2a3832c5b247f
Created December 19, 2015 10:25
prismatic schema invariant to return the same type that param x has
(def FunSchema
(s/conditional
(comp string? :arg1)
{:arg1 s/Str :return s/Str}
(comp integer? :arg1)
{:arg1 s/Int :return s/Int}))
(defn fun [arg1]
(let [return-value (* 2 (Integer. arg1))] ; calculate function return here
@sveri
sveri / gist:701aa9f1cd1af12a37d7
Created July 2, 2015 14:05
Find if any of the given strings exists in any of .java source files in a folder
(ns playground
(:require [clojure.java.io :as io]
[clojure.string :as s])
(:import java.io.File))
(defn walk [dirpath pattern]
(doall (filter #(re-matches pattern (.getName %))
(file-seq (io/file dirpath)))))
@sveri
sveri / gist:9bcb992b25aa4bc05dc9
Last active August 29, 2015 14:15
map words to ints with benchmarking
(ns state-test.core
(:require [criterium.core :refer [bench]]))
;;Die Methode ist relativ sinnlos, da ich mit einem array schneller waere
;;aber sie soll nur verdeutlichen, wie das ganze dann ablaeuft, die number
;;zu einem wort kommt woanders her und kann durchaus verschieden vom inc
;;highest key sein.
(defn add-word
"adds a wort to a dictionary, which is basically a map word > number
returns modified dictionary and the number inserted for the word.