Skip to content

Instantly share code, notes, and snippets.

View phdoerfler's full-sized avatar

Philipp Dörfler phdoerfler

View GitHub Profile
@phdoerfler
phdoerfler / p4merge install
Last active June 14, 2022 14:41 — forked from AaronGhent/p4merge install
Installs p4merge on a linux based machine
# p4merge for 64 bit
wget 'https://www.perforce.com/downloads/perforce/r22.1/bin.linux26x86_64/p4v.tgz'
tar zxvf p4v.tgz
sudo cp -r p4v-* /usr/local/p4v/
sudo ln -s /usr/local/p4v/bin/p4merge /usr/local/bin/p4merge
@phdoerfler
phdoerfler / Focusmate_num_sessions_v1.rb
Created January 19, 2022 15:08 — forked from seyonv/Focusmate_num_sessions_v1.rb
File to get the current total number of sessions in Focusmate
require 'json'
require 'pry'
require 'uri'
require 'net/http'
class FocusMateNumSessions
# Step 1. Create a file somewhere in your filesystem.
# Call it fm_token_file.txt. Insert the path to the file into the line below
# Make sure to look at the reference .txt file and just paste
# that over.
@phdoerfler
phdoerfler / bisect-test.sh
Last active December 21, 2021 15:50
A script to use with git bisect run, to automatically find a bad revision of a project using sbt
#!/usr/bin/env sh
# requires: GNU timeout
# code 0 if the current source code is good/old
# code between 1 and 127 (inclusive), except 125, if the current source code is bad/new.
# code 125 should be used when the current source code cannot be tested.
# see https://git-scm.com/docs/git-bisect
#
# Use (after you copied this to bisect-test.sh _outside_ your repository):
#
# git reset --hard
@phdoerfler
phdoerfler / move-and-link
Created August 13, 2021 12:06
Scala Ammonite Script to move and symlink directories
package io.doerfler
/**
* As an alternative consider flatMapConcat and mapConcat of Akka Streams.
*/
abstract class IteratorThatKeepsOnGiving[T] extends Iterator[T] {
private var currentIter: Iterator[T] = Iterator.empty[T]
private var currentElement: Option[T] = None
def nextIterator(lastElement: Option[T]): Iterator[T]
@phdoerfler
phdoerfler / tmux.md
Last active April 23, 2021 07:43
tmux
@phdoerfler
phdoerfler / hg.md
Last active April 22, 2021 16:19
HG

Reorder commits

hg convert --datesort

Try this first. However, in my case I saw no difference and moved on.

Lots of small pulls

That said, if you want to try you just need to use a series of hg pull -r REV commands into a new clone. Something like this:

@phdoerfler
phdoerfler / nixos.md
Last active April 20, 2021 07:15
nixos

NixOS

Path to $binary/$derivation

$derivation/bin gets linked into PATH only when explicitely installing it. If, e.g., sieve-filter is only in /nix/store because something else dependet on dovecot_pigeonhole, it won't be in PATH.

Path to $derivation Part 2

$ nix repl
@phdoerfler
phdoerfler / javatime.md
Last active April 13, 2021 10:42
Java Time

2021-04-06T10:03:57.249000072Z too precise?

instant.truncatedTo(ChronoUnit.SECONDS)

Custom formatter?

.withZone!

@phdoerfler
phdoerfler / README.md
Last active April 13, 2021 07:08
VS Code Snippet to promote tuples to case classes in Circe

What does it look like

import io.circe._
case class Fnord(thing: Int, otherThing: Double)
object Fnord {
  implicit val codec: Codec[Fnord] = Codec.from(
    implicitly[Decoder[(Int, Double)]].map((Fnord.apply _).tupled),
    implicitly[Encoder[(Int, Double)]].contramap(r => Fnord.unapply(r).get)
  )