Skip to content

Instantly share code, notes, and snippets.

Install for pantheon (elementary os):
1. sudo apt install fcitx fcitx-googlepinyin fcitx-mozc im-config
2. im-config -> select: fcitx
3. reboot
4. fcitx configure
@fbaierl
fbaierl / NumberOfIslands.scala
Last active August 14, 2018 08:29
NumberOfIslands
/*
https://leetcode.com/problems/number-of-islands/description/
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
Example 1:
Input:
11110
11010
@fbaierl
fbaierl / FirstMissingPositive
Last active August 14, 2018 09:34
first_missing_positive
/*
https://leetcode.com/problems/first-missing-positive/description/
Given an unsorted integer array, find the smallest missing positive integer.
Example 1:
Input: [1,2,0]
Output: 3
Example 2:
@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 / 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 / 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 / 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 / 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 {
/**
* 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