Skip to content

Instantly share code, notes, and snippets.

View xrigau's full-sized avatar
:shipit:
🚀

Xavi Rigau xrigau

:shipit:
🚀
View GitHub Profile
@xrigau
xrigau / AndroidManifest.xml
Last active October 22, 2022 02:36
Disable animations for Espresso tests - run with `gradle cATDD`
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.novoda.espresso">
<!-- For espresso testing purposes, this is removed in live builds, but not in dev builds -->
<uses-permission android:name="android.permission.SET_ANIMATION_SCALE" />
<!-- ... -->
#!/bin/bash
# From: https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
export DEBIAN_FRONTEND=noninteractive
echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes
sudo apt-get update
sudo apt-get install \
apt-transport-https \
@xrigau
xrigau / MyInstrumentationTestCase.java
Created November 24, 2014 17:50
Disable Animations for Espresso tests v2.0
package com.novoda.espresso;
import android.os.SystemClock;
import android.test.ActivityInstrumentationTestCase2;
import com.mypackage.EntryPointActivity;
public class EspressoInstrumentationTestCase extends ActivityInstrumentationTestCase2<EntryPointActivity> {
private SystemAnimations systemAnimations;
@xrigau
xrigau / to_do_list_page.dart
Created April 16, 2018 16:18
Introduction to Redux in Flutter (to_do_list_page.dart viewmodel)
class _ViewModel {
final String pageTitle;
final List<_ItemViewModel> items;
final Function onNewItem;
final String newItemToolTip;
_ViewModel(this.pageTitle, this.items, this.onNewItem, this.newItemToolTip, this.newItemIcon);
factory _ViewModel.create(Store<AppState> store) {
List<_ItemViewModel> items = store.state.toDos
@xrigau
xrigau / actions.dart
Last active April 16, 2018 16:18
Introduction to Redux in Flutter (actions.dart)
class DisplayListWithNewItemAction {}
@xrigau
xrigau / reducer.dart
Created April 16, 2018 16:17
Introduction to Redux in Flutter (reducer.dart)
AppState appReducer(AppState state, action) => AppState(toDoListReducer(state.toDos, action), listStateReducer(state.listState, action));
final Reducer<List<ToDoItem>> toDoListReducer = // Boilerplate ignored
final Reducer<ListState> listStateReducer = combineReducers<ListState>([
TypedReducer<ListState, DisplayListOnlyAction>(_displayListOnly),
TypedReducer<ListState, DisplayListWithNewItemAction>(_displayListWithNewItem),
]);
ListState _displayListOnly(ListState listState, DisplayListOnlyAction action) => ListState.listOnly;
@xrigau
xrigau / to_do_list_page.dart
Created April 16, 2018 16:17
Introduction to Redux in Flutter (to_do_list_page.dart)
class ToDoListPage extends StatelessWidget {
@override
Widget build(BuildContext context) => StoreConnector<AppState, _ViewModel>(
converter: (Store<AppState> store) => _ViewModel.create(store),
builder: (BuildContext context, _ViewModel viewModel) => Scaffold(
appBar: AppBar(
title: Text(viewModel.pageTitle),
),
body: ListView(children: viewModel.items.map((_ItemViewModel item) => _createWidget(item)).toList()),
floatingActionButton: FloatingActionButton(
@xrigau
xrigau / state.dart
Created April 16, 2018 16:16
Introduction to Redux in Flutter (state.dart)
class AppState {
final List<ToDoItem> toDos;
final ListState listState;
AppState(this.toDos, this.listState);
factory AppState.initial() => AppState(List.unmodifiable([]), ListState.listOnly);
}
enum ListState {
@xrigau
xrigau / main.dart
Created April 16, 2018 16:16
Introduction to Redux in Flutter (main.dart)
void main() => runApp(ToDoListApp());
class ToDoListApp extends StatelessWidget {
final Store<AppState> store = Store<AppState>(
appReducer, /* Function defined in the reducers file */
initialState: AppState.initial(),
middleware: createStoreMiddleware(),
);
@override
@xrigau
xrigau / genesis_public_key
Created February 22, 2018 10:27
genesis_public_key
048065b862d831ce6162907fd624ecdf97a91ea30a19a327263d19e2bb687812d2450bfc639ae6ab5d453c14e112869cbc6b8aa972890a6c6b854fd3c6938b3db5