This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function expectThrow(promise) { | |
try { | |
await promise; | |
assert(true); | |
} catch (err) { | |
return; | |
} | |
assert(false, 'The contract did not throw.'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Module 1 - Create Blockchain | |
import datetime | |
import hashlib | |
import json | |
from flask import Flask, jsonify | |
## Building the blockchain | |
class Blockchain: | |
def __init__(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) => { |
NewerOlder