Skip to content

Instantly share code, notes, and snippets.

View samtsai's full-sized avatar
🏠
Working from home

Sam Tsai samtsai

🏠
Working from home
View GitHub Profile
@samtsai
samtsai / components.my-component.js
Created June 14, 2016 21:29 — forked from jpadilla/components.my-component.js
Component Lifecycle Hooks
import Ember from 'ember';
export default Ember.Component.extend({
init(options) {
console.log('init', options);
},
didUpdateAttrs(options) {
console.log('didUpdateAttrs', options);
},
@samtsai
samtsai / asap.js
Last active February 21, 2017 19:32
As soon as possible - simple asynchronous script loading library
// ASAP Library
// use case
/*
add omniture to registry
omniture tags are waiting to fire
asap loads omniture asynchronously
page waits for omniture to be ready
omniture loads
asap announces omniture is ready
import Ember from 'ember';
export default Ember.Component.extend({
logger: Ember.inject.service()
});
@samtsai
samtsai / selection-command.js
Last active March 6, 2021 19:37 — forked from erquhart/selection-command.js
Text selection commands for Cypress.io
/**
* Credits
* @Bkucera: https://github.com/cypress-io/cypress/issues/2839#issuecomment-447012818
* @Phrogz: https://stackoverflow.com/a/10730777/1556245
*
* Usage
* ```
* // Types "foo" and then selects "fo"
* cy.get('input')
* .type('foo')
@samtsai
samtsai / billion.xml
Created January 27, 2021 22:10
Test Billion laughs
<?xml version="1.0"?>
<!DOCTYPE lolz [
<!ENTITY lol "lol">
<!ELEMENT lolz (#PCDATA)>
<!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
<!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">
<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">
@samtsai
samtsai / cy-all.ts
Created April 18, 2022 18:22
Typed `cy.all([...])` command for Cypress consumers
// @see https://github.com/cypress-io/cypress/issues/915#issuecomment-475862672
// Modified due to changes to `cy.queue` https://github.com/cypress-io/cypress/pull/17448
// Note: this DOES NOT run Promises in parallel like `Promise.all` due to the nature
// of Cypress promise-like objects and command queue. This only makes it convenient to use the same
// API but runs the commands sequentially.
declare namespace Cypress {
type ChainableValue<T> = T extends Cypress.Chainable<infer V> ? V : T
interface cy {