Skip to content

Instantly share code, notes, and snippets.

View mhevery's full-sized avatar

Miško Hevery mhevery

View GitHub Profile
@mhevery
mhevery / LandingPage.builder.tsx
Last active May 19, 2022 03:14
Value of Builder.io Slides
export function LandingPage() {
return (
<>
<div class="hero">
<img src="./hero.jpg"/>
<span>10% SALE</span>
</div>
<ProductCard sku="MB002"/>
</>
);
# Overview
Github has a feature where the reviewer can suggest inline edits to a PR in side of a comment.
This is super usefull feature. PR owner can than accept these changes by accepting the suggestions and merging
them into the PR directly from the UI.
@mhevery
mhevery / microsyntax.md
Last active November 21, 2022 09:53
Angular microsyntax gramar

Microsyntax

Microsyntax in Angular allows you to write <div *ngFor="let item of items">{{item}}</div> instead of <ng-template ngFor [ngForOf]="items"><div>{{item}}</div></ng-template.

Constraints

The microsyntax must:

  • be know ahead of time so that IDEs can parse it without knowing what is the underlying semantics of the directive or what directives are present.
  • must translate to key-value attributes in the DOM.
/**
* Zone is a mechanism for intercepting and keeping track of asynchronous work.
*
* A Zone is a global object which is configured with rules about how to intercept and keep track
* of the asynchronous callbacks. Zone has these responsibilities:
*
* 1. Intercept asynchronous task scheduling
* 2. Wrap callbacks for error-handling and zone tracking across async operations.
* 3. Provide a way to attach data to zones
* 4. Provide a context specific last frame error handling
@mhevery
mhevery / Zone.md
Last active March 30, 2022 11:54
TC39 Zone Proposal

Zone Motivation

Make writing asynchronous code easier by having a consistent way of propagating "context" across related asynchronous operations. Have the "context" be responsible for async-local-storage, allowing the execution before and after hooks, and "context"-local error handling. Finally make sure that the "context"s are composable.

This feature needs to be part of the platform so that library and framework authors can relay on a common well know API, otherwise adoption will be limited.

@mhevery
mhevery / examples.md
Last active July 27, 2017 09:08
TC39 Zone API Proposal

Monkey patching common browser APIs

Here is an example of how browser APIs could be patched to take advantage of Zone propagation.

setTimeout

Ideally we would not need to do this, since the browser would do this for us.

window.setTimeout = ((delegate) => {
@mhevery
mhevery / example.ts
Last active June 1, 2017 08:06
Angular2: NgProbe Design
// https://gist.github.com/mhevery/4b1bdb59a8c16f9cbe76
/// <reference path="probe.d.ts" />
///////////////////////
/// WORK IN PROGRESS //
///////////////////////
var appRef: ApplicationRef = ng.platform.applications[0];
#!/bin/sh
curl http://storage.googleapis.com/dart-archive/channels/dev/release/latest/editor/darteditor-macos-x64.zip > ~/Downloads/darteditor-macos-64-dev.zip;
echo Fetched new dart version $(unzip -p ~/Downloads/darteditor-macos-64-dev.zip dart/dart-sdk/version)
rm -rf /Applications/dart-dev ;
unzip ~/Downloads/darteditor-macos-64-dev.zip -d /tmp > /dev/null
mv /tmp/dart /Applications/dart-dev
curl http://storage.googleapis.com/dart-archive/channels/stable/release/latest/editor/darteditor-macos-x64.zip > ~/Downloads/darteditor-macos-64.zip;
echo Fetched new dart version $(unzip -p ~/Downloads/darteditor-macos-64.zip dart/dart-sdk/version)
rm -rf /Applications/dart ;
When you go to bleeding edge you should change to:
@NgController {
selector: '[ng-controller=AppointmentCtrl]',
publishAs: 'ctrl'
}
class AppointmentCtrl {
String appointmentText = '';
List appointments = [{'time': '08:00', 'title': 'Wake Up'}];
@mhevery
mhevery / angular-issue-1051.html
Created June 13, 2012 18:37
angular-issue-1051
<html ng-app>
<head>
<script type="text/javascript" src="http://code.angularjs.org/1.0.0rc12/angular-1.0.0rc12.min.js"></script>
<script>
function Test($scope, $location) {
$scope.away = 'away';
}
</script>
</head>
<body ng-controller="Test">