Skip to content

Instantly share code, notes, and snippets.

Avatar

Adi Sahar adi518

View GitHub Profile
@adi518
adi518 / react-select-data-attributes.jsx
Created Aug 30, 2021 — forked from MikaelCarpenter/react-select-data-attributes.jsx
Solution for adding data attributes to a react-select component by passing in "custom components" where you've manipulated the innerProps prop
View react-select-data-attributes.jsx
import React, { Component } from 'react';
import ReactSelect, { components } from 'react-select';
const TextOption = props => (
components.Option && (
<components.Option { ...props }>
...
</components.Option>
)
);
@adi518
adi518 / hotkeys.js
Created Aug 25, 2021 — forked from abuduba/hotkeys.js
Hotkey library
View hotkeys.js
const isEqual = (a, b) => {
const aKeys = Object.keys(a);
if (aKeys.length !== Object.keys(b).length) {
return false;
}
return aKeys.every(
(k) => Object.prototype.hasOwnProperty.call(b, k)
&& a[k] === b[k],
@adi518
adi518 / index.html
Created Nov 3, 2020
`value => value` vs Boolean #jsbench #jsperf (https://jsbench.github.io/#04b0ae9d1a00327b88ff8c9a4c98abdb) #jsbench #jsperf
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>`value => value` vs Boolean #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
View ZMI-LPB02_ENGLISH_MANUAL.md

Battery Light Indicator

  • Green: 50-100%
  • Orange: 20-50%
  • Red: < 20%
@adi518
adi518 / matrixDigitalRain.js
Created Mar 31, 2020 — forked from danielt69/matrixDigitalRain.js
Matrix rain animation using HTML5 canvas and javascript
View matrixDigitalRain.js
// https://codepen.io/P3R0/pen/MwgoKv
var matrix = (function(){
var init = function() {
document.body.style.background = 'black';
var mdr = document.createElement('canvas');
mdr.id = "mdr";
mdr.style.display = 'block';
mdr.style.position = 'fixed';
mdr.style.top = '0';
mdr.style.left = '0';
View chrome-like-scrollbar.scss
--scrollbar-thumb-width: 9px; // bigger = smaller width
--scrollbar-thumb-margin: 3px;
--scrollbar-thumb-color: rgba(255, 255, 255, 0.25);
/* Chrome-like (mobile) scrollbar */
&::-webkit-scrollbar {
width: var(--scrollbar-thumb-width);
}
&::-webkit-scrollbar-thumb {
@adi518
adi518 / git-tag-delete-local-and-remote.sh
Last active Sep 14, 2021 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
View git-tag-delete-local-and-remote.sh
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@adi518
adi518 / README-Template.md
Created Feb 17, 2020 — forked from PurpleBooth/README-Template.md
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

View fibonacci_with_generators.js
function* fibonacci(limit = Infinity) {
let [prev, current] = [0, 1]
while (current < limit) {
;[prev, current] = [current, prev + current]
yield current
}
}
for (let i of fibonacci(30)) console.log(i)
@adi518
adi518 / consumer.js
Last active Oct 31, 2019
Higher-order React component for providing fallback content while server-dependent props are absent.
View consumer.js
// `MyComponent` depends on server-data, so it will render nothing
// or a fallback component until fetching is completed.
const withFallback = composeFallback(({ serverData }) => [serverData]);
export default withFallback(MyComponent);