原创 Remove Linked List Elements

Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 -

原创 House Robber

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed,

原创 處理百萬級以上的數據提高查詢速度的方法

處理百萬級以上的數據提高查詢速度的方法:  1.應儘量避免在 where 子句中使用!=或<>操作符,否則將引擎放棄使用索引而進行全表掃描。  2.對查詢進行優化,應儘量避免全表掃描,首先應考慮在 where 及 order by 涉及的

原创 淺談CSRF攻擊方式

轉自:http://www.cnblogs.com/hyddd/archive/2009/04/09/1432744.html 一.CSRF是什麼?   CSRF(Cross-site request forgery),中文名稱:跨站

原创 全面剖析Smarty緩存機制

今天主要全面總結下Smarty模板引擎中強大的緩存機制,緩存機制有效減少了系統對服務器的壓力,而這也是很多開發者喜歡Smarty的原因之一,由於篇幅較大,便於博友閱讀,這篇文章將剖析Smarty緩存的幾種方式,下篇文章着重講解下設置緩存

原创 單例模式

定義: 保證一個類僅有一個實例,並提供一個訪問它的全局訪問點。 單例模式的優缺點:優點: 1. 改進系統的設計 2. 是對全局變量的一種改進缺點: 1. 難於調試 2. 隱藏的依賴關係 3. 無法用錯誤類型的數據覆寫一個單例 php示例代

原创 memcache適用和不適用場景

適用memcached的業務場景:1)如果網站包含了訪問量很大的動態網頁,因而數據庫的負載將會很高。由於大部分數據庫請求都是讀操作,那麼memcached可以顯著地減小數據庫負載。2)如果數據庫服務器的負載比較低但CPU使用率很高,這時可

原创 Summary Ranges

Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], re

原创 linux下Memcache服務器端的安裝

1、需要兩個安裝包 memcache安裝包,可到官網下載(http://memcached.org/); libevent安裝包,官網(http://monkey.org/~provos/libevent/) 2、把安裝包上傳到 home

原创 Binary Tree Paths

Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \ 2 3

原创 Palindrome Linked List

Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? 思

原创 Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Give

原创 php中web上傳文件的原理及如何限制上傳文件的大小及格式

一、限制上傳文件的大小 move_uploaded_file();  利用php的文件函數來實現上傳 這段代碼分爲兩個文件,一個爲upload.html,一個是upload.php upload.html <form enctype

原创 簡單工廠模式

定義: 簡單工廠模式是類的創建模式,又叫做靜態工廠方法(Static Factory Method)模式。簡單工廠模式是由一個工廠類根據傳入的參量決定創建出哪一種產品類的實例。 優點: 工廠類是整個模式的關鍵:包含了必要的邏輯判斷,根據外

原创 Longest Palindromic Substring 最長迴文字符串

Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000,