Skip to content

Instantly share code, notes, and snippets.

View eerohele's full-sized avatar
🐺

Eero Helenius eerohele

🐺
View GitHub Profile
@ghoseb
ghoseb / ns-cheatsheet.clj
Last active May 20, 2024 13:01 — forked from alandipert/ns-cheatsheet.clj
Clojure ns syntax cheat-sheet
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix
;; and optionally can refer functions to the current ns.
;;
;; * :import refers Java classes to the current namespace.
;;
;; * :refer-clojure affects availability of built-in (clojure.core)
;; functions.
@eerohele
eerohele / Rakefile
Created February 16, 2012 21:19
A simple Rakefile for running RSpec, Cucumber, or both.
require 'rspec/core/rake_task'
require 'cucumber/rake/task'
namespace :test do
desc 'Run RSpec tests'
RSpec::Core::RakeTask.new(:spec) do |task|
task.rspec_opts = %w[--color --format documentation]
task.pattern = 'spec/*_spec.rb'
end
@eerohele
eerohele / gemspec.rb
Created February 16, 2012 21:36
A template for a RubyGem specification.
require 'rake/gempackagetask'
# RubyGems versioning policy: http://docs.rubygems.org/read/chapter/7
gemspec = Gem::Specification.new do |gs|
gs.name = 'name'
gs.summary = 'summary'
gs.description = File.read(File.join(File.dirname(__FILE__), 'README.md'))
gs.requirements = [ 'requirements' ]
gs.version = '0.0.1'
@ogrrd
ogrrd / dnsmasq OS X.md
Last active May 14, 2024 08:39
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

@gamma235
gamma235 / joc-logic.clj
Last active July 30, 2021 06:37
Joy of Clojure, updated core.logic examples
(ns logic.core
(:require [clojure.core.logic.pldb :as pldb] ;; facts are now stored in a logic database which requires the pldb ns
[clojure.core.logic.fd :as fd] ;; for constraint programming, no need to include include in project.clj
[clojure.core.logic :refer :all :exclude [record?]])) ;; I left out ":as :logic" for aesthetics
(run* [answer]
(== answer 5))
(run* [val1 val2]
(== {:a val1, :b 2}

hiredman [6:39 PM]

I just don't understand why people use mount, I must be missing something, its model of each namespace as a component, with state as a global thing in a namespace(maybe I am mistunderstanding this), just seems bad, like sticking (def state (atom {})) in every namespace would be

[6:41] https://github.com/tolitius/mount/blob/master/src/mount/core.cljc#L10-L14

GitHub tolitius/mount mount - managing Clojure and ClojureScript app state since (reset)

@reborg
reborg / rich-already-answered-that.md
Last active May 8, 2024 14:20
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

@bhb
bhb / blockchain-w-spec.md
Last active July 1, 2022 11:24
Building a blockchain, assisted by Clojure spec

Building a blockchain, assisted by Clojure spec

In an effort to gain at least a superficial understanding of the technical implementation of cryptocurrencies, I recently worked my way through "Learn Blockchains by Building One" using Clojure.

This was a good chance to experiment with using spec in new ways. At work, we primarily use spec to validate our global re-frame state and to validate data at system boundaries. For this project, I experimented with using instrumentation much more pervasively than I had done elsewhere.

This is not a guide to spec (there are already many excellent resources for this). Rather, it's an experience report exploring what went well, what is still missing, and quite a few unanswered questions for future research. If you have solutions for any of the problems I've presented, please let me know!

You don't need to know or care about blockchains to understand the code be