Skip to content

Instantly share code, notes, and snippets.

View ddikman's full-sized avatar

David Dikman ddikman

View GitHub Profile
@ddikman
ddikman / routes.dart
Last active September 23, 2021 03:23
Example of feature flagging
void registerRoutes() {
// ...
final useNewArticlePage = isDebugMode == true;
if (useNewArticlePage) {
routing.register(Routes.Article, (context, param) => FixedSizeArticlePage());
} else {
routing.register(Routes.Article, (context, param) => ArticlePage());
}
// ....
}
@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 / 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
@ddikman
ddikman / titled_list_of_list.dart
Created May 17, 2021 03:06
List of List with titles
import 'package:flutter/widgets.dart';
typedef ItemBuilder<T> = Widget Function(BuildContext context, T item);
class TitledListOfListBuilder<T> extends StatelessWidget {
final List<List<T>> lists;
final ItemBuilder<T> itemBuilder;
final IndexedWidgetBuilder titleBuilder;
TitledListOfListBuilder({@required this.lists, @required this.itemBuilder, @required this.titleBuilder});
@ddikman
ddikman / flutter-package-spec-renderer.html
Last active May 8, 2021 07:31
Helper to generate badges for flutter packages
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type="text/javascript">
function setOutput(html) {
$('#code-output').text(html)
$('#rendered-ouput').html(html)
}
function renderOutput(packageName, githubName) {
@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 = [