Skip to content

Instantly share code, notes, and snippets.

View HassanAlgoz's full-sized avatar

Hassan Algoz HassanAlgoz

View GitHub Profile
@HassanAlgoz
HassanAlgoz / virtualbox-debian-guest-additions.sh
Created May 23, 2022 16:29
Install VirtualBox Guest Additions
sudo apt-get install linux-headers-$(uname -r) build-essential dkms
VERSION=6.1.34
wget http://download.virtualbox.org/virtualbox/$VERSION/VBoxGuestAdditions_$VERSION.iso
sudo mkdir /media/VBoxGuestAdditions
sudo mount -o loop,ro VBoxGuestAdditions_$VERSION.iso /media/VBoxGuestAdditions
sudo sh /media/VBoxGuestAdditions/VBoxLinuxAdditions.run
rm VBoxGuestAdditions_$VERSION.iso
sudo umount /media/VBoxGuestAdditions
sudo rmdir /media/VBoxGuestAdditions
@HassanAlgoz
HassanAlgoz / filter-map-reduce.js
Last active April 7, 2018 12:28
Tutorial on JavaScript Array Methods: .filter .map .forEach and .reduce
// Arrow Functions
function isEven(number) {
return (number % 2 === 0);
}
let isEven = function (number) {
return (number % 2 === 0);
}
// drop the 'function' keyword, and append '=>' after function parameters
let isEven = (number) => {
return (number % 2 === 0);
const http = require('http')
// The `url` module splits up a web address into readable parts
const url = require('url')
http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/html'})
// url.parse() will return a URL object with each part of the address as properties
let urlObject = url.parse(req.url, true)
@HassanAlgoz
HassanAlgoz / nodejs-http-server.md
Created August 18, 2017 16:58
Part of a YouTube video tutorial

Node.js HTTP Server

YouTube Lesson by Hassan Algoz.

let http = require('http')

let server = http.createServer(function(req, res) {

    // req: methods and properties for request
    // res: method and properties for response

fetch is the modern equivalent to XMLHttpRequest. fetch uses promises.

A function that uses promises can chain .thens to allow for asynchronous flow that listens for when the task is completed, rather than wait.

// Callback Functions: passing functions to functions
function processArray(array, func) {
let resultArray = []
for(let i = 0; i < array.length; i++) {
resultArray[i] = func(array[i])
}
return resultArray
}
console.log('script-DOM.js') // DOM: Document Object Model
// Selection by Id
let title = document.getElementById("main-title")
title.innerHTML += " Hello World"; // Modifying Text
// Also Selection by Id, using CSS selectors
let subtitle = document.querySelector('#subtitle')
// The querySelector(string) is powerful in that you can
window.addEventListener('load', function() {
// Recursion and loops (repetition)
function greetings(str) {
console.log(str)
console.log(str)
console.log(str)
}
window.addEventListener('load', function() {
console.log("Hello from script.js")
// Functions
let a = Math.max(10, 43)
console.log( myMax(99, 45) )
console.log( myMin(34, 12) )
developer tools > console
4 + 5
9 * 2
12 / 4
2 ** 3
true && false
true || false
age = 19
name = "Hasssan"