Skip to content

Instantly share code, notes, and snippets.

View justinfagnani's full-sized avatar

Justin Fagnani justinfagnani

View GitHub Profile
import 'dart:async';
import 'package:postgresql/postgresql.dart';
void main() {
var username = "TheRightMan";
var password = "WithTheRightSecret";
var DBname = "AtTheRightPlace";
var uri = 'postgres://$username:$password@localhost:5432/$DBname';
@justinfagnani
justinfagnani / gist:8e0b18cf4604f039c859
Created July 17, 2014 00:53
code_transformers / analyzer
class InterfaceTransformer extends Transformer with ResolverTransformer {
final Resolvers resolvers;
InterfaceTransformer(this.resolvers);
Future<bool> isPrimary(AssetId id) => new Future.value(id.extension == '.dart');
Future<bool> shouldApplyResolver(Asset asset) {
return asset.readAsString().then((contents) {
var cu = parseCompilationUnit(contents, suppressErrors: true);
/// Returns a [Duration] if another attempt needs to be made after
/// waiting for the returned [Duration]. Returns the error object
/// that instructs the retry mechanism to stop trying and report error
/// immediately.
typedef dynamic OnErrorFunc(Object err, int retry, Duration elapsed);
/// `onError` returns either [Duration] or an error object. If [Duration]
/// is returned, the `attempt` function will be retried after waiting
/// for the returned duration, otherwise the retry mechanism gives up
/// and evaluates the [Future] with the the error object.
Future start(
<link rel="import" href="bower_components/polymer/polymer.html">
<dom-module id="quick-alert">
<style>
:host {
display: block;
position: fixed;
top: 0;
left: 0;
right: 0;
@justinfagnani
justinfagnani / gist:6aec137ed97cfa3db002
Last active August 29, 2015 14:22
Dependency Resolution with Events
Polymer({
is: 'x-foo',
ready() {
// provides a FooService to descendents
this.provideInstance('foo-service', new FooService());
},
attached() {
// requests a BarService from an ancestor, re-requests if moved
@justinfagnani
justinfagnani / gist-server.json
Last active August 29, 2015 14:25
gist-server test
{
"polymer": "https://raw.githubusercontent.com/Polymer/polymer/v1.0.7/",
"webcomponentsjs": "https://raw.githubusercontent.com/webcomponents/webcomponentsjs/v0.7.7/"
}
{
"font-roboto": "https://raw.githubusercontent.com/PolymerElements/font-roboto/v1.0.1/",
"iron-flex-layout": "https://raw.githubusercontent.com/PolymerElements/iron-flex-layout/v1.0.2/",
"paper-material": "https://raw.githubusercontent.com/PolymerElements/paper-material/v1.0.1/",
"paper-styles": "https://raw.githubusercontent.com/PolymerElements/paper-styles/v1.0.10/",
"polymer": "https://raw.githubusercontent.com/Polymer/polymer/v1.0.7/",
"webcomponentsjs": "https://raw.githubusercontent.com/webcomponents/webcomponentsjs/v0.7.7/"
}
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
<!doctype html>
<html>
<head>
<script src="shadow-root.js"></script>
</head>
<div>
<div slot="main">
I'm some projected content.
</div>
<shadow-root>
@justinfagnani
justinfagnani / custom-element-conformance.js
Created October 8, 2017 22:38
Web Components Conformance Tests
const NativeHTMLElement = window.HTMLElement;
const documentWrite = document.write;
const documentOpen = document.open;
window.HTMLElement = class extends NativeHTMLElement {
constructor(...args) {
console.assert(args.length === 0);
super();