Share Code Quickly

What is Harigami?

Harigami is a simple source code sharing service. You can share source code by an URL which is issued after submission.
You can also run your source code online such as Python, Ruby, JavaScript and so on.
For free.Use for code review.
Preferences
フェアリーテイルを読む、赤紙を書く No title
C++
#include <stdio.h>
#include <stdlib.h>
int main(void){
    unsigned char header[0x36];
    unsigned char **data;
    unsigned char *temp_data;
    char in_f_name[20] = "./LENNA.bmp", out_f_name[20];
    FILE *in_f, *out_f;
    long start_addr, end_addr;
    int width, height, color_bit;
    int i, j, k;
    if ((in_f=fopen(in_f_name, "rb"))==NULL){
        printf("Error on open file.\n");
    }

    /* header */
    for (int i=0; i<0x36; i++){
        header[i] = fgetc(in_f);
        // printf("%x: %x\n", i, header[i]);
    }
    start_addr = header[0x0A] + header[0x0B] * 0x100;
    end_addr = header[0x02] + header[0x03]*0x100 + header[0x04]*0x10000 + header[0x05]*0x1000000;
    width = header[0x12] + header[0x13] * 0x100;
    height = header[0x16] + header[0x17] * 0x100;
    color_bit = header[0x1C];
    printf("data_addr: 0x%x to 0x%x\n", start_addr, end_addr);
    printf("width: %d\n", width);
    printf("height: %d\n", height);
    printf("color: %xbit\n", color_bit);

    /* color parett*/
    for (int i=0x36; i<start_addr; i++){
        fgetc(in_f);
    }

    /* data */
    data = (char **)malloc(sizeof(char *) * height);
    for(i=0; i<height; i++){
        data[i] = (char *) malloc(sizeof(char)*width);
    }

    // 1D data for 2D data
    temp_data = (char *)malloc(sizeof(char) * (end_addr - start_addr));
    for(i=start_addr; i<end_addr; i++){
        temp_data[i-start_addr] = fgetc(in_f);
    }

    free(temp_data);
    free(data);

}
フェアリーテイルを読む、赤紙を書く No title
C++
#include <stdio.h>
#include <stdlib.h>
int main(void){
    unsigned char header[0x36];
    unsigned char **data;
    unsigned char *temp_data;
    char in_f_name[20] = "./LENNA.bmp", out_f_name[20];
    FILE *in_f, *out_f;
    long start_addr, end_addr;
    int width, height, color_bit;
    if ((in_f=fopen(in_f_name, "rb"))==NULL){
        printf("Error on open file.\n");
    }

    /* header */
    for (int i=0; i<0x36; i++){
        header[i] = fgetc(in_f);
        // printf("%x: %x\n", i, header[i]);
    }
    start_addr = header[0x0A] + header[0x0B] * 0x100;
    end_addr = header[0x02] + header[0x03]*0x100 + header[0x04]*0x10000 + header[0x05]*0x1000000;
    width = header[0x12] + header[0x13] * 0x100;
    height = header[0x16] + header[0x17] * 0x100;
    color_bit = header[0x1C];
    printf("data_addr: 0x%x to 0x%x\n", start_addr, end_addr);
    printf("width: %d\n", width);
    printf("height: %d\n", height);
    printf("color: %xbit\n", color_bit);

    /* color parett*/
    for (int i=0x36; i<start_addr; i++){
        fgetc(in_f);
    }

    /* data */
    data = (char **)malloc(sizeof(char *) * height);
    for(int i=0; i<height; i++){
        data[i] = (char *) malloc(sizeof(char)*width);
    }
    temp_data = (char *)malloc(sizeof(char) * (end_addr - start_addr));
    for(int i=start_addr; i<end_addr; i++){
        temp_data[i-start_addr] = fgetc(in_f);
    }

    free(temp_data);
    free(data);

}
anonymous No title
PHP
<!DOCTYPE html>
<html>
    
<head>
<meta charset="utf-8" />
<title>Mission_1-20</title>
</head>

<body>
    <form action="" method="post">
        <input type="text" name"str">
        <input type="submit" name="submit">
    </form>
    <?php
            $str = $_POST["str"];
            echo $str;
            $str_a = $_POST["comment"];
            echo $str_a;
    ?>

</body>
</html>
anonymous No title
Python
# (1)拡張モジュールのインポート
import numpy as np                  # 配列を扱う数値計算ライブラリNumPy
import matplotlib.pyplot as plt     # グラフ描画ライブラリmatplotlib
import japanize_matplotlib  # matplotlibの日本語化
import math
from operator import mul
#片対数グラフの傾きを線形回帰により求めるやーつ
print("データ数を入力")
n=int(input())
print("データ(x,y)を入力")
data_set=[list(map(float,input().split())) for i in range(n)]
#print(data_set)
data_x=list(map(lambda x:x[0],data_set))

log_y=list(map(math.log10,map(lambda x: x[1], data_set)))
x_y=list(map(mul,data_x,log_y))
x_x=list(map(mul,data_x,data_x))
a=(n*sum(x_y)-sum(data_x)*sum(log_y))/(n*sum(x_x)-sum(data_x)*sum(data_x))
b=(sum(log_y)-a*sum(data_x))/n
print("求めたい値=")
print(a*math.log(10))
x = np.linspace(min(data_x),max(data_x),100)
y=a*x+b
#print(log_y)
plt.scatter(data_x,log_y)
plt.plot(x,y)
plt.show()
anonymous No title
PHP
  Many thanks quest of making the naturalistic trouble to vindicate this.   https://www.google.rs/url?q=https://professional-heating-and-air-conditioning-repair.com
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
C
#include <stdio.h>
#include <stdlib.h>
#include<string.h>

 struct CELL{
    struct CELL *prev;
    int value;
    struct CELL *next;
};
struct CELL *insertCellPrev(struct CELL*, int);

struct CELL head;

struct CELL *appendCell(int data){
    struct CELL *p;
    int x=data;
    p=insertCellPrev(&head , x);
    return p;
}
struct CELL *insertCellPrev(struct CELL *p , int data){
    struct CELL *x;
    if(p==NULL){
        printf("insert : 引数が正しくありません\n");
        return NULL;
    }
    x=(struct CELL*)malloc(sizeof(struct CELL));
    if(x==NULL){
        printf("not enough memory\n");
        return NULL;
    }
    x->value=data;
    x->next=p;
    x->prev=p->prev;
    p->prev->next=x;
    p->prev=x;
    return x;
}

void printDlist(struct CELL *q){
    struct CELL *p;
    printf("LIST[");
    for(p=q; p!=&head ; p=p->next){
        printf(" %d ", p->value);
    }
    printf("]\n");

}
int deleteDuplicatedCell(int data){
    struct CELL *p;
    int num=0;
    for(p=head.next ; p!=&head ; p=p->next){
        if(p->value==data){
            num++;
            p->prev->next=p->next;
            p->next->prev=p->prev;
            free(p);
        }
    }
    if(num==0){
        return -1;
    }else{
        return num;
    }
}
void freeDlist(){
    struct CELL *p;
    int x=0;
    p=&head;
    for(p=head.next ; p->prev=&head ; p=p->next){
        printDlist(p);
        p->prev->next=p->next;
        p->next->prev=p->prev;
        free(p);
    }
}
void main(int argc , char *argv[]){
    struct CELL *p;
    int num;
    int n;
    head.prev = head.next = &head;

    for(int i=1 ; i<argc ; i++){
       p=appendCell(atoi(argv[i]));
    }
    printDlist(head.next);

while(1){
    printf("Delete Data : "); scanf("%d", &num);
    if(num<0){
        printf("free list\n");
        freeDlist();
        exit(0);
    }
    n=deleteDuplicatedCell(num);
    if(n!=-1){
        printf("Deleted : %d\n", n);
    }else if(n==-1){
        printf("Not deleted .....\n");
    }
    printDlist(head.next);
}

    return ;
}
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 No title
TypeScript
// 過去作成したニーモニックよりアカウントを復元し、保有モザイクを確認する
(async () => {
  const mnemonicWords = "xxxxxxxxxxxxxxxxxx";
  const xKey = ExtendedKey.createFromSeed(new MnemonicPassPhrase(mnemonicWords).toSeed("password").toString("hex"), Network.SYMBOL);
  const wallet = new Wallet(xKey);
  const privateKey = wallet.getChildAccountPrivateKey(Wallet.DEFAULT_WALLET_PATH);
  const symbolAccount = Account.createFromPrivateKey(privateKey, NetworkType.TEST_NET);

  const nodeUrl = "http://symbol-test.next-web-technology.com:3000";
  const address = Address.createFromRawAddress(symbolAccount.address.pretty());
  const accountRepo = new RepositoryFactoryHttp(nodeUrl).createAccountRepository();
  const accountInfo = await accountRepo.getAccountInfo(address).pipe(timeout(5000)).toPromise();

  for (const ownedMosaic of accountInfo.mosaics) {

    const mosaicId = new MosaicId(ownedMosaic.id.toHex());
    const repositry = new RepositoryFactoryHttp(nodeUrl);
    const mosaicHttp = repositry.createMosaicRepository();
    const info = await mosaicHttp.getMosaic(mosaicId).pipe(timeout(5000)).toPromise();
    console.log(info);
  }

})();
anonymous No title
TypeScript
// 新規アカウントを発行する
(async () => {
  const mnemonic = MnemonicPassPhrase.createRandom(); // hd-wallet向け
  const seed = mnemonic.toSeed("password").toString("hex"); // passphraseにて暗号化(root seed)
  const xkey = ExtendedKey.createFromSeed(seed, Network.SYMBOL);
  const wallet = new Wallet(xkey);
  const masterAccount = wallet.getAccountPrivateKey();
  const defaultAccount = wallet.getChildAccountPrivateKey(Wallet.DEFAULT_WALLET_PATH);
  console.log(mnemonic);
  // console.log(masterAccount);
  // console.log(defaultAccount);
})();