Skip to content

Instantly share code, notes, and snippets.

View mohamedragaey's full-sized avatar

mohamed ragaey mohamedragaey

View GitHub Profile
/*
* There are 3 key problems with the React code below. Can you find them?
* Assume fetchUserProfile exists elsewhere.
*/
import {Suspense, useState, useEffect} from 'react'
const SuspensefulUserProfile = ({userId}) => {
const [data, setData] = useState({})
useEffect(() => {
fetchUserProfile(userId).then((profile) => setData(profile))
@mohamedragaey
mohamedragaey / git-pushing-multiple.rst
Created October 27, 2019 16:23 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

/*!
* classie - class helper functions
* from bonzo https://github.com/ded/bonzo
*
* classie.has( elem, 'my-class' ) -> true/false
* classie.add( elem, 'my-new-class' )
* classie.remove( elem, 'my-unwanted-class' )
* classie.toggle( elem, 'my-class' )
*/
@mohamedragaey
mohamedragaey / User welcome screen
Created September 26, 2018 16:40 — forked from smhatre59/User welcome screen
Screen to be displayed on first app launch
import React, { Component, PropTypes } from "react";
import {
AsyncStorage,
Modal,
View,
Text,
TouchableHighlight
} from "react-native";
import styles from "./styles/ftreScreenStyles";
export default class FtueScreen extends Component {
@mohamedragaey
mohamedragaey / index.html
Created May 31, 2018 11:57
Required labels
<div id="wrapper" class="page-wrapper">
<section class="content">
<form id="form">
<div class="form-group">
<label for="name">Name</label>
<input id="name" type="text" placeholder="Name" required />
</div>
<div class="form-group">
<label for="password">password</label>
<input id="password" type="password" placeholder="password" required />
@mohamedragaey
mohamedragaey / label-to-placeholder.js
Created May 30, 2018 11:22 — forked from makeusabrew/label-to-placeholder.js
Simple jQuery snippet to convert form labels into inline placeholders
$("form :input").each(function(index, elem) {
var eId = $(elem).attr("id");
var label = null;
if (eId && (label = $(elem).parents("form").find("label[for="+eId+"]")).length == 1) {
$(elem).attr("placeholder", $(label).html());
$(label).remove();
}
});
@mohamedragaey
mohamedragaey / 1-How-to-root-Redmi-Note-4.md
Last active May 29, 2018 23:30
A detailed guide for step by step to how to unlock, root your Xiaomi Redmi Note 4.

Detailed guide to Root Xiaomi Redmi Note4

Follow this guide and all things would be just fine.

####Brerquested

  • Unlock Bootloader
  • USB DATA cable (the one that came with your device)
  • Enable USB Debugging - Goto Settings > Additional settings > Developer options > USB Debugging - Enable (If you have not activated Developer options, then Goto Settings > About phone > tap MIUI version 7 times > You are now a developer)
  • Battery is charged at least 50%.
@mohamedragaey
mohamedragaey / bookmark.min.js
Created May 17, 2018 10:17 — forked from zaydek-old/bookmark.min.js
A simple CSS debugger. Learn more here: https://medium.freecodecamp.org/88529aa5a6a3. To use, bookmark "Debug CSS" at https://zaydek.github.io/debug.css
/* debug.css | MIT License | zaydek.github.com/debug.css */ if (!("is_debugging" in window)) { is_debugging = false; var debug_el = document.createElement("style"); debug_el.append(document.createTextNode(`*:not(path):not(g) { color: hsla(210, 100%, 100%, 0.9) !important; background: hsla(210, 100%, 50%, 0.5) !important; outline: solid 0.25rem hsla(210, 100%, 100%, 0.5) !important; box-shadow: none !important; }`)); } function enable_debugger() { if (!is_debugging) { document.head.appendChild(debug_el); is_debugging = true; } } function disable_debugger() { if (is_debugging) { document.head.removeChild(debug_el); is_debugging = false; } } !is_debugging ? enable_debugger() : disable_debugger();
@mohamedragaey
mohamedragaey / direction-check.js
Created May 9, 2018 16:02 — forked from navidkashani/direction-check.js
Check Page Direction and Return Object() for some related data
// Get Value(Sample) : dirCheck().start => 'left'
function dirCheck(dir) {
dir = dir || document.getElementsByTagName("HTML")[0].getAttribute("dir");
if (dir === 'rtl') {
return {
dir : 'rtl',
rtl : true,
ltr : false,
start : 'right',
end : 'left'
@mohamedragaey
mohamedragaey / linux-kali-install-wifi-drivers.sh
Created January 21, 2018 19:23 — forked from torresashjian/linux-kali-install-wifi-drivers.sh
How to install Broadcom BCM43142 Drivers on Kali Linux
apt-get update
apt-get install linux-image-$(uname -r|sed 's,[^-]*-[^-]*-,,') linux-headers-$(uname -r|sed 's,[^-]*-[^-]*-,,') broadcom-sta-dkms
modprobe -r b44 b43 b43legacy ssb brcmsmac bcma
modprobe wl