Skip to content

Instantly share code, notes, and snippets.

language: go
go:
- 1.5
- release
install:
- go get github.com/alecthomas/gometalinter
- gometalinter --install --update
- go get github.com/axw/gocov/gocov
@dotdoom
dotdoom / verify.go
Last active July 11, 2016 11:05
Verify Google-issued OAuth2 token in Go
package main
import (
"fmt"
"log"
"net/http"
"google.golang.org/api/oauth2/v2"
)
@dotdoom
dotdoom / adbtcpipd
Last active July 31, 2016 19:34
A "daemon" constantly trying to enable ADB tcpip on any connected device
#!/usr/bin/env bash
sleep 5
if /sbin/ifconfig usb0 &>/dev/null; then
# usb0 is present - we are in slave mode, this script won't work.
exit
fi
led() {
- emulator -avd test -no-window:
background: true
- circle-android wait-for-boot
# Wait until there's no log spam for some time -- means all Google Play Services have booted.
- >
while ! cmp /tmp/android.log /tmp/android-previous.log; do
mv /tmp/android.log /tmp/android-previous.log
sleep 20
# Compare the last few lines of logcat
adb logcat -t 25 >/tmp/android.log
@dotdoom
dotdoom / flutter-firebase-order-by-child.dart
Created July 15, 2018 14:11
Demo of FirebaseDatabase orderByChild with Flutter
import 'package:flutter/material.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/foundation.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
const subpath = 'flutter-firebase-order-by-child';
MyApp() {
@dotdoom
dotdoom / main.dart
Created December 7, 2018 09:42
URI schemes for sending emails (iOS)
import 'dart:core';
void main() {
final commonOptions = {
'subject': 'test',
'body': 'foobar',
};
print(Uri(scheme: 'mailto', path: 'mail@example.com', queryParameters: commonOptions));
@dotdoom
dotdoom / main.dart
Created December 25, 2018 18:19
Default initializer vs constructor
class A {
String value;
A(this.value) { print(value); }
String toString() => value;
}
class B {
A a = A('Default');
B();
@dotdoom
dotdoom / main.dart
Created March 15, 2019 08:26
Future, async and scheduleMicrotask
import 'dart:async';
Future<void> b(value) async {
await Future.delayed(Duration(seconds: 0));
// OR: remove the line ABOVE for fun effect.
print('b(${value})');
}
Future<void> a(value) async {
print('a(${value})');
@dotdoom
dotdoom / zvv2kml.py
Created March 24, 2016 21:24
ZVV Tarifzonen KML (Google Maps)
#!/usr/bin/env python
# Fetch ZVV Tarifzonen map in SVG and convert to KML.
# You can save the output and import into Google Maps.
# Use at your own risk. The API used is not publicly disclosed,
# improper use may lead to lawsuits.
import sys
import urllib2
import xml.etree.ElementTree as ET
testWidgets('StreamController adding null wtf', (WidgetTester tester) async {
final source = StreamController<String>();
var index = 0;
await tester.pumpWidget(MaterialApp(
home: StreamBuilder(
stream: source.stream,
builder: (context, snapshot) {
index += 1;
return Text('$index');