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
-- 対象のフォルダの一番上を選択している状態から始める | |
set targetFolder to "aaa" | |
tell application "Notes" | |
activate | |
repeat with theFolder in every folder | |
if name of theFolder = targetFolder then | |
repeat with theNote in every note of theFolder | |
tell application "System Events" | |
key code 126 |
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
.rounded-corners-gradient-borders { | |
width: 300px; | |
height: 80px; | |
border: double 4px transparent; | |
border-radius: 80px; | |
background-image: linear-gradient(white, white), radial-gradient(circle at top left, #f00,#3020ff); | |
background-origin: border-box; | |
background-clip: content-box, border-box; | |
} |
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
import { useEffect, useState } from 'react'; | |
// Spec | |
// https://www.w3.org/TR/page-visibility-2/ | |
// MDN | |
// https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API | |
// https://developers.google.com/web/updates/2017/03/background_tabs |
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
// Generate data | |
const k = 1 * 1000; | |
let gen = () => { | |
return Array.from({length: k}, () => Math.floor(Math.random() * k)); | |
}; | |
let a = gen(); |
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
// simple "hungry" solution | |
let denominations = [1, 7, 9]; | |
function withdraw(amount) { | |
let remain = amount; | |
let result = []; | |
const denominationsSorted = denominations.sort((a, b) => b - a); | |
denominationsSorted.forEach((denomination) => { | |
let count = Math.floor(remain / denomination); |
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
/* | |
----------------------- | |
Example: | |
----------------------- | |
Round 1 | |
Player1 hits Player2 with 5 dmg | |
Player2 hits Player3 with 10 dmg | |
Player3 has died | |
Player4 hits Player1 with 4 dmg |
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
// Complexity for getBondsData - 3n | |
// Memory - ? | |
class BondsCache { | |
constructor() { | |
this.data = new Map(); | |
} | |
getId(date, isin) { | |
return `${date}_${isin}`; |
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
// Float To Percent | |
// Complexity - 2n | |
// Memory - ? | |
// Input limit - 6e6 (6_000_000) elements | |
function floatToPercent(array) { | |
const total = array.reduce((acc, curr) => acc + parseFloat(curr), 0); | |
return array.map(value => { | |
return (parseFloat(value) / total * 100).toFixed(3); | |
}); |
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 requiredParam (param) { | |
const requiredParamError = new Error( | |
`Required parameter, "${param}" is missing.` | |
); | |
// preserve original stack trace | |
if (typeof Error.captureStackTrace === ‘function’) { | |
Error.captureStackTrace( | |
requiredParamError, | |
requiredParam, | |
); |
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 loadScript(src) { | |
return new Promise(function(resolve, reject) { | |
const script = document.createElement('script'); | |
script.src = src; | |
script.onload = resolve; | |
script.onerror = reject; | |
document.head.appendChild(script); | |
}); | |
} |
NewerOlder