in

SDT Community Server

SDT Forums, Blogs, Photos server.

Floating Heart

No description is bad.

February 2007 - Posts

  • Page.Cache, HttpContext.Cache, HttpRuntime.Cache的区别

    其实都是引用的同一样东西,通过Reflector可以看到,Page.Cache引用的是HttpContext.Cache,HttpContext.Cache引用的是HttpRuntime.Cache。前2的存在只是为了使用的方便而以。

    由于Page和Context不是在任何环境都可用,HttpRuntime.Cache应该是最好的选择。
    SimpleCache就是HttpRuntime.Cache的简单包装。

    有种说法是HttpContext.Cache是页面相关的,由代码看,这个说法是错误的。
    它们都指向同一个实例,范围是Application。

     

    Posted Feb 28 2007, 02:49 PM by wicky with no comments
    Filed under: ,
  • SQL Server 2005 SP2

    Posted Feb 25 2007, 09:05 AM by wicky with no comments
    Filed under:
  • XtraGrid: How to filter a second LookUp column based on a first LookUp column's value


    https://www.devexpress.com/Support/Center/ViewKBIssue.aspx?kbid=A237&searchtext=lookupedit+datasource&pgid=ecb3be56-c75a-4166-aa68-cb462cd2dd2b&pid=382e0f17-f133-4866-aa3f-aeb2f50b59b7

    Description

    Let's assume that there is an XtraGrid with two combo boxes (dropdown lists) in one row. The list items of the second combo depends upon the current value of the first combo. If a user selects any value in the first combo, the second combo must filter its list items. Is this possible to implement?

    Solution

    Applies to:
    XtraGrid, XtraEditors, XtraTreeList, XtraVerticalGrid

    The XtraEditors and XtraGrid allow you to fulfill this task. It's best to use RepositoryItemLookUpEdit in this situation as a column's editor with a dropdown list.

    In case of using the XtraGrid, you should handle the ShownEditor event: create a new data object, filter it and assign to the active editor (not to the repository item).

    If you are using stand-alone LookUpEdit editors, it's best to utilize the Enter event to filter lookup items at the time when an editor gets focused. The QueryPopUp event is not suitable, because a user can enter a new value without opening the dropdown list.

    Please review the attached project. It uses two linked LookUp editors in the XtraGrid. The lookup list of the second editor (City) depends on the value of the first editor (Country). Please pay close attention to the fact that a new data view is created, filtered and assigned to the active editor (GridView.ActiveEditor).

    [C#]
    
    private DataView clone = null;
    
    private void gridView1_ShownEditor(object sender, System.EventArgs e) {
        DevExpress.XtraGrid.Views.Grid.GridView view;
        view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
        if (view.FocusedColumn.FieldName == "CityCode" && view.ActiveEditor is DevExpress.XtraEditors.LookUpEdit) {
            Text = view.ActiveEditor.Parent.Name;
            DevExpress.XtraEditors.LookUpEdit edit;
            edit = (DevExpress.XtraEditors.LookUpEdit)view.ActiveEditor;
    
            DataTable table = edit.Properties.LookUpData.DataSource as DataTable;
            clone = new DataView(table);
            DataRow row = view.GetDataRow(view.FocusedRowHandle);
            clone.RowFilter = "[CountryCode] = " + row["CountryCode"].ToString();
            edit.Properties.LookUpData.DataSource = clone;
        }
    }
    
    private void gridView1_HiddenEditor(object sender, System.EventArgs e) {
        if (clone != null) {
            clone.Dispose();
            clone = null;
        }
    }
    

    See Also:
    How to use a combo box whose choices are different for each cell in the grid
  • 关于初次DataBind的时候会触发ValueChanged事件的问题

    由于MS Binding的机制的影响,在ShowDialog的时候,数据绑定的相关控件会触发ValueChanged事件。
    对于XtraEditors,会触发EditValueChanged事件。
    但是这个是我们不期望的,因为他只相当于Form的初始化。
    一个解决办法就是在Form Load事件里面邦定EditValueChanged事件,
    而不在InitializeComponent里面绑定。
    这样第一次的数据绑定将不会激发EditValueChanged事件。

     

  • DataSourceUpdateMode in DataBinding

    有时我们希望在控件的值一修改就更新绑定的数据源。但是默认的DataBinding却不会这样做。

    因为默认的DataSourceUpdateMode是OnValidation,一般也就是在离开焦点的时候才做这件事。

    如果用DevExpress的XtraEditors,通常有几种方法:

    1) call BaseEdit.DoValidate方法
    2) call BindingContext[].EndCurrentEdit方法
    3) 绑定的时候将DataSourceUpdateMode设置成OnPropertyChanged
    例如:
    luePayTerms.DataBindings.Add("EditValue", dt, "PAYTERMS", false, DataSourceUpdateMode.OnPropertyChanged );

    某些情况下,由于MS Binding机制的关系,可能只有第3)种方法可用。
    比如在LookupEdit的EditValueChanged事件里面就是这样的。

     

  • 金鸡独立-最简单有效的平衡健身法


    身体有病中医认为是阴阳失调,但是这个概念太过笼统,细分之可以理解为五脏六腑之间相互谐调的关系出了问题。但是有些人罹患的是肢体病似乎又需归类于五脏六腑与四肢百骸之间的不和谐所产生。如此推而论之,问题就会变得越来越复杂。没有点中医知识的人就很难理解。所以有没有一种简单有效的方法可以直接来调节身体的平衡呢?答案是肯定的,而且是出乎意料的简单易行。那就是金鸡独立健身法。

    方法很简单,只需将两眼微闭,两手自然放在身体两侧,任意抬起一只脚,试试能站立几分钟,注意关键是不能将眼睛睁开。这样你调节自己的平衡就不是靠双眼和参照物之间的谐调,而是调动了你大脑神经来对身体的各个器官的平衡进行调节。在脚上有六条重要的经络通过。通过脚的调节,虚弱的经络就会感到酸痛,同时得到了锻炼,这根经络对应的脏腑和它循行的部位也就相应的得到了调节。这种方法可以使意念集中,将人体的气血引向足底,对于高血压、糖尿病、颈腰椎病都有立杆见影的疗效。还可以治疗小脑痿缩,并可预防美尼尔、痛风等许多病症。对于足寒症更是效果奇特。因为是治本的方法,所以可以迅速的增强人体的免疫力。

    Posted Feb 10 2007, 01:59 PM by wicky with no comments
    Filed under:
  • 如何得到硬盘序列号?.NET版本[C#]

    http://study.pay500.com/4/s44901.htm

    硬盘序列号(Serial Number)不等于卷标号(Volume Name),后者虽然很容易得到,但是格式化分区后就会重写,不可靠。遗憾的是很多朋友往往分不清这一点。
    要得到硬盘的物理序列号,可以通过WMI,也就是Win32_PhysicalMedia.SerialNumber。可惜的是Windows 98/ME的WMI并不支持这个类,访问时会出现异常。
    受陆麟的例子的启发,我们还可以通过S.M.A.R.T.接口,直接从RING3调用API DeviceIoControl()来获取硬盘信息,而不需要写VXD或者DRIVER。这样这个问题就解决了,我对它进行了封装,大量使用了P/Invoke技术,一个完整的Library。支持Windows 98-2003。
    使用上很简单:
    HardDiskInfo hdd = AtapiDevice.GetHddInfo(0); // 第一个硬盘
    Console.WriteLine("Module Number: {0}", hdd.ModuleNumber);
    Console.WriteLine("Serial Number: {0}", hdd.SerialNumber);
    Console.WriteLine("Firmware: {0}", hdd.Firmware);
    Console.WriteLine("Capacity: {0} M", hdd.Capacity);
    下面是全部代码:
    using System;
    using System.Runtime.InteropServices;
    using System.Text;

    namespace Sunmast.Hardware
    {
    [Serializable]
    public struct HardDiskInfo
    {
    /// <summary>
    /// 型号
    /// </summary>
    public string ModuleNumber;
    /// <summary>
    /// 固件版本
    /// </summary>
    public string Firmware;
    /// <summary>
    /// 序列号
    /// </summary>
    public string SerialNumber;
    /// <summary>
    /// 容量,以M为单位
    /// </summary>
    public uint Capacity;
    }

    #region Internal Structs

    [StructLayout(LayoutKind.Sequential, Pack=1)]
    internal struct GetVersionOutParams
    {
    public byte bVersion;
    public byte bRevision;
    public byte bReserved;
    public byte bIDEDeviceMap;
    public uint fCapabilities;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)]
    public uint[] dwReserved; // For future use.
    }

    [StructLayout(LayoutKind.Sequential, Pack=1)]
    internal struct IdeRegs
    {
    public byte bFeaturesReg;
    public byte bSectorCountReg;
    public byte bSectorNumberReg;
    public byte bCylLowReg;
    public byte bCylHighReg;
    public byte bDriveHeadReg;
    public byte bCommandReg;
    public byte bReserved;
    }

    [StructLayout(LayoutKind.Sequential, Pack=1)]
    internal struct SendCmdInParams
    {
    public uint cBufferSize;
    public IdeRegs irDriveRegs;
    public byte bDriveNumber;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=3)]
    public byte[] bReserved;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)]
    public uint[] dwReserved;
    public byte bBuffer;
    }

    [StructLayout(LayoutKind.Sequential, Pack=1)]
    internal struct DriverStatus
    {
    public byte bDriverError;
    public byte bIDEStatus;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
    public byte[] bReserved;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
    public uint[] dwReserved;
    }

    [StructLayout(LayoutKind.Sequential, Pack=1)]
    internal struct SendCmdOutParams
    {
    public uint cBufferSize;
    public DriverStatus DriverStatus;
    public IdSector bBuffer;
    }

    [StructLayout(LayoutKind.Sequential, Pack=1, Size=512)]
    internal struct IdSector
    {
    public ushort wGenConfig;
    public ushort wNumCyls;
    public ushort wReserved;
    public ushort wNumHeads;
    public ushort wBytesPerTrack;
    public ushort wBytesPerSector;
    public ushort wSectorsPerTrack;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=3)]
    public ushort[] wVendorUnique;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=20)]
    public byte[] sSerialNumber;
    public ushort wBufferType;
    public ushort wBufferSize;
    public ushort wECCSize;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=8)]
    public byte[] sFirmwareRev;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=40)]
    public byte[] sModelNumber;
    public ushort wMoreVendorUnique;
    public ushort wDoubleWordIO;
    public ushort wCapabilities;
    public ushort wReserved1;
    public ushort wPIOTiming;
    public ushort wDMATiming;
    public ushort wBS;
    public ushort wNumCurrentCyls;
    public ushort wNumCurrentHeads;
    public ushort wNumCurrentSectorsPerTrack;
    public uint ulCurrentSectorCapacity;
    public ushort wMultSectorStuff;
    public uint ulTotalAddressableSectors;
    public ushort wSingleWordDMA;
    public ushort wMultiWordDMA;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=128)]
    public byte[] bReserved;
    }

    #endregion

    /// <summary>
    /// ATAPI驱动器相关
    /// </summary>
    public class AtapiDevice
    {

    #region DllImport

    [DllImport("kernel32.dll", SetLastError=true)]
    static extern int CloseHandle(IntPtr hObject);

    [DllImport("kernel32.dll", SetLastError=true)]
    static extern IntPtr CreateFile(
    string lpFileName,
    uint dwDesiredAccess,
    uint dwShareMode,
    IntPtr lpSecurityAttributes,
    uint dwCreationDisposition,
    uint dwFlagsAndAttributes,
    IntPtr hTemplateFile);

    [DllImport("kernel32.dll")]
    static extern int DeviceIoControl(
    IntPtr hDevice,
    uint dwIoControlCode,
    IntPtr lpInBuffer,
    uint nInBufferSize,
    ref GetVersionOutParams lpOutBuffer,
    uint nOutBufferSize,
    ref uint lpBytesReturned,
    [Out] IntPtr lpOverlapped);

    [DllImport("kernel32.dll")]
    static extern int DeviceIoControl(
    IntPtr hDevice,
    uint dwIoControlCode,
    ref SendCmdInParams lpInBuffer,
    uint nInBufferSize,
    ref SendCmdOutParams lpOutBuffer,
    uint nOutBufferSize,
    ref uint lpBytesReturned,
    [Out] IntPtr lpOverlapped);

    const uint DFP_GET_VERSION = 0x00074080;
    const uint DFP_SEND_DRIVE_COMMAND = 0x0007c084;
    const uint DFP_RECEIVE_DRIVE_DATA = 0x0007c088;

    const uint GENERIC_READ = 0x80000000;
    const uint GENERIC_WRITE = 0x40000000;
    const uint FILE_SHARE_READ = 0x00000001;
    const uint FILE_SHARE_WRITE = 0x00000002;
    const uint CREATE_NEW = 1;
    const uint OPEN_EXISTING = 3;

    #endregion

    #region GetHddInfo

    /// <summary>
    /// 获得硬盘信息
    /// </summary>
    /// <param name="driveIndex">硬盘序号</param>
    /// <returns>硬盘信息</returns>
    /// <remarks>
    /// 参考lu0的文章:http://lu0s1.3322.org/App/2k1103.html
    /// by sunmast for everyone
    /// thanks lu0 for his great works
    /// 在Windows 98/ME中,S.M.A.R.T并不缺省安装,请将SMARTVSD.VXD拷贝到%SYSTEM%\IOSUBSYS目录下。
    /// 在Windows 2000/2003下,需要Administrators组的权限。
    /// </remarks>
    /// <example>
    /// AtapiDevice.GetHddInfo()
    /// </example>
    public static HardDiskInfo GetHddInfo(byte driveIndex)
    {
    switch(Environment.OSVersion.Platform)
    {
    case PlatformID.Win32Windows:
    return GetHddInfo9x(driveIndex);
    case PlatformID.Win32NT:
    return GetHddInfoNT(driveIndex);
    case PlatformID.Win32S:
    throw new NotSupportedException("Win32s is not supported.");
    case PlatformID.WinCE:
    throw new NotSupportedException("WinCE is not supported.");
    default:
    throw new NotSupportedException("Unknown Platform.");
    }
    }

    #region GetHddInfo9x

    private static HardDiskInfo GetHddInfo9x(byte driveIndex)
    {
    GetVersionOutParams vers = new GetVersionOutParams();
    SendCmdInParams inParam = new SendCmdInParams();
    SendCmdOutParams outParam = new SendCmdOutParams();
    uint bytesReturned = 0;

    IntPtr hDevice = CreateFile(
    @"\\.\Smartvsd",
    0,
    0,
    IntPtr.Zero,
    CREATE_NEW,
    0,
    IntPtr.Zero);
    if (hDevice == IntPtr.Zero)
    {
    throw new Exception("Open smartvsd.vxd failed.");
    }
    if (0 == DeviceIoControl(
    hDevice,
    DFP_GET_VERSION,
    IntPtr.Zero,
    0,
    ref vers,
    (uint)Marshal.SizeOf(vers),
    ref bytesReturned,
    IntPtr.Zero))
    {
    CloseHandle(hDevice);
    throw new Exception("DeviceIoControl failed:DFP_GET_VERSION");
    }
    // If IDE identify command not supported, fails
    if (0 == (vers.fCapabilities & 1))
    {
    CloseHandle(hDevice);
    throw new Exception("Error: IDE identify command not supported.");
    }
    if (0 != (driveIndex & 1))
    {
    inParam.irDriveRegs.bDriveHeadReg = 0xb0;
    }
    else
    {
    inParam.irDriveRegs.bDriveHeadReg = 0xa0;
    }
    if (0 != (vers.fCapabilities & (16 >> driveIndex)))
    {
    // We don't detect a ATAPI device.
    CloseHandle(hDevice);
    throw new Exception(string.Format("Drive {0} is a ATAPI device, we don't detect it",driveIndex + 1));
    }
    else
    {
    inParam.irDriveRegs.bCommandReg = 0xec;
    }
    inParam.bDriveNumber = driveIndex;
    inParam.irDriveRegs.bSectorCountReg = 1;
    inParam.irDriveRegs.bSectorNumberReg = 1;
    inParam.cBufferSize = 512;
    if (0 == DeviceIoControl(
    hDevice,
    DFP_RECEIVE_DRIVE_DATA,
    ref inParam,
    (uint)Marshal.SizeOf(inParam),
    ref outParam,
    (uint)Marshal.SizeOf(outParam),
    ref bytesReturned,
    IntPtr.Zero))
    {
    CloseHandle(hDevice);
    throw new Exception("DeviceIoControl failed: DFP_RECEIVE_DRIVE_DATA");
    }
    CloseHandle(hDevice);

    return GetHardDiskInfo(outParam.bBuffer);
    }

    #endregion

    #region GetHddInfoNT

    private static HardDiskInfo GetHddInfoNT(byte driveIndex)
    {
    GetVersionOutParams vers = new GetVersionOutParams();
    SendCmdInParams inParam = new SendCmdInParams();
    SendCmdOutParams outParam = new SendCmdOutParams();
    uint bytesReturned = 0;

    // We start in NT/Win2000
    IntPtr hDevice = CreateFile(
    string.Format(@"\\.\PhysicalDrive{0}",driveIndex),
    GENERIC_READ | GENERIC_WRITE,
    FILE_SHARE_READ | FILE_SHARE_WRITE,
    IntPtr.Zero,
    OPEN_EXISTING,
    0,
    IntPtr.Zero);
    if (hDevice == IntPtr.Zero)
    {
    throw new Exception("CreateFile faild.");
    }
    if (0 == DeviceIoControl(
    hDevice,
    DFP_GET_VERSION,
    IntPtr.Zero,
    0,
    ref vers,
    (uint)Marshal.SizeOf(vers),
    ref bytesReturned,
    IntPtr.Zero))
    {
    CloseHandle(hDevice);
    throw new Exception(string.Format("Drive {0} may not exists.",driveIndex + 1));
    }
    // If IDE identify command not supported, fails
    if (0 == (vers.fCapabilities & 1))
    {
    CloseHandle(hDevice);
    throw new Exception("Error: IDE identify command not supported.");
    }
    // Identify the IDE drives
    if (0 != (driveIndex & 1))
    {
    inParam.irDriveRegs.bDriveHeadReg = 0xb0;
    }
    else
    {
    inParam.irDriveRegs.bDriveHeadReg=0xa0;
    }
    if (0 != (vers.fCapabilities & (16 >> driveIndex)))
    {
    // We don't detect a ATAPI device.
    CloseHandle(hDevice);
    throw new Exception(string.Format("Drive {0} is a ATAPI device, we don't detect it.",driveIndex + 1));
    }
    else
    {
    inParam.irDriveRegs.bCommandReg = 0xec;
    }
    inParam.bDriveNumber = driveIndex;
    inParam.irDriveRegs.bSectorCountReg = 1;
    inParam.irDriveRegs.bSectorNumberReg = 1;
    inParam.cBufferSize = 512;

    if (0 == DeviceIoControl(
    hDevice,
    DFP_RECEIVE_DRIVE_DATA,
    ref inParam,
    (uint)Marshal.SizeOf(inParam),
    ref outParam,
    (uint)Marshal.SizeOf(outParam),
    ref bytesReturned,
    IntPtr.Zero))
    {
    CloseHandle(hDevice);
    throw new Exception("DeviceIoControl failed: DFP_RECEIVE_DRIVE_DATA");
    }
    CloseHandle(hDevice);

    return GetHardDiskInfo(outParam.bBuffer);
    }

    #endregion

    private static HardDiskInfo GetHardDiskInfo(IdSector phdinfo)
    {
    HardDiskInfo hddInfo = new HardDiskInfo();

    ChangeByteOrder(phdinfo.sModelNumber);
    hddInfo.ModuleNumber = Encoding.ASCII.GetString(phdinfo.sModelNumber).Trim();

    ChangeByteOrder(phdinfo.sFirmwareRev);
    hddInfo.Firmware = Encoding.ASCII.GetString(phdinfo.sFirmwareRev).Trim();

    ChangeByteOrder(phdinfo.sSerialNumber);
    hddInfo.SerialNumber = Encoding.ASCII.GetString(phdinfo.sSerialNumber).Trim();

    hddInfo.Capacity = phdinfo.ulTotalAddressableSectors / 2 / 1024;

    return hddInfo;
    }

    private static void ChangeByteOrder(byte[] charArray)
    {
    byte temp;
    for(int i = 0; i < charArray.Length; i += 2)
    {
    temp = charArrayIdea;
    charArrayIdea = charArray[i+1];
    charArray[i+1] = temp;
    }
    }

    #endregion
    }
    }

    注:
    在Windows 98/ME中,S.M.A.R.T并不缺省安装,请将SMARTVSD.VXD拷贝到%SYSTEM%\IOSUBSYS目录下。
    在Windows 2000/2003下,需要Administrators组的权限。
    不要在装有SCSI硬盘的机器上尝试了,因为SCSI硬盘根本不存在序列号。

     

  • 从SQL Server表中随机取一条记录


    这是比较巧妙的方法:

    SELECT TOP(1) * FROM YOURTABLE ORDER BY CHECKSUM(NEWID());

    表大的时候可能性能不是很好。

    Posted Feb 06 2007, 02:07 PM by wicky with 1 comment(s)
    Filed under:
  • How to Shoot Yourself in the Foot in Any Programming Language

    http://www.fullduplex.org/humor/2006/10/how-to-shoot-yourself-in-the-foot-in-any-programming-language/

    C
    You shoot yourself in the foot.

    C++
    You accidentally create a dozen clones of yourself and shoot them all in the foot. Providing emergency medical assistance is impossible since you can’t tell which are bitwise copies and which are just pointing at others and saying, “That’s me, over there.”

    JAVA
    After importing java.awt.right.foot.* and java.awt.gun.right.hand.*, and writing the classes and methods of those classes needed, you’ve forgotten what the hell you’re doing.

    Ruby
    Your foot is ready to be shot in roughly five minutes, but you just can’t find anywhere to shoot it.

    PHP
    You shoot yourself in the foot with a gun made with pieces from 300 other guns.

    ASP.NET
    Find a gun, it falls apart. Put it back together, it falls apart again. You try using the .GUN Framework, it falls apart. You stab yourself in the foot instead.

    SQL
    SELECT @ammo:=bullet FROM gun WHERE trigger = ‘PULLED’;
    INSERT INTO leg (foot) VALUES (@ammo);

    Perl
    You shoot yourself in the foot, but nobody can understand how you did it. Six months later, neither can you. (via Andy)

    Javascript
    YOu’ve perfected a robust, rich user experience for shooting yourself in the foot. You then find that bullets are disabled on your gun.

    CSS
    You shoot your right foot with one hand, then switch hands to shoot your left foot but you realize that the gun has turned into a banana.

    FORTRAN
    You shoot yourself in each toe, iteratively, until you run out of toes, then you read in the next foot and repeat. If you run out of bullets, you continue anyway because you have no exception-handling ability.

    Modula2
    After realizing that you can’t actually accomplish anything in this language, you shoot yourself in the head.

    COBOL
    Using a COLT 45 HANDGUN, AIM gun at LEG.FOOT, THEN place ARM.HAND.FINGER. on HANDGUN.TRIGGER and SQUEEZE. THEN return HANDGUN to HOLSTER. CHECK whether shoelace needs to be retied.

    LISP
    You shoot yourself in the appendage which holds the gun with which
    you shoot yourself in the appendage which holds the gun with which
    you shoot yourself in the appendage which holds the gun with which
    you shoot yourself in the appendage which holds the gun with which
    you shoot yourself in the appendage which holds ….

    BASIC
    Shoot yourself in the foot with a water pistol. On big systems, continue until entire lower body is waterlogged.

    FORTH
    Foot in yourself shoot.

    APL
    You shoot yourself in the foot, then spend all day figuring out how to do it in fewer characters.

    Pascal
    The compiler won’t let you shoot yourself in the foot.

    SNOBOL
    If you succeed, shoot yourself in the left foot.
    If you fail, shoot yourself in the right foot.

    Concurrent Euclid
    You shoot yourself in somebody else’s foot.

    HyperTalk
    Put the first bullet of the gun into the foot of the left leg of you.
    Answer the result.

    Motif
    You spend days writing a UIL description of your foot, the trajectory, the bullet, and the intricate scrollwork on the ivory handles of the gun. When you finally get around to pulling the trigger, the gun jams.

    Unix
    % ls
    foot.c foot.h foot.o toe.c toe.o
    % rm * .o
    rm: .o: No such file or directory
    % ls
    %

    Paradox
    Not only can you shoot yourself in the foot, your users can too.

    Revelation
    You’ll be able to shoot yourself in the foot just as soon as you figure out what all these bullets are for.

    Visual Basic
    You’ll shoot yourself in the foot, but you’ll have so much fun doing it that you won’t care.

    Prolog
    You tell your program you want to be shot in the foot. The program figures out how to do it, but the syntax doesn’t allow it to explain.

    Ada
    After correctly packaging your foot, you attempt to concurrently load the gun, pull the trigger, scream and shoot yourself in the foot. When you try, however, you discover that your foot is of the wrong type.

    Assembly
    You try to shoot yourself in the foot only to discover you must first reinvent the gun, the bullet, and your foot. After that’s done, you pull the trigger, the gun beeps several times, then crashes.

    370 JCL
    You send your foot down to MIS with a 4000-page document explaining how you want it to be shot. Three years later, your foot comes back deep-fried.

    Python
    You try to shoot yourself in the foot but you just keep hitting the whitespace between your toes.

    任务:射你自己的脚。    
       
              c:射你自己的脚。    
       
              c++:你不留神生成了一堆你自己的实例,所以只好挨个射他们的脚。紧急援救是不可能的,因为你不知道哪个是你的真拷贝,哪个只是指向你的指针。    
       
              fortran:你逐个射你的脚趾,一直循环到射没了所有的脚趾,然后你读入下一只脚并重复之。如果你没了子弹,你也得接着射,因为你没有意外处理机制。    
       
              pascal:编译器不允许你这么干。    
       
              ada:在你仔细地包装好了你的脚后,你试图以并行的方式上弹,扣扳机,尖叫,并射你自己的脚。然而,当你试了一下后,发现你的脚类型不对。    
       
              lisp:你用拿着枪的四肢拿着的枪射你的拿着枪的四肢。    
       
              forth:脚的己自你射。    
       
              prolog:你告诉程序你想射你自己的脚。程序会自动找到具体的计划,不过语法上是不允许把这些计划告诉你的。    
       
              basic:你用水枪射你自己的脚。如果是在大系统中,重复直至你的下半身被水浸没。    
       
              visualbasic:你其实只是装出好象是射了你的脚的样子,不过你觉得这么干更有趣所以也不在乎倒底射没射。    
       
              paradox:不但你可以射你自己的脚,你的用户也可以。    
       
              access:你用枪瞄准了你自己的脚,但子弹却把旁边所有标着borland字样的软盘打出了洞。    
       
              assembler:你试图射你自己的脚,结果发现你还得先自己来制造出枪支,子弹,瞄准具,和你的脚。    
       
              modula2:当终于明白用这个语言什么也干不了时,你一枪射穿了你的脑门。

     

    Posted Feb 06 2007, 08:32 AM by wicky with no comments
    Filed under:
Copyright SDT, 2006-2009. All rights reserved.