use "/opt/bitnami/ctlscript.sh"
sudo /opt/bitnami/ctlscript.sh restart apache
Let's Encrypt certificate is replaced by the command below
"--dry-run": testing process. no execution
"--force-renew": force renew certificate. Without this option, certificate which needs more time to expired is not replaced.
# ./certbot-auto renew --force-renew --dry-run
Encountered error below.
# ./certbot-auto renew --force-renew --dry-run
Error: couldn't get currently installed version for /opt/eff.org/certbot/venv/bin/letsencrypt:
Traceback (most recent call last):
File "/opt/eff.org/certbot/venv/bin/letsencrypt", line 7, in <module>
from certbot.main import main
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/certbot/main.py", line 10, in <module>
import josepy as jose
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/__init__.py", line 41, in <module>
from josepy.interfaces import JSONDeSerializable
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/interfaces.py", line 8, in <module>
from josepy import errors, util
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/util.py", line 4, in <module>
import OpenSSL
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/rand.py", line 12, in <module>
from OpenSSL._util import (
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/_util.py", line 6, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
ImportError: No module named cryptography.hazmat.bindings.openssl.binding
Error message wouldn't change even the modules are installed.
# pip install cryptography hazmat bindings openssl binding
Collecting cryptography
# ./certbot-auto renew --force-renew --dry-run
Error: couldn't get currently installed version for /opt/eff.org/certbot/venv/bin/letsencrypt:
Traceback (most recent call last):
File "/opt/eff.org/certbot/venv/bin/letsencrypt", line 7, in <module>
from certbot.main import main
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/certbot/main.py", line 10, in <module>
import josepy as jose
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/__init__.py", line 41, in <module>
from josepy.interfaces import JSONDeSerializable
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/interfaces.py", line 8, in <module>
from josepy import errors, util
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/util.py", line 4, in <module>
import OpenSSL
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/rand.py", line 12, in <module>
from OpenSSL._util import (
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/_util.py", line 6, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
ImportError: No module named cryptography.hazmat.bindings.openssl.binding
Error message is changed after executing the command below. It means pip path used by Let's Encrypt is different.
# /opt/eff.org/certbot/venv/bin/pip install -U certbot
# sudo ./certbot-auto renew --force-renew --dry-run --debug
Error: couldn't get currently installed version for /opt/eff.org/certbot/venv/bin/letsencrypt:
Traceback (most recent call last):
File "/opt/eff.org/certbot/venv/bin/letsencrypt", line 7, in
from certbot.main import main
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/certbot/main.py", line 10, in
import josepy as jose
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/__init__.py", line 44, in
from josepy.interfaces import JSONDeSerializable
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/interfaces.py", line 8, in
from josepy import errors, util
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/util.py", line 4, in
import OpenSSL
ImportError: No module named OpenSSL
Install "openssl" with the pip path.
# /opt/eff.org/certbot/venv/bin/pip install pyOpenSSL
# sudo ./certbot-auto renew --force-renew --dry-run --debug
Error: couldn't get currently installed version for /opt/eff.org/certbot/venv/bin/letsencrypt:
Traceback (most recent call last):
File "/opt/eff.org/certbot/venv/bin/letsencrypt", line 7, in
from certbot.main import main
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/certbot/main.py", line 10, in
import josepy as jose
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/__init__.py", line 44, in
from josepy.interfaces import JSONDeSerializable
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/interfaces.py", line 8, in
from josepy import errors, util
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/util.py", line 4, in
import OpenSSL
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in
from OpenSSL import crypto, SSL
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/crypto.py", line 12, in
from cryptography import x509
ImportError: No module named cryptography
Also install "cryptigraphy".
"no module named cryptography" error even cryptography module is installed successfully.
# /opt/eff.org/certbot/venv/bin/pip install cryptography
# sudo ./certbot-auto renew --force-renew --dry-run --debug
Error: couldn't get currently installed version for /opt/eff.org/certbot/venv/bin/letsencrypt:
Traceback (most recent call last):
File "/opt/eff.org/certbot/venv/bin/letsencrypt", line 7, in
from certbot.main import main
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/certbot/main.py", line 10, in
import josepy as jose
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/__init__.py", line 44, in
from josepy.interfaces import JSONDeSerializable
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/interfaces.py", line 8, in
from josepy import errors, util
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/util.py", line 4, in
import OpenSSL
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in
from OpenSSL import crypto, SSL
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/crypto.py", line 12, in
from cryptography import x509
ImportError: No module named cryptography
only put "sudo" to avoid the error.
# sudo /opt/eff.org/certbot/venv/bin/pip install cryptography
# sudo ./certbot-auto renew --force-renew --dry-run --debug
Error: couldn't get currently installed version for /opt/eff.org/certbot/venv/bin/letsencrypt:
Traceback (most recent call last):
File "/opt/eff.org/certbot/venv/bin/letsencrypt", line 7, in
from certbot.main import main
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/certbot/main.py", line 11, in
import zope.component
File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/zope/component/__init__.py", line 16, in
from zope.interface import Interface
ImportError: No module named interface
Install "interface" as same way.
# sudo /opt/eff.org/certbot/venv/bin/pip install interface
Successfully replaced certificate, finally!
# sudo ./certbot-auto renew --force-renew --dry-run --debug
Saving debug log to /var/log/letsencrypt/letsencrypt.log
-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/www.yoshiislandserver.net.conf
-------------------------------------------------------------------------------
Plugins selected: Authenticator standalone, Installer None
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for www.yoshiislandserver.net
Waiting for verification...
Cleaning up challenges
-------------------------------------------------------------------------------
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/www.yoshiislandserver.net/fullchain.pem
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates below have not been saved.)
Congratulations, all renewals succeeded. The following certs have been renewed:
/etc/letsencrypt/live/www.yoshiislandserver.net/fullchain.pem (success)
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates above have not been saved.)
-------------------------------------------------------------------------------
IMPORTANT NOTES:
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
% python -V
Python 3.5.0
% pip install dataspyre
% tree
.
├── csv_update.py
├── data
│ ├── test_data.csv
% cat data/test_data.csv
data1,data2,data3,data4,data5
haha,hihi,huhu,hehe,hoho
gaga,gigi,gugu,gege,gogo
rara,riri,ruru,rere,roro
% python csv_update.py



% tree
.
├── csv_update.py
├── data
│ ├── test_data.csv
│ ├── test_data.csv_20180103173523
│ └── test_data.csv_20180103174330
% cat data/test_data.csv
data1,data2,data3,data4,data5
haha,hihi,huhu,hehe,hoho
gaga,gigi,gugu,gege,gogo
rara,riri,ruru,rere,roro
data1,data2,data3,data4,data5
% ifconfig
......
vmnet1: flags=8863 mtu 1500
ether xxxxx
inet 192.168.167.1 netmask 0xffffff00 broadcast 192.168.167.255
vmnet8: flags=8863 mtu 1500
ether xxxxx
inet 192.168.154.1 netmask 0xffffff00 broadcast 192.168.154.255
......
/Library/Preferences/VMware Fusion/vmnet8
% cat nat.conf
# VMware NAT configuration file
# Manual editing of this file is not recommended. Using UI is preferred.
[host]
# NAT gateway address
ip = 192.168.154.2 # <== here!
netmask = 255.255.255.0
# VMnet device if not specified on command line
device = vmnet8
.......
% vagrant --version
Vagrant 1.9.6
% cd
% mkdir vagrant_work
% cd vagrant_work
% vagrant init ubuntu/trusty64
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
% vagrant up --provider virtualbox
% cd
% mkdir vagrant_work2
% cd vagrant_work
% vagrant init ubuntu/trusty64
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
% vagrant up --provider virtualbox

% cd
% cd vagrant_work
% vi Vagrantfile
% cat Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.11"
end
% vagrant halt
==> default: Attempting graceful shutdown of VM...
% vagrant up
% ping -c 3 192.168.33.11
% cd
% cd vagrant_work2
% vi Vagrantfile
% cat Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.10"
end
% vagrant halt
==> default: Attempting graceful shutdown of VM...
% vagrant up
% ping -c 3 192.168.33.10
% cd
% cd vagrant_work
% vagrant ssh
# apt-get install nginx
# cp /usr/share/nginx/html/index.html /usr/share/nginx/html/index.html.backup
# vi /usr/share/nginx/html/index.html
# cat /usr/share/nginx/html/index.html
192.168.33.11
% cd
% cd vagrant_work2
% vagrant ssh
# apt-get install nginx
# cp /usr/share/nginx/html/index.html /usr/share/nginx/html/index.html.backup
# vi /usr/share/nginx/html/index.html
# cat /usr/share/nginx/html/index.html
192.168.33.10


% cd
% cd vagrant_work
% vagrant ssh
# vi /etc/nginx/conf.d/server.conf
# cat /etc/nginx/conf.d/server.conf
server {
listen 80;
server_name 192.168.33.11;
location / {
proxy_pass http://192.168.33.10/;
}
}
# service nginx restart
* Restarting nginx nginx [ OK ]

% cd
% cd vagrant_work
% vagrant ssh
# mkdir /usr/local/tmp
# cd /usr/local/tmp/
# openssl genrsa -des3 -out server.key 1024
Generating RSA private key, 1024 bit long modulus
Enter pass phrase for server.key:[1234]
Verifying - Enter pass phrase for server.key:[1234]
# openssl req -new -key server.key -out server.csr
Enter pass phrase for server.key:[1234]
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
# cp server.key server.key.org
# openssl rsa -in server.key.org -out server.key
Enter pass phrase for server.key.org:
writing RSA key
# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Signature ok
subject=/C=AU/ST=Some-State/O=Internet Widgits Pty Ltd
Getting Private key
# ls
server.crt server.csr server.key server.key.org
# pwd
/usr/local/tmp
# vi /etc/nginx/conf.d/server.conf
# cat /etc/nginx/conf.d/server.conf
server {
listen 80;
server_name 192.168.33.11;
location / {
proxy_pass http://192.168.33.10/;
}
}
server {
listen 443;
server_name 192.168.33.11;
ssl on;
ssl_certificate /usr/local/tmp/server.crt;
ssl_certificate_key /usr/local/tmp/server.key;
ssl_protocols SSLv2 SSLv3 TLSv1;
location / {
proxy_pass http://192.168.33.10/;
}
}
# service nginx restart
* Restarting nginx nginx [ OK ]

current time is
end time is
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--multi device--!>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>TimeKeeper</title>
</head>
<body>
<!-- get current time --!>
<p>
current time is<label id="RealtimeClock"></label>
</p>
<!-- get end time --!>
<p>
end time is<input type="text"id="EndTime" value="18:00" size="10">
</p>
<!-- get remain time and set buttons --!>
<p>
<form name="timer">
remain time is</br>
<input type="text" value="10" size="10">min
<input type="text" value="0" size="10">sec<br>
<input type="button" value="start" onclick="cntStart()">
<input type="button" value="stop" onclick="cntStop()">
<input type="button" value="reset" onclick="reSet()">
</form>
<!-- get aleart message --!>
<font color="red"><label id="AlertMessage"></label></font>
</p>
<!-- get textbox --!>
<p>
<textarea name="freeans" rows="20" cols="30">Today's Agenda</textarea>
</p>
<!-- javascript --!>
<script type="text/javascript">
// display clock
function showClock() {
var nowTime = new Date();
var nowHour = setfig( nowTime.getHours() );
var nowMin = setfig( nowTime.getMinutes() );
var nowSec = setfig( nowTime.getSeconds() );
var msg = nowHour + ":" + nowMin + ":" + nowSec;
document.getElementById("RealtimeClock").innerHTML = msg;
}
setInterval('showClock()',1000);
// fix number of digits to two if its one
function setfig(num) {
var ret;
if( num < 10 ) { ret = "0" + num; }
else { ret = num; }
return ret;
}
// set timer id
var timer1;
// get countdown timer for 1000msec
function cntStart() {
document.timer.elements[2].disabled=true;
timer1=setInterval("countDown()",1000);
}
// stop timer
function cntStop() {
document.timer.elements[2].disabled=false;
clearInterval(timer1);
}
// countdowm timer
function countDown() {
var min=document.timer.elements[0].value;
var sec=document.timer.elements[1].value;
if( (min=="") && (sec=="") ) {
var msg="set time!";
document.getElementById("AlertMessage").innerHTML = msg;
reSet();
} else {
if (min=="") min=0;
min=parseInt(min);
if (sec=="") sec=0;
sec=parseInt(sec);
tmWrite(min*60+sec-1);
}
}
// get remain time
function tmWrite(int) {
int=parseInt(int);
if (int<=0)
{
reSet();
var msg="it's time!";
//alert(msg)
document.getElementById("AlertMessage").innerHTML = msg;
// aleart tab if remain time is zero
document.title = msg
} else {
// get remain min
rem_min=Math.floor(int/60);
// get remain sec
rem_sec=int % 60;
// get remain time
document.timer.elements[0].value=rem_min;
document.timer.elements[1].value=rem_sec;
// display remain time
document.title = 'remain time is ' + rem_min + ':' + rem_sec;
}
}
// reset form
function reSet() {
var msg="";
document.getElementById("AlertMessage").innerHTML = msg;
document.timer.elements[0].value="10";
document.timer.elements[1].value="0";
document.timer.elements[2].disabled=false;
clearInterval(timer1);
}
</script>
</body>
</html>
# coding: utf-8
import turtle
t = turtle.Pen()
while True:
color_list = 'pink', 'green', 'purple'
import random
scale = random.randint(50, 100)
print("scale %s" % scale)
t.left(60)
for c in color_list:
i = 1
print("color %s" % c)
while i <= 360 / 60:
print("count %s" % i)
t.begin_fill()
t.forward(scale)
t.fillcolor(c)
t.left(30)
t.circle(scale/4, 180)
t.right(180)
t.circle(scale/4, 180)
t.left(30)
t.forward(scale)
t.left(180)
i = i + 1
t.end_fill()
scale = scale * 0.8
t.up()
location = random.randint(100, 300)
print("location %s" % location)
t.left(scale)
t.forward(location)
t.left(scale)
t.forward(location)
t.down()
turtle.done()
% python turtle_work.py
#!/bin/bash
# make directory if unexist
DIR=./pinglog
if [ ! -d $DIR ]; then
mkdir $DIR
echo -e "directory created"
fi
# variables
LOGDIR=$DIR
NOW=$(date +"%Y%m%d-%H%M%S")
OKLOG=$LOGDIR/hostcheck_$NOW.log
NGLOG=$LOGDIR/hostcheck_error_$NOW.log
# check ping reply
while read line; do
hosts=$(echo $line | grep -v ^# | grep -v ^$ | grep -v localhost | cut -d " " -f 2)
# ping to hosts
if [ -n "$hosts" ]; then
ping -c 1 $hosts > /dev/null 2>&1
# it got reply "hostname : OK" else "hostname : NG"
# output OK-log and NG-log file
if [ $? -eq 0 ]; then
echo -e "$hosts : OK" >> $OKLOG
else
echo -e "$hosts : NG" >> $NGLOG
fi
fi
done < /etc/hosts
echo -e "done"
github link is below
https://github.com/yoshi-island/shell-script_work/blob/master/check_hosts.sh
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :server do |server|
server.vm.box = "centos7.0_x64"
server.vm.hostname = "server"
server.vm.network :private_network, ip: "192.168.111.223"
#server.ssh.private_key_path = "~/.ssh/id_rsa"
end
config.vm.define :client do |client|
client.vm.box = "centos7.0_x64"
client.vm.hostname = "client"
client.vm.network :private_network, ip: "192.168.111.224"
#client.ssh.private_key_path = "~/.ssh/id_rsa"
end
end
start machines on.
% vagrant up
/etc/hosts file is wrote like this.
% cat /etc/hosts | egrep -v "^#"
127.0.0.1 localhost
::1 localhost
192.168.111.223 server # active on virtualbox
192.168.111.224 client # active on virtualbox
111.111.111.111 dummy # dummyhost
% bash check_hosts.sh
directory created
done
results
% cat pinglog/hostcheck_20170527-232436.log
server : OK
client : OK
% cat pinglog/hostcheck_error_20170527-232436.log
dummy : NG
% python hitandblow.py
Enter three digits >>123
0 hit 0 blow
Enter three digits >>456
0 hit 1 blow
Enter three digits >>857
1 hit 2 blow
Enter three digits >>875
3 hit 0 blow
congratulation!
import random
def judge(c, u):
h=0
b=0
for x in range(3):
for y in range(3):
if c[x] == u[y]:
if x == y:
h = h + 1
else:
b = b + 1
print("%s hit %s blow" %(h,b))
if h == 3:
print("congratulation!")
return True
else:
return False
if __name__ == '__main__':
com = []
while len(com)!=3:
rannum = random.randint(0,9)
if rannum not in com:
com.append(rannum)
while True:
usrnum=input("Enter three digits >>")
usr = (int(usrnum[0]),int(usrnum[1]),int(usrnum[2]))
if judge(com,usr) == True:
break
< > &
&amp;lt; &amp;gt; &amp;amp;
How easy!

<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>

<pre class="prettyprint"><code class="language-python">
# code here
print ("hogehoge")
</code></pre>
shown like this.
# code here
print ("hogehoge")
% brew install go
% cat go_work.go
package main
import "fmt"
func main() {
SayHello()
}
func SayHello() {
fmt.Println("Hello World for go lang")
}
% go run go_work.go
Hello World for go lang
build and run
% go build go_work.go
% ./go_work
Hello World for go lang
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>Audio API test</title>
<!-- Bootstrap core CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" id="themesid">
<!-- Custom styles -->
<link href="https://getbootstrap.com/examples/theme/theme.css" rel="stylesheet">
<link href="https://getbootstrap.com/dist/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="https://getbootstrap.com/examples/offcanvas/offcanvas.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row row-offcanvas row-offcanvas-right">
<div class="col-xs-12 col-sm-9">
<div class="row">
<!-- button -->
<div class="container theme-showcase" role="main">
<p>
<button type="button" class="btn btn-lg btn-primary" id="PlayButton">Play</button>
</p>
</div>
</div>
</div>
</div>
</div>
<script>
function play() {
window.AudioContext = window.AudioContext || window.webkitAudioContext; // cross browser
var audioCtx = new AudioContext();
for (key = 0; key < music.length; key++) {
// define sound key
if(music[key] == "Do"){var hz = 262;}
if(music[key] == "re"){var hz = 294;}
if(music[key] == "mi"){var hz = 330;}
if(music[key] == "fa"){var hz = 349;}
if(music[key] == "so"){var hz = 392;}
if(music[key] == "la"){var hz = 440;}
if(music[key] == "si"){var hz = 494;}
if(music[key] == "Doo"){var hz = 523;}
if(music[key] == "ree"){var hz = 587;}
if(music[key] == "mii"){var hz = 659;}
if(music[key] == "faa"){var hz = 699;}
if(music[key] == "soo"){var hz = 784;}
if(music[key] == "laa"){var hz = 880;}
if(music[key] == "sii"){var hz = 988;}
// sound play
if(hz != "none"){
var osciillator = audioCtx.createOscillator(); // sound generate
osciillator.frequency.value = hz; // defined hertz
var audioDestination = audioCtx.destination; //defined sound output
osciillator.connect(audioDestination); // connect speaker
osciillator.start = osciillator.start || osciillator.noteOn; // cross browser
osciillator.start(); // start playing
osciillator.stop(audioCtx.currentTime + time[key]); // stop sound after time[key] sec
}
// sleep between each sound
Sleep(time[key]+0.1);
}
}
// sleep function
function Sleep(T){
var d1 = new Date().getTime();
var d2 = new Date().getTime();
while( d2 < d1+1000*T ){ // wait T sec
d2=new Date().getTime();
}
return;
}
// defined tone
var music = [];
music.push("soo");
music.push("mii");
music.push("Doo");
music.push("so");
music.push("so");
music.push("so");
music.push("la");
music.push("Doo");
music.push("faa");
music.push("laa");
music.push("soo");
// defined length of sound
var time = [];
time.push(0.7);
time.push(0.2);
time.push(0.7);
time.push(0.2);
time.push(0.2);
time.push(0.2);
time.push(0.2);
time.push(0.2);
time.push(0.2);
time.push(0.2);
time.push(0.7);
// execution
var Button1 = document.getElementsByClassName("btn btn-lg btn-primary");
Button1[0].addEventListener("click", play, false);
</script>
</body>
</html>
% pyenv versions
system
2.7.5
2.7.6
2.7.8
* 3.5.0
~/virtualenv1 % bash bin/activate # activate peen-virtualenv
(virtualenv1) ~/virtualenv1 % pyenv versions
system
2.7.5
2.7.6
2.7.8
* 3.5.0 (set by xxx/.python-version)
(virtualenv1) ~/virtualenv1 % deactivate # deactivate peen-virtualenv
~/virtualenv1 %
~/pyenv_test $ cd pyenv-virtualenv1/
(pyenv-virtualenv1) ~/pyenv_test/pyenv-virtualenv1 $
(pyenv-virtualenv1) ~/pyenv_test/pyenv-virtualenv1 $ cat .python-version
pyenv-virtualenv1
% cat random_test.yml
- hosts: all
become: true
user: vagrant
tasks:
- set_fact:
var1: "{{ 100 |random(1,2) }}" # odd random number 1-100
var2: "{{ 100 |random(2,2) }}" # even random number 2-100
- debug:
msg:
- "odd number is {{ var1 }}"
- "even number is {{ var2 }}"
generate numbers successfully.
% ansible-playbook -i hosts random_test.yml
PLAY [all] *********************************************************************
TASK [setup] *******************************************************************
ok: [192.168.111.223]
ok: [192.168.111.224]
TASK [set_fact] ****************************************************************
ok: [192.168.111.224]
ok: [192.168.111.223]
TASK [debug] *******************************************************************
ok: [192.168.111.224] => {
"msg": [
"odd number is 33",
"even number is 80"
]
}
ok: [192.168.111.223] => {
"msg": [
"odd number is 1",
"even number is 72"
]
}
PLAY RECAP *********************************************************************
192.168.111.223 : ok=3 changed=0 unreachable=0 failed=0
192.168.111.224 : ok=3 changed=0 unreachable=0 failed=0
% python
...
>>>
if you have not install yet, get it.
*the command below is for mac os.
% brew install python
Then, get ansible.
% pip install ansible
% ls
ansible.cfg # configuration file
hosts # hosts file
hello_ansible.yml # execution file
include define hosts file path and ssh key file path on ansible.cfg file.
% cat ansible.cfg
[defaults]
hostfile = ./hosts
private_key_file=$HOME/.ssh/id_rsa
include target hosts address, username and passwords on ansible.cfg file. I have two hosts "192.168.111.223" and "192.168.111.224".
% cat hosts
[all]
192.168.111.223
192.168.111.224
[server]
192.168.111.223
[client]
192.168.111.224
[all:vars]
ansible_ssh_user=vagrant
ansible_ssh_pass=vagrant
ansible script file is here.
% cat hello_ansible.yml
- hosts: all
become: true
user: vagrant
tasks:
- debug:
msg:
- "hello ansible"
% ansible-playbook -i hosts hello_ansible.yml
PLAY [all] *********************************************************************
TASK [setup] *******************************************************************
ok: [192.168.111.223]
ok: [192.168.111.224]
TASK [debug] *******************************************************************
ok: [192.168.111.224] => {
"msg": [
"hello ansible"
]
}
ok: [192.168.111.223] => {
"msg": [
"hello ansible"
]
}
PLAY RECAP *********************************************************************
192.168.111.223 : ok=2 changed=0 unreachable=0 failed=0
192.168.111.224 : ok=2 changed=0 unreachable=0 failed=0
% tree
.
├── auto_login.sh # main file
├── login_client.sh # script to login client host
└── login_server.sh # script to login server host
% cat auto_login.sh
#!/bin/sh
auto_ssh() {
host=$1
id=$2
pass=$3
expect -c "
set timeout 10
spawn ssh ${id}@${host}
#expect \"Are you sure you want to continue connecting (yes/no)?\"
#send \"yes\n\"
expect \"${id}@${host}'s password:\"
send \"$pass\n\"
expect \"# \"
send \"cd /opt/work/ ; ls\n\"
interact
"
}
remove "#" if you have not exchange ssh key with target host yet.
% cat login_server.sh
#!/bin/sh
# execute main script
. ./auto_login.sh
# auto login 'host address' 'username' 'password'
auto_ssh '192.168.111.223' 'vagrant' 'vagrant'
% cat login_client.sh
#!/bin/sh
# execute main script
. ./auto_login.sh
# auto login 'host address' 'username' 'password'
auto_ssh '192.168.111.224' 'vagrant' 'vagrant'
% bash login_server.sh
spawn ssh vagrant@192.168.111.223
vagrant@192.168.111.223's password:
Last login: Sat May 27 17:19:45 2017 from 192.168.111.1
Welcome to your Vagrant-built virtual machine.
[vagrant@server ~]$