Skip to content

Instantly share code, notes, and snippets.

View jaouadballat's full-sized avatar
🏠
Working from home

Jaouad Ballat jaouadballat

🏠
Working from home
View GitHub Profile
@jaouadballat
jaouadballat / !NOTE.md
Created September 13, 2020 00:17 — forked from ivanvermeyen/!NOTE.md
Setup a Laravel Storage driver with Google Drive API
function omit(object, fields) {
const shallowObject = Object.assign({}, object);
if (typeof fields === Array) {
fields.forEach(field => {
if (!!shallowObject[field]) delete shallowObject[field];
});
return shallowObject;
} else if (typeof fields === "string") return delete shallowObject[fields];
else throw new Error(`fields ${fields} must be array or string`);
}
<? php
public function validate($startDate, $endDate) {
$rules = [
'startDate' => 'date_format:Y-m-d',
'endDate' => 'date_format:Y-m-d',
];
$validator = Validator::make(['startDate' => $startDate, 'endDate' => $endDate], $rules);
if ($validator->fails()) {
class Draggable {
constructor() {
this.container = document.querySelector('.box__dragabble');
this.box = document.querySelectorAll('.box');
this._addEventListener();
}
_addEventListener() {
import React, { useEffect, useState } from 'react';
import Bus from '../Utils/Bus';
import './index.css';
export const Flash = () => {
let [visibility, setVisibility] = useState(false);
let [message, setMessage] = useState('');
let [type, setType] = useState('');
import React, { useEffect, useState } from 'react';
import './index.css';
export const Flash = () => {
let [visibility, setVisibility] = useState(false);
let [message, setMessage] = useState('');
let [type, setType] = useState('');
Route::get('preview-emails', function () {
$message = (new \App\Notifications\Order\NewOrderNotification(\App\Order::first()))->toMail('[email protected]');
return $message->render();
});
var express = require('express');
var router = express.Router();
const User = require('../models/user');
/* GET users listing. */
router.post('/', function(req, res, next) {
const user = new User({
email: req.body.email,
UserSchema.pre('save', function(next) {
let user = this;
if(!user.isModified('password')) return next(); //password has not modified
bcrypt.genSalt(10, function (err, salt) {
bcrypt.hash(user.password, salt, function (err, hash) {
if(err) return next(err);
user.password = hash;
next();
});
});
const express = require('express');
const app = express();
const server = app.listen(3001, function() {
console.log('server running on port 3001');