Python Usarelmódulogmpyparanúmerosracionales

import gmpy

num = gmpy.mpq(5,2)
num2 = gmpy.mpq(10,2)

print(num+num2)

PHP 读取原始发布数据,对于从Flash XmlSocket中获取XML非常有用。

/**
     Using php://input
     -----------------
     Version: 4.3+
     
     Reading [php://input][1] is the preferred method since PHP 4.3.
     
     The Content-Type header of the posted content must _NOT_ be 
     application/x-www.form-urlencoded or multipart/form-data.
     
     For XML you can use the Content-Type: text/xml.
     
      [1]: http://us2.php.net/manual/en/wrappers.php.php
    */

    // Make sure the user is posting
    if ( $_SERVER['REQUEST_METHOD'] === 'POST' )
    {
        // Read the input from stdin
        $postText = trim(file_get_contents('php://input'));
    }
  
    /**
     Using $HTTP_RAW_POST_DATA
     -------------------------
     Version 3.0+
     
     __Note__: Reading php://input is preferred.
     
     
     As with php://input, the Content-Type header of the 
     posted content must _NOT_ be application/x-www.form-urlencoded or
     multipart/form-data.     
     
     PHP 4.1+
     ~~~~~~~~
     You can also enable [always-populate-raw-post-data][1] in the php.ini to
     have the value always populated reguardless of Content-Type. However
     since this requires config changes it is less portable.
     
      [1]: http://us2.php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data
    */
    $postText = $GLOBALS['HTTP_RAW_POST_DATA'];

JavaScript 新对话

If DonorType(0).Checked Then
		If Dialog("donorType") <> "" And Dialog("donorType") <> typeIndividual Then
			ResetDialogInfo		
		End If
		Dialog("donorType") = typeIndividual
		Dialog.GoNext("dialog-new-ind1.htm")
	Else
		If Dialog("donorType") <> "" And Dialog("donorType") <> typeOrganization Then
			ResetDialogInfo		
		End If
		Dialog("donorType") = typeOrganization
		Dialog.GoNext("dialog-new-org1.htm")
	End If

Bash 如何在开发被阻止时卸载?

lsof -n | grep /mnt/cdrom

PHP 功能limpiarPTags

/**
 *  Function limpiarPTags
 *
 *   Elimina las etiquetas de parrafo <P> (sin parametros) y las sustituye por
 *   saltos de linea <BR />.
 *   En caso necesario inserta un <BR /> adicional para simular la separacion de
 *   parrafos.
 *   
 *   Parámetros:
 *   @param string $cadena -> texto a limpiar
 *   @param boolean $separar_parrafos -> separar parrafos ??
 *   @return string $cadena -> texto limpio
*/
    function limpiarPTags($cadena, $separar_parrafos = true)
    {
        $cadena = trim($cadena);
        $cadena = eregi_replace("^<p>","", $cadena);
        if ($separar_parrafos) {
            $cadena = eregi_replace("<p>","<br /><br />", $cadena);
        } else {
            $cadena = eregi_replace("<p>","<br />", $cadena);
        }
        $cadena = eregi_replace("</p>","", $cadena);
        return $cadena;
    }

HTML 元html重定向

<meta http-equiv="refresh" content="5;URL=index.php" />

JavaScript RND - innerHTML的简单模板

function RND(tmpl, ns) {
  var fn = function(w, g) {
    g = g.split("|");
    var cnt = ns[g[0]];
    for(var i=1; i < g.length; i++)
      cnt = eval(g[i])(cnt);
    return cnt || w;
  };
  return tmpl.replace(/%(([A-Za-z0-9_|.]*))/g, fn);
}

HTML CWT

<cwt>
  <table width="768px">
    <tr>
      <td><img src="/img/spacer.gif" width="768" height="1" /></td>
    </tr>
  </table>
</cwt>

PHP MySQL的

function updateKillPoints($PlayerID) {
	$TKP = 0;
	$result = mysql_query("SELECT `KillID` FROM `Involved` WHERE `PlayerID` = '".$PlayerID."'");

	while($data = mysql_fetch_array($result)) {
		$KillID = $data['KillID'];

		$get_result = mysql_query("SELECT `ShipID` FROM `Kill` WHERE `KillID` = '".$KillID."'");

		while($get_kills = mysql_fetch_array($get_result)) {
			$ShipID = $get_kills['ShipID'];

			$get_points = mysql_query("SELECT `Points` FROM `Ship` WHERE `ShipID` = '".$ShipID."'");

			while($get_points = mysql_fetch_array($get_points)) {
				$TKP = $TKP + $get_points;
			}
		}
	}

	echo $TKP;
	#mysql_query("UPDATE Player SET KillPoints = ".$TKP." WHERE PlayerID = ".$PlayerID."");
}

Ruby 一个assert_difference

module AssertHelper
  # Author:: http://blog.caboo.se/articles/2006/06/13/a-better-assert_difference
  # 
  # == Examples
  #   assert_difference Group, :count do
  #     post :create, :group => { :name => 'monkeys' }
  #   end
  #   
  #   assert_difference [ User, Group ], :count do
  #     Membership.create(:user_id => 1, :group_id => 5)
  #   end 
  #   
  #   assert_difference User, :name, nil do
  #     post :update, :id => 5, { :name => 'monkeys' }
  #   end
  def assert_difference(objects, method = nil, difference = 1)
    objects = [objects].flatten
    initial_values = objects.inject([]) { |sum,obj| sum << obj.send(method) }
    yield
    if difference.nil?
      objects.each_with_index { |obj,i|
        assert_not_equal initial_values[i], obj.send(method), "#{obj}##{method}"
      }
    else
      objects.each_with_index { |obj,i|
        assert_equal initial_values[i] + difference, obj.send(method), "#{obj}##{method}"
      }
    end
  end
  
  def assert_no_difference_in_size(object, methods = nil, &block)
    assert_difference_in_size object, methods, 0, &block
  end
end