Skip to content

Instantly share code, notes, and snippets.

View rachidelaid's full-sized avatar

rachid el aid rachidelaid

View GitHub Profile
@rachidelaid
rachidelaid / WebviewDownloadShare.jsx
Last active March 10, 2025 15:09 — forked from mshivam019/ScreenWebview.jsx
A feature rich webview for react native
import {useState, useEffect, useRef, useCallback} from 'react';
import {View,Text,BackHandler, Share as RNshare, Platform} from 'react-native';
import {WebView} from 'react-native-webview';
import {useRoute, useNavigation} from '@react-navigation/native';
import {useFocusEffect, useIsFocused} from '@react-navigation/native';
import Share from 'react-native-share';
import ReactNativeBlobUtil from 'react-native-blob-util';
import styled from 'styled-components/native';
import axios from 'axios';
import HeaderComponentWithBackButton from '../components/HeaderComponentWithBackButton';
function catAndMouse(x, y, z) {
const diffA = Math.abs(z-x);
const diffB = Math.abs(z-y);
if(diffA === diffB) return "Mouse C";
return diffA < diffB ? "Cat A" : "Cat B";
}
function saveThePrisoner(n, m, s) {
return (m%n+s-1)%n ? (m%n+s-1)%n : n
}
function angryProfessor(k, a) {
const onTimeStudents = a.filter(s => s <= 0).length
return onTimeStudents >= k ? "NO" : "YES"
}
@rachidelaid
rachidelaid / hike.js
Created May 10, 2022 07:24
this is an algo peoblem from hacker rank
/*
this is an algo peoblem from hacker rank https://www.hackerrank.com/challenges/counting-valleys/problem?isFullScreen=true
*/
function countingValleys(steps, path) {
let count = 0;
let level = 0;
path.split("").forEach(unit => {
if(unit === "D") {
@rachidelaid
rachidelaid / drawing_book.js
Created May 3, 2022 07:37
drawing book hackerrank
/*
https://www.hackerrank.com/challenges/drawing-book/problem?isFullScreen=true
Given and , find and print the minimum number of pages that must be turned in order to arrive at page .
*/
function pageCount(n, p) {
let index = 0;
const chunks = [];
const arr = [...Array(n + 1).keys()];
for (let i = 0; i < arr.length; i += 2) {
function jumpingOnClouds(c, k) {
let index = 0;
let energy = 100;
let stop = false;
while (!stop) {
if (c[index] === 1) {
energy -= 2;
}
@rachidelaid
rachidelaid / jest.config.js
Created January 19, 2022 13:06 — forked from johno/jest.config.js
Mock localStorage with Jest for React testing
module.exports = {
testPathIgnorePatterns: ['<rootDir>/.next/', '<rootDir>/node_modules/'],
setupFiles: ['./test-setup.js']
}
@rachidelaid
rachidelaid / exemple-1.md
Created January 17, 2022 13:08
Is it DRY? Exercise
const pets = ['Cat', 'Dog', 'Bird', 'Fish', 'Frog', 'Hamster', 'Pig', 'Horse' 'Lion', 'Dragon'];
// Print all pets
console.log(pets[0]);
console.log(pets[1]);
console.log(pets[2]);
console.log(pets[3]);
...

This block of code is not DRY.

@rachidelaid
rachidelaid / gist:17b4f8da5bf366edbd6debdd383c0481
Created June 20, 2021 12:52 — forked from su-v/gist:9965739
Inkscape / SVG on GitHub