Skip to content

Instantly share code, notes, and snippets.

@duongntbk
duongntbk / kotlinDelegationBytecoce
Created March 23, 2023 07:02
Kotlin delegation bytecode
// ================WeaponWrapper.class =================
// class version 52.0 (52)
// access flags 0x31
public final class WeaponWrapper implements Weapon {
// access flags 0x2
private LWeapon; weapon
@Lorg/jetbrains/annotations/NotNull;() // invisible
@duongntbk
duongntbk / html_tag_v2.py
Created March 31, 2022 15:22
Demo HTML Tag formatting with context manager, version 2
# -*- coding: utf-8 -*-
'''
This is the demo code for my article about context manager at the link below.
https://duongnt.com/context-manager
'''
class HtmlTagV2:
INDENT = 2
depth = 0
@duongntbk
duongntbk / html_tag.py
Last active March 31, 2022 15:22
Demo HTML Tag formatting with context manager
# -*- coding: utf-8 -*-
'''
This is the demo code for my article about context manager at the link below.
https://duongnt.com/context-manager
'''
class HtmlTag:
INDENT = 2
depth = 0
@duongntbk
duongntbk / adversarial_example_demo.py
Created January 14, 2022 19:43
adversarial_example_demo
# -*- coding: utf-8 -*-
'''
This is the demo code for my article about adversarial example at the link below.
https://duongnt.com/adversarial-example
Please install these packages before running this script.
- pip install tensorflow
- pip install keras
- pip install Pillow
'''
@duongntbk
duongntbk / keras_tuner_demo.py
Last active January 4, 2022 14:53
keras_tuner_demo
# -*- coding: utf-8 -*-
'''
This is the demo code for my article about KerasTuner at the link below.
https://duongnt.com/kerastuner
Please install these packages before running this script.
- pip install tensorflow
- pip install keras
- pip install keras-tuner
'''
@duongntbk
duongntbk / h5py_demo.py
Last active December 13, 2021 17:37
h5py demo
# -*- coding: utf-8 -*-
'''
This is the demo code for my article about HDF5 in Python at the link below.
https://duongnt.com/hdf5-with-h5py
Please install these packages before running this script.
- pip install h5py
- pip install imutils
- pip install keras
import argparse
import os
BMP_HEADER_LENGTH = 54
BMP_HEADER = bytes.fromhex('424d36000c000000000036000000280000000002000000020000010018000000000000000c0074120000741200000000000000000000')
first_encrypted_path = 'first_encrypted_image.bmp'
second_encrypted_path = 'second_encrypted_image.bmp'
mix_encrypted_path = 'mix_encrypted_image.bmp'
@duongntbk
duongntbk / to_pb.py
Last active March 8, 2020 09:02
Script to convert tensorflow's ckpt or keras' h5 model into pb graph
# -*- coding: utf-8 -*-
'''
pip install keras >= 2.3.1
pip install tensorflow >= 1.14.0
'''
import os
import tensorflow as tf