Skip to content

Instantly share code, notes, and snippets.

@miladd3
miladd3 / remCalc.ts
Last active July 9, 2025 17:41
Javascript px to Rem function
/**
* Converts pixel size to rem and accepts the base as second argument. default base is 16px
*
* @param {number|string} px
* @param {number} base
* @return {string}
*/
const remCalc = (px: number | string, base: number = 16) => {
const tempPx = `${px}`.replace('px', '')
@Aebrathia
Aebrathia / PrivateRoute.js
Created June 14, 2018 15:58
React Router PrivateRoute connected component and unit testing with Jest
import React from 'react';
import { Route, Redirect, withRouter } from 'react-router';
import { connect } from 'react-redux';
import Proptypes from 'prop-types';
export const PrivateRoute = ({ component: Component, isAuthenticated, ...rest }) => (
<Route
{...rest}
render={props => (
isAuthenticated
@joseluisq
joseluisq / stash_dropped.md
Last active March 18, 2025 14:49
How to recover a dropped stash in Git?

How to recover a dropped stash in Git?

1. Find the stash commits

git log --graph --oneline --decorate ( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

This will show you all the commits at the tips of your commit graph which are no longer referenced from any branch or tag – every lost commit, including every stash commit you’ve ever created, will be somewhere in that graph.

@mofesolapaul
mofesolapaul / nigeria-states.json
Last active May 26, 2025 10:13
List of all Nigerian states, alphabetically arranged in JSON array
[
"Abia",
"Adamawa",
"Akwa Ibom",
"Anambra",
"Bauchi",
"Bayelsa",
"Benue",
"Borno",
"Cross River",
@pascaldevink
pascaldevink / scrollspy.js
Created April 13, 2012 20:53
ScrollSpy in pure javascript
/*
Copyright (C) 2021 Pascal de Vink (Tweakers.net)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"