Skip to content

Instantly share code, notes, and snippets.

Justin Fagnani justinfagnani

View GitHub Profile
View gist:6675416
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 Jul 17, 2014
code_transformers / analyzer
View gist:8e0b18cf4604f039c859
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);
View quiver_retry_2.dart
/// 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(
View quick-alert.html
<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 Aug 29, 2015
Dependency Resolution with Events
View gist:6aec137ed97cfa3db002
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
View gist-server.json
{
"polymer": "https://raw.githubusercontent.com/Polymer/polymer/v1.0.7/",
"webcomponentsjs": "https://raw.githubusercontent.com/webcomponents/webcomponentsjs/v0.7.7/"
}
View gist-server.json
{
"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/"
}
View designer.html
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
View index.html
<!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 Oct 8, 2017
Web Components Conformance Tests
View custom-element-conformance.js
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();
You can’t perform that action at this time.