Skip to content

Instantly share code, notes, and snippets.

View rezaiyan's full-sized avatar
👋

Ali Rezaiyan rezaiyan

👋
View GitHub Profile
@rezaiyan
rezaiyan / SmartContract.html
Created December 17, 2023 12:31
This HTML file establishes a web interface for interacting with a smart contract deployed on Ganache CLI. It utilizes the Web3 library for Ethereum interactions and displays transaction information in a table. The displayed transactions include details such as transaction hash, sender, recipient, value, gas price, and more. Additionally, it inco…
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ganache CLI Transactions</title>
<style>
table {
border-collapse: collapse;
@rezaiyan
rezaiyan / transfer.js
Created December 16, 2023 21:51
This is a script for creating and sending an Ethereum transaction using the Web3 library and EthereumJS. It demonstrates how to set up the transaction parameters, sign it with a private key, and send it using Ganache, a local Ethereum blockchain emulator. Feel free to use and modify this code for your Ethereum-related projects.
const { Web3 } = require('web3');
const EthereumTransaction = require('ethereumjs-tx').Transaction;
// Step 1: Set up the appropriate configuration
const web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:7545'));
async function transfer() {
// Step 2: Set the sending and receiving addresses for the transaction
const sendingAddress = 'sendingAddress';
const receivingAddress = 'receivingAddress';
@rezaiyan
rezaiyan / MockResponse.kt
Created October 21, 2022 07:05
Mock response
val client = OkHttpClient.Builder()
.addInterceptor(MockInterceptor())
.build()
//-------------------------
import okhttp3.Interceptor
import okhttp3.Protocol
import okhttp3.Response
import okhttp3.ResponseBody.Companion.toResponseBody
#!/bin/bash
#hi
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for rootFolder in */ ; do
if [ -d $rootFolder"build" ]; then
echo "do you want to delete build folders of \"${rootFolder%?}\" project?"
read ans
if [ "$ans" = "y" ] || [ "$ans" = "Y" ]; then
@rezaiyan
rezaiyan / build.gradle
Created May 6, 2021 19:16
Add your android library to the sonatype (maven central)
Define these lines to the library gradle file:
project.group = "io.github.rezaiyan"
project.archivesBaseName = "LevelProgressBar"
project.version = "1.0.0"
apply from: '../publish.gradle'
@rezaiyan
rezaiyan / Activity.java
Created March 7, 2021 14:49
Transparent Activity
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
}
}
liveData.observeLimit({
//asset 1
}, {
//assert 2
})...
public class MultipartHelper {
private final String fileDir;
private final String outputDir;
public MultipartHelper(String fileDir, String outputDir) {
this.fileDir = fileDir;
String baseDir = BaseApplication.getAppContext().getObbDir() + File.separator + "uploads";
this.outputDir = baseDir + File.separator;
File upload = new File(baseDir);
@rezaiyan
rezaiyan / StaggeredGridLayoutManager.java
Created September 29, 2020 09:24
To have a full width item in the StaggeredGridLayoutManager
ViewGroup.LayoutParams layoutParams = itemView.getLayoutParams();
if (layoutParams instanceof StaggeredGridLayoutManager.LayoutParams) {
if (getAdapterPosition() == 0) {
((StaggeredGridLayoutManager.LayoutParams) layoutParams).setFullSpan(true);
} else {
((StaggeredGridLayoutManager.LayoutParams) layoutParams).setFullSpan(false);
}
}
@rezaiyan
rezaiyan / Degree.java
Created July 4, 2020 20:37
Array degree algo
public static String codeHere(String inputData) {
// Use this function to write your solution;
String[] arrayInfo = inputData.split("\n");
int size = Integer.parseInt(arrayInfo[0]);
int[] lenghsArray = new int[size];
String[] stringArray = arrayInfo[1].split(" ");
List<Integer> subArray = new ArrayList<>();