Skip to content

Instantly share code, notes, and snippets.

View christoph-frick's full-sized avatar

Christoph Frick christoph-frick

View GitHub Profile
@christoph-frick
christoph-frick / ics2pal.groovy
Created September 1, 2021 14:15
Convert ICS to PAL
@Grapes([
@Grab('org.slf4j:slf4j-simple:1.7.32'),
@Grab('org.mnode.ical4j:ical4j:3.1.0'),
])
import net.fortuna.ical4j.data.CalendarBuilder
import net.fortuna.ical4j.model.Component
import net.fortuna.ical4j.model.Property
import net.fortuna.ical4j.model.component.CalendarComponent
import net.fortuna.ical4j.model.property.DateProperty
; clj -Sdeps '{:deps {org.jsoup/jsoup {:mvn/version "1.13.1"}}}'
; Clojure 1.10.1
(import 'org.jsoup.Jsoup)
; org.jsoup.Jsoup
(def soup (Jsoup/parse "<html><head><title>Website title</title></head>
<body><p>Sample paragraph number 1 </p>
<p>Sample paragraph number 2</p>
</body></html>"))
; #'user/soup
(.getElementsByTag soup "p")
@christoph-frick
christoph-frick / .vimrc
Last active June 25, 2019 07:32
Vim Clojure setup
call plug#begin('~/.vim/plugged')
" ...
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
Plug 'guns/vim-sexp', {'for': ['clojure', 'fennel']}
Plug 'guns/vim-slamhound', {'for': 'clojure'}
Plug 'tpope/vim-sexp-mappings-for-regular-people', {'for': ['clojure', 'fennel']}
Plug 'tpope/vim-salve', {'for': 'clojure'}
Plug 'kovisoft/paredit', {'for': ['clojure', 'fennel']}
Plug 'tpope/vim-fireplace', {'for': 'clojure'}
@christoph-frick
christoph-frick / .vimrc
Last active April 8, 2019 10:18
.vimrc for use with Fennel
call plug#begin('~/.vim/plugged')
" ...
Plug 'guns/vim-sexp', {'for': ['fennel']}
Plug 'tpope/vim-sexp-mappings-for-regular-people', {'for': ['fennel']}
Plug 'kovisoft/paredit', {'for': ['fennel']}
Plug 'bakpakin/fennel.vim', {'for': 'fennel'}
" ...
call plug#end()
let g:sexp_enable_insert_mode_mappings = 0
@christoph-frick
christoph-frick / Awesome-Fennel.md
Last active March 1, 2024 19:42
Use fennel to write the awesome-wm config

How to write an awesome-wm config with Fennel

Awesome-WM is a X11 window manager, that is configured via Lua. Fennel is a Lisp for Lua. This shows a general setup of how to write your awesome-wm config using fennel directly without the compilation step (which would also work, but is not needed).

General setup

Fetch a recent Fennel version (the

@christoph-frick
christoph-frick / SteamLinux.groovy
Created December 6, 2017 21:29
Helper to create a pull request for SteamLinux
import groovy.json.*
def rootbranch = "upstream/master"
def jsonFile = "GAMES.json" as File
def id = args[0]
["git", "checkout", "-b", id, rootbranch].execute()
@christoph-frick
christoph-frick / vaadin8.groovy
Created May 31, 2017 14:46
Minimal failing example, V8 ComboBox not deleting text of previous selected item
// run with `spring run --watch vaadin.groovy`
@Grapes([
@Grab('com.vaadin:vaadin-spring-boot-starter:2.0.1'),
@Grab('com.vaadin:vaadin-archetype-application:8.0.5'),
])
import com.vaadin.ui.*
import java.time.*
@com.vaadin.spring.annotation.SpringUI
@com.vaadin.annotations.Theme("valo")
@christoph-frick
christoph-frick / ConverterField.groovy
Last active April 25, 2017 12:23
Vaadin CustomField for a Value-type, that wrapps a field for a Presentation-type and uses a Converter to transform between the two
package net.ofnir.vaadin.form
import com.vaadin.data.BeanValidationBinder
import com.vaadin.data.Binder
import com.vaadin.data.Converter
import com.vaadin.data.HasValue
import com.vaadin.shared.Registration
import com.vaadin.ui.AbstractField
import com.vaadin.ui.Component
import com.vaadin.ui.CustomField
@christoph-frick
christoph-frick / update_ad_block
Created March 24, 2017 20:43
Generate a block list for unbound
curl https://raw.githubusercontent.com/notracking/hosts-blocklists/master/hostnames.txt | grep '^0.0.0.0' | awk '{ print "local-zone: \"" $2 "\" refuse" }' > ad-blocking-data.conf
@christoph-frick
christoph-frick / reflection-in-macros.clj
Created March 6, 2017 20:19
Experiment about using reflection in macros for #clojure
(require '[clojure.reflect :refer [type-reflect]])
(require '[clojure.walk :refer [postwalk]])
(require '[clojure.set :refer [subset?]])
(defn public-static? [{:keys [flags]}]
(subset? #{:public :static} flags))
(def public-static-member?
(memoize
(fn public-static-member? [cls sym]