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
anonymous No title
Python
import math
import time

from talon import canvas, ctrl, tap, ui
from talon.skia import Shader
from talon.track.filter import DwellFilter, LowPassFilter, MultiFilter, OneEuroFilter
from talon.types import Point2d
from talon_plugins.eye_mouse import tracker
from talon.track.tobii import EyeFrame

ENABLED = True

screen = ui.main_screen()
size_px = Point2d(screen.width, screen.height)


class LensMouse:
    def __init__(self):
        # tracker.register("gaze", self.on_gaze)

        self.xy_hist = [Point2d(0, 0)]
        self.origin = Point2d(0, 0)

        canvas.register("overlay", self.draw)
        self.enabled = True

    # Shows crazy circles
    def smooth_location(self):
        # Calculate smooth location of point
        x = self.origin.x
        y = self.origin.y
        n = 75
        if len(self.xy_hist) < n:
            n = len(self.xy_hist)
        total = 1
        minimum_group = 50
        for i in range(n):
            x2 = self.xy_hist[-1 - i].x
            y2 = self.xy_hist[-1 - i].y

            # If there are at least 5 points (so there's some smoothness)
            if i > minimum_group:
                # Don't use if points are really far away, so long moves are fast
                if abs(x2 - self.origin.x) > 60:
                    continue
                if abs(y2 - self.origin.y) > 60:
                    continue

            x += x2
            y += y2
            total += 1

        x /= total
        y /= total
        return [x, y]

    def draw(self, canvas):
        if self.origin is None:
            print("Is the tobii disconnected?")
            return

        pos = self.smooth_location()

        # Append the smoothed dot to history > to smooth it some more
        self.xy_hist.append(Point2d(pos[0], pos[1]))
        self.xy_hist.append(Point2d(pos[0], pos[1]))

        if pos is None:
            return

        paint = canvas.paint

        paint.stroke_width = 1
        paint.style = paint.Style.STROKE
        paint.color = "44444444"

        canvas.draw_circle(pos[0], pos[1], 150)

        paint.style = paint.Style.FILL
        paint.color = "99999944"
        canvas.draw_circle(pos[0], pos[1], 150)

    def on_gaze(self, frame):
        x = frame.gaze.x
        y = frame.gaze.y

        # Don't pass edges of screen
        if x < 0:
            x = 0
        if y < 0:
            y = 0

        if x == 0 or y == 0:
            return

        # Multiply by screen width
        x *= size_px.x
        y *= size_px.y

        self.origin = Point2d(x, y)
        self.xy_hist.append(self.origin)
        self.xy_hist = self.xy_hist[-200:]

if ENABLED:
    mouse = LensMouse()
    tracker.register('gaze', mouse.on_gaze)
anonymous No title
TypeScript
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
anonymous No title
Python
<!DOCTYPE html>
<html lang="ja">

<head>

  <meta charset="UTF-8">
  <title>練習2the hiatus</title>
<link rel="stylesheet" href="css/styles.css">

<link rel="stylesheet" href="./css/slick.css">
<link rel="stylesheet" href="./css/slick-theme.css">
<link href="https://fonts.googleapis.com/css?family=Amiri:700i|Noto+Sans+JP:500|Overpass+Mono:300,400|Overpass:300,400,700&amp;subset=japanese" rel="stylesheet">
<!-- /css -->
<!-- js -->
<script src="https://thehiatus.com/js/jquery-1.11.1.min.js"></script>
<script src="https://thehiatus.com/js/jquery.flexslider.js"></script>
<!-- <script src="https://thehiatus.com/js/default.js"></script>
<script src="https://thehiatus.com/js/slick.min.js"></script>
<script src="https://thehiatus.com/js/jquery.bxslider.js"></script>
<script src="./js/modal.js"></script>
<script src="https://thehiatus.com/js/ua.js"></script>
<script src="https://thehiatus.com/js/conf.js"></script>
<script src="https://thehiatus.com/js/aip.js"></script> -->
<script src="https://thehiatus.com/js/index.js"></script>

</head>
	<body id="body" class="firstview">
		<div id="wrapper" class="top">
			<header id="header">
				<div id="headerIn">
					<h1><a href="#"><img src="https://thehiatus.com/img/common/logo.png" width="180" alt="the HIATUS"></a></h1>
					<nav>
						<ul>
							<li><a href="https://thehiatus.com/">TOP</a></li>
							<li><a href="https://thehiatus.com/./news/">NEWS</a></li>
							<li><a href="https://thehiatus.com/./media/">MEDIA</a></li>
							<li><a href="https://thehiatus.com/./live/">LIVE</a></li>
							<li><a href="https://thehiatus.com/./biography/">BIOGRAPHY</a></li>
							<li><a href="https://thehiatus.com/./discography/">DISCOGRAPHY</a></li>
							<li><a href="https://thehiatus.com/./gallery/">VIDEO</a></li>
							<li class="last"><a href="https://www.official-store.jp/thehiatus/" target="_blank">STORE</a></li>
						</ul>
					</nav>
				</div>
			</header>
			<section id="feature" style="opacity: 1;">
				<!-- <div id="slider" class="slider">
					<ul class="slides slick-initialized slick-slider">
											<div class="slick-list draggable">
												<div class="slick-track" style="opacity: 1; width: 3920px;">
													<li class="slide001 slick-slide" data-slick-index="0" aria-hidden="true" style="width: 980px; position: relative; left: 0px; top: 0px; z-index: 998; opacity: 1; transition: opacity 3000ms ease 0s;">
														<a href="news/index.html">
															<div class="videologo">
															
																												
																<img src="https://thehiatus.com/img/top/slide_logo.svg">
															</div>
															<video id="player" autoplay="" loop="" muted="" playsinline="" width="100%">
																<source src="https://thehiatus.com/img/top/main.mp4">
															</video>
														</a>
													</li>
													<li class="slide002 slick-slide" data-slick-index="1" aria-hidden="true" style="width: 980px; position: relative; left: -980px; top: 0px; z-index: 998; opacity: 0; transition: opacity 3000ms ease 0s;">
														<a href="https://thehiatus.com/biography/index.html"></a>
													</li>
													<li class="slide004 slick-slide" data-slick-index="2" aria-hidden="true" style="width: 980px; position: relative; left: -1960px; top: 0px; z-index: 998; opacity: 0; transition: opacity 3000ms ease 0s;">
														<a href="https://sp.universal-music.co.jp/the-hiatus/10th/" target="_brank">
														</a>
													</li>
													<li class="slide003 slick-slide slick-current slick-active" data-slick-index="3" aria-hidden="false" style="width: 980px; position: relative; left: -2940px; top: 0px; z-index: 1000; opacity: 0; transition: opacity 3000ms ease 0s;">
														<a href="live/index.html">
														</a>
													</li>
												</div>
											</div>
											
											
											
					</ul>
				</div> -->
				<div class="contents">
								
					<p><img src="img/biography_bg.jpg" width="1128" alt="the HIATUS"></p>
				
				</div>
			</section>
					<!-- main -->
			<main class=" clearfix" style="opacity: 1;">
				<section class="newsInfo clearfix mb80" style="opacity: 1;">
					<div class="newsTop contsHead" id="newsBox">
						<div class="latestnews_inner">
							<h2 class="titles">LATEST NEWS</h2>
							<p class="links hover"><a href="https://thehiatus.com/news/">All</a></p>
							<img src="https://thehiatus.com/img/top/latest-news-img.jpg" width="304" alt="アーティスト写真">
						</div>
						<ul class="newsMain">
							<li class="hover">
								<p class="nbl"><span class="day">2021.04.22</span></p>
								<p class="nbr">
									<span class="ntext"><a href="https://thehiatus.com/news/">三吉ツカサ氏撮影 the HIATUS新作写真集発売決定!</a></span>
									<span class="ntextSub">カメラマン三吉ツカサ氏撮影による、2020年のthe HIATUSを収めた新作写真集の発売が決定!the HIATUS 新作写真集 上下巻セット「...</span>
								</p>
							</li>
							<li class="hover">
								<p class="nbl"><span class="day">2020.12.24</span></p>
								<p class="nbr">
									<span class="ntext"><a style="opacity:1;" href="./news/">「Jive Turkey vol.5」生配信ライブ アーカイブ期間延長のお知らせ</a></span>
									<span class="ntextSub">「Jive Turkey vol.5」12/23 (水) ブルーノート東京 2ndショウ生配信ライブにつきまして、一部のお客様に映像や音声が途切れると...</span>
								</p>
							</li>
							<li class="hover last">
								<p class="nbl"><span class="day">2020.12.21</span></p>
								<p class="nbr">
									<span class="ntext"><a href="https://thehiatus.com/news/">「COUNTDOWN JAPAN 20/21」中止のお知らせ</a></span>
									<span class="ntextSub">12/31に出演を予定しておりました「COUNTDOWN JAPAN 20/21」は、開催中止となりました。詳細はイベントオフィシャルサイトをご確...</span>
								</p>
							</li>
						</ul>
					</div>
					<div class="info contsHead">
						<div class="liveinfo_inner">
							<h2 class="titles">LIVE INFO</h2>
							<p class="links hover"><a href="./live/">All</a></p>
						</div>
						<ul class="liveInfo" id="liveBox">
							<li>
							<a href="https://thehiatus.com/live/?y=2021&amp;m=8">
								<p class="day01"><span class="month">08	</span>
									<span class="day">07</span>
								</p>
								<p class="day02">
									<span class="year">2021</span>
									<span class="week">SAT</span>
								</p>
								<p class="mainText">
									<i>ROCK IN JAPAN FESTIVAL 2021</i>
								</p>
								<p class="subText mb5">
									<span>2021/08/07(土) 国営ひたち海浜公園</span>
									<span>Open 8:00 / Start 12:00</span>
								</p>
							</a>
							</li>
						</ul>
					</div>
				</section>
				<section class="pv">
					<div class="pv_inner">
						<iframe width="595" height="325" src="https://www.youtube.com/embed/ELVIZiXwe98" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
							<iframe width="595" height="325" src="https://www.youtube.com/embed/ELVIZiXwe98" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="">
							</iframe>
							<div class="pv_description">
									<h2>LATEST VIDEOS</h2>
									<p>the HIATUS - Regrets(Music Video)</p>
									<div class="pv_a_inner">
											<a href="https://thehiatus.com/gallery/">
												All
											</a>
									</div>
							</div>
					</div>
			</section>
			<div class="banner_erea">
				<a href="https://sp.universal-music.co.jp/the-hiatus/10th/" target="_blank"><img src="https://thehiatus.com/img/top/top_banner.jpg" width="980" alt="">
				</a>
		</div>
		<section class="timeLine clearfix" style="opacity: 1;">
			<div class="fbTime">
									<iframe src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2Fthehiatus.jp&tabs=timeline&width=465&height=530&small_header=true&adapt_container_width=true&hide_cover=true&show_facepile=false&appId=567173303304701" width="465" height="530" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowtransparency="true" allow="encrypted-media">
									</iframe>
			</div>
			<div class="twTime">
				<a class="twitter-timeline" data-width="450" data-height="907" href="https://twitter.com/theHIATUS_offic?ref_src=twsrc%5Etfw">Tweets by theHIATUS_offic</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
			</div>
		</section>
					<div class="pagetop_inner">
						<a href="#"><img src="https://thehiatus.com/img/common/pagetop.png" width="11" alt="pagetop"></a>
					</div>
			</main>
			<!-- /main -->
			<footer id="footer">
				<div class="footer_inner">
						<a href="file:///C:/Users/3054m/Desktop/web%E7%B7%B4%E7%BF%92/%E7%B7%B4%E7%BF%922the%20hiatus/thehiatus/second.html" target="_blank"><img src="https://thehiatus.com/img/common/logo.png" width="180" alt="the HIATUS"></a>
						<ul class="footer_li">
								<li><a href="https://thehiatus.com/">TOP</a></li>
								<li><a href="https://thehiatus.com/news/">NEWS</a></li>
								<li><a href="https://thehiatus.com/media/">MEDIA</a></li>
								<li><a href="https://thehiatus.com/live/">LIVE</a></li>
								<li><a href="https://thehiatus.com/biography/">BIOGRAPHY</a></li>
								<li><a href="https://thehiatus.com/discography/">DISCOGRAPHY</a></li>
								<li><a href="https://thehiatus.com/gallery/">VIDEO</a></li>
								<li class="last"><a href="https://www.official-store.jp/thehiatus/" target="_blank">STORE</a></li>
						</ul>
				</div>
				<div class="footer_inner">
						<p>
							<small>Copyright © the HIATUS.</small>
						</p>
						<ul class="footer_icon">
								<li><a href="https://twitter.com/thehiatus_offic" target="_blank"><img src="https://thehiatus.com/img/common/footer_icon_twitter.png" width="18" alt="Twitter"></a></li>
								<li><a href="https://www.facebook.com/thehiatus.jp" target="_blank"><img src="https://thehiatus.com/img/common/footer_icon_insta.png" 
anonymous No title
Python
11. 〒105-0022 東京都港区海岸1丁目
12.3か月先のヴァイオリンのコンサートチケットを¥5000
で購入した。
商品に関するご質問は、お気軽に最寄りの支店・営業所
問合せください。
14. 次の休日は、友達とドライブに行く約束をしている。
15.表計算ソフトである Excelの基本操作を学習するには、『Excel
基礎』のテキストが分かりやすいと評判である。
16. ゴルフ場を選ぶ基準は、ホール数・距離(ヤード)・パーの数
などがあります。例えば、18H(=ホール)、6,577Y(ヤー
ド)、P(=パー)72のように表示されます。
17. 来週の日曜日から駅前のショップでバーゲンが開催され、全
品50%OFF(半額)のSALEということである。
anonymous No title
PHP
<?php
session_start();
$dsn = "mysql:dbname=co_19_349_99sv_coco_com;host=localhost;charset=UTF8";
$name_db = "co-19-349.99sv-c";
$password_db = "U2j9s5dQ";

try {
  $mysql = new PDO($dsn,$name_db,$password_db);

} catch (PDOExcption $e){
  echo "エラー" . $e->getMessage() ;
}


if (!empty($_POST["roguinn_submit"])) {

  if (!empty($_POST["roguinn_id"])&&!empty($_POST["roguinn_password"])) {

    if (preg_match("/^[a-zA-Z0-9]+$/",$_POST["roguinn_id"])&&preg_match("/^[a-zA-Z0-9]+$/",$_POST["roguinn_password"])) {

      $roguinn_id = $_POST["roguinn_id"];
      $roguinn_password = $_POST["roguinn_password"];

      $select_sql = "SELECT * FROM kadai_3_1 WHERE id='" . $roguinn_id . "' AND password='" . $roguinn_password . "'";
      $select_sql_query = $mysql->query($select_sql);
      while ($select_sql_query_fetch = $select_sql_query->fetch(PDO::FETCH_ASSOC)) {
              $_SESSION["id"] = $select_sql_query_fetch["id"];
              $_SESSION["password"] = $select_sql_query_fetch["password"];
              $_SESSION["name"] = $select_sql_query_fetch["name"];
              setcookie(name,$_SESSION["name"],1623632328);
        }

      if (!empty($_SESSION["id"])&&!empty($_SESSION["password"])) {

        header('Location: ./kadai_2_ouyou.php');
      }else{
        echo "ID、パスワードが正しくありません";
      }

    }else{
      echo "IDとパスワードは半角英数字で入力してください";
    }
  }else{
    echo "IDとパスワードを両方入力してください";
  }
}

 ?>


<!DOCTYPE html>
<html lang="ja">
  <head>
    <meta charset="utf-8">
    <title>ログインページ</title>
  </head>
  <body>
    <h1>ログインページ</h1>
    <p>*IDとパスワードを半角で入力してください</p>
    <br />
    <form action="kadai_2_ouyou.php" method="post">
      ID:<input type="text" name="roguinn_id" value="<?php if(!empty($_SESSION["id"])){echo $_SESSION["id"];} ?>"><br>
      <br />
      パスワード:<input type="text" name="roguinn_password" value="<?php  if(!empty($_SESSION["password"])){echo $_SESSION["password"];} ?>"><br>
      <br />
      <input type="submit" name="roguinn_submit" value="ログイン">
    </form>
  </body>
</html>
anonymous No title
PHP
<h1><?php echo "登録完了";?></h1>

<?php
$dsn = "mysql:dbname=co_19_349_99sv_coco_com;host=localhost;charset=UTF8";
$name_db = "co-19-349.99sv-c";
$password_db = "U2j9s5dQ";
try {
  $mysql = new PDO($dsn,$name_db,$password_db);
} catch (PDOExcption $e){
  echo "エラー" . $e->getMessage() ;
}
$select_sql = "SELECT * FROM kadai_3_1 WHERE id=(select max(id) from kadai_3_1)";
$select_sql_query = $mysql->query($select_sql);
while ($select_sql_query_fetch = $select_sql_query->fetch(PDO::FETCH_ASSOC)) {
  echo "あなたのユーザー情報は" . "<br>" . "ID:{$select_sql_query_fetch["id"]}" . "<br>" . "名前:{$select_sql_query_fetch["name"]}" . "<br>" . "パスワード:{$select_sql_query_fetch["password"]}";
}
 ?>
anonymous No title
PHP
<?php
$dsn = "mysql:dbname=co_19_349_99sv_coco_com;host=localhost;charset=UTF8";
$name_db = "co-19-349.99sv-c";
$password_db = "U2j9s5dQ";
try {
  $mysql = new PDO($dsn,$name_db,$password_db);
} catch (PDOExcption $e){
  echo "エラー" . $e->getMessage() ;
}
if (!empty($_POST["submit"])) {
  if (!empty($_POST["password"])&&!empty($_POST["name"])) {
     if (preg_match("/^[a-zA-Z0-9]+$/",$_POST["password"])) {
        $name = $_POST["name"];
        $password = $_POST["password"];
        $insert_sql = "INSERT INTO kadai_3_1 (name, password) VALUES (?, ?)";
        $insert_sql_prepare = $mysql->prepare($insert_sql);
        $insert_sql_execute = $insert_sql_prepare->execute(array($name, $password));
        header('Location: kadai_3_1_entry.php');
     }else{
       echo "パスワードは半角英数字で入力してください";
     }
  }else{
    echo "パスワードと名前を両方入力してください";
  }
}
?>
<!DOCTYPE html>
<html lang="ja">
  <head>
    <meta charset="utf-8">
    <title>登録フォーム</title>
  </head>
  <body>
    <h1>新規登録</h1>
    <p>*名前とパスワードを半角で入力してください</p>
    <br />
    <form action="kadai_3_1.php" method="post">
      名前:<input type="text" name="name"><br>
      <br />
      パスワード:<input type="text" name="password"><br>
      <br />
      <input type="submit" name="submit" value="登録">
    </form>
  </body>
</html>
anonymous No title
C++
//迷路(改良ver) はぎさんのやり方を参考にしました
#include <iostream>
#include <random>
#include <ctime>
#include <vector>
#include <stdio.h>

using namespace std;

class Labyrinth {
    private: 
        int xSize;
        int ySize;
        int directionsArray[4][2] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; //コンパイル時warnigが出るが動作には問題なし
        vector<vector<bool> > maze;

    public:
        Labyrinth(int xSize, int ySize);
        bool JudgeEdge(int x_index, int y_index);
        bool judgeDirections(int x_index, int y_index, int direction);
        bool searchDigable();
        vector<int> getMovableDirections(int x_index, int y_index);
        vector<int> getRestartPoint(); 
        vector<int> digRoad(int x_index, int y_index, int digableDirection); 
        void digMaze();
        void print(); 
        ~Labyrinth();
};

//コンストラクタ
Labyrinth::Labyrinth(int xSize, int ySize) {
    srand(time(NULL));
    this->xSize = xSize;
    this->ySize = ySize;
    //迷路の土台を生成
    maze.resize(xSize, vector<bool>(ySize));
    for (int i = 0; i < xSize; i ++) {
        for (int j = 0; j < ySize; j ++) {
            maze[i][j] = false;
        }
    }
    maze[1][1] = true; //スタート地点
}

//引数によって与えられた座標が壁であるかを判定する
bool Labyrinth::JudgeEdge(int x_index, int y_index) {
    int edge_array[4] = {0, ySize - 1, xSize - 1, 0}; // 上, 右, 下, 左の順番
    for (int i = 0; i < 4; i ++) {
        if (i % 2 == 0 && x_index == edge_array[i]) {
            return false;
        } else if (i % 2 == 1 && y_index == edge_array[i]) {
            return false;
        }
    }
    return true;
}

//リスタート地点の取得
vector<int> Labyrinth::getRestartPoint() {
    vector<int> restart_point;
    vector<vector <int> > restart_points;
    for (int i = 1; i < xSize - 1; i ++) {
        for (int j = 1; j < ySize - 1; j ++) {
            if (maze[i][j]) {
                if (getMovableDirections(i, j).size() > 0) {
                    //リスタート地点の座標が入ったらforを抜ける
                    restart_point.push_back(i); //0番目にはx座標
                    restart_point.push_back(j); //1番目にはy座標
                    restart_points.push_back(restart_point);
                    restart_point.clear();
                    break;
                }
            }
        }
    }
    if (restart_points.size() > 0) {
        //x, yの要素番号は一対一対応であるのでxだけ求めれば良い
        int restart_point_index = rand() % restart_points.size();
        restart_point.push_back(restart_points[restart_point_index][0]); //x座標にpush_back
        restart_point.push_back(restart_points[restart_point_index][1]); //y座標にpush_back
        return restart_point;
    }

    restart_point.clear();
    return restart_point;
}

//上下左右に対してその方向に進めるかを判定する
bool Labyrinth::judgeDirections(int x_index, int y_index, int direction) {
    //指定した座標がまだ掘られていない場所かつ壁ではなければ通る
    if (maze[x_index + directionsArray[direction][0]][y_index + directionsArray[direction][1]] == false &&
        JudgeEdge(x_index + directionsArray[direction][0], y_index + directionsArray[direction][1])) {
        return true;
    }

    return false;
}

//judgeDirectionsで返された値からさらにその先へ進めるかの判定->進めたらその方向を返す
vector<int> Labyrinth::getMovableDirections(int x_index, int y_index) {
    vector<int> digable_directions;
    int more_directions[4][3] = {{3, 0, 1}, {0, 1, 2}, {1, 2, 3}, {2, 3, 0}}; //三方向の判定->4パターンあり, 時計回りの順番で判定
    int judge_count = 0; 
    for (int i = 0; i < 4; i ++) {
        for (int j = 0; j < 3; j ++) {
            if (judgeDirections(x_index, y_index, i)) { 
                if (maze[x_index + directionsArray[i][0] + directionsArray[more_directions[i][j]][0]][y_index + directionsArray[i][1] + directionsArray[more_directions[i][j]][1]] == false) {
                    judge_count ++;
                }
            }
        }
        if (judge_count == 3) {
            digable_directions.push_back(i);
        }
        judge_count = 0;
    }    

    return digable_directions;
}

bool Labyrinth::searchDigable() {
    //迷路全体の調査
    for (int i = 1; i < xSize - 1; i ++) {
        for (int j = 1; j < ySize - 1; j ++) {
            if (maze[i][j]) {
                for (int k = 0; k < 4; k ++) {
                    if (getMovableDirections(i, j).size() != 0) {
                        return true;
                    }
                }
            }
        }
    }

    return false;
}

//迷路を作っていく
void Labyrinth::digMaze() {
    int x_index = 1;
    int y_index = 1;
    while(searchDigable() != false) {
        vector<int> directions = getMovableDirections(x_index, y_index);
        if (directions.size() > 0) {
            int digableDirection = rand() % directions.size();
            vector<int> next_point = digRoad(x_index, y_index, directions[digableDirection]);
            //次の座標の設定
            if (next_point.size() > 0) {
                x_index = next_point[0];
                y_index = next_point[1];
            }
        }  else if (directions.size() == 0) {
            vector<int> restart_point = getRestartPoint();
            if (restart_point.size() > 0) {
                x_index = restart_point[0];
                y_index = restart_point[1];
            }
        }
        directions.clear();
    }
    //ゴール地点の生成
    if (maze[xSize - 2][ySize - 2] == false) {
        maze[xSize - 2][ySize - 2] = true;
    }
}

//引数の示す方向に道を作る
vector<int> Labyrinth::digRoad(int x_index, int y_index, int digableDirection) {
    vector<int> next_point;
    for (int i = 0; i < 4; i ++) {
        next_point.push_back(x_index + directionsArray[i][0]);
        next_point.push_back(y_index + directionsArray[i][1]);
        if (i == digableDirection && JudgeEdge(next_point[0], next_point[1]) && maze[next_point[0]][next_point[1]] == false) {
            maze[next_point[0]][next_point[1]] = true;
            return next_point;
        }
        next_point.clear();
    }

    return next_point;
}

//表示関数
void Labyrinth::print() {
    //"◇" : スタート地点, "☆" : ゴール地点
    const char *wall = "■";
    const char *hole = "□";
    const char *start = "◇";
    const char *goal = "☆";
    for (int i = 0; i < xSize; i++) {
        for (int j = 0; j < ySize; j++) {
            printf("%s ", maze[i][j] == false ? (i == 0 && j == 1 ? start : (i == xSize - 1 && j == ySize - 2) ? goal : wall) : hole);
        }
        printf("\n");
    }
}

Labyrinth::~Labyrinth() { //デストラクタ
    vector<vector<bool> >().swap(maze);
}


int main() {
    Labyrinth obj(15, 15);
    obj.digMaze();
    obj.print();

    return 0;
}
anonymous No title
PHP
<!DOCTYPE html>
<html lang="ja">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>簡易掲示板</title>
</head>

<body>

    <h2>入力フォーム</h2>
    <form action="" method="POST">
        <input type="hidden" name="editnumber" size='20' value='' placeholder="名前"><br />
        <input type="text" name="name" size='20' value='' placeholder="名前"><br />
        <input type="text" name="comment" size='20' value='' placeholder="コメント"><br />
        <input type="password" name="password" size='20' value='' placeholder="パスワード"><br />
        <br />
        <input type="submit" name='submit' value='送信' />
    </form>

    <form action="" method="POST">
        <h2>削除フォーム</h2>
        <input type="number" name="deletenumber" size='20' placeholder="削除番号"><br />
        <input type="password" name="deletepassword" placeholder="パスワード"><br />
        <br />
        <input type="submit" name='delete' value='削除' onclick="return confirm('削除しますか?')" />
        <br />
        <br />
    </form>

    <form action="" method="POST">
        <h2>編集フォーム</h2>
        <input type="text" name="editnumber" placeholder="編集番号"><br />
        <input type="password" name="editpassword" placeholder="パスワード"><br />
        <br />
        <input type="submit" name="edit" value="編集"><br />
        <br />
        <br />
    </form>


    <?php
    // データベースへ接続
    try {
        $dsn = 'mysql:dbname=co_19_349_99sv_coco_com;host=localhost';
        $user = 'co-19-349.99sv-c';
        $password = 'U2j9s5dQ';
        $pdo = new PDO($dsn, $user, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
    } catch (PDOException $e) {
        echo 'DB接続エラー' . $e->getMessage;
    }


    // リセット用
    // $sql = "DROP TABLE kadai2a";
    // $pdo->query($sql);


    // テーブルを作成
    $sql = "CREATE TABLE IF NOT EXISTS kadai2a"
        . "("
        . "id INT AUTO_INCREMENT PRIMARY KEY,"
        . "name char(32),"
        . "comment TEXT,"
        . "date DATETIME,"
        . "password TEXT"
        . ");";
    $stmt = $pdo->query($sql);


    // 新規投稿
    if (isset($_POST['submit'])) {
        if (isset($_POST['name']) && (isset($_POST['comment'])) && (isset($_POST['password']))) {
            $sql = $pdo->prepare("INSERT INTO kadai2a (name,comment,date,password) VALUES (:name,:comment,:date,:password)");
            $sql->bindParam(':name', $name, PDO::PARAM_STR);
            $sql->bindParam(':comment', $comment, PDO::PARAM_STR);
            $sql->bindParam(':date', $date, PDO::PARAM_STR);
            $sql->bindParam(':password', $password, PDO::PARAM_STR);
            $name = $_POST['name'];
            $comment = $_POST['comment'];
            date_default_timezone_set('Asia/Tokyo');
            $date = date("Y/m/d H:i:s");
            $password = $_POST['password'];
            $sql->execute();
        }
        if ((empty($name)) || (empty($comment)) || (empty($password))) {
            echo "<script>alert('未入力項目があります')</script>";
        }
    }

    // 編集
    if (isset($_POST['edit'])) {
        if ((isset($_POST['editnumber'])) && (isset($_POST['editpassword']))) {
            $editnumber = $_POST['editnumber'];
            $editpassword = $_POST['editpassword'];
            $results = $pdo->query("SELECT * FROM kadai2a WHERE id= $editnumber");
            foreach ($results as $result) {
                if ($editnumber == $result['id'] && $editpassword == $result['password']) {
                    $editnumber = $result['id'];
                    $editname = $result['name'];
                    $editcomment = $result['comment'];
                    $editpassword = $result['password'];
                    echo "編集番号" . $editnumber
    ?>
                    <form action="<?php echo ($_SERVER['PHP_SELF']) ?>" method="POST">
                        <input type="hidden" name="editnumber" value="<?php if (isset($editnumber)) {
                                                                            echo $editnumber;
                                                                        } ?>">
                        <h3>名前:</h3>
                        <input type="text" name="editname" value="<?php if (isset($editname)) {
                                                                        echo $editname;
                                                                    } ?>">
                        <h3>コメント:</h3>
                        <input type="text" name="editcomment" value="<?php if (isset($editcomment)) {
                                                                            echo $editcomment;
                                                                        } ?>">
                        <h3>パスワード:</h3>
                        <input type="password" name="editpassword" value="<?php if (isset($editpassword)) {
                                                                                echo $editpassword;
                                                                            } ?>"><br />
                                                                            <br />
                        <input type="submit" name="editsubmit" value="編集"><br /><br /><br />
                    </form>
    <?php
                    break;
                } elseif ($editnumber == $result['id'] && $editpassword != $result['password']) {
                    echo "<script>alert('パスワードが違います')</script>";
                }
            }
        }
    }
    if (isset($_POST['editsubmit'])) {
        if (!empty($_POST["editname"]) && (!empty($_POST["editcomment"])) && (!empty($_POST["editpassword"]))) {
            try {
                $dsn = 'mysql:dbname=co_19_349_99sv_coco_com;host=localhost';
                $user = 'co-19-349.99sv-c';
                $password = 'U2j9s5dQ';
                $pdo = new PDO($dsn, $user, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
                $editnumber = $_POST['editnumber'];
                $name = $_POST['editname'];
                $comment = $_POST['editcomment'];
                date_default_timezone_set('Asia/Tokyo');
                $date = date("Y/m/d H:i:s");
                $password = $_POST['editpassword'];
                $sql = "UPDATE kadai2a SET name=:name,comment=:comment,date=:date,password=:password WHERE id=$editnumber";
                $stmt = $pdo->prepare($sql);
                $stmt->execute(array(':name' => $name, ':comment' => $comment, ':date' => $date, ':password' => $password));
            } catch (PDOException $e) {
                echo 'DB接続エラー' . $e->getMessage;
            }
        }
    }


    // 削除
    if (isset($_POST['delete'])) {
        if ((isset($_POST['delete'])) && (isset($_POST['deletepassword']))) {
            $deletenumber = $_POST['deletenumber'];
            $deletepassword = $_POST['deletepassword'];
            $res = $pdo->query('SELECT * FROM kadai2a');
            foreach ($res as $value) {
                if ($deletenumber == $value['id'] && $deletepassword == $value['password']) {
                    $id = $deletenumber;
                    $sql = 'delete from kadai2a where id=:id';
                    $stmt = $pdo->prepare($sql);
                    $stmt->bindParam(':id', $id, PDO::PARAM_INT);
                    $stmt->execute();
                } elseif ($deletenumber == $value['id'] && $deletepassword != $value['password']) {
                    echo "<script>alert('パスワードが違います')</script>";
                }
            }
        }
    }




    // データを表示する
    $sql = 'SELECT * FROM kadai2a';
    $stmt = $pdo->prepare($sql);
    $stmt->execute();
    $results = $stmt->fetchAll();
    foreach ($results as $row) {
        echo $row['id'] . ',';
        echo $row['name'] . ',';
        echo $row['comment'] . ',';
        echo $row['date'] . '<br>';
        echo "<hr>";
    }
    ?>

</body>

</html>
anonymous No title
Python
#!python3

'''
This script implements a simple calculator in the Today widget.

You can toggle between two different button layouts (compact/expanded) using the widget's
built-in "Show More/Less" button. This is accomplished by overriding the `ui.View.layout`
method in the `CalcView` class.
'''

import appex, ui
import console
import os

op_symbols = ('+', '\u2212', '\u00F7', '\u00D7')
operators = {'+': '+', '\u2212': '-', '\u00F7': '/', '\u00D7': '*'}

class CalcView (ui.View):
	def __init__(self, *args, **kwargs):
		super().__init__(self, *args, **kwargs)
		self.shows_result = False
		self.bounds = (0, 0, 400, 200)
		button_style = {'background_color': (0, 0, 0, 0.05), 'tint_color': 'black', 'font': ('HelveticaNeue-Light', 24), 'corner_radius': 3}
		self.number_buttons = [ui.Button(title=str(i), action=self.button_tapped, **button_style) for i in range(10)]
		self.op_buttons = [ui.Button(title=s, action=self.button_tapped, **button_style) for s in op_symbols]
		self.ac_button = ui.Button(title='AC', action=self.button_tapped, **button_style)
		self.ac_button.tint_color = 'red'
		self.add_subview(self.ac_button)
		self.c_button = ui.Button(title='C', action=self.button_tapped, **button_style)
		self.c_button.tint_color = 'red'
		self.add_subview(self.c_button)
		self.eq_button = ui.Button(title='=', action=self.button_tapped, **button_style)
		self.add_subview(self.eq_button)
		self.dot_button = ui.Button(title='.', action=self.button_tapped, **button_style)
		self.add_subview(self.dot_button)
		for b in self.number_buttons + self.op_buttons:
			self.add_subview(b)
		self.display_view = ui.View(background_color=(.54, .94, 1.0, 0.2))
		self.display_label = ui.Label(frame=self.display_view.bounds.inset(0, 8), flex='wh', text='0', alignment=ui.ALIGN_RIGHT)
		self.display_label.font = ('HelveticaNeue-Light', 32)
		self.display_view.add_subview(self.display_label)
		self.add_subview(self.display_view)
	
	def layout(self):
		compact = self.height < 150
		bw = self.width / 10 if compact else self.width / 5
		bh = self.height / 3 if compact else self.height / 5
		for i, b in enumerate(self.number_buttons):
			if compact:
				frame = ui.Rect(((i - 1) % 10) * bw, bh, bw, bh)
			else:
				frame = ui.Rect(max(i-1, 0) % 3 * bw, 3 * bh - (i-1) // 3 * bh, bw, bh)
			b.frame = frame.inset(1, 1)
		for i, b in enumerate(self.op_buttons):
			if compact:
				frame = ui.Rect((4 + i) * bw, 2 * bh, bw, bh)
			else:
				frame = ui.Rect((3 + i % 2) * bw, (2 + i//2) * bh, bw, bh)
			b.frame = frame.inset(1, 1)
		if compact:
			self.ac_button.frame = ui.Rect(0, 2 * bh, 2 * bw, bh).inset(1, 1)
			self.c_button.frame = ui.Rect(2 * bw, 2 * bh, bw, bh).inset(1, 1)
			self.eq_button.frame = ui.Rect(8 * bw, 2 * bh, 2*bw, bh).inset(1, 1)
			self.dot_button.frame = ui.Rect(3 * bw, 2 * bh, bw, bh).inset(1, 1)
		else:
			self.ac_button.frame = ui.Rect(3 * bw, bh, bw, bh).inset(1, 1)
			self.c_button.frame = ui.Rect(4 * bw, bh, bw, bh).inset(1, 1)
			self.eq_button.frame = ui.Rect(3 * bw, 4 * bh, 2*bw, bh).inset(1, 1)
			self.dot_button.frame = ui.Rect(bw, 4 * bh, bw, bh).inset(1, 1)
		self.display_view.frame = (0, 0, self.width, bh)
	
	def button_tapped(self, sender):
		t = sender.title
		label = self.display_label
		if t in '0123456789':
			if self.shows_result or label.text == '0':
				label.text = t
			else:
				label.text += t
		elif t == '.' and label.text[-1] != '.':
			label.text += t
		elif t in op_symbols:
			if label.text[-1] in op_symbols:
				label.text = label.text[:-1] + t
			else:
				label.text += t
		elif t == 'AC':
			label.text = '0'
		elif t == 'C':
			label.text = label.text[:-1]
			if len(label.text) == 0:
				label.text = '0'
		elif t == '=':
			try:
				expr = label.text
				for symbol in op_symbols:
					expr = expr.replace(symbol, operators[symbol])
				result = str(eval(expr))
				if result.endswith('.0'):
					result = result[:-2]
				label.text = result
			except (SyntaxError, ZeroDivisionError):
				label.text = 'ERROR'
			self.shows_result = True
		if t != '=':
			self.shows_result = False

def main():
	# Optimization: Don't create a new view if the widget already shows the calculator.
	widget_name = __file__ + str(os.stat(__file__).st_mtime)
	widget_view = appex.get_widget_view()
	if widget_view is None or widget_view.name != widget_name:
		widget_view = CalcView()
		widget_view.name = widget_name
		appex.set_widget_view(widget_view)

if __name__ == '__main__':
	main()