Skip to content

Instantly share code, notes, and snippets.

View ammarnajjar's full-sized avatar

Ammar Najjar ammarnajjar

View GitHub Profile
customObservable({
next: val => console.log(val),
error: err => console.error(err),
complete: () => console.log('Completed')
});
@ammarnajjar
ammarnajjar / main-args.py
Last active March 14, 2019 06:41
fetch-gitlab-using-api
#!/usr/local/bin/python3.7
"""
Clone/fetch projects from Gitlab using the private token
"""
import argparse
from os import path
import json
import subprocess
import shlex
@ammarnajjar
ammarnajjar / rm_duplicates.sh
Created September 17, 2019 11:22
remove duplicates from PATH
# remove duplicates from PATH
# order in reverse as well
export PATH=$(echo -n $PATH | awk -v RS=: '{print}' | sort -r | awk '!($0 in a) {a[$0]; printf("%s%s", length(a) > 1 ? ":" : "", $0)}')
@ammarnajjar
ammarnajjar / .pre-commit-config.yml
Last active October 23, 2019 06:54
A collection of pre-commit hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- id: end-of-file-fixer
- id: mixed-line-ending
- id: check-docstring-first
- id: check-json
@ammarnajjar
ammarnajjar / .vcmrc
Created October 23, 2019 10:07
validate commit-msg hook using husky
{
"types": [
"feat",
"fix",
"docs",
"style",
"refactor",
"perf",
"test",
"build",
@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 / 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
-- => Header ---------------------- {{{
-- Fie: init.lua
-- Author: Ammar Najjar <[email protected]>
-- Description: My neovim lua configurations file
-- }}}
-- => General ---------------------- {{{
--- Change leader key to ,
vim.g.mapleader = ','
local editor_root=vim.fn.expand("~/.config/nvim/")
@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;
@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}"
}