Skip to content

Instantly share code, notes, and snippets.

View full-sized avatar

Tamir Bahar tmr232

View GitHub Profile
@tmr232
tmr232 / README.md
Created April 24, 2023 13:55
C++ Scoped Enums implementation
View README.md
@tmr232
tmr232 / README.md
Created January 4, 2023 21:33
Removing that pesky GB keyboard!
View README.md

To remove the GB language pack:

Get-AppxPackage -AllUsers Microsoft.LanguageExperiencePacken-GB | Remove-AppxPackage

Then in the registry, remove the GB entry from Computer\HKEY_CURRENT_USER\Keyboard Layout\Preload. According to MSDN docs the value should be 0x809. If it is not the last value, make sure to rename the others!

@tmr232
tmr232 / order_of_eval.java
Created November 7, 2022 14:38
Differences in order of evaluation between Java and Python
View order_of_eval.java
// This is actually a JShell script, because I am lazy
int c = 0;
int nxt() {
c += 1;
return c;
}
int l[] = {1, 2, 3, 4};
@tmr232
tmr232 / README.md
Created October 4, 2022 17:14
Adding an option to the context menu of a folder in Windows, via the registry.
View README.md

Edit the example.reg file to suit your needs by changing the following:

  1. In line 3, Example is the name of the registry key. It can be whatever you want, but must match the path in line 6.
  2. In line 4 change the string to whatever you want to see in the right-click menu. Use & before the letter to use as a hotkey (underscored in the menu)
  3. Line 7 contains the command you want to run. %1 will be replaced with the path to the folder you right-clicked.

Lastly, if you want it to be per-user and not global,

@tmr232
tmr232 / oneline-decorator.py
Created March 15, 2022 08:57
Demonstration of decorator-abuse!
View oneline-decorator.py
"""
Relevant PEPs:
- https://peps.python.org/pep-0572/
- https://peps.python.org/pep-0614/
"""
from functools import wraps
@lambda f: (
@tmr232
tmr232 / PythonFunctionOverloads.py
Created March 13, 2022 21:08
This is a proof-of-concept for function overloading in Python based on metaclasses and `__prepare__()`.
View PythonFunctionOverloads.py
"""
This is a proof-of-concept for function overloading in Python
based on metaclasses and `__prepare__()`.
This code is intended as a fun experiment and an educational resource.
I highly recommend avoiding the overload patterns presented here in
real projects, as they will be very confusing to readers.
Additionally, this code does not handle edge cases and is very likely
to fail or behave unexpectedly.
"""
@tmr232
tmr232 / context_only.py
Created November 5, 2021 14:15
Class decorator for enforcing the use of `with` statement for an object
View context_only.py
from typing import Type, ContextManager, TypeVar
T = TypeVar("T")
def context_only(cls: Type[T]) -> Type[ContextManager[T]]:
def _default_enter(self):
return self
def _default_exit(self, exc_type, exc_val, exc_tb):
@tmr232
tmr232 / memlog.py
Last active November 8, 2021 10:19
View memlog.py
import time
from pathlib import Path
import typer
import maya
import psutil
from loguru import logger
app = typer.Typer()
@tmr232
tmr232 / property.cpp
Created July 31, 2017 12:31
C++ property POC
View property.cpp
#include <functional>
#include <cstdio>
template <class T>
class Property {
public:
using Setter = std::function<void(T)>;
using Getter = std::function<T()>;
Property(Setter setter, Getter getter) :_setter{setter}, _getter{getter}
@tmr232
tmr232 / delete_multychunk.py
Created December 2, 2016 11:17
Delete functions with multiple chunks in IDA
View delete_multychunk.py
import idaapi
import idautils
def iter_all_funcs():
for func_ea in idautils.Functions(idaapi.cvar.inf.minEA, idaapi.cvar.inf.maxEA):
yield idaapi.get_func(func_ea)
def iter_multichunk_funcs():
for func_t in iter_all_funcs():
if func_t.tailqty > 0: