Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
function sendMessage(){ | |
const mainEl = document.querySelector('#main') | |
const textareaEl = mainEl.querySelector('div[contenteditable="true"]') | |
if(!textareaEl) { | |
throw new Error('There is no opened conversation') | |
} | |
random_length = Math.floor(Math.random() * 1000) + 1 | |
textareaEl.focus() | |
document.execCommand('insertText', false, ' '.repeat(random_length)) |
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
""" | |
Exercises: | |
Try to change difficulty level in proof of work algorithm and see how long does it takes to compute nonce. | |
Write a method to validate the chain. | |
Reward the mining node. | |
""" | |
# blockchain.py | |
import hashlib |
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
from flask import Flask | |
class Blockchain(): | |
def __init__(self): | |
self.chain = [] | |
self.current_transactions = [] | |
def new_block(self): | |
# Creates a new Block and adds it to the chain | |
pass |
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
""" | |
Q1. Given an unsorted array with multiple duplicate elements. Find the most repeated element. Return the bigger number if multiple numbers have the highest frequency. | |
For example: | |
T1: | |
Input: [2, 1, -2, 55, 2, 1, 3, 9, 3, 3] | |
Answer: 3 | |
T2: [1, 1, 2, 2, 2, 2, 1, 1] | |
Answer: 2 | |
""" | |
def most_frequent(arr): |
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
""" | |
The Game of Dice | |
The "Game of Dice" is a game where two players roll 6 faced dice in a round-robin fashion. | |
Each time a player rolls the dice their points increase by the number (1 to 6) achieved by the | |
roll. The first player to accumulate M points wins the game. | |
created by - Mohit Khandelwal ([email protected]) | |
""" |
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
// Q2. Write a function to get Max value of a number Array? | |
function findMax(arr) { | |
maxValue = arr[0]; | |
arr.forEach(element => { | |
if (element >= maxValue) { | |
maxValue = element; | |
} | |
}); | |
return maxValue; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script> | |
<style> | |
#scroll-section{ |
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 turtle | |
# set up screen | |
window = turtle.Screen() | |
window.bgcolor("#bbb") | |
# Setting up boundry | |
mypen = turtle.Turtle() | |
mypen.penup() | |
mypen.setposition(-260, -260) |
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
# Python code to save a file with timestamp of accuracy upto millisecond | |
from datetime import datetime as dt | |
current_time = dt.now() # current system time e.g. 2018-07-16 16:34:43.050328 | |
current_time_as_str = str(current_time) | |
filename = current_time_as_str + ".txt" | |
file = open(filename, "w+") # Create a empty text file with timestamp name | |
file.close() |
NewerOlder