Skip to content

Instantly share code, notes, and snippets.

Avatar
💩
[object Object]

dasDaniel

💩
[object Object]
View GitHub Profile
@dasDaniel
dasDaniel / logAssert.spec.js
Created Oct 16, 2020
cypress - check if log message was recorded
View logAssert.spec.js
const spyConsoleLog = () => {
let logs = [];
const findLog = fragment => logs.find(message => (message + "").indexOf(fragment) >= 0);
Cypress.on("window:before:load", win => {
let clog = win.console.log;
win.console.log = (...arg) => {
logs.push(arg.join(" "));
clog.apply(console, arg);
};
});
View _is_y.sh
#!/bin/bash
echo -n "Continue (y/n)? "
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
echo Yes
install_thing
else
echo No
@dasDaniel
dasDaniel / vue-test-utils-helpers.js
Last active Mar 26, 2019
helper functions for vue-test-utils
View vue-test-utils-helpers.js
function withWrapperArray(wrapperArray) {
return {
childSelectorHasText: (selector, str) => wrapperArray.filter(i => i.find(selector).text().match(str)),
hasText: (str) => wrapperArray.filter(i => i.text().match(str)),
areVisible: () => wrapperArray.wrappers.filter(w => w.isVisible()).length,
areHidden: () => wrapperArray.wrappers.filter(w => !w.isVisible()).length,
areAllVisible: () => wrapperArray.wrappers.every(w => w.isVisible()),
areAllHidden: () => wrapperArray.wrappers.every(w => !w.isVisible()),
}
}
View day03.js
function onGLC(glc) {
glc.loop();
glc.size(400, 400);
glc.setDuration(1.5);
glc.setFPS(30);
glc.setMode('single');
glc.setEasing(false);
glc.styles.backgroundColor = "#000000";
var list = glc.renderList,
width = glc.w,
@dasDaniel
dasDaniel / BaseAlert.vue
Last active Apr 6, 2018
Functional Base Component with class and style inheritance
View BaseAlert.vue
<template functional>
<div :class="['alert', data.class, data.staticClass].join(' ')" :style="data.style">
<slot name="icon">
</slot>
<slot name="body">
</slot>
</div>
</template>
@dasDaniel
dasDaniel / selector-example.js
Last active Feb 21, 2018
Testcafe does not trim values, and IE/Edge seems to keep the whitespace. This solution trims in-line
View selector-example.js
/*
<div class="el-with-whitespace>
No spaces at the end
</div>
*/
await t.expect(await Selector('.el-with-whitespace').innerText.then(v => v.trim())).eql('No spaces at the end')
// it requires the `await t` otherwise the element doesn't check the updated value
View index.html
<div id="demo" class="demo">
<button v-on:click="add">Add</button>
<canvas id="assetcanvas" width="200" height="200"></canvas>
</div>
View designer.html
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<polymer-element name="my-element">
@dasDaniel
dasDaniel / deparam
Created Oct 27, 2013
deparam javascript split serialized string with square bracket items. ref http://jsfiddle.net/drzaus/8EE8k/
View deparam
deparam = (function(d,x,params,pair,i) {
return function (qs) {
params = {};
// remove preceding non-querystring, correct spaces, and split
qs = qs.substring(qs.indexOf('?')+1).replace(x,' ').split('&');
// march and parse
for (i = qs.length; i > 0;) {
pair = qs[--i].split('=');
//params[d(pair[0])] = d(pair[1]);
You can’t perform that action at this time.