Skip to content

Instantly share code, notes, and snippets.

View nhancv's full-sized avatar
🏠
Working from home

Nhan Cao nhancv

🏠
Working from home
View GitHub Profile
@nhancv
nhancv / version-ios.sh
Last active May 15, 2023 16:51
React native: Bash script to update Info.plist version
#!/usr/bin/env bash -e
_PROJECT_NAME=$(cat package.json | grep name | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')
_INFOPLIST_DIR="ios/${_PROJECT_NAME}/Info.plist"
_PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')
# Set BUILD_NUMBER to the value 1 only if it is unset.
: ${BUILD_NUMBER=$(expr $(git log -1 --pretty=format:%ct) / 3600)}
@nhancv
nhancv / Widget.dart
Last active January 10, 2023 12:36
Flutter highlight text in search
// list
return ListView.separated(
physics: const AlwaysScrollableScrollPhysics(),
itemCount: friends.length,
itemBuilder: (BuildContext context, int index) {
final Friend item = friends[index];
return _buildItem(context, index, item, provider);
},
separatorBuilder: (_, int index) => const Divider(),
);
@nhancv
nhancv / snapshot_graphql.js
Created November 24, 2022 10:01
Example query data of snapshot.org
/**
DIR=snapshotdev
mkdir $DIR
cd $DIR
touch index.js
npm init -y
npm i isomorphic-unfetch
npm i @urql/core
# Docs: https://docs.snapshot.org/snapshot.js
@nhancv
nhancv / IERC20Full.sol
Created November 19, 2022 04:17
Interface of the ERC20 standard as defined in the EIP.
// SPDX-License-Identifier: MIT
pragma solidity 0.4.25;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Full {
/**
* @dev Returns the name of the token.
*/
@nhancv
nhancv / web3-metamask.html
Created November 14, 2022 01:19
Example web3 - Metamask
<!-- Localhost start: http-server -->
<html>
<link
rel="icon"
type="image/x-icon"
href="https://www.mozilla.org/media/img/favicons/firefox/browser/favicon.f093404c0135.ico"
/>
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script>
@nhancv
nhancv / video-station-language-injection.js
Created October 14, 2022 07:31 — forked from the-unsoul/video-station-language-injection.js
Inject a subtitle language into Synology - Video Station
(function() {
var synoLang;
var isSynoReady;
var additional = {
code : 'vie', // <== uses reference language list at the bottom and set the 'code' to the language you wanted
label: 'Tiếng Việt' // <== 'label' can be anything you wanted. i.e. if set to 'New lang 123' you will see 'New lang 123' in the list
}
@nhancv
nhancv / intl_arb2csv.py
Created August 6, 2020 04:58
convert arb to csv for flutter intl
import csv
import json
import os
cmd_path = os.path.dirname(__file__)
# Init file
intl_name = 'intl_vi'
arb_file_path = cmd_path + '/' + 'lib/l10n/' + intl_name + '.arb'
csv_file_path = cmd_path + '/' + 'lib/l10n/' + intl_name + '.csv'
@nhancv
nhancv / _z_android_setup.md
Last active July 3, 2022 11:05
Flutter stream hls m3u8

build.gradle

    aaptOptions {
        noCompress '.flv', '.mp4'
    }

    signingConfigs {}
@nhancv
nhancv / NKemICO.sol
Created March 27, 2018 10:54
NKem ICO Crowdsale simple
pragma solidity 0.4.21;
/**
ICO CrowdSale token contract
Abstract
Start date : Tuesday, March 27, 2018 5:31:11 PM GMT+07:00
Bonus end date : Wednesday, March 27, 2019 5:31:11 PM GMT+07:00
End date : Thursday, March 26, 2020 5:31:11 PM GMT+07:00
Normal price : 100 NKEM Tokens per 1 ETH
@nhancv
nhancv / MockERC20.sol
Last active March 2, 2022 13:25
MockERC20
// SPDX-License-Identifier: MIT
pragma solidity 0.8.4;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MockERC20 is ERC20 {
constructor(
string memory _name,
string memory _symbol,