FileSystemFinder: A PHP library that can list files and directories hierarchically using wildcard and regex patterns
Actually, this PHP library was created in the National Day holiday last year. But at that time, it was not as complete as it is now.

Today I cleaned up the code, made a few improvements, and commited it to github:

https://github.com/wudicgi/file-system-finder

The example is as follows:
  1. <?php
  2. include_once 'FileSystemFinder.php';
  3.  
  4. // List files using static method FileSystemFinder::find()
  5.  
  6. $filelist = FileSystemFinder::find('C:/php/ext/php_pdo_*.dll');
  7.  
  8. print_r($filelist);                 // via __debugInfo()
  9. echo "\r\n";
  10.  
  11.  
  12. // List files using file() method with a wildcard pattern
  13.  
  14. $filelist = (new FileSystemFinder('C:/php/ext'))
  15.     ->file('php_pdo_*.dll');
  16.  
  17. print_r($filelist->toArray());      // using toArray()
  18. echo "\r\n";
  19.  
  20.  
  21. // List files using dir() and file() method with wildcard and regex patterns
  22.  
  23. $filelist = (new FileSystemFinder('C:/php'))
  24.     ->dir('dev|ext')                                    // using default wildcard matcher
  25.     ->file('/[0-9]/', FileSystemFinder::REGEX_MATCHER); // using the specified regex matcher
  26.  
  27. foreach ($filelist as $path) {      // via SeekableIterator interface
  28.     echo "$path\r\n";
  29. }
  30. echo "\r\n";
  31.  
  32.  
  33. // A combination of using both static and non-static method
  34.  
  35. $filelist = FileSystemFinder::find('C:/php/dev|ext', FileSystemFinder::DIR_ONLY);
  36. print_r($filelist);
  37.  
  38. $filelist = $filelist->file('/[0-9]/', FileSystemFinder::REGEX_MATCHER);
  39. print_r($filelist);
  40.  
  41. echo "\r\n";
  42.  
  43.  
  44. // List files using wfio extension
  45.  
  46. if (extension_loaded('wfio')) {
  47.     $filelist = FileSystemFinder::find('wfio://E:/Music/* 笑话/* 欢乐剧场/??? *大*.wma');
  48.  
  49.     for ($i = 0; $i < count($filelist); $i++) {     // via Countable interface
  50.         echo "[$i] => $filelist[$i]\r\n";           // via ArrayAccess interface
  51.     }
  52. } else {
  53.     echo "The wfio extension is not loaded.\r\n";
  54. }
  55.  
  56. ?>

This will output:
FileSystemFinder Object
(
    [0] => C:/php/ext/php_pdo_firebird.dll
    [1] => C:/php/ext/php_pdo_mysql.dll
    [2] => C:/php/ext/php_pdo_oci.dll
    [3] => C:/php/ext/php_pdo_odbc.dll
    [4] => C:/php/ext/php_pdo_pgsql.dll
    [5] => C:/php/ext/php_pdo_sqlite.dll
)

Array
(
    [0] => C:/php/ext/php_pdo_firebird.dll
    [1] => C:/php/ext/php_pdo_mysql.dll
    [2] => C:/php/ext/php_pdo_oci.dll
    [3] => C:/php/ext/php_pdo_odbc.dll
    [4] => C:/php/ext/php_pdo_pgsql.dll
    [5] => C:/php/ext/php_pdo_sqlite.dll
)

C:/php/dev/php5ts.lib
C:/php/ext/php_bz2.dll
C:/php/ext/php_gd2.dll
C:/php/ext/php_oci8_12c.dll
C:/php/ext/php_sqlite3.dll

FileSystemFinder Object
(
    [0] => C:/php/dev
    [1] => C:/php/ext
)
FileSystemFinder Object
(
    [0] => C:/php/dev/php5ts.lib
    [1] => C:/php/ext/php_bz2.dll
    [2] => C:/php/ext/php_gd2.dll
    [3] => C:/php/ext/php_oci8_12c.dll
    [4] => C:/php/ext/php_sqlite3.dll
)

[0] => wfio://E:/Music/04 笑话/01 欢乐剧场/036 武大日记.wma
[1] => wfio://E:/Music/04 笑话/01 欢乐剧场/087 大学趣闻.wma
[2] => wfio://E:/Music/04 笑话/01 欢乐剧场/109 武大郎后传.wma
[3] => wfio://E:/Music/04 笑话/01 欢乐剧场/117 孙大圣“评职”申请书.wma
[4] => wfio://E:/Music/04 笑话/01 欢乐剧场/120 肖大明白.wma
[5] => wfio://E:/Music/04 笑话/01 欢乐剧场/156 吃大户.wma
[6] => wfio://E:/Music/04 笑话/01 欢乐剧场/160 说大道小.wma
[7] => wfio://E:/Music/04 笑话/01 欢乐剧场/168 四大…….wma
[8] => wfio://E:/Music/04 笑话/01 欢乐剧场/197 过大年.wma
Current language: English · 其他语言: 中文 (简体)
Making Windows 8.1 better to use
The following steps were recorded when I configure my Windows 8.1 64-bit system. For reference only.

1. UAC

  • Settings -> Control Panel -> User Accounts -> Change User Account Control settings
  • Choose "Never notify"

2. DPI

  • Right click on desktop -> Screen resolution -> Make text and other items larger or smaller
  • Choose "Medium - 125%"
  • Check "Let me choose one scaling level for all my displays"
  • Sign out & in
  • Right click on desktop -> View -> Small icons

3. Animate Effects

  • Settings -> Control Panel -> System -> Advanced system settings
  • Advanced -> Performance -> Settings... -> Visual Effects -> Uncheck all animate effects

4. Classic Shell

  • Install Classic Shell (Do not install Classic IE9 and Update) (Download)
  • Config
  • File Explorer -> Hide Classic Explorer Bar

5. 7+ Taskbar Tweak

  • Install 7+ Taskbar Tweak (Download)
  • Config

6. Taskbar and Navigation properties

  • Right click on taskbar -> Properties
  • Taskbar -> Check "Auto-hide the taskbar"
  • Taskbar -> Check "Use small taskbar buttons"
  • Taskbar -> Taskbar buttons: Never combine
  • Jump Lists -> Uncheck "Store and display recently opened items in Jump Lists"

7. Install Drivers

8. Default Font

  • Use Windows 8 Font Changer (Download) to modify the default font to Tahoma
  • Restart
  • Adjust ClearType

9. Region

  • Settings -> Control Panel -> Region
  • Short date: yyyy-M-d
  • First day of week: 星期日

10. Keyboard Shortcuts Underline

  • Settings -> Control Panel -> Ease of Access Center -> Make the keyboard easier to use -> Make it easier to use keyboard shortcuts
  • Check "Underline keyboard shortcuts and access keys"
  • Check "Prevent windows from being automatically arranged when moved to the edge of the screen"

11. AutoPlay

  • Start -> Control Panel -> AutoPlay
  • Uncheck "Use AutoPlay for all media and devices"
  • Each selection remains the default "Choose a default"

  • Run "gpedit.msc"
  • User Configuration -> Administrative Templates -> Windows Components -> AutoPlay Policies -> Turn off AutoPlay -> Enabled on All drives
  • Computer Configuration -> Administrative Templates -> Windows Components -> AutoPlay Policies -> Turn off AutoPlay -> Enabled on All drives

12. Built-in CD Burning

  • Run "gpedit.msc"
  • User Configuration -> Administrative Templates -> Windows Components -> File Explorer -> Remove CD Burning features -> Enabled

13. Temp Folder (optional)

  • Start -> Control Panel -> System -> Advanced system settings
  • Advanced -> Environment Variables...
  • Set TEMP, TMP = F:\Temp
  • Clear original files (%USERPROFILE%\AppData\Local\Temp)

14. Folder Recognition

  • Run Restore_Default_Folder_Templates.bat (Download)
  • Run All_Folders_Use_General_Items_Folder_Template.bat (Same download page as above)

15. Hide Library Folders


16. Set Folder Default View

17. Zip Folder

  • Import Disable_ZIP_Compressed_Folders.reg

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\CompressedFolder\CLSID]

[-HKEY_CLASSES_ROOT\SystemFileAssociations\.zip\CLSID]

  • Import Disable_CAB_Files.reg

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\CABFolder\CLSID]

[-HKEY_CLASSES_ROOT\SystemFileAssociations\.cab\CLSID]

18. Compression Software

  • Install WinRAR or 7-zip

19. Configs

  • Config Sounds (Set to no sounds)
  • Config Windows Color
  • Config Quick Launch Bar

20. Install Input Method

21. Language

  • Start -> Control Panel -> Language
  • Advanced Settings -> Switching input methods -> Let me set a different input method for each app window
  • Change language bar hot keys -> Between input languages: Ctrl + Shift
  • Config as the following screenshots:









22. AutoHotkey

  • Install AutoHotkey
  • Edit the startup script as below:

; Ctrl + Shift
^space::^shift

23. WinSAT Scheduled Task

  • Start -> Control Panel -> Administrative Tools -> Task Scheduler
  • Task Scheduler Library -> Microsoft -> Windows -> Maintenance
  • Right click WinSAT, and choose "Disable"

24. Set Power Options
Current language: English · 其他语言: 中文 (简体)
今天才知道 SysWOW64 是什么意思
现在平时很少有机会手动往 System32 目录里复制 dll 文件了。今天把 VC++ 2010 Debug 版的运行时 dll 文件复制到 System32 和 SysWOW64 目录后,运行程序还是报错。用 Dependency Walker 查看,发现这个 32 位的程序加载的是 64 位版本的 dll。

在网上一番搜索才知道,原来在 64 位 Windows 中,System32 目录下存放的都是 64 位的东西,而 SysWOW64 下存放的才是 32 位的东西。为了保持兼容性,System32 的名称就没改,而 SysWOW64 其实也没体现出来 32-bit Windows on 64-bit Windows,所以这两个文件夹的名称现在看着很容易让人糊涂。

文章就是这篇《什么是SysWow64》,推荐阅读一下。
Current language: 中文 (简体)
Notepad++ with enhanced PHP syntax highlighting
During the National Day holiday, I searched for a alternative text editor and intend to use Notepad++. But when I start using it, I found its syntax highlighting feature is a bit weak.

From this article, I knew that the Scintilla editor component using by Notepad++ uses hard-coded method to deal with syntax highlighting. To add a new type of highlighting keywords, you need to modify the C++ source code. As for the problem that keywords and function names are mixed together for PHP, it has been there for 9 years.

I could have put it away and looking for commercial softwares. But I felt the well-known Sublime Text is not good as well after trying it out. So I came back to consider modifying the source code of Notepad++. Through the modification on Oct 5, I had figured it out and commited it to the repository I forked on github:

https://github.com/wudicgi/npp-customized

Today, I merged the code of v6.8.6 to my enhanced branch

This is the PHP syntax highlighting result in original edition:


And below is my enhanced version:


Now, in the Style Configurator, you can specify the PHP keywords (WORD) and function names (FUNCTION) to different colors:

Current language: English · 其他语言: 中文 (简体)
Transform Windows 7 into Windows 8.1
A few days ago, I changed the theme of Win 7 on my office computer to Win 8.1. Now, it looks much better. Through all these years, I still cannot accept the default theme of Win 7.



You can download the Win 8.1 theme for Win 7 here:
http://www.askvg.com/download-windows-8-rtm-theme-for-windows-7/

And if you want to change the start button, login screen and so forth as well, you can refer to this article:
http://www.askvg.com/transform-windows-7-into-windows-8-vnext-without-using-customization-pack/
Current language: English · 其他语言: 中文 (简体)
Wrote a new PHP library: HtmlMinerDocument
During the National Day holiday, I wrote a new PHP library by which you can retrieve DOM elements from HTML using the simple CSS selector syntax.

Now I have commited it to github, at:
https://github.com/wudicgi/html-miner-document

The usage is straightforward. For example, the code below could retrieve the title and link of all headline news from Netease News:
  1. <?php
  2. include_once 'HtmlMinerDocument.php';
  3.  
  4. // Find all elements matching the given CSS selectors
  5.  
  6. $doc = new HtmlMinerDocument(file_get_contents('http://news.163.com/'));
  7.  
  8. $news_list = $doc->findAll('div.ns-wnews h3 a');
  9.  
  10. foreach ($news_list as $news) {
  11.     echo "$news[text] ($news[href])\r\n";
  12. }
  13.  
  14. echo "\r\n";
  15. ?>

And using the code below, you can get all threads from the collection forum of amobbs:
  1. <?php
  2. include_once 'HtmlMinerDocument.php';
  3.  
  4. // Find elements by group
  5.  
  6. $doc = new HtmlMinerDocument(file_get_contents('http://www.amobbs.com/forum-9892-1.html'));
  7.  
  8. $threads = $doc
  9.     ->findFirst('table#threadlisttableid')
  10.     ->findAll('tr')
  11.     ->findAllByGroup(array(
  12.         'title'         => 'th a.s',
  13.         'author'        => 'td.by cite a',
  14.         'last_reply'    => 'td.by em span'
  15.     ));
  16.  
  17. foreach ($threads as $thread) {
  18.     echo $thread['title']['text'];
  19.     echo ' by ' . $thread['author']['text'];
  20.     echo ' (' . $thread['last_reply']['text'] . ')';
  21.     echo "\r\n";
  22. }
  23. ?>
Current language: English · 其他语言: 中文 (简体)
More entries: [1] [2] [3] [4] [5] [6] ... [21]
« Previous page · Next page »