Bash mysql复制数据库

# mysqladmin create DB_name -u DB_user --password=DB_pass && \
mysqldump -u DB_user --password=DB_pass DB_name | mysql -u DB_user --password=DB_pass -h DB_host DB_name

C# 使用带有NMock的虚拟工厂方法来帮助NUnit测试

using System;
using System.Collections.Generic;
using System.Text;
using NMock2;
using NUnit.Framework;

namespace NUnitSandbox
{
    public interface IThingInterface
    {
        int GetThingNumber(); 
    }
    public class RealThing
    {
        public int GetThingNumber()
        {
            return 13;
        }
    }

    public class ClassToBeTested
    {
        protected virtual IThingInterface GetThing()
        {
            return new RealThing() as IThingInterface;
        }
        public int WhatIsTheThingNumber()
        {
            IThingInterface iThing = GetThing();
            return iThing.GetThingNumber(); 
        }
    }

    /// <summary>
    /// This class inherits from ClassToBeTested, so it can override the Virtual Thing Factory method (GetThing).  
    /// </summary>
    [TestFixture]
    public class TestClass : ClassToBeTested
    {
        private Mockery mocks = new Mockery();

        /// <summary>
        /// This is the key.  
        /// </summary>
        protected override IThingInterface GetThing()
        {
            IThingInterface mockThing = mocks.NewMock<IThingInterface>();
            Expect.AtLeastOnce.On(mockThing).Method("GetThingNumber").Will(Return.Value(42));
            return mockThing;
        }

        [Test]
        public void TestGetThingNumber()
        {
            Assert.AreEqual(42, this.WhatIsTheThingNumber(), "Get Thing Number value should return 42 as specified by the mock.");
        }
    }
}

Rails Rails flash消息助手

#FLASH_TYPES = [:error, :warning, :success, :message]

  def display_flash(type = nil)
    html = ""
    
    if type.nil?
      FLASH_TYPES.each { |name| html << display_flash(name) }
    else
      return flash[type].blank? ? "" : "<div class="#{type}"><p>#{flash[type]}</p></div>"
    end
    
    html
  end

C++ ASSERT_GUI_THREAD - 查看当前线程是否是MFC C ++中的GUI线程

inline void ASSERT_GUI_THREAD() 
{
	const CWnd * pWnd           = AfxGetMainWnd();
	const HWND   hWnd           = pWnd->GetSafeHwnd();
	const DWORD  WindowThreadId = GetWindowThreadProcessId( hWnd, 0 );
	const DWORD  thisThreadId   = AfxGetThread()->m_nThreadID;
	// const bool   bGuiThread     = IsGUIThread(FALSE);
	// ctrlTree.InvokeRequired == false // this might work in .NET but not MFC.

	bool isGuiThread = 
		pWnd != NULL     &&
		hWnd != NULL     &&
		thisThreadId == WindowThreadId;

	ASSERT( isGuiThread );

}

PHP Ofuscar字符串

function obuscar($str, $key) {
	if( ! defined( 'obuscar_hash' ) ) define( 'obuscar_hash', '545487875458715154879664164' );
	srand( obuscar_hash );
	$salida = '';
	$total = strlen($str);
	for( $i = -1; ++$i < $total; ){
		for( $j = -1; ++$j < ord(substr($key, $i % strlen($key), 1)); ) $toss = rand(0, 255);
		$mascara = rand(0, 255);
		$salida .= chr( ord( substr( $str, $i, 1) ) ^ $mascara);
	}
	return $salida;
}

echo obuscar('nicolas pardo','Mykey');
echo "<hr>";
echo obuscar('MS¬Š0­9k6g','Mykey');

C 在目录上操作

#include <stdio.h>
#include <dirent.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <time.h>
//coded by cobra90nj
int main(int argc, char **argv) {

struct dirent *drs;
struct stat buf;

DIR *dir;

	if (argc == 1) {
		dir = opendir(".");
	}
	else {
		dir = opendir(argv[1]);
	}
	
	while ((drs = readdir(dir)) != NULL) {
		stat(drs->d_name, &buf);
		printf("\033[0;20;31m Nome File: %s\n Ultima modifica: %s\n Dimensione file: %d B \n", drs->d_name, ctime(&(buf.st_mtime)), buf.st_size);
	}
	
closedir(dir);

}

ASP UTC和原子时

<%
    ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
    '
    ' This work is licensed under the Creative Commons Attribution License. To view
    ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
    ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
    ' 94305, USA.

    ' Returns the current date and time (UTC) from the NIST server in Boulder, Colorado.
    function utcnow()
        dim xmlhttp
        dim response
        
        ' Server to query datetime from
        Const TimeServer = "http://time.nist.gov:13"
    
        ' Use XML HTTP object to request web page content
        Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
        xmlhttp.Open "GET", TimeServer, false, "", ""
        xmlhttp.Send
        response = xmlhttp.ResponseText
        set xmlhttp = nothing
    
        ' Parse UTC date
        utcnow = cDate(mid(response, 11, 2) & "/" & mid(response, 14, 2) & "/" & mid(response, 8, 2) & " " & mid(response, 16, 9))    
    end function

    ' Returns the current date and time, offset to local time zone, from the NIST server in Boulder, Colorado.
    ' This is more accurate than VBScript's built-in Now() function in situations where the local server is not synchronized.
    ' There is expected to be some lag caused by this function, but the order of magnitude should only be milliseconds.
    ' REQUIRES: utcnow()
    function atomicnow()
        dim utc
        dim offset
        
        utc = utcnow()
        
        ' The order of the dates is important here!
        offset = DateDiff("h", utc, now())
        
        atomicnow = DateAdd("h", offset, utc)
    end function
%>

CSS 酷Web 2.0字体显示动态文本

font-family: 'Stone Sans ITC TT','Gill Sans',tahoma,sans-serif;

Bash 针对给定域的网络解决方案的Whois数据库查找

whois -h whois.networksolutions.com <DOMAIN>

SQL 如何恢复数据库的gzip压缩mysqldump

zcat <GZIPPED_MYSQLDUMP> | mysql --host=localhost --user=<USERNAME> --password=<PASSWORD> <DATABASE>