Skip to content

Instantly share code, notes, and snippets.

View Kobe's full-sized avatar

Kobe Kobe

View GitHub Profile
@Kobe
Kobe / inp-devtools-watch.js
Created September 8, 2023 14:49 — forked from mmocny/inp-devtools-watch.js
Add these snippets to DevTools (console) Watch expressions
// max-INP:
(()=>{let o=globalThis;return void 0===o.winp&&(o.winp=0,new PerformanceObserver(n=>{for(let e of n.getEntries()){if(!e.interactionId)continue;o.winp=Math.max(e.duration,o.winp);let r=o=>o<=200?"color: green":o<=500?"color: yellow":"color: red";console.log(`%c[Interaction: ${e.name.padEnd(12)}] %cDuration: %c${e.duration}`,"color: grey; font-family: Consolas,monospace","",r(e.duration))}}).observe({type:"event",durationThreshold:0,buffered:!0})),o.winp})();
// interactionCount
performance.interactionCount;
@Kobe
Kobe / intl-api-price-formatting.js
Last active August 24, 2023 11:51
price formatting by Intl API
const price = 123456.789;
console.log({"de-DE": new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(price)});
console.log({"de-AT": new Intl.NumberFormat('de-AT', { style: 'currency', currency: 'EUR' }).format(price)});
console.log({"en-GB": new Intl.NumberFormat('en-GB', { style: 'currency', currency: 'GBP' }).format(price)});
console.log({"fr-FR": new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR' }).format(price)});
console.log({"it-IT": new Intl.NumberFormat('it-IT', { style: 'currency', currency: 'EUR' }).format(price)});
console.log({"es-ES": new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'EUR' }).format(price)});
@Kobe
Kobe / index.html
Created March 17, 2019 20:04
valid HTML example w/o head + body
<html lang="en">
<title>foo</title>
<p>bar
</html>
@Kobe
Kobe / ansible-macos-homebrew-packages.yml
Created March 2, 2019 17:55 — forked from mrlesmithjr/ansible-macos-homebrew-packages.yml
Install MacOS Homebrew Packages With Ansible
---
- name: Install MacOS Packages
hosts: localhost
become: false
vars:
brew_cask_packages:
- 'atom'
- 'docker'
- 'dropbox'
- 'firefox'
@Kobe
Kobe / shuffle-lunch.html
Last active January 23, 2019 08:57
shuffle JS array
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>shuffle lunch</title>
</head>
<body>
<h1>lunch people</h1>
<div id="lunch"></div>
@Kobe
Kobe / movie.2.gif.md
Created August 17, 2018 15:21
Convert movies to gif in OS X Mac

#OS X Movie to animated GIF

ffmpeg -i movie-name.mp4 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=0 --delay=3 > movie-name.gif

##Options

  • -r 10 tells ffmpeg to reduce the frame rate from 25 fps to 10
  • -s 600x400 tells ffmpeg the max-width and max-height
@Kobe
Kobe / logging.es6.js
Created June 23, 2018 11:39
logging via Ajax endpoint
import Location from './location.es6';
import { isJQueryAvailable } from './lib.es6';
export const LOG_LEVEL_DEBUG = 'DEBUG'; // eslint-disable-line no-unused-vars
export const LOG_LEVEL_INFO = 'INFO'; // eslint-disable-line no-unused-vars
export const LOG_LEVEL_WARN = 'WARN';
export const LOG_LEVEL_ERROR = 'ERROR'; // eslint-disable-line no-unused-vars
export const LOG_LEVEL_OFF = 'OFF'; // eslint-disable-line no-unused-vars
const INTERNAL_LOGGING_URL = '/clientLogger';
(function (window) {
window.sendErrorReport = function (jsonData, type) {
var url = URL + '?type=' + type;
var request = new XMLHttpRequest();
request.open('POST', url, true);
request.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
if (window.myh && window.myh.user && window.myh.user.profileId) {
jsonData.profileId = window.myh.user.profileId;
}
request.send(JSON.stringify(jsonData));
var module = module || {};
window.module.config = window.module.config || {};
window.module.config.tracking = window.module.config.tracking || {};
function tracker(window, module, trackingOptions, $) {// NOSONAR
'use strict';
var LOG_EVENT_CONSOLE = 'console';
var LOG_EVENT_ERROR = 'error';
var LOG_EVENT_EVENT_TRACKING = 'event-tracking';
@Kobe
Kobe / _color-map.scss
Last active June 23, 2018 11:40
color map + generated Colors
$site-colors: (
primary-color: #f60,
secondary-color: #ff0000,
tertiary-color: #008000,
);
@each $color, $value in $site-colors {
.styleguide .#{$color} {
background-color: $value;
color: white;