It is my Computer Notes. Using Guide : object-key or object-key-key e.g. Step 1 Blog Search : [mysql-run] and then Step 2 ctrl+F [mysql-run] {bookMark me : Ctrl+D}
2013年8月31日 星期六
python-mysql-connector
python-mysql-connector
config = {
'user': 'root',
'password': 'root',
'host': '127.0.0.1',
'database': 'test',
'raise_on_warnings': True,
}
cnx = mysql.connector.connect(**config)
cur = cnx.cursor(buffered=True)
cur.execute("SHOW DATABASES;")
python-mongodb-select-insert-reccount
python-mongodb-select
## python-mongo-connector ## connection
import pymongo
import datetime
from pymongo import MongoClient
cnx=MongoClient('localhost', 27017)
#### Show available databases ####
print (cnx.database_names())
db=cnx['mypymongdb'] #### DatabaseName ####
print (db.name)
print (db.profiling_level())
collection=db.abc ## = foxpro use tableName
## mongo-insert ##
#row = {"_id": str(datetime.datetime.now()), "author": "Mike", "text": "Hello PyMongo!", "tags": ["mongodb", "python", "pymongo"], "date": datetime.datetime.utcnow()}
row = {
"author": "Mike",
"text": "Hello PyMongo!",
"tags": ["mongodb", "python", "pymongo"],
"date": datetime.datetime.utcnow()
}
## mongodb-use difference table(posts) to update =>db.posts
dbHandler=db.posts
record=dbHandler.insert(row)
row = {
"authors": "Mike", ## it will be difference field
"text": "Hello PyMongo!",
"tags": ["mongodb", "python", "pymongo"],
"date": datetime.datetime.utcnow()
}
dbHandler=db.posts
record=dbHandler.insert(row)
## mongodb-reccount => dbHandler.count() ##
print("There are " + str(dbHandler.count()) + " records in the collection (aka Table). Details are:")
## mongodb-select ##
for queryset in dbHandler.find():
print( queryset )
## mongodb-close ##
db.logout()
mssql-connector
asp conncetion to mssql
inf : http://support.microsoft.com/kb/169377
with sql authorization logon
sqlServer Name
create system.dsn
Global.asa
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnStart
Session("ConnectionString") =
"DSN=DEMO;UID=<username>;PWD=<strong password>;DATABASE=pubs;APP=ASP script"
Session("ConnectionTimeout") = 15
Session("CommandTimeout") = 30
End Sub
Sub Session_OnEnd
End Sub
</SCRIPT>
example.asp
inf : http://support.microsoft.com/kb/169377
- install sql server with sql authorization logon
- create system.dsn
- create Global.asa file in iis. (syntax)
- now it can create example.asp file to run it.
with sql authorization logon
sqlServer Name
create system.dsn
Global.asa
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnStart
Session("ConnectionString") =
"DSN=DEMO;UID=<username>;PWD=<strong password>;DATABASE=pubs;APP=ASP script"
Session("ConnectionTimeout") = 15
Session("CommandTimeout") = 30
End Sub
Sub Session_OnEnd
End Sub
</SCRIPT>
example.asp
<HTML> <HEAD> <TITLE>All Authors</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF"> <% Set OBJdbConnection = Server.CreateObject("ADODB.Connection") OBJdbConnection.ConnectionTimeout = Session("ConnectionTimeout") OBJdbConnection.CommandTimeout = Session("CommandTimeout") OBJdbConnection.Open Session("ConnectionString") Set SQLStmt = Server.CreateObject("ADODB.Command") Set RS = Server.CreateObject ("ADODB.Recordset") %> <p> <table border="0" bordercolor="#000000"> <% SQLStmt.CommandText = "select * from authors" SQLStmt.CommandType = 1 Set SQLStmt.ActiveConnection = OBJdbConnection RS.Open SQLStmt Do While Not RS.EOF %> <TR> <TD Width = 150 ALIGN=LEFT> <FONT SIZE=+1> <%= RS("au_id") %> </FONT></TD> <TD></TD> <TD Width = 150 ALIGN=LEFT> <FONT SIZE=+1> <%= RS("au_lname") %> </FONT></TD> <TD Width = 150 ALIGN=LEFT> <FONT SIZE=+1> <%= RS("au_fname") %> </FONT></TD> <TD Width = 150 ALIGN=LEFT> <FONT SIZE=+1> <%= RS("phone") %> </FONT></TD> </TR> <% RS.MoveNext Loop %> </table> <hr> <p> </BODY> <% OBJdbConnection.Close Set OBJdbConnection = Nothing %> </HTML>
iis-logon
iis-logon iis-login
How To Use Simple ASP Code to Password Protect Your ASP Pages
How to Write a Simple login page in Asp.net
http://support.microsoft.com/kb/258063 IE may prompt password
http://forums.iis.net/t/1178188.aspx?Windows+Authentication+repeatedly+asks+for+authentication+in+IIS7+Windows+7
https://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/36ea667e-c578-43b5-87fa-a2f174efb27a.mspx?mfr=true (iis 6 method support authorize)
http://bytes.com/topic/asp-net/answers/678068-intranet-iis
10
How To Use Simple ASP Code to Password Protect Your ASP Pages
How to Write a Simple login page in Asp.net
http://support.microsoft.com/kb/258063 IE may prompt password
http://forums.iis.net/t/1178188.aspx?Windows+Authentication+repeatedly+asks+for+authentication+in+IIS7+Windows+7
https://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/36ea667e-c578-43b5-87fa-a2f174efb27a.mspx?mfr=true (iis 6 method support authorize)
How to Edit Local Intranet Sites in Group Policy
IIIS 6.0 的預設權限和使用者權限預設權限和使用者權限
IIS_WPG 用户组权限问题
http://bytes.com/topic/asp-net/answers/678068-intranet-iis
Why do I still get a user/password Login prompt with Integrate Authentication (for Virtual server 2005 Administration website)
910
iis-install enable asp
inf: http://www.w3schools.com/asp/asp_install.asp
iis-run-asp , install-asp-on-iis iis-asp
How to install IIS on Windows Server 2003
- When you start the Windows Server 2003, you should see the Manage Your Server wizard
- If the wizard is not displayed, go to Administrative Tools, and select Manage Your Server
- In the wizard, click Add or Remove a Role, click Next
- Select Custom Configuration, click Next
- Select Application Server role, click Next
- Select Enable ASP.NET, click Next
- Now, the wizard may ask for the Server 2003 CD. Insert the CD and let it run until it is finished, then click the Finish button
- The wizard should now show the Application Server role installed
- Click on Manage This Application Server to bring up the Application Server Management Console (MMC)
- Expand the Internet Information Services (IIS) Manager, then expand your server, and then the Web Sites folder
- You should see the Default Web Site, and it should not say (Stopped)
- IIS is running!
- In the Internet Information Services (IIS) Manager click on the Web Service Extensions folder
- Here you will see that Active Server Pages are Prohibited (this is the default configuration of IIS 6)
- Highlight Active Server Pages and click the Allow button
- ASP is now active!
java-date-now-time java-dtoc
<date>
//date()
Date date = new Date();
//date format java-date-format
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date temp = new SimpleDateFormat("yyyy-MM-dd").parse("2012-12-12");
//java-dtoc date to character
String dateString = sdf.format(date);
System.out.println(dateString);
java.util.Date temp = new SimpleDateFormat("yyyy-MM-dd").parse("2012-03-04");
Calendar cal = Calendar.getInstance();
cal.setTime(temp);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH)+1; // the variable is 3
int day = cal.get(Calendar.DAY_OF_MONTH);
//date()
Date date = new Date();
//date format java-date-format
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date temp = new SimpleDateFormat("yyyy-MM-dd").parse("2012-12-12");
//java-dtoc date to character
String dateString = sdf.format(date);
System.out.println(dateString);
java.util.Date temp = new SimpleDateFormat("yyyy-MM-dd").parse("2012-03-04");
Calendar cal = Calendar.getInstance();
cal.setTime(temp);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH)+1; // the variable is 3
int day = cal.get(Calendar.DAY_OF_MONTH);
java-if java-iif
fields=fields+(!fields.equals("")?",":"")+s8;
formats=formats+(!formats.equals("")?",":"")+"S";
alistTables[i][15]=alistTables[i][15]+(!alistTables[i][15].equals("")?",":"")+LoadV[a][4]; //20150123
condition? A : B ## foxpro iif
name = ((city == null) || (city.getName() == null) ? "N/A" : city.getName());
mysql-run
DELIMITER //
CREATE PROCEDURE GetOfficeByCountry(IN countryName VARCHAR(255))
BEGIN
SELECT city, phone
FROM offices
WHERE country = countryName;
END //
DELIMITER ;
CALL GetOfficeByCountry('USA')
CALL GetOfficeByCountry(‘France’)
CREATE PROCEDURE GetOfficeByCountry(IN countryName VARCHAR(255))
BEGIN
SELECT city, phone
FROM offices
WHERE country = countryName;
END //
DELIMITER ;
CALL GetOfficeByCountry('USA')
CALL GetOfficeByCountry(‘France’)
mysql-if example sample eg e.g.
if statment
IF expression THEN commands
[ELSEIF expression THEN commands]
[ELSE commands]
END IF;
IF quantity_in_stock < 100 THEN
INSERT INTO infologs(msg)
VALUES (prd_code);
END IF;
FETCH cur_product INTO prd_code;
UNTIL no_more_products = 1
END REPEAT;
CLOSE cur_product;
SELECT * FROM infologs;
DROP TABLE infologs;
END$$
DELIMITER;
IF expression THEN commands
[ELSEIF expression THEN commands]
[ELSE commands]
END IF;
IF quantity_in_stock < 100 THEN
INSERT INTO infologs(msg)
VALUES (prd_code);
END IF;
FETCH cur_product INTO prd_code;
UNTIL no_more_products = 1
END REPEAT;
CLOSE cur_product;
SELECT * FROM infologs;
DROP TABLE infologs;
END$$
DELIMITER;
mysql-procedure example sample eg e.g.
DELIMITER //
CREATE PROCEDURE GetOfficeByCountry(IN countryName VARCHAR(255))
BEGIN
SELECT city, phone
FROM offices
WHERE country = countryName;
END //
DELIMITER ;
CALL GetOfficeByCountry('USA')
CALL GetOfficeByCountry(‘France’)
/***********************************************************/
NO PARAMETER
DELIMITER $$
DROP PROCEDURE UPDATE_TEMP_SUMMARY_VIEW01 $$
CREATE PROCEDURE UPDATE_TEMP_SUMMARY_VIEW01()
BEGIN
truncate table TEMP_SUMMARY_VIEW01;
insert ignore into TEMP_SUMMARY_VIEW01 select * from SOINVPOSUMMARY;
END ;
$$
DELIMITER ;
linux-lan
/etc/sysconfig/network-scripts
ifdown ifcfg-eth0
ifup
ifconfig
szexzdz
ifdown ifcfg-eth0
ifup
ifconfig
szexzdz
/etc/sysconfig/network[top] gateway
- NETWORKING=yes
- HOSTNAME=host.domainname.com ## set Host Name
- GATEWAY=20.0.0.254 && SET THE ROUTER'S GATEWAY
net.ipv4.ip_forward=1 && 0 for disable routner, default is 0
net.ipv4.tcp_syncookies = 1 && prevents the Linux machine from sync flood attacks
net.ipv4.icmp_echo_ignore_broadcasts = 1 && prevents attackers make use smurf attacks.
kernel.shmmax = 5000000
net.ipv4.tcp_syncookies = 1 && prevents the Linux machine from sync flood attacks
net.ipv4.icmp_echo_ignore_broadcasts = 1 && prevents attackers make use smurf attacks.
kernel.shmmax = 5000000
- DEVICE=eth0 &ð0 it must match the file name , when second id, then the eth0, change to eth0:0
- BOOTPROTO =dhcp ii(dhcp , none, dhcp or static)
- HWADDR==00:12:34:56:78:90
- ONBOOT=yes && when linux boot up
- DHCP_HOSTNAME=servera.domain.com
- SEARCH=
- NM_CONTROLLED=
- IPADDR=192.168.65.31 && iif(dhcp, 192.168.65.31, no this line)
- NETMASK=255.255.255.0 && iif(dhcp, 255.255.255.0, no this line)
- GATEWAY=192.168.65.254 && iif(dhcp, 192.168.65.3254, no this line)
Remark : The Second will call ifcfg-eth1
/etc/resolv.conf ## DNS Setting
echo "nameserver 202.14.67.4" >> /etc/resolv.conf
tcp-port
TCP port (Listen) | Service | ||
---|---|---|---|
20 | Ftp data | ||
21 | Ftp command | ||
22 | SSH | ||
23 | Telnet | ||
25 | SMTP | ||
37 | Time Protocol | ||
53 | DNS | ||
66 | Oracle Sql-net | ||
67 | DHCP | ||
80 | Http | ||
88 | Authentication | ||
110 | POP3 | ||
119 | NNTP | ||
123 | NTP | network time protocol | |
135 | epmap | end point map for mc rpc locator | |
137 | samba (nmbd) for net bios | ||
138 | samba | ||
139 | samba (smbd for printer share and file share) | ||
143 | IMAP | ||
389 | LDAP | http://www.hkitn.com/article.php/4897AD Active Directory windows2003 firwall setting, 流覽當前正在使用 NetMeeting 2.0 的用戶名單 | |
443 | https | ||
445 | samba, microsoft-ds | smb protocol , directory share | |
631 | cups | ||
636 | LDAPS | ||
873 | rsyncd | ||
993 | imaps | ||
995 | Pop 3 (ssh) | ||
1158 | oracle em | http://localhost.localdomain:1158/em | |
1154-1500 | Ip-Phone | ||
1521 | Oracle | http://localhost.localdomain:1521/isqplus/dba | |
1526 | Oracle Listen Port | ||
1720 | H323 | IP Phone | |
1723 | VPN | ||
1863 | xp 一般連線,msm | ||
3128 | squid (proxy server) | ||
3306 | MySql | ||
3389 |
| ||
5100 | 即時影音通訊 | ||
5560 | Oracle isqplus |
| |
5631 | Anywhere | ||
6000 | TCP guarantees delivery of data and also guarantees that packets will be delivered on port 6000 in the same order in which they were sent. Guaranteed communication over port 6000 is the key difference between TCP and UDP. UDP port 6000 would not have guaranteed communication in the same way as TCP. ...more, | ||
6346 | foxy | ||
6501 udp | xp | ||
6885-6889 | BT | ||
8080 | IPPhone Hutch... | ||
30000-31000 | IP-Phone | ||
6891-6900 | |||
7800-7825 |
abc class private-network private-lan
TCP Class | Ip Network | Private LAN | Must mask | subnet | |
---|---|---|---|---|---|
A | 1-126 [00000001] [01111111] | 10.0.0.0 /8 | 255.0.0.0 | 255.128.0.0 | |
B | 128-191 [10000001] [10111111] | 172.16.0.0 /16 to 172.31.0.0 /16 | 255.255.0.0 | 255.255.192.0 | |
C | 192-223 [11000000] [11011111] | 192.168.0.0 /24 to 192.168.255.0 /24 | 255.255.255.0 | 255.255.255.224 | |
D | 224-239 | Multi case | |||
E | 240-255 | Remain | |||
Class D is multicase purpose. Some software can add a ip number on the lan Card for rec'd purpose. A lan can have more than 1 this number. 1 < many. Subnet Mask option : 0,128,192,224,240,248,252,254,255, A subnet mask is used to idenify the network ID or the Host ID of an IP address. |
sub-net-mask
subnet mask
A /24 network may be divided into the following subnets by increasing the subnet mask successively by one bit. This affects the total number of hosts that can be addressed in the /24 network (last column).
Prefix size | Network mask | Available subnets | Usable hosts per subnet | Total usable hosts |
---|---|---|---|---|
/24 | 255.255.255.0 | 1 | 254 | 254 |
/25 | 255.255.255.128 | 2 | 126 | 252 |
/26 | 255.255.255.192 | 4 | 62 | 248 |
/27 | 255.255.255.224 | 8 | 30 | 240 |
/28 | 255.255.255.240 | 16 | 14 | 224 |
/29 | 255.255.255.248 | 32 | 6 | 192 |
/30 | 255.255.255.252 | 64 | 2 | 128 |
/31 | 255.255.255.254 | 128 | 2 * | 256 |
osi-7layer
osi7layer
1 Physical | 2 Data-Link | 3 Network | 4 Transport | 5 Session | 6 Presen tation | 7 Application | |
---|---|---|---|---|---|---|---|
Example | Cables, Adapters | Ethernet Lan, PPP, Token Ring, Frame Relay, Telephone Lines, ATM | IP | TCP, UDP | NetBIOS Check Point open 1 IE connect | ASCII | FTP, SMTP, Telnet |
Address | MAC | Network | |||||
Protocol | Transfer logical device to prhysical device protocol (DNS, NBP, X500) | IPX,IP NWLINK, NetBeui, DECnet, XNS, DDP (datagram delivery Protocol : Apple talk) | SPX,TCP,NWLink, ATP (Apple Talk Protocol) NBP (Name binding Protocol) Netbeui (not routable) LAT (loca area trasnport , not routable) | NetBIOS | APPC - AS400 Advance Protoprog comm FTAM OSI, File Transfer access Management, X.400; x.500, SMTP, FTP, SNMP, Telnet, NCP (novell core protocol) , SMB (server manage Block), AFP (Apple Talk Filing Protocol) , DAP (Data access protocol) DEC (Apple Talke/ Apple Share) | ||
Hardware | Hub, Switch, Bridge, Repeater 100M bit per second = 30 g Byte transfer per hour. | Router | Gateway | ||||
Oracle | Oracle Net | ||||||
ARP | ARP | ||||||
Netbeui | netbeui | ||||||
*
訂閱:
文章 (Atom)