Skip to content

Instantly share code, notes, and snippets.

@afulsamet
afulsamet / main.cpp
Created October 4, 2022 22:10
Inline string with using bit_cast (std:c++20)
#include <bit>
#include <array>
int main()
{
// Create raw array in stack: rsp+2C
volatile std::uint32_t stack[3];
// mov dword ptr ss:[rsp+2C], 6C6C6548
stack[0] = std::integral_constant<std::uint32_t, std::bit_cast<std::uint32_t>(std::array<char, sizeof(std::uint32_t)>{'H', 'e', 'l', 'l'})>::value;
@afulsamet
afulsamet / index.js
Last active March 4, 2021 06:07
Censor bad words with JavaScript
const Regex = {
BadWords: /(bad word|can't censor me)/g
}, IString = "hey, i'm a bad word and you can't censor me";
IString.replace(new RegExp(Regex.BadWords), RString => Array.from(RString).map(() => "*").join(String()))
// Output: "hey, i'm a ******** and you ***************"