項目 | 表記 |
---|---|
改行を検索 | \n |
タブ文字を検索 | \t |
半角カナを検索 | [ア-ンァ-ョッー゚゙・] |
全角ひらがなを検索 | [あ-んが-ぼぁ-ょゎっー] |
全角カタカナを検索 | [ア-ンガ-ボァ-ョヮッー] |
半角英字を検索 | [a-zA-Z] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arrays = [[10], 50, [100, [2000, 3000, [40000]]]]; | |
arrays.flat(Infinity); | |
// results: | |
// [ 10, 50, 100, 2000, 3000, 40000 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number.prototype.pad = function(size) { | |
var s = String(this); | |
while (s.length < (size || 2)) {s = "0" + s;} | |
return s; | |
} | |
(1).pad(3) // => "001" | |
(10).pad(3) // => "010" | |
(100).pad(3) // => "100" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// source: http://stackoverflow.com/questions/16491758/remove-objects-from-array-by-object-property | |
// we have an array of objects, we want to remove one object using only the id property | |
var apps = [{id:34,name:'My App',another:'thing'},{id:37,name:'My New App',another:'things'}]; | |
// get index of object with id:37 | |
var removeIndex = apps.map(function(item) { return item.id; }).indexOf(37); | |
// remove object | |
apps.splice(removeIndex, 1); |
People
:bowtie: |
😄 :smile: |
😆 :laughing: |
---|---|---|
😊 :blush: |
😃 :smiley: |
:relaxed: |
😏 :smirk: |
😍 :heart_eyes: |
😘 :kissing_heart: |
😚 :kissing_closed_eyes: |
😳 :flushed: |
😌 :relieved: |
😆 :satisfied: |
😁 :grin: |
😉 :wink: |
😜 :stuck_out_tongue_winking_eye: |
😝 :stuck_out_tongue_closed_eyes: |
😀 :grinning: |
😗 :kissing: |
😙 :kissing_smiling_eyes: |
😛 :stuck_out_tongue: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getTextWidth(txt) { | |
let $elm = $('<span class="tempforSize">'+txt+'</span>').prependTo('body'); | |
let elmWidth = $elm.width(); | |
$elm.remove(); | |
return elmWidth; | |
} | |
function centerSelect($elm) { | |
const optionWidth = getTextWidth($elm.children(':selected').html()); | |
const emptySpace = $elm.width() - optionWidth; | |
$elm.css('text-indent', (emptySpace/2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
axios({ | |
url: 'http://localhost:5000/static/example.pdf', | |
method: 'GET', | |
responseType: 'blob', // important | |
}).then((response) => { | |
const url = window.URL.createObjectURL(new Blob([response.data])); | |
const link = document.createElement('a'); | |
link.href = url; | |
link.setAttribute('download', 'file.pdf'); | |
document.body.appendChild(link); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let DECIMAL_SEPARATOR = '.' | |
let asInteger = (number) => { | |
number = String(number) | |
// var value, exp, tokens = number.split(DECIMAL_SEPARATOR), integer = tokens[0], fractional = tokens[1]; | |
let value = number.split(DECIMAL_SEPARATOR) | |
let exp = value | |
let tokens = value | |
let integer = tokens[0] | |
let fractional = tokens[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Classification is adopted eight regional division | |
var regions = [ | |
{id:1, name:"北海道", kana:"ホッカイドウ", en:"hokkaido", neighbor:[2]}, | |
{id:2, name:"東北", kana:"トウホク", en:"tohoku", neighbor:[1]}, | |
{id:3, name:"関東", kana:"カントウ", en:"kanto", neighbor:[2, 4]}, | |
{id:4, name:"中部", kana:"チュウブ", en:"chubu", neighbor:[2, 3, 5]}, | |
{id:5, name:"近畿", kana:"キンキ", en:"kinki", neighbor:[4, 6, 7]}, | |
{id:6, name:"中国", kana:"チュウゴク", en:"chugoku", neighbor:[5, 7, 8]}, | |
{id:7, name:"四国", kana:"シコク", en:"shikoku", neighbor:[5, 6, 8]}, | |
{id:8, name:"九州", kana:"キュウシュウ", en:"kyusyu", neighbor:[6, 7]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FUN METHOD | |
/** | |
* Remove duplicates from an array of objects in javascript | |
* @param arr - Array of objects | |
* @param prop - Property of each object to compare | |
* @returns {Array} | |
*/ | |
function removeDuplicates( arr, prop ) { | |
let obj = {}; | |
return Object.keys(arr.reduce((prev, next) => { |
NewerOlder