Skip to content

Instantly share code, notes, and snippets.

/* Non-blocking Breathing LED
* Kevin Mark, 2017
* https://kmark.io
*
* Adapted from:
* Breathing sleep LED, like on a Mac.
* Jeremy Saglimbeni 2011
* http://thecustomgeek.com/2011/06/17/breathing-sleep-led/
*/
#!/bin/bash
if [ -z ${1+x} ]; then
workdir=${PWD}
else
workdir=${1}
fi
find "${workdir}" -name '.DS_Store' -type f -delete
find "${workdir}" -name '.Trashes' -type d -delete
/*
Copyright 2012 by Johnson Controls
__________________________________________________________________________
Filename: systemApp.js
__________________________________________________________________________
Project: JCI-IHU
Language: EN
Author: awoodhc
@kmark
kmark / xdlcount.php
Created September 27, 2016 23:32
Counts cumulative downloads of an Xposed module from both the Xposed repo and GitHub. Beware of GitHub rate limits.
#!/usr/bin/env php
<?php
$repoId = 'com.versobit.kmark.xhangouts';
$ghId = 'kmark/XHangouts';
preg_match_all('/([\\d,]+) in total/m', fgc('http://repo.xposed.info/module/' . $repoId), $matches);
$repoCount = array_reduce($matches[1], function($carry, $item) {
return $carry + str_replace(',', '', trim($item));
}, 0);
@kmark
kmark / AudioRecordActivity.java
Last active January 4, 2024 11:01
An example of how to read in raw PCM data from Android's AudioRecord API (microphone input, for instance) and output it to a valid WAV file. Tested on API 21/23 on Android and API 23 on Android Wear (modified activity) where AudioRecord is the only available audio recording API. MediaRecorder doesn't work. Compiles against min API 15 and probabl…
/*
* Copyright 2016 Kevin Mark
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
@kmark
kmark / profinder.php
Created August 21, 2015 15:50
ProFinder - The ProGuard obfuscation tracker.
#!/usr/bin/env php
<?php
/*******************************************************************************************************************
* ProFinder v1.0 *
* http://forum.xda-developers.com/android/software/profinder-proguard-obfuscation-tracker-t3183647 *
*******************************************************************************************************************
* Copyright 2015 Kevin Mark *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
@kmark
kmark / HueFromRgb.java
Created March 9, 2015 20:26
Retrieves the hue value in degrees from a packed (A)RGB color. Adapted from a C algorithm by Eugene Vishnevsky. http://www.cs.rit.edu/~ncs/color/t_convert.html
public class HueFromRgb {
// Retrieves the hue value in degrees from a packed (A)RGB color.
// Adapted from a C algorithm by Eugene Vishnevsky.
// http://www.cs.rit.edu/~ncs/color/t_convert.html
public static float hueFromRgb(int rgb) {
int r = (rgb >> 16) & 0xFF;
int g = (rgb >> 8) & 0xFF;
int b = rgb & 0xFF;
float min = Math.min(Math.min(r, g), b);
@kmark
kmark / CLionTrace.sh
Created February 20, 2015 22:51
Finds a running CLion instance and takes multiple jstack traces at a specified interval. Changing the regex should allow for use in any Java process that can be uniquely identified via jps.
#!/bin/bash
traces=10
interval=5
jps -mv | while read -r line; do
if [[ $line =~ ^([0-9]+).*clion.*$ ]]; then
printf "CLion running with PID %s\n" ${BASH_REMATCH[1]}
for ((i = 1; i <= $traces; i++)); do
printf "%d... " $i
@kmark
kmark / XHookGms.java
Last active January 14, 2024 13:42
Hooking into any class in Google Play Services
package com.versobit.kmark.gist;
import android.app.Application;
import android.content.Context;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
@kmark
kmark / LCM.c
Created November 16, 2014 20:49
Least common multiple calculator via greatest common denominator using Euclid's method. Includes both iterative and recursive implementations.
int gcdIterative(int a, int b) {
while(true) {
if(a > b) {
a -= b;
continue;
}
if(b > a) {
b -= a;
continue;
}