Skip to content

Instantly share code, notes, and snippets.

View amElnagdy's full-sized avatar

Ahmed Mohammed Nagdy amElnagdy

View GitHub Profile
sudo dd iflag=direct if=/dev/sda of=/dev/null count=1
sudo /usr/libexec/oci-growfs
Run as sudo:
sudo -i
Update server:
yum update -y
aapanel install command:
yum install -y wget && wget -O install.sh http://www.aapanel.com/script/install_6.0_en.sh && bash install.sh
@amElnagdy
amElnagdy / useLocation.js
Created April 26, 2020 19:48
React reusable hook to get the user location
// To use it, import useLocation from useLocation and then const [lat, errorMessage] = useLocation();
import { useState, useEffect } from "react";
export default () => {
const [lat, setLat] = useState(null);
const [errorMessage, setErrorMessage] = useState("");
useEffect(() => {
window.navigator.geolocation.getCurrentPosition(
@amElnagdy
amElnagdy / useResources.js
Created April 26, 2020 19:42
React reusable hooks for fetching data from some API
import { useState, useEffect } from "react";
import axios from "axios";
const useResources = (resource) => {
const [resources, setResources] = useState([]);
useEffect(() => {
(async (resource) => {
const response = await axios.get(
`https://jsonplaceholder.typicode.com/${resource}`
);
setResources(response.data);
import React, { useState, useEffect } from "react";
function App() {
const [postList, setPostList] = useState([]);
const [currentPost, setCurrentPost] = useState(null);
const [isLoading, setIsLoading] = useState(false);
const [postClicked, setPostClicked] = useState(false);
const fetchPosts = () => {
fetch(`https://www.codeinwp.com/wp-json/wp/v2/posts?per_page=5`)
h1, h2, h3, h4, h5, h6 {
font-weight: 700;
font-family: 'Cairo', sans-serif;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 500;
font-family: 'Roboto', sans-serif;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: local(''),
url(../../uploads/fonts/Roboto-Light.woff) format('woff');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
@font-face {
font-family: 'Cairo';
font-style: normal;
font-weight: 400;
src: local(''),
url(../../uploads/fonts/Cairo-Regular.woff) format('woff');
}
@font-face {
font-family: 'Cairo';
font-style: normal;
<?php
/*
Plugin Name: Display Custom Id
Description: This plugin assigns a random custom id to each registered user, you can show your custom id by inserting a short code into your posts.
Author: Mahamad Sayed
*/
// generste random customer ID
function generate_custom_id (){
$new_id = rand(1, 1000);
return $new_id;