亂貼小站公告欄

Easy_run_class v1.0.3 歡迎下載 (2011.10.04)

 
主要對象:JAVA 程式語言的初學者 (Windows XP / Vista / 7 適用)。

 
主要功能:
1.自動幫忙設定 JDK 的相關環境。
2.為副檔名為 .java 的檔案提供右鍵選單可直接【編譯並執行】。
3.為副檔名為 .class 的檔案提供雙擊即可快速執行的功能。

 
歡迎大家多多推廣。若有任何使用上的問題均可在此站留言。

轉載自:Google API 1.7.7

<?php
        function getCurrentUrl() 
        {
          global $_SERVER;

          /**
           * Filter php_self to avoid a security vulnerability.
           */
          $php_request_uri = htmlentities(substr($_SERVER['REQUEST_URI'], 0, strcspn($_SERVER['REQUEST_URI'], "\n\r")), ENT_QUOTES);

          if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
                $protocol = 'https://';
          } else {
                $protocol = 'http://';
          }
          $host = $_SERVER['HTTP_HOST'];
          if ($_SERVER['SERVER_PORT'] != '' &&
                 (($protocol == 'http://' && $_SERVER['SERVER_PORT'] != '80') ||
                 ($protocol == 'https://' && $_SERVER['SERVER_PORT'] != '443'))) {
                $port = ':' . $_SERVER['SERVER_PORT'];
          } else {
                $port = '';
          }
          return $protocol . $host . $port . $php_request_uri;
        }
?>

Posted by 和風信使 at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()

// WA
// BY taichunmin
// NCPC 2011 pb
#include<iostream>
#include<fstream>
#include<sstream>
using namespace std;
int va[1000000];
int va_c;
int main()
{
        //freopen("pb.in","r",stdin);
        int ta;
        cin>>ta;
        string sa;
        while(ta--)
        {
                int ia,ib;
                cin>>ia;
                cin.get();
                getline(fin,sa);
                va_c=0;
                istringstream ssin(sa);
                while(ssin>>ib)
                {
                        bool ba=true;
                        for(int k=0;k<va_c;k++)
                                if(va[k]>=ib)
                                {
                                        va[k]=ib;
                                        ba=false;
                                        break;
                                }
                        if(ba)va[va_c++]=ib;
                }
                cout<<va_c<<endl;
        }
        return 0;
}

 

// WA
// BY taichunmin
// NCPC 2011 pd
#include<iostream>
#include<sstream>
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int ia,ib;
struct ta_t
{
        string n;
        int v;
}attr[10];
int fa(string sa)
{
        bool is_num=true;
        for(int i=0;i<sa.size() && is_num;i++)
                if(!('0'<=sa[i] && sa[i]<='9')is_num=false;
        if(is_num)
        {
                istringstream ssin(sa);
                int temp;
                ssin>>temp;
                return temp;
        }
        else
        {
                for(int i=0;i<ia;i++)
                        if(attr[i].n==sa)return attr[i].v;
        }
        return 2147483647;
}
int main()
{
        //freopen("pd.in","r",stdin);
        int ta;
        cin>>ta;
        while(ta--)
        {
                cin>>ia>>ib;
                string sa,sname,sx,sy;
                for(int i=0;i<ia;i++)
                        cin>>attr[i].n>>attr[i].v;
                cin.get();
                bool ba=true;
                for(int i=0;i<ib;i++)
                {
                        getline(cin,sa);
                        if(!ba)continue;
                        istringstream ssin(sa);
                        ssin>>sname;
                        bool bb=true;
                        while(getline(ssin,sa,'('))
                        {
                                ssin>>sx;
                                getline(ssin,sy,')');
                                sy.erase(0,3);
                                //cout<<"sy = "<<sy<<endl;
                                if(fa(sx)<=fa(sy))
                                {
                                        bb=false;
                                        break;
                                }
                        }
                        if(bb)
                        {
                                ba=false;
                                cout<<sname<<endl;
                        }
                }
        }
}

 

// AC
// BY morris1028
// NCPC 2011 ph
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int A[100000],HASH[1000000],size;
struct Node{
        int v,s;
        int next;
}Node[200000];
int insHash(int v,int index)
{
        int m = v%1000000;
        if(HASH[m]==0) {
                size++;
                HASH[m]=size;
                Node[size].v=v, Node[size].s=index;
                Node[size].next=0;
                return -1;
        }
        int now=HSAH[m],pre=0;
        while(now)
        {
                if(Node[now].v>v || (Node[now].v==v && Node[now].s>index))
                        break;
                else pre=now, now=Node[now].next;
        }
        size++;
        if(pre == 0) HASH[m]=size;
        else Node[pre].next=size;
        Node[size].v=v,Node[size].s=index;
        Node[size].next=now;
        return -1;
}
int find(int v,int index)
{
        int m=v%1000000;
        int now=HASH[m], pre=0;
        while(now)
        {
                if(Node[now].v==v && Node[now].s>index)
                        return Node[now].s;
                else pre=now, now=Node[now].next;
        }
        return -1;
}
int Print(){
        int now, pre, i=0;
        for(int i=0;i<10;i++)
        {
                now=HASH[i];
                while(now)
                {
                        printf("(%d,%d)->",Node[now].v,Node[now].s);
                        pre=now, now=Node[now].next;
                }
                puts("===");
        }
        return 0;
}
int main(){
        //freopen("ph.in","r",stdin);
        int n,k,i;
        while(scanf("%d", &n)==1 && n) {
                for(i=0;i<n;i++)
                        scanf("%d",&A[i];
                memset(HASH, 0, sizeof(HASH));
                scanf("%d", &k);
                int sum=0,tmp;
                size=1;
                for(i=0;i<n;i++)
                {
                        A[i]%=k;
                        sum+=A[i];
                        sum%=k;
                        if(sum<0) sum+=k;
                        insHash(sum,i);
                }
                /* Print();*/
                sum=0;
                int flag=0;
                tmp=find(0,-1);
                if(tmp!=-1)
                {
                        printf("%d %d\n",1,tmp+1);
                        flag=1;
                }
                for(i=0;i<n;i++){
                        A[i]%=k;
                        sum+=A[i];
                        sum%=k;
                        if(sum<0) sum+=k;
                        tmp=find(sum,i);
                        /* printf("%d\n",tmp);*/
                        if(tmp!=-1 && flag==0)
                        {
                                printf("%d %d\n",i+2,tmp+1);
                                flag=1;
                                break;
                        }
                }
                if(flag==0)
                        printf("no solutions.\n");
        }
        return 0;
}
/*
7
2 5 1 -4 5 9 3
10
11 -3 1 13 -5 6 1 -8 -4 5
10
*/

 

// AC
// BY morris1028
// NCPC 2011 pk
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#define oo 2147483647
int map[1000][1000],Mt[1000];
int gcd(int x,int y)
{
        int t;
        while(y)
                t=x, x=y, y=t%y;
        return x;
}
int Used[1000], Time[1000], Ans;
int DFS(int T,int now,int start) {
        int last= oo,i,tmp,flag=0,ttry=0;
        Time[now] = T;
        /*printf("%d %d\n",now,T);*/
        for(i=0;i<Mt[now];i++){
                if(Used[map[now][i]]==0) {
                        used[map[now][i]]=1;
                        tmp=DFS(T+1, map[now][i],0);
                        if(tmp>=T) flag=1;
                        last=tmp<last?tmp:last;
                        ttry++;
                } else {
                        tmp=Time[map[now][i]];
                        last=tmp<last?tmp:last;
                }
        }
        if(start==1) {
                if(ttry>1)
                        Ans++;
        } else {
                Ans += flag;
        }
        /*printf("key : %d %d\nn", now,flag);*/
        return last;
}
int main() {
        //freopen("pk.in","r",stdin);
        int T,i,j,A[1001],n;
        scanf("%d",&T);
        while(T--)
        {
                scanf("%d",&n);
                for(i=0;i<n;i++)
                        scanf("%d",&A[i]);
                memset(map, 0, sizeof(map));
                memset(Mt, 0, sizeof(Mt));
                memset(Used, 0, sizeof(Used));
                memset(Time, 0, sizeof(Time));
                Ans=0;
                for(i=0;i<n;i++) {
                        for(j=i+1;j<n;j++) {
                                int tmp=gcd(A[i],A[j]);
                                if(tmp!=1) {
                                        map[i][Mt[i]++]=j;
                                        map[j][Mt[j]++]=i;
                                }
                        }
                }
                for(i=0;i<n;i++)
                        if(Used[i]==0) {
                                Used[i] =1,Time[i] = 1;
                                DFS(1,i,1);
                        }
                printf("%d\n",Ans);
        }
        return 0;
}

Posted by 和風信使 at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()

資料來源:http://php.net/manual/en/function.preg-match.php

<?php
$pattern = '`^((?P<protocol>[^:/?#]+):)?(//(?P<host>[^/?#]*))?(?P<path>[^?#]*)(\?(?P<query>[^#]*))?(#(?P<label>.*))?`i';
$subject = 'http://example.com/defg/abcd/index.php?m=1&b=2#taichunmin';
preg_match($pattern,$subject,$match);
//可取用的資料如下
echo 'protocol = '  .$match['protocol']. '<br />';
echo 'host = '      .$match['host'    ]. '<br />';
echo 'path = '      .$match['path'    ]. '<br />';
echo 'query = '     .$match['query'   ]. '<br />';
echo 'label = '     .$match['label'   ]. '<br />';
?>

, ,

Posted by 和風信使 at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()

引用自:http://blog.miniasp.com/post/2008/11/17/Using-Netsh-Command-Line-Utility-to-switch-TCP-IP-settings.aspx


有時後帶著筆記型電腦(Notebook)到處跑時,時常都要切換網路卡的 TCP/IP 設定,每次都透過介面切換也實在很煩。例如說上週人在機房安裝主機時,因為網路切了 vLan 導致 Notebook 要搬來搬去的,每次都要改 IP 很麻煩,還好我寫了個批次檔幫我快速切換 IP 位址,果然省時、省力、又方便。

首先,我先介紹如何設定網路介面到 DHCP 模式

1. 先查到你的網路卡介面名稱,如下圖示,你的名稱就是【區域連線】四個字。

2. 再利用記事本(Notepad)開啟一份新文件,並且命名為 SwitchToDHCP.bat

3. 輸入以下指令碼(由於 Windows XP 與 Windows Vista 的指令有些差異,因此分開列表)

  • Windows 2000 / XP / 2003

netsh interface ip set address "區域連線" source=dhcp
netsh interface ip set dns     "區域連線" source=dhcp

  • Windows Vista / 2008

netsh interface ip set address   "區域連線" source=dhcp
netsh interface ip set dnsserver "區域連線" source=dhcp

再來,介紹如何設定網路介面到靜態 IP 模式

1. 先查到你的網路卡介面名稱,如上圖示。

2. 再利用記事本(Notepad)開啟一份新文件,並且命名為 SwitchTo公司內部IP.bat

3. 輸入以下指令碼(由於 Windows XP 與 Windows Vista 的指令有些差異,因此分開列表)

  • Windows 2000 / XP / 2003

netsh interface ip set address "區域連線" static 10.10.1.168 255.255.255.0 10.10.1.254 1
netsh interface ip set dns     "區域連線" static 10.10.1.1 primary

  • Windows Vista / 2008

netsh interface ip set address   "區域連線" static 10.10.1.168 255.255.255.0 10.10.1.254 1
netsh interface ip set dnsserver "區域連線" static 10.10.1.254 primary

Posted by 和風信使 at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()

%SystemRoot%\system32;

%SystemRoot%;

%SystemRoot%\System32\Wbem;

%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\


Posted by 和風信使 at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()

需先安裝外掛模組 NppExec

第一次使用先按 F6

把下面的程式碼貼上

並自行更改 JSP_www 和 JSP_url

以後就只需要按 Ctrl + F6 即可直接看到結果

 

NPP_CONSOLE ?
npp_save
set JSP_www = C:\Tomcat 7.0\webapps\ROOT\
set JSP_url = http://localhost:8080/
cmd.exe /c copy /Y "$(FULL_CURRENT_PATH)" "$(JSP_www)$(FILE_NAME)"
cmd.exe /c start "" "$(JSP_url)$(FILE_NAME)"


, ,

Posted by 和風信使 at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()

下載網址:http://dl.dropbox.com/u/12113131/Install_Easy_run_class.msi

2011/10/05 v1.0.3更新:

 

  1. 將 .java 改為編譯並執行。
  2. 修改掉自動新增環境變數的 BUG。

 

2011/10/05 v1.0.3已知 BUG:

 

  1. 安裝程式在安裝前不會刪除舊版資料,使用者須先手動刪除,以免檔案仍為舊版。

 

 

其實,這個版本主要只是修bug而已...

感謝 SyneArt 幫忙,終於成功找到無法穩定找出 JDK 安裝路徑的問題所在。

另外,這個程式還額外使用了 Rapid Environment Editor 來做環境變數新增的工具。

目前這個程式只有在我自己的電腦試過...

希望徵求自願者阿XDD

不然我就只好對學弟下手了...

 

這個程式是為了 JAVA 的初學者寫的

希望能有很多人給我【我做得到的】意見阿~

好累喔~睡覺去


, , , , ,

Posted by 和風信使 at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()

使用 Dev-C++所編譯出來的程式,都是32位元的

在x64的系統中,有時候會導致讀取不到想要讀取的資料

舉例:

若安裝 64 位元的 JDK,則在 Dev-C++ 讀取不到 Java 的安裝路徑

REG QUERY "hklm\SOFTWARE\JavaSoft\Java Development Kit" /v CurrentVersion  (找不到)

這時,請改用以下敘述

%windir%\Sysnative\REG QUERY "hklm\SOFTWARE\JavaSoft\Java Development Kit" /v CurrentVersion

因為在x64系統中執行32位元的程式,會自動進入 WOW64 的模式,位於 %windir%\System32 的 reg.exe (64bit) 會被重定向到 %windir%\SysWOW64 的 reg.exe (32bit)

若要在32位元的程式中強制讀取位於 %windir%\System32 的 reg.exe (64bit),則須改用 %windir%\Sysnative\


參考資料:

http://blog.csdn.net/andylin02/article/details/2679792 - 重定向
http://blog.xuite.net/y0933717246/IT/39759341 - 補充說明 SysWoW64 目錄
http://www.cnblogs.com/hsapphire/archive/2011/03/09/1978519.html - 如何通过使用 64 位版本 Windows 查看系统注册表 WOW6432Node
http://www.tipandtrick.net/2008/how-to-suppress-and-bypass-system32-file-system-redirect-to-syswow64-folder-with-sysnative/zh_TW/ - 如何制止和繞道system32文件系統重定向到SysWow64文件夾與sysnative
http://www.tipandtrick.net/2008/how-to-suppress-and-bypass-system32-file-system-redirect-to-syswow64-folder-with-sysnative/ - How to Suppress and Bypass System32 File System Redirect to SysWOW64 Folder with Sysnative

  • 什么是重定向

无论是Windows XP Professional X64 Edition、Windows Server 2003 X64 Edition还是Windows Vista X64 Edition(以下把均统称为X64系统),都引入了一项技术:文件和注册表的重定向。

之所以有这个技术,是为了将32位程序和64位程序分离开。这种在64位平台上运行32位程序的模拟器被称为WOW64。WOW64是"Windows 32 on Windows 64"的简称,它在系统层中另提供了一层,以支持老式的32位程序。

在X64系统里面,一些特殊的目录和特殊的注册表键被分为2个独立的部分。对于文件系统来说,%systemroot%/system32 目录被保留给64位文件使用,而32位文件会被重定向到%systemroot%/SysWOW64目录。换句话说,所有的32位程序一般情况下只会出现在%systemroot%/SysWOW64目录里面。任何32位程序试图访问%systemroot%/system32 目录的企图都会被重定向到%systemroot%/SysWOW64目录。这个是一个默认的行为,除非程序的线程明确的指名需要关闭这种重定向机制。

对于注册表来说,也有类似的内容。WOW64子系统也提供了对注册表访问的重定向。如果是32位程序,对注册表的操作不论是读还是写, WOW64都将会截取对HKLM/Software访问,并重定向到HKLM/Software/Wow6432Node(即32位应用程序的注册信息被写在HKLM/Software/Wow6432Node中,而不是预期的HKLM/Software中);如果是64位程序,就直接到 HKLM/Software。

  • 需要重定向的注册表项

注册表重定向,其实质就是维护两套不同的注册表键,一套用于64位,一套用于32位。受影响的键不只是上面提及的HKLM/Software,还包括:

Posted by 和風信使 at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()

終於找到在 windows 7 中替某個程式加上【以系統管理員執行此程式】的方法了!!

這樣的話,我在 Easy_run_class 中新增 PATH 應該就不會遇到什麼問題了

要新增資料到登錄檔裡面

安裝程式都可以代勞~

接下來的比較大的問題...可能就是要怎麼辦找到 JDK 的路徑了吧 (在沒有安裝在預設路徑的情況下)


本文章轉載自:http://www.sevenforums.com/tutorials/316-compatibility-mode.html

1. Open the Start Menu, then type regedit in the search box and press Enter.

2. If prompted by UAC, then click on Yes.

3. In regedit, navigate to the location below. (see screenshot below)

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

Compatibility Mode-reg1.jpg

4. To Run a Program in Compatibility Mode

A) In the right pane of Layers, right click on a empty area and click on New, then onString Value. (see screenshot below)

Compatibility Mode-reg2.jpg

B) Type in the full path of the program's exe file and press Enter, then right click on the full path and click on Modify. (see screenshot below)

Compatibility Mode-reg3.jpg

C) Type in a single or combination of Data values (see tables below) for how you want to run the program as, and click on OK. (see screenshot below)

NOTE: If you use more than one Settings, then you must add them in the order they are in the table below.

[Compatibility Mode (only one)] + space + [Settings (one or more with a space inbetween)] + space + [Privilege Level]

Posted by 和風信使 at 痞客邦 PIXNET 留言(1) 引用(0) 人氣()

Rapid Environment Editor

是一款很方便更改 windows 環境變數的工具程式

(官方網站:http://www.rapidee.com )

當然 這款程式讓我看中的不是這一點

它讓我看中的是

他可以從命令列下指令更改環境變數!!

(說明文件:http://www.rapidee.com/en/command_line )

這絕對可以幫助我把 Easy_run_class 寫得更方便、更好用!!

因為我之前想讓程式自動幫忙把 JDK 的路徑放進 PATH

但是卻一直因為 windows 7 的權限問題 和 難用的 reg.exe 程式 搞得非常鬱悶

沒想到今天這個程式能有這麼方便的功能

只不過...還是有 windows 7 權限的問題 QAQ

要把程式調成【以系統管理員的身分執行此程式】或是【以相容模式執行這個程式】

這個程式才有辦法在 windows 7 中順利執行...

有沒有什麼辦法呢??

( Easy_run_class 還有遇到一個問題

  就是如果 JDK 沒有安裝在預設路徑

  那該怎麼去找到 JDK 安裝在何處?

  希望有高手解惑啊!!!                        )


Posted by 和風信使 at 痞客邦 PIXNET 留言(0) 引用(0) 人氣()