Skip to content

Instantly share code, notes, and snippets.

Cezary Nowak CezaryDanielNowak

Block or report user

Report or block CezaryDanielNowak

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View async-confirm.js
/**
* This function replaces built-in `confirm` function, but it's async
* Sample usage:
const exitFullscreen = await confirm('Do you really want to exit full-screen mode?');
* @param {String} askText Text to display on the dialog
* @param {Array} buttonText Array with captions of the buttons
* @return {Promise} Resolves with true or false
*/
function confirm(askText = '', buttonText = ['Cancel', 'OK']) {
View all-video-events
x = `abort Sent when playback is aborted; for example, if the media is playing and is restarted from the beginning, this event is sent.
canplay Sent when enough data is available that the media can be played, at least for a couple of frames. This corresponds to the HAVE_ENOUGH_DATA readyState.
canplaythrough Sent when the ready state changes to CAN_PLAY_THROUGH, indicating that the entire media can be played without interruption, assuming the download rate remains at least at the current level. It will also be fired when playback is toggled between paused and playing. Note: Manually setting the currentTime will eventually fire a canplaythrough event in firefox. Other browsers might not fire this event.
durationchange The metadata has loaded or changed, indicating a change in duration of the media. This is sent, for example, when the media has loaded enough that the duration is known.
emptied The media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded
View allegro-get-images.js
// Open gallery and run from console:
const images = $$('div[style="transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1);"] img')
const result = images.map((img, i) => {
return `<a href="${img.src}" download="Img${i}">${img.src}</a>`;
});
document.body.innerHTML = result.join('<br />')
View PlayAround.js
import React from 'react';
import atom from 'atom-js';
import PageTitle from 'components/PageTitle';
import BasePage from 'pages/BasePage';
import Button from 'sf/components/Button';
import JsonPrettyPrint from 'sf/components/JsonPrettyPrint';
import PhotoCaptureButton from 'sf/components/PhotoCaptureButton';
import ValidationInput from 'sf/components/ValidationInput';
View test.js
var values = [...new Array(32000000)].map((_, i) => i);
console.time('map + reduce');
window.sum1 = values.map(x => x*x).reduce( (total,num,index,array) => total+num,0.0);
console.timeEnd('map + reduce');
console.time('reduce');
window.sum2 = values.reduce( (total,num,index,array) => total+num*num,0.0);
console.timeEnd('reduce');
View webpack-copy-directory-solutions.js
// Solution 1:
require.context('./sf/assets/', true, /\.(png|jpe?g|svg)$/);
// Solution 2:
new CopyPlugin([
{ from: path.resolve(paths.appSrc, 'sf/assets') , to: paths.appBuild},
]),
// Testing in dev server:
https://localhost:3000/webpack-dev-server
View no-respect.js
(function() {
var n, walk = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);
while (n = walk.nextNode()) { if (n.nodeValue.trim()) n.nodeValue += ", fockin' cunt!" };
})();
View fast-babel-prototyping.html
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
<title>react-fns with script tags</title>
<!-- Load React -->
<script src="https://unpkg.com/react/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script>
<!-- Load babel for JSX -->
View pardot-custom-thank-you.js
var origin = document.referrer.replace(/^((\w+:)?\/\/[^\/]+\/?).*$/,'$1').replace(/\/$/, '');
try {
parent.postMessage('pardot_form_success', origin);
} catch (e) {
window.console && window.console.log(e);
}
View JIRA - Add ticket description next to ID
// ==UserScript==
// @name Add ticket description next to ID
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://10clouds.atlassian.net/*
// @grant none
// ==/UserScript==
You can’t perform that action at this time.