Skip to content

Instantly share code, notes, and snippets.

View hirorock's full-sized avatar

hiro / connec / THETIME hirorock

  • THE TIME, LLC.
  • Japan
View GitHub Profile
@hirorock
hirorock / add-custom-header-on-param
Last active October 11, 2024 04:45
CloudFrontFunctionで、リクエスト時にURLのGETパラメータを見てHeaderを書き換える。Viewer responseで設定する。
function handler(event) {
var request = event.request;
var response = event.response;
var headers = response.headers;
// クエリパラメーターをゴニョゴニョして、paramsオブジェクトを生成
var params = parseQueryParams(request.querystring);
// ターゲットとする、GETパラメーターのリスト
var targetParams = ['id', 's', 'utm', 'utm_source', 'keyword', 'returnURL'];
@hirorock
hirorock / ie.css
Created February 18, 2022 02:36
IE用のStyleこれでいいんじゃないか?
[data-ie-display="block"],
[data-ie-display="inline-block"] {
display: none;
}
@media (-ms-high-contrast: none), (-ms-high-contrast: active) {
[data-ie-display="block"] {
display: block !important;
}
@hirorock
hirorock / svg2base64.js
Last active December 15, 2021 06:08
SVGタグをbase64エンコードする。
btoa(unescape(encodeURIComponent(
`<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false"><path d="M5 9v6h14V9H5zm11-4.8H8v1.5h8V4.2zM8 19.8h8v-1.5H8v1.5z"></path></svg>`
)));
@hirorock
hirorock / tiny-glob
Created March 31, 2021 03:14
globをかんたんに使う
const glob = require("tiny-glob");
(async () => {
let entryPoints = await glob("./assets/dev/js/**/*.js");
console.log({entryPoints});
})();
@hirorock
hirorock / Measure Paint
Created October 22, 2020 05:44
Performance measurements with reference to W3C, MDN, and "超速本", for DevTools.
for (const paint of performance.getEntriesByType('paint')) {
console.table({
'Name': paint.name,
'Entry Type': paint.entryType,
'Start Time': paint.startTime / 1000,
'Duration': paint.duration / 1000,
})
}
@hirorock
hirorock / Measure performance
Last active October 16, 2020 03:32
Performance measurements with reference to W3C, MDN, and "超速本", for DevTools.
const { timing } = performance;
console.table({
'Unload': (timing.unloadEventEnd - timing.unloadEventStart) / 1000,
'Redirect': (timing.redirectEnd - timing.redirectStart) / 1000,
'App Cache': (timing.domainLookupEnd - timing.domainLookupStart) / 1000,
'DNS': (timing.domainLookupEnd - timing.domainLookupStart) / 1000,
'TCP': (timing.connectEnd - timing.connectStart) / 1000,
'Request': (timing.responseStart - timing.requestStart) / 1000,
'Response': (timing.responseEnd - timing.responseStart) / 1000,
'Processing': (timing.domComplete - timing.domLoading) / 1000,
@hirorock
hirorock / gulpfile.js
Last active January 18, 2016 12:02
gulp.spritesmithを使う時の実装メモ
var gulp = require('gulp'),
plumber = require('gulp-plumber'),//エラー発生時もタスクを継続する
notify = require('gulp-notify'),//エラー通知
using = require('gulp-using'),//
spritesmith = require('gulp.spritesmith');
gulp.task('default', function () {
var spriteData = gulp.src('src/images/sprite/**/*.png')
.pipe(plumber({