anonymous No title
JavaScript
const nodeUrl = "http://symbol-test.next-web-technology.com:3000";
  const nw = await NetworkScripts.getNetworkStructureFromNode(nodeUrl, NetworkType.TEST_NET);
  const account = AccountScripts.createRootAccountFromMnemonic(SAMPLE1.MNEMONIC, "password", nw);
  const repositoryFactory = new RepositoryFactoryHttp(nodeUrl);
  const listerner = repositoryFactory.createListener();
  listerner.open().then(() => {
    listerner.newBlock(); // セッションアウト防止用
    listerner
      .confirmed(Address.createFromRawAddress(account.address))
      .subscribe(tx => {
        console.log("受信", tx);
      })
  });
anonymous No title
JavaScript
(async () => {
  const nodeUrl = "http://symbol-test.next-web-technology.com:3000";
  const nw = await NetworkScripts.getNetworkStructureFromNode(nodeUrl, NetworkType.TEST_NET);
  // Accountの作成
  const account1 = AccountScripts.createFromMnemonic(SAMPLE1.MNEMONIC, "password", nw);
  const account2 = AccountScripts.createFromMnemonic(SAMPLE2.MNEMONIC, "password", nw);
  console.log(account1.address);
  console.log(account2.address);
  // Account情報の取得
  const [account1Info] = await AccountScripts.getBalanceFromAddress(account1.address, nw);
  const [account2Info] = await AccountScripts.getBalanceFromAddress(account2.address, nw);
  console.log(JSON.stringify(account1Info));
  console.log(JSON.stringify(account2Info));
  // ACCOUNT1 -> 2への送金
  const mosaic = await MosaicScripts.getMosaicStructureFromMosaicId(account1Info.mosaicId, nw);
  const tx = await TransactionScripts.createTransaction(account2.address, [{ mosaic, amount: 1 }], "test", nw);
  console.log(tx.transactionInfo?.id);
  const result = await TransactionScripts.signTransaction(account1, tx, nw);
  console.log(result);
})();
anonymous Stravaの画面上のKudosを一括で押すブックマークレット
JavaScript
javascript:!function(c,b,a){a=c.createElement("script");a.src="//j.mp/1bPoAXq";a.onload=function(){b(jQuery.noConflict(1))};c.body.appendChild(a)}(document,function(b){var a = b(".btn-kudo.js-add-kudo");a.click();});
anonymous No title
JavaScript
const input = [
  { level: 1, text: "1章 JavaScriptの第一歩" },
  { level: 1, text: "2章 データ型と変数" },
  { level: 2, text: "2.1 変数の識別" },
  { level: 2, text: "2.2 スコープ" },
  { level: 1, text: "第3章 演算子と文" },
  { level: 2, text: "3.1 文の形式" },
  { level: 2, text: "3.2 単純文" },
  { level: 3, text: "3.2.1 代入文" },
  { level: 3, text: "3.2.2 演算文" },
];

function treefy(input) {
  const output = [];
  const containers = [output];
  let level = 1;

  for (let i = 0; i < input.length; i++) {
    const item = input[i];

    if (item.level > level) {
      input[i-1].children = [item];
      containers.push(input[i-1].children);
    } else if (item.level < level) {
      containers.pop();
    }
    
    containers[containers.length-1].push(item);
    level = item.level;
  }

  return output;
}

console.log(
  JSON.stringify(treefy(input), null, '\t')
);
anonymous No title
JavaScript
<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
    
    for (let n=1; n<=100  ;n++)
   {
        if (n % 15 == 0){
            document.write("FizzBuzz" + "<br>" );
        }
            else if(n % 5 == 0){
                document.write("Buzz" + "<br>" );
            }
            else if(n % 3 == 0){
                document.write("Fizz" + "<br>" );
            }

        else {
        document.write(n  + "<br>" );
        }
   }
        //document.write("FizzBuzz");
    </script>
</body>
</html>
anonymous No title
JavaScript
console.log("a");
anonymous No title
JavaScript
  useEffect(() => {
    if (typeof window !== 'undefined') {
      window.addEventListener('focus', readClipboardText);
    }
    return () => {
      if (typeof window !== 'undefined') {
        window.removeEventListener('focus', readClipboardText);
      }
    };
  }, [window]);
anonymous <p></p>
JavaScript
does it rate limit?
anonymous <p></p>
JavaScript
does it rate limit?
anonymous <p></p>
JavaScript
does it rate limit?
Don't you submit code?
Submit