Skip to content

Instantly share code, notes, and snippets.

View jiyuujin's full-sized avatar
🐬
o(^_-)O

YUMA Kitamura jiyuujin

🐬
o(^_-)O
View GitHub Profile
@jiyuujin
jiyuujin / countCharactersIncludedEmoji.ts
Created September 16, 2021 23:51
絵文字を考慮して数える
/**
* 絵文字を含む場合の文字数 (サロゲートペアと呼ばれる領域を間引く)
* @param val 対象文字列
*/
export const countCharactersIncludedEmoji = (val: string): number => {
return val?.toString().length - (val?.toString().split(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g).length - 1);
};
@jiyuujin
jiyuujin / machineDependentWordPattern.ts
Last active February 9, 2022 11:26
機種依存文字を抽出する
export const targetText = "①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑯⑰⑱⑲⑳ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ㍉㌔㌢㍍㌘㌧㌃㌶㍑㍗㌍㌦㌣㌫㍊㌻㎜㎝㎞㎎㎏㏄㎡㍻〝〟№㏍℡㊤㊥㊦㊧㊨㈱㈲㈹㍾㍽㍼∮∟⊿纊褜鍈銈蓜俉炻昱棈鋹曻彅丨仡仼伀伃伹佖侒侊侚侔俍偀倢俿倞偆偰偂傔僴僘兊兤冝冾凬刕劜劦勀勛匀匇匤卲厓厲叝﨎咜咊咩哿喆坙坥垬埈埇﨏增墲夋奓奛奝奣妤妺孖寀甯寘寬尞岦岺峵崧嵓﨑嵂嵭嶸嶹巐弡弴彧德忞恝悅悊惞惕愠惲愑愷愰憘戓抦揵摠撝擎敎昀昕昻昉昮昞昤晥晗晙晳暙暠暲暿曺朎杦枻桒柀栁桄棏﨓楨﨔榘槢樰橫橆橳橾櫢櫤毖氿汜沆汯泚洄涇浯涖涬淏淸淲淼渹湜渧渼溿澈澵濵瀅瀇瀨炅炫焏焄煜煆煇凞燁燾犱犾猤獷玽珉珖珣珒琇珵琦琪琩琮瑢璉璟甁畯皂皜皞皛皦睆劯砡硎硤礰禔禛竑竧竫箞絈絜綷綠緖繒罇羡茁荢荿菇菶葈蒴蕓蕙蕫﨟薰蘒﨡蠇裵訒訷詹誧誾諟諶譓譿賰賴贒赶﨣軏﨤遧郞鄕鄧釚釗釞釭釮釤釥鈆鈐鈊鈺鉀鈼鉎鉙鉑鈹鉧銧鉷鉸鋧鋗鋙鋐﨧鋕鋠鋓錥錡鋻﨨錞鋿錝錂鍰鍗鎤鏆鏞鏸鐱鑅鑈閒﨩隝隯霳霻靃靍靏靑靕顗顥餧馞驎髙髜魵魲鮏鮱鮻鰀鵰鵫鸙黑ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ¬¦'"≒≡∫∑√⊥∠∵∩∪€㍵〷☯☸☬☤☡℆℅℄℁℀⁀‿‷‶‵‴‱🔣✇☣㈳㈴㈵㈶㈷㈸㈺㈻㈼㈽㈾㈿㉀㉁㉂㉃㈪㈫㈬㈭㈮㈯㈰❶❷❸❹❺❻❼❽❾❿➊➋➌➍➎➏➐➑➒➓⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇₁₂₃₄₅₆₇₈₉¹²³⁴⁵⁶⁷⁸⁹㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩㊀㊁㊂㊃㊄㊅㊆㊇㊈㊉⑮㉑㉒㉓㉔㉕㉖㉗㉘㉙㉚㉛㉜㉝㉞㉟㊱㊲㊳㊴㊵㊶㊷㊸㊹㊺㊻㊼㊽㊾㊿㋿塚朗晴猪凞礼神硺祥福靖精羽蘒諸逸隆飯飼鶴館";
export const separationText = "①|②|③|④|⑤|⑥|⑦|⑧|⑨|⑩|⑪|⑫|⑬|⑭|⑯|⑰|⑱|⑲|⑳|Ⅰ|Ⅱ|Ⅲ|Ⅳ|Ⅴ|Ⅵ|Ⅶ|Ⅷ|Ⅸ|Ⅹ|㍉|㌔|㌢|㍍|㌘|㌧|㌃|㌶|㍑|㍗|㌍|㌦|㌣|㌫|㍊|㌻|㎜|㎝|㎞|㎎|㎏|㏄|㎡|㍻|〝|〟|№|㏍|℡|㊤|㊥|㊦|㊧|㊨|㈱|㈲|㈹|㍾|㍽|㍼|∮|∟|⊿|纊|褜|鍈|銈|蓜|俉|炻|昱|棈|鋹|曻|彅|丨|仡|仼|伀|伃|伹|佖|侒|侊|侚|侔|俍|偀|倢|俿|倞|偆|偰|偂|傔|僴|僘|兊|兤|冝|冾|凬|刕|劜|劦|勀|勛|匀|匇|匤|卲|厓|厲|叝|﨎|咜|咊|咩|哿|喆|坙|坥|垬|埈|埇|﨏|增|墲|夋|奓|奛|奝|奣|妤|妺|孖|寀|甯|寘|寬|尞|岦|岺|峵|崧|嵓|﨑|嵂|嵭|嶸|嶹|巐|弡|弴|彧|德|忞|恝|悅|悊|惞|惕|愠|惲|愑|愷|
@jiyuujin
jiyuujin / main.css
Created May 13, 2020 22:46
ある一定の行数を超えないようにする
.multiline_text-ellipsis {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
}
@jiyuujin
jiyuujin / index.js
Created May 3, 2020 05:13
AWS LambdaでWebフォントを利用するため、S3経由でそのファイルをアップロードする
function setFontConfig() {
return new Promise((resolve, reject) => {
process.env.HOME = process.env.LAMBDA_TASK_ROOT
const command = `fc-cache -v ${process.env.HOME}fonts`
exec(command, (error, stdout, stderr) => {
if (error) {
return reject(error)
}
resolve();
})
@jiyuujin
jiyuujin / index.js
Last active April 4, 2020 08:39
メタ情報を取得する
'use strict'
import { getMetaInfo }from './ogp'
const marked = require('marked')
const async = require('async')
// https://github.com/markedjs/marked/issues/1279
const linkSupport = /^!?\[((?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|[^\[\]\\])*?)\]\(\s*(<(?:\\[<>]?|[^\s<>\\])*>|(?:\\[()]?|\([^\s\x00-\x1f()\\]*\)|[^\s\x00-\x1f()\\])*?(?:\s+=(?:[\w%]+)?x(?:[\w%]+)?)?)(?:\s+("(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)))?\s*\)/;
@jiyuujin
jiyuujin / pushState.js
Created March 18, 2020 02:02
pushStateを使って画面遷移する、popStateを使ってブラウザバックを検知する
if (window.history && window.history.pushState) {
const selectors = [
'.js-double_click_link:not([target="_blank"])',
'.breadcrumb-section a',
'.pagenation-init a',
'a[href*="sort:"]'
];
$(document).on('click', selectors, function(event) {
event.preventDefault();
const url = $(this).attr('href');
@jiyuujin
jiyuujin / FormControl.js
Last active March 24, 2020 06:02
[doubleSubmit対策] Enterによる連打、ダブルクリックによるリクエストを禁止する
export class FormControl {
constructor(form) {
this.form = form;
this.hiddenInput = null;
this.shouldSubmit = true;
}
/**
*緩めの2重クリック対策
*/
@jiyuujin
jiyuujin / linkUrl.js
Last active January 31, 2020 00:05
location.hrefからhtmlファイル名を取得する
export const getLinkUrlWithExtention = url => {
return url.match('.+/(.+?)([?#;].*)?$')[1]
}
export const getLinkUrlWithoutExtention = url => {
return url.match('.+/(.+?).[a-z]+([?#;].*)?$')[1]
}