Skip to content

Instantly share code, notes, and snippets.

try {
doSomething()
} catch(error) {
Raven.captureException(error)
}
library cookie;
import 'dart:html';
/*
* dart document.cookie lib
*
* ported from
* http://www.quirksmode.org/js/cookies.html
*
<x-secret placeholder="Choose a Password"></x-secret>
@nikgraf
nikgraf / chai-react-shallow.js
Created December 18, 2015 07:37
Chai React Shallow Testing
import {findAll} from 'react-shallow-testutils';
import objectMatches from 'object-matches';
import inspectReactElement from 'inspect-react-element';
const findAllMatching = (rootElementTree, elementTreeToMatch) => {
return findAll(rootElementTree, (element) => {
// In case a null is passed for a template value
if (element === null) return false;
const matchType = (elementTreeToMatch.type ? element.type === elementTreeToMatch.type : true);
@nikgraf
nikgraf / run_dartium.dart
Created July 12, 2013 23:45
A small script to start Dartium with type checks and asserts enabled on OSX. To run it you need the Dart editor and added the `dart` command to $PATH
#!/usr/bin/env dart
import 'dart:io';
import 'dart:async';
main() {
// find and run Dartium with type checks and asserts enabled
var whichDart = Process.run('which', ['dart']);
whichDart.then((command) {
var dartiumExecutable = new Path(command.stdout).join(new Path('../../../chromium/Chromium.app/Contents/MacOS/Chromium'));
void main() {
}
import 'dart:async';
import 'package:polymer/polymer.dart';
import 'package:observe/observe.dart';
class CountdownClock extends CustomElement with ObservableMixin {
static final oneSecond = new Duration(seconds: 1);
@observable var timeLeft = new Duration(seconds: 72);
/*
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="import" href="countdown_clock.html">
</head>
<body>
<h1>Alarm</h1>
<div is="countdown-clock"></div>
<script type="application/dart" src="alarm.dart"></script>
import 'package:mdv/mdv.dart' as mdv;
void main() {
mdv.initialize();
}
@nikgraf
nikgraf / UnicornEditor.js
Created February 25, 2016 19:00
someOtherVariable doesn't trigger an error!?
type UnicornEditorState = {
editorState: any,
}
export default class UnicornEditor extends Component {
state: UnicornEditorState = {
editorState: EditorState.createEmpty(compositeDecorator),
someOtherVariable: 'Should throw an error?',
};