Skip to content

Instantly share code, notes, and snippets.

View ddikman's full-sized avatar

David Dikman ddikman

View GitHub Profile
@ddikman
ddikman / loading_overlay.dart
Created July 25, 2020 06:49
A brief overlay progress spinner to use for async functions
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class LoadingOverlay {
BuildContext _context;
void hide() {
Navigator.of(_context).pop();
}
@ddikman
ddikman / authorUpdate.ts
Created March 22, 2021 10:52
firebase-function-example.ts
import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin'
interface AuthorData {
role: string;
name: string;
}
const onAuthorNameUpdated = functions.firestore.document('users/{userId}').onWrite(async (change, context) => {
if (!change.after.exists) {
@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 / greycastle-scraper.py
Last active April 25, 2021 04:56
Example Scrapy scraper
import scrapy
from scrapy.shell import inspect_response
class GreycastleSpider(scrapy.Spider):
name = "greycastle"
start_urls = [
'https://greycastle.se'
@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 / 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 / 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 / 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 / .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 / 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: