Skip to content

Instantly share code, notes, and snippets.

View ddikman's full-sized avatar

David Dikman ddikman

View GitHub Profile
@ddikman
ddikman / experimental_switcher.dart
Created August 16, 2021 12:00
A wrapper widget to enable tapping to switch off or on an experimental mode setting
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);
@override
@ddikman
ddikman / experimental_mode.dart
Created August 16, 2021 11:58
Example of a service to help abstract the storage of experimental mode on local device
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
ddikman / input.rb
Created July 28, 2021 12:54
Example of cucumber step definitions
Then("the first match is {string}") do |title|
expect(find(:css, '#search div h3', :match => :first).text).to eq(title)
end
When("tapping search") do
click_button('btnK')
end
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
ddikman / table.py
Last active July 24, 2021 03:32
Scrapy table scraper helper utility class
''' Utility class Table for parsing an html table with Scrapy
'''
class InvalidSelector(Exception):
''' Exception raised when the table selector is invalid
'''
def validate_selector(selector):
''' Validates if a selector has a match and can be used
'''
@ddikman
ddikman / table_scraper.py
Created April 25, 2021 07:42
Scraping a table
import scrapy
from table import Table
# requires https://gist.github.com/ddikman/7426cad6cba342b162162babc1a5d0a3 to be placed as tably.py in the same folder
class TableSpider(scrapy.Spider):
name = "table-scraper"
start_urls = [
@ddikman
ddikman / gitlab-ci.yaml
Created July 3, 2021 09:49
A single step flutter lint, test and coverage pipeline for gitlab
cache:
paths:
- /flutter/bin/cache/dart-sdk
build:
image: greycastle/jreader:2.3.0
script:
- flutter analyze
- pub global activate junitreport
- export PATH="$PATH":"$HOME/.pub-cache/bin"
@ddikman
ddikman / gitlab-ci.yaml
Created July 3, 2021 09:46
Flutter three step build and test job
stages:
- lint
- test
- coverage
default:
image: greycastle/jreader:2.3.0
cache:
paths:
@ddikman
ddikman / .gitlab-ci.yml
Created June 25, 2021 09:27
Gitlab CI yaml for flutter project
stages:
- lint
- test
- coverage
default:
image: greycastle/flutter:2.2.0
cache:
paths:
@ddikman
ddikman / pre-commit
Created May 22, 2021 03:30
Flutter linting pre-commit hook
# Add this pre-commit file to ./.git/hooks/pre-commit
#!/bin/sh
flutter analyze