Skip to content

Instantly share code, notes, and snippets.

View darwinsubramaniam's full-sized avatar

Darwin Subramaniam darwinsubramaniam

View GitHub Profile
@darwinsubramaniam
darwinsubramaniam / btree_gist.sql
Created February 18, 2023 14:32
SQL btree_gist
CREATE EXTENSION IF NOT EXISTS btree_gist;
export $(grep -v '^#' .env | xargs)
#[derive(
Debug,
Copy,
Clone,
PartialEq,
Eq,
scale::Encode,
scale::Decode,
ink_storage::traits::SpreadLayout,
ink_storage::traits::PackedLayout,
@darwinsubramaniam
darwinsubramaniam / test.rs
Created May 16, 2022 13:39
Ink! Set Caller and Callee
let accounts =
ink_env::test::default_accounts::<ink_env::DefaultEnvironment>();
assert_eq!(erc20.balance_of(accounts.bob), 0);
// Set the contract as callee and Bob as caller.
let contract = ink_env::account_id::<ink_env::DefaultEnvironment>();
ink_env::test::set_callee::<ink_env::DefaultEnvironment>(contract);
ink_env::test::set_caller::<ink_env::DefaultEnvironment>(accounts.bob);
@darwinsubramaniam
darwinsubramaniam / any.rs
Last active February 18, 2023 14:26
Rust: Dynamic Result Return
// Adding this line
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
// as the example
async main() -> Result<int> {
let mut args = std::env::args();
let _ = args.next();
let path = args.next().expect("missing path argument");

Keybase proof

I hereby claim:

  • I am darwinsubramaniam on github.
  • I am udworld (https://keybase.io/udworld) on keybase.
  • I have a public key ASCyKSM2iiSadB5lbh0iaePzUA8JTJuq158pcSwPTxmkrwo

To claim this, I am signing this object:

@darwinsubramaniam
darwinsubramaniam / Cargo.toml
Created October 24, 2021 03:06
Phala Enclave Cargo.toml
[package]
name = "EnclaveApp"
version = "0.0.1"
authors = ["jasl"]
edition = "2018"
resolver = "2"
[lib]
name = "enclaveapp"
crate-type = ["staticlib"]

Keybase proof

I hereby claim:

  • I am darwinsubramaniam on github.
  • I am darwinudw (https://keybase.io/darwinudw) on keybase.
  • I have a public key ASAp_9cAVV1vXtAjN8IK078v_4lV8QeGaXc0IBjWa6mYCwo

To claim this, I am signing this object:

@darwinsubramaniam
darwinsubramaniam / index.ts
Created August 2, 2020 11:20
sample in node js
import { mkdir, open, writeFile} from 'fs/promises';
import { existsSync } from 'fs';
var dir = './asset';
async function start() {
if (!existsSync(dir)) {
await mkdir(dir);
}
{
"name": "node",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"start": "tsc -p tsconfig.json && node ./dist/index.js"
},
"keywords": [],
"author": "",