PHP String_Begins_With

function String_Begins_With($needle, $haystack {
 return (substr($haystack, 0, strlen($needle))==$needle);
}

SQL SELECT REPLACE

<?php

$query = "
SELECT 
  id, REPLACE(names,'".chr(29)."',', ') as namestring
FROM 
  table
";

?>

Bash 准确了解apache返回的标头

$ curl -I --user auser:mypassword http://example.com/test.jpg

Ruby 显示表模式的快捷方法

#add this inside .irbrc
#shortcut for y model.column_names
def show(obj)
  y(obj.send("column_names"))
end

SVN 命令缩写

svn st = svn status
svn ci = svn commit
svn up = svn update
svn di = svn diff
svn co = svn checkout
svn mv = svn move
svn cp = svn copy
svn rm = svn delete
svn ls = svn list
svn h  = svn help

Bash 脚本bash GPL模板(简称)

#!/bin/sh

# Copyright (C) %{YEAR} by %{AUTHOR}
# Released under GNU GPL 2 or later

Smarty 几个柜台

<ol>
	<li><a href="#{counter name=list start=1}">bla</a></li>
	<li><a href="#{counter name=list}">bla</a></li>
	<li><a href="#{counter name=list}">bla</a></li>

</ol>

<a name="{counter name=anchors start=1}"></a>
<p><div class="num">{counter name=answers}</div><h3>bla</h3></p>
<p>answer</p><hr />

<a name="{counter name=anchors}"></a>
<p><div class="num">{counter name=answers}</div><h3>bla</h3></p>
<p>answer</p><hr />

<a name="{counter name=anchors }"></a>
<p><div class="num">{counter name=answers}</div><h3>bla</h3></p>
<p>answer</p><hr />

Other 跨平台安全密码存储

A quicker method that also works cross-platform is to use OpenSSL (which macos includes).

To encypt a list of secrets with the 256-bit AES, open the terminal and do:

openssl enc -aes256 -salt -a -e -out secrets.aes

You'll then be prompted twice for a password, after which you can begin typing whatever you want. When you've typed enough, hit control-d twice and the data will be encrypted and placed in a filed named "secrets.aes".

To decrypt the file created above, do:

openssl enc -aes256 -a -d -in secrets.aes 

Enter the password when asked and openssl will decrypt the file and print it in the terminal. Because openssl works the same under macos, bsd, linux, and (cygwin) Windows, files created like this can be used on any platform.

A slight variation can be used to encrypt/decrypt files (rather than typed input):

openssl enc -aes256 -salt -a -e -in myfile -out myfile.aes
openssl enc -aes256 -salt -a -d -in myfile.aes -out myfile

There are also other cyphers available, type "openssl enc help" for a list.

C# 使用可信连接将SQLDMO连接到服务器

SQLDMO.SQLServer serverManager = new SQLDMO.SQLServerClass();
serverManager.LoginSecure = true;
serverManager.Connect(serverName, null, null);

C# 使用WMI连接到服务器并检查服务

ServiceController sc = new ServiceController("MSSQLSERVER", serverName); 
string sqlStatus = sc.Status.ToString();