無法升級Windows 7 SP1

主因 :"C:\Windows\System32\DriverStore\FileRepository",內容缺失導致升級系統失敗。

方法一:
  1. Imagex
  2. imagex /apply G:\sources\install.wim 4 D:\123
    PS:首先注意空格 G 為安裝光碟所在光碟機機
              4代表旗艦版 (1:hb 2:hp 3:pro 4:u)
              D:\123 表示複製到D槽123資料夾中 保證此資料空間在7G以上
  3. FileRepository 複製出來,換給系統下的FileRepository

方法二:
  1. Win7光碟
  2. 找到install.wim
  3. 使用7zip解壓縮DriverStore
  4. FileRepository 複製出來,換給系統下的FileRepository

無法升級Windows 7 SP1之解決方案.....-Hermes的平凡之子-無名小站網誌
打開WIM文件並提取系統文件最簡單最有效的方法

Quick Tetris

因為懶得動滑鼠按按鈕,故寫AHK用鍵盤按
目前功能如下:
  • W鍵,自動置中視窗
  • S鍵,Start (Sprint、2P)
  • A鍵,Play Again (Sprint、2P)
  • R鍵,Restart (Sprint)

#IfWinActive ahk_class Chrome_WidgetWin_1
$W::ResizeWin(1075,1052)

;Sprint Restart
#IfWinActive ahk_class Chrome_WidgetWin_1, Tetris Sprint
$R::
Send {Esc}
ControlClick, x710 y570
Return

;Sprint Play Again
#IfWinActive ahk_class Chrome_WidgetWin_1, Tetris Sprint
$A::ControlClick, x258 y558

;Sprint Start
#IfWinActive ahk_class Chrome_WidgetWin_1, Tetris Sprint
$S::ControlClick, x722 y503

;2P Start
#IfWinActive ahk_class Chrome_WidgetWin_1, Battle 2P
$S::ControlClick, x332 y345

;2P Play Again
#IfWinActive ahk_class Chrome_WidgetWin_1, Battle 2P
$A::ControlClick, x258 y560

ResizeWin(Width = 0,Height = 0)
{
    WinGetPos,X,Y,W,H,A
    If %Width% = 0
        Width := W
    If %Height% = 0
        Height := H
   
    X:=(A_ScreenWidth - Width) / 2
    Y:=0
    WinMove,A,,%X%,%Y%,%Width%,%Height%
}

StringSplitOptions.RemoveEmptyEntries

string str = "aaa,bbb,ccc,,ddd";
string[] strAry = str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < strAry.Length; i++)
    Console.WriteLine(strAry[i]);

String.Split 方法 (Char[], StringSplitOptions) (System)
用 split() 分割字串 : 文章 : 格子樑 | 艾倫 郭 | AllenKuo.com

Graphviz 中文字型

  1. 開啟Graphviz\etc\fonts\fonts.conf
  2. 找到
    <dir>#FONTDIR#</dir>
  3. 更改
    <dir>C:\WINDOWS\Fonts</dir>

  4. digraph g {
         node[fontname = "Microsoft JhengHei"];
         "中文" -> "英文";
    }

在 Windows 上設定 Graphviz 中文字型 - electronic_blue

Calling a Batch in the work directory

Runtime.getRuntime().exec(System.getProperty("user.dir") + "\\BATCH.bat");
Calling a Batch file from Java using the exec command.

[FireGestures] Paste and Go

const IN_NEW_TAB = true;
const IN_BACKGROUND = false;

var str = readFromClipboard();
var s='http://www.google.com.tw/search?q=@search&oe=utf-8&hl=zh-TW';
if (!str) return;
if (!/^(\s*)http(s?):\/\//.test(str)) str=s.replace('@search',encodeURIComponent(str));
if (IN_NEW_TAB)
gBrowser.loadOneTab(str, null, null, null, IN_BACKGROUND, false);
else
gBrowser.loadURI(str);

FireGestures :: Get Scripts -> Open URL from Clipboard
求高手將Paste and go ,Paste and search這兩個腳本合二為一 - 閱讀主題 :: Mozilla Firefox中文社區

Command-line reference A-Z

Command-line reference A-Z

WebClient download HTML source code

using System;
using System.IO;
using System.Net;
using System.Text;

string source;
using (WebClient wc=new WebClient())
{
    //方法1:使用串流讀取
    StreamReader sr=new StreamReader(wc.OpenRead("http://tw.yahoo.com"),Encoding.UTF8);
    source=sr.ReadToEnd();
    sr.Close();
    sr.Dispose();
           
    //方法2:使用webclient.DownloadString()
    //source=wc.DownloadString("http://tw.yahoo.com");
}
Console.WriteLine(source);

C# Array.ForEach Method

string[] testAry = { "Apple","bbb", "Ben", "aaa" };
Array.Sort(testAry);
Array.ForEach(testAry, delegate(string str) { Console.WriteLine(str); });

Common Expression

Table Expression = <table[^>]*>(.*?)</table>
Header Expression = <th[^>]*>(.*?)</th>
Row Expression = <tr[^>]*>(.*?)</tr>
Column Expression  = <td[^>]*>(.*?)</td>
Textarea Expression = <textarea[^>]*>(.*?)</textarea>

HashCode x Random

Random Counter = new Random(Guid.NewGuid().GetHashCode());
[C#]不同的Random物件給予不同的亂數種子 - Level Up- 點部落

UTF8Encoding And BOM

//Write with BOM
File.WriteAllText(path, content,new UTF8Encoding(true));

//Write with no BOM
File.WriteAllText(path, content,new UTF8Encoding(false));

UTF8Encoding 建構函式 (Boolean) (System.Text)
KB-UTF8Encoding And BOM - 黑暗執行緒

M01 Category Fix

// ==UserScript==
// @name    M01 Category Fix
// @description    修改M01 category.php的快捷連結
// @run-at document-end
// @author    NKid
// @version    2011-07-10
// @include    http://www.mobile01.com/category.php?id=*
// ==/UserScript==
var htmlCode='<ul class="lv02" style="visibility: hidden; display: none;">@lis</ul>';
var s=document.getElementById('shortcut-content').innerHTML;
s=s.replace(/\s\|\s/g,'');
s=s.replace(/(<a\s.*?href=.*?>)(.*?)(<\/a>)/g,'<li>$1$2$3</li>');
htmlCode=htmlCode.replace('@lis',s);
document.querySelector("#top-menu a[style]").parentNode.innerHTML+=htmlCode;
unsafeWindow.$(".sf-menu").superfish({
        delay: 500,
        pathClass: 'current',
        dropShadows: false,
        speed: 100,
        autoArrows: false
    });

two select elements exchange single option

W3C ver.
var s1=document.getElementById('s1');
var s2=document.getElementById('s2');

function AddDelOption(a,b) {
  var txt=a.options[a.selectedIndex].value;
  b.options.add(new Option(txt,txt));
  a.remove(a.selectedIndex);
}
document.getElementById('addBtn').addEventListener('click',function(){AddDelOption(s1,s2);},false);
document.getElementById('delBtn').addEventListener('click',function(){AddDelOption(s2,s1);},false);

jQuery ver. var s1=document.getElementById('s1');
var s2=document.getElementById('s2');

function AddDelOption(a,b) {
  var txt=$(a).val();
  $(b).append("<option value=\"" + txt + "\">" + txt + "</option>");
  a.remove(a.selectedIndex);
}

$('#addBtn').click(function(){AddDelOption(s1,s2);});
$('#delBtn').click(function(){AddDelOption(s2,s1);});

Creating URL shortcut

private void urlShortcutToDesktop(string linkName, string linkUrl)
{
    string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

    using (StreamWriter writer = new StreamWriter(deskDir + "\\" + linkName + ".url"))
    {
        writer.WriteLine("[InternetShortcut]");
        writer.WriteLine("URL=" + linkUrl);
        writer.Flush();
    }
}

C# - Creating URL shortcut to desktop

How to pass arguments to addEventListener listener function?

function test(a,b) {
    return a+b;
}
someObj.addEventListener("click",function() { test(5,20); },false);

javascript - How to pass arguments to addEventListener listener function? - Stack Overflow

ASP.NET 2.0 AJAX Extensions run in IIS7

  1. ASPAJAXExtSetup
  2. 取出System.Web.Extensions.Design.dll、System.Web.Extensions.dll
  3. 放入網站Bin資料夾

Redirect to static HTML (Discuz!)

適用於Discuz!論壇,從動態網頁轉至靜態網頁,AutoPagerize才有作用
javascript:
(function(){
  var tid=/tid=(\d*)/.exec(location.search)[1];
  var page=(/page=(\d*)/.test(location.search)[1])?/page=(\d*)/.exec(location.search)[1]:1;
  location.assign('thread-'+tid+'-'+page+'-1.html');
}
)()