Skip to content

Instantly share code, notes, and snippets.

View gimelfarb's full-sized avatar
😎
Coding

Lev Gimelfarb gimelfarb

😎
Coding
View GitHub Profile
@gimelfarb
gimelfarb / aes-encrypt-example.js
Last active February 1, 2023 11:26
CryptoJS AES encryption with custom Key & IV
const CryptoJS = require('crypto-js');
const msg = CryptoJS.enc.Hex.parse('00010203');
// key & iv - 128-bit (16 byte)
const key = CryptoJS.enc.Hex.parse('1234567890abcdef1234567890abcdef');
const iv = CryptoJS.enc.Hex.parse('fedcba0987654321fedcba0987654321');
// AES-128
const enc = CryptoJS.AES.encrypt(msg, key, {
@gimelfarb
gimelfarb / tasks.json
Created February 10, 2020 20:14
VSCode task for webpack dev server
{
"version": "2.0.0",
"tasks": [
{
"label": "start-web-server",
"type": "npm",
"script": "start",
// "path": "packages/xxx/", <-- for monorepo
"isBackground": true,
"problemMatcher": [
@gimelfarb
gimelfarb / withEnhancement.js
Created April 13, 2019 23:46
Recursive React HOC
import getDisplayName from 'react-display-name';
/**
* Create HOC with recursive Enhancement.
*
* @param {import('react').ComponentType} Component
* @returns {import('react').FunctionComponent}
*/
export function withEnhancement(Component) {
const Enhanced = (props) => {
@gimelfarb
gimelfarb / Scripts~_references.js
Created August 24, 2014 20:39
JavaScript Intellisense broken tilde-slash path references
/// <reference path="~/www/js/r.js" />
@gimelfarb
gimelfarb / AssemblyDebugInfo.cs
Created January 27, 2014 02:05
Reading PDB symbol reference info (file, GUID, age) from a loaded Assembly
public static AssemblyDebugInfo ReadAssemblyDebugInfo(Assembly assembly)
{
// Parses PE headers structure from the module base address pointer
var modulePtr = Marshal.GetHINSTANCE(assembly.ManifestModule);
var peHdrs = PeHeaders.FromUnmanagedPtr(modulePtr);
// Depending on whether this is 32-bit or 64-bit module, the offsets are
// slightly different