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
anonymous No title
Python
anonymous No title
Python
anonymous No title
Python
pip install tweepy
anonymous No title
CSS
/*
 ページ全体のフォント設定
*/
html {
  font-family: "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "メイリオ", Meiryo, Osaka, "MS Pゴシック", "MS PGothic", "sans-serif";
  font-size: 13px;
  line-height: 160%;
  color: #333;
}
/*
すべてのブラウザ用に、デフォルトのマージンを取り除く。
*/
body {
  margin: 0;
}

/*
IE9+用に、displayプロパティを定義。
1. Edge, IE, Firefox用、details要素とsummary要素に「display: block;」を定義。
2. IE, Firefox用、main要素に「display: block;」を定義。
*/

article,
aside,
details, /* 1 */
figcaption,
figure,
footer,
header,
main, /* 2 */
menu,
nav,
section,
summary { /* 1 */
display: block;
}

/*
IE9+用、displayプロパティを定義。
*/

audio,
canvas,
progress,
video {
display: inline-block;
}

/* Clearfix */
.clearfix:after {
  content:" ";
  display:block;
  clear:both;
}

/* 追加マージン */
.mb5 {margin-bottom: 5px !important;}
.mb10 {margin-bottom: 10px !important;}
.mb15 {margin-bottom: 15px !important;}
.mb20 {margin-bottom: 20px !important;}
.mb30 {margin-bottom: 30px !important;}
.mb40 {margin-bottom: 40px !important;}

strong {
  color: #FF5722;
}

em {
  font-weight: bold;
  text-decoration: underline;
}

/*****************************************
レイアウト関連
******************************************/

/* wrapper関連
**********************/



.wrapper {
  width: 100%;
  margin: 0;
}

.row1 {
  border-top: 3px solid #263238;
  background: url(../images/bg_head.gif);
}
.row2 {
  background: #263238;
}
.row3 {
  background: #ECEFF1;
  margin-bottom: 13px;
  padding: 13px 0;
}.row4 {
  margin-top: 20px;
}
.row5 {
  background: #263238;
}/* ヘッダー
**********************/
/* グローバルナビゲーション
**********************/
#g_navi {
    width: 960px;
    margin: 0 auto;
}
 
/* メインビジュアル
**********************/
#mainvisual {
    width: 960px;
    margin: 0 auto;
}
 
/* メインコンテンツ
**********************/
main {
    width: 960px;
    margin: 0 auto;
}

#main_contents {
  float: left;
}

/* サイドメニュー
**********************/
#side_contents {
  float: right;
}
anonymous No title
HTML
<!DOCTYPE html>
<html lang="ja">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="uxin.css">
</head>

<body>

  <body>
    <div class="wrapper row1">
      <header id="main_header"> id "main_header" の内容がここに入ります</header>
    </div>
    <div class="wrapper row2">
      <nav id="g_navi"> id "g_navi" の内容がここに入ります</nav>
    </div>
    <div class="wrapper row3">
      <p id="mainvisual">メインビジュアルがここに入ります。</p>
    </div>
    <div class="wrapper row4">
      <main class="clearfix">
        <article id="main_contents"> id "main_contents" の内容がここに入ります</article>
        <aside id="side_contents"> id "side_contents" の内容がここに入ります</aside>
      </main>
    </div>
    <div class="wrapper row5">
      <footer id="main_footer"> id "main_footer" の内容がここに入ります</footer>
    </div>
  </body>


</body>

</html>




anonymous No title
Python
import discord
import os
from dotenv import load_dotenv
import random

class Ciao:
	def __init__(self):
		self.joining = False
		self.players = []
		self.player_ids = []
		self.turn = 0
		self.current_turn = 0
		self.current_player_roll = ""
		self.pieces = []
		self.pieces_position = []
		self.point_num = 0
		self.points = []
		self.players_num = 0
		self.orders = {}
		self.goal_flag = False

	async def main(self,message):
		self.joining = False
		self.advance_turn()
		await self.show_roll(message)
		for player in self.players:
			await self.channel.send("{}の位置:{}".format(player,self.pieces_position[self.orders[player]]))
		await self.finish_check()

	def advance_turn(self):
		self.current_turn += 1

	def create_roll(self):
		self.current_true_roll = str(random.randrange(1,6))

	async def finish_check(self):
		finish = False
		for piece in self.pieces:
			if piece == 0:
				finish = True
		if finish:
			i = 0
			tmp = 0
			for point in self.points:
				i += 1
				await self.channel.send("{}さん {}ポイント".format(self.players[i],point))
				if tmp < point:
					winner = self.players[i]
					tmp = point
			await self.channel.send("{}ポイントで、{}さんの勝利".format(tmp,winner))



	async def show_roll(self,message):
		who_turn = self.current_turn % len(self.players)
		if who_turn == 0:
			who_turn = len(self.players)
		self.current_player = self.players[who_turn - 1]
		await self.channel.send("{}さんの番です".format(self.current_player))
		user = client.get_user(self.player_ids[who_turn - 1])
		self.create_roll()
		await user.send(self.current_true_roll)

	async def check(self,message):
		self.pointer = message.author.name
		await self.channel.send("サイコロの出目:{}".format(self.current_true_roll))
		if self.current_true_roll != self.current_player_roll:
			#うそ
			self.delete_pieces(self.orders[self.current_player])
			self.advance_pieces(self.orders[self.pointer],self.current_player_roll)
			await self.channel.send("{}さんは嘘をついたため、現在駒数は{}です".format(self.current_player,self.pieces[self.orders[self.current_player]]))
		else:
			#ほんとう
			self.delete_pieces(self.orders[self.pointer])
			self.advance_pieces(self.orders[self.current_player],self.current_player_roll)
			await self.channel.send("{}さんは嘘をついていなかったため、{}さんの現在駒数は{}です".format(self.current_player,self.pointer,self.pieces[self.orders[self.pointer]]))
		await ciao.main(message)
	def add_member(self,author):
		if not(author.name in self.players):
			self.players.append(author.name)
			self.player_ids.append(author.id)
			self.pieces.append(7)
			self.pieces_position.append(0)
			self.points.append(0)
			self.orders[author.name] = self.players_num
			self.players_num += 1
	async def advance_pieces(self,piece_num,roll):
		self.pieces_position[piece_num] += int(roll)
		if self.pieces_position[piece_num] > 7:
			self.point_num += 1
			self.pieces_position[piece_num] = 0
			self.points[piece_num] += self.point_num
			await self.channel.send("{}さんがゴール {}ポイント獲得しました".format(self.players[piece_num],self.point_num))
	def delete_pieces(self,piece_num):
		self.pieces_position[piece_num] = 0
		self.pieces[piece_num] -= 1
		
ciao = Ciao()
load_dotenv()
client = discord.Client()

@client.event
async def on_ready():
	print(discord.__version__)
	
@client.event
async def on_message(message):
	if message.content.startswith("!on"):
		if client.user != message.author:
			ciao.channel = message.channel
			ciao.joining = True
			await ciao.channel.send("チャオチャオを開始します")
	if message.content.startswith("!j") and ciao.joining:
		if len(ciao.players) < 4:
			ciao.add_member(message.author)
			await message.channel.send(message.author)
		else:
			await message.channel.send("参加者リスト:{}".format(ciao.players))
			await ciao.main(message)
	if message.content.startswith("!e"):
			await message.channel.send("参加者リスト:{}".format(ciao.players))
			await ciao.main(message)
	if message.content.startswith("!n"):
		await ciao.advance_pieces(ciao.orders[ciao.current_player],ciao.current_player_roll)
		await ciao.main(message)
	if (message.content.startswith("1") or message.content.startswith("2") or message.content.startswith("3") or message.content.startswith("4")):
		if client.user != message.author:
			ciao.current_player_roll = message.content
	if message.content.startswith("!d"):
		await ciao.check(message)


client.run(os.environ["API_KEY"])
anonymous No title
JavaScript
function() {
  var _ret = document.querySelector('[data-checkout-payment-due-target]').dataset.checkoutPaymentDueTarget;
  if(_ret === undefined){
  	return _ret;
  }
  else{
  	return _ret / 100;
  }

}
anonymous No title
PHP
<html>
<head><title>課題2-6 ver. SQL</title>
<meta charset="utf-8"/>

<script type="text/javascript">
Comlis=[];//グローバルです
function check(){
 if(window.confirm("ほんとうに削除しますか?"))return true;
 else return false;
}
function printComment(Clis,jun){
document.getElementById("PRComments").innerHTML="";
if (jun==-1)Clis.reverse();
Clis.forEach(Element=>document.getElementById("PRComments").innerHTML+=Element);
if (jun==-1)ClisR=Clis.reverse();
}

</script>
<?php
function h($str) {
    return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
}
?>

</head>
<body>
<?php
//!!環境変数になる--------------------------------------------------------------!!環境変数になる
$sqluid=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
$sqlhost=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
$sqldbname=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
$sqlpswd=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
//!!環境変数になる--------------------------------------------------------------!!環境変数になる
$Ermes="";
?>

名前、コメント、パスワードを入力してください<br>
<form action="kadai2_6_sql.php" method="POST">
<?php
if(isset($_POST["editn"]) && $_POST["editn"]!=null && 
    isset($_POST["pswd"])){

try{
 $database=new PDO("mysql:host=".$sqlhost.";dbname=".$sqldbname.";charset=utf8",$sqluid,$sqlpswd);
 $sql="create table if not exists ".$sqldbname.".keiziban(num int,name nvarchar(10),comment nvarchar(1000),date datetime,status nvarchar(2),pswd nvarchar(8))";
 $database->query($sql);
 //dbがなければ生成

$sql="select num,name,comment,pswd from keiziban limit 1 offset ".($_POST["editn"]-1);
$R=$database->query($sql);
$RR = $R->fetchAll();

if(count(array_column($RR,'pswd'))==0)$Ermes="<br>編集失敗:存在しない投稿<br>";
  $rqpswd=array_column($RR,'pswd')[0];
  if ($_POST["pswd"]!=$rqpswd ){
 $Ermes="<br>編集失敗:パスワードが一致しません<br>";
 $_POST["pswd"]=null;
 }
else{
 if ($_POST["pswd"]==array_column($RR,'pswd')[0])
 $_POST["pswd"]=array_column($RR,'pswd')[0];
 $_POST["name"]=array_column($RR,'name')[0];
 $_POST["comment"]=array_column($RR,'comment')[0];
 echo('<input type="hidden" name="editN" size="4" value="'.$_POST['editn'].'">');
}
}catch(PDOException $e){
 echo $e->getMessage();
 die();
}
}
?>
 名前  <input type="text" name="name" size="15" value="<?php if (isset($_POST['name']) && isset($_POST['comment'])&& isset($_POST['pswd'])) if ($_POST['comment']==null  || $_POST['pswd']==null)  echo($_POST['name']) ;
if(isset($_POST["editn"]) && $_POST["editn"]!=null && isset($_POST['name']))echo($_POST['name'])  ?>">
<br>

コメント <input type="text" name="comment" size="80" value="<?php if (isset($_POST['name']) && isset($_POST['comment']) && isset($_POST['pswd'])) if($_POST['name']==null  || $_POST['pswd']==null) echo ($_POST['comment']);
if(isset($_POST["editn"]) && $_POST["editn"]!=null && isset($_POST['comment']))echo($_POST['comment'])  ?>"><br>

パスワード<input type="text" name="pswd" size="8"

<?php
if(isset($_POST["editn"]) && $_POST["editn"]!=null && isset($_POST['pswd']))echo(' value="'.$_POST['pswd'].'"') ;
?>

><br>
<input type="submit" value="送信"><input type="reset" value="リセット"><br>
</form>

<?php
try{
 $database=new PDO("mysql:host=".$sqlhost.";dbname=".$sqldbname.";charset=utf8",$sqluid,$sqlpswd);
$sql="create table if not exists ".$sqldbname.".keiziban(num int,name nvarchar(10),comment nvarchar(1000),date datetime,status nvarchar(2),pswd nvarchar(8))";
$database->query($sql);
//dbがなければ生成


$sql="select * from keiziban";
$getcomm=$database->query($sql);
$data = $getcomm->fetchAll();

if (count(array_column($data,'num'))==0)$LineN=1;
else $LineN=1+max(array_column($data,'num'));

if( isset($_POST["comment"])&& isset($_POST["name"]) &&  isset($_POST["pswd"])){
 if(($_POST["name"])==null)echo("名前入力に不備があります<br>");
 if( $_POST["comment"]==null)echo("コメント入力に不備があります<br>");
 if( $_POST["pswd"]==null)echo("パスワード入力に不備があります<br>");
 if( $_POST["comment"]!=null && ($_POST["name"])!=null && ($_POST["pswd"])!=null){
  if(isset($_POST["editN"])==False && isset($_POST["editn"])==False){
   $sql = "insert into keiziban (num,
                                                 name, 
                                                 comment,
                                                 date,status,
                                                 pswd
                                                 ) 
                                  values (".$LineN.",
                                           ('".$_POST["name"]."'),
                                           ('".$_POST["comment"]."'),
                                                  now(),('送信'),
                                           ('".$_POST["pswd"].
                                                 "'))";

   $statement=$database->query($sql);
   //echo($sql);echo("<br>");
   //var_dump($statement);
   echo("<br>コメント送信しました<br>");
   $LineN+=1;
  }
 }
}

if(isset($_POST["delete"])&& isset($_POST["pswd"])){//削除
 $sql="select num,pswd from keiziban limit 1 offset ".($_POST["delete"]-1);
 $R=$database->query($sql);
 $RR = $R->fetchAll();
 //var_dump(array_column($data,'pswd'));
 if(count(array_column($RR,'pswd'))==1){
 $rqpswd=array_column($RR,'pswd')[0];
  if ($_POST["pswd"]!=$rqpswd )$Ermes="<br>削除失敗:パスワードが一致しません<br>";
  else{
   //var_dump(array_column($data,'num'));
   $delnum=array_column($RR,'num')[0];
   
   $sql="delete from keiziban where num=".($delnum);
   $database->query($sql);
  }
}
else $Ermes="<br>削除失敗:投稿が存在しません<br>";
}

if(isset($_POST["editN"])){//Edit
 $sql="select num,pswd from keiziban limit 1 offset ".($_POST["editN"]-1);
 $R=$database->query($sql);
 $RR = $R->fetchAll();
 if(count(array_column($RR,'pswd'))==1){
   $rqpswd=array_column($RR,'pswd')[0];
   $editnum=array_column($RR,'num')[0];
   $sql="update keiziban set comment='".$_POST["comment"].
                                                  "',name='".$_POST["name"].
                                                  "',pswd='".$_POST["pswd"].
                                                  "',date=now()
                                                    ,status='編集' 
                                                               where num=".$editnum;

   $database->query($sql);
  
}
else $Ermes="<br>編集失敗:投稿が存在しません<br>";
}

//掲示板表示
echo("表示順<a href='javascript:printComment(Comlis,1)'>▲</a><a href='javascript:printComment(Comlis,-1)'>▼</a><br>");
$sql="select * from keiziban";
$getcomm=$database->query($sql);
if ($LineN==1)echo("コメントはまだありません<br>");
$comN=0;
echo('<div id="PRComments">');
foreach($getcomm as $R){
$comN+=1;

$commone=h("No. ".$comN." 投稿者 ".$R["name"]).
("<br>").
(h($R["comment"])).///コメント内容
("<br>").
(h($R["status"].//変更or更新のステータス
       "日時:".$R["date"])).
("<br><br>");

echo ($commone);

echo ("<script type='text/javascript'>Comlis.push('".$commone."');</Script>");
}
echo('</div>');

}catch(PDOException $e){
 echo $e->getMessage();
 die();
}
echo($Ermes);
$database=null;
?>

<br><form action="kadai2_6_sql.php" method="POST" onSubmit="return check()">
削除フォーム<input type="number" name="delete" size="4"><br>
パスワード<input type="text" name="pswd" size=8><br>
<input type="submit" value="送信"><input type="reset" value="リセット">
</form>
<br><form action="kadai2_6_sql.php" method="POST">
編集フォーム<br>
編集する投稿番号<input type="number" name="editn" size="4"><br>
パスワード<input type="text" name="pswd" size=8><br>
<input type="submit" value="送信"><input type="reset" value="リセット">
</form>
</body>
</html>
anonymous e 1000 桁計算
Fortran
real :: m(1000) = 1
do j = 1, 2000, 2
    do i = 1000, 2, -1
        n = 10*m(i) + k
        k = n / i
        m(i) = n - k * i
    end do
    print'(ag0$)','2.'(j:),k
end do   
end