Skip to content

Instantly share code, notes, and snippets.

View Blazing-Mike's full-sized avatar
👷
Focusing

Michael Adebambo Blazing-Mike

👷
Focusing
View GitHub Profile
@Blazing-Mike
Blazing-Mike / index.html
Created August 23, 2021 23:52
code for form validation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- displays site properly based on user's device -->
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png">
<link rel="stylesheet" href="style.css">
<title>Frontend Mentor | Intro component with sign up form</title>
@Blazing-Mike
Blazing-Mike / binarytodecimal.js
Created August 28, 2021 00:32
Convert Binary to decimal with javascript
// METHOD 1 (IN-BUILT FUNCTION)
function convertBaseToBinary(bin) {
return parseInt(bin, 2).toString(10); // Convert arguments from one radix/base to radix in toString()/
}
// USING FOR LOOP & parseInt FUNCTION
function bin2dec(bin) {
var decimal = 0;
for (var index = bin.length - 1; index >= 0; index--) {
@Blazing-Mike
Blazing-Mike / function__if__statements.rs
Created September 24, 2021 19:24
function and if statement i wrote in my rustlings exercise
fn main() {
let answer = square(10);
println!("The answer is {}", answer);
}
fn square(num: i32) -> i32 {
num * num
}
// Learning ternary operators
// Traditional way
let message;
if (login == 'Employee') {
message = 'Hello';
} else if (login == 'Director') {
message = 'Greetings';
} else if (login == '') {
// writing if statements as swich statements
//This IF/ELSE statement
if(x === 'value1'){
...
} else if (x = 'value2'){
...
} else{
...
fn main() {
let age = 18;
if x < 18 {
println!('you are too young');
} else if x == 18 {
println!('you are just the right age');
} else {
println!(' wow, you are old, enjoy !!! ');
}
// This is just snippets showing how signature functions works
// Generate private key and public key
generate_keys(){
return (priv_key, pub_key);
}
// sign a message using you private key( still kept secret)
sign(message, priv_key){
return signature; // a signature is returned
@Blazing-Mike
Blazing-Mike / order.html
Created October 26, 2021 12:52 — forked from craigshoemaker/order.html
Bethany's Pie Shop Order Form
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Order | Bethany's Pie Shop</title>
<link rel="stylesheet" href="site.css" type="text/css" />
<style>
@media only screen and (min-width: 768px) {
@Blazing-Mike
Blazing-Mike / arrowfunc.js
Created November 1, 2021 23:36
Improving Readabilty of code with Arrow functions
//Normal function
function sum(num1, num2){
return num1 + num2;
}
let output =sum(10, 4);
console.log(output)
//Arrow function
let sum = (num1, num2) => return num1 + num2;
/* For the first task, you have to create a simple function — chooseName() — that prints
a random name from the provided array (names) to the provided paragraph (para), and then run it once. */
const names = ['Chris', 'Li Kang', 'Anne', 'Francesca', 'Mustafa', 'Tina', 'Bert', 'Jada']
const para = document.createElement('p');
function chooseName(){
let eachName = names[Math.floor(Math.random() * names.length)];
para.textContent = eachName;
}