d
Amit DhamuSoftware Engineer

Snippets

274

javascript

244
Get object key based on value

typescript

71504
Use as const to create union type

typescript

15238
Chunking arrays

javascript

285
Sort an object

typescript

321
Human friendly file size

javascript

1363
Overwrite console output in Node

javascript

11048
Encode image as base64 using fetch

javascript

217
String to camelCase

python

2372
Flatten a directory

css

1259
3 ways to center a div

typescript

955
Convert roman numeral to number

javascript

257
Check if phrase is a palindrome

javascript

200
10 handy regular expressions

typescript

1394
Recursively deep merging objects

shell

1976
Flags in Bash with getopts

shell

1767
Switch statement in Bash

javascript

166
Leading zeros with padStart

javascript

1231
is_numeric

javascript

2241405
Scroll Into View With Offset

sql

235
Using string_agg in PostgreSQL

shell

2122
Git Status Porcelain

testing

38590
Spying on localStorage in Jest

testing

1449
Advance Timers in Jest

typescript

33206
Debounce

javascript

242
Omit property from object

typescript

187
Time of day greeting

react

374
Scroll Progress Bar Indicator

javascript

233
Unique values from array of objects

shell

156
Commit case changed filenames in Git

react

222
Smooth Scroll to Top

typescript

222
Read Time in minutes

typescript

687
Cartesian Product

javascript

127
Sharing with navigator.share

shell

122
Git status - files only

shell

121
Search in files and move to directory

javascript

6832
Get domain without subdomain

javascript

189
Find a HTML Element With Text

shell

218
Create A Folder For Each File

javascript

153
Capitalize Word

misc

218
CTRL+CMD+DOWN in VSCode

css

140
Invert Images

javascript

145
Sort Array of Objects by Property

javascript

136
Write to a File in Node

php

165
Valid PHP Types

php

240
is_countable

php

431
Replacing MsSQL_ functions

php

341
Migrating from mysql_ to mysqli_

javascript

141
YYYY-MM-DD in Javascript

misc

209
List Available Makefile Commands

javascript

1315
Generate Initials From String

misc

125
Restore macOS Desktop

misc

187
Delete Git Tag

misc

139
Prevent Safari Reopening Previous Session

python

250
Using argparse For Script Arguments

shell

114
Truncate A File

python

159
File Operations In Python

python

126
Loops In Python

shell

132
Bash - For Loop With Range

misc

110
Handy Docker Commands

misc

170
macOS - Get Serial Number

misc

167
Recent Items in macOS Dock

shell

188
Bash - If In Array

sql

138
Helpful mysqldump Commands

css

158
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

172
Trim Whitespace Pixels with Imagemagick

shell

125
What's Using A Port

misc

140
Chrome (macOS) - Delete URL Suggestion

misc

1944
Solr - Select Distinct Field

misc

674
Change Sublime Text 3 Title Bar Colour on macOS

misc

159
Test /etc/fstab

shell

185
Reformat A Hard Drive on Ubuntu

python

123
Write File Contents in Python

misc

447
Force Delete iCloud Account on macOS

shell

917
Step Through Commits On A Branch In Git

php

508
Case Insensitive Multi Dimensional Array Sort

javascript

122
Is Element Visible In Viewport

shell

103
Search For String In Files

misc

1214
Pip - Install Specific Hash, Branch or Tag

misc

211
Plex Downloads API

misc

98
Eject Disc From CD/DVD Drive on Mac

shell

123
Generate LetsEncrypt SSL Certificate

shell

597
Update Plex From Command Line on Ubuntu

javascript

122
Upgrade Node From NPM

shell

147
Use Heredoc In Bash Script

javascript

159
Get List of NPM Packages

server

107
Redirect to https & non-www in NGINX

javascript

151
Escape HTML

javascript

121
Get Query Parameters

shell

143
Create Multiple Subdirectories At Once

css

261
Clear Button On Input Field

javascript

131
Redirect to HTTPS in Express

javascript

12926
Strip Trailing Slashes From Express Requests

misc

115
Install VirtualBoxGuestAdditions In Ubuntu

shell

119
Recursively Find and Delete File

misc

670
Restart Plex From Command Line

misc

189
Install Ruby Gem Behind Proxy

misc

187
Hide Minified File Contents From Git History

shell

101
Search Occurrences In Between Two Strings

misc

113
Git - Change Remote Origin

php

129
Convert XML to Array

css

118
If Statements in SASS

shell

295
Watch Filesize On Command Line

html

812
Placeholder Image if Src Unavailable

shell

183
Get Number of Commits by Author in Git

shell

143
Temporarily Ignore File in Git

shell

150
Search Git Commit History

javascript

270
Social Media Share Counts

misc

129
Solr - Delete By Query

javascript

126
Default Parameter in Function

css

157
Generate Colour Classes in SASS

shell

279
Use Terminal Through Proxy

misc

178
Vim Commands

shell

126
Git Commands

shell

132
UNIX Commands

jquery

986
Insert Character At Position

php

149
MySQL to CSV Export

jquery

213
Check If Radio Button Has Been Checked

jquery

126
Open External Links In New Tab

misc

143
Use Browser As Notepad

sql

102
Get Date If After Interval

misc

171
Mac Recovery Tools

misc

152
Restart Mac In Safe Mode

php

374
Load Random Image From Directory

css

207
Fullscreen Styling

jquery

112
On The Fly Form With jQuery

javascript

132
Comma Separated String To Array

css

112
Make Images Black and White

shell

175
FTP Upload Using Command Prompt or Terminal

jquery

86
Wrap Element Around Other Element

php

117
Exif Image Data

misc

132
Add Close All To Sublime Text Tab Menu

php

212
Search Files Using glob()

php

217
Write To A Text File

shell

187
Handy Shell Commands (Windows)

javascript

189
Double Click Event

server

149
HTTP Authentication

jquery

142
Toggle Text Function

php

104
Useful Folder and File Functions in PHP

jquery

201
Select Nth Class of Element

jquery

118
Scroll To Bottom of Element

css

197
Pure CSS Speech Bubble

jquery

124
Implement Keyboard Shortcuts For Your Website

html

113
Favicon For Windows 8 Tile

php

126
Append To Text File

php

490
mysql_real_escape_string on Array

php

97
Autoload Class

php

130
Use An Array Recursively

javascript

181
Save Canvas as PNG

php

167
Detect AJAX Request in PHP

php

138
Ignore nl2br() Inside Pre/Code Tag

php

184
List System Drives - Windows Only

sql

128
Capitalise Field in Row

misc

181
Create A Lockscreen Shortcut in Windows

php

137
Remove File Extension

jquery

114
Self Executing Function

php

127
Social Bookmark Share Function

php

166
Recursive Directory Scanning

jquery

151
Get Mouse Coordinates

php

126
Get File Extension

css

269
Available List Style Types

css

125
Maintain Aspect Ratio

php

151
Check If Uppercase or Lowercase

php

195
Case Insensitive In Array Check

php

352
List System Drives

misc

132
Remove Empty Lines In SublimeText

php

163
CRUD Functions with PDO

php

153
Simple Select Query with PDO

misc

115
Query Fetch Types in PDO

php

219
PDO Database Connection

sql

132
Duplicate Table Into New Table

jquery

159
Scroll To Position

php

110
Cacheable Tweets

css

118
Mixins in LESS

css

147
Variables in LESS

php

116
Serialize and Unserialize Array

html

182
Viewport Meta Tag For Mobile

javascript

142
Prompt For User Input

css

128
Minify CSS On The Fly

php

132
cURL

jquery

124
Element Is Not

php

94
Specify Decimal Places

php

147
Page Last Modified

php

130
Add Month or Year to Date

javascript

115
OnClick Function

php

98
Embed Images With Data URIs

php

117
Conditional Vs Ternary

php

235
Loop Between Date Range

css

136
CSS3 Animation

css

156
CSS3 Transitions

sql

122
Return Row Count

jquery

134
Filter Table Results

css

138
Box Shadow

shell

96
Dividing The Dock In OSX

php

120
Remove Value From Array

jquery

135
Select Where Attribute Is

server

125
Set Timezone

jquery

125
FadeIn Image When Loaded

php

101
Leading Zeroes

jquery

139
Toggle Password Characters

php

146
Width and Height of SWF

sql

107
Add 1 To Number In Field

html

134
Get Site Favicon

javascript

169
HTML5 Desktop Notifications

php

1052
Create an ICS file

css

128
Full Screen Background Image

css

109
CSS3 Attribute Selectors

php

122
Current File Name

php

122
Delete File From Server

php

138
Highlight Search Keyword

server

1155
Force or remove www from URL

jquery

100
Check If Element Exists

css

102
Multiple Background

html

168
Phone and SMS Prefixes

sql

138
Date of Birth to Age

jquery

112
Disable Right Click Context Menu

css

111
Cross Browser Opacity

php

119
Flickr Photo Search API

server

110
Optimise Site Using DEFLATE

html

172
HTML5 Audio Tag

javascript

156
Popup Window

css

94
Target By Attribute

server

122
Error Document

html

255
Hide Broken Image Icon

javascript

108
Random Colour

php

124
Encode & Decode JSON

php

109
SimpleXML

css

115
Using RGBa

javascript

124
Detect CSS Property

jquery

149
Hover Animations

html

116
RSS Structure

css

116
Append Ellipsis To Long Text

css

125
Target Nth Child in CSS

server

113
Clean URLs

javascript

239
Client Location From Google

html

167
Conditional IE Statements

php

123
Mail in PHP

css

123
Device and Size Detection

sql

140
New Table in MySQL

css

107
CSS Greater Than Sign

jquery

111
ID Is Like

php

123
Email Using PHPMailer

php

161
ZipArchive in PHP

html

102
Full Table Structure

jquery

121
Wordpress Login Shake

jquery

138
TextArea Remaining Characters

php

156
GD Image Filters

javascript

186
iOS and Android Detection

jquery

140
Fixed Position on Scroll

php

122
Multiples Of

html

123
Useful HTML Character Entities

php

146
Generate Random Password

jquery

132
Simple AJAX Using jQuery

shell

129
Show Hidden Files on Mac

html

112
Favicons

javascript

168
Restrict Input to Numbers

jquery

123
setInterval Function

php

130
Twitter Timeline API Results

jquery

101
Smooth Scroll To Top

php

121
Time Ago Function

css

107
Text Emboss Technique

server

103
301 Redirect

php

113
Convert Twitter Links To URLs

jquery

246
Smooth Slide Toggle

css

103
Border Radius

php

125
PHP Range

php

94
Generate Random Colour

css

155
Embedding Fonts

css

104
Browser Selection Colour

html

112
Social Bookmark URLs

php

1431
Date to Roman Numerals

php

110
Copyright Trick

php

161
Sorting an Array in PHP

jquery

135
Calculate Lighter Shade of RGB

sql

125
Inline MySQL Replace Statement