Skip to content

Instantly share code, notes, and snippets.

View mefjuu's full-sized avatar
🎯
Focusing

Mateusz Janik mefjuu

🎯
Focusing
View GitHub Profile
@mefjuu
mefjuu / appstore-bookmarklets.js
Last active November 5, 2020 12:41
App Store bookmarklet for copy-paste an app's "What's new" and "Promotional Text" between languages / versions
javascript:(function copyFromCurrentLanguage(){
if (!document.hasFocus()) {
window.alert("Click the document body first");
return;
}
const promotionalText = document.querySelector("#promotionalText").innerText;
const whatsNew = document.querySelector("#whatsNew").innerText;
const data = {
@mefjuu
mefjuu / updating-external-data-when-props-changes-using-promises.js
Created February 1, 2019 08:34 — forked from bvaughn/updating-external-data-when-props-changes-using-promises.js
Example for loading new external data in response to updated props
// This is an example of how to fetch external data in response to updated props,
// If you are using an async mechanism that does not support cancellation (e.g. a Promise).
class ExampleComponent extends React.Component {
_currentId = null;
state = {
externalData: null
};
@mefjuu
mefjuu / quantitynounvariant.js
Created December 9, 2014 07:02
Returns noun variant for specified number
/**
* Returns noun variant for specified quantity
*
* @param {integer} n e.g. 5
* @param {array} nounVariants e.g. ["produkt", "produkty", "produktów"]
* @param {string} template Optional template ('$1 $2' as default)
*
* @return {string} e.g. "5 produktów"
*/
function quantityNounVariant(n, variants, template) {