This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <vector> | |
#include <unordered_map> | |
using namespace std; | |
/* | |
* @ A simple parser can recognize shell command options in format | |
* "--<option> <args>" or "--<option>=<args>". | |
* @ Note. It tolerate spaces in args. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <winhttp.h> | |
#include <array> | |
#include <iostream> | |
#include <string> | |
#pragma comment(lib, "Winhttp.lib") | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Client should release HashData with HeapFree() | |
// e.g. HeapFree(GetProcessHeap(), 0, HashData); | |
// Ref. https://learn.microsoft.com/en-us/windows/win32/seccng/creating-a-hash-with-cng | |
NTSTATUS HashCreate ( | |
LPCWSTR HashAlg, | |
PBYTE RawData, | |
DWORD RawDataSize, | |
PBYTE *HashData, | |
DWORD *HashDataSize | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Client should release FileBuffer with HeapFree() | |
// e.g. HeapFree(GetProcessHeap(), 0, buffer); | |
VOID FileRead( | |
char *Filename, | |
PBYTE *FileBuffer, | |
DWORD *FileSize | |
) | |
{ | |
HANDLE hFile; | |
PBYTE buffer = NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
for i in sys.argv: | |
print i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
# https://www.udacity.com/course/cs212 | |
import re, itertools, string | |
def fill_in(formula): | |
letters = ''.join(set([s for s in formula if s in string.uppercase])) | |
for i in itertools.permutations('0123456789', len(letters)): | |
trans = string.maketrans(letters, ''.join(i)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "lua.h" | |
#include "lauxlib.h" | |
int l_bar(lua_State *L) | |
{ | |
const char *str = lua_tostring(L, -1); | |
int length; | |
while (1) { | |
char c = str[length]; | |
if (c == '\0') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
typedef struct RAW_SMBIOS_DATA | |
{ | |
BYTE Used20CallingMethod; | |
BYTE MajorVersion; | |
BYTE MinorVersion; | |
BYTE Revision; | |
DWORD Length; | |
BYTE SMBIOSTableData[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _WIN32_DCOM | |
#include <iostream> | |
using namespace std; | |
#include <comdef.h> | |
#include <Wbemidl.h> | |
# pragma comment(lib, "wbemuuid.lib") | |
int main(int argc, char **argv) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#define STRINGIZE(something) STRINGIZE_HELPER(something) | |
#define STRINGIZE_HELPER(something) #something | |
using namespace std; | |
int Test02() | |
{ | |
int foo = 999; |
NewerOlder