Skip to content

Instantly share code, notes, and snippets.

@fbaierl
fbaierl / gist:f50e6049509eb4aede73ab97dd95b80b
Created March 3, 2022 09:55
gradle: build scala.js (on linux)
tasks.register('buildui') {
doLast {
// clone & pull the sbt-extras repository from github
def sbtExtrasDirPath = 'sbt-extras'
def sbtExtrasDir = file(sbtExtrasDirPath)
try{
if(!sbtExtrasDir.exists()){
org.ajoberstar.grgit.Grgit.clone(dir: sbtExtrasDir, uri: 'https://github.com/dwijnand/sbt-extras.git')
}
@fbaierl
fbaierl / lubu_shortcuts.md
Last active February 27, 2019 17:53
Lubuntu window shortcuts

Add this to ~/.config/openbox/lxde-rc.xml:

<!-- Keybindings for window tiling -->

    <keybind key="C-W-Up">        # FullScreen
      <action name="Maximize"/>
    </keybind>
    <keybind key="C-W-Down">        # MiddleScreen
      <action name="UnmaximizeFull"/>
@fbaierl
fbaierl / howto_backup.txt
Last active December 8, 2018 23:00
BACKUP SYSTEM
1. Backup:
sudo dd if=/dev/sda1 of=/media/florian/Seagate\ Backup\ Plus\ Drive/back.img
2. Recover:
sudo dd if=/media/florian/Seagate\ Backup\ Plus\ Drive/back.img of=/dev/sda1
@fbaierl
fbaierl / Puppeteer_todo.md
Last active November 8, 2018 13:14
Puppeteer Library TODOs

1. Trigger more than one recalc()

x ~~~> y z w

2. Trigger with condition

x ~~ onfyIf (() => false) ~~~> y

3. Execute before and after

x ~~ before { println("before") } after { println("after") } ~~~> y

4. Trigger multiple times

@fbaierl
fbaierl / ForkMITLicensedProject.md
Created November 6, 2018 14:17
HOWTO fork a MIT licensed project

No, you are not allowed to change the copyright notice. Indeed, the license text states pretty clearly:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

But you are allowed to add a copyright notice.

If you want to keep the MIT license, which is what I would advise you to do, you only need to add a single line to the license file, before or after Copyright (c) 2012 Some Name with your own copyright notice. The final LICENSE file will look like this:

The MIT License (MIT)

@fbaierl
fbaierl / TarjanRecursive.scala
Last active January 31, 2021 21:19
Tarjan's algorithm for Scala
package tarjan
import scala.collection.mutable
// See python version: https://github.com/bwesterb/py-tarjan
/**
* Tarjan's algorithm is an algorithm in graph theory for finding the strongly connected components of a directed graph. It runs in linear time,
* matching the time bound for alternative methods including Kosaraju's algorithm and the path-based strong component algorithm.
*/
class TarjanRecursive {
@fbaierl
fbaierl / I18n.java
Last active October 26, 2018 13:49
Java I18n wrapper for scaposer lib (Scala)
// dependencies:
// https://mvnrepository.com/artifact/tv.cntt/scaposer
// compile group: 'tv.cntt', name: 'scaposer_2.12', version: '1.11.0'
package internationalization;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scala.collection.Seq;
import scala.util.Either;
import scaposer.ParseFailure;
@fbaierl
fbaierl / Format
Created October 25, 2018 07:59
Scala.js string interpolation like java.text.MessageFormat
object Format {
/**
* String interpolation [[java.text.MessageFormat]] style:
* {{{
* format("{1} {0}", "world", "hello") // result: "hello world"
* format("{0} + {1} = {2}", 1, 2, "three") // result: "1 + 2 = three"
* format("{0} + {0} = {0}", 0) // throws MissingFormatArgumentException
* }}}
* @return
/**
* A toggle switch with two labels. Modeled after: https://codemyui.com/toggle-switch-with-lables/
*/
object ToggleSwitchWithLabels {
private var toggled = true
def apply(labelOn: String, labelOff: String) = {
def onClick = {
println("on click: " + toggled)
toggled = !toggled