Skip to content

Instantly share code, notes, and snippets.

View phdoerfler's full-sized avatar

Philipp Dörfler phdoerfler

View GitHub Profile
@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 / 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
];
#!/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 / 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);
})
}
@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 / 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/'
}
object GhettoValidation {
implicit class Optionator[A](val a: A) extends AnyVal {
def iff(f: => Boolean): Option[A] =
if (f) Some(a) else None
}
}
@phdoerfler
phdoerfler / sbt
Last active December 11, 2015 13:37
A launch script for SBT which warns if there are locally published libraries.
#!/usr/bin/env ruby
ivy = File.join(Dir.home, '/.ivy2/local')
local = Dir[File.join(ivy, '*/*/*')]
if not local.empty?
puts "\e[1m\e[33mFiles in IVY local:"
local.each do |d|
puts "- " + d.sub(ivy + '/', '').split('/').map { |s| '"' + s + '"' }.join(' % ')
end
@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() {
$ xiki
> Summary
The 'xiki' shell command is mostly meant to be called by programs
that want to interface with Xiki. But it is sometimes useful for
people to call it directly. Example usages:
$ xiki ip
$ xiki docs/faq
> Setting up your editor