Skip to content

Instantly share code, notes, and snippets.

View vaclavsvejcar's full-sized avatar

Vaclav Svejcar vaclavsvejcar

View GitHub Profile
@vaclavsvejcar
vaclavsvejcar / sme-properties-gen.js
Created February 7, 2022 13:42
SME properties generator
(function () {
const json = JSON.parse(document.body.getElementsByTagName('pre')[0].innerText);
const lines = [];
for (let ns of Object.keys(json.cs)) {
for (let [key, value] of Object.entries(json.cs[ns])) {
lines.push(`${ns}.${key}=${value}`);
}
}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-|
Module : Headroom.IO.Cache
Description : Support for Cache implementations
name: headroom
version: 0.2.2.0
homepage: https://github.com/vaclavsvejcar/headroom
license: BSD-3-Clause
license-file: LICENSE
author: Vaclav Svejcar
maintainer: vaclav.svejcar@gmail.com
copyright: Copyright (c) 2019-2020 Vaclav Svejcar
github: vaclavsvejcar/headroom
category: Utils
import shapeless._
import scala.annotation.implicitNotFound
/*
* Used type names:
* - A = type of the sealed trait
* - C = type of the coproduct
* - H = type of the iterated singleton (case object) instance
* - T = type of the iterated coproduct
*/
package com.norcane.reelife.client.router
import scala.annotation.tailrec
import scala.language.implicitConversions
package object syntax {
type Out = String
def bind[R](routeDef: RouteDef[R]): R = routeDef.self
import scala.scalajs.js
import scala.scalajs.js.annotation.JSName
package object highlightjs {
lazy val hljs: HighlightJs = js.Dynamic.global.hljs.asInstanceOf[HighlightJs]
@JSName("hljs")
@js.native
@vaclavsvejcar
vaclavsvejcar / rxinterop.scala
Created October 7, 2016 11:19
Scalatags ↔ Scala.Rx integration
import org.scalajs.dom.html.Span
import org.scalajs.dom.{Element, Node}
import rx._
import scala.annotation.tailrec
import scala.util.{Failure, Success}
import scalatags.JsDom.all._
/**
* Provides support for using [[https://github.com/lihaoyi/scala.rx Scala.Rx]] together with the
@vaclavsvejcar
vaclavsvejcar / Injector.scala
Last active February 5, 2016 21:45
Dead-simple dependency injection based on Scalaz Reader Monad
import scalaz.Reader
/**
* Trait providing helper methods for handling application-wide dependency injection using the
* ''reader monad'' functional pattern.
*
* @author Vaclav Svejcar (v.svejcar@norcane.cz)
*/
trait Injector {
@vaclavsvejcar
vaclavsvejcar / mongo_upload.sh
Last active January 31, 2016 10:46
Command line utility for uploading directory structure into GridFS
#!/usr/bin/env bash
## Command line utility for uploading directory structure into GridFS
## Copyright (c) 2015-2016 norcane
##
## Authors:
## - Vaclav Svejcar (v.svejcar@norcane.cz)
## ------------------------------------------------------------------
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@vaclavsvejcar
vaclavsvejcar / ManualContext.java
Created May 20, 2014 17:59
Simple helper class providing manual lookup for CDI beans in non-managed environment
import java.util.Iterator;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
/**
* Provides simple way how to obtain the instance of managed beans