Skip to content

Instantly share code, notes, and snippets.

View spandan114's full-sized avatar
📚
Learning

spandan joshi spandan114

📚
Learning
View GitHub Profile
@spandan114
spandan114 / SolcCompilation.js
Last active January 16, 2022 13:12
How solidity actually compile behind the hood & how its generate ABI & Byte code .
const solc = require("solc");
// file system - read and write files to your computer
const fs = require("fs");
// web3 interface
const Web3 = require("web3");
// setup a http provider
const web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:7545"));
@spandan114
spandan114 / 1CRUD.sol
Last active December 28, 2021 20:31
Solidity smart contracts
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
struct Student{
string name ;
uint rollno;
}
contract Crud{
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.9.0;
contract Array{
uint[6] public fixedArr = [1,2,3]; //Fixed size array
uint[] public arr = [1,2,3]; //Dynamic array
function updateArrVal(uint index,uint val) public{
arr[index] = val;
@spandan114
spandan114 / geoip.js
Last active October 31, 2021 18:52
get user location in node.js & express.js using geo ip
const express = require("express");
var geoip = require("geoip-lite");
const app = express();
app.use(express.json());
app.get("/", (req, res) => {
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
var geo = geoip.lookup(ip);
console.log(geo)