andy0130tw
4/4/2017 - 9:14 AM

Some material found in the ancient HOJ. They might not be part in HOJ since this iteration so I put them here.

Some material found in the ancient HOJ. They might not be part in HOJ since this iteration so I put them here.

@echo off

cd C:\nginx
:main
set cnt=0
set mincnt=2

for /f %%i in ('tasklist /nh^|findstr /i /s /c:"php-cgi.exe"') do set /a cnt+=1

if %cnt% lss %mincnt% (   
	goto youwenti
)else (
	goto meiwenti
)

:youwenti
echo [%date% %time%] Add process now
RunHiddenConsole.exe  php\php-cgi.exe -b 127.0.0.1:9000 -c php\php.ini
RunHiddenConsole.exe  php\php-cgi.exe -b 127.0.0.1:9000 -c php\php.ini
RunHiddenConsole.exe  php\php-cgi.exe -b 127.0.0.1:9000 -c php\php.ini
RunHiddenConsole.exe  php\php-cgi.exe -b 127.0.0.1:9000 -c php\php.ini
RunHiddenConsole.exe  php\php-cgi.exe -b 127.0.0.1:9000 -c php\php.ini
ping 127.1 -n 8 1>nul 2>nul
goto main

:meiwenti
echo [%date% %time%] PHP is running
ping 127.1 -n 8 1>nul 2>nul

goto main
@echo off
cd C:\nginx
echo [%date% %time%] Starting nginx ...
c:/nginx/nginx.exe
@echo off
echo [%date% %time%] stopping all web services

taskkill /f /im nginx.exe 1>nul 2>nul
ping -n 2 localhost 1>nul 2>nul

taskkill /f /im php-cgi.exe 1>nul 2>nul
ping -n 2 localhost 1>nul 2>nul

echo [%date% %time%] all web services has been stopped
pause
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<cstdio>
#include<vector>
#include<cassert>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<iostream>
#include<algorithm>
#include<functional>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 10000005
using namespace std;
typedef long long LL;

char in[M];
int strpos(char *x,char *y)
{
	char *p = strstr(x, y);
	if(p) return p-x;
	return -1;
}
int main()
{
	int tt=0;
	while(gets(in))
	{
		if(strpos(in,"piwik")==-1 && strpos(in,"google")==-1 && strpos(in,"bot")==-1)
			if(strpos(in,"contest_36.html")!=-1)
				puts(in);
		
		tt++;
		if(tt%100000==0)fprintf(stderr, "read %d\n",tt);
	}
	fprintf(stderr, "%s\n", in);
	return 0;
}
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<cstdio>
#include<vector>
#include<cassert>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<iostream>
#include<algorithm>
#include<functional>
#include "windows.h"
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 
using namespace std;
typedef long long LL;
typedef pair<string,string> P;
vector<P> work;

bool isAlpha(char x)
{
	if( x>='a' && x<='z' ) return true;
	if( x>='A' && x<='Z' ) return true;
	return false;
}
bool isDigit(char x)
{
	return x>='0' && x<='9';
}
void toLower(string &x)
{
	REP(i,0,(int)x.length()-1)
		if( x[i]>='A' && x[i]<='Z' )
			x[i] += 'a' - 'A';
}
string newFileName(string x)
{
	toLower(x);
	char out[256];
	int cnt=0, num=0;
	bool allDigit = true;
	char alpha;
	string y,z;
	
	REP(i,0,(int)x.length()-1)
	{
		if(x[i] == '.')
			cnt++;
		else if(cnt==1)
			y += x[i];
		else if(cnt==2)
			z += x[i];
	}

	//- sample
	if( y.find("sample") == 0 )
	{
		y.replace(0, string("sample").length(), "0");
	}

	cnt = 0;
	REP(i,0,(int)y.length()-1)
	{
		if( isAlpha(y[i]) )
		{
			cnt++;
			alpha = y[i];
		}

		if( isDigit(y[i]) )
		{
			if(allDigit)
			{
				num = num*10 + y[i]-'0';
			}
		}
		else
		{
			allDigit = false;
		}
	}

	if(cnt == 0)
	{
		sprintf(out, "%d.%s", num, z.c_str());
	}
	else if(cnt == 1)//a~z
	{
		sprintf(out, "%d-%d.%s", num, alpha-'a'+1, z.c_str());
	}
	else if(cnt > 1)//ocen
	{
		sprintf(out, "%d-ocen.%s", num, z.c_str());
	}
	return string(out);
}
void dfs(const char *sDir)
{
	WIN32_FIND_DATA fdFile;
	HANDLE hFind = NULL;
	char sPath[2048];
	sprintf(sPath, "%s\\*.*", sDir);

	if((hFind = FindFirstFile(sPath, &fdFile)) == INVALID_HANDLE_VALUE)
	{
		printf("error: %s\n",sDir);
		return;
	}

	do
	{
		if( strcmp(fdFile.cFileName, ".") == 0 ) continue;
		if( strcmp(fdFile.cFileName, "..") == 0 ) continue;

		sprintf(sPath, "%s\\%s", sDir, fdFile.cFileName);
		if(fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
		{
			dfs(sPath);
		}
		else
		{
			string from = string(sDir) + "\\" + string(fdFile.cFileName);
			string to   = string(sDir) + "\\" + newFileName(fdFile.cFileName);
			
			work.PB( MP(from, to) );
		}
	}
	while(FindNextFile(hFind, &fdFile));
	FindClose(hFind);
}

int main()
{
	dfs("C:\\nginx\\judge\\testdata");
	FOR(i, work) MoveFile(i->F.c_str(), i->S.c_str() );
	return 0;
}
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\Windows Error Reporting]
"ConfigureArchive"=dword:00000001
"DisableArchive"=dword:00000000
"Disabled"=dword:00000000
"DisableQueue"=dword:00000000
"DontSendAdditionalData"=dword:00000000
"DontShowUI"=dword:00000001
"ForceQueue"=dword:00000000
"LoggingDisabled"=dword:00000000
"MaxArchiveCount"=dword:000001f4
"MaxQueueCount"=dword:00000032
"LastQueuePesterTime"=hex(b):69,7c,fa,f0,98,91,ce,01
"LastResponsePesterTime"=hex(b):63,81,9d,64,9a,91,ce,01

[HKEY_CURRENT_USER\Software\Microsoft\Windows\Windows Error Reporting\Consent]
"DefaultConsent"=dword:00000001

[HKEY_CURRENT_USER\Software\Microsoft\Windows\Windows Error Reporting\Hangs]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\Windows Error Reporting\Hangs\NHRTimes]

DISCLAIMER: NOT WRITTEN BY ME