Skip to content

Instantly share code, notes, and snippets.

View yongkangc's full-sized avatar
🎃
Focusing

YK yongkangc

🎃
Focusing
View GitHub Profile
@yongkangc
yongkangc / hashURI.py
Created August 16, 2022 14:11
Python Implementation for Hashing with Salting of URI
import uuid
import hashlib
def hashText(secret, uri):
"""
Basic hashing function for a text using unique secret from the user.
"""
return hashlib.sha256(secret.encode() + text.encode()).hexdigest() + ':' + secret
def matchHashedText(hashedUri, Uri):
@yongkangc
yongkangc / SimpleRewards.sol
Created June 21, 2022 15:28 — forked from Markkop/SimpleRewards.sol
A staking contract using a loop to save rewards data for each staker
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;
import "hardhat/console.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./RewardToken.sol";
contract StakingManager is Ownable{
@yongkangc
yongkangc / Model.py
Created December 10, 2021 15:16
Linear Regression Code Template
#importing the required packages
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import statsmodels.api as sm
def normalize_z(dfin):
dfout = (dfin - dfin.mean(axis=0))/dfin.std(axis=0)
return dfout
@yongkangc
yongkangc / transfer-learning-cnn-tutorial.ipynb
Last active June 9, 2021 16:15
transfer learning cnn tutorial.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yongkangc
yongkangc / pytorch_cnn_from_scratch.ipynb
Created June 9, 2021 15:52
Pytorch_CNN_from_scratch.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yongkangc
yongkangc / hierachical.ipynb
Created April 30, 2020 07:48
Hierachical.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yongkangc
yongkangc / lda_kmeans.ipynb
Created April 30, 2020 05:45
LDA_KMeans.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yongkangc
yongkangc / lda_kmeans.ipynb
Created April 2, 2020 08:18
LDA_KMeans.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#confusionmatrix
from sklearn.metrics import confusion_matrix
import numpy as np
def print_confusion_matrix(confusion_matrix, class_names, figsize = (10,7), fontsize=14, normalize=False):
if normalize:
confusion_matrix = confusion_matrix.astype('float') / confusion_matrix.sum(axis=1)[:, np.newaxis]
fmt = '.2f'
title = 'Normalized Confusion Matrix'
@yongkangc
yongkangc / pipenv_cheat_sheet.md
Last active January 16, 2020 14:37 — forked from bradtraversy/pipenv_cheat_sheet.md
Pipenv cheat sheet for common commands

Pipenv Cheat Sheet

Install pipenv

pip3 install pipenv

Activate

pipenv shell