Skip to content

Instantly share code, notes, and snippets.


Ben Awad benawad

View GitHub Profile
View init.vim
" Specify a directory for plugins
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'scrooloose/nerdtree'
"Plug 'tsony-tsonev/nerdtree-git-plugin'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
benawad / [slug].js
Created Mar 24, 2020
ssg + mdx next.js
View [slug].js
import fs from "fs";
import MDX from "@mdx-js/runtime";
import ReactDOM from "react-dom/server";
import path from "path";
const Post = ({ post }) => {
return <div dangerouslySetInnerHTML={{ __html: post }} />;
export async function getStaticPaths() {
View uploadImageStream.ts
import * as Sentry from "@sentry/node";
import imagemin from "imagemin";
import mozjpeg from "imagemin-mozjpeg";
import sharp from "sharp";
import isJpg from "is-jpg";
import * as aws from "aws-sdk";
import { Upload } from "../../types/graphqlUtils";
import { generateFilename } from "./generateFilename";
export const s3 = new aws.S3({
View coc-settings.json
"suggest.noselect": false,
"coc.preferences.formatOnSaveFiletypes": [
View TodoList.jsx
import React from "react";
import TodoForm from "./TodoForm";
import Todo from "./Todo";
1. add todo
2. display todos
3. cross off todo
4. show number of active todos
View hashTable.js
function hashStringToInt(s, tableSize) {
let hash = 17;
for (let i = 0; i < s.length; i++) {
hash = (13 * hash * s.charCodeAt(i)) % tableSize;
return hash;
View typescriptreact.json
// Place your snippets for typescriptreact here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Typescript React PureComponent": {
"prefix": "rpc",
"body": [
"import * as React from 'react'",
View beginner-tutorial.sql
-- code for
create table users (
id serial primary key,
first_name varchar(255) not null,
last_name text,
age int,
email text unique not null
View .eslintrc.js
module.exports = {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
extends: [
"plugin:@typescript-eslint/recommended" // Uses the recommended rules from the @typescript-eslint/eslint-plugin
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: "module" // Allows for the use of imports
rules: {
View auto-accept-linkedin-conns.js
[...document.querySelectorAll('button.invitation-card__action-btn')].forEach(b => {
if (b.innerText === 'Accept') {