Skip to content

Instantly share code, notes, and snippets.

View AhmedKorim's full-sized avatar

Ahmed Korim AhmedKorim

View GitHub Profile
window.onload = function () {
if (typeof history.pushState === "function") {
history.pushState("jibberish", null, null);
window.onpopstate = function () {
history.pushState('newjibberish', null, null);
// Handle the back (or forward) buttons here
// Will NOT handle refresh, use onbeforeunload for this.
};
}
else {
<?php
DEFINE('DB_USER', 'root');
DEFINE('DB_PASSWORD', 'root');
DEFINE('DB_HOST', 'localhost');
DEFINE('DB_NAME', 'minor_shopping_cart');
function db_connect() {
$connection = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, "3306");
return $connection;
}
export enum Industries {
INDUSTRY = 'INDUSTRY',
ACCOUNTING = 'ACCOUNTING',
AIRLINES_OR_AVIATION = 'AIRLINES/AVIATION',
ALTERNATIVE_DISPUTE_RESOLUTION = 'ALTERNATIVE_DISPUTE_RESOLUTION',
ALTERNATIVE_MEDICINE = 'ALTERNATIVE_MEDICINE',
ANIMATION = 'ANIMATION',
APPAREL_OR_FASHION = 'APPAREL/FASHION',
ARCHITECTURE_OR_PLANNING = 'ARCHITECTURE/PLANNING',
ARTS_OR_CRAFTS = 'ARTS/CRAFTS',
@AhmedKorim
AhmedKorim / entity-editor-draft-js-example.markdown
Created September 17, 2019 01:05
Entity Editor - Draft.js example
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { CSSTransition } from "react-transition-group";
import logo from '../../image/logo.png';
import menuIcon from '../../image/menu-button.svg';
import './Topbar.scss';
import Sidebar from './Sidebar';
class Topbar extends Component {
state = {
@AhmedKorim
AhmedKorim / PromisAllWithFails.js
Created April 30, 2019 09:44 — forked from nhagen/PromisAllWithFails.js
Wait until all promises have completed even when some reject, with Promise.all
var a = ["sdfdf", "http://oooooolol"],
handleNetErr = function(e) { return e };
Promise.all(fetch('sdfdsf').catch(handleNetErr), fetch('http://invalidurl').catch(handleNetErr))
.then(function(sdf, invalid) {
console.log(sdf, invalid) // [Response, TypeError]
})
.catch(function(err) {
console.log(err);
})
const url = 'https://reqres.in/api/users';
// لعرض الصفحة
const getPages = '?page=';
// declare Element
const render = document.getElementById('render'),
title = document.getElementById('title');
function load (pageNum){
let xReq = new XMLHttpRequest();
@AhmedKorim
AhmedKorim / RippleKeyFrames.scss
Created November 18, 2018 17:28
ripple effect keyframes
// key frames
// ripple
@function number($value) {
@if type-of($value) == 'number' {
@return $value;
} @else if type-of($value) != 'string' {
$_: log('Value for `to-number` should be a number or a string.');
@AhmedKorim
AhmedKorim / mongoose-cheatsheet.md
Created October 25, 2018 13:15 — forked from subfuzion/mongoose-cheatsheet.md
mongoose cheatsheet

Definitely not comprehensive. This is meant to be a basic memory aid with links to get more details. I'll add to it over time.

Install

$ npm install mongoose --save

Connect

const mongoose = require('mongoose');
// select database path => mongod --dbpath=<dbpath>