Skip to content

Instantly share code, notes, and snippets.

View mmaous's full-sized avatar
💻
Focused

Mhand mmaous

💻
Focused
View GitHub Profile
@mmaous
mmaous / json2csv.py
Created April 25, 2024 15:40
A py script to convert JSON data to Excel (XLSX) and CSV formats, checking for duplicate IDs and exporting the data accordingly.
import pandas as pd
import json
# to detect duplicates
unique_key = 'id'
def check_duplicates(json_file):
# Read JSON file
with open(json_file, 'r') as file:
data = json.load(file)
@mmaous
mmaous / install_docker.sh
Last active July 18, 2024 17:29
Install Docker on a Debian-based system and configure Docker to run without sudo
#!/bin/bash
# Step 1: Installing Docker
# Update the package list
sudo apt update
# Install prerequisite packages
sudo apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
@mmaous
mmaous / react-select-styles.js
Last active February 24, 2023 14:35
React Select Ultimate Styles
export const defaultStyles = {
option: (provided, { isSelected, isDisabled, isFocused }) => ({
...provided,
...fontStyles,
top: 0,
color: isSelected ? '#F5F5F5' : '#000',
padding: '7px 8px',
backgroundColor: isSelected ? '#000' : isFocused ? '#00000040' : '#F5F5F5',
'&:last-child': {
borderRadius: '0 0 5px 5px',
@mmaous
mmaous / vscode-shortcuts.json
Created December 15, 2022 10:47
Keyboard shortcuts for Windows - Visual Studio Code
// Override key bindings by placing them into your key bindings file.
[
{ "key": "escape escape", "command": "workbench.action.exitZenMode",
"when": "inZenMode" },
{ "key": "shift+escape", "command": "closeReferenceSearch",
"when": "inReferenceSearchEditor && !config.editor.stablePeek" },
{ "key": "escape", "command": "closeReferenceSearch",
"when": "inReferenceSearchEditor && !config.editor.stablePeek" },
{ "key": "escape", "command": "editor.closeTestPeek",
"when": "testing.isInPeek && !config.editor.stablePeek || testing.isPeekVisible && !config.editor.stablePeek" },
@mmaous
mmaous / useMediaQuery.jsx
Created May 17, 2022 15:01
Easily retrieve media dimensions with this Hook React which also works onResize.
import { useState, useEffect } from "react";
const useMediaQuery = (query) => {
const [matches, setMatches] = useState(false);
useEffect(() => {
const media = window.matchMedia(query);
if (media.matches !== matches) {
setMatches(media.matches);
}
@mmaous
mmaous / nprogress.jsx
Created May 17, 2022 13:35
nprogress component to use with Nextjs !
import Router from 'next/router';
import NProgress from 'nprogress';
import { useEffect } from 'react';
export const LoadingBar = () => {
useEffect(() => {
let timer = 0;
NProgress.configure({ showSpinner: false });
NProgress.done();
@mmaous
mmaous / convert-csv-to-json.js
Created May 16, 2022 13:02
Convert CSV data to JSON script
var csv = require('csv-parser')
var fs = require('fs')
var countries = []
fs.createReadStream('./data.csv')
.pipe(csv(['label', 'value']))
.on('data', function (data) {
if (data.label === 'label' && data.value === 'value') return
countries.push({ value: data.value, label: data.label })
@mmaous
mmaous / .eslintrc
Last active March 2, 2022 21:23
Linter for TS-node Projects
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"env": {
"node": true,
"es6": true
@mmaous
mmaous / .eslintrc.js
Last active February 27, 2022 15:53
Eslint for Reactjs Project!
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:react/recommended'],
parserOptions: {
ecmaFeatures: {
jsx: true,