Skip to content

Instantly share code, notes, and snippets.

View srawlins's full-sized avatar

Sam Rawlins srawlins

View GitHub Profile
@srawlins
srawlins / analyze_flutter_customers.sh
Created December 11, 2023 23:53
A little shell script to locally analyze flutter customer code with a custom dart binary
# This script is as dead simple as it can be. It emulates the behavior of the
# `.test` files at https://github.com/flutter/tests/blob/main/registry/
# but assumes that all of the mentioned repos are already cloned, and in the
# current directory. (For example, see in `analyze_assorted_layout_widgets`,
# the first step is `pushd flutter-assorted_layout_widgets` which is relative
# to the current directory.) Limiting the git work to `git fetch` and
# `git checkout` should keep the overhead low.:
#
# The hashes are hard-coded here, so you'll have to hand-update them with the
# registry mentioned above. If you have `flutter/tests` cloned, you can
enum X { a, b }
const bool foo = X.a == X.b; // <-- won't compile
void main() {
print(foo);
}
import 'dart:math' as math;
// Poorly named wrapper for math.Random
class Random {
math.Random inner;
Random(this.inner);
}
void main() {
@srawlins
srawlins / a.dart
Created June 14, 2018 21:59
nSM Forwarding between VM and dart2js disagree - VM loses default values
void main() {
var a = new AImpl();
var b = new B(a);
print("CALLING W/O NAMED ARG");
b.a();
print("CALLING W/ NAMED ARG");
b.a(followLinks: false);
}
abstract class A {
@srawlins
srawlins / tryy.dart
Created February 17, 2017 22:59
Dart SDK Functions that take closures and don't like null.
import 'dart:async';
import 'dart:collection';
void main() async {
print('Function arguments that cannot be null');
// dart:async
//tryy('runZoned(null)', () => runZoned(null));
//tryy('scheduleMicrotask(null)', () => scheduleMicrotask(null));
await trya('Future.doWhile(null)', () => Future.doWhile(null));
await trya('Future.forEach(_, null)', () => Future.forEach([1], null));
@srawlins
srawlins / tmux.conf
Created January 22, 2017 01:16
my tmux.conf
# Ring the bell if any background window rang a bell
set -g bell-action any
# Default termtype. If the rcfile sets $TERM, that overrides this value.
set -g default-terminal screen-256color
# Keep your finger on ctrl, or don't
bind-key ^D detach-client
# Create splits and vertical splits
@srawlins
srawlins / README.md
Last active May 3, 2016 21:58
Performance of new DEAD_CODE analyses

Performance of new DEAD_CODE analyses

Before this change, the DEAD_CODE analysis only alerted on statements that follow:

  • a return
  • an unlabeled break
  • an unlabeled continue

My change adds the following to that list:

@srawlins
srawlins / README.md
Last active April 8, 2016 18:40
Performance of new UNUSED_SHOWN_NAME warnings

Performance of new UNUSED_SHOWN_NAME warning

Examining imports, and now the shown names on imports, is an expensive operation, as it potentially requires examining all of the elements in a library to discover if an import, or a shown name on an import, is used. So I wanted to test whether the new UNUSED_SHOWN_NAME warning significantly increases analysis time.

It obviously should increase analysis time by some amount, as it is doing extra work that wasn't being done before, but I wanted to measure this increase

@srawlins
srawlins / tables-spec.markdown
Last active September 27, 2023 22:28
CommonMark-like spec text for tables
# Through vertical-arrows (first 10 ifs)
%self total self wait child calls name
7.60 1.284 1.284 0.000 0.000 25396 String#split
5.60 0.946 0.946 0.000 0.000 117606 Array#flatten
4.08 0.690 0.690 0.000 0.000 487582 Regexp#match
4.03 1.053 0.680 0.000 0.372 393708 SCSSLint::ControlCommentProcessor#retrieve_comment_text
3.53 0.597 0.597 0.000 0.000 522139 Kernel#is_a?
3.42 0.860 0.578 0.000 0.282 396943 Enumerable#any?
3.21 0.542 0.542 0.000 0.000 492675 Kernel#class