Skip to content

Instantly share code, notes, and snippets.

View apaatsio's full-sized avatar

Antti Ahti apaatsio

View GitHub Profile
@apaatsio
apaatsio / graphql_test.md
Last active October 21, 2016 05:59
Github GraphQL test
@apaatsio
apaatsio / apple_i_products_regex.js
Created October 25, 2016 14:04
Useless regexp to match Apple i products
/i(?:P(?:hone|od|ad)|Book|Mac|Cloud)/.exec("Apple iPhone 7")
@apaatsio
apaatsio / kitten_in_console.js
Created October 31, 2016 15:31
JavaScript snippet to show random kitten image in console
(function(url) {
// Create a new `Image` instance
var image = new Image();
image.onload = function() {
// Inside here we already have the dimensions of the loaded image
var style = [
// Hacky way of forcing image's viewport using `font-size` and `line-height`
'font-size: 1px;',
'line-height: ' + this.height + 'px;',
{
"sourceSpace": "XXX",
"destinationSpace": "YYY",
"sourceDeliveryToken": "AAA",
"managementToken": "ZZZ",
"syncTokenDir": "/tmp/contentful-sync",
"rateLimit": 1,
"rateLimitPeriod": 5000
}
@apaatsio
apaatsio / assert.dart
Last active October 1, 2018 10:26
lcov report shows coverage only for some asserts in Flutter 0.8.2; https://github.com/flutter/flutter/issues/22508
void successfulAsserts(int x) {
assert(true);
assert(x != null);
assert(x == 1);
int foo = 1;
assert(foo == 1);
}
void failingAssert() {
assert(false);
@apaatsio
apaatsio / coverage.dart
Last active May 23, 2022 13:26
Calculate total test coverage from lcov.info file generated by `flutter test --coverage`
// NOTE: The preferred way is to install lcov and use command `lcov --summary path/to/lcov.info`
// Use this script only if you can't install lcov on your platform.
// Usage: dart coverage.dart path/to/lcov.info
import 'dart:io';
void main(List<String> args) async {
final lcovFile = args[0];
final lines = await File(lcovFile).readAsLines();
[✓] Flutter (Channel master, v0.10.2-pre.25, on Linux, locale en_US.UTF-8)
• Flutter version 0.10.2-pre.25 at /home/antti/tools/flutter
• Framework revision 0edbe726a1 (3 hours ago), 2018-10-22 10:29:00 -0700
• Engine revision 58cdd53f90
• Dart version 2.1.0-dev.7.1.flutter-b99bcfd309
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at /home/antti/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
@apaatsio
apaatsio / size.sh
Last active February 23, 2019 09:12
Project size evaluator for Flutter Create contest 2019. More info: https://flutter.io/create
#!/bin/sh
# Project size evaluator for Flutter Create contest 2019.
# More info: https://flutter.io/create
MAX_SIZE=5120
SIZE=`find . -name "*.dart" | xargs cat | wc -c`
if [ $SIZE -gt $MAX_SIZE ];
@apaatsio
apaatsio / change_commit_date.sh
Created March 4, 2019 09:36
Change any git commit date
# STEP 1
# To change non-root commit
git rebase -i f154548^
# Alternatively, to change the root commit
git rebase -i --root
# STEP 2
# edit the commit you want to change by changing the line
pick f154548 This is a commit message
@apaatsio
apaatsio / debug-crashlytics.sh
Created March 16, 2019 19:54
How to debug Crashlytics on Flutter
#!/bin/sh
adb shell setprop log.tag.Fabric DEBUG
adb shell setprop log.tag.CrashlyticsCore DEBUG
adb logcat -s flutter Fabric CrashlyticsCore FirebaseApp libcrashlytics FlutterCrashlytics