Skip to content

Instantly share code, notes, and snippets.

View aaronoe's full-sized avatar

Aaron Oertel aaronoe

  • Reddit
  • Bellevue, WA
View GitHub Profile
var policy = Policy
.Handle<SomeExceptionType>()
.Retry();
var result = policy.Execute(() => DoSomething());
private static readonly Regex AppIdPattern = "fg=([0-z]{1,10}):\"com.example.yourpackagename\"".ToRegex();
private static readonly Regex TimeOnBatteryPattern = @"(Time on battery: .+?) \(".ToRegex();
private static BatteryStatistics ExtractBatteryStatsFromLog(string batteryLog)
{
var appId = AppIdPattern.Match(batteryLog).Groups[1].Value;
var wifiUsagePattern = $@"{appId}:[\s]+?(Wi-Fi network: .*?packets \d+ received, \d+ sent\))".ToRegex();
var wifiUsage = wifiUsagePattern.Match(batteryLog).Groups[1].Value;
var wifiUsageBreakdown = NetworkUsageBreakdown.CreateFromLogLine(wifiUsage);
# emulate device being unplugged
adb shell dumpsys unplug
# reset existing battery stats. stats are captured from this point on
adb shell dumpsys batterystats --reset
# -------------------
# RUN YOUR TESTS HERE
# -------------------
# dump the battery stats and capture the output
StartGroup: YourPhoneTests.AndroidBatteryTests.PhotoBatteryTest
Battery stats for test group: Photos
App UID: u0a207
Battery Capacity: 3000mAh
Time on Battery: 00:04:25.9310000
Battery Usage Breakdown:
Total Usage: 62.1mAh
Cpu Usage: 1.21mAh
Wifi Usage: 60.9mAh
@NotNull
private static final Playground.CounterProperty myProperty$delegate;
public static final Playground INSTANCE;
static {
myProperty$delegate = new Playground.CounterProperty("foo");
}
@NotNull
public final String getMyProperty() {
val myProperty by CounterProperty("foo")
class CounterProperty(private val value: String) : ReadOnlyProperty<Any, String> {
private var counter = 0
override fun getValue(thisRef: Any, property: KProperty<*>): String {
return synchronized(counter) {
println("Counter: ${++counter}")
value
}
@NotNull
private static String notNull = "Hello";
@Nullable
private static String maybeNull = "Hello";
@NotNull
public static final String getNotNull() {
return notNull;
}
@override
Widget build(BuildContext context) {
return new FutureBuilder<Repositories>(
future: apiClient.getUserRepositoriesFuture(username),
builder: (BuildContext context,
AsyncSnapshot<Repositories> snapshot) {
if (snapshot.hasError)
return new Center(child: new Text("Network error"));
if (!snapshot.hasData)
return new Center(
class ToolbarDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.star),
onPressed: _handleClickFavorite
Meta-Date for the Flutter app
http://cloc.sourceforge.net v 1.60 T=0.16 s (247.5 files/s, 14905.1 lines/s)
--------------------------------------------------------------------------------
Language files blank comment code
--------------------------------------------------------------------------------
Dart 31 263 39 1735
Bourne Again Shell 1 19 20 121
DOS Batch 1 24 2 64
XML 3 3 22 35