Skip to content

Instantly share code, notes, and snippets.

View anthonyattard's full-sized avatar
📡
building...

Anthony Attard anthonyattard

📡
building...
View GitHub Profile
@anthonyattard
anthonyattard / README-Template.md
Last active August 13, 2019 10:30 — forked from PurpleBooth/README-Template.md
Good README/Markdown Template

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@anthonyattard
anthonyattard / View File Permissions with Code.md
Last active August 13, 2019 10:28
View File Permissions with Code

stat -f "%N %OLp" *

@anthonyattard
anthonyattard / Keeping a fork up to date.md
Created April 24, 2018 09:02 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@anthonyattard
anthonyattard / two-pointer-container-with-most-water.md
Last active August 13, 2019 09:26
Two Pointer - Container with Most Water

Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. From https://leetcode.com/problems/container-with-most-water/

Algorithm

The intuition behind this approach is that the area formed between the lines will always be limited by the height of the shorter line. Further, the farther the lines, the more will be the area obtained.

We take two pointers, one at the beginning and one at the end of the array constituting the length of the lines. Futher, we maintain a variable maxarea to store the maximum area obtained till now. At every step, we find out the area formed between them, update maxarea and move the pointer pointing to the shorter line towards the other end by one step.

How this approach works?

@anthonyattard
anthonyattard / waitForKeyElements.js
Last active July 7, 2020 23:05
waitForKeyElements.js
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);