Skip to content

Instantly share code, notes, and snippets.

View kevmoo's full-sized avatar
🤘
Crankin!

Kevin Moore kevmoo

🤘
Crankin!
View GitHub Profile
@kevmoo
kevmoo / whitespace.rb
Created October 7, 2009 17:38
A ruby script for whitespace clean-up
#!/usr/bin/env ruby
# Take a file_name
# If there are any "bad" lines:
# => Print out the file name
# => Print out the offending line numbers
# => Overwrite the file with "good" lines
# You might want to make sure *everything* is in source control first
# It's "good form" to have mass white-space clean-up be a single check-in, too
def clean_whitespace(file_name)
# So this is completely gone now
# Moved to my own brew recipes collection at
# https://github.com/kevmoo/homebrew-kevmoo
# Run this:
# brew tap kevmoo/kevmoo
# and you'll be good to go!
@kevmoo
kevmoo / async_demo.dart
Created June 17, 2012 16:45
Async crash in Dartium - 8641
#import('dart:html');
#import('dart:isolate');
SendPort sender;
ReceivePort receiver;
main(){
CanvasElement canvas = document.query("#content");
canvas.on.mouseMove.add(mouse);
canvas.on.mouseOut.add(mouse);
@kevmoo
kevmoo / mixin_class.dart
Last active December 19, 2015 22:58
Dart Bug: mixins with aliased imports Repo for https://code.google.com/p/dart/issues/detail?id=11891
library mixin_library;
import 'dart:json' as json;
class MixinClass {
String bar() => json.stringify({'a':1});
}
@kevmoo
kevmoo / lazy_iterable.dart
Last active January 4, 2016 20:10
Lazy Iterable
import 'dart:collection';
void main() {
var list = new WatchList([1,2,3,4,5]);
var mapped = list.where((x) => x.isEven).map((x) => x*2);
// What is printed here?
print(list.accessCount);
@kevmoo
kevmoo / pre-commit
Last active September 2, 2020 11:19
Pre-commit hook to format Dart code
# Inspired by https://robots.thoughtbot.com/use-git-hooks-to-automate-annoying-tasks
dart_files=$(git diff --cached --name-only --diff-filter=ACM | grep '.dart$')
[ -z "$dart_files" ] && exit 0
function checkfmt() {
unformatted=$(dartfmt -n $dart_files)
[ -z "$unformatted" ] && return 0
@kevmoo
kevmoo / docker_log_last.dart
Created June 18, 2015 16:12
When using App Engine, docker containers are constantly restarting. Use this to keep a finger on the logs.
#!/usr/bin/env dart
import 'dart:async';
import 'dart:convert';
import 'dart:io';
const _splitter = const LineSplitter();
const _waitDuration = const Duration(milliseconds: 250);
const _green = '\u001b[32m';

Keybase proof

I hereby claim:

  • I am kevmoo on github.
  • I am kevmoo (https://keybase.io/kevmoo) on keybase.
  • I have a public key whose fingerprint is 9355 AC2E 028E 65FC D971 3458 829C 1FBA D2A1 9840

To claim this, I am signing this object:

@kevmoo
kevmoo / uuidv4.dart
Created March 16, 2017 01:38
easy uuid-v4 for dart
// Ran with http://www.cryptosys.net/pki/uuid-rfc4122.html
import 'dart:math' as m;
void main() {
for (var i = 0; i < 1000000; i++) {
var thing = getThing();
print(thing);
print(thing.length);
diff --git a/index_2-dev-32.tree.json b/terry_chrome_fun.tree.json
index 49d9b3a..553260a 100644
--- a/index_2-dev-32.tree.json
+++ b/terry_chrome_fun.tree.json
@@ -1491,6 +1491,14 @@
"method: dart:core.Pattern.matchAsPrefix"
]
},
+ {
+ "name": "class: dart:core.pragma",