Skip to content

Instantly share code, notes, and snippets.

View vunguyen9404's full-sized avatar
🎯
Focusing

Nguyễn Vũ vunguyen9404

🎯
Focusing
View GitHub Profile
@vunguyen9404
vunguyen9404 / Clear storage NEAR contract.md
Last active June 6, 2024 03:42
Remove storage NEAR Contract

Clear storage NEAR Contract

Prepare

  • Install near-cli
  • Login contract wallet and export source
export CONTRACT_NAME=contract
  • Install jq
apt-get install jq
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@vunguyen9404
vunguyen9404 / wheelStatics.js
Created May 31, 2023 17:09
Wheel Statistics
db.getCollection("wheel_histories").aggregate(
[
{
"$match" : {
}
},
{
"$group" : {
"_id" : "$createdAtInt",
@vunguyen9404
vunguyen9404 / wheel.java
Created May 13, 2023 03:23
Wheel Random
Integer totalSlot = 100000;
Double totalLuckyPercent = gifts.stream()
.filter(gift -> gift.getQuantity() > 0)
.map(gift -> {
// Set rate limit
if (giftLogs.size() > 0 && gift.getType() == GiftType.GIFT) {
return Double.parseDouble("0");
};
return gift.getLuckyPercent();
const validateUsername = (username: string): boolean => {
const regex = new RegExp("^(?=[a-zA-Z0-9._]{3,30}$)(?!.*[_.]{2})[^_.].*[^_.]$");
return regex.test(username);
}
@vunguyen9404
vunguyen9404 / sendToken.js
Created December 23, 2022 19:00 — forked from x3388638/sendToken.js
Send ethereum ERC20 token via web3.js (ether, ETH, contract)
const Tx = require('ethereumjs-tx');
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/'));
const contractAddr = 'CONTRACT_ADDRESS';
const contractAbi = [/* CONTRACT_ABI_ARRAY */];
const contractOwner = {
addr: 'CONTRACT_OWNER_ADDRESS',
key: 'CONTRACT_OWNER_PRIVATE_KEY'
};
@vunguyen9404
vunguyen9404 / slow-query-mongodb.md
Last active August 26, 2022 10:19 — forked from rantav/README.md
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...