Skip to content

Instantly share code, notes, and snippets.

View sromku's full-sized avatar
🍪
Burning calories

Roman Kushnarenko sromku

🍪
Burning calories
View GitHub Profile
@sromku
sromku / ReverseDelayInterplorator.java
Created December 22, 2013 12:58
ReverseDelayInterplorator
/**
* The graph:
*
* ----
* /
* /
* /
* ----
*
* @author sromku
@sromku
sromku / adb - key events.md
Last active December 31, 2021 22:44
Run key events from adb
$ adb shell input keyevent <keycode>
code event code event code event
0 UNKNOWN 30 B 60 SHIFT_RIGHT
1 MENU 31 C 61 TAB
2 SOFT_RIGHT 32 D 62 SPACE
3 HOME 33 E 63 SYM
@sromku
sromku / ImageScaleView.java
Created November 20, 2015 15:32
Image View Top Crop / Bottom Crop
/**
* Scale to center top or scale to center bottom
*
* @author sromku
*/
public class ImageScaleView extends ImageView {
private MatrixCropType mMatrixType = MatrixCropType.TOP_CENTER; // default
private enum MatrixCropType {
@sromku
sromku / app-multiple-ports.go
Created December 31, 2016 16:58
Multiple server ports for the same shared app.
func startServer(port string) {
log.Println("Starting on port: " + port)
serverMux := http.NewServeMux()
serverMux.HandleFunc("/", handle)
log.Println("ERROR: " + http.ListenAndServe(":" + port, serverMux).Error())
}
@sromku
sromku / RoundedBitmapDrawableUtil.java
Created January 29, 2017 13:13
Getting Bitmap from obfuscated RoundedBitmapDrawable from support v4 lib. Good for matching Bitmaps in espresso.
public static Bitmap getBitmapFromRoundedBitmapDrawable(RoundedBitmapDrawable drawable) {
Bitmap origin = null;
try {
Field[] declaredFields = RoundedBitmapDrawable.class.getDeclaredFields();
for (Field field : declaredFields) {
if (field.getType().isAssignableFrom(Bitmap.class)) {
field.setAccessible(true);
origin = (Bitmap) field.get(drawable);
break;
}
@sromku
sromku / parallel.sh
Created June 6, 2017 10:53
Control number of parallel 'threads' to be able execute and keep the in pool
#!/bin/bash
# params
num=20 # total tests
threads=5 # parallel processes
# for script
readonly CONST_NAN_PID=-1
# return 0 (true) if PID is running, otherwise return 1 (false)