Skip to content

Instantly share code, notes, and snippets.

View jbaginski's full-sized avatar

Janusz Bagiński jbaginski

View GitHub Profile
@jbaginski
jbaginski / gist:57ef274c3adaf359207e2b7a9de966db
Created October 10, 2017 14:23 — forked from rb2k/gist:8372402
A jenkins script to clean up workspaces on slaves
// Check if a slave has < 10 GB of free space, wipe out workspaces if it does
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
for (node in Jenkins.instance.nodes) {
#!/bin/bash
adb devices | awk '{ print $1 }' | grep -v "List" | grep -v "192.168." | xargs -I{} adb -s {} reboot
watch -d -n 1 devices
@jbaginski
jbaginski / completion-for-gradle.md
Created November 14, 2016 11:02 — forked from nolanlawson/completion-for-gradle.md
Gradle tab completion for Bash. Works on both Mac and Linux.

Gradle tab completion script for Bash

A tab completion script that works for Bash. Relies on the BSD md5 command on Mac and md5sum on Linux, so as long as you have one of those two commands, this should work.

Usage

$ gradle [TAB]
@jbaginski
jbaginski / FragmentTransaction.kt
Created March 24, 2016 11:40
Kotlin recipes for Android: Fragment Tranaction
import android.app.Activity
import android.app.Fragment
import android.app.FragmentTransaction
inline fun Activity.fragmentTransaction(autocommit: Boolean = true, func: FragmentTransaction.() -> Unit) {
val transaction = fragmentManager.beginTransaction()
func.invoke(transaction)
if (autocommit && !transaction.isEmpty) {
@jbaginski
jbaginski / howto.md
Created March 7, 2016 10:02 — forked from neworld/howto.md
How to make faster Android build without sacrificing new api lint check

Original solution sacrifices new api lint check.

Here my solution:

int minSdk = hasProperty('minSdk') ? minSdk.toInteger() : 16

apply plugin: 'com.android.application'

android {
 compileSdkVersion 23
@jbaginski
jbaginski / genymotionwithplay.txt
Created October 7, 2015 15:17 — forked from wbroek/genymotionwithplay.txt
Genymotion with Google Play Services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161892865 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
Google Apps for Android 4.4.4 (https://www.androidfilehost.com/?fid=23501681358544845 - gapps-kk-20140606-signed.zip)
Google Apps for Android 4.3 (https://www.androidfilehost.com/?fid=23060877490000124 - gapps-jb-20130813-signed.zip)
Google Apps for Android 4.2 (https://www.androidfilehost.com/?fid=23060877490000128 - gapps-jb-20130812-signed.zip)
@jbaginski
jbaginski / themes-debug.xml
Last active August 29, 2015 14:27 — forked from dlew/themes-debug.xml
With the new theming in AppCompat, a lot of assets are tinted automatically for you via theme attributes. That has often led me to wonder "where the hell did this color come from?" You can replace your normal theme with this debug theme to help figure out the source of that color.
<!-- You can change the parent around to whatever you normally use -->
<style name="DebugColors" parent="Theme.AppCompat">
<!-- System colors -->
<item name="android:colorForeground">#440000</item>
<item name="android:colorForegroundInverse">#004400</item>
<item name="android:colorBackground">#444400</item>
<item name="android:colorBackgroundCacheHint">#440044</item>
<item name="android:textColorPrimary">#FFFF00</item>
import android.util.Log;
import com.squareup.leakcanary.AnalysisResult;
import com.squareup.leakcanary.DisplayLeakService;
import com.squareup.leakcanary.HeapDump;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.http.Multipart;
import retrofit.http.POST;
import retrofit.http.Part;
import retrofit.mime.TypedFile;

Making behat use phantomjs for the tests

If you want to run it on phantomjs (a headless browser) you can add this profile to your behat.yml and you need phantomjs >= 1.8.0

phantomjs:
    extensions:
        Behat\MinkExtension\Extension:
            base_url: http://dev.local
            goutte: ~
            selenium2:
 wd_host: "http://localhost:8643/wd/hub" 
@jbaginski
jbaginski / PackageManagerInfo.java
Created August 8, 2013 07:44
android build details
package org.example;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.content.pm.PackageInfo;
class PackageManagerInfo extends Activity {
public void onCreate() {
super.onCreate();