Skip to content

Instantly share code, notes, and snippets.

View dchenbecker's full-sized avatar

Derek Chen-Becker dchenbecker

View GitHub Profile
@dchenbecker
dchenbecker / import-certs.sh
Created May 3, 2021 17:39
Script to import Unifi admin certificates (e.g. letsencrypt)
#!/bin/zsh
KS_HOME=/var/lib/unifi
cd $KS_HOME/certs
umask 0077
print "Paste in the cert.pem file followed by Ctrl-D"
cat > unifi.crt
@dchenbecker
dchenbecker / recoll.py
Created August 22, 2018 21:44 — forked from hanny24/recoll.py
Quick & dirty recoll support for Kupfer. Just place it to ~/.local/share/kupfer/plugins.
# Heavily based on Locate plugin by Ulrik Sverdrup <ulrik.sverdrup@gmail.com>
__kupfer_name__ = _("Recoll")
__kupfer_actions__ = (
"Recoll",
)
__description__ = _("Search using Recoll")
__version__ = ""
__author__ = "Honza Strnad <hanny.strnad@gmail.com>"
@dchenbecker
dchenbecker / gist:7ea5c392681e35ee7355
Created March 18, 2015 18:38
Making Process aggregation work
import scalaz.{ \/, -\/, \/-, \&/, Monoid }
import \&/._
import scalaz.concurrent.Task
import scalaz.syntax.semigroup._
import scalaz.stream.{ Process, Process1 }
import com.typesafe.scalalogging.Logger
object StreamReporting {

Keybase proof

I hereby claim:

  • I am dchenbecker on github.
  • I am dchenbecker (https://keybase.io/dchenbecker) on keybase.
  • I have a public key whose fingerprint is RETU RN T HIS. PGP. GET_ FING ERPR INT( ); }

To claim this, I am signing this object:

@dchenbecker
dchenbecker / keybase.md
Created January 21, 2015 20:08
keybase.md

Keybase proof

I hereby claim:

  • I am dchenbecker on github.
  • I am dchenbecker (https://keybase.io/dchenbecker) on keybase.
  • I have a public key whose fingerprint is 209A 77CA A4F9 E716 E20C 6348 B657 77EC 21A7 FB53

To claim this, I am signing this object:

@dchenbecker
dchenbecker / gist:5096560
Created March 6, 2013 03:50
Sometimes I just need to remind myself how crappy some Java APIs are...
scala> import java.util.Properties
import java.util.Properties
scala> val defaults = new Properties
defaults: java.util.Properties = {}
scala> defaults.setProperty("test", "foo")
res8: java.lang.Object = null
scala> defaults.containsKey("test")
@dchenbecker
dchenbecker / gist:947293
Created April 28, 2011 20:42
ZenOSS transform attempt
if 'is down' in evt.message:
if evt.prodState == 501: #Pre-Populated
evt._action = 'drop'
if 'is up' in evt.message:
if evt.prodState == 501: #Pre-Populated
evt._action = 'status'
evt.severity = 5
object JPASpec extends Specification {
object EM extends LocalEMF("jpaSample") with ThreadLocalEM
"EntityManager" should {
setSequential() // Make sure that the following specs execute in order
"Add users" in {
println("running add users")
val user1 = new User("Ted")
val user2 = new User("Fred")
class DefaultNullable<A,B> {
public delegate B MapFunc(A input);
private A underlying;
public DefaultNullable(A input) {
this.underlying = input;
}
public static implicit operator DefaultNullable<A,B>(A input) {
scala> object PositiveInt {
| def unapply (input : String) = try { if (input.toInt > 0) Some(input.toInt) else None } catch { case _ ⇒ None }
| }
defined module PositiveInt
scala> List("foo","bar","14") match {
| case group :: user :: PositiveInt(id) :: Nil ⇒ println("%s:%s (%d)".format(group, user, id))
| case _ ⇒ // NOP
| }
foo:bar (14)