Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Mohammad Khanafi thekingofbandit

I may be slow to respond.
View GitHub Profile
thekingofbandit /
Created Jun 27, 2020 — forked from Kartones/
PostgreSQL command line cheatsheet


Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
thekingofbandit /
Created Jun 27, 2020 — forked from Kartones/
Imagemagick & ffmpeg commands


  • Nornalize all images of a folder converting them to jpgs with 90% quality (warning, removes original files):
rename 's/\.JPG$/\.jpg/' *.JPG
rename 's/\.JPEG$/\.jpg/' *.JPEG
rename 's/\.jpeg$/\.jpg/' *.jpeg
mogrify -format jpg *.png
mogrify -resize 1600x1280\> -quality 90 *.jpg
rm *.png
thekingofbandit / no-css
Created Jun 27, 2020 — forked from Kartones/no-css
Bookmark to remove all CSS, JS and iframesfrom a page. Just paste as new bookmark
View no-css
View request.js
* Axios Request Wrapper
* ---------------------
* @author Sheharyar Naseer (@sheharyarn)
* @license MIT
import axios from 'axios'
View index.html
<!DOCTYPE html>
<meta name="description" content="[push to chart data]">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src=""></script>

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.


JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and

thekingofbandit /
Created Sep 23, 2020 — forked from KartikTalwar/
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
View ReactClassComponentWithMethods.jsx
import React, { Component } from 'react';
import PropTypes from 'prop-types';
class reactClassComponentWIthMethods extends Component {
constructor(props) {
componentWillMount() {
View untrusted-lvl1-solution.js
* cellBlockA.js *
* Good morning, Dr. Eval.
* It wasn't easy, but I've managed to get your computer down
* to you. This system might be unfamiliar, but the underlying
* code is still JavaScript. Just like we predicted.
View configure multiple github accounts on the same

SSH keys


ssh-keygen -o

You can view the created files (one without extension and one with .pub) under ~/.ssh/. When creating several of them, you may want to rename them appropriately (e.g. work, pers...).

Add them

to the relevant github account:


The configuration file for ssh is usually not created by default so we create it: