Skip to content

Instantly share code, notes, and snippets.

@manuelp
manuelp / markdown.el
Created December 16, 2016 12:51
Markdown support for Emacs
;; ========== Markdown
(use-package markdown-mode
:ensure t
:config
(setq markdown-coding-system "utf-8")
(add-hook 'markdown-mode-hook 'turn-off-auto-fill)
(add-hook 'markdown-mode-hook 'toggle-word-wrap)
;; Source: https://gist.github.com/edavis10/6084120
(add-hook 'markdown-mode-hook
(lambda ()
@manuelp
manuelp / funtional-java-libraries.md
Last active June 7, 2023 06:48
(Some) Functional Java Libraries: A quick comparison

Disclaiment: FP in Java is doable, even in Java 7- without lambda expressions (I use it basically every day), but there are limits. Sometimes the pragmatic choice is to NOT use it (for example for performance or readability reasons), but in most cases I find it applicable and beneficial. My kingdom for, at least: higher-kinded types, type inference and value types!

TotallyLazy

Warning: I have experience with the 1.x line of development and I'm going to talk about it.

@manuelp
manuelp / Makefile
Last active May 26, 2019 00:28
Makefile for producing documents with Asciidoctor + Pandoc
BASE_NAME=sample-document
all: $(BASE_NAME).html $(BASE_NAME).pdf $(BASE_NAME).xml $(BASE_NAME).docx $(BASE_NAME).epub $(BASE_NAME).md $(BASE_NAME).confluence
$(BASE_NAME).html: prepare
asciidoctor $(BASE_NAME).adoc -o output/$(BASE_NAME).html
# https://github.com/asciidoctor/asciidoctor-pdf
$(BASE_NAME).pdf: prepare
asciidoctor -r asciidoctor-pdf -b pdf $(BASE_NAME).adoc -o output/$(BASE_NAME).pdf
@manuelp
manuelp / frp-resources.md
Last active August 29, 2015 14:21
FRP resources
@manuelp
manuelp / never-use-string-java.md
Last active August 29, 2015 14:15
Never, never, never use String in Java (or at least less often :-)

This is a reproduction of a blog post written by Stephan Schmidt and originally published on May 2, 2008 at this URL. This version was retrieved using the Wayback Machine. Other than some minor formatting changes and modified links, this post is a copy of the original one.

Never, never, never use (unwrapped) String or long or int. Why? Those primitive types have no semantic meaning. They are hard to understand, hard to maintain, and hard to extend. I've been evangelizing this concept for some time, the essay "Object calisthenics" finally prompted be to write this post. Suppose we have an example of a cinema ticket booking service.

Update: *If you just want to drop

/**
* Haskell Brushe for SyntaxHighlighter 3.0
*/
SyntaxHighlighter.brushes.Haskell = function()
{
var constants = 'True False Nothing Just Left Right LT EQ GT';
var datatypes = 'Bool Maybe Either Ordering Char String Int Integer Float Double Rational ' +
'IO ReadS ShowS FilePath IOError Monad Functor Show Read' +
'Eq Ord Enum Bounded Num Real Integral Fractional Floating RealFrac RealFloat';
/*
Buttondown
A Markdown/MultiMarkdown/Pandoc HTML output CSS stylesheet
Author: Ryan Gray
Date: 15 Feb 2011
Revised: 21 Feb 2012
Modified by: Manuel Paccagnella
On: 07 Aug 2014
General style is clean, with minimal re-definition of the defaults or
@manuelp
manuelp / not-only-oo_ita
Last active August 29, 2015 14:04
Italian translation of the "Manifesto for Not Only Object-Oriented Development"
From: http://simontcousins.azurewebsites.net/manifesto/
----
Stiamo scoprendo modi migliori di sviluppare software praticandoli e aiutando altri a farlo. Attraverso questo lavoro siamo arrivati a dar valore a:
* **Funzioni e Tipi** piuttosto che classi
* **Purezza** piuttosto che mutabilità
* **Composizione** piuttosto che ereditarietà
* **Funzioni di ordine superiore** piuttosto che method dispatch
@manuelp
manuelp / word_wrap.rb
Created May 30, 2012 16:58
Word wrap in Ruby
class WordWrap
def initialize(text)
@text = text
end
def wrap(col)
result = ""
len = 0
@text.split(" ").each do |word|
if (len + word.length + 1) <= col then
@manuelp
manuelp / filtering.clj
Created May 6, 2012 20:21
Small exercise on filtering records by a criteria with multiple values in AND.
(ns filtering.core
(:require clojure.set))
(def records [{:id 10 :cat 12 :div 16}
{:id 10 :cat 11 :div 15}
{:id 11 :cat 12 :div 18}
{:id 11 :cat 22 :div 19}])
(defn has-all? [criteria records]
(letfn [(take-vals [criteria records]