Skip to content

Instantly share code, notes, and snippets.

View addyosmani's full-sized avatar
🎯
Focusing

Addy Osmani addyosmani

🎯
Focusing
View GitHub Profile
@addyosmani
addyosmani / 12-days.js
Last active February 3, 2016 18:31
12 Days of Christmas in ES2015 - paste this into your DevTools console!
// adapted from https://tonicdev.com/n3dst4/twelve-days-of-emoji
// full credit to n3dst4. I just rewrote this to be browser developer tools friendly.
const pressies = [
"🐦🍐🌳",
"🐢🐦",
"🇫🇷🐔",
"📞🐦",
"💛💍",
"🐦🍳 ",
"🐦🏊",
@addyosmani
addyosmani / app.yaml
Created December 2, 2015 10:10 — forked from dustintheweb/app.yaml
Google App Engine (Python) - app.yaml for hosting a static site
application: your-app-name
version: 1
runtime: python27
api_version: 1
threadsafe: true
default_expiration: "30d"
handlers:
# web files
@addyosmani
addyosmani / state.md
Last active October 8, 2015 13:11
save/restore state

tl;dr: no / it's quite hard :'(

Afaik, it's incredibly difficult to restore a highly multi-threaded system to a set state in time - doing so is non-trivial, but also comes with a heavy cost as quite a few different systems need to be in a relatively stable/safe state so you know what to save. For V8, saving state doesn't guarantee that it's possible to gather all of the information necessary to get you back to where you were in a random point in time given the various execution contexts your code is likely running in. You also need to factor in somehow serializing the different contexts in which your closures and other constructs exist in which is again not straight-forward.

For example, we might not be able to traverse the heap at that point, there may be threads that are still locked, not fully-initialized objects and so on. So at best you would be capturing an incomplete state of the world which may not scale when trying to restore the state of something quite complex. If it were possible to save state,

@addyosmani
addyosmani / suggest.md
Last active September 28, 2015 13:39
Example questions for Chrome's answer suggestions.

All platforms where Chrome ships now support suggesting answers directly inside the Omnibox (Chrome's address bar). We currently suggest answers across a few different categories including weather, finance and general knowledge (people/places/auto).

Some examples of queries to test out the feature:

  • weather
  • weather tokyo
  • how old is obama?
  • how tall is chewbacca?
  • what's the capital of spain?
  • population of china
@addyosmani
addyosmani / polymer-perf-bookmarklet.js
Last active September 8, 2015 16:04 — forked from ebidel/polymer-perf-bookmarklet.js
Polymer performance numbers bookmarklet
javascript:(function(){(function printStats(){var loadTimes=window.chrome.loadTimes();firstPaint=loadTimes.firstPaintTime*1000;firstPaintTime=firstPaint-(loadTimes.startLoadTime*1000);console.info('First paint took',firstPaintTime,'ms');console.info('Load took',performance.timing.loadEventStart-performance.timing.navigationStart,'ms');var instances=0;if(parseFloat(Polymer.version)<1){instances=[].slice.call(document.querySelectorAll('html /deep/ *')).filter(function(el){return el.localName.indexOf('-')!=-1||el.getAttribute('is');}).length;}else{instances=Polymer.telemetry.instanceCount;}console.info('Custom element instances:',instances);var reflectCount=0;if(Polymer.telemetry){console.info('=== Properties set to reflectToAttribute ===');Polymer.telemetry.registrations.forEach(function(el){for(var prop in el.properties){if(el.properties[prop].reflectToAttribute){console.log(el.is+'.'+prop);reflectCount++;}}});}else{console.info('=== Properties set to reflect ===');Polymer.elements.forEach(function(el){for(var
@addyosmani
addyosmani / monday.md
Last active August 29, 2015 14:28
Monday

Morning team!,

Hope y'all had a fantastic weekend. As requested, here's a strawman for some things we could focus on this week:

  • Wishlist for 1.1 - what do our users (and us) want to see in there? We're looking for specific features, components, docs you think we should tackle & balance with what our us. For anything we want to target, let's open an issue and consider for the 1.1 milestone unless one already exists.
  • 1.1 milestone prioritisation. We can do this later in the week.
  • Review / continue landing 1.1 PRs - feel free to grab-bag existing 1.1 PRs and continue to review/land for 1.1. If there's anything contentious, we can talk about it.
  • 1.0.4 blog post & regression fixes (if any) - we'll get the post out today. So far it's looking like .4 is stable, but let's watch the tracker
  • 1.1 target date. Sergio and I are currently thinking October 15th may be a realistic goal. A good chunk of September will be eaten up by Polymer Summit, talks, codelabs & Google perf reviews. SG?
  • Identify site fixes
@addyosmani
addyosmani / simplestDecorator.py
Last active August 29, 2015 14:24
Decorator samples
@mydecorator
def myfunc():
pass
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files
GHBU_ORG=${GHBU_ORG-"<CHANGE-ME>"} # the GitHub organization whose repos will be backed up
# (if you're backing up a user's repos instead, this should be your GitHub username)
GHBU_UNAME=${GHBU_UNAME-"<CHANGE-ME>"} # the username of a GitHub account (to use with the GitHub API)
GHBU_PASSWD=${GHBU_PASSWD-"<CHANGE-ME>"} # the password for that account
GHBU_GITHOST=${GHBU_GITHOST-"github.com"} # the GitHub hostname (see comments)
GHBU_PRUNE_OLD=${GHBU_PRUNE_OLD-true} # when `true`, old backups will be deleted
@addyosmani
addyosmani / notes.md
Last active August 10, 2022 03:59
Notes on streaming JS & long-term code compilation caching in Chrome

Re: http://blog.chromium.org/2015/03/new-javascript-techniques-for-rapid.html

V8 Optimisations to enable fast page startup

As mentioned in our Chromium blog post, Chrome 41 introduces support for streaming parsing of JavaScript files using the async or defer attributes. This is where the V8 parser will parse any incoming JavaScript piece-by-piece so the compiler can immediately begin compiling the AST when script loading has completed. This lets us do something useful while waiting for the page to load. Compare:

This means parsing can be removed from the critical path when loading up the page. In these cases such scripts are parsed on a separate thread as soon as the download begins, allowing parsing to complete very soon after the download has completed (milliseconds), leading to pages (potentially) loading much faster.

@addyosmani
addyosmani / quickie.md
Last active April 24, 2022 22:20
Phonegap/Cordova + Polymer resources

Yoyo. There are more articles/resources available than the below, but most appear to be older. To avoid the pain of upgrading finding things broken, I would try one of these. They're more recent.