Skip to content

Instantly share code, notes, and snippets.

View peta909's full-sized avatar
🏠
Working from home

Mark Lim peta909

🏠
Working from home
View GitHub Profile
#include "pch.h"
#include <iostream>
#include <string>
using namespace std;
//Parent Class
class Animal
{
public:
string name;
@peta909
peta909 / Class_OOP_inheritance_DynamicMem.cpp
Last active February 25, 2019 02:41
Demo use of OOP inheritance and use of Dynamic member to create new objects
#include "pch.h"
#include <iostream>
#include <string>
using namespace std;
//Parent Class
class Animal
{
public:
string name;
#include <iostream>
#include <string>
using namespace std;
class Fighters {
public:
string model;
int Health;
int Strength;
void add_stealth();
@peta909
peta909 / CPP_CheatSheet.cpp
Last active February 20, 2019 02:19
C++ explaination for use of inline and const keywords; and recursive functions
#include <iostream>
#include <string>
using namespace std;
enum Animals { Bear, Cat, Chicken };
//enum Birds { Eagle, Duck, Chicken }; // error! Chicken has already been declared!
enum class Fruits { Apple, Pear, Orange };
enum class Colours { Blue, White, Orange }; // no problem!
@peta909
peta909 / Python_CheatSheet.py
Last active March 29, 2019 03:54
Python code with comments
from math import *
import struct
'''
This is
Multi
Line
comment
'''
@peta909
peta909 / Select_person.py
Last active February 15, 2019 23:31
Using Python Dict and accessing key and value using indexes
food_cook_dict = {
"pasta" : "Aaron",
"bread" : "Thomas",
"rice" : "John",
"Soup" : "Kate",
"noodles" : "Liam",
}
# dictionary are unordered unlike lists till python 3.6
@peta909
peta909 / SimpleHexDump.py
Created February 15, 2019 08:36
Simple hex dump using python. using binascii and struct modules
#try to write a simple hex dump
import binascii,struct
fd = open("abcd.exe", "r")
fd_contents_str = fd.read()
fd_contents_hex = (binascii.b2a_hex(fd_contents_str)).upper()
Hex_dump = []
Byte_str = ""
for i, Half_byte in enumerate(fd_contents_hex):
@peta909
peta909 / LocateProcess.cpp
Created January 22, 2019 07:17
Function to locate PID based on given process name in string
int LocateProcess(wchar_t* proc)
{
// Need to add #include <tlhelp32.h> for PROCESS* definitions
HANDLE hProcessSnap;
HANDLE hProcess;
PROCESSENTRY32 pe32;
DWORD dwPriorityClass;
int FoundPID;
// Take a snapshot of all processes in the system.
@peta909
peta909 / LocateProcess.cpp
Created January 22, 2019 07:17
Function to locate PID based on given process name in string
int LocateProcess(wchar_t* proc)
{
// Need to add #include <tlhelp32.h> for PROCESS* definitions
HANDLE hProcessSnap;
HANDLE hProcess;
PROCESSENTRY32 pe32;
DWORD dwPriorityClass;
int FoundPID;
// Take a snapshot of all processes in the system.
@peta909
peta909 / closehandles.cpp
Created January 18, 2019 01:25
Close Handles
CloseHandle(pi.hProcess);//Handles must be explicitly closed if not parent process will hold on to it even if child process is terminated.
CloseHandle(pi.hThread);