Skip to content

Instantly share code, notes, and snippets.

View Spetsnaz-Dev's full-sized avatar
🌴
On vacation

Ravindra K Spetsnaz-Dev

🌴
On vacation
View GitHub Profile
/* C/C++ Implementation of Memory
efficient Doubly Linked List */
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
// Node structure of a memory
// efficient doubly linked list
struct Node
{
@Spetsnaz-Dev
Spetsnaz-Dev / Sort_an_array_of_0s_1s+and_2s.cpp
Created June 24, 2020 06:47
Dutch National Flag Algorithm
// Credits : Ashmik Harinkhede
#include<iostream>
#include<vector>
using namespace std;
void swap(vector<int> &arr, int i, int j){
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
//CODE TO Count_Number_Of_Strings_With_Given_Prefix
//Assumption: All characters are in lowercase
#include<iostream>
using namespace std;
//#define NULL 0
struct Trienode
{
char data;
int wc; //wc:word_count
@Spetsnaz-Dev
Spetsnaz-Dev / stake.sol
Created September 24, 2021 17:40
Building our own staking smart contract
pragma solidity >=0.7.0 <0.9.0;
contract Storage {
uint totalContractBalance = 0;
mapping(address => uint) public balance;
bool public isActive = false;
uint constant public threshold = 0.003 * 10**18;
uint public deadline = block.timestamp + 1 minutes;
@Spetsnaz-Dev
Spetsnaz-Dev / get_counterFactualAddress.js
Last active June 27, 2023 10:04
Get counterfactual address of an AA Smart Wallet before deployment
import { BigNumberish, ethers } from 'ethers'
import { KernelFactory__factory, EntryPoint__factory } from '@zerodevapp/contracts-new'
const ENTRYPOINT_ADDRESS = '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789'
const KERNEL_FACTORY_ADDRESS = '0x4E4946298614FC299B50c947289F4aD0572CB9ce'
async function getKernelWalletAddress(factoryAddress: string, entryPointAddress: string, provider: ethers.providers.BaseProvider, signerWalletAddress: string, index: BigNumberish): Promise<string> {
const factory = KernelFactory__factory.connect(
factoryAddress,
provider