This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:convert'; | |
import 'package:http/http.dart' as http; | |
const BGGLOGIN_URL = 'https://boardgamegeek.com/login/api/v1'; | |
const BGGUPLOAD_URL = 'https://boardgamegeek.com/geekplay.php'; | |
enum UploadResult { | |
Success, | |
UsernamePassword, | |
NetworkError, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyListNotifier extends ValueNotifier<MyList> { | |
MyListNotifier(MyList myList) : super(myList) { | |
value.setNotifyListeners(notifyListeners); | |
} | |
} | |
class MyList<E> extends List<E> { | |
VoidCallback _notifyListeners; | |
void setNotifyListeners(VoidCallback notifyListeners) { | |
this.notifyListeners = notifyListeners; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyWidget extends StatefulWidget { | |
final GlobalKey myKey = GlobalKey(); | |
MyWidget(); | |
@override | |
State<StatefulWidget> createState() => MyWidgetState(); | |
} | |
class MyWidgetState extends State<MyWidget> { | |
@override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var items= document.getElementsByClassName("highlight") | |
var lines= [] | |
for(var i= 0; i < items.length; i++) lines.push(items[i].innerText) | |
copy(lines.join("\n\n")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This pattern is useful when using context in React to pass values down | |
the component tree. The example I use here is localization but I use it every | |
time I use contexts in React | |
*/ | |
/* | |
Locale is a Higher Order Component that creates the "locale" context. Components | |
that are locale sensitive can use this context value to both get the active | |
locale and to be notified when the locale changes. It also puts the function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let promises= [...] | |
function wrap(inner) { | |
let outer= new Promise() | |
inner.then(result => { | |
outer.resolve(result) | |
}).catch(error) { | |
outer.resolve(error) | |
} | |
return outer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Drag & Drop | |
*/ | |
var parent= document.getElementById('parent'); | |
var widget= document.getElementById('widget'); | |
var mouseDowns= Observable.fromEvent(widget, 'mousedown'); | |
var parentMouseMoves= Observable.fromEvent(parent, 'mousemove'); | |
var parentMouseUp= Observable.fromEvent(parent, 'mosueup'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# go sloc | |
find . -name "*.go" | grep -v test.go | xargs wc -l | sort -n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prop(obj, name, get, set) { | |
var base= name.substr(0,1).toUpperCase() + name.substr(1); | |
if(!get) { | |
get= function() { | |
return this['_' + name]; | |
}; | |
} | |
if(!set) { | |
set= function(v) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://toddmotto.com/opinionated-angular-js-styleguide-for-teams/ | |
(function() { | |
/** | |
* Describe controller | |
* | |
* @param $scope | |
* @param p1 | |
* @constructor | |
*/ |
NewerOlder