Skip to content

Instantly share code, notes, and snippets.


Lecky Lao leckylao

View GitHub Profile
View settings.json
"slither.solcPath": "",
"slither.hiddenDetectors": [],
"solidity.compileUsingRemoteVersion": "v0.6.12+commit.27d51765",
"solidity.nodemodulespackage": "@eth-optimism/solc"
leckylao / save.js
Last active Sep 6, 2020
instadapp save
View save.js
let borrowAmount = 3880;
let borrowAmtInWei = dsa.tokens.fromDecimal(borrowAmount, "usdc"); // borrow flash loan and swap via OasisDEX
console.log("borrowAmtInWei: ", borrowAmtInWei)
let position = await dsa.compound.getPosition();
let wbtcDebtAmount = position.wbtc.borrow;
let wbtcDebtAmtInWei = dsa.tokens.fromDecimal(wbtcDebtAmount, "wbtc");
console.log("wbtcDebtAmount: ", wbtcDebtAmount)
View subArray.js
function printSubsequences(arr, index, subarr)
// Print the subsequence when reach
// the leaf of recursion tree
if (index === arr.length)
// Condition to avoid printing
// empty subsequence
if (subarr.length != 0)
leckylao / getSubArraysOfSum.js
Created Aug 1, 2020 — forked from mo7amd/getSubArraysOfSum.js
Get all sub-arrays of array arr[] with sum k
View getSubArraysOfSum.js
hellow world from emacs
View short_dai.js
await dsa.setInstance(;
let borrowAmount = 10000; // 10000 DAI
let borrowAmtInWei = dsa.tokens.fromDecimal(borrowAmount, "dai"); // borrow flash loan and swap via OasisDEX
let position = await dsa.compound.getPosition();
let debtAmount = position.wbtc.borrow;
let debtAmtInWei = dsa.tokens.fromDecimal(debtAmount, "wbtc"); // borrow flash loan and swap via OasisDEX
let slippage = 0.5; // 0.5% slippage.
View lending_swap.js
await dsa.setInstance(237);
let withdrawAmount = 1000;
let withdrawAmtInWei = dsa.tokens.fromDecimal(withdrawAmount, "bat");
let slippage = 0.1; // 0.1% slippage.
let bat_address =
let usdc_address =
let buyAmount = await dsa.kyber.getBuyAmount("USDC", "BAT", withdrawAmount, slippage);
View instadapp.js
async function oneInchSwapQuote(fromToken, toToken, dsa){
const oneInchSwapQuote = await (await fetch(`${fromToken.symbol}&toTokenSymbol=${toToken.symbol}&amount=${fromToken.balance.toString()}&fromAddress=${dsa.instance.address}&slippage=1&disableEstimate=true`)).json();
console.log(`Estimate exchange: ${oneInchSwapQuote.toTokenAmount / (10 ** toToken.decimals)}`)
return oneInchSwapQuote;
// Set DSA instance
await dsa.setInstance((await dsa.getAccounts())[0].id);
// Set up tokens
leckylao /
Created Sep 11, 2017 — forked from spalladino/
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
leckylao / Permission problems with SSH
Last active Aug 29, 2015
Permission problems with SSH
View Permission problems with SSH
Ssh is very picky about permissions on the ~/.ssh directory and files. Sometimes you may do something to mess up these permissions. Run the following to fix most permissions problems. You may have to do this on both the remote host and local host.
SSH will not work correctly and will send warnings to the log facilities if any variation of g+w or o+wexists on the $HOME directory
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/
chmod 644 ~/.ssh/authorized_keys
chmod 644 ~/.ssh/known_hosts
leckylao / .zshrc
Last active Feb 26, 2019
zsh theme that works with multi-user rvm installation rvm-prompt
View .zshrc
# Path to your oh-my-zsh installation.
export ZSH=/Users/leckylao/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
# ZSH_THEME="robbyrussell"
# two lines