Skip to content

Instantly share code, notes, and snippets.

View johnhmj's full-sized avatar
😃
online

John "DumbSheep" Hsieh johnhmj

😃
online
View GitHub Profile
@johnhmj
johnhmj / W32Tester.cpp
Last active August 29, 2015 14:01
Socket, client socket, HTTP request (class)
#include "W32Tester.h"
//
CSocketClient::CSocketClient()
{
memset((void*)&this->m_wsadata, 0, sizeof(struct WSAData));
memset((void*)&this->m_saddr, 0, sizeof(struct sockaddr_in));
this->m_s = INVALID_SOCKET;
this->m_AFamily = AF_INET;
this->m_Port = 0;
this->m_hostent = NULL;
@johnhmj
johnhmj / main.cpp
Last active August 29, 2015 14:00
Socket, client socket, HTTP request
#pragma comment(lib, "Ws2_32.lib")
#include <iostream>
#include <WinSock2.h>
#define BUF_SIZE 4096
//
int main(int argc, char* argv[])
{
struct hostent *d;
struct sockaddr_in a;
SOCKET s;
COPY START 1000
FIRST STL RETADR
CLOOP JSUB RDREC
LDA LENGTH
COMP ZERO
JEQ ENDFIL
JSUB WRREC
J CLOOP
ENDFIL LDA EOF
STA BUFFER
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
//
// 不使用 stdafx 標頭檔
// #include "stdafx.h"
//
#include <iostream>
using std::cout;
using std::endl;
//
// 類別:這只是節點而已,(鏈結)串列的基本元素
class list
@johnhmj
johnhmj / W32Dll.cpp
Last active December 18, 2015 05:09
A simple DLL programing. "main.cpp" should be with Project "W32Dll (W32Dll.h & W32Dll.cpp)".
#include "W32Dll.h"
//
_dllexport void Pause(void)
{
using std::cin;
using std::cout;
using std::endl;
cout << "press any key to continue...";
cin.clear();
cin.ignore(_BufSize, '\n');
#include "W32Tester.h"
//
void W32Tester::Pause(void)
{
using std::cin;
using std::cout;
using std::endl;
cout << "press any key to continue...";
cin.clear();
cin.ignore(_BufSize, '\n');
@johnhmj
johnhmj / FileVersion.bat
Created May 19, 2013 15:11
Get version of exe/dll file
SET Folder=%SystemRoot%\system32
CSCRIPT //NOLOGO VersionInfo.vbs "%Folder%\cmd.exe"| FINDSTR "6.1" > nul
IF %ERRORLEVEL%==0 ECHO cmd.exe at 7
IF NOT %ERRORLEVEL%==0 ECHO cmd.exe NOT at 7
PAUSE
@johnhmj
johnhmj / W32String.cpp
Last active December 17, 2015 11:59
String, MultiByteToWideChar & WideCharToMultiByte
#include "W32String.h"
//
W32String::W32String()
{
this->m_string = NULL;
this->m_wstring = NULL;
this->m_temp = NULL;
this->m_size = 0;
}
W32String::W32String(const char* s)
@johnhmj
johnhmj / Win32Tester.cpp
Created May 15, 2013 16:34
inheritance & assignment operator
#include "Win32Tester.h"
shape::shape()
{
this->m_perimeter = 0.0l;
}
shape::shape(const double perimeter)
{
this->m_perimeter = perimeter;
}
shape::~shape()