Friday, March 19, 2010

ERROR: Missing kernel configuration file(s) (MYKERNEL)

I had such mistake several days ago. In my case the reson was that I forgot that I am using amd64 arch, and I placed config to /usr/src/sys/i386/conf, but the right place was /usr/src/sys/amd64/conf.

Tuesday, March 16, 2010

誠心為思想之本

1. 誠心為思想之本
2. 忘我以求道
3. 遍習諸藝
4. 廣渉百業之道
5. 了解諸事的利弊得失
6. 培養辨別事物的眼光
7. 洞悉肉眼不可見之事
8. 留心細節小事
9. 不做無功效之事

Six ways to make people like you

Six ways to make people like you

1. Become genuinely interested in other people.
2. Smile.
3. Remember that a person's name is to that person the sweetest and most important sound in any language.
4. Be a good listener. Encourage others to talk about themselves.
5. Talk in terms of the other person's interests.
6. Make the other person feel important - and do it sincerely.

Win people to your way of thinking

Win people to your way of thinking

1. The only way to get the best of an argument is to avoid it.
2. Show respect for the other person's opinions. Never say, "You're wrong."
3. If you are wrong, admit it quickly and emphatically.
4. Begin in a friendly way.
5. Get the other person saying "yes, yes" immediately.
6. Let the other person do a great deal of the talking.
7. Let the other person feel that the idea is his or hers.
8. Try honestly to see things from the other person's point of view.
9. Be sympathetic with the other person's ideas and desires.
10. Appeal to the nobler motives.
11. Dramatize your ideas.
12. Throw down a challenge.

Wednesday, March 3, 2010

vbscript for deleting 2 week old files in 44 separate folders

Option Explicit

Dim fso, dTwoWeeksAgo

dTwoWeeksAgo = Date() - 14
wscript.echo dTwoWeeksAgo
Set fso = CreateObject("Scripting.FileSystemObject")

'DirWalk("C:\")               ' repeat this subroutine call with a different path to process more paths
'DirWalk("F:\users\data\")   ' like this.
'DirWalk("\\phobos\E$\ee\")  ' and/or like this.

DirWalk("C:\tmp\test\hmm")

Sub DirWalk(parmPath)
Dim oSubDir, oSubFolder, oFile, n

   On Error Resume Next         ' We'll handle any errors ourself, thank you very much

   Set oSubFolder = fso.getfolder(parmPath)

   For Each oFile In oSubFolder.Files   ' look in the current dir
      If Err.Number <> 0 Then   ' if we got an error, just skip this entry
         Err.Clear
      ElseIf oFile.DateLastModified < dTwoWeeksAgo Then
         Wscript.Echo "about to delete " & oFile.Path
      '''uncomment the next line when you are satisfied this script works properly
      '''fso.DeleteFile oFile.Path, True
      End If
   Next

   For Each oSubDir In oSubFolder.Subfolders
      DirWalk oSubDir.Path      ' recurse the DirWalk sub with the subdir paths
   Next

   On Error Goto 0              ' Resume letting system handle errors.

   ' Removing a empty folder.
   ' Commenting out following block if you prefer to keep these empty folders.
   If fso.getfolder(parmPath).SubFolders.Count = 0 AND fso.getfolder(parmPath).Files.Count = 0 Then
      fso.DeleteFolder(parmPath)
   End If

End Sub

Tuesday, February 23, 2010

Difference Between getcwd() and dirname(__FILE__) ? Which should I use?

Difference Between getcwd() and dirname(__FILE__) ? Which should I use?

__FILE__ is a magic constant containing the full path to the file you are executing. If you are inside an include, its path will be the contents of __FILE__.

So with this setup:

./foo.php
<?php
echo getcwd() ,"\n";
echo dirname(__FILE__),"\n" ;
echo '-------',"\n";
include 'bar/bar.php';
?>

./bar/bar.php
<?php
echo getcwd(),"\n";
echo dirname(__FILE__),"\n";
?>

You get this output (Windows / Zend Studio Debugger):

C:\Users\me\Zend\workspaces\DefaultWorkspace7\random
C:\Users\me\Zend\workspaces\DefaultWorkspace7\random
-------
C:\Users\me\Zend\workspaces\DefaultWorkspace7\random
C:\Users\me\Zend\workspaces\DefaultWorkspace7\random\bar

On FreeBSD:

# php foo.php
/tmp/tmp
/tmp/tmp
-------
/tmp/tmp
/tmp/tmp/bar

Appearantly, getcwd() returns the CURRENT directory where the file you started executing resided, while dirname(__FILE__) is file-dependant.

Note: for getcwd(), if you put your script in /tmp/test.php, but you started executing that script in / the root directory, getcwd() will return / instead of /tmp

Example:
<?php
echo getcwd();
?>

Running the script from /tmp, returns /tmp
root@host [/tmp] # php test.php
/tmp

While, running the script from /, returns /
root@host [/] # php /tmp/test.php
/

So, please be aware of the difference.