Why Will Artificial Intelligence Matter In The Near Future?

—- written by saiful takeshi, tokyo, japan

You could say that artificial intelligence, robots and smart devices were all offspring of some of the wildest imaginations of visionaries. Through art, movies and literature, we have been able to conceive such ideas and work our ways up towards making them a reality. But no matter how harder we try to live our futuristic dreams right now, artificial intelligence and other allied technologies are still in their infant stages. We have achieved face recognition, speech detection and stages of autonomous cars at consumer levels and it will be years from now until we have robots serving us mac  and cheese.

With that said, groundbreaking technologies and researches are being made every single day and if you are a follower of influencers and industry experts, you would see how artificial intelligence is working at grassroot levels to solve some of the simplest of concerns besides the most complicated ones. Artificial intelligence is indeed laying the foundation for what will be standards tomorrow and to get ready for the future, you need to start becoming open from today.

Why It Will Matter In the Near Future

Visionaries today are working on enriching our everyday lives. Home delivery of food, apparel, and consumer goods, cab services, entertainment options are all some of the basic conveniences we have made them necessities. But technology feels there is still human intervention involved. So, it is working on making life simpler to another level by introducing delivery drones, chatbots, advanced systems and more to further add convenience in our lives.

Gateway to the Unknown

Artificial Intelligence is all about bridging the gap between the known and the unknown. As humans, we have restrictions in terms of perceiving and understanding things with chances of human errors. But advanced machines (like quantum supercomputers) can redefine our understanding of things such as the universe, dark matters, ailments and diseases, online transactions, nature and more and help us see the truth. Supercomputers are already working on simulating blackholes and working on string theories and other unproven concepts. IBM’s Watson is detecting diseases and predicting ailments that veteran doctors could not and algorithms are showing companies why their products are not selling online. These are all just instances of things we never paid attention to before these technologies come into action.

——-saiful takeshi

tokyo, japan

A zero-indexed array A consisting of N integers is given. An equilibrium index of this array is any integer P such that 0 ≤ P < N and the sum of elements of lower indices is equal to the sum of elements of higher indices, i.e.

    A[0] + A[1] + ... + A[P−1] = A[P+1] + ... + A[N−2] + A[N−1].

Sum of zero elements is assumed to be equal to 0. This can happen if P = 0 or if P = N−1.
int solution(int A[], int N) {
    // return 3 for [3,2,-5,1]
    int sum_prefix = 0;
    int sum_suffix = 0;
int i, j;
for (i = 0; i < N; i++) {
    // Check if is is the equilibrium point
    sum_prefix = 0;
    for (j = 0; j < i; j++) {
       sum_prefix += A[j];
    }
    sum_suffix = 0;
    for (j = i+1; j < N; j++) {
        sum_suffix += A[j];
       // Compute suffix sum
    }
    if (sum_prefix == sum_suffix)
        return i;
}
return -1;
}

leader of this array

A non-empty zero-indexed array A consisting of N integers is given. The leader of this array is the value that occurs in more than half of the elements of A.

  $A[0] = 1;
  $A[1] = 1;
  $A[2] = 1;
  $A[3] = 50;
  $A[4] = 1;

function solution($A){
  if(empty($A)) return -1;
  
  $array_total_element = count($A);
  $ar_cnt_values = array_count_values($A);

  foreach($ar_cnt_values as $value){
      if($value > $array_total_element/2) return 1;
    }
  return -1;
}

MAC OS XのSIPを無効化する

https://book.mynavi.jp/macfan/detail_summary/id=44838

 

OS Xの最新バージョンエルキャピタンでは、SIP(System Integrity Protection)という新機能によってシステムが保護されている。これによってセキュリティは強固になるが、システムのライブラリなどをユーザ側で いじれなくなった。たとえばシステムアイコンの変更などができなくなったわけだが、どうしても変更したい場合のSIPの無効化方法をお伝えする。

今回はわかりやすい具体例として、「LiteIcon」というフリーのアイコン変更ソフトの挙動を見てみよう。SIPが有効な状態でLiteIconを起動しようとすると、以下のようなメッセージが表示される。


SIPが有効なのでシステムアイコンは変更できない、という内容だ。そのままLiteIconを動かすと変更対象にシステムアイコンがない状態となる。

さて、ここからが本題。SIPを無効にすればシステムアイコンは変更できる。まずはMacを再起動して起動時に[コマンド]キー+[R]キーを押しながら起動して、リカバリモードを立ち上げよう。


[ユーティリティ]メニューから[ターミナル]を選択し、

csrutil disable

とコマンドを入力して実行しよう。これでSIPは無効化される。


再起動後はこのように警告が表示されることもなく、システムアイコンの変更ができるようになっている。とはいえSIPを切りっぱなしではせっかくのシステ ム保護が意味を為さないので、一時的に無効化し、アイコンの変更などの必要な作業をしたら、再びSIPを有効にするのが良いだろう。有効にするには、同様 の手順でリカバリモードからターミナルに入った後に、

csrutil enable

と入力すれば良い。

Sending mail while user login and logout in MAC OS

Making postfix mail server start while MAC system startup

and Sending mail while user login and logout in MAC OS
=========================================================

vi /System/Library/LaunchDaemons/org.postfix.master.plist

Edit the file as bellow
————————
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<key>Label</key>
<string>org.postfix.master</string>
<key>KeepAlive</key>
<true/>
<key>Program</key>
<string>/usr/libexec/postfix/master</string>
<key>ProgramArguments</key>
<array>
<string>master</string>
</array>
<key>QueueDirectories</key>
<array>
<string>/var/spool/postfix/maildrop</string>
</array>
<key>AbandonProcessGroup</key>
<true/>
</dict>
</plist>

Set load the file when MAC system starts up
——————————————-
launchctl load /System/Library/LanuchDaemons/org.postfix.master.plist

Create autodaily directory
————————–
mkdir /usr/libexec/autodaily

Create the log file
———————
vi /usr/libexec/autodaily/log.log
chmod 0777 log.log

Create autodailyLogin.sh and autodailyLogout.sh file
—————————————————-
cd /usr/libexec/autodaily/
vi autodailyLogin.sh

Enter the followings in the file
——————————–
#!/bin/bash

# Created by Saiful Takeshi
# Environment variables #################################################

DEST_EMAIL=”saiful_takeshi@number-1.co.jp,hanamitsu_makoto@number-1.co.jp”

USER_NAME=”CHUMAN SHOUHEI”

TODAY=$(date +%Y/%m/%d)

EVENT_TIME=$(date “+DATE: %Y-%m-%d%nTIME: %H:%M:%S”)

LOGGEDIN_SUBJECT=”[MAC Login] : $TODAY : $USER_NAME”

LOGGEDIN_BODY=”$USER_NAME  has Logged In successfully at \n$EVENT_TIME.”

# Functions ##########

function loggedin(){

echo “$LOGGEDIN_BODY” | mail -s “$LOGGEDIN_SUBJECT” $DEST_EMAIL

return 0

}

loggedin;

echo “Login at $EVENT_TIME” >> log.log

Create autodailyLogin.sh and autodailyLogout.sh file
—————————————————-
vi /usr/libexec/autodaily/autodailyLogout.sh

Enter the followings in this file
————————————-

#!/bin/bash

# Created by Saiful Takeshi
# Environment variables #################################################

DEST_EMAIL=”saiful_takeshi@number-1.co.jp,hanamitsu_makoto@number-1.co.jp”

USER_NAME=”CHUMAN SHOUHEI”

TODAY=$(date +%Y/%m/%d)

#EVENT_TIME=$(date +%Y/%m/%d-%H:%M:%S)

EVENT_TIME=$(date “+DATE: %Y-%m-%d%nTIME: %H:%M:%S”)

LOGGEDOUT_SUBJECT=”[MAC Logout] : $TODAY : $USER_NAME”

LOGGEDOUT_BODY=”$USER_NAME san has Logged Out successfully at \n$EVENT_TIME.”

# Functions ##########

function loggedout(){

echo “$LOGGEDOUT_BODY” | mail -s “$LOGGEDOUT_SUBJECT” $DEST_EMAIL

return 0

}

loggedout;

echo “logout at $EVENT_TIME” >> log.log

Make both file as executable
———————————
chmod +x autodailyLogin.sh
chmod +x autodailyLogout.sh

Checking the script is ok or not(execute)
—————————————–
sh autodailyLogin.sh
sh autodailyLogout.sh

—————————–
Show the default setting for login and logout
———————————————
defaults read

Add the login hook event as execute the autodailyLogin.sh file when login
——————————————————————–
sudo defaults write com.apple.loginwindow LoginHook /usr/libexec/autodaily/autodailyLogin.sh

Add the logout hook event as execute the autodailyLogout.sh file when logout
——————————————————————–
sudo defaults write com.apple.loginwindow LogoutHook /usr/libexec/autodaily/autodailyLogout.sh

Now check the mac machine by login and logout

 

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

Summary command

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

#launch FTP
sudo launchctl load -w /System/Library/LaunchDaemons/ftp.plist

#copy postfix file
sudo cp /System/Library/LaunchDaemons/org.postfix.master.plist /System/Library/LaunchDaemons/org.postfix.master.plist_bk

#Edit postfix plist file
sudo vi /System/Library/LaunchDaemons/org.postfix.master.plist

#unload load postfix
sudo launchctl unload -w /System/Library/LaunchDaemons/org.postfix.master.plist
sudo launchctl load -w /System/Library/LaunchDaemons/org.postfix.master.plist

 

#autodailylogin.sh and autodailylogout.sh file

cd /usr/libexec
sudo mkdir autodaily
sudo chmod 0777 autodaily/
cd autodaily/
sudo chmod 0777 log.log

#edit files

sudo vi autodailylogin.sh

sudo vi autodailylogout.sh

#permission change to execute

sudo chmod +x autodailylogin.sh

sudo chmod +x autodailylogout.sh

Add the login hook event as execute the autodailyLogin.sh file when login
——————————————————————–
sudo defaults write com.apple.loginwindow LoginHook /usr/libexec/autodaily/autodailyLogin.sh

Add the logout hook event as execute the autodailyLogout.sh file when logout
——————————————————————–
sudo defaults write com.apple.loginwindow LogoutHook /usr/libexec/autodaily/autodailyLogout.sh

 

 

PHPでJIS以外の文字(例:①②③)を文字化けせずに日本語メールを送る方法

mb_internal_encoding(“UTF-8”);
mail(
‘dummy@aainc.co.jp’,
mb_encode_mimeheader(‘テスト’, ‘ISO-2022-JP-MS’), //エンコードはISO-2022-JP-MSで
mb_convert_encoding(‘①②③’, ‘ISO-2022-JP-MS’), //エンコードはISO-2022-JP-MSで
“Content-Type: text/html; charset=\”ISO-2022-JP\”;\n” //ヘッダはISO-2022-JPを指定
);