Skip to content

Instantly share code, notes, and snippets.

View nire0510's full-sized avatar

Nir Elbaz nire0510

  • Holisto
View GitHub Profile
@nire0510
nire0510 / notion-rtl.user.js
Last active September 22, 2024 12:03
Userscripts for Tampermonkey and such
// ==UserScript==
// @name Notion RTL
// @namespace https://rtl.notion.so/
// @version 1.01
// @description RTL support for Notion web application
// @author Nir Elbaz
// @match https://www.notion.so/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=notion.so
// @grant none
// ==/UserScript==
@nire0510
nire0510 / Dockerfile
Created November 28, 2023 09:21
A Node.js dockerfile example
# Use an official Node.js runtime as the base image
FROM node:14
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000
# Create a work directory for the application
WORKDIR /app
@nire0510
nire0510 / split_csv.sh
Created July 17, 2023 13:29
Split large CSV file into smaller chunks
FILE=$1
BASENAME=`basename $FILE .csv`
ROWS=$2
echo Splitting $FILE into multiple files of $ROWS rows each...
# split to chunks:
split -l $ROWS -d $FILE $BASENAME\_
# append file extension:
for file in $(find $BASENAME\_*);
do mv $file $file.csv;
@nire0510
nire0510 / dom-toggle-selectors.json
Last active September 9, 2021 08:31
Common selectors for Dom-Toggle browser extension
[
{
"selector": ":not(.nH[role=main], .nH[role=main] *)",
"description": "Gmail's all elements, except emails list / email message",
"matches": ["*://*.google.com/mail/u/*/#inbox", "*://*.google.com/mail/u/*/#inbox/*"]
}
]
@nire0510
nire0510 / wait-until.js
Created April 18, 2018 11:41
Wait until condition is truthy and only then - proceed
/**
* Example of an async function which returns some value
*/
function doSomething() {
return new Promise((resolve, reject) => {
window.setTimeout(function () {
resolve(Math.random() > 0.8);
}, 1000);
});
}
@nire0510
nire0510 / npm-deps-scan.sh
Last active April 15, 2018 09:00
Scans all projects in a directory and generates a global npm & bower dependencies list
# npm-deps-scanner
# Scans all projects in a directory and generates a global npm & bower dependencies list.
# dependencies: jq, npm, json2csv
# extract all dependencies:
find ./*/{package,bower}.json | xargs cat | jq '(.dependencies + .devDependencies) | keys[]' | sort | uniq | tr -d '"' > npm-deps-scan-pname.txt
# fetch each package info and write to file:
echo "[" > npm-deps-scan-pinfo.json
while read f; do
@nire0510
nire0510 / readme.md
Created April 11, 2018 12:00
Check which kind of value is behind REDIS key
  • strlen KEY - if this works, it is a string
  • hlen KEY - if this works, it is a hash
  • llen KEY - if this works, it is a list
  • scard KEY - if this works, it is a set
  • zcard KEY - if this works, it is a sorted-set
@nire0510
nire0510 / distinct.js
Created April 4, 2018 12:17
Returns array which each of its elements appears only once
const arr = [1, 2, 2, 8, 5, 5, 3, 8, 3];
arr.sort().reduce((a, c) => {
if (a.includes(c)) {
return a;
}
a.push(c);
return a;
}, []);
@nire0510
nire0510 / get.js
Last active February 16, 2022 10:29
Naive implementation of lodash.get method
/**
* @property {object} object - The object to query
* @property {string} path - The path of the property to get
* @property {object} fallback - The default value to return if no value found in path
* @returns {*} Returns the resolved value (undefined / fallback value / value found).
*/
function get(object, path, fallback) {
const dot = path.indexOf('.');
if (object === undefined) {
@nire0510
nire0510 / index.js
Last active September 19, 2017 15:24
[Splice vs. Slice] #javascript
let a = [1, 2, 3, 4, 5, 6];
let b = [1, 2, 3, 4, 5, 6];
console.log('-- SLICE --');
console.log('- Returns values which were removed');
console.log('- Does not change the original array');
console.log(a.slice(0, 2));
console.log(a);
console.log();