Skip to content

Instantly share code, notes, and snippets.

View saschpe's full-sized avatar

Sascha Peilicke saschpe

View GitHub Profile
@saschpe
saschpe / release
Created April 19, 2023 09:53
Versioning script for Android projects
#!/bin/bash
#
# Script to create a release commit.
#
# Increases the version name and version code of an Android app,
# commits and tags the result.
#
# Based of semantic versioning: MAJOR.MINOR.PATCH
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
@saschpe
saschpe / Api.kt
Last active April 23, 2020 08:42
class Api(
userAgent: String,
val apiKey: String
) {
val client = HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer(Json.nonstrict)
}
install(Logging) {
@saschpe
saschpe / .gitlab-ci.yml
Created February 21, 2020 11:00
Ein Beispiel basierend auf Gitlab CI
---
image: saschpe/android-sdk:29_29.0.2
stages:
- prepare
- build
- test
- integration
- release
- deploy
@saschpe
saschpe / release-check.sh
Created February 12, 2020 14:55
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)
#!/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 February 11, 2020 15:12
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 January 16, 2020 06:33
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.
#!/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 May 24, 2022 21:50
Kotlin enum class extension for Android (SharedPreference, Parcelable, Bundle, Intent)
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 December 3, 2017 11:19
Kotlin enums in Android bundles
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 November 13, 2014 10:02
GreaseMonkey User Script to convert (all) texteareas into HTML editors (powerered by CodeMirror)
// ==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
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)
+