Skip to content

Instantly share code, notes, and snippets.

View ammarnajjar's full-sized avatar

Ammar Najjar ammarnajjar

View GitHub Profile
@ammarnajjar
ammarnajjar / plugins.yaml
Last active March 28, 2024 15:01
k9s plugin to pretty print json logs using jq
# $XDG_CONFIG_HOME/k9s/plugins.yaml
plugins:
jqlogs:
shortCut: Ctrl-J
confirm: false
description: "Logs (jq)"
scopes:
- pod
command: sh
background: false
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dNOPAUSE -dQUIET -dBATCH -dPrinted=false -sOutputFile=foo-compressed.pdf foo.pdf
@ammarnajjar
ammarnajjar / yml-envs.sh
Created October 12, 2022 08:00
parse yml to envs and source it in the running shell
# requires python3
# replace <path>
source <(python <<EOF
with open('<path>', 'r') as fi:
content = fi.readlines()
trans = [line.strip().replace(': ', '=').replace('\'', '"') for line in content if line.strip() and line.strip()[0] != '#']
envs = '\n'.join([f'export {line}' for line in trans])
print(envs)
EOF
@ammarnajjar
ammarnajjar / git-cheat-sheet.sh
Last active April 24, 2022 15:19
My git cheat sheet
# set user name
git config --global user.name "Ammar Najjar"
# set user email
git config --local user.email <email>
# set user sign key -S
git config --local user.signingkey <key>
# current branch name
@ammarnajjar
ammarnajjar / custom_prompt.bash
Created April 15, 2022 21:27
Custom prompt (left and right) for bash
RED='\033[0;31m'
YELLOW='\033[0;33m'
LIGHT_GREEN='\033[0;32m'
LIGHT_GRAY='\033[0;37m'
NORMAL='\033[0m'
function prompt_right() {
echo -e "${LIGHT_GRAY}\\\t${NORMAL}"
}
@ammarnajjar
ammarnajjar / picked.ts
Last active February 10, 2022 10:10
create a typescript type that excludes everything but specific sub-type
interface SeatingGroup {
id: string;
name: string;
freeSeats: number;
}
interface Customer {
id: number;
name: string;
tag: string;
-- => Header ---------------------- {{{
-- Fie: init.lua
-- Author: Ammar Najjar <najjarammar@protonmail.com>
-- Description: My neovim lua configurations file
-- }}}
-- => General ---------------------- {{{
--- Change leader key to ,
vim.g.mapleader = ','
local editor_root=vim.fn.expand("~/.config/nvim/")
@ammarnajjar
ammarnajjar / github_graphql.py
Created April 21, 2020 00:08
compare github API v3 (rest) VS v4 (grapghql)
import os
from gql import Client
from gql import gql
from gql.transport.requests import RequestsHTTPTransport
from typing import Any
from typing import Dict
@ammarnajjar
ammarnajjar / original.jsx
Created November 24, 2019 19:21
use Array.map instead of crap
render() {
return (
<div>
<div className="board-row">
{this.renderSquare(0)}
{this.renderSquare(1)}
{this.renderSquare(2)}
</div>
<div className="board-row">
{this.renderSquare(3)}
@ammarnajjar
ammarnajjar / .vcmrc
Created October 23, 2019 10:07
validate commit-msg hook using husky
{
"types": [
"feat",
"fix",
"docs",
"style",
"refactor",
"perf",
"test",
"build",