Skip to content

Instantly share code, notes, and snippets.

Avatar

Sascha Peilicke saschpe

View GitHub Profile
View Api.kt
class Api(
userAgent: String,
val apiKey: String
) {
val client = HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer(Json.nonstrict)
}
install(Logging) {
@saschpe
saschpe / .gitlab-ci.yml
Created Feb 21, 2020
Ein Beispiel basierend auf Gitlab CI
View .gitlab-ci.yml
---
image: saschpe/android-sdk:29_29.0.2
stages:
- prepare
- build
- test
- integration
- release
- deploy
@saschpe
saschpe / release-check.sh
Created Feb 12, 2020
A script to figure out if a release commit was part of a merge (i.e. part of the entire merged branch or current HEAD commit)
View release-check.sh
#!/bin/bash
#
# Script to publish apps to the Play Store in case a release is discovered
#
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "${SCRIPT_DIR}/../inc.functions.sh"
# Constants
SECRET_FILE=config/play-publishing-api.json
@saschpe
saschpe / Result.kt
Last active Feb 11, 2020
Result.kt
View Result.kt
package saschpe.feel.free.to.copy
/**
* Wraps any computational result with compile-time type safety
*
* Suitable to catch and deliver exceptions across thread and process
* boundaries (e.g. when an exception happened on a networking thread and needs
* to be delivered to the UI thread). Works perfectly with coroutines.
*
* Very similar to [kotlin.Result] but as a sealed class (with it's benefits).
@saschpe
saschpe / otp.py
Last active Jan 16, 2020
Implementation of the OTP algorithm described at http://motp.sourceforge.net in Python. Supports reading secret and PIN from the command-line or from a config file. Allows to paste the generated token to the system's clipboard directly.
View otp.py
#!/usr/bin/env python3
#
# Copyright 2019 Sascha Peilicke <sascha@peilicke.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@saschpe
saschpe / Enum.kt
Last active Oct 28, 2021
Kotlin enum class extension for Android (SharedPreference, Parcelable, Bundle, Intent)
View Enum.kt
import android.content.SharedPreferences
import android.os.Bundle
import android.os.Parcel
inline fun <reified T : Enum<T>> Bundle.getEnum(key: String, default: T) =
getInt(key).let { if (it >= 0) enumValues<T>()[it] else default }
fun <T : Enum<T>> Bundle.putEnum(key: String, value: T?) =
putInt(key, value?.ordinal ?: -1)
@saschpe
saschpe / BundleUtils.kt
Created Dec 3, 2017
Kotlin enums in Android bundles
View BundleUtils.kt
package saschpe.alphaplus.utils
import android.os.Bundle
inline fun <reified T : Enum<T>> Bundle.getEnum(key: String, default: T) =
getInt(key).let { if (it >= 0) enumValues<T>()[it] else default }
fun <T : Enum<T>> Bundle.putEnum(key: String, value: T?) =
putInt(key, value?.ordinal ?: -1)
@saschpe
saschpe / gist:19e3033ff663950d6951
Created Nov 13, 2014
GreaseMonkey User Script to convert (all) texteareas into HTML editors (powerered by CodeMirror)
View gist:19e3033ff663950d6951
// ==UserScript==
// @name CodeMirror HTML Textareas
// @namespace saschpe
// @description Instanciate a CodeMirror HTML editor for every textarea...
// @author Sascha Peilicke <saschpe@mailbox.org>
// @include example.com
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
// @require http://cdnjs.cloudflare.com/ajax/libs/codemirror/4.7.0/codemirror.min.js
// @require http://cdnjs.cloudflare.com/ajax/libs/codemirror/4.7.0/mode/css/css.min.js
// @require http://cdnjs.cloudflare.com/ajax/libs/codemirror/4.7.0/mode/javascript/javascript.min.js
View gist:5763924
diff --git a/crowbar_framework/app/models/service_object.rb b/crowbar_framework/app/models/service_object.rb
index 5f24184..b60483e 100644
--- a/crowbar_framework/app/models/service_object.rb
+++ b/crowbar_framework/app/models/service_object.rb
@@ -1027,6 +1027,8 @@ class ServiceObject
# XXX: This should not be done this way. Something else should request this.
system("sudo -i /opt/dell/bin/single_chef_client.sh") if CHEF_ONLINE and !ran_admin
+ apply_role_post_chef_call(old_role, role, all_nodes)
+