2011|08|
2013|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|05|06|07|08|09|10|11|12|
2016|01|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|04|

2014-04-15 [ネタ]ビックデータ 江端分析


2017-04-15 ラズパイにsshサーバをインストールする方法

 
>sudo apt-get install openssh-server
 
/etc/ssh/sshd_config の portの番号を替える。
 
>sudo service ssh restart

2018-04-15 /etc/postfix/main.cf

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
 
smtpd_banner = $myhostname ESMTP $mail_name (Raspbian)
biff = no
 
# appending .domain is the MUA's job.
append_dot_mydomain = no
 
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
 
readme_directory = no
 
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2
 
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
 
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
 
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = raspberrypi
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, mail.alone.net, alone.mydns.jp, raspberrypi, localhost.localdomain, localhost
 
 
relayhost = [alone.ohana.ne.jp]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_mechanism_filter = plain, login
#tls setting
smtp_use_tls = yes
 
mynetworks = 127.0.0.0/8 192.168.0.0/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
 
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
 
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = raspberrypi
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, mail.alone.net, alone.mydns.jp, raspberrypi, localhost.localdomain, localhost
 
 
relayhost = [alone.ohana.ne.jp]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_mechanism_filter = plain, login
#tls setting
smtp_use_tls = yes
 
mynetworks = 127.0.0.0/8 192.168.0.0/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
syntax2html

2019-04-15 usleep()がコンパイルエラーになる件

原因は良く分からないのだけど、C言語用のpostgresのAPIの環境と一緒に使うと、コンパイルエラーが発生する現象に悩まされていた。

#include 
#include 
int main(int argc, char **argv) {
  fprintf(stderr, "start\n");
  usleep(1000000);
  fprintf(stderr, "end\n");
  return 0;
}

で、これまで見たことがない、以下のエラーが発生するようになってしまった。

 error: 'usleep' was not declared in this scope
   usleep(1000);

原因ははっきりしないのだけど、

g++ -g db20190415.cpp -o db20190415 -I"D:\PostgreSQL\10\include" -L"D:\PostgreSQL\10\lib" -llibpq -lwsock32 -lws2_32

とか、

#include "libpq-fe.h"

が怪しそうである(これらを追加したら、出てきたから)。

==============

暫く悩んだのだけど、usleep()を使わない方法を、試してみた。

#include 
#include 
int main(int argc, char **argv) {
  struct timespec ts;
  fprintf(stderr, "start\n");
  ts.tv_sec = 0;
  ts.tv_nsec = 999999999/35; // 1/35秒と見なして良い
  nanosleep(&ts, NULL);
  fprintf(stderr, "end\n");
  return 0;
}
 
 // 出展 https://www.mm2d.net/main/prog/c/sleep-01.html

これで良しとした。