Skip to content

Instantly share code, notes, and snippets.


David Dikman ddikman

View GitHub Profile
ddikman / .gitlab-ci.yml
Created Sep 8, 2021
Gitlab CI for flutter build with caching packages folder
View .gitlab-ci.yml
- $CI_PROJECT_DIR/.pub-cache/
image: greycastle/flutter:2.2.3
- export PUB_CACHE=$CI_PROJECT_DIR/.pub-cache
- export PATH="$PATH":"$PUB_CACHE/bin"
- flutter pub get
ddikman /
Created Aug 25, 2021
Bash script to download a list of URLs
# usage:
# chmod +x
# pbpaste |
# cat inputfile.txt |
# thanks to
while read -r full_url
ddikman / app_root.dart
Created Aug 16, 2021
Example of loading remote config, avoiding stale values during testing
View app_root.dart
_initRemoteConfig(ExperimentalMode experimentalMode) async {
final RemoteConfig remoteConfig = RemoteConfig.instance;
var cacheDuration = Duration(hours: 1);
// allows us to force update the cache even when we exit the experimental mode
if (experimentalMode.isExperimentalMode || experimentalMode.isConfigStale()) {
cacheDuration = Duration(seconds: 0);
await remoteConfig.setConfigSettings(RemoteConfigSettings(
ddikman / experimental_switcher.dart
Created Aug 16, 2021
A wrapper widget to enable tapping to switch off or on an experimental mode setting
View experimental_switcher.dart
import 'package:flutter/material.dart';
import 'package:japanese_reading/settings_page/services/experimental_mode.dart';
class ExperimentalModeSwitcher extends StatefulWidget {
final Widget child;
final ExperimentalMode experimentalMode;
const ExperimentalModeSwitcher({Key key, @required this.child, @required this.experimentalMode}) : super(key: key);
ddikman / experimental_mode.dart
Created Aug 16, 2021
Example of a service to help abstract the storage of experimental mode on local device
View experimental_mode.dart
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:japanese_reading/services/preferences.dart';
class ExperimentalMode {
static final cacheStaleKey = 'cache_stale';
static final experimentalModeKey = 'experimental_mode';
final FirebaseAnalytics analytics;
final Preferences preferences;
ddikman / routes.dart
Last active Sep 23, 2021
Example of feature flagging
View routes.dart
void registerRoutes() {
// ...
final useNewArticlePage = isDebugMode == true;
if (useNewArticlePage) {
routing.register(Routes.Article, (context, param) => FixedSizeArticlePage());
} else {
routing.register(Routes.Article, (context, param) => ArticlePage());
// ....
ddikman / input.rb
Created Jul 28, 2021
Example of cucumber step definitions
View input.rb
Then("the first match is {string}") do |title|
expect(find(:css, '#search div h3', :match => :first).text).to eq(title)
When("tapping search") do
View google-search.feature
Feature: Google Search
Scenario: Searching a term will generate results
Given the user is on google top page
When searching for "greycastle ab software"
Then the first match is "Greycastle - Greycastle"
Scenario: The lucky feature will navigate straight to the first match
Given the user is on google top page
When entering "greycastle ab software"
ddikman / gitlab-ci.yaml
Created Jul 3, 2021
A single step flutter lint, test and coverage pipeline for gitlab
View gitlab-ci.yaml
- /flutter/bin/cache/dart-sdk
image: greycastle/jreader:2.3.0
- flutter analyze
- pub global activate junitreport
- export PATH="$PATH":"$HOME/.pub-cache/bin"
ddikman / gitlab-ci.yaml
Created Jul 3, 2021
Flutter three step build and test job
View gitlab-ci.yaml
- lint
- test
- coverage
image: greycastle/jreader:2.3.0