Skip to content

Instantly share code, notes, and snippets.

Avatar

Jacek Marchwicki jacek-marchwicki

View GitHub Profile
View cleanup-old-images.sh
#!/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..."
View Using schedulers while testing your code.md

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.
@jacek-marchwicki
jacek-marchwicki / LastCall.java
Created Mar 25, 2015
LastCall mockito verification
View LastCall.java
/*
* 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
View designer.html
<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 / SmartViewPager.java
Created Jun 18, 2014
ViewPager with getActiveFragment for position
View SmartViewPager.java
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;
View gist:5346268
// 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}:
View gist:5344188
@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();
View git-completion.bash
#!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:
#