anonymous No title
JavaScript
function ageCheck(){
    if( confirm("20歳以上ですか?")){
        alert("お酒が飲めますね!");
    }
    else {
        alert("20歳まで我慢しましょう!");
    }
}

ageCheck();
anonymous No title
JavaScript
document.evaluate("a//[contains(text(),'クリック')]",document.null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
anonymous No title
JavaScript
//1HのstochRSIを表示
mtf = input.timeframe(title='MTF算出_60分', defval='60')
mtf_rsi = request.security(syminfo.tickerid, mtf, rsi1)
mtf_k = ta.sma(ta.stoch(mtf_rsi, mtf_rsi, mtf_rsi, lengthStoch), smoothK)
mtf_d = ta.sma(mtf_k, smoothD)

//エントリー条件を記述 条件を満たせばtrue扱いとなる
entry = ta.crossover(k,d) and ta.crossover(mtf_k,mtf_d)

//アラート条件
alertcondition(entry, title='エントリー例', message='1Dと1hのstochGC')
anonymous No title
JavaScript
class BlockChain {

  constructor(nemesisHash, timestamp, message) {
    this.chain = [{
      height: 0,
      hash: nemesisHash,
      timestamp: 0,
      epochAjustment: timestamp,
      message: message,
    }];
    console.log("Start BlockChain");
    console.log(JSON.stringify(this.chain[0], null, 2));
  }

  static __init__() {
    const nemesisMessage = "hello block chain Symbol !!";
    const nemesisHashRow = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_256, nemesisMessage);
    const nemesisHash = nemesisHashRow.map(n => ("0" + ((n < 0) ? 256 + n : n).toString(16)).slice(-2)).join("").toUpperCase();
    const timestamp = new Date().getTime();
    return new BlockChain(nemesisHash, timestamp, nemesisMessage);
  }

  add() {
    const message = new Date().toLocaleString() + " Blockを追加しました";
    const lastBlock = this.chain[this.chain.length - 1];
    const epochAjustment = this.chain[0].epochAjustment;
    const date = new Date().getTime();
    if (this.hashSum() === true) {
      const hashRow = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_256, `${lastBlock.hash}${message}`);
      const hash = hashRow.map(n => ("0" + ((n < 0) ? 256 + n : n).toString(16)).slice(-2)).join("").toUpperCase();
      const block = { height: this.chain.length, hash, timestamp: date - epochAjustment, message, epochAjustment: undefined };
      console.log(JSON.stringify(block, null, 2))
      this.chain.push(block);
    } else {
      throw new Error("データの改竄があった為、停止しました");
    }
  }

  hashSum() {
    if (this.chain.length === 1) {
      return true;
    }
    for (let i = 1; i < this.chain.length; i++) {
      const prev = this.chain[i - 1];
      const current = this.chain[i];
      const currentHashRow = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_256, `${prev.hash}${current.message}`);
      const currentHash = currentHashRow.map(n => ("0" + ((n < 0) ? 256 + n : n).toString(16)).slice(-2)).join("").toUpperCase();
      if (currentHash !== current.hash) return false;
    }
    return true;
  }

}

function test() {
  const Chain = BlockChain.__init__();
  for (let i = 0; i < 50; i++) {
    Utilities.sleep(1000);
    Chain.add();
    // 改竄
    if(i === 10){
      console.log("データを改竄しました");
      Chain.chain[5].message = "改竄します";
    }
  }
}
anonymous テキスト選択禁止を解除するブックマークレットだよ
Public Domain JavaScript
javascript:document.body.appendChild((function(){var s=document.createElement('style');s.innerHTML='* { user-select: initial !important; -webkit-user-select: initial !important; }'; return s})());var ss = function() { event.stopImmediatePropagation(); return true; }; document.querySelectorAll('*').forEach(function(e) { e.addEventListener('selectstart', ss, true); });
anonymous Node.jsでGoogle Apps Script APIを使う
JavaScript
const fs = require('fs');

const { google } = require('googleapis');
const OAuth2 = google.auth.OAuth2;

// OAuthクライアントを初期化
const creds = JSON.parse(fs.readFileSync('creds.json', 'utf-8')).installed;
const oauth2Client = new OAuth2(
    creds.client_id,
    creds.client_secret,
    'urn:ietf:wg:oauth:2.0:oob'
);

// 認証コードを取得するためのURLを取得
const getAuthorizeUrl = () => {
    const authorizeUrl = oauth2Client.generateAuthUrl({
        access_type: 'offline',
        scope: [
            'https://www.googleapis.com/auth/script.scriptapp',
            'https://www.googleapis.com/auth/drive'
        ],
    });
    return authorizeUrl;
}

// トークンを取得してJSONファイルに保存
const getToken = () => {
    const code = 'getAuthorizeUrlで得たコード';
    oauth2Client.getToken(code, (err, token) => {
        fs.writeFileSync('token.json', JSON.stringify(token));
    });
}

// GAS APIを実行
const callAppsScript = (auth) => {
    const scriptId = 'デプロイID';
    const script = google.script('v1');
    script.scripts.run({
        auth: auth,
        resource: {
            function: 'doSomething',
        },
        scriptId: scriptId,
    }, (err, resp) => {
        // GASの関数からの戻り値
        console.log(resp.data.response.result);
    });
}

// エントリー
const main = () => {
    // JSONからトークンを取得してOAuthClientにセットする
    const token = JSON.parse(fs.readFileSync('token.json', 'utf-8'));
    oauth2Client.setCredentials(token);
    // GASの関数を実行
    callAppsScript(oauth2Client);
}


main();
anonymous No title
JavaScript
window.addEventListener('keypress', handleKeyDown);

var pressed = "";
var howmany = 0;
document.querySelector('#main').innerHTML = `
<h1>${pressed}<h1>
<h2>現在${howmany}文字入力中です<h2>
<h3>右クリックでファイルにセーブできます<h3>
`
function handleKeyDown (event) {
  if(event.key !== "Enter"){
  if(event.key === "Backspace"){
    pressed = pressed.slice(0, pressed.length - 1)
  }else if (event.key === " "){
    pressed += " "
  
  }else if(/[a-zA-Z0-9]/.test(event.key)){
  pressed += event.key
  }else if(/[,.;:@!"#$%&'-^<>?+*`~=_/]/.test(event.key)){
  pressed += event.key
  }
}
  
  howmany = pressed.length
  document.querySelector('#main').innerHTML = `
<h1>${pressed}<h1>
<h2>現在${howmany}文字入力中です<h2>
`
}

function draw() {
  if (mouseButton === RIGHT && mouseIsPressed === true) {
    var typed = createWriter('typed.txt')
    typed.print(pressed);
    typed.close();
    typed.clear();
    }
}
anonymous No title
JavaScript
import fs from "fs";
const buffer = Buffer.from(fs.readFileSync("sample.png"));
// --- split png header & chunk --- //
// skip
// --- --- //
console.log("1. Hex", buffer.toString("hex").length);
console.log("2. Base64", buffer.toString("base64").length);
console.log("3. Binary", buffer.toString("binary").length);
console.log("4. Uint8", Uint8Array.from(buffer).toString().length);
console.log("5. 2進数", [...buffer.values()].map(b => b.toString(2)).join("").length);
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);
})();
Don't you submit code?
Submit