Skip to content

Instantly share code, notes, and snippets.

View iamnotstatic's full-sized avatar
🎯
Focusing

Abdulfatai Suleiman iamnotstatic

🎯
Focusing
View GitHub Profile
@iamnotstatic
iamnotstatic / guessing_game.rs
Created March 5, 2024 18:13
A guessing game on rust
use rand::Rng;
use std::{cmp::Ordering, io};
fn main() {
println!("Guess the number!");
let secret_number = rand::thread_rng().gen_range(1..=100);
loop {
println!("Please input your guess.");
public class Main {
public static void main(String[] args) {
int[] A = { -1, 2, -10, 20, 30 - 3, 4, 10, 45, -50, 75 };
int[] B = new int[A.length];
int[] C = new int[A.length];
separatePositiveNegative(A, B, C, A.length, 0, 0);
// print the positive numbers from array A
System.out.println("Positive numbers: ");
@iamnotstatic
iamnotstatic / expire.js
Created November 9, 2021 18:08
Check if login code is expired nestjs
// check if date is expired or not
const userLoginCode = await this.usersRepository.findOne({ id });
const loginCodeExpiry = userLoginCode.loginCodeExpiry;
const currentDate = new Date();
if (currentDate > loginCodeExpiry) {
await this.usersRepository.update(
{ id: id },
{
loginCode: null,
loginCodeExpiry: null,
@iamnotstatic
iamnotstatic / web3checker.js
Created November 2, 2021 09:23
Web3 checker for expecting error/event from smart contract
async function expectThrow(promise) {
try {
await promise;
assert(true);
} catch (err) {
return;
}
assert(false, 'The contract did not throw.');
}
@iamnotstatic
iamnotstatic / blockchain.py
Created October 20, 2021 14:34
Blockchain with Python
# Module 1 - Create Blockchain
import datetime
import hashlib
import json
from flask import Flask, jsonify
## Building the blockchain
class Blockchain:
def __init__(self):
@iamnotstatic
iamnotstatic / deploy.js
Created July 18, 2021 18:52
Deploy Contract with Web3js
const HDWalletProvider = require('@truffle/hdwallet-provider');
const Web3 = require('web3')
const {abi,bytecode} = require('./build/contracts/A1.json')
const provider = new HDWalletProvider(
'PRIVATE key',
` http://127.0.0.1:8545`
)
const web3 = new Web3(provider)
@iamnotstatic
iamnotstatic / hdwallet.js
Created July 11, 2021 09:01
Generate Addresses with hdwallet-provider
const HDWalletProvider = require('@truffle/hdwallet-provider')
export const generateAddresses = (startFromIndex: number = 0, numAddresses: number = 10) => {
const mnemonic: string = "mnemonic seed phraze goes here"
const rpcNode: string = "https://data-seed-prebsc-1-s2.binance.org:8545"
const provider: any = new HDWalletProvider(
mnemonic,
rpcNode,
startFromIndex,
import cheerio from 'cheerio';
import axios from 'axios';
const scrapper = async (url: string) => {
try {
const { data } = await axios.get(url, {
headers: {
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36',
},
@iamnotstatic
iamnotstatic / app.js
Created December 22, 2020 01:58
Web scrapping
const axios = require("axios");
const cheerio = require("cheerio");
const url = "https://stackoverflow.com/jobs";
(async () => {
try {
const res = await axios.get(url);
const html = res.data;
const TelegramBot = require('node-telegram-bot-api');
const bot = new TelegramBot("YOUR_BOT_TOKEN", { polling: true });
const request = require('request');
const express = require('express');
const app = express();
const port = process.env.PORT || 3000;
bot.onText(/\/movie (.+)/, (msg, match) => {