d
Amit DhamuSoftware Engineer

Snippets

274

javascript

191
Get object key based on value

typescript

71398
Use as const to create union type

typescript

15175
Chunking arrays

javascript

252
Sort an object

typescript

265
Human friendly file size

javascript

1283
Overwrite console output in Node

javascript

11003
Encode image as base64 using fetch

javascript

181
String to camelCase

python

2301
Flatten a directory

css

1230
3 ways to center a div

typescript

900
Convert roman numeral to number

javascript

220
Check if phrase is a palindrome

javascript

174
10 handy regular expressions

typescript

1328
Recursively deep merging objects

shell

1923
Flags in Bash with getopts

shell

1723
Switch statement in Bash

javascript

137
Leading zeros with padStart

javascript

1197
is_numeric

javascript

2140902
Scroll Into View With Offset

sql

208
Using string_agg in PostgreSQL

shell

2033
Git Status Porcelain

testing

38535
Spying on localStorage in Jest

testing

1397
Advance Timers in Jest

typescript

33156
Debounce

javascript

211
Omit property from object

typescript

156
Time of day greeting

react

350
Scroll Progress Bar Indicator

javascript

210
Unique values from array of objects

shell

135
Commit case changed filenames in Git

react

198
Smooth Scroll to Top

typescript

187
Read Time in minutes

typescript

651
Cartesian Product

javascript

106
Sharing with navigator.share

shell

102
Git status - files only

shell

99
Search in files and move to directory

javascript

6761
Get domain without subdomain

javascript

147
Find a HTML Element With Text

shell

180
Create A Folder For Each File

javascript

133
Capitalize Word

misc

192
CTRL+CMD+DOWN in VSCode

css

119
Invert Images

javascript

118
Sort Array of Objects by Property

javascript

111
Write to a File in Node

php

115
Valid PHP Types

php

198
is_countable

php

393
Replacing MsSQL_ functions

php

308
Migrating from mysql_ to mysqli_

javascript

116
YYYY-MM-DD in Javascript

misc

181
List Available Makefile Commands

javascript

1262
Generate Initials From String

misc

107
Restore macOS Desktop

misc

157
Delete Git Tag

misc

114
Prevent Safari Reopening Previous Session

python

226
Using argparse For Script Arguments

shell

91
Truncate A File

python

125
File Operations In Python

python

100
Loops In Python

shell

104
Bash - For Loop With Range

misc

91
Handy Docker Commands

misc

148
macOS - Get Serial Number

misc

117
Recent Items in macOS Dock

shell

142
Bash - If In Array

sql

105
Helpful mysqldump Commands

css

130
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

137
Trim Whitespace Pixels with Imagemagick

shell

102
What's Using A Port

misc

118
Chrome (macOS) - Delete URL Suggestion

misc

1909
Solr - Select Distinct Field

misc

631
Change Sublime Text 3 Title Bar Colour on macOS

misc

127
Test /etc/fstab

shell

148
Reformat A Hard Drive on Ubuntu

python

92
Write File Contents in Python

misc

412
Force Delete iCloud Account on macOS

shell

885
Step Through Commits On A Branch In Git

php

474
Case Insensitive Multi Dimensional Array Sort

javascript

103
Is Element Visible In Viewport

shell

85
Search For String In Files

misc

1178
Pip - Install Specific Hash, Branch or Tag

misc

177
Plex Downloads API

misc

78
Eject Disc From CD/DVD Drive on Mac

shell

104
Generate LetsEncrypt SSL Certificate

shell

533
Update Plex From Command Line on Ubuntu

javascript

96
Upgrade Node From NPM

shell

121
Use Heredoc In Bash Script

javascript

125
Get List of NPM Packages

server

83
Redirect to https & non-www in NGINX

javascript

118
Escape HTML

javascript

99
Get Query Parameters

shell

104
Create Multiple Subdirectories At Once

css

236
Clear Button On Input Field

javascript

107
Redirect to HTTPS in Express

javascript

12851
Strip Trailing Slashes From Express Requests

misc

92
Install VirtualBoxGuestAdditions In Ubuntu

shell

89
Recursively Find and Delete File

misc

573
Restart Plex From Command Line

misc

142
Install Ruby Gem Behind Proxy

misc

144
Hide Minified File Contents From Git History

shell

72
Search Occurrences In Between Two Strings

misc

89
Git - Change Remote Origin

php

99
Convert XML to Array

css

92
If Statements in SASS

shell

265
Watch Filesize On Command Line

html

769
Placeholder Image if Src Unavailable

shell

155
Get Number of Commits by Author in Git

shell

107
Temporarily Ignore File in Git

shell

117
Search Git Commit History

javascript

230
Social Media Share Counts

misc

99
Solr - Delete By Query

javascript

106
Default Parameter in Function

css

115
Generate Colour Classes in SASS

shell

252
Use Terminal Through Proxy

misc

135
Vim Commands

shell

98
Git Commands

shell

101
UNIX Commands

jquery

945
Insert Character At Position

php

129
MySQL to CSV Export

jquery

176
Check If Radio Button Has Been Checked

jquery

108
Open External Links In New Tab

misc

122
Use Browser As Notepad

sql

82
Get Date If After Interval

misc

115
Mac Recovery Tools

misc

127
Restart Mac In Safe Mode

php

351
Load Random Image From Directory

css

184
Fullscreen Styling

jquery

91
On The Fly Form With jQuery

javascript

100
Comma Separated String To Array

css

90
Make Images Black and White

shell

143
FTP Upload Using Command Prompt or Terminal

jquery

62
Wrap Element Around Other Element

php

94
Exif Image Data

misc

99
Add Close All To Sublime Text Tab Menu

php

164
Search Files Using glob()

php

185
Write To A Text File

shell

148
Handy Shell Commands (Windows)

javascript

150
Double Click Event

server

124
HTTP Authentication

jquery

115
Toggle Text Function

php

81
Useful Folder and File Functions in PHP

jquery

173
Select Nth Class of Element

jquery

97
Scroll To Bottom of Element

css

163
Pure CSS Speech Bubble

jquery

100
Implement Keyboard Shortcuts For Your Website

html

90
Favicon For Windows 8 Tile

php

101
Append To Text File

php

459
mysql_real_escape_string on Array

php

76
Autoload Class

php

101
Use An Array Recursively

javascript

148
Save Canvas as PNG

php

140
Detect AJAX Request in PHP

php

108
Ignore nl2br() Inside Pre/Code Tag

php

161
List System Drives - Windows Only

sql

105
Capitalise Field in Row

misc

135
Create A Lockscreen Shortcut in Windows

php

112
Remove File Extension

jquery

93
Self Executing Function

php

99
Social Bookmark Share Function

php

130
Recursive Directory Scanning

jquery

110
Get Mouse Coordinates

php

111
Get File Extension

css

231
Available List Style Types

css

100
Maintain Aspect Ratio

php

124
Check If Uppercase or Lowercase

php

177
Case Insensitive In Array Check

php

303
List System Drives

misc

100
Remove Empty Lines In SublimeText

php

142
CRUD Functions with PDO

php

119
Simple Select Query with PDO

misc

92
Query Fetch Types in PDO

php

185
PDO Database Connection

sql

99
Duplicate Table Into New Table

jquery

127
Scroll To Position

php

88
Cacheable Tweets

css

101
Mixins in LESS

css

124
Variables in LESS

php

95
Serialize and Unserialize Array

html

137
Viewport Meta Tag For Mobile

javascript

107
Prompt For User Input

css

107
Minify CSS On The Fly

php

109
cURL

jquery

99
Element Is Not

php

73
Specify Decimal Places

php

114
Page Last Modified

php

97
Add Month or Year to Date

javascript

90
OnClick Function

php

77
Embed Images With Data URIs

php

90
Conditional Vs Ternary

php

194
Loop Between Date Range

css

113
CSS3 Animation

css

132
CSS3 Transitions

sql

94
Return Row Count

jquery

106
Filter Table Results

css

115
Box Shadow

shell

74
Dividing The Dock In OSX

php

96
Remove Value From Array

jquery

105
Select Where Attribute Is

server

108
Set Timezone

jquery

101
FadeIn Image When Loaded

php

72
Leading Zeroes

jquery

101
Toggle Password Characters

php

120
Width and Height of SWF

sql

92
Add 1 To Number In Field

html

106
Get Site Favicon

javascript

145
HTML5 Desktop Notifications

php

995
Create an ICS file

css

103
Full Screen Background Image

css

72
CSS3 Attribute Selectors

php

97
Current File Name

php

101
Delete File From Server

php

114
Highlight Search Keyword

server

1133
Force or remove www from URL

jquery

78
Check If Element Exists

css

77
Multiple Background

html

127
Phone and SMS Prefixes

sql

110
Date of Birth to Age

jquery

83
Disable Right Click Context Menu

css

91
Cross Browser Opacity

php

84
Flickr Photo Search API

server

86
Optimise Site Using DEFLATE

html

156
HTML5 Audio Tag

javascript

136
Popup Window

css

79
Target By Attribute

server

107
Error Document

html

212
Hide Broken Image Icon

javascript

87
Random Colour

php

107
Encode & Decode JSON

php

89
SimpleXML

css

90
Using RGBa

javascript

93
Detect CSS Property

jquery

128
Hover Animations

html

96
RSS Structure

css

100
Append Ellipsis To Long Text

css

106
Target Nth Child in CSS

server

91
Clean URLs

javascript

216
Client Location From Google

html

128
Conditional IE Statements

php

95
Mail in PHP

css

102
Device and Size Detection

sql

95
New Table in MySQL

css

82
CSS Greater Than Sign

jquery

89
ID Is Like

php

95
Email Using PHPMailer

php

131
ZipArchive in PHP

html

80
Full Table Structure

jquery

92
Wordpress Login Shake

jquery

116
TextArea Remaining Characters

php

126
GD Image Filters

javascript

163
iOS and Android Detection

jquery

107
Fixed Position on Scroll

php

94
Multiples Of

html

95
Useful HTML Character Entities

php

113
Generate Random Password

jquery

97
Simple AJAX Using jQuery

shell

103
Show Hidden Files on Mac

html

83
Favicons

javascript

143
Restrict Input to Numbers

jquery

88
setInterval Function

php

105
Twitter Timeline API Results

jquery

78
Smooth Scroll To Top

php

82
Time Ago Function

css

78
Text Emboss Technique

server

86
301 Redirect

php

85
Convert Twitter Links To URLs

jquery

217
Smooth Slide Toggle

css

77
Border Radius

php

99
PHP Range

php

71
Generate Random Colour

css

126
Embedding Fonts

css

80
Browser Selection Colour

html

91
Social Bookmark URLs

php

1377
Date to Roman Numerals

php

90
Copyright Trick

php

129
Sorting an Array in PHP

jquery

102
Calculate Lighter Shade of RGB

sql

102
Inline MySQL Replace Statement