Skip to content

Instantly share code, notes, and snippets.

View grumpyshoe's full-sized avatar

Thomas Cirksena grumpyshoe

View GitHub Profile
@grumpyshoe
grumpyshoe / android_hint.txt
Last active April 9, 2016 08:47
This is just a collection of my hints to remind myself. I this will help anybody, I'm happy ;)
Start AVD using comupters VPN tunnel:
emulator -avd <avd-name> -dns-server <IPs, comma seperated>
e.g. emulator -avd Nexus_5_API_23_x86 -dns-server 192.168.1.2,192.168.1.3
List all dns-server:
scutil --dns | grep 'nameserver\[[0-9]*\]'
@grumpyshoe
grumpyshoe / gist:fdcddeed2c70c0b2b0d69428ce83ecca
Created November 22, 2016 13:01
Espresso: How to add intent Extras/Bundle to IntentsTestRule
@Rule
public IntentsTestRule<MainActivity> mTestRule = new IntentsTestRule<MainActivity>(MainActivity.class){
@Override
protected Intent getActivityIntent() {
Context targetContext = InstrumentationRegistry.getInstrumentation()
.getTargetContext();
Intent result = new Intent(targetContext, MainActivity.class);
result.putExtra("Name", "Value");
return result;
}
@grumpyshoe
grumpyshoe / gist:d65a286ce87bb7965abf17b5a030055c
Created December 1, 2016 13:50
How to make Bitmap from view
public static Bitmap loadBitmapFromView(View v) {
b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
v.layout(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
v.draw(c);
if (v.getMeasuredHeight() <= 0) {
v.measure(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
Bitmap b = Bitmap.createBitmap(v.getMeasuredWidth(), v.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
@grumpyshoe
grumpyshoe / gist:c3a5183b08fe4492c1091deba779f293
Created January 3, 2017 07:19
How to rename a git branch locally and remote
git branch -m old_branch new_branch # Rename your branch locally
git push origin :old_branch # Delete the old remote branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@grumpyshoe
grumpyshoe / gist:548045ee22e937e40db1b266babd6e2f
Created January 11, 2017 20:03
reset git to a previous branch
Example of how to reset a master branch to a specific commit (doen't matter which branch of)
git checkout master
git reset --hard <newBaseCommitId>
git push -f origin master
git merge <speceficCommitId>
git push origin master
@grumpyshoe
grumpyshoe / gist:d2c324303b382d4aa75adb0c0f822a62
Created February 9, 2017 22:11
Android / Espresso / Spinner - How to click on a spinner item
onView(withId(R.id.spinner)).perform(click());
onView(allOf(withId(R.id.textview_in_custom_spinner), withText("DummyText"))).perform(click());
@grumpyshoe
grumpyshoe / osx_animations.sh
Created January 8, 2018 08:35 — forked from dvdrhr/osx_animations.sh
osx animation options
# opening and closing windows and popovers
defaults write -g NSAutomaticWindowAnimationsEnabled -bool false
# smooth scrolling
defaults write -g NSScrollAnimationEnabled -bool false
# showing and hiding sheets, resizing preference windows, zooming windows
# float 0 doesn't work
defaults write -g NSWindowResizeTime -float 0.001
@grumpyshoe
grumpyshoe / MainViewModelTest.kt
Last active February 15, 2019 10:30
JUnit-Test example
class MainViewModelTest {
private lateinit var apiService: ApiService
@Rule
@JvmField
var rule: TestRule = InstantTaskExecutorRule()
@Before
fun setUp() {
@grumpyshoe
grumpyshoe / MockTestRunner.kt
Last active January 18, 2019 09:41
TestRunner using custom Application implementation
open class MockTestRunner : AndroidJUnitRunner() {
override fun onCreate(arguments: Bundle) {
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder().permitAll().build())
super.onCreate(arguments)
}
@Throws(InstantiationException::class, IllegalAccessException::class, ClassNotFoundException::class)
override fun newApplication(cl: ClassLoader, className: String, context: Context): Application {