Skip to content

Instantly share code, notes, and snippets.

View ImanMousavi's full-sized avatar

Iman ImanMousavi

View GitHub Profile
@ImanMousavi
ImanMousavi / keystore.py
Last active February 12, 2024 12:24
Generate keystore file from raw private key
from web3 import Web3
from eth_account import Account
import json
import string
import random
# import qrcode
@ImanMousavi
ImanMousavi / capsLock.ahk
Created September 8, 2023 13:46
AHS: CapsLock like on MacOS
#Requires AutoHotkey v2.0
SendMode "Input"
$CapsLock::
{
CapsError := !KeyWait("CapsLock", "T0.5")
If CapsError {
if GetKeyState("CapsLock", "T") = 0
SetCapsLockState("on")
@ImanMousavi
ImanMousavi / CustodialWallet.sol
Created July 18, 2023 12:49
Custodial Wallet smart contract code with support for ERC20 tokens
pragma solidity ^0.8.0;
interface IERC20 {
function transfer(address to, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function balanceOf(address account) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
}
@ImanMousavi
ImanMousavi / USDTReceiver.sol
Created July 15, 2023 10:07
This contract is designed to be used with the ERC20 standard USDT token, and it uses the IERC20 interface from the OpenZeppelin library to interact with the USDT token contract.
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
// This contract is written in Solidity and is designed to receive USDT tokens and aggregate them into a single address. The contract constructor takes in three parameters: the USDT token address, the collection address where the tokens will be sent, and the threshold value for the minimum amount of tokens to be collected before they are sent to the collection address.
// The receiveUSDT function is used to receive USDT tokens from users. When a user calls this function and sends USDT tokens to the contract, the transferFrom function of the USDT token contract is used to transfer the tokens to the contract. The function then checks the current balance of USDT tokens held by the contract, and if the balance is greater than or equal to the threshold value, all the tokens are transferred to the collection address using the transfer function of the USDT token contract.
@ImanMousavi
ImanMousavi / pp.go
Last active April 21, 2023 16:08
dd
package main
import (
"cryptodax/new-race-robot/exchange"
"cryptodax/new-race-robot/models"
"cryptodax/new-race-robot/utils"
"log"
"math"
"math/rand"
"time"
@ImanMousavi
ImanMousavi / softether.sh
Created April 14, 2023 21:12 — forked from bouroo/softether.sh
Install softether vpn server on ubuntu 16.04+
#!/usr/local/env bash
# Register vultr.com with free credit https://www.vultr.com/?ref=9206731-8H
# Create vps
# Tested on Ubuntu 18.04, Debian 10.0
# How to...
# 1. Save this file as softether-installer.sh
# 2. chmod +x softether-installer.sh
# 3. Run bash file
# > ./softether-installer.sh
# Or just
@ImanMousavi
ImanMousavi / biasedRandom.js
Last active April 4, 2023 18:02
A function that returns a random number between 1 and 8 with a higher probability of being less than 2
// A function that returns a random number between 1 and 8 with a higher probability of being less than 2
function biasedRandom() {
// Generate a random number between 0 and 1
let r = Math.random();
// If the number is less than 0.75, return a number between 1 and 2
if (r < 0.75) {
return Math.floor(r * 2) + 1;
}
@ImanMousavi
ImanMousavi / index.html
Last active December 27, 2022 12:25
CryptoCurrency Live Ticker with Vue
<div id="app" v-cloak>
<header class="header-wrap">
<div class="header-row flex-row flex-middle flex-space">
<div class="if-small">
<div class="form-input dark">
<div class="push-right">🔎</div>
<input type="text" v-model="search" placeholder="Search token..." />
</div>
</div>

Creating an SSTP server on GCP


Local command line

  1. ssh-keygen -t rsa -b 4096 -C "YOUR EMAIL ADDRESS"
  2. write ssh key to ~/.ssh/gcp-sstp-box
  3. also save the key to an encrypted location, e.g. Lastpass
  4. gcloud config set project YOURGCPPROJECTNAME
  5. gcloud config compute/region set europe-west1 (or wherever you wish to host it)
  6. gcloud config compute/zone set europe-west1-b (or wherever)
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.8.0;
pragma experimental ABIEncoderV2;
contract Wallet {
address[] public approvers;
uint8 public quorum;
struct Transfer {