2016年9月26日 星期一

Google 0.3.3 glog on Windows 10 with Visual Studio 2013

https://github.com/google/glog/archive/v0.3.3.zip

Compilation Error
When compiling gloc v0.3.3 in Visual Studio 2013, you may encounter the below errors.

Error 2 error C2039: 'min' : is not a member of 'std' j:\public\glog-0.3.3\src\logging.cc 75 1 libglog
Error 3 error C2873: 'min' : symbol cannot be used in a using-declaration j:\public\glog-0.3.3\src\logging.cc 75 1 libglog
Error 4 error C2065: 'min' : undeclared identifier j:\public\glog-0.3.3\src\logging.cc 1386 1 libglog
Error 5 error C2062: type 'int' unexpected j:\public\glog-0.3.3\src\logging.cc 1386 1 libglog
6 IntelliSense: namespace "std" has no member "min" j:\public\glog-0.3.3\src\logging.cc 75 12 libglog
7 IntelliSense: identifier "min" is undefined j:\public\glog-0.3.3\src\logging.cc 1386 24 libglog
8 IntelliSense: type name is not allowed j:\public\glog-0.3.3\src\logging.cc 1386 28 libglog


Solution:
Open file glog-0.3.3\src\logging.cc
Add #include <algorithm> so that it becomes
#include <vector>
#include <errno.h>                   // for errno
#include <sstream>
#include <algorithm>
#include "base/commandlineflags.h"        // to get the program name
#include "glog/logging.h"
#include "glog/raw_logging.h"

#include "base/googleinit.h"

Batch build all of them
























#define GOOGLE_GLOG_DLL_DECL
#include "src/windows/glog/logging.h"

2016年9月23日 星期五

How do you compile and/or run Python, Golang, Node.js Nodejs , C++ within notepad++?

Using 32 bit Notepad++ 7.5.7

Python


Download NppExec
https://sourceforge.net/projects/npp-plugins/files/NppExec/
Download NppExec Plugin v0.6 RC2.zip
Download https://nppexec_083_dll_x64.zip/ on 2023
Extract and copy so that C:\Program Files (x86)\Notepad++\plugins\NppExec\NppExec.dll

https://github.com/d0vgan/nppexec/releases/tag/v06-RC2

NppExe Console UTF8

Most of the time you want NppExe console displays UTF8 where the default is OEM(DOS)

NppExec > Console Output/Input Encoding > Output from OEM(DOS) to UTF-8 (Input default OEM)

NppExec F6

Plugins NppExec Execute (F6) is much more powerful than plain Run (F5).
Then in F6 add/save the following:
NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
C:\Python34\python.exe -u "$(FULL_CURRENT_PATH)"

NppExec Shift + F6

In Plugins NppExec Console output filters (Shift+F6) add the following HighLight mask:

  File "C:\Users\ricky\Downloads\a.py", line 2, in <module>
*File "%FILE%", line %LINE%
Red: FF
Checked: U for underlined



Run F6






Go


NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
go.exe run "$(FULL_CURRENT_PATH)"

.\a.go:6:7: syntax error: unexpected int at end of statement

*%FILE%:%LINE%:*error*

Notepad++ Golang Syntax

Language > User Defined Language Format > Import > golang.xml




Node.js

Similar to Python:

NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
C:\Program Files\nodejs\node.exe "$(FULL_CURRENT_PATH)"


Java

Similar to Python:

NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
java -cp . "$(FILE_NAME)"



Visual Studio C++


NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" && cl /EHsc "$(FULL_CURRENT_PATH)" && $(NAME_PART).exe

NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" && cl /EHsc "$(FULL_CURRENT_PATH)" && $(NAME_PART).exe



*%FILE%:%LINE%:*error*




Clang++ (2023)

Similar to Python:

NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
C:\msys64\mingw64\bin\clang++.exe "$(FULL_CURRENT_PATH)"
$(NAME_PART).exe


gPRC Python

NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
python -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. $(FILE_NAME)

Julia

Similar to Python:

NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
C:\Users\ricky\AppData\Local\Julia-1.3.1\bin\julia.exe "$(FULL_CURRENT_PATH)"

R Programming

Similar to Python:

NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
"C:\Program Files\R\R-4.2.1\bin\x64\Rscript" "$(FULL_CURRENT_PATH)"






End

2016年9月20日 星期二

Using Boost 1.54 on Windows 7 For Visual Studio 2013


Tutorial
http://www.boost.org/doc/libs/1_54_0/more/getting_started/windows.html




Download
http://sourceforge.net/projects/boost/files/boost/1.54.0/boost_1_54_0.7z
File size is 51.3 MB compressed and 373MB uncompressed.

Extract
So that the file structure is in form of C:\Program Files\boost\boost_1_54_0\index.htm

Visual Studio Project
Use Visual Studio 2013 > File > New > Project > Visual Studio C++ > Win32 Console Application > Empty

Setup Include Path
<ProjectName> > Right Click > Properties > C/C++ > General > Additional Include Directories >
C:\Program Files\boost\boost_1_54_0\























Header-only Boost.Lambda Code
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main() {
       using namespace boost::lambda;
       typedef std::istream_iterator<int> in;
       std::for_each(in(std::cin), in(), std::cout << (_1 * 3) << " ");
}














Test
Press F5 to compile and run, enter 1 to return 3







Build Boost
cmd.exe
cd C:\Program Files\boost\boost_1_54_0
bootstrap.bat
./b2.exe toolset=msvc-12.0
Running b2.exe takes very long time from 4:49 PM to 5:18 PM or near 30 minutes on my Intel i5-4440 3.1 Ghz 16GB Windows 7 64 bits. While building, it generates additional 3.2 GB of files mainly in .obj, .lib and .rsp in stage and bin.v2 folders.

Build Version 2
Use VS2013 x64 本机工具命令提示
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"" amd64
bootstrap.bat
b2.exe toolset=msvc-12.0


Generated Files
In folder \bin.v2\libs, the generated .lib file prefixed with libboost_. The following libraries are generated.
atomic chrono context coroutine date_time exception filesystem graph iostreams locale log math prg_exec_monitor program_options python3 random regex serialization signals system test_exec_monitor thread timer unit_test_framework wave wserialization





Compiled-binary Boost.Regex Code
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main() {
       std::string line;
       boost::regex pat("^Subject: (Re: |Aw: )*(.*)");
       while (std::cin) {
              std::getline(std::cin, line);
              boost::smatch matches;
              if (boost::regex_match(line, matches, pat))
                     std::cout << matches[2] << std::endl;
       }

}

Auto-Linking
Visual Studio supports auto-linking that while build the above code, the name of library will be detected.
For Debug Win32 project, it searches for 'libboost_regex-vc110-mt-gd-1_54.lib'
For Release Win32 project, it searches for 'libboost_regex-vc110-mt-1_54.lib'
<ProjectName> > Right Click > Linker > Additional Library Directories > C:\Program Files\boost\boost_1_54_0\stage\lib\

Potential Error
Error 1 error LNK2038: mismatch detected for '_MSC_VER': value '1700' doesn't match value '1800' in main.obj D:\public\boostexample\boostexample\libboost_regex-vc110-mt-gd-1_54.lib(instances.obj) boostexample

You need to build it with correct version of toolset for b2.exe in previous steps.


2016年9月9日 星期五

Loop ping in Windows using Python 3

import subprocess

def ping(hostname):
  output = subprocess.Popen(["ping.exe", hostname, "-n", "1"], stdout = subprocess.PIPE).communicate()[0]
txt = output.decode('ascii')
return txt

for i in range(140, 200):
  hostname = "10.1.10." + str(i)
output = ping(hostname)
print(hostname, 'unreachable'
  not in output)

2016年9月2日 星期五

Linux Check Hardware and Network Commands

[quantprod@hkoffice083 network-scripts]$ ifconfig
em1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.1.10.183  netmask 255.255.255.0  broadcast 10.1.10.255
        ether a4:ba:db:50:66:64  txqueuelen 1000  (Ethernet)
        RX packets 672507  bytes 156314638 (149.0 MiB)
        RX errors 0  dropped 1565  overruns 0  frame 0
        TX packets 2342106  bytes 3009870528 (2.8 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

em2: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether a4:ba:db:50:66:65  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 0  (Local Loopback)
        RX packets 161360  bytes 14142796 (13.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 161360  bytes 14142796 (13.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[quantprod@hkoffice083 network-scripts]$ netstat -lntu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:15022           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:15023           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:59001           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:59002           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8899            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8900            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:1988            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:2020            0.0.0.0:*               LISTEN
udp        0      0 10.1.10.183:123         0.0.0.0:*
udp        0      0 127.0.0.1:123           0.0.0.0:*
udp        0      0 0.0.0.0:123             0.0.0.0:*
udp        0      0 0.0.0.0:55405           0.0.0.0:*

[quantprod@hkoffice083 network-scripts]$ cat ifcfg-em1
TYPE=Ethernet
BOOTPROTO=static
NAME=em1
UUID=c4d5d83d-4991-4623-9422-025804d6ca21
DEVICE=em1
ONBOOT=yes
IPADDR=10.1.10.183
NETMASK=255.255.255.0

[quantprod@hkoffice083 network-scripts]$ cat ifcfg-em2
TYPE=Ethernet
BOOTPROTO=static
NAME=em2
UUID=8fd78b3f-b8c9-48f1-9740-9d5f9feae4f2
DEVICE=em2
ONBOOT=no
IPADDR=192.168.10.50
NETMASK=255.255.255.0

[quantprod@hkoffice083 ~]$ sudo service ntpd start
Redirecting to /bin/systemctl start  ntpd.service
[quantprod@hkoffice083 ~]$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*218.189.210.4   128.138.140.44   2 u    1   64    1    2.905  -18.203   1.256
 218.189.210.3   128.138.140.44   2 u    2   64    1    3.559  -17.617   0.000

[quantprod@hkoffice083 ~]$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                16
On-line CPU(s) list:   0-15
Thread(s) per core:    2
Core(s) per socket:    4
Socket(s):             2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 26
Model name:            Intel(R) Xeon(R) CPU           E5520  @ 2.27GHz
Stepping:              5
CPU MHz:               2261.120
BogoMIPS:              4521.29
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              8192K
NUMA node0 CPU(s):     0,2,4,6,8,10,12,14
NUMA node1 CPU(s):     1,3,5,7,9,11,13,15

[quantprod@hkoffice083 ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdd1        50G  1.5G   46G   4% /
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G     0   16G   0% /dev/shm
tmpfs            16G  8.8M   16G   1% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
/dev/sdc1       275G  363M  261G   1% /data
/dev/sdd3        54G  179M   51G   1% /usr/local
tmpfs           3.2G     0  3.2G   0% /run/user/1004
tmpfs           3.2G     0  3.2G   0% /run/user/1002

[quantprod@hkoffice083 ~]$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,size=16374724k,nr_inodes=4093681,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/sdd1 on / type ext4 (rw,noatime,data=ordered)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
/dev/sdc1 on /data type ext4 (rw,noatime,data=ordered)
/dev/sdd3 on /usr/local type ext4 (rw,noatime,data=ordered)
tmpfs on /run/user/1004 type tmpfs (rw,nosuid,nodev,relatime,size=3276928k,mode=700,uid=1004,gid=1004)
tmpfs on /run/user/1002 type tmpfs (rw,nosuid,nodev,relatime,size=3276928k,mode=700,uid=1002,gid=1002)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)

[quantprod@hkoffice083 ~]$ free -g
              total        used        free      shared  buff/cache   available
Mem:             31           0          29           0           0          30
Swap:            31           0          31


[quantprod@hkoffice083 ~]$ cat /proc/version
Linux version 3.10.0-327.22.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Jun 23 17:05:11 UTC 2016

[quantprod@hkoffice083 ~]$ cat /etc/*-release
CentOS Linux release 7.2.1511 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

CentOS Linux release 7.2.1511 (Core)
CentOS Linux release 7.2.1511 (Core)


How to connect to Synology DSM 5 NFS volume from Linux CentOS 7



error encounted
[root@localhost ~]# mount 10.1.10.192:/volume1/share /mnt
mount: wrong fs type, bad option, bad superblock on 10.1.10.192:/volume1/share,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

Install suitable tools
sudo yum -y install nfs-utils nfs4-acl-tools portmap

Follow the manual
https://www.synology.com/zh-tw/knowledgebase/DSM/tutorial/File_Sharing/How_to_access_files_on_Synology_NAS_within_the_local_network_NFS

2016年9月1日 星期四

Google 0.3.4 glog on Windows 7




https://github.com/google/glog/archive/master.zip

Sln档案
D:\public\glog-master\google-glog.sln
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008


I use Visual Studio 2013. After converted, run batch build to all






















先下載glog最新版,解壓裡面有*sln文件,如果你安裝了VS2005以上版本都可以直接打開,編譯即可得到libglog.dll和libglog.lib文件,拷貝文件到你的測試文件夾下,並拷貝src\windows\下的glog目錄到你的工程文件下。

或者可以把整个编译完的glog-master拷到你的工程文件下。
其中某些档案可以删掉不要,Backup,vsprojects\*\Debug, \Release, \*.vcxproj, \*.filters *.suo UpgradeLog.htm,最后剩下21.4 MB (22,452,538 bytes)。



工程文件我新创建solution包含一个project,添加library文件夹在solution下面,把glog放到library里面。
















C/C++ > General > Additional Include Directories = ..\library\glog\src\windows\
Linker > General > Additional Library Directories = ..\library\glog\$(Configuration);%(AdditionalLibraryDirectories)
Build Evenets > POst-Build Event > Command Line = xcopy /y /d "..\\library\glog\$(Configuration)\*.dll" "$(OutDir)"

2007 to 2023 HP and Dell Servers Comparison

  HP Gen5 to Gen11  using ChatGPT HP ProLiant Gen Active Years CPU Socket Popular HP CPUs Cores Base Clock Max RAM Capacity Comparable Dell ...