隨筆-69  評(píng)論-0  文章-5  trackbacks-0
            2008年3月24日
          先占個(gè)地兒
          http://blog.csdn.net/boat1980/archive/2008/07/23/2698318.aspx

          posted @ 2008-09-22 11:36 liunix 閱讀(243) | 評(píng)論 (0)編輯 收藏
          <html>
          <head>
          <script>
          function overlay() {
              el 
          = document.getElementById("overlay");
              el.style.visibility 
          = (el.style.visibility == "visible"? "hidden" : "visible";
          }
          </script>
          <style>
          body 
          {
               height
          :100%;
               margin
          :0;
               padding
          :0;
          }
          /*外層全部*/
          #overlay
          {
               visibility
          : hidden;
               position
          : absolute;
               left
          : 0px;
               top
          : 0px;
               width
          :100%;
               height
          :100%;
               text-align
          :center;
               z-index
          : 1000;
               background-color
          :#000;
               filter
          : alpha(opacity=70); /*ie支持的半透明,下面兩名為ff支持的*/
               -moz-opacity
          : 0.7;
               opacity
          :.70;
          }
          /*外層的顯示區(qū)*/
          #overlay div 
          {
               width
          :300px;
               margin
          : 100px auto;
               background-color
          : #FFFFFF;
               border
          :1px solid #000;
               padding
          :15px;
               text-align
          :center;
          }
          </style>
          </head>
          <body id="body">
          <div id="overlay">
               
          <div>
                  用戶名:
          <input type="text" name="" /><br/>
                  密  碼:
          <input type="text" name="" /><br/>
                  
          <input type="button" value="關(guān)閉" onclick="overlay()" />
               
          </div>
          </div>

          <href='#' onclick='overlay()'>Click here to show the overlay</a>
          </body>
          </html>   
          posted @ 2008-08-29 16:23 liunix 閱讀(652) | 評(píng)論 (0)編輯 收藏
          一、DESede加密(對(duì)應(yīng)SunJCE不提供模式和填充的情況)
          declare
              result raw(
          2000);
              l_mod number :
          = dbms_crypto.ENCRYPT_3DES+dbms_crypto.CHAIN_ECB+dbms_crypto.PAD_PKCS5;
          begin
              result :
          = dbms_crypto.Encrypt(src => utl_i18n.string_to_raw('wwww'),typ => l_mod,key => hextoraw('123456789012345678901234567890123456')
              );
              dbms_output.put_line(result);
          end;
          /

          二,摘要
          dbms_crypto.Hash(utl_i18n.string_to_raw('input'),dbms_crypto.MD5))
          posted @ 2008-07-21 14:54 liunix 閱讀(679) | 評(píng)論 (0)編輯 收藏
          用了幾天jira管理對(duì)它的權(quán)限模式有了初步理解:



          project和permission schema多對(duì)一,從而形成了permission schema的重用
          而permission schema本身則代表了group/user和pemission之前的映射關(guān)系

          另外,jira還有一個(gè)Project Role的概念更增加了jira權(quán)限管理的靈活性
          其實(shí)它實(shí)質(zhì)上就是一個(gè)角色(RBAC中的R),可以和group/user多對(duì)多關(guān)聯(lián),
          (當(dāng)然也可和Permission通過schema進(jìn)行關(guān)聯(lián))
          使jira的權(quán)限配置更新靈活的同時(shí),也增加了相當(dāng)?shù)膹?fù)雜性

          posted @ 2008-07-17 16:06 liunix 閱讀(1309) | 評(píng)論 (0)編輯 收藏
          一,造libmysql.def文件
             1, ${mysql_home}/include/libmySQL.def文件如果有直接用
             2, 否則下載pexports工具,執(zhí)行pexprots libmySQL.dll> libmySQL.def(libmySQL.dll在${mysql_home}/bin目錄下一般會(huì)有)
          二,轉(zhuǎn)換成靜態(tài)庫
             dlltool --input-def libmySQL.def --dllname libmySQL.dll --output-lib libmysql.a -k
          三,配置Eclipse(靜態(tài)庫和動(dòng)態(tài)庫加法都是-L${DIR} -l${libname},但誰的優(yōu)先級(jí)高呢?)
              1, 加上庫目錄,如"${workspace_loc:/hello_mysql/libs}"
              2, 加上libmysql.a的庫名: mysql
              3, 構(gòu)建,報(bào)錯(cuò):  #ff0000 reference to `mysql_real_connect@32'之類的錯(cuò)
              4, 修改def文件,將mysql_real_connect改成mysql_real_connect@32,其它錯(cuò)誤同理,并重新生成靜態(tài)庫
              5, 重新構(gòu)建完成
          四,示例程序(只須修改連接信息及表名)
          #include <stdio.h>
          /*下面這一行一定要加上*/
          #include 
          <my_global.h>
          #include 
          <mysql.h>

          int main() {
              MYSQL mysql;
              MYSQL_RES 
          *result;
              MYSQL_ROW row;

              
          int numrows, numcols, c;

              mysql_init(
          &mysql);

              
          if (!mysql_real_connect(&mysql, "localhost""opencart""opencart""opencart"0, NULL, 0)) {
                  fprintf(stderr,
          "Failed to connect to database: Error %d:%s\n", mysql_errno(&mysql), mysql_error(&mysql));
              }
              
          char query[] = "SELECT * FROM product";

              
          if (mysql_query(&mysql, query))
              {
                  fprintf(stderr,
          "Error executing query: Error %d: %s\n", mysql_errno(&mysql), mysql_error(&mysql));
              }

              result 
          = mysql_use_result(&mysql);

              
          if (!result) {
                  fprintf(stderr,
          "Error executing query: Error %d: %s\n", mysql_errno(&mysql), mysql_error(&mysql));
              }
              numcols 
          = mysql_num_fields(result);

              
          while (row = mysql_fetch_row(result)) {
                  
          for (c = 0; c < numcols; c++) {
                      printf(
          "%s\t", row[c]);
                  }
                  printf(
          "\n");
              }
          }

             
          posted @ 2008-07-14 15:36 liunix 閱讀(1039) | 評(píng)論 (0)編輯 收藏
          一、安裝
          1, 安裝xampp
          2, 安裝zend studio[6]

          二、配置調(diào)式
          1,在http.conf中指定php.ini的位置
              PhpIniDir "D:/xampp/php"

          2, 在php.ini中的zend的部分指定以下內(nèi)容(ZendDebugger.dll是從zend studio中搜出來的)
          [Zend]
          zend_extension_ts = "D:\xampp\php\zendOptimizer\lib\ZendDebugger_5.2.12.dll"
          ;下面部分可選
          zend_debugger.allow_hosts=127.0.0.1/32,127.0.0.1/24
          zend_debugger.expose_remotely=allowed_hosts


          posted @ 2008-07-07 11:38 liunix 閱讀(291) | 評(píng)論 (0)編輯 收藏
          放在/usr/local/bin下,挺好用
           #!/bin/sh
           # this script converts an rpm into a plain tarball

           mkdir $$.cpio
           rpm2cpio $@ 
          > $$.cpio/foo
           cd $$
          .cpio
           cpio 
          ---< foo
           rm 
          -f foo
           find 
          . -type d -perm 700 -exec chmod 755 {} \;
           tar cvzf 
          ../`basename $@ .rpm`.tar.gz .
           cd 
          ../
           rm 
          -rf $$.cpio


          posted @ 2008-06-18 11:37 liunix 閱讀(347) | 評(píng)論 (0)編輯 收藏
          1,去http://rpm.pbone.net/下載下列rpm包并安裝
          libnasl-2.2.9-1.fc5.i386.rpm
          nessus-core-2.2.9-1.fc5.i386.rpm
          nessus-core-debuginfo-2.2.9-1.fc5.i386.rpm(可選)
          nessus-libraries-2.2.9-1.fc5.i386.rpm
          nessus-server-2.2.9-1.fc5.i386.rpm
          nessus-gui-2.2.9-1.fc5.i386.rpm
          2, 找個(gè)能用的郵箱去http://www.nessus.org/plugins/index.php?view=register注冊(cè)一下
          3, 按郵件中的方式運(yùn)行nessus-fetch --register ****
          4, 運(yùn)行nessus-adduser增加一個(gè)沒有rule的用戶
          5, 運(yùn)行nessus-mkcert造個(gè)證書
          6, 運(yùn)行nessus-fetch --check檢查一下狀態(tài)
          7, 如果前面沒啥問題,運(yùn)行service nessusd start
             如果這一步除了成功沒啥別的輸出就ok啦


          posted @ 2008-06-18 10:44 liunix 閱讀(277) | 評(píng)論 (0)編輯 收藏
          限制本機(jī)的對(duì)外訪問(例如不讓測(cè)試環(huán)境訪問生產(chǎn)庫):
          iptables -t filter -A OUTPUT -d 192.168.2.2 -p tcp --dport 1521 -j REJECT

          #端口轉(zhuǎn)發(fā)到另一臺(tái)機(jī)器上
          -A PREROUTING -d $ip1 -i eth0 -p tcp -m tcp --dport $port1 -j DNAT --to-destination $ip2:$port2
          -A POSTROUTING -d $ip2 -p tcp -m tcp --dport $port2 -j SNAT --to-source $ip1
          #本機(jī)端口相互映射
          -A PREROUTING -p tcp --dport $port1 -j REDIRECT --to-port $port2
          posted @ 2008-06-02 11:07 liunix 閱讀(224) | 評(píng)論 (0)編輯 收藏
          pre-commit.tmpl,然后更名pre-commit并加上執(zhí)行權(quán)限:
          #!/bin/sh

          REPOS
          ="$1"
          TXN
          ="$2"

          RES
          ="OK"
          # Make sure that the log message contains some text.
          SVNLOOK=/app/subversion/bin/svnlook
          $SVNLOOK log -"$TXN" "$REPOS" | egrep "[^[:space:]]+" >/dev/null || unset RES
          if [ "$RES" != "OK" ]
          then
              echo 
          "You must input some comments for you commit" >&2
              
          exit 1
          fi

          # All checks passed, so allow the commit.
          exit 0


          posted @ 2008-05-28 14:18 liunix 閱讀(1495) | 評(píng)論 (0)編輯 收藏
          fisheye(1.4.3):
              cenqua_com_licensing.atlassian.license.DefaultLicense
                 isExpired(),getExpiryDate()
              cenqua_com_licensing.atlassian.license.DefaultLicenseType(重點(diǎn))
                 isEvaluationLicenseType(),expires().....

          posted @ 2008-05-28 11:13 liunix 閱讀(518) | 評(píng)論 (0)編輯 收藏

          一,將pem格式的key文件導(dǎo)入keystore

          摘抄備用:http://www.agentbob.info/agentbob/79-AB.html

          說明: 經(jīng)試驗(yàn)證書的pem文件可能通過keytool直接導(dǎo)入keystore中的

          Apache Tomcat and many other Java applications expect to retrieve SSL/TLS certificates from a Java Key Store (JKS). Jave Virtual Machines usually come with keytool  to help you create a new key store.

          Keytool helps you to:

          • create a new JKS with a new private key
          • generate a Certificate Signung Request (CSR) for the private key in this JKS
          • import a certificate that you received for this CSR into your JKS

          Keytool does not let you import an existing private key for which you already have a certificate. So you need to do this yourself, here's how:

          Let's assume you have a private key (key.pem) and a certificate (cert.pem), both in PEM format as the file names suggest.

          PEM format is 'kind-of-human-readable' and looks like e.g.

          -----BEGIN CERTIFICATE-----
          Ulv6GtdFbjzLeqlkelqwewlq822OrEPdH+zxKUkKGX/eN
          .
          . (snip)
          .
          9801asds3BCfu52dm7JHzPAOqWKaEwIgymlk=
          ----END CERTIFICATE-----

          Convert both, the key and the certificate into DER format using openssl :

          openssl pkcs8 -topk8 -nocrypt -in key.pem -inform PEM -out key.der -outform DER
          openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER

          Now comes the tricky bit, you need something to import these files into the JKS. ImportKey will do this for you, get the ImportKey.java (text/x-java-source, 6.6 kB, info) source or the compiled (Java 1.5 !) ImportKey.class (application/octet-stream, 3.3 kB, info) and run it like

          user@host:~$ java ImportKey key.der cert.der
          Using keystore-file : /home/user/keystore.ImportKey
          One certificate, no chain.
          Key and certificate stored.
          Alias:importkey Password:importkey

          Now we have a proper JKS containing our private key and certificate in a file called keystore.ImportKey, using 'importkey' as alias and also as password. For any further changes, like changing the password we can use keytool.



          二、將私鑰導(dǎo)出成pem文件(默認(rèn)keytool是不能導(dǎo)出私鑰的)
          import sun.misc.BASE64Encoder;
          import java.security.cert.Certificate;
          import java.security.*;
          import java.io.File;
          import java.io.FileInputStream;
           
          class ExportPriv {
              
          public static void main(String args[]) throws Exception{
              ExportPriv myep 
          = new ExportPriv();
              myep.doit();
              }
           
              
          public void doit() throws Exception{
           
              KeyStore ks 
          = KeyStore.getInstance("JKS");
              String fileName 
          = "store.jks";
           
              
          char[] passPhrase = "password".toCharArray();
              BASE64Encoder myB64 
          = new BASE64Encoder();
              
           
              File certificateFile 
          = new File(fileName);
              ks.load(
          new FileInputStream(certificateFile), passPhrase);
           
              KeyPair kp 
          = getPrivateKey(ks, "alias", passPhrase);
                  
              PrivateKey privKey 
          = kp.getPrivate();
              
           
              String b64 
          = myB64.encode(privKey.getEncoded());
           
              System.out.println(
          "-----BEGIN PRIVATE KEY-----");
              System.out.println(b64);
              System.out.println(
          "-----END PRIVATE KEY-----");
           
              }
           
          // From http://javaalmanac.com/egs/java.security/GetKeyFromKs.html
           
             
          public KeyPair getPrivateKey(KeyStore keystore, String alias, char[] password) {
                  
          try {
                      
          // Get private key
                      Key key = keystore.getKey(alias, password);
                      
          if (key instanceof PrivateKey) {
                          
          // Get certificate of public key
                          Certificate cert = keystore.getCertificate(alias);
              
                          
          // Get public key
                          PublicKey publicKey = cert.getPublicKey();
              
                          
          // Return a key pair
                          return new KeyPair(publicKey, (PrivateKey)key);
                      }
                  } 
          catch (UnrecoverableKeyException e) {
                  } 
          catch (NoSuchAlgorithmException e) {
                  } 
          catch (KeyStoreException e) {
                  }
                  
          return null;
              }
           
          }
           

          posted @ 2008-04-17 16:27 liunix 閱讀(8007) | 評(píng)論 (0)編輯 收藏
          去年rails正火的時(shí)候,仿active record用hibernate實(shí)現(xiàn)了一個(gè)BasePo,當(dāng)時(shí)用的是一個(gè)
          靜態(tài)sessionfactory注入的方式,感覺很不好,當(dāng)明也沒想到好的方案,后來發(fā)現(xiàn)有人通過
          threadlocal實(shí)現(xiàn)了下面這個(gè),可以看看:
           1 public class Persistent implements Lifecycle, Validatable, Serializable {
           2    
           3    protected Serializable _id;
           4    protected int _version;
           5 
           6    public Serializable getIdentifier() {
           7       return _id;
           8    }
           9    public void setIdentifier(Serializable id) {
          10       _id = id;
          11    }
          12    public int getVersion() {
          13       return _version;
          14    }
          15    public void setVersion(int version) {
          16       _version = version;
          17    }
          18 
          19    public Long persist() throws HibernateException, SQLException {
          20       HibernateSession.currentSession().saveOrUpdate(this);
          21       return _id;
          22    }
          23    public void delete() throws HibernateException, SQLException {
          24       HibernateSession.currentSession().delete(this);
          25    }
          26    public void refresh() throws HibernateException, SQLException {
          27       HibernateSession.currentSession().load(this, _id);
          28    }
          29    public void lock() throws HibernateException, SQLException {
          30       HibernateSession.currentSession().lock(this, LockMode.UPGRADE);
          31    }
          32 
          33    public boolean onSave(Session s) throws CallbackException {
          34       return NO_VETO;
          35    }
          36    public boolean onDelete(Session s) throws CallbackException {
          37       return NO_VETO;
          38    }
          39    public boolean onUpdate(Session s) throws CallbackException {
          40       return NO_VETO;
          41    }
          42    public void onLoad(Session s, Serializable id) {
          43       _id = id;
          44    }
          45 
          46    public void validate() throws ValidationFailure {
          47    }
          48 }

          原文:http://hibernate.bluemars.net/46.html?cmd=prntdoc

          下面是hibernatesession的源碼,應(yīng)該考濾一下如何與spring事務(wù)結(jié)合的問題(還是加一個(gè)doInTransaction 的callback?)
           1 import java.util.Collection;
           2 
           3 import net.sf.hibernate.HibernateException;
           4 import net.sf.hibernate.Session;
           5 import net.sf.hibernate.Transaction;
           6 
           7 import org.apache.commons.logging.Log;
           8 import org.apache.commons.logging.LogFactory;
           9 
          10 /**
          11  * @author Ralph Schaer
          12  * @version $Revision: 1.6 $ $Date: 2004/05/22 12:24:32 $
          13  */
          14 public class HibernateSession {
          15 
          16   private static final Log LOG = LogFactory.getLog(HibernateSession.class);
          17   public static final ThreadLocal SESSION = new ThreadLocal();
          18 
          19   public static Session currentSession() throws HibernateException {
          20 
          21     Session s = (Session) SESSION.get();
          22     if (s == null) {
          23       s = HibernateFactoryManager.getSessionFactory().openSession();
          24       SESSION.set(s);
          25     }
          26     return s;
          27   }
          28 
          29   public static Session getSession() throws HibernateException {
          30     return HibernateFactoryManager.getSessionFactory().openSession();
          31   }
          32 
          33   public static void closeSession() {
          34     try {
          35       Session s = (Session) SESSION.get();
          36       SESSION.set(null);
          37       if (s != null) {
          38         s.close();
          39       }
          40 
          41     } catch (HibernateException e) {
          42       LOG.error("HibernateSession:  closeSession", e);
          43     }
          44 
          45   }
          46 
          47   public static void rollback(Transaction tx) {
          48     if (tx != null) {
          49       try {
          50         tx.rollback();
          51         closeSession();
          52       } catch (HibernateException he) {
          53         LOG.error("HibernateSession: rollback", he);
          54       }
          55     }
          56   }
          57 
          58   //Utility methods
          59   public static int collectionSize(Collection coll) throws HibernateException {
          60     return ((Integer) currentSession().createFilter(coll, "select count(*)").iterate().next()).intValue();
          61   }
          62 
          63 }


          還有一種考慮泛型的方式可以參考:
          http://privacyneed.info/index.php?hl=f5&q=uggc%3A%2F%2Fcrgreonpxyhaq.oybtfcbg.pbz%2F2007%2F07%2Fvzcyrzragvat-npgvirerpbeq-va-wnin.ugzy
          posted @ 2008-03-28 11:30 liunix 閱讀(483) | 評(píng)論 (0)編輯 收藏
          從網(wǎng)上找了一段,寫得挺麻煩,但可以借一下思路
          cat watch.sh

          #!/bin/sh
          cd /root/bin

          PID
          =`ps -aef | grep Xms500M | grep -grep | gawk '{print $2}'`
          PID
          =`expr $PID + 1 - 1`

          date
          free
          echo 
          $PID
          echo 
          "------------------"

          if [ $PID -eq 0 ]
          then
          sleep 10
          /usr/java/tomcat/bin/startup.sh
          sleep 160
          fi

          while [ 1 ]
          do
          date
          free
          echo 
          "Tomcat process ID is $PID"
          wget http
          ://192.168.1.101/jsp/w_blog/blog.jsp -O working.jpg 2>> /dev/null &
          sleep 120
          touch working
          .jpg
          SIZE
          =`du working.jpg | gawk '{print $1}'`
          if [ $SIZE -le 20 ]
          then


          WID
          =`ps -aef | grep 192.168.1.101 | grep -grep | gawk '{print $2}'`
          WID
          =`expr $WID + 1 - 1`

          if ! test -$WID
          then
          killall wget
          fi


          echo 
          "Tomcat restart checking"
          free
          vmstat
          FREEMEM
          =`free | grep Mem | gawk '{print $4}'`

          if [ $FREEMEM -le 15000 ]
          then

          if [ $PID -ne 0 ]
          then
          kill -9 $PID
          ls 
          -l
          /usr/java/tomcat/bin/shutdown.sh
          fi

          /usr/java/tomcat/bin/shutdown.sh
          sleep 10
          /usr/java/tomcat/bin/startup.sh
          sleep 30
          fi

          date
          ps 
          -aef | grep -v httpd
          ls 
          -l
          PID
          =`ps -aef | grep Xms500M | grep -grep | gawk '{print $2}'`
          PID
          =`expr $PID + 1 - 1`

          fi

          rm 
          -f working.jpg

          done


          posted @ 2008-03-24 19:25 liunix 閱讀(1300) | 評(píng)論 (0)編輯 收藏
          主站蜘蛛池模板: 平谷区| 饶平县| 本溪市| 梁山县| 南城县| 左贡县| 上饶市| 盐亭县| 香河县| 东方市| 基隆市| 公安县| 永年县| 东宁县| 克东县| 新干县| 团风县| 革吉县| 和田市| 甘孜县| 沐川县| 扶绥县| 奎屯市| 聂拉木县| 高阳县| 赤水市| 郸城县| 兴化市| 米脂县| 莱阳市| 鄂尔多斯市| 磴口县| 永善县| 探索| 铜川市| 巴马| 濮阳市| 镇坪县| 喀喇| 香河县| 呼伦贝尔市|