Skip to content

Instantly share code, notes, and snippets.

Avatar
🍪
Burning calories

Roman Kushnarenko sromku

🍪
Burning calories
View GitHub Profile
@sromku
sromku / parallel.sh
Created Jun 6, 2017
Control number of parallel 'threads' to be able execute and keep the in pool
View parallel.sh
#!/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)
@sromku
sromku / RoundedBitmapDrawableUtil.java
Created Jan 29, 2017
Getting Bitmap from obfuscated RoundedBitmapDrawable from support v4 lib. Good for matching Bitmaps in espresso.
View RoundedBitmapDrawableUtil.java
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 / app-multiple-ports.go
Created Dec 31, 2016
Multiple server ports for the same shared app.
View app-multiple-ports.go
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 / ImageScaleView.java
Created Nov 20, 2015
Image View Top Crop / Bottom Crop
View ImageScaleView.java
/**
* 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 / adb - key events.md
Last active Aug 29, 2015
Run key events from adb
View adb - key events.md
$ 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
View ReverseDelayInterplorator.java
/**
* The graph:
*
* ----
* /
* /
* /
* ----
*
* @author sromku