PHP 密码生成器

return substr(md5(rand().rand()), 0, $len);

PHP 简单的类连接

<php
/**
* Simple Class Connect
*/

class Connect {
     
     var $host="localhost";
     var $dbname="yourdatabase"; 
     var $usuario="userserver"; 
     var $password="passwordserver";
     var $link;
     var $unlink;

     function onServer()
     {
          $this->link = mysql_connect($this->host, $this->usuario, $this->password);
          $this->database = mysql_select_db($this->dbname);
     }
     
     
     function offServer()
     {
          $this->unlink = mysql_close($this->link);
     }

}

$var = new Connect();
$var->onServer();
  echo 'run your queries here';
$var->offServer();
?>

C# C#:Indexer

class IndexerClass
{
    protected string[] data;

    public IndexerClass(int len)
    {
        data = new string[len];
    }

    public string this[int index]
    {
        get
        {
            return data[index];
        }
        set
        {
            data[index] = value;
        }
    }
}

// in the Main()
IndexerClass ind = new IndexerClass(10);
ind[1] = "haha hello world";
ind[2] = "hello world";

for (var i = 0; i < 10; i++)
{
    Console.WriteLine(ind[i]);
}

SQL 获取特定数据库的记录计数

--Specify the name of the database to count in the following line
USE AdventureWorks; --Added by James_DBA
GO

--Code modified from original posting on SQLServerCentral.Com
--URL: http://www.sqlservercentral.com/scripts/Miscellaneous/30324/
SELECT o.name AS "Table Name", i.rowcnt AS "Row Count"
FROM sysobjects o, sysindexes i
WHERE i.id = o.id
AND indid IN(0,1)
--This specifies 'user' databases only
AND xtype = 'u' --Added by James_DBA
--This omits the diagrams table of the database
--You may find other system tables will need to be ommitted,
--you would just name them all here using the <> operator
--i.e. o.name <> dtproperties, o.name <> 'sysdiagrams'
AND o.name <> 'sysdiagrams' --Added by James-DBA

--You could also look further into filtering out temp tables,
--or user specified tables
ORDER BY i.rowcnt DESC --I found it more useful to display 
--the results by 'Row Count' Descending
--The original posting suggested to sort by Table name by
--using the following line, instead of the line I use above:
--ORDER BY o.name

--The following line adds up all the rowcount results and places
--the final result into a seperate column (below the first resulting table)
COMPUTE SUM(i.rowcnt); --Added by James_DBA
GO

PHP 检测大多数移动HTTP客户端

/**
 * Detects most mobile agents.
 * 
 * @return bool
 * @see http://en.wikipedia.org/wiki/List_of_user_agents_for_mobile_phones
 */
function isMobile()
{
  $userAgent = $_SERVER["HTTP_USER_AGENT"];
  $yes = strpos($userAgent, "Android") !== false;
  $yes = $yes || strpos($userAgent, "iPhone") !== false;
  $yes = $yes || strpos($userAgent, "Palm") !== false;
  $yes = $yes || strpos($userAgent, "Symbian") !== false;
  $yes = $yes || strpos($userAgent, "Mobile") !== false;
  $yes = $yes || strpos($userAgent, "MIDP") !== false;
  $yes = $yes || strpos($userAgent, "CLDC") !== false;
  return $yes;
}

HTML Twitter上一条推文

<h2>Recent Tweets</h2>
<ul id="twitter_update_list"></ul>
</div>
<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/NAME.json?callback=twitterCallback2&count=1"></script>

PHP Zend Framework:引导Zend_Log(登录firebug)

$log = new Zend_Log(new Zend_Log_Writer_Firebug);
Zend_Registry::set('log', $log);

CSS 只针对谷歌浏览器和野生动物园

@media screen and (-webkit-min-device-pixel-ratio:0) {
     /* put webkit CSS here*/
}

C# 在C#中捕获视频

capturing video in c# loading all the video and audio devices

PHP PDO Connect - MySQL

$hostname = 'localhost';
$username = 'username';
$password = 'password';

try {
    $dbh = new PDO("mysql:host=$hostname;dbname=mysql", $username, $password);
    }
catch(PDOException $e)
    {
    echo $e->getMessage();
    }