d
Amit DhamuSoftware Engineer

Snippets

274

javascript

Get object key based on value

typescript

Use as const to create union type

typescript

Chunking arrays

javascript

Sort an object

typescript

Human friendly file size

javascript

Overwrite console output in Node

javascript

Encode image as base64 using fetch

javascript

String to camelCase

python

Flatten a directory

css

3 ways to center a div

typescript

Convert roman numeral to number

javascript

Check if phrase is a palindrome

javascript

10 handy regular expressions

typescript

Recursively deep merging objects

shell

Flags in Bash with getopts

shell

Switch statement in Bash

javascript

Leading zeros with padStart

javascript

is_numeric

javascript

Scroll Into View With Offset

sql

Using string_agg in PostgreSQL

shell

Git Status Porcelain

testing

Spying on localStorage in Jest

testing

Advance Timers in Jest

typescript

Debounce

javascript

Omit property from object

typescript

Time of day greeting

react

Scroll Progress Bar Indicator

javascript

Unique values from array of objects

shell

Commit case changed filenames in Git

react

Smooth Scroll to Top

typescript

Read Time in minutes

typescript

Cartesian Product

javascript

Sharing with navigator.share

shell

Git status - files only

shell

Search in files and move to directory

javascript

Get domain without subdomain

javascript

Find a HTML Element With Text

shell

Create A Folder For Each File

javascript

Capitalize Word

misc

CTRL+CMD+DOWN in VSCode

css

Invert Images

javascript

Sort Array of Objects by Property

javascript

Write to a File in Node

php

Valid PHP Types

php

is_countable

php

Replacing MsSQL_ functions

php

Migrating from mysql_ to mysqli_

javascript

YYYY-MM-DD in Javascript

misc

List Available Makefile Commands

javascript

Generate Initials From String

misc

Restore macOS Desktop

misc

Delete Git Tag

misc

Prevent Safari Reopening Previous Session

python

Using argparse For Script Arguments

shell

Truncate A File

python

File Operations In Python

python

Loops In Python

shell

Bash - For Loop With Range

misc

Handy Docker Commands

misc

macOS - Get Serial Number

misc

Recent Items in macOS Dock

shell

Bash - If In Array

sql

Helpful mysqldump Commands

css

Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

Trim Whitespace Pixels with Imagemagick

shell

What's Using A Port

misc

Chrome (macOS) - Delete URL Suggestion

misc

Solr - Select Distinct Field

misc

Change Sublime Text 3 Title Bar Colour on macOS

misc

Test /etc/fstab

shell

Reformat A Hard Drive on Ubuntu

python

Write File Contents in Python

misc

Force Delete iCloud Account on macOS

shell

Step Through Commits On A Branch In Git

php

Case Insensitive Multi Dimensional Array Sort

javascript

Is Element Visible In Viewport

shell

Search For String In Files

misc

Pip - Install Specific Hash, Branch or Tag

misc

Plex Downloads API

misc

Eject Disc From CD/DVD Drive on Mac

shell

Generate LetsEncrypt SSL Certificate

shell

Update Plex From Command Line on Ubuntu

javascript

Upgrade Node From NPM

shell

Use Heredoc In Bash Script

javascript

Get List of NPM Packages

server

Redirect to https & non-www in NGINX

javascript

Escape HTML

javascript

Get Query Parameters

shell

Create Multiple Subdirectories At Once

css

Clear Button On Input Field

javascript

Redirect to HTTPS in Express

javascript

Strip Trailing Slashes From Express Requests

misc

Install VirtualBoxGuestAdditions In Ubuntu

shell

Recursively Find and Delete File

misc

Restart Plex From Command Line

misc

Install Ruby Gem Behind Proxy

misc

Hide Minified File Contents From Git History

shell

Search Occurrences In Between Two Strings

misc

Git - Change Remote Origin

php

Convert XML to Array

css

If Statements in SASS

shell

Watch Filesize On Command Line

html

Placeholder Image if Src Unavailable

shell

Get Number of Commits by Author in Git

shell

Temporarily Ignore File in Git

shell

Search Git Commit History

javascript

Social Media Share Counts

misc

Solr - Delete By Query

javascript

Default Parameter in Function

css

Generate Colour Classes in SASS

shell

Use Terminal Through Proxy

misc

Vim Commands

shell

Git Commands

shell

UNIX Commands

jquery

Insert Character At Position

php

MySQL to CSV Export

jquery

Check If Radio Button Has Been Checked

jquery

Open External Links In New Tab

misc

Use Browser As Notepad

sql

Get Date If After Interval

misc

Mac Recovery Tools

misc

Restart Mac In Safe Mode

php

Load Random Image From Directory

css

Fullscreen Styling

jquery

On The Fly Form With jQuery

javascript

Comma Separated String To Array

css

Make Images Black and White

shell

FTP Upload Using Command Prompt or Terminal

jquery

Wrap Element Around Other Element

php

Exif Image Data

misc

Add Close All To Sublime Text Tab Menu

php

Search Files Using glob()

php

Write To A Text File

shell

Handy Shell Commands (Windows)

javascript

Double Click Event

server

HTTP Authentication

jquery

Toggle Text Function

php

Useful Folder and File Functions in PHP

jquery

Select Nth Class of Element

jquery

Scroll To Bottom of Element

css

Pure CSS Speech Bubble

jquery

Implement Keyboard Shortcuts For Your Website

html

Favicon For Windows 8 Tile

php

Append To Text File

php

mysql_real_escape_string on Array

php

Autoload Class

php

Use An Array Recursively

javascript

Save Canvas as PNG

php

Detect AJAX Request in PHP

php

Ignore nl2br() Inside Pre/Code Tag

php

List System Drives - Windows Only

sql

Capitalise Field in Row

misc

Create A Lockscreen Shortcut in Windows

php

Remove File Extension

jquery

Self Executing Function

php

Social Bookmark Share Function

php

Recursive Directory Scanning

jquery

Get Mouse Coordinates

php

Get File Extension

css

Available List Style Types

css

Maintain Aspect Ratio

php

Check If Uppercase or Lowercase

php

Case Insensitive In Array Check

php

List System Drives

misc

Remove Empty Lines In SublimeText

php

CRUD Functions with PDO

php

Simple Select Query with PDO

misc

Query Fetch Types in PDO

php

PDO Database Connection

sql

Duplicate Table Into New Table

jquery

Scroll To Position

php

Cacheable Tweets

css

Mixins in LESS

css

Variables in LESS

php

Serialize and Unserialize Array

html

Viewport Meta Tag For Mobile

javascript

Prompt For User Input

css

Minify CSS On The Fly

php

cURL

jquery

Element Is Not

php

Specify Decimal Places

php

Page Last Modified

php

Add Month or Year to Date

javascript

OnClick Function

php

Embed Images With Data URIs

php

Conditional Vs Ternary

php

Loop Between Date Range

css

CSS3 Animation

css

CSS3 Transitions

sql

Return Row Count

jquery

Filter Table Results

css

Box Shadow

shell

Dividing The Dock In OSX

php

Remove Value From Array

jquery

Select Where Attribute Is

server

Set Timezone

jquery

FadeIn Image When Loaded

php

Leading Zeroes

jquery

Toggle Password Characters

php

Width and Height of SWF

sql

Add 1 To Number In Field

html

Get Site Favicon

javascript

HTML5 Desktop Notifications

php

Create an ICS file

css

Full Screen Background Image

css

CSS3 Attribute Selectors

php

Current File Name

php

Delete File From Server

php

Highlight Search Keyword

server

Force or remove www from URL

jquery

Check If Element Exists

css

Multiple Background

html

Phone and SMS Prefixes

sql

Date of Birth to Age

jquery

Disable Right Click Context Menu

css

Cross Browser Opacity

php

Flickr Photo Search API

server

Optimise Site Using DEFLATE

html

HTML5 Audio Tag

javascript

Popup Window

css

Target By Attribute

server

Error Document

html

Hide Broken Image Icon

javascript

Random Colour

php

Encode & Decode JSON

php

SimpleXML

css

Using RGBa

javascript

Detect CSS Property

jquery

Hover Animations

html

RSS Structure

css

Append Ellipsis To Long Text

css

Target Nth Child in CSS

server

Clean URLs

javascript

Client Location From Google

html

Conditional IE Statements

php

Mail in PHP

css

Device and Size Detection

sql

New Table in MySQL

css

CSS Greater Than Sign

jquery

ID Is Like

php

Email Using PHPMailer

php

ZipArchive in PHP

html

Full Table Structure

jquery

Wordpress Login Shake

jquery

TextArea Remaining Characters

php

GD Image Filters

javascript

iOS and Android Detection

jquery

Fixed Position on Scroll

php

Multiples Of

html

Useful HTML Character Entities

php

Generate Random Password

jquery

Simple AJAX Using jQuery

shell

Show Hidden Files on Mac

html

Favicons

javascript

Restrict Input to Numbers

jquery

setInterval Function

php

Twitter Timeline API Results

jquery

Smooth Scroll To Top

php

Time Ago Function

css

Text Emboss Technique

server

301 Redirect

php

Convert Twitter Links To URLs

jquery

Smooth Slide Toggle

css

Border Radius

php

PHP Range

php

Generate Random Colour

css

Embedding Fonts

css

Browser Selection Colour

html

Social Bookmark URLs

php

Date to Roman Numerals

php

Copyright Trick

php

Sorting an Array in PHP

jquery

Calculate Lighter Shade of RGB

sql

Inline MySQL Replace Statement