Skip to content

Instantly share code, notes, and snippets.

View juntalis's full-sized avatar

Charles Grunwald juntalis

View GitHub Profile
@hakril
hakril / syswow64.py
Last active April 11, 2024 05:28
syswow64.py with assert
import struct
import ctypes
from ctypes import byref
import codecs
import functools
import windows
import windows.native_exec.simple_x86 as x86
import windows.native_exec.simple_x64 as x64
from .generated_def.winstructs import *
@JokerQyou
JokerQyou / win_subprocess.py
Last active April 19, 2018 02:18 — forked from vaab/win_subprocess.py
Fixing python 2.7 windows unicode issue with ``subprocess.Popen``.
# coding: utf-8
# This patched `Popen` class
# adds support for Unicode commandline on Windows platform.
# issue: https://bugs.python.org/issue19264
import os
import ctypes
import subprocess
import _subprocess
from ctypes import (
@sunxiaoguang
sunxiaoguang / benchmark.c
Created August 14, 2017 07:48
hgetall optimization sample data generator and benchmark code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hiredis.h>
#include <sys/time.h>
long long elapsed(struct timeval *start, struct timeval *end) {
return (end->tv_sec * 1000000l + end->tv_usec) - (start->tv_sec * 1000000l + start->tv_usec);
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hiredis.h>
int main(int argc, char **argv) {
redisContext *c;
redisReply *reply;
const char *hostname = (argc > 1) ? argv[1] : "127.0.0.1";
/*
* A simple Windows 32-bit DLL injector
*
* Note that this does not attempt to be "stealthy". If you are
* using this to inject hacks into games, prepare to be banned.
*
* To start a process and inject a DLL before main() is called:
* CreateProcessWithDll("path/to/program.exe", "--program-args", "path/to/library.dll");
*
* To inject a DLL into an already-running process:
@ruby0x1
ruby0x1 / hash_fnv1a.h
Last active December 30, 2023 00:40
FNV1a c++11 constexpr compile time hash functions, 32 and 64 bit
#pragma once
#include <stdint.h>
//fnv1a 32 and 64 bit hash functions
// key is the data to hash, len is the size of the data (or how much of it to hash against)
// code license: public domain or equivalent
// post: https://notes.underscorediscovery.com/constexpr-fnv1a/
inline const uint32_t hash_32_fnv1a(const void* key, const uint32_t len) {
@application2000
application2000 / how-to-install-latest-gcc-on-ubuntu-lts.txt
Last active February 21, 2024 03:02
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04)
These commands are based on a askubuntu answer http://askubuntu.com/a/581497
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below.
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING.
ABSOLUTELY NO WARRANTY.
If you are still reading let's carry on with the code.
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
@kastnerkyle
kastnerkyle / shared_memory_example.py
Last active April 20, 2024 22:14
Shared memory example
# Example from J.F. Sebastien on SO
# http://stackoverflow.com/questions/7894791/use-numpy-array-in-shared-memory-for-multiprocessing/7908612#7908612
import ctypes
import logging
import multiprocessing as mp
from contextlib import closing
import numpy as np
@graphitemaster
graphitemaster / WORKING_AROUND_OFFSETOF_LIMITATIONS.MD
Last active February 29, 2024 08:49
Working around offsetof limitations in C++

Working around offsetof limitations in C++:

There is sometimes a situation in which one needs to get the relative offset of a structure field, common examples of this include serialization frameworks which aid to serialize objects, vertex attributes for rendering (D3D, GL.), etc.

The most common technique for getting this information is through the offsetof macro defined in stddef.h. Unfortunately using the macro in C++ comes with a new set of restrictions that prevent some (subjectively valid) uses of it.

@moontan
moontan / ANSI sequences for use in shell scripts
Last active August 1, 2020 08:30
bash script ANSI sequences
#!/bin/bash
# use the following variables as in
# echo -e "[$TYPE…][$FG…][$BG…]formatted text[$TYPERSALL]"
# to set colours and other formatting
# 8<-------------------- ANSI-Sequences ------------------------
# (remove this paragraph if you prefer things plain and simple)
# --------------------------------------------------------------
# Type:
TYPERSALL="\x1B[0m" # reset all properties
TYPEBOLD="\x1B[1m" # bold type on