Skip to content

Instantly share code, notes, and snippets.

View back_button_override.js
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 {
View index.php
<?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;
}
View industries.enum.ts
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',
View Topbar.js
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 Apr 30, 2019 — forked from nhagen/PromisAllWithFails.js
Wait until all promises have completed even when some reject, with Promise.all
View PromisAllWithFails.js
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);
})
View app.js
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 Nov 18, 2018
ripple effect keyframes
View RippleKeyFrames.scss
// 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.');
View mongoose-cheatsheet.md

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');
View mongodb
// select database path => mongod --dbpath=<dbpath>