Skip to content

Instantly share code, notes, and snippets.

@zahra-ove
zahra-ove / UploadController.php
Last active March 11, 2022 13:28
Upload Image via Ajax with FileReader() API
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
class UploadController extends Controller
{
public function showForm()
@zahra-ove
zahra-ove / UploadController.php
Created March 11, 2022 17:23
How to upload multiple images via ajax
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
class UploadController extends Controller
{
public function showForm()
// create h1 element and append it to root element that already exists in the dom
const h = document.createElement("h1");
h.textContent = "some dummy text";
h.className = "header";
document.getElementById("root").append(h);
=======================
// note1:
// React is declarative programming.
// vanilla javascript is imperative programming.
====================================================================================
// note2:
// JSX: javascript xml
// it means flavor of javascript that lookes alike html.
====================================================================================
// note3:
All javascript notes:
1. this article is awesome. it is about two types of variables in javascript:
- primitive variables
- reference variables
link: https://www.javascripttutorial.net/javascript-primitive-vs-reference-values/
Summary
Javascript has two types of values: primitive values and reference values.
in js:
function makeDoggy(e) {
e.target.setAttribute('src', 'https://content.codecademy.com/courses/React/react_photo-puppy.jpeg');
e.target.setAttribute('alt', 'doggy');
}
in html:

note1: form-data vs x-www-form-urlencoded

These are different Form content types defined by W3C. If you want to send simple text/ ASCII data, then x-www-form-urlencoded will work. This is the default. But if you have to send non-ASCII text or large binary data, the form-data is for that. link

note2: What is a Service?

Service is a very loaded term in computer programming that has all sorts of different meanings and connotations depending on the context you are using it in.

A Service in Domain Driven Design is simply a stateless object that performs an action.

note1:

//Equality comparisons
if (strpos('testing', 'test')) {    // 'test' is found at position 0, which is interpreted as the boolean 'false'
    // code...
}

// vs. strict comparisons
if (strpos('testing', 'test') !== false) {    // true, as strict comparison was made (0 !== false)
 // code...

Process Oriented Programming NOTES:

note1:

process-oriented programming can be defined as a paradigm in which the process structure and communication between processes of a system are the primary concerns. link

note2:

Workflow Engine vs Business Rules Engine

to show list of all dependencies in a laravel app:

composer show --tree
composer show --tree | grep wrokflow