This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getIframeDocument = () => { | |
return cy | |
.get('iframe[title="YouTube video player"]]') | |
// Cypress yields jQuery element, which has the real | |
// DOM element under property "0". | |
// From the real DOM iframe element we can get | |
// the "document" element, it is stored in "contentDocument" property | |
// Cypress "its" command can access deep properties using dot notation | |
// https://on.cypress.io/its | |
.its('0.contentDocument').should('exist') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getIframeDocument = () => { | |
return cy | |
.get('iframe[title="Trailer"]]') | |
// Cypress yields jQuery element, which has the real | |
// DOM element under property "0". | |
// From the real DOM iframe element we can get | |
// the "document" element, it is stored in "contentDocument" property | |
// Cypress "its" command can access deep properties using dot notation | |
// https://on.cypress.io/its | |
.its('0.contentDocument').should('exist') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ranks = '23456789TJQKA'; | |
const suits = '♥♦♣♠'; | |
// Fake class for hand | |
// replace with importing real class | |
class Hand { | |
constructor() { | |
console.log([...arguments]) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simplify states, contexts and binding to forms | |
// ironboy 2022 | |
import { useState, useDebugValue } from 'react'; | |
const savedStates = {}; | |
export function useStates(initObj, contextName) { | |
typeof initObj === 'string' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Omits the need to write 'key={someUniqueKey}' | |
// for elements in list when mapping them to jsx | |
// - automatically tries to get the key from id or _id, | |
// if not possible, uses the array index instead | |
let ap = Array.prototype; | |
if (!ap._mapNoAutoKey) { | |
let org = ap._mapNoAutoKey = ap.map; | |
ap.map = function (...args) { | |
// get ids/unique keys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | |
window.onXhr = require('on-xmlhttprequest'); | |
},{"on-xmlhttprequest":2}],2:[function(require,module,exports){ | |
var EventEmitter = require('events').EventEmitter; | |
var oldOpen = window.XMLHttpRequest.prototype.open; | |
module.exports = function (onrequest) { | |
function open () { | |
var emitter = new EventEmitter(); | |
var xhr = this; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Thread | |
from datetime import datetime | |
from network import connect, send | |
# convert timestamp to iso date time format | |
def timestamp_to_iso(timestamp): | |
return datetime.fromtimestamp(timestamp / 1000)\ | |
.isoformat().replace('T', ' ').split('.')[0] | |
def send_message(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lStore(key,val){ | |
var parsed = JSON.parse(localStorage.store || '{}'); | |
if(val === undefined){ | |
// read | |
return parsed[key]; | |
} | |
// write | |
parsed[key] = val; | |
localStorage.store = JSON.stringify(parsed); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(!window.jQuery){ | |
var scr = document.createElement('script'); | |
scr.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js'; | |
document.getElementsByTagName('head')[0].appendChild(scr); | |
} | |
var jwait = setInterval(function(){ | |
if(!window.jQuery){return;} | |
clearInterval(jwait); | |
var $ = jQuery; | |
var table = $('#ppfdata').contents().find('.file-archive-table'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The supershort version | |
// with no extras (as super, named constructors etc.) | |
// And nice way to handle inheritance is by creating a base object | |
// with an extend method | |
var Base = { | |
extend: function(props){ | |
// A new object with this object as its prototype | |
var t = this, obj = Object.create(t); | |
// Assign properties to the new object |
NewerOlder