Skip to content

Instantly share code, notes, and snippets.

@medaminefh
medaminefh / shell.sh
Created March 26, 2023 13:33
List npm packages globally & locally
npm list -g # this will list all your npm packages installed globally
npm list # this will list all your npm packages installed locally (in node project)
@medaminefh
medaminefh / index.html
Created October 27, 2021 20:58 — forked from sethbergman/index.html
Medium clap effect
<button id="clap" class="clap">
<span>
<!-- SVG Created by Luis Durazo from the Noun Project -->
<svg id="clap--icon" xmlns="http://www.w3.org/2000/svg" viewBox="-549 338 100.1 125">
<path d="M-471.2 366.8c1.2 1.1 1.9 2.6 2.3 4.1.4-.3.8-.5 1.2-.7 1-1.9.7-4.3-1-5.9-2-1.9-5.2-1.9-7.2.1l-.2.2c1.8.1 3.6.9 4.9 2.2zm-28.8 14c.4.9.7 1.9.8 3.1l16.5-16.9c.6-.6 1.4-1.1 2.1-1.5 1-1.9.7-4.4-.9-6-2-1.9-5.2-1.9-7.2.1l-15.5 15.9c2.3 2.2 3.1 3 4.2 5.3zm-38.9 39.7c-.1-8.9 3.2-17.2 9.4-23.6l18.6-19c.7-2 .5-4.1-.1-5.3-.8-1.8-1.3-2.3-3.6-4.5l-20.9 21.4c-10.6 10.8-11.2 27.6-2.3 39.3-.6-2.6-1-5.4-1.1-8.3z"/>
<path d="M-527.2 399.1l20.9-21.4c2.2 2.2 2.7 2.6 3.5 4.5.8 1.8 1 5.4-1.6 8l-11.8 12.2c-.5.5-.4 1.2 0 1.7.5.5 1.2.5 1.7 0l34-35c1.9-2 5.2-2.1 7.2-.1 2 1.9 2 5.2.1 7.2l-24.7 25.3c-.5.5-.4 1.2 0 1.7.5.5 1.2.5 1.7 0l28.5-29.3c2-2 5.2-2 7.1-.1 2 1.9 2 5.1.1 7.1l-28.5 29.3c-.5.5-.4 1.2 0 1.7.5.5 1.2.4 1.7 0l24.7-25.3c1.9-2 5.1-2.1 7.1-.1 2 1.9 2 5.2.1 7.2l-24.7 25.3c-.5.5-.4 1.2 0 1.7.5.5 1.2.5 1.7 0l14.6-15c2-2 5.2-
@medaminefh
medaminefh / flat.js
Created September 5, 2021 13:35
create a one-dimensional array from a multidimensional array in Javascript
['Dog', ['Sheep', 'Wolf']].flat()
//[ 'Dog', 'Sheep', 'Wolf' ]
/*By default it only "flats" up to one level, but you can add a parameter to set the number of
levels you want to flat the array to. Set it to
Infinity
to have unlimited levels:
*/
['Dog', ['Sheep', ['Wolf']]].flat()
@medaminefh
medaminefh / class.py
Created September 5, 2021 10:05
class properties in Python
class Animal:
def __init__(self,name,age):
self.name = name
self.age = age
@property
def whoami(self):
print(f"Hello There, My name is {self.name} and i'm {self.age} years old")
# create an instance
@medaminefh
medaminefh / samplerest.js
Created July 17, 2021 21:21 — forked from joshbirk/samplerest.js
Sample of using passport w/ mult strategies
var fs = require("fs")
var ssl_options = {
key: fs.readFileSync('privatekey.pem'),
cert: fs.readFileSync('certificate.pem')
};
var port = process.env.PORT || 3000;
var express = require('express');
var ejs = require('ejs');
var passport = require('passport')
@medaminefh
medaminefh / index.js
Created May 28, 2021 09:46
Prevent the Form from reloading the page when submitting
const form = document.querySelector("#myForm");
form.addEventListener("submit", (event) => {
// this line will prevent the default behavior of that event
event.preventDefault();
});
@medaminefh
medaminefh / .js
Created January 17, 2021 18:37
Create an Arrow function in JS
const a = () => {
return 'hello world'
}
// or simply
const a = () => 'hello world'