Skip to content

Instantly share code, notes, and snippets.

View paramsen's full-sized avatar
🏠
Working from home

Pär Nils Amsen paramsen

🏠
Working from home
View GitHub Profile
@paramsen
paramsen / build.groovy
Last active January 17, 2024 08:17
Generate Android version code from git count in Gradle (build.gradle)
// Generate a minor version code from git commit count (for prod builds)
static def generateVersionCode() {
def result = "git rev-list HEAD --count".execute().text.trim() //unix
if(result.empty) result = "PowerShell -Command git rev-list HEAD --count".execute().text.trim() //windows
if(result.empty) throw new RuntimeException("Could not generate versioncode on this platform? Cmd output: ${result.text}")
return result.toInteger()
}
def majorVersion = 1
@paramsen
paramsen / basic_upload_apks_service_account.py
Last active April 5, 2018 08:00 — forked from machinekoder/Google Play Api - Apk Upload.md
This python script uploads an apk file into Google Play Store using Android Play Publisher API
#!/usr/bin/env python
#
# Copyright 2014 Marta Rodriguez.
#
# 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
#
@paramsen
paramsen / raw_pcm_float32_average.py
Last active June 11, 2018 10:48
Script that reads a file with raw pcm data in little endian float32 and prints the mean.
import sys
import numpy
import struct
f = sys.argv[1]
avg = lambda f: numpy.mean(numpy.absolute(numpy.fromfile(f, '<f4')), dtype=numpy.float64)
print('average of %s: %.16f' % (f, avg(f)))
@paramsen
paramsen / SlackBotToBitrise.js
Created April 29, 2019 12:05
Slack bot who triggers Bitrise, using Google Cloud Function as a messenger
const rp = require('request-promise-native')
const slackToken = '<SLACK TOKEN>'
const bitriseToken = '<BITRISE API TOKEN>'
const baseBitriseData = {
hook_info: {
type: 'bitrise',
build_trigger_token: bitriseToken
},
@paramsen
paramsen / ExoPlayerFromAssets.kt
Created August 28, 2020 11:49
ExoPlayer play file from assets (in this case audio, repeat for eternity)
val assetFactory = DataSource.Factory { AssetDataSource(context) }
val source = ProgressiveMediaSource.Factory(assetFactory).createMediaSource(Uri.parse("assets:///alarm_sound_1.mp3"))
val exo = SimpleExoPlayer.Builder(context).build().apply {
repeatMode = Player.REPEAT_MODE_ALL
volume = 1f
audioAttributes = AudioAttributes.Builder().setContentType(C.CONTENT_TYPE_MUSIC).build()
prepare(source)
playWhenReady = true
}