Skip to content

Instantly share code, notes, and snippets.

View phdoerfler's full-sized avatar

Philipp Dörfler phdoerfler

View GitHub Profile
@phdoerfler
phdoerfler / idea
Last active November 27, 2016 17:14 — forked from grocky/idea
Open IDEA applications based on project type from the command line!
#!/usr/bin/env bash
IDEA=''
PROJECT_DIR=''
function main() {
openIdea "$@"
}
function openIdea() {
@phdoerfler
phdoerfler / sbt-latest-version.sh
Created August 4, 2017 11:06
Outputs the latest version of SBT
sbtlatest() {
curl -s "https://github.com/sbt/sbt/releases/latest" | perl -pe 's/^.*href="(.*)".*$/$1/' | perl -pe 's/^.*tag\/v(.*).*$/$1/'
}
@phdoerfler
phdoerfler / rsnapshotbackup.nix
Created January 12, 2018 19:38
A work in progress backup of dovecot maildirs using rsnapshot and dsync.
{ config, pkgs, lib, ... }:
let
cfg = config.mailserver;
backupUser = "tardis";
dsyncBackupScript = "dsyncbackup.sh";
set = cfg.loginAccounts;
@phdoerfler
phdoerfler / tab.rs
Created January 17, 2019 21:26
Run a command in a new iTerm tab
use std::io::{self, Write};
use std::process::{exit, Command, Stdio};
use std::env;
fn main() {
main2().unwrap_or_else(|e| {
eprintln!("{}", e);
exit(1);
})
}
#!/usr/bin/env bash
set -e
TRASH="~/.local/share/Trash"
nix-collect-garbage -d
nix optimise-store
rm -rfv "$TRASH/*"
nixos-rebuild switch --repair
@phdoerfler
phdoerfler / configuration.nix
Created March 22, 2019 14:17
Dropbox in NixOS
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
./mount.nix
./dropbox.nix
];
@phdoerfler
phdoerfler / Dashboard.cpp
Created May 26, 2019 21:57
WiFi + HTTP[S] + JSON
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecureBearSSL.h>
const uint8_t fingerprint[20] = {0xA3, 0xDE, 0xBD, 0xC9, 0x77, 0xE0, 0xDC, 0x68, 0x2F, 0x97, 0xB5, 0x59, 0xA0, 0xD0, 0x0A, 0x8E, 0x3B, 0xBA, 0x5C, 0xFC};
@phdoerfler
phdoerfler / thermonitor.nix
Created June 24, 2019 11:06
NixOS systemd service with python
{ config, pkgs, lib, ... }:
let
python = pkgs.python3Packages.python;
in
{
systemd.services.thermonitor = {
description = "Thermonitor Daemon";
serviceConfig = {
ExecStart = "/home/phi/thermonitor.py";
@phdoerfler
phdoerfler / main.rs
Created July 30, 2019 13:48
update-all
use std::io::{self, Write};
use std::process::{exit, Command, Stdio};
fn main() {
main_guarded().unwrap_or_else(|e| {
eprintln!("{}", e);
exit(1);
})
}
@phdoerfler
phdoerfler / PomDependenciesToSbt.scala
Last active June 24, 2020 21:37 — forked from dportabella/PomDependenciesToSbt
Script to convert Maven dependencies (and exclusions) from a pom.xml to sbt dependencies. Or run it online on http://goo.gl/wnHCjE
#!/usr/bin/env amm
// This script converts Maven dependencies from a pom.xml to sbt dependencies.
// It is based on the answers of George Pligor and Mike Slinn on http://stackoverflow.com/questions/15430346/
// - install https://github.com/lihaoyi/Ammonite
// - make this script executable: chmod +x PomDependenciesToSbt
// - run it with from your shell (e.g bash):
// $ ./PomDependenciesToSbt /path/to/pom.xml
import scala.xml._