Skip to content

Instantly share code, notes, and snippets.

View caoer's full-sized avatar
🎯
Focusing as always

Zitao Xiong caoer

🎯
Focusing as always
View GitHub Profile
@caoer
caoer / contracts...artifacts...build-info...c041de928c6ecfbdf734b90e8444376f.json
Created October 23, 2022 19:14
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
This file has been truncated, but you can view the full file.
{
"id": "c041de928c6ecfbdf734b90e8444376f",
"_format": "hh-sol-build-info-1",
"solcVersion": "0.8.7",
"solcLongVersion": "0.8.7+commit.e28d00a7",
"input": {
"language": "Solidity",
"sources": {
"contracts/1_Storage.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.7;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\n\ncontract Ownable {\n address private _owner;\n\n constructor() {\n _owner = msg.sender;\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n modifier only_owner() {\n require(check_is_owner(), 'Error: Unauthorized access');\n _;\n }\n\n function check_is_owner() public view returns (bool) {\n return msg.sender == _owner;\n }\n}\n\ncontract TokenTransfer is Ownable {\n using SafeERC20 for IERC20;\n IERC20 _token;\n\n constructor(address token) {\n _token = IERC20(token);\n }\n\n event SettleInfoEvent(string settle);\n\
for file in ./* ; do mv "$file" "$(echo $file| sed -e 's/\([A-Z]\)/\L\1/g' | sed -e 's/ /_/g')" ; done
function useAsyncStorage(key: string, initialValue: string | null = null) {
const [storageItem, setStorageItem] = useState<string | null>(initialValue);
const updateStorageItem = useCallback(
function (data: string) {
void AsyncStorage.setItem(key, data).catch(e =>
console.log(`updateStorageItem error: ${e}`),
);
setStorageItem(data);
return data;
### Keybase proof
I hereby claim:
* I am caoer on github.
* I am zitao (https://keybase.io/zitao) on keybase.
* I have a public key ASCMYcEZc4il0nlJc4NwsxEU78K4QM8EPwr9UPx3UMK0pQo
To claim this, I am signing this object:
@caoer
caoer / postgres_queries_and_commands.sql
Created May 11, 2021 10:18 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@caoer
caoer / github-utils.zsh
Created June 19, 2020 08:14
github-utils.zsh
github_current_repo() {
local REPO=`git remote -v show | awk 'NR==1 {print $2}' | sed 's/[email protected]://' | sed 's/\.git$//'`
echo $REPO
}
github_deployment_create() {
REPO=`github_current_repo`
if [ -z "${2-}" ]
then
@caoer
caoer / autossh-jump-rtunnel.service
Created August 21, 2019 08:02 — forked from ntrepid8/autossh-jump-rtunnel.service
AutoSSH reverse tunnel service config for systemd
[Unit]
Description=AutoSSH reverse tunnel service for jump.you.io 100022 -> 22
After=network.target
[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -NR 10022:127.0.0.1:22 [email protected] -i /home/root/.ssh/id_rsa
[Install]
WantedBy=multi-user.target
https://miqu.me/blog/2017/06/16/fixing-autocompletion-on-mixed-objective-c-and-swift-projects/
export SOURCEKIT_LOGGING=3 && /Applications/Xcode6-Beta2.app/Contents/MacOS/Xcode
{"sig":"fa5cbae791ae3e237da9b763e11913a3b67600a6cce56b3f188d2a0d2b3fd6e780cfd8de60e5e73cc2bd55c176cc7bcb95523e35d16bef72c9587e91903354690","msghash":"2094ab44298b3ce60f4ded71387a5917b5061f4ef35a6fc722becb3027d9a0a0"}
@caoer
caoer / better-nodejs-require-paths.md
Created November 3, 2017 22:26 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions