Skip to content

Instantly share code, notes, and snippets.

View jacek-marchwicki's full-sized avatar

Jacek Marchwicki jacek-marchwicki

View GitHub Profile
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
return false;
case R.id.menu_refresh:
item.setActionView(R.layout.indeterminate_progress_action);
return true;
case R.id.menu_both:
rotateLeftFrag();
// Add this template in Preferences > Java > Editor > Templates > New
// I stored this snippet with newLoader name, but you can use any name you want
// To use this loader your class should implements LoaderCallbacks<Cursor>
private static final int ${loaderName} = 0;
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
switch (id) {
case ${loaderName}:
@jacek-marchwicki
jacek-marchwicki / SmartViewPager.java
Created June 18, 2014 10:45
ViewPager with getActiveFragment for position
package com.yapert.view.viewpager;
import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import com.google.common.base.Charsets;
import java.io.ByteArrayOutputStream;
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@jacek-marchwicki
jacek-marchwicki / LastCall.java
Created March 25, 2015 14:25
LastCall mockito verification
/*
* Copyright 2015 Jacek Marchwicki <jacek.marchwicki@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software

Using schedulers while testing your code

Let's start with some example

We would like to implement UI that will send some post to API. Our UI will need a button that will send a post, and a text field called "message" so a user will be able to choose a message that will be posted to the server. Of course, our UI can display errors and will show success (via toast). We will implement everything via MVC and will test presenter.

At a starting point we will have two classes that will be returned from API:

  • ApiError - it's used to represent some errors from API,
  • Post that represent post that needs to be added to the server.
#!/bin/bash -e
echo "WARNING"
echo "All docker files that are currenlty not runned will be removed!"
echo "Press enter to continue, or ctrl+c"
read
echo "Removing stopped images"
docker ps -a -q -f status=exited | xargs --no-run-if-empty docker rm || echo "Oooopps..."