Skip to content

Instantly share code, notes, and snippets.

View quangkeu95's full-sized avatar
🦀
rusty

Hashira quangkeu95

🦀
rusty
View GitHub Profile
@quangkeu95
quangkeu95 / gist:fe27dff8171f7061928fb1a3dacd695c
Created April 27, 2024 10:37
Parse Meteora Dynamic AMM pools locked info
// Fetch lock info from rpc
pub async fn fetch_lock_info_from_rpc(rpc_client: &RpcClient, pair_id: &str) -> Result<LockInfo> {
let pool_pubkey = Pubkey::from_str(pair_id)?;
// find lp mint of the pool
let pool_account = rpc_client.get_account(&pool_pubkey).await?;
let pool = PoolState::try_deserialize(&mut pool_account.data.as_ref())?;
let lp_mint = pool.lp_mint;
let lp_mint_account = rpc_client.get_account(&lp_mint).await?;
let lp_mint_state = Mint::try_deserialize(&mut lp_mint_account.data.as_ref())?;

Keybase proof

I hereby claim:

  • I am quangkeu95 on github.
  • I am quangkeu95 (https://keybase.io/quangkeu95) on keybase.
  • I have a public key ASDvi3_r0U_iymEyWLKFQhbn_GSMUfamBmvdlYPcSXpTlQo

To claim this, I am signing this object:

@quangkeu95
quangkeu95 / git_submodules.md
Created April 4, 2019 02:59 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of advantages of using submodules:

  • You can separate the code into different repositories.
For example, to override the AppBar (https://material-ui-next.com/api/app-bar/) root class we can do the following:
First method (override Material UI classnames):
1 - Add the property classes in the AppBar component:
<AppBar classes={{root: 'my-root-class'}}
2 - Override the styles with the styled components:
styled(AppBar)`
&.my-root-class {
z-index: 1500;
}
@quangkeu95
quangkeu95 / es6-class.js
Last active November 7, 2018 08:09
ES6 Class Inheritance
class Animal {
constructor(name, weight) {
this.name = name;
this.weight = weight;
}
eat() {
return `${this.name} is eating`;
}
@quangkeu95
quangkeu95 / prototype-based-inheritance-class.js
Created November 6, 2018 07:53
Prototype-based Inheritance Class
function Person(name, age) {
this.name = name;
this.age = age;
};
Person.prototype.sayHi = function() {
console.log(`${this.name}, ${this.age} say hi`);
};
function Employee(name, age, job) {
@quangkeu95
quangkeu95 / prototype_property.js
Last active November 5, 2018 06:58
"Proptotype" property
let person = {
works: true
};
function Employee(name) {
this.name = name;
}
Employee.prototype = person;
function User(name, birthday) {
this.name = name;
this.birthday = birthday;
// age is calculated from the current date and birthday
Object.defineProperty(this, "age", {
get() {
let todayYear = new Date().getFullYear();
return todayYear - this.birthday.getFullYear();
}
@quangkeu95
quangkeu95 / smart_setter.js
Last active November 5, 2018 03:36
Smart Setter
let employee = {
get workDuration() {
return this._workDuration;
},
set workDuration(value) {
if (value.length > 8) {
console.log("Work duration is too much, maximum 8 hours is allowed");
return;
}
this._workDuration = value;
@quangkeu95
quangkeu95 / kafka-cheat-sheet.md
Created June 26, 2018 06:41 — forked from sahilsk/kafka-cheat-sheet.md
Apache Kafka Cheat Sheet

Kafka Cheat Sheet

Display Topic Information

$ kafka-topics.sh --describe --zookeeper localhost:2181 --topic beacon
Topic:beacon	PartitionCount:6	ReplicationFactor:1	Configs:
	Topic: beacon	Partition: 0	Leader: 1	Replicas: 1	Isr: 1
	Topic: beacon	Partition: 1	Leader: 1	Replicas: 1	Isr: 1