Home | First | Prev | Next | Last |
Yamada,Takao,takao@yamada.com,123-456-7890 Amano,Jiro,jiro_amano@gmail.com,987-654-3210 Terada,Takao,tt@terada.co.jp,456-789-0123これをエディタで開いて編集というのでは、Linux を使っている意味がありません。cut の -d オプションで区切り文字を、-f でフィールドを指定。次のコマンドで、期待した結果を得られました。
$ cut -d, -f1 input_file > output_file
year % 4 == 0 and (year % 100 != 0 or year % 400 == 0
# 各月の日数、月の名前、曜日の名前、出力したい年月の指定 days_of_the_month = (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) names_of_the_month = ('', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec') names_of_the_day = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat') year = 2021 month = 4 # 1900年1月1日から、その年の1月1日までの日数 days = 0 for y in range(1900, year): days += 365 + (y % 4 == 0) - (y % 100 == 0 and y % 400 != 0) # その年の前の月までの日数を加える for m in range(1, month): days += days_of_the_month[m] # その年がうるう年だったら if month > 2: days += (year % 4 == 0) - (year % 100 == 0 and year % 400 != 0)
# その月の名前と日数 name_of_the_month = names_of_the_month[month] the_days_of_the_month = days_of_the_month[month] # その年がうるう年だったら if month == 2: the_days_of_the_month += (year % 4 == 0) - (year % 100 == 0 or year % 400 != 0) # 一ヶ月分の日付を出力 for date in range(1, the_days_of_the_month + 1): weekday = days % 7 the_name_of_the_day = names_of_the_day[weekday] print('{}, {} {}, {}' .format(the_name_of_the_day,name_of_the_month,date,year)) days += 1
import calendar name_of_the_month = names_of_the_month[month] the_days_of_the_month = calendar.monthrange(year,month)[1] for date in range(1, the_days_of_the_month + 1): weekday = calendar.weekday(year,month,date) the_name_of_the_day = names_of_the_day[weekday] print('{}, {} {}, {}' .format(the_name_of_the_day,name_of_the_month,date,year))
#!/usr/bin/env python3 # hello.cgi # print("Content-Type: text/html") print() print("<html><h1>Hello World!</h1></html>")私が最初に作ったファイルは、第一行目の Python へのパスが間違っていたのだと思います。これで Python で作った CGI を Synology Web Station でも使えることが分かったので、Synology Web Station でも、少しづつ CGI を Python で書いていこうと思います。
<div style="text-align:center;padding:1em 0;"> <h4><a style="text-decoration:none;" href="https://www.zeitverschiebung.net/en/country/jp"><span style="color:gray;">Current local time in</span><br />Japan</a></h4> <iframe src="https://www.zeitverschiebung.net/clock-widget-iframe-v2?language=en&size=small&timezone=Asia%2FTokyo" width="100%" height="90" frameborder="0" seamless></iframe> </div>これを、表示したいウェブページにペーストするだけで、きれいなデジタル時計を表示できます。
<iframe src="https://www.zeitverschiebung.net/clock-widget-iframe-v2?language=en&size=small&timezone=Asia%2FTokyo" width="100%" height="90" frameborder="0" seamless></iframe>size は small, medium, large の中から選ぶことができます。「秒」を表示したくなければオプションに show=hour_minute を加えます。
var today = new Date(); var year = today.getYear(); var month = today.getMonth(); var day = today.getDate(); var hrs = today.getHours(); var mins = today.getMinutes(); var secs = today.getSeconds();
if(year < 1000){ year += 1900; } var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var monthName = monthArray[month]; let date = `${monthName} ${day}, ${year}`;時刻のほうは次のようにしました。
var period = "a.m."; if (hrs == 12) { period = "p.m."; } if (hrs > 12) { hrs -= 12; period = "p.m."; } if (hrs < 10) { hrs = " " + hrs; } if (mins < 10) { mins = "0" + mins; } if (secs < 10) { secs = "0" + secs; } let time = `${hrs}:${mins}:${secs} ${period}`;
<div id="date"></div> <div id="time"></div>と記入しておいて、JavaScript に
document.getElementById('date').innerHTML = date; document.getElementById('time').innerHTML = time;と記述すれば出来ます。
<html> <head> <script languate="JavaScript"> function startTime() { var today = new Date(); var day = today.getDate(); var month = today.getMonth(); var year = today.getYear(); if(year > 1000){ year += 1900; } var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var monthName = monthArray[month]; let date = `${monthName} ${day}, ${year}`; document.getElementById('date').innerHTML = date; var hrs = today.getHours(); var mins = today.getMinutes(); var secs = today.getSeconds(); var period = "a.m."; if (hrs == 12) { period = "p.m."; } if (hrs > 12) { hrs -= 12; period = "p.m."; } if (hrs < 10) { hrs = " " + hrs; } if (mins < 10) { mins = "0" + mins; } if (secs < 10) { secs = "0" + secs; } let time = `${hrs}:${mins}:${secs} ${period}`; document.getElementById('time').innerHTML = time; } setInterval('startTime()', 1000); </script> </head> <body onload="startTime()"> <div id="date"></div> <div id="time"></div> </body> </html>
var today = new Date(); var gmtMS = today.getTime() + (today.getTimezoneOffset() * 60000) var gmtTime = new Date(gmtMS); var hrs = gmtTime.getHours(); var mins = gmtTime.getMinutes(); var secs = gmtTime.getSeconds(); var zone = 9; hrs = hrs + zone; if (hrs >= 24) { hrs = hrs - 24; day -= -1; } if (hrs < 0) { hrs -= -24; day -= 1; } var period = "a.m."; if (hrs == 12) { period = "p.m."; } if (hrs > 12) { hrs -= 12; period = "p.m."; } if (hrs < 10) { hrs = " " + hrs; } if (mins < 10) { mins = "0" + mins; } if (secs < 10) { secs = "0" + secs; } let time = `${hrs}:${mins}:${secs} ${period}`; document.getElementById('time').innerHTML = time;
var year = gmtTime.getYear(); var month = gmtTime.getMonth(); var day = gmtTime.getDate(); var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var monthDays = new Array("31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"); if (year%4 == 0){ monthDays = new Array("31", "29", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"); } if(year%100 == 0 && year%400 != 0){ monthDays = new Array("31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"); } hrs = hrs + zone; if (hrs >= 24) { hrs -= 24; day += 1; } if (hrs < 0) { hrs += 24; day -= 1; } if (day <= 0){ if (month == 0){ month = 11; year -= 1; } else{ month -= 1; } day = monthDays[month]; } if(day > monthDays[month]){ day = 1; if(month == 11){ month = 0; year += 1; } else{ month += 1; } } var monthName = monthArray[month]; let date = `${monthName} ${day}, ${year}`; document.getElementById("date").innerHTML = date;
<style> .digital_am { font-family:sans-serif;color:black;background-color:white;border:solid 1px black;border-radius:8px;padding:3px;font-size:24pt;font-weight:bold; } .digital_pm { font-family:sans-serif;color:white;background-color:black;border-radius:8px;padding:4px;font-size:24pt;font-weight:bold; } .digital_sep { font-family:sans-serif;color:black;font-size:24pt;font-weight:bold; } .digital_secs { font-family:sans-serif;color:black;background-color:lightgray;border-radius:8px;padding:4px;font-size:24pt;font-weight:bold; } .digital_period { font-family:sans-serif;color:gray;font-size:18pt;font-weight:bold; } </style>
var sep = "<span class='digital_sep'>" + ":" + "</span>"; if (period == "a.m.") { hrs = "<span class='digital_am'>" + hrs + "</span>"; mins = "<span class='digital_am'>" + mins + "</span>"; } else { hrs = "<span class='digital_pm'>" + hrs + "</span>"; mins = "<span class='digital_pm'>" + mins + "</span>"; } secs = "<span class='digital_secs'>" + secs + "</span>"; period = "<span class='digital_period'>" + period + "</span>"; time = hrs + sep + mins + sep + secs + " " + period;
Perl
$ENV{TZ} = 'Asia/Tokyo'; tzset; my $tokyo = localtime; print "Tokyo time is $tokyo\n";
Python
from datetime import datetime, timedelta, timezone JST = timezone(timedelta(hours = +9), 'JST') s = datetime.now(JST) print(s)
$ pdftoppm -jpeg Seminar.pdf Seminarを実行すると、
Seminar-1.jpg Seminar-2.jpg Seminar-3.jpgのようにスライド画像が出力されました。
$ pdftoppm -singlefile -jpeg -scale-to 850 Book.pdf BookCoverこれを実行すると
BookCover.jpgができました。GIMP で作るよりも小さいサイズになりました。
function findWeekday(year, thisMonth, day) { var monthDays2 = new Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); var weekdayNames = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); var days = 0; var y = 2017; while (y < year) { days += 365 + (y % 4 == 0) - (y % 100 == 0 && y % 400 != 0); y++; } var m = 1; while (m < thisMonth) { days = days + monthDays2[m]; m++; } if (thisMonth > 2) { days = days + (year % 4 == 0) - (year % 100 == 0 && year % 400 != 0); } weekday = (days + day - 1) % 7; return weekdayNames[weekday]; }
💻 💻 💻
.rotate { display:inline-block;transform:rotate(180deg); } .reverse { display:inline-block;transform:scaleX(-1);filter:FlipH; }
🇺🇳
🇺🇳
<img src='https://www.countryflags.io/us/flat/64.png'> <img src='https://www.countryflags.io/us/shiny/64.png'>とすれば、アメリカの国旗が次のように表示されます。
このサービスでの国旗の最小サイズは 16px、最大は 64px です。
$bin_string =~ /^[\d][\d][\d][\d]([\d][\d][\d][\d])[\d][\d]([\d][\d][\d][\d])([\d][\d])[\d][\d]([\d][\d])([\d][\d][\d][\d])$/;図で書くと次のようになります。後ろから 8 bit づつ取り出しますが、後ろから 2番目と 4番目の上位 2 bit は飛ばします。
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
X | X | X | X | ① | ① | ① | ① | X | X | ② | ② | ② | ② | ③ | ③ | X | X | ③ | ③ | ④ | ④ | ④ | ④ |
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
X | X | X | X | X | X | ① | ① | X | X | ① | ① | ② | ② | ② | ② | X | X | ③ | ③ | ③ | ③ | ④ | ④ | X | X | ④ | ④ | ⑤ | ⑤ | ⑤ | ⑤ |
$emoji = "🍀"; @chars = split //, $emoji; $bin_string = ""; $i = 0; for $char (@chars) { $bin = sprintf("%b", ord($char)); $bin_string = $bin_string . $bin; $i++; } if ($i == 3) { $bin_string =~ /^[\d][\d][\d][\d]([\d][\d][\d][\d])[\d][\d]([\d][\d][\d][\d])([\d][\d])[\d][\d]([\d][\d])([\d][\d][\d][\d])$/; $emoji_code = sprintf("%x%x%x%x",oct("0b$1"), oct("0b$2"),oct("0b$3$4"),oct("0b$5")); print "$emoji_code;\n"; } elsif ($i == 4) { $bin_string =~ /^[\d][\d][\d][\d][\d][\d]([\d][\d])[\d][\d]([\d][\d])([\d][\d][\d][\d])[\d][\d]([\d][\d][\d][\d])([\d][\d])[\d][\d]([\d][\d])([\d][\d][\d][\d])$/; $emoji_code = sprintf("%x%x%x%x%x",oct("0b$1$2"),oct("0b$3"),oct("0b$4"),oct("0b$5$6"),oct("0b$7")); print "$emoji_code;\n"; }
1 00:00:04,361 --> 00:00:05,866 みなさんこんにちわ。 2 00:00:05,966 --> 00:00:10,612 ペンギン・クラブにようこそ。 3 00:00:10,712 --> 00:00:12,727 きょうのメニューです。subtilteeditor のプロジェクトファイルでは開始時刻と終了時刻がミリ秒で表示されているので、それを HH:MM:SS,XXX 形式に変換すればよいわけです。私が使った動画は数分の短いものでしたので HH のところは 00 にして省略してあります。コードは次のようになります。
@lines = `cat input_video.sep`; foreach $line (@lines) { chomp $line; if ($line =~ /<subtitle duration="[\d]+" effect="" end="([\d]+)" layer="0" margin-l="0" margin-r="0" margin-v="0" name="" note="" path="([\d]+)" start="([\d]+)" style="Default" text="([^"]+)" translation=""\/>/) { $end = $1; $number = $2 + 1; $start = $3; $text = $4; $start = &get_timing($start); $end = &get_timing($end); print $number . "\n" . $start . " --> " . $end . "\n" . $text . "\n\n"; } } sub get_timing { my ($timing) = @_; $seconds = int ($timing / 1000); $mil = $timing % 1000; $min = int ($seconds / 60); $sec = $seconds % 60; if ($min < 10) { $min= "0$min"; } if ($sec < 10) { $sec= "0$sec"; } if ($mil < 10) { $mil = "00$mil"; } elsif ($mil < 100) { $mil = "0smil"; } return "00:$min:$sec,$mil"; }
$ sudo apt insatall x11vnc次に x11vnc にパスワードを設定しました。
$ x11vnc -storepasswd Enter VNC password: Verify password: Write password to /home/pi/.vnc/passwd? [y]/n Password written to: /home/penguin/.vnc/passwdそして、次のコマンドで VNC を起動しました。
$ x11vnc -usepw -forever -display :0
## Setup $ curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg $ sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/ $ sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list' $ sudo rm microsoft.gpg ## Install $ sudo apt update $ sudo apt install microsoft-edge-dev
${1} ${2} ${3} ${4}最後に下部に ZIP+4 のバーコードをつけました。
chrome://accessibility/と記入して、LINE アプリへのリンクを見つけ、それを、ランチャーに指定しました。
Home | First | Prev | Next | Last |