d
Amit DhamuSoftware Engineer

Snippets

274

javascript

238
Get object key based on value

typescript

71496
Use as const to create union type

typescript

15232
Chunking arrays

javascript

282
Sort an object

typescript

319
Human friendly file size

javascript

1357
Overwrite console output in Node

javascript

11041
Encode image as base64 using fetch

javascript

211
String to camelCase

python

2365
Flatten a directory

css

1255
3 ways to center a div

typescript

950
Convert roman numeral to number

javascript

254
Check if phrase is a palindrome

javascript

195
10 handy regular expressions

typescript

1388
Recursively deep merging objects

shell

1972
Flags in Bash with getopts

shell

1763
Switch statement in Bash

javascript

160
Leading zeros with padStart

javascript

1228
is_numeric

javascript

2241359
Scroll Into View With Offset

sql

234
Using string_agg in PostgreSQL

shell

2113
Git Status Porcelain

testing

38585
Spying on localStorage in Jest

testing

1446
Advance Timers in Jest

typescript

33200
Debounce

javascript

240
Omit property from object

typescript

185
Time of day greeting

react

371
Scroll Progress Bar Indicator

javascript

231
Unique values from array of objects

shell

155
Commit case changed filenames in Git

react

220
Smooth Scroll to Top

typescript

221
Read Time in minutes

typescript

684
Cartesian Product

javascript

127
Sharing with navigator.share

shell

120
Git status - files only

shell

120
Search in files and move to directory

javascript

6829
Get domain without subdomain

javascript

186
Find a HTML Element With Text

shell

216
Create A Folder For Each File

javascript

150
Capitalize Word

misc

216
CTRL+CMD+DOWN in VSCode

css

138
Invert Images

javascript

142
Sort Array of Objects by Property

javascript

134
Write to a File in Node

php

159
Valid PHP Types

php

234
is_countable

php

427
Replacing MsSQL_ functions

php

338
Migrating from mysql_ to mysqli_

javascript

140
YYYY-MM-DD in Javascript

misc

207
List Available Makefile Commands

javascript

1312
Generate Initials From String

misc

122
Restore macOS Desktop

misc

185
Delete Git Tag

misc

138
Prevent Safari Reopening Previous Session

python

244
Using argparse For Script Arguments

shell

113
Truncate A File

python

155
File Operations In Python

python

124
Loops In Python

shell

129
Bash - For Loop With Range

misc

108
Handy Docker Commands

misc

169
macOS - Get Serial Number

misc

165
Recent Items in macOS Dock

shell

185
Bash - If In Array

sql

134
Helpful mysqldump Commands

css

154
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

171
Trim Whitespace Pixels with Imagemagick

shell

123
What's Using A Port

misc

136
Chrome (macOS) - Delete URL Suggestion

misc

1940
Solr - Select Distinct Field

misc

671
Change Sublime Text 3 Title Bar Colour on macOS

misc

158
Test /etc/fstab

shell

184
Reformat A Hard Drive on Ubuntu

python

121
Write File Contents in Python

misc

444
Force Delete iCloud Account on macOS

shell

915
Step Through Commits On A Branch In Git

php

506
Case Insensitive Multi Dimensional Array Sort

javascript

121
Is Element Visible In Viewport

shell

103
Search For String In Files

misc

1212
Pip - Install Specific Hash, Branch or Tag

misc

207
Plex Downloads API

misc

97
Eject Disc From CD/DVD Drive on Mac

shell

121
Generate LetsEncrypt SSL Certificate

shell

594
Update Plex From Command Line on Ubuntu

javascript

120
Upgrade Node From NPM

shell

146
Use Heredoc In Bash Script

javascript

157
Get List of NPM Packages

server

106
Redirect to https & non-www in NGINX

javascript

148
Escape HTML

javascript

119
Get Query Parameters

shell

141
Create Multiple Subdirectories At Once

css

260
Clear Button On Input Field

javascript

129
Redirect to HTTPS in Express

javascript

12921
Strip Trailing Slashes From Express Requests

misc

114
Install VirtualBoxGuestAdditions In Ubuntu

shell

116
Recursively Find and Delete File

misc

667
Restart Plex From Command Line

misc

185
Install Ruby Gem Behind Proxy

misc

185
Hide Minified File Contents From Git History

shell

98
Search Occurrences In Between Two Strings

misc

112
Git - Change Remote Origin

php

126
Convert XML to Array

css

116
If Statements in SASS

shell

292
Watch Filesize On Command Line

html

808
Placeholder Image if Src Unavailable

shell

183
Get Number of Commits by Author in Git

shell

141
Temporarily Ignore File in Git

shell

148
Search Git Commit History

javascript

267
Social Media Share Counts

misc

126
Solr - Delete By Query

javascript

125
Default Parameter in Function

css

154
Generate Colour Classes in SASS

shell

276
Use Terminal Through Proxy

misc

175
Vim Commands

shell

124
Git Commands

shell

129
UNIX Commands

jquery

982
Insert Character At Position

php

147
MySQL to CSV Export

jquery

209
Check If Radio Button Has Been Checked

jquery

124
Open External Links In New Tab

misc

141
Use Browser As Notepad

sql

100
Get Date If After Interval

misc

163
Mac Recovery Tools

misc

149
Restart Mac In Safe Mode

php

373
Load Random Image From Directory

css

206
Fullscreen Styling

jquery

112
On The Fly Form With jQuery

javascript

130
Comma Separated String To Array

css

109
Make Images Black and White

shell

172
FTP Upload Using Command Prompt or Terminal

jquery

83
Wrap Element Around Other Element

php

114
Exif Image Data

misc

129
Add Close All To Sublime Text Tab Menu

php

210
Search Files Using glob()

php

213
Write To A Text File

shell

184
Handy Shell Commands (Windows)

javascript

186
Double Click Event

server

147
HTTP Authentication

jquery

138
Toggle Text Function

php

102
Useful Folder and File Functions in PHP

jquery

198
Select Nth Class of Element

jquery

117
Scroll To Bottom of Element

css

196
Pure CSS Speech Bubble

jquery

122
Implement Keyboard Shortcuts For Your Website

html

111
Favicon For Windows 8 Tile

php

124
Append To Text File

php

487
mysql_real_escape_string on Array

php

94
Autoload Class

php

128
Use An Array Recursively

javascript

179
Save Canvas as PNG

php

164
Detect AJAX Request in PHP

php

137
Ignore nl2br() Inside Pre/Code Tag

php

181
List System Drives - Windows Only

sql

127
Capitalise Field in Row

misc

178
Create A Lockscreen Shortcut in Windows

php

135
Remove File Extension

jquery

112
Self Executing Function

php

124
Social Bookmark Share Function

php

162
Recursive Directory Scanning

jquery

149
Get Mouse Coordinates

php

125
Get File Extension

css

268
Available List Style Types

css

124
Maintain Aspect Ratio

php

148
Check If Uppercase or Lowercase

php

194
Case Insensitive In Array Check

php

350
List System Drives

misc

129
Remove Empty Lines In SublimeText

php

161
CRUD Functions with PDO

php

150
Simple Select Query with PDO

misc

112
Query Fetch Types in PDO

php

215
PDO Database Connection

sql

130
Duplicate Table Into New Table

jquery

152
Scroll To Position

php

110
Cacheable Tweets

css

116
Mixins in LESS

css

145
Variables in LESS

php

114
Serialize and Unserialize Array

html

178
Viewport Meta Tag For Mobile

javascript

138
Prompt For User Input

css

125
Minify CSS On The Fly

php

130
cURL

jquery

121
Element Is Not

php

93
Specify Decimal Places

php

145
Page Last Modified

php

126
Add Month or Year to Date

javascript

114
OnClick Function

php

96
Embed Images With Data URIs

php

114
Conditional Vs Ternary

php

233
Loop Between Date Range

css

136
CSS3 Animation

css

152
CSS3 Transitions

sql

118
Return Row Count

jquery

132
Filter Table Results

css

135
Box Shadow

shell

94
Dividing The Dock In OSX

php

119
Remove Value From Array

jquery

131
Select Where Attribute Is

server

123
Set Timezone

jquery

121
FadeIn Image When Loaded

php

99
Leading Zeroes

jquery

136
Toggle Password Characters

php

144
Width and Height of SWF

sql

106
Add 1 To Number In Field

html

133
Get Site Favicon

javascript

169
HTML5 Desktop Notifications

php

1047
Create an ICS file

css

125
Full Screen Background Image

css

106
CSS3 Attribute Selectors

php

121
Current File Name

php

120
Delete File From Server

php

137
Highlight Search Keyword

server

1154
Force or remove www from URL

jquery

100
Check If Element Exists

css

99
Multiple Background

html

165
Phone and SMS Prefixes

sql

137
Date of Birth to Age

jquery

111
Disable Right Click Context Menu

css

108
Cross Browser Opacity

php

112
Flickr Photo Search API

server

107
Optimise Site Using DEFLATE

html

171
HTML5 Audio Tag

javascript

155
Popup Window

css

93
Target By Attribute

server

120
Error Document

html

252
Hide Broken Image Icon

javascript

107
Random Colour

php

124
Encode & Decode JSON

php

107
SimpleXML

css

113
Using RGBa

javascript

123
Detect CSS Property

jquery

146
Hover Animations

html

114
RSS Structure

css

116
Append Ellipsis To Long Text

css

125
Target Nth Child in CSS

server

112
Clean URLs

javascript

236
Client Location From Google

html

165
Conditional IE Statements

php

123
Mail in PHP

css

121
Device and Size Detection

sql

137
New Table in MySQL

css

104
CSS Greater Than Sign

jquery

109
ID Is Like

php

121
Email Using PHPMailer

php

157
ZipArchive in PHP

html

101
Full Table Structure

jquery

121
Wordpress Login Shake

jquery

136
TextArea Remaining Characters

php

154
GD Image Filters

javascript

184
iOS and Android Detection

jquery

137
Fixed Position on Scroll

php

121
Multiples Of

html

122
Useful HTML Character Entities

php

145
Generate Random Password

jquery

130
Simple AJAX Using jQuery

shell

125
Show Hidden Files on Mac

html

112
Favicons

javascript

166
Restrict Input to Numbers

jquery

118
setInterval Function

php

129
Twitter Timeline API Results

jquery

98
Smooth Scroll To Top

php

119
Time Ago Function

css

106
Text Emboss Technique

server

102
301 Redirect

php

112
Convert Twitter Links To URLs

jquery

244
Smooth Slide Toggle

css

102
Border Radius

php

122
PHP Range

php

92
Generate Random Colour

css

151
Embedding Fonts

css

104
Browser Selection Colour

html

110
Social Bookmark URLs

php

1429
Date to Roman Numerals

php

108
Copyright Trick

php

155
Sorting an Array in PHP

jquery

132
Calculate Lighter Shade of RGB

sql

122
Inline MySQL Replace Statement