Skip to content

Instantly share code, notes, and snippets.

View sajadtorkamani's full-sized avatar

Sajad Torkamani sajadtorkamani

View GitHub Profile
#!/usr/bin/env bash
# Copy type definitions
printf "%s\n\nexport = Schemas;" "$(cat src/types/schema.d.ts)" > packages/types/index.d.ts
# Bump version and publish
cd packages/types && \
npm version patch && \
npm publish
@sajadtorkamani
sajadtorkamani / check-envvars.js
Created November 5, 2019 00:21
Redundant node script to check envvars are set correctly.
const fs = require('fs');
const path = require('path');
const dotenv = require('dotenv');
const chalk = require('chalk');
/**
* Parse env file into object.
*
* @param {string} path - Absolute path to env file.
* @returns {object} - Object containing all env vars from file.
@sajadtorkamani
sajadtorkamani / check_ip.md
Last active October 10, 2018 07:37
Check IP address

curl icanhazip.com

@sajadtorkamani
sajadtorkamani / curl-pretty-print.md
Last active July 27, 2018 09:13
Pretty print CURL JSON output with jq

Install jq package

sudo apt-get install jq

Output all results

curl <url> | jq

Output only certain fields

curl <url> | jq '{<fieldA>, <fieldB>}'

Convert output to array

https://www.digitalocean.com/community/tutorials/how-to-set-up-password-authentication-with-apache-on-ubuntu-16-04
@sajadtorkamani
sajadtorkamani / rsync.md
Last active August 28, 2018 12:50
rsync

Simplest way

rsync -avz --progress <resource> <username>@<ip>:<destination>

Using AWS pem file

rsync -avL --progress -e "ssh -i ~/Downloads/AWS/WEB1/Keys/WEB1.pem" \
/var/www/html/eisa/wp-content/uploads/* \
ubuntu@<ip-address>:/var/www/eisa/wp-content/uploads/
@sajadtorkamani
sajadtorkamani / mysqldump.md
Last active August 28, 2018 12:55
Creating a mysql dump file
Dump database to file

mysqldump -u <username> -p <database> > <dump_filename>

Create database from dump file.
mysql> create database <db_name>;
use <db_name>;
source <absolute_path_to_dump_file>;
```
@sajadtorkamani
sajadtorkamani / vim_macros.md
Last active February 10, 2020 15:58
Recording and playing vim macro
# Record
q<number><commands>q

# Play
@<number><letter>
@sajadtorkamani
sajadtorkamani / process_on_port
Created June 2, 2018 11:23
Get process on particular port
sudo lsof -i :<port>
@sajadtorkamani
sajadtorkamani / and_in_regex.md
Last active April 29, 2017 11:14
AND in Regex

Called a look-ahead expression, we can use this to match multiple expressions:

Syntax:

(?=match this expression)(?=match this too)(?=oh, and this)

Example - match string containing the words 'ruby' and 'rails' (regardless of order of occurence):

"ruby rails".match(/(?=.*ruby)(?=.*rails)/)