Skip to content

Instantly share code, notes, and snippets.

View bholota's full-sized avatar

Bartłomiej Hołota bholota

View GitHub Profile
@bholota
bholota / BaristaUtils.java
Created May 31, 2016 12:28
Wake up before UI test
public final class BaristaUtils {
public static void wakeUp() {
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
Window window = new ComponentFinder().findCurrentActivity().getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
Index: spoon-runner/src/main/java/com/squareup/spoon/SpoonDeviceRunner.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- spoon-runner/src/main/java/com/squareup/spoon/SpoonDeviceRunner.java (revision 0e7361ea1c2926d3953a37a4f62357bc94dde3e2)
+++ spoon-runner/src/main/java/com/squareup/spoon/SpoonDeviceRunner.java (revision )
@@ -61,6 +61,7 @@
private final List<String> instrumentationArgs;
private final String className;
@bholota
bholota / TextUtils.java
Created January 12, 2016 14:39
Sets regular font face for regex matches and light one for rest
private Spannable setLightHeaderText(String text, String regexPattern) {
final Pattern regPattern = Pattern.compile(regexPattern);
final Matcher matches = regPattern.matcher(text);
final Spannable spannable = new SpannableString(text);
// right now we use first only occurrence if exist
if (!matches.find()) {
final CustomTypeFaceSpan lightSpanStart = new CustomTypeFaceSpan("roboto-light");
spannable.setSpan(lightSpanStart, 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return spannable;
@bholota
bholota / Logger.cs
Last active November 24, 2015 21:31
Fire and forget Unity3d remote logger for mobile (Android/iOS) devices
using UnityEngine;
using System.Collections;
public class Logger : MonoBehaviour
{
public static string URL = "XXX";
void Start()
{
public static class FadeoutBehavior extends CoordinatorLayout.Behavior<View> {
private int startPos = 0;
private int finalPos = 0;
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
return dependency instanceof AppBarLayout;
}
@bholota
bholota / sha256combinations.py
Created November 14, 2015 13:48
Generate all combinations for given chars, combination fixed length and print them with sha256 hash
# Simple script that generate all possible string combinations for given lenght
# and generates sha256 hashes for every combination. Combination allow to use
# single char zero or more times.
import hashlib
import itertools
possibleChars = ['a', 'l', 'i', 'n', 's', 'b']
passLen = 7
@bholota
bholota / MainActivity.java
Created August 31, 2015 14:19
Sample oAuth2 code flow, based on gist service
/**
* Sample oauth2 based on code flow
*/
public class MainActivity extends AppCompatActivity {
private static final String REDIRECT_URL = "http://redirect.com";
private static final String CLIENT_ID = "your_client_id(oauth_key)";
@Override
protected void onCreate(Bundle savedInstanceState) {
@bholota
bholota / build.gradle
Created August 27, 2015 12:24
gradle task dependency
// Custom tasks
/**
* This test make sure if we have everything committed (or stashed). Allows keep project clean
* and with even small change crashlytics beta upload will have different SHA1.
*/
task testGitWorkingCopy << {
def checkChanges = 'git status -uno --porcelain'.execute([], project.rootDir).text.trim()
android {
signingConfigs {
release {
storeFile file(fileConfig['keystore_dir'])
storePassword fileConfig['keystore_password']
keyAlias fileConfig['key_alias']
keyPassword fileConfig['key_password']
}
}
@bholota
bholota / gist:7a8c47577a91caf1255d
Created July 8, 2015 12:42
Add crashlyticsUpload tasks dependency on the fly - checking if everything is commited to git
//add it to your build.gradle
//every time when your will call task crashlyticsUploadSomethingSomething it will be called before it
//and it will crash if you have some uncommited changes in your working copy.
//
//I'm using this because I need git sha1 for app versioning in development versions.
task everythingGitCommited << {
def checkChanges = 'git status -uno --porcelain'.execute([], project.rootDir).text.trim()