d
Amit DhamuSoftware Engineer

Snippets

274

javascript

226
Get object key based on value

typescript

71465
Use as const to create union type

typescript

15220
Chunking arrays

javascript

272
Sort an object

typescript

303
Human friendly file size

javascript

1328
Overwrite console output in Node

javascript

11028
Encode image as base64 using fetch

javascript

202
String to camelCase

python

2346
Flatten a directory

css

1248
3 ways to center a div

typescript

929
Convert roman numeral to number

javascript

242
Check if phrase is a palindrome

javascript

189
10 handy regular expressions

typescript

1375
Recursively deep merging objects

shell

1962
Flags in Bash with getopts

shell

1752
Switch statement in Bash

javascript

152
Leading zeros with padStart

javascript

1220
is_numeric

javascript

2241219
Scroll Into View With Offset

sql

225
Using string_agg in PostgreSQL

shell

2083
Git Status Porcelain

testing

38568
Spying on localStorage in Jest

testing

1439
Advance Timers in Jest

typescript

33186
Debounce

javascript

228
Omit property from object

typescript

172
Time of day greeting

react

368
Scroll Progress Bar Indicator

javascript

224
Unique values from array of objects

shell

152
Commit case changed filenames in Git

react

209
Smooth Scroll to Top

typescript

214
Read Time in minutes

typescript

676
Cartesian Product

javascript

122
Sharing with navigator.share

shell

116
Git status - files only

shell

114
Search in files and move to directory

javascript

6813
Get domain without subdomain

javascript

177
Find a HTML Element With Text

shell

211
Create A Folder For Each File

javascript

146
Capitalize Word

misc

205
CTRL+CMD+DOWN in VSCode

css

135
Invert Images

javascript

137
Sort Array of Objects by Property

javascript

129
Write to a File in Node

php

148
Valid PHP Types

php

226
is_countable

php

414
Replacing MsSQL_ functions

php

332
Migrating from mysql_ to mysqli_

javascript

134
YYYY-MM-DD in Javascript

misc

202
List Available Makefile Commands

javascript

1307
Generate Initials From String

misc

116
Restore macOS Desktop

misc

179
Delete Git Tag

misc

132
Prevent Safari Reopening Previous Session

python

241
Using argparse For Script Arguments

shell

104
Truncate A File

python

144
File Operations In Python

python

117
Loops In Python

shell

122
Bash - For Loop With Range

misc

105
Handy Docker Commands

misc

163
macOS - Get Serial Number

misc

153
Recent Items in macOS Dock

shell

178
Bash - If In Array

sql

124
Helpful mysqldump Commands

css

149
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

165
Trim Whitespace Pixels with Imagemagick

shell

120
What's Using A Port

misc

127
Chrome (macOS) - Delete URL Suggestion

misc

1933
Solr - Select Distinct Field

misc

661
Change Sublime Text 3 Title Bar Colour on macOS

misc

147
Test /etc/fstab

shell

172
Reformat A Hard Drive on Ubuntu

python

109
Write File Contents in Python

misc

440
Force Delete iCloud Account on macOS

shell

912
Step Through Commits On A Branch In Git

php

500
Case Insensitive Multi Dimensional Array Sort

javascript

117
Is Element Visible In Viewport

shell

100
Search For String In Files

misc

1202
Pip - Install Specific Hash, Branch or Tag

misc

197
Plex Downloads API

misc

89
Eject Disc From CD/DVD Drive on Mac

shell

118
Generate LetsEncrypt SSL Certificate

shell

580
Update Plex From Command Line on Ubuntu

javascript

116
Upgrade Node From NPM

shell

142
Use Heredoc In Bash Script

javascript

148
Get List of NPM Packages

server

100
Redirect to https & non-www in NGINX

javascript

141
Escape HTML

javascript

111
Get Query Parameters

shell

133
Create Multiple Subdirectories At Once

css

255
Clear Button On Input Field

javascript

123
Redirect to HTTPS in Express

javascript

12900
Strip Trailing Slashes From Express Requests

misc

110
Install VirtualBoxGuestAdditions In Ubuntu

shell

111
Recursively Find and Delete File

misc

641
Restart Plex From Command Line

misc

177
Install Ruby Gem Behind Proxy

misc

182
Hide Minified File Contents From Git History

shell

91
Search Occurrences In Between Two Strings

misc

105
Git - Change Remote Origin

php

117
Convert XML to Array

css

110
If Statements in SASS

shell

288
Watch Filesize On Command Line

html

799
Placeholder Image if Src Unavailable

shell

179
Get Number of Commits by Author in Git

shell

128
Temporarily Ignore File in Git

shell

140
Search Git Commit History

javascript

259
Social Media Share Counts

misc

121
Solr - Delete By Query

javascript

122
Default Parameter in Function

css

145
Generate Colour Classes in SASS

shell

271
Use Terminal Through Proxy

misc

159
Vim Commands

shell

117
Git Commands

shell

122
UNIX Commands

jquery

974
Insert Character At Position

php

142
MySQL to CSV Export

jquery

201
Check If Radio Button Has Been Checked

jquery

120
Open External Links In New Tab

misc

136
Use Browser As Notepad

sql

94
Get Date If After Interval

misc

147
Mac Recovery Tools

misc

144
Restart Mac In Safe Mode

php

369
Load Random Image From Directory

css

202
Fullscreen Styling

jquery

107
On The Fly Form With jQuery

javascript

126
Comma Separated String To Array

css

98
Make Images Black and White

shell

167
FTP Upload Using Command Prompt or Terminal

jquery

80
Wrap Element Around Other Element

php

107
Exif Image Data

misc

120
Add Close All To Sublime Text Tab Menu

php

201
Search Files Using glob()

php

203
Write To A Text File

shell

169
Handy Shell Commands (Windows)

javascript

178
Double Click Event

server

141
HTTP Authentication

jquery

133
Toggle Text Function

php

98
Useful Folder and File Functions in PHP

jquery

190
Select Nth Class of Element

jquery

109
Scroll To Bottom of Element

css

193
Pure CSS Speech Bubble

jquery

116
Implement Keyboard Shortcuts For Your Website

html

107
Favicon For Windows 8 Tile

php

118
Append To Text File

php

481
mysql_real_escape_string on Array

php

89
Autoload Class

php

121
Use An Array Recursively

javascript

171
Save Canvas as PNG

php

159
Detect AJAX Request in PHP

php

133
Ignore nl2br() Inside Pre/Code Tag

php

175
List System Drives - Windows Only

sql

121
Capitalise Field in Row

misc

170
Create A Lockscreen Shortcut in Windows

php

129
Remove File Extension

jquery

107
Self Executing Function

php

118
Social Bookmark Share Function

php

152
Recursive Directory Scanning

jquery

142
Get Mouse Coordinates

php

121
Get File Extension

css

262
Available List Style Types

css

118
Maintain Aspect Ratio

php

139
Check If Uppercase or Lowercase

php

188
Case Insensitive In Array Check

php

343
List System Drives

misc

120
Remove Empty Lines In SublimeText

php

157
CRUD Functions with PDO

php

141
Simple Select Query with PDO

misc

107
Query Fetch Types in PDO

php

207
PDO Database Connection

sql

122
Duplicate Table Into New Table

jquery

147
Scroll To Position

php

104
Cacheable Tweets

css

112
Mixins in LESS

css

139
Variables in LESS

php

112
Serialize and Unserialize Array

html

168
Viewport Meta Tag For Mobile

javascript

131
Prompt For User Input

css

120
Minify CSS On The Fly

php

126
cURL

jquery

116
Element Is Not

php

87
Specify Decimal Places

php

136
Page Last Modified

php

116
Add Month or Year to Date

javascript

108
OnClick Function

php

90
Embed Images With Data URIs

php

107
Conditional Vs Ternary

php

224
Loop Between Date Range

css

130
CSS3 Animation

css

149
CSS3 Transitions

sql

108
Return Row Count

jquery

127
Filter Table Results

css

128
Box Shadow

shell

87
Dividing The Dock In OSX

php

114
Remove Value From Array

jquery

126
Select Where Attribute Is

server

120
Set Timezone

jquery

117
FadeIn Image When Loaded

php

91
Leading Zeroes

jquery

126
Toggle Password Characters

php

140
Width and Height of SWF

sql

100
Add 1 To Number In Field

html

127
Get Site Favicon

javascript

163
HTML5 Desktop Notifications

php

1032
Create an ICS file

css

118
Full Screen Background Image

css

101
CSS3 Attribute Selectors

php

115
Current File Name

php

116
Delete File From Server

php

133
Highlight Search Keyword

server

1152
Force or remove www from URL

jquery

94
Check If Element Exists

css

92
Multiple Background

html

155
Phone and SMS Prefixes

sql

133
Date of Birth to Age

jquery

101
Disable Right Click Context Menu

css

104
Cross Browser Opacity

php

104
Flickr Photo Search API

server

100
Optimise Site Using DEFLATE

html

166
HTML5 Audio Tag

javascript

148
Popup Window

css

90
Target By Attribute

server

115
Error Document

html

246
Hide Broken Image Icon

javascript

99
Random Colour

php

118
Encode & Decode JSON

php

101
SimpleXML

css

107
Using RGBa

javascript

112
Detect CSS Property

jquery

141
Hover Animations

html

110
RSS Structure

css

112
Append Ellipsis To Long Text

css

119
Target Nth Child in CSS

server

106
Clean URLs

javascript

231
Client Location From Google

html

155
Conditional IE Statements

php

117
Mail in PHP

css

116
Device and Size Detection

sql

130
New Table in MySQL

css

98
CSS Greater Than Sign

jquery

104
ID Is Like

php

117
Email Using PHPMailer

php

151
ZipArchive in PHP

html

94
Full Table Structure

jquery

116
Wordpress Login Shake

jquery

132
TextArea Remaining Characters

php

148
GD Image Filters

javascript

180
iOS and Android Detection

jquery

127
Fixed Position on Scroll

php

116
Multiples Of

html

118
Useful HTML Character Entities

php

137
Generate Random Password

jquery

122
Simple AJAX Using jQuery

shell

117
Show Hidden Files on Mac

html

99
Favicons

javascript

161
Restrict Input to Numbers

jquery

108
setInterval Function

php

122
Twitter Timeline API Results

jquery

92
Smooth Scroll To Top

php

109
Time Ago Function

css

101
Text Emboss Technique

server

96
301 Redirect

php

107
Convert Twitter Links To URLs

jquery

238
Smooth Slide Toggle

css

96
Border Radius

php

118
PHP Range

php

85
Generate Random Colour

css

146
Embedding Fonts

css

99
Browser Selection Colour

html

107
Social Bookmark URLs

php

1423
Date to Roman Numerals

php

105
Copyright Trick

php

146
Sorting an Array in PHP

jquery

124
Calculate Lighter Shade of RGB

sql

116
Inline MySQL Replace Statement