Skip to content

Instantly share code, notes, and snippets.

@NitsanBaleli
NitsanBaleli / enum-alternative.ts
Created June 30, 2021 07:03
typescript enum alternative
//https://stackoverflow.com/a/60041791/2460773
//https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums
export const mapConsumptionActiveMapType = {
elevation: "map",
orthomosaic: "elevation",
model_3d: "3d model",
} as const;
export type MapConsumptionActiveMapType = keyof typeof mapConsumptionActiveMapType;
import * as React from "react";
import { useState, useMemo, Dispatch, SetStateAction } from "react";
type IContext<T> = [T, Dispatch<SetStateAction<T>>];
type ProviderProps<T> = { initialValue: T; children: React.ReactNode };
export function makeStore<T>(): [
(props: ProviderProps<T>) => React.ReactElement,
() => IContext<T>
] {
// Make a context for the store
const context = React.createContext<IContext<T>>(null);
@NitsanBaleli
NitsanBaleli / machine.js
Created October 8, 2020 12:12
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@mixin equilateral-triangle($direction, $size, $color) {
width: 0;
height: 0;
@if $direction == 'up' {
border-left: em($size) solid transparent;
border-right: em($size) solid transparent;
border-bottom: em($size) solid $color;
}
@else if $direction == 'down' {
border-left: em($size) solid transparent;
const fs = require('fs');
const path = require('path');
const allFilesSync = (dir, fileList = [], prefix = '') => {
fs.readdirSync(dir).forEach(file => {
const filePath = path.join(dir, file)
fileList.push(
fs.statSync(filePath).isDirectory()
? {file: allFilesSync(filePath, undefined, file)}
@NitsanBaleli
NitsanBaleli / emails.js
Last active February 6, 2018 13:15
Loop ajax requests with Rxjs
var array = ["[email protected]", "[email protected]"];
const emails = () => array;
module.exports = emails;
@NitsanBaleli
NitsanBaleli / wireless
Last active August 29, 2015 14:06
TP-LINK TL-WN821Nv4
Ensure you have the necessary prerequisites installed:
sudo apt-get install linux-headers-generic build-essential dkms
Clone this repository:
git clone https://github.com/pvaret/rtl8192cu-fixes.git
Set it up as a DKMS module:
sudo dkms add ./rtl8192cu-fixes
Build and install it:
@NitsanBaleli
NitsanBaleli / fresh
Last active July 19, 2016 21:20
fresh install
sudo apt-get update && sudo apt-get upgrade
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
sudo apt-get update
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo add-apt-repository ppa:olivier-berten/misc
@NitsanBaleli
NitsanBaleli / .zshrc
Last active March 27, 2022 12:10
.zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
#ZSH_THEME="cobalt2"
ZSH_THEME="robbyrussell"
#ZSH_THEME="af-magic"
@NitsanBaleli
NitsanBaleli / .bash_history.bash
Last active February 22, 2021 07:43
.bash_history
sudo apt-get update
sudo apt-get install -y guake git curl g++ zsh vim build-essentia
//---------------------zsh guake etc..
---------------------------------------------------------------------------------
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
sudo chsh -s $(which zsh) $USER
git clone https://github.com/rupa/z.git ~/z
curl -L "https://raw.githubusercontent.com/NitsanBaleli/Linux-env/master/zsh/.zshrc" > ~/.zshrc