Skip to content

Instantly share code, notes, and snippets.

View hemedani's full-sized avatar
📿

SydAmir hemedani

📿
View GitHub Profile
@hemedani
hemedani / 07-arrNumber.js
Created November 2, 2022 07:01
create number from an array
const arr = [5, 6, 5, 4, 7, 8];
const nums = arr.reduce(
(current, next) => (current * 10) + next,
0,
);
console.log("the final number is ", nums);
@hemedani
hemedani / 06-arrNumber.js
Last active November 2, 2022 06:58
create number from an array
const arr = [5, 6, 5, 4, 7, 8];
const nums = eval(arr.map((number, index, arr) => number * 10 ** (arr.length - 1 - index)).join("+"));
console.log("the final number is ", nums);
@hemedani
hemedani / 05-arrNumber.js
Created November 2, 2022 06:03
create number from an array
const arr = [5, 6, 5, 4, 7, 8];
const nums = arr.map((number, index, arr) => number * 10 ** (arr.length - 1 - index));
console.log("the final number is ", nums);
@hemedani
hemedani / 04-arrNumber.js
Last active November 2, 2022 05:42
create number from an array
const arr = [5, 6, 5, 4, 7, 8];
let nums = 0;
for (let i = 0; i < arr.length; i++) {
nums = nums * 10 + arr[i];
}
console.log("the final number is ", nums);
@hemedani
hemedani / 01-arrNumber.js
Last active November 1, 2022 18:51
create number from an array
const arr = [5, 6, 5, 4, 7, 8];
console.log(
"we should get back this number : 565478 :"
);
@hemedani
hemedani / config.fish
Created August 6, 2022 16:13
nice header for fish shell
fish_vi_key_bindings
function fish_greeting
echo ⠀(set_color yellow)⠀⠀⣤⣤⠀⠀(set_color normal)⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀
echo ⠀(set_color yellow)⠀⠀⣿⣿⠀(set_color red)⠀⠀⣀⣀⡀⠀⣀⣀⠀(set_color normal)⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣤⣄⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
echo ⠀(set_color yellow)⠀⠀⢸⣿⠀(set_color red)⠀⣾⣿⣿⣿⣾⣿⣿⣷⠀⠀(set_color normal)⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣴⣿⣿⡿⠏⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠁⠀⠀⠀⣰⣶⡀⠀⠀⠀⠀
echo ⠀(set_color yellow)⠀⠀⢸⣿⠀(set_color red)⠀⠻⣿⣿⣿⣿⣿⣿⡿⠀⠀(set_color normal)⠀⢰⣶⣶⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣶⣿⣿⣿⠟⠋⠀⠀⠀⠀⠀⣠⣶⣿⣿⠀⠸⣿⣿⣷⣶⣶⣿⣿⡿⠀⠀⠀⠀⠀
echo ⠀(set_color yellow)⠀⠀⣠⣤⠀⠀(set_color red)⠀⠙⢿⣿⣿⡿⠋⠀⠀⠀⠀(set_color normal)⠀⠻⢿⣿⣿⣿⣿⣿⣷⣶⣾⣿⣿⣿⣿⣿⡿⠟⠉⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⠟⠉⠀⠀⠙⠻⠿⠿⠿⠟⣋⣀⣤⣄⡀⠀⠀
echo ⠀(set_color yellow)⠀⠀⠈⠉⠀⠀(set_color red)⠀⠀⠀⢻⡟⠁⠀⠀⠀⠀⠀(set_color normal)⠀⠀⠀⠈⠉⠛⠛⠻⠿⠿⠿⠛⠛⠋⠉⠀⠀⠀⠀⠀⠀⠀⢀⣠⣾⣿⡿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⢠⣾⣿⣿⠿⠿⠃⠀⠀
echo ⠀⠀⠀⠀⠀⠀⠀⠀(set_color red)⠀⠀⠀⠀⠀⠀⠀⠀(set_color normal)⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⡄⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡿⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠛⠉⠀⠀⠀⠀⠀⠀
@hemedani
hemedani / key_binding.ron
Created July 28, 2022 16:35
VIM like keybinding for GitUI
// bit for modifiers
// bits: 0 None
// bits: 1 SHIFT
// bits: 2 CONTROL
//
// Note:
// If the default key layout is lower case,
// and you want to use `Shift + q` to trigger the exit event,
// the setting should like this `exit: Some(( code: Char('Q'), modifiers: ( bits: 1,),)),`
// The Char should be upper case, and the shift modified bit should be set to 1.
@hemedani
hemedani / la.fish
Created July 28, 2022 16:02
list command with exa in fish shell
function la --wraps=ls --wraps=exa --description 'List contents of directory using exa tree'
exa --grid --icons -a --long --header --accessed --git $argv
end
@hemedani
hemedani / starship.toml
Created July 28, 2022 12:31
starship configuration
add_newline = true
[character]
vicmd_symbol = "[█](bold yellow) "
success_symbol = "[█](bold #CC59B0) "
error_symbol = "[█](bold red) "
format = """
[╔══════════════════════════════════════$symbol](fg:#CC59B0)
[╚═══╬▶▶](fg:#CC59B0) """
@hemedani
hemedani / wezterm.lua
Created June 16, 2022 11:51
my wezterm config
local wezterm = require("wezterm")
return {
font = wezterm.font_with_fallback({
"Cascadia Code Light",
"MesloLGS NF",
}),
font_size = 15,
-- color_scheme = "Batman",