Skip to content

Instantly share code, notes, and snippets.

View code-architect's full-sized avatar
🎯
Focusing

Indranil Samanta code-architect

🎯
Focusing
View GitHub Profile
import { ethers } from "ethers";
const API_KEY = YOUR_API_KEY;
const network = "homestead";
const provider = ethers.getDefaultProvider(network, {
etherscan: API_KEY,
});
const blockNumber = await provider.getBlockNumber();
console.log(blockNumber);
@code-architect
code-architect / autoload.py
Last active April 22, 2022 21:26
Autoload Python libraries
files = {
"functools": ["reduce", "cache", "lru_cache"],
"json": "",
"hashlib": ["sha3_256"]
}
def unlimited_files(keyword_args):
lib = {}
for k, b in keyword_args.items():
// composer require
// "elasticsearch/elasticsearch": "^7.0",
// "fzaninotto/faker": "^1.8"
<?php
use Elasticsearch\ClientBuilder;
require 'vendor/autoload.php';
set_time_limit(0);
@code-architect
code-architect / Stopwatch.js
Created December 4, 2018 23:09
Basic JavaScript Stopwatch class control from the console
function Stopwatch() {
let startTime, endTime, running, duration = 0;
this.start = function(){
if(running){
throw new Error('Stopwatch has already started');
}
running = true;
startTime = new Date();
};
@code-architect
code-architect / errors.php
Created January 29, 2017 21:28
Getting Errors from PDO Exception
<?php
function showPdoError($e)
{
$error = 'Could Not Connect: '.$e->getMessage().'<br>';
$error .= 'There is an error on line: '.$e->getLine().'<br>';
$error .= 'Error Number: '.$e->getCode().'<br>';
$error .= 'Error File Location: '.$e->getFile();
return $error;
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$url = $actual_link;
$path = parse_url($url, PHP_URL_PATH);
$pathFragments = explode('/', $path);
$end = end($pathFragments);
echo $end;
@code-architect
code-architect / check_session_status.php
Created December 17, 2015 13:46
Check session status instantly
function status(){
$status = session_status();
switch ($status) {
case PHP_SESSION_DISABLED:
echo 'PHP is complied with --disable-session option';
break;
case PHP_SESSION_NONE:
echo 'No active session';
break;