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 / 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 {
@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 / 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')
import Ember from 'ember';
export default Ember.Component.extend({
logger: Ember.inject.service()
});
@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
@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 / delete-orig.sh
Created September 14, 2015 15:07
Remove "*.orig" after git merge
find . -name '*.orig' -delete
@samtsai
samtsai / components.my-component.js
Last active September 1, 2015 18:46 — forked from rwjblue/components.my-component.js
Set Bound Attr in `didInitAttrs`
import Ember from 'ember';
export default Ember.Component.extend({
didInitAttrs() {
this._super(...arguments);
var value = this.get('value');
if (value) {
console.log('initial value');
/* Original source: https://gist.github.com/oskarrough/914653b03d886c015320
* Modified fork: https://gist.github.com/consideRatio/761c6286158e70feaed7
*
* Working authentication with
* Firebase 2.0.x + Ember.js 1.8.1 + Ember Data Canary + EmberFire 1.3.0 + Ember CLI
* works for me! oskar@rough.dk
*
* Note: this assumes you've set up login on your Firebase,
* only handles Google and Facebook for now.
*
.gold-standard {
background-color: #FFBC31;
}
.gold-standard .inner-ring {
background-color: #FFD700;
}
.badge-ribbon {
position: relative;
height: 100px;
width: 100px;