Skip to content

Instantly share code, notes, and snippets.


Mindaugas Kuprionis mkuprionis

View GitHub Profile
mkuprionis /
Last active Aug 29, 2015
EnumPreference for Android following u2020 path
public class EnumPreference<E extends Enum<E>> {
private final SharedPreferences preferences;
private final Class<E> clazz;
private final String key;
private final E defaultValue;
public EnumPreference(SharedPreferences preferences, Class<E> clazz, String key) {
this(preferences, clazz, key, null);
mkuprionis /
Created Oct 10, 2014
List view with sticky headers and filtering
public class BrandListFragment extends BaseFragment {
private static final String ARGS_LOCATION_SPEC = "location_spec";
private LocationSpec location;
@InjectView( View progress;
@InjectView( StickyListHeadersListView brandList;
mkuprionis /
Created May 14, 2014
Embeded ActionBar tabs

Copied from Cyril Mottier's post on G+

His comments:

In order to implement tabs I decided to go for an entirely custom solution. I created the tab bar from scratch and added it as a custom ActionBar View. The tabs container is called TabBarView and extends LinearLayout. TabBarView actually handles the "selection strip".

The TabBarView is then filled with several TabView (one for each tab). The main purpose of TabView is to provide a nice API to deal with icon and the optional text (only visible in landscape) and handle the long press gesture (long pressing a tab displays a hint).

Once the TabBarView is initialized with a bunch of TabView, it is added as a custom View to the ActionBar:

mkuprionis /
Last active Feb 3, 2016
Retrofit API wrapper to be used when testing with Espresso
complete = false,
library = true,
overrides = true
public final class DebugApiModule {
@Provides @Singleton ApiEndpoint provideApiEndpoint(Locale locale, @ApiEndpointMarker StringPreference apiEndpoint,
@NetworkIgnoreLocale BooleanPreference ignoreLocale) {
return (ignoreLocale.get())
View gist:4084888
# Print file names with line numbers sorted ascending
for f in $(find . -iname "*.java"); do echo $f `(cat $f | wc -l)`; done | sort -k2 -n
# Total line count in directory
for f in $(find . -iname "*.java"); do cat $f; done | wc -l
# Copy files from multiple directories to a single one (filenames contain whitespace)
SAVEIFS=$IFS; IFS=$(echo -en "\n\b"); for f in $(find . -iname "*_new.png"); do cp $f ~/tmp/md/; done; IFS=$SAVEIFS;
# Total changed lines since some date from Git log
mkuprionis /
Created Aug 30, 2012
Android snippets, tips & tricks
// Hide keyboard
.hideSoftInputFromWindow(editText.getWindowToken(), 0);
mkuprionis / _app.scss
Created Jul 21, 2012
Compass/SASS sprites for different density displays
View _app.scss
@import "_mixins.scss";
@mixin app($dpi) {
header {
position: relative;
header .logo {
// Center in header
@include sprt-box-centered($dpi, logo);
mkuprionis / gist:3155322
Created Jul 21, 2012
Flask-Restless with URL rules example
View gist:3155322
# flask-restless.views.API
class API(ModelView):
def get(self, instid, **kwargs):
def _search(self, **kwargs):
self._before_search(data, **kwargs)
mkuprionis / gist:3155303
Created Jul 21, 2012
Flask-Restless extension example
View gist:3155303
class ProductAPI(API):
def _before_search(self, data):
if not current_user.isAdmin():
if not data.has_key('filters'):
data['filters'] = []
'name': 'sysUserId',
'op': 'equals',