Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Pär Nils Amsen paramsen

🏠
Working from home
View GitHub Profile
@paramsen
paramsen / SlackBotToBitrise.js
Created Apr 29, 2019
Slack bot who triggers Bitrise, using Google Cloud Function as a messenger
View SlackBotToBitrise.js
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 / raw_pcm_float32_average.py
Last active Jun 11, 2018
Script that reads a file with raw pcm data in little endian float32 and prints the mean.
View raw_pcm_float32_average.py
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 / basic_upload_apks_service_account.py
Last active Apr 5, 2018 — 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
View basic_upload_apks_service_account.py
#!/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 / build.groovy
Last active Jun 28, 2020
Generate Android version code from git count in Gradle (build.gradle)
View build.groovy
// 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 / batch-convert-dpi.kts
Last active Jan 15, 2018
[Android util] [kotlin script] Batch convert Android res from xxxhdpi to *dpi sizes using imagemagick
View batch-convert-dpi.kts
/**
* Batch conversion from one dpi to the others using imagemagick
* (got some Windows and personal machine hardcoded stuff, change that)
*
* Usage: kotlinc -script batch-convert-dpi.kts <output dir> <paths to input files (pngs)>
*/
import java.io.File
import jdk.nashorn.internal.runtime.ScriptingFunctions.readLine
import java.io.BufferedReader
@paramsen
paramsen / Vector2Png.kt
Created Jan 9, 2018
Batch convert <vector> to png for mdpi..xxxhdpi using Canvas api
View Vector2Png.kt
/**
* Run convertVectorsToPngs() test, get the pngs from the device by "adb pull <the path>" and paste the res folders
* into your android project.
*
* @author Pär Amsen 01/2018
*/
@RunWith(AndroidJUnit4::class)
class Vector2Png {
lateinit var context: Context
lateinit var baseDir: File
@paramsen
paramsen / CraneView.java
Last active Aug 3, 2017
Android: Simple trigonometric formula for calculating cascading joint rotations for an arm joint system.
View CraneView.java
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
@paramsen
paramsen / CustomFrameLayout.java
Last active Jan 10, 2018
Android; Mixing wrap_content and match_parent in a wrap_content FrameLayout
View CustomFrameLayout.java
/**
* Wraps the inflated TextView, adds an ImageView programatically that matches_parent by force.
* By default the FrameLayout would adjust it's bounds to the added ImageView, even if we add a
* LayoutParams with MATCH_PARENT. I omitted it here since it doesn't matter.
*
* @author Pär Amsen 07/2017
*/
public class CustomFrameLayout extends FrameLayout {
public CustomFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
@paramsen
paramsen / build.gradle
Created Jun 20, 2017
Crashlytics+Cmake NDK
View build.gradle
android {
//...
}
dependencies {
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.6@aar') {
transitive = true
}
}
@paramsen
paramsen / LogView.java
Last active Jan 10, 2018
Android View for printing private logs in realtime, supports lifecycle methods (start->stop)
View LogView.java
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.support.annotation.LayoutRes;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ScrollView;
import android.widget.TextView;
You can’t perform that action at this time.