2013年8月31日 星期六

python-datetime


datetime.datetime.utcnow() ## datetime.datetime(2013, 9, 1, 4, 12, 55, 254769)

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()




asp-source



asp-source


W3Schools.com


How to access SQL Server in Active Server Pages


How To Use Simple ASP Code to Password Protect Your ASP Pages










mssql-connector

asp conncetion to mssql 


inf  : http://support.microsoft.com/kb/169377



  1. install sql server with sql authorization logon
  2. create system.dsn
  3. create Global.asa file in iis. (syntax)
  4. 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)

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)

9

10

iis-ftp-install

iis-install ftp


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

  1. When you start the Windows Server 2003, you should see the Manage Your Server wizard
  2. If the wizard is not displayed, go to Administrative Tools, and select Manage Your Server
  3. In the wizard, click Add or Remove a Role, click Next
  4. Select Custom Configuration, click Next
  5. Select Application Server role, click Next
  6. Select Enable ASP.NET, click Next
  7. 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
  8. The wizard should now show the Application Server role installed
  9. Click on Manage This Application Server to bring up the Application Server Management Console (MMC)
  10. Expand the Internet Information Services (IIS) Manager, then expand your server, and then the Web Sites folder
  11. You should see the Default Web Site, and it should not say (Stopped)
  12. IIS is running!
  13. In the Internet Information Services (IIS) Manager click on the Web Service Extensions folder
  14. Here you will see that Active Server Pages are Prohibited (this is the default configuration of IIS 6)
  15. Highlight Active Server Pages and click the Allow button
  16. 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);

java-string-len -length

 <len>
int _length= StringVAriable.length()

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’) 

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; 

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



/etc/sysconfig/network[top] gateway
  • NETWORKING=yes
  • HOSTNAME=host.domainname.com ## set Host Name
  • GATEWAY=20.0.0.254 && SET THE ROUTER'S GATEWAY
/etc/sysctl.conf[top]
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
/etc/sysconfig/network-scripts/ifcfg-eth0[top]
  • DEVICE=eth0 &&eth0 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  
    
20Ftp data  
21Ftp command  
22SSH  
23Telnet  
25SMTP  
37Time Protocol  
53DNS  
66Oracle Sql-net  
67DHCP  
80Http  
88Authentication  
110POP3  
119NNTP  
123NTPnetwork time protocol 
135epmapend point map for mc rpc locator 
137samba (nmbd) for net bios  
138samba  
139samba (smbd for printer share and file share)  
143IMAP  
389LDAPhttp://www.hkitn.com/article.php/4897AD Active Directory windows2003 firwall setting,
流覽當前正在使用 NetMeeting 2.0 的用戶名單
 
    
   
443https  
445samba, microsoft-dssmb protocol , directory share 
    
631cups  
636LDAPS  
873rsyncd  
993imaps  
995Pop 3 (ssh)  
1158oracle emhttp://localhost.localdomain:1158/em 
1154-1500Ip-Phone  
1521Oraclehttp://localhost.localdomain:1521/isqplus/dba 
1526Oracle Listen Port  
1720H323IP Phone 
1723VPN  
1863xp 一般連線,msm  
3128squid (proxy server)  
3306MySql  
3389
  • Terminal Service
  • xp 遠端協助
  
5100即時影音通訊  
5560Oracle isqplus
  • http://localhost.localdomain:5560/isqlplus
  • http://localhost.localdomain:5560/isqplus/dba
 
5631Anywhere  
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,
 
6346foxy  
6501 udpxp   
6885-6889BT  
8080IPPhone Hutch...  
30000-31000IP-Phone  
6891-6900
  
7800-7825
 

abc class private-network private-lan

TCP ClassIp NetworkPrivate LANMust masksubnet 
A1-126
[00000001] [01111111]
10.0.0.0 /8255.0.0.0255.128.0.0 
B128-191
[10000001]
[10111111]
172.16.0.0 /16 to 172.31.0.0 /16255.255.0.0255.255.192.0 
C192-223
[11000000]
[11011111]
192.168.0.0 /24 to 192.168.255.0 /24255.255.255.0255.255.255.224 
D224-239Multi case   
E240-255Remain   
      
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 sizeNetwork maskAvailable
subnets
Usable hosts
per subnet
Total
usable hosts
/24255.255.255.01254254
/25255.255.255.1282126252
/26255.255.255.192462248
/27255.255.255.224830240
/28255.255.255.2401614224
/29255.255.255.248326192
/30255.255.255.252642128
/31255.255.255.2541282 *256

osi-7layer

osi7layer


1
Physical
2
Data-Link
3
Network
4
Transport
5
Session
6
Presen tation
7
Application
ExampleCables, AdaptersEthernet Lan, PPP, Token Ring, Frame Relay, Telephone Lines, ATMIPTCP, UDPNetBIOS
Check Point
open 1 IE connect
ASCIIFTP, SMTP, Telnet
AddressMACNetwork
ProtocolTransfer 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)
NetBIOSAPPC - 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)
HardwareHub, Switch, Bridge, Repeater
100M bit per second = 30 g Byte transfer per hour.
RouterGateway
OracleOracle Net
ARPARP
Netbeuinetbeui
*