d
Amit DhamuSoftware Engineer

Snippets

274

javascript

234
Get object key based on value

typescript

71485
Use as const to create union type

typescript

15226
Chunking arrays

javascript

277
Sort an object

typescript

316
Human friendly file size

javascript

1354
Overwrite console output in Node

javascript

11038
Encode image as base64 using fetch

javascript

208
String to camelCase

python

2363
Flatten a directory

css

1253
3 ways to center a div

typescript

937
Convert roman numeral to number

javascript

250
Check if phrase is a palindrome

javascript

194
10 handy regular expressions

typescript

1386
Recursively deep merging objects

shell

1971
Flags in Bash with getopts

shell

1759
Switch statement in Bash

javascript

155
Leading zeros with padStart

javascript

1224
is_numeric

javascript

2241322
Scroll Into View With Offset

sql

230
Using string_agg in PostgreSQL

shell

2103
Git Status Porcelain

testing

38578
Spying on localStorage in Jest

testing

1444
Advance Timers in Jest

typescript

33198
Debounce

javascript

234
Omit property from object

typescript

183
Time of day greeting

react

371
Scroll Progress Bar Indicator

javascript

230
Unique values from array of objects

shell

154
Commit case changed filenames in Git

react

219
Smooth Scroll to Top

typescript

218
Read Time in minutes

typescript

681
Cartesian Product

javascript

126
Sharing with navigator.share

shell

119
Git status - files only

shell

118
Search in files and move to directory

javascript

6827
Get domain without subdomain

javascript

182
Find a HTML Element With Text

shell

215
Create A Folder For Each File

javascript

149
Capitalize Word

misc

213
CTRL+CMD+DOWN in VSCode

css

137
Invert Images

javascript

140
Sort Array of Objects by Property

javascript

133
Write to a File in Node

php

156
Valid PHP Types

php

231
is_countable

php

423
Replacing MsSQL_ functions

php

337
Migrating from mysql_ to mysqli_

javascript

138
YYYY-MM-DD in Javascript

misc

206
List Available Makefile Commands

javascript

1311
Generate Initials From String

misc

121
Restore macOS Desktop

misc

183
Delete Git Tag

misc

136
Prevent Safari Reopening Previous Session

python

244
Using argparse For Script Arguments

shell

110
Truncate A File

python

152
File Operations In Python

python

122
Loops In Python

shell

128
Bash - For Loop With Range

misc

108
Handy Docker Commands

misc

168
macOS - Get Serial Number

misc

156
Recent Items in macOS Dock

shell

185
Bash - If In Array

sql

133
Helpful mysqldump Commands

css

153
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

170
Trim Whitespace Pixels with Imagemagick

shell

123
What's Using A Port

misc

132
Chrome (macOS) - Delete URL Suggestion

misc

1938
Solr - Select Distinct Field

misc

668
Change Sublime Text 3 Title Bar Colour on macOS

misc

154
Test /etc/fstab

shell

181
Reformat A Hard Drive on Ubuntu

python

114
Write File Contents in Python

misc

442
Force Delete iCloud Account on macOS

shell

914
Step Through Commits On A Branch In Git

php

506
Case Insensitive Multi Dimensional Array Sort

javascript

119
Is Element Visible In Viewport

shell

103
Search For String In Files

misc

1208
Pip - Install Specific Hash, Branch or Tag

misc

206
Plex Downloads API

misc

96
Eject Disc From CD/DVD Drive on Mac

shell

120
Generate LetsEncrypt SSL Certificate

shell

589
Update Plex From Command Line on Ubuntu

javascript

119
Upgrade Node From NPM

shell

146
Use Heredoc In Bash Script

javascript

155
Get List of NPM Packages

server

106
Redirect to https & non-www in NGINX

javascript

147
Escape HTML

javascript

116
Get Query Parameters

shell

140
Create Multiple Subdirectories At Once

css

259
Clear Button On Input Field

javascript

128
Redirect to HTTPS in Express

javascript

12914
Strip Trailing Slashes From Express Requests

misc

114
Install VirtualBoxGuestAdditions In Ubuntu

shell

115
Recursively Find and Delete File

misc

658
Restart Plex From Command Line

misc

183
Install Ruby Gem Behind Proxy

misc

183
Hide Minified File Contents From Git History

shell

97
Search Occurrences In Between Two Strings

misc

111
Git - Change Remote Origin

php

123
Convert XML to Array

css

115
If Statements in SASS

shell

290
Watch Filesize On Command Line

html

805
Placeholder Image if Src Unavailable

shell

183
Get Number of Commits by Author in Git

shell

134
Temporarily Ignore File in Git

shell

145
Search Git Commit History

javascript

263
Social Media Share Counts

misc

125
Solr - Delete By Query

javascript

125
Default Parameter in Function

css

150
Generate Colour Classes in SASS

shell

275
Use Terminal Through Proxy

misc

167
Vim Commands

shell

121
Git Commands

shell

127
UNIX Commands

jquery

979
Insert Character At Position

php

147
MySQL to CSV Export

jquery

209
Check If Radio Button Has Been Checked

jquery

123
Open External Links In New Tab

misc

139
Use Browser As Notepad

sql

99
Get Date If After Interval

misc

159
Mac Recovery Tools

misc

148
Restart Mac In Safe Mode

php

373
Load Random Image From Directory

css

206
Fullscreen Styling

jquery

111
On The Fly Form With jQuery

javascript

129
Comma Separated String To Array

css

107
Make Images Black and White

shell

170
FTP Upload Using Command Prompt or Terminal

jquery

83
Wrap Element Around Other Element

php

113
Exif Image Data

misc

125
Add Close All To Sublime Text Tab Menu

php

209
Search Files Using glob()

php

211
Write To A Text File

shell

181
Handy Shell Commands (Windows)

javascript

183
Double Click Event

server

145
HTTP Authentication

jquery

138
Toggle Text Function

php

102
Useful Folder and File Functions in PHP

jquery

196
Select Nth Class of Element

jquery

115
Scroll To Bottom of Element

css

196
Pure CSS Speech Bubble

jquery

121
Implement Keyboard Shortcuts For Your Website

html

110
Favicon For Windows 8 Tile

php

124
Append To Text File

php

484
mysql_real_escape_string on Array

php

92
Autoload Class

php

125
Use An Array Recursively

javascript

174
Save Canvas as PNG

php

163
Detect AJAX Request in PHP

php

137
Ignore nl2br() Inside Pre/Code Tag

php

180
List System Drives - Windows Only

sql

124
Capitalise Field in Row

misc

176
Create A Lockscreen Shortcut in Windows

php

134
Remove File Extension

jquery

112
Self Executing Function

php

122
Social Bookmark Share Function

php

161
Recursive Directory Scanning

jquery

147
Get Mouse Coordinates

php

124
Get File Extension

css

265
Available List Style Types

css

122
Maintain Aspect Ratio

php

145
Check If Uppercase or Lowercase

php

191
Case Insensitive In Array Check

php

347
List System Drives

misc

125
Remove Empty Lines In SublimeText

php

160
CRUD Functions with PDO

php

146
Simple Select Query with PDO

misc

111
Query Fetch Types in PDO

php

213
PDO Database Connection

sql

129
Duplicate Table Into New Table

jquery

149
Scroll To Position

php

108
Cacheable Tweets

css

115
Mixins in LESS

css

142
Variables in LESS

php

113
Serialize and Unserialize Array

html

174
Viewport Meta Tag For Mobile

javascript

134
Prompt For User Input

css

124
Minify CSS On The Fly

php

129
cURL

jquery

119
Element Is Not

php

92
Specify Decimal Places

php

143
Page Last Modified

php

124
Add Month or Year to Date

javascript

114
OnClick Function

php

94
Embed Images With Data URIs

php

112
Conditional Vs Ternary

php

232
Loop Between Date Range

css

135
CSS3 Animation

css

152
CSS3 Transitions

sql

117
Return Row Count

jquery

132
Filter Table Results

css

132
Box Shadow

shell

92
Dividing The Dock In OSX

php

118
Remove Value From Array

jquery

130
Select Where Attribute Is

server

123
Set Timezone

jquery

121
FadeIn Image When Loaded

php

97
Leading Zeroes

jquery

132
Toggle Password Characters

php

144
Width and Height of SWF

sql

106
Add 1 To Number In Field

html

131
Get Site Favicon

javascript

168
HTML5 Desktop Notifications

php

1043
Create an ICS file

css

122
Full Screen Background Image

css

105
CSS3 Attribute Selectors

php

121
Current File Name

php

120
Delete File From Server

php

136
Highlight Search Keyword

server

1154
Force or remove www from URL

jquery

100
Check If Element Exists

css

97
Multiple Background

html

161
Phone and SMS Prefixes

sql

136
Date of Birth to Age

jquery

108
Disable Right Click Context Menu

css

107
Cross Browser Opacity

php

110
Flickr Photo Search API

server

105
Optimise Site Using DEFLATE

html

170
HTML5 Audio Tag

javascript

152
Popup Window

css

92
Target By Attribute

server

118
Error Document

html

250
Hide Broken Image Icon

javascript

107
Random Colour

php

122
Encode & Decode JSON

php

105
SimpleXML

css

111
Using RGBa

javascript

122
Detect CSS Property

jquery

145
Hover Animations

html

113
RSS Structure

css

115
Append Ellipsis To Long Text

css

122
Target Nth Child in CSS

server

110
Clean URLs

javascript

235
Client Location From Google

html

164
Conditional IE Statements

php

121
Mail in PHP

css

121
Device and Size Detection

sql

136
New Table in MySQL

css

101
CSS Greater Than Sign

jquery

107
ID Is Like

php

120
Email Using PHPMailer

php

154
ZipArchive in PHP

html

99
Full Table Structure

jquery

119
Wordpress Login Shake

jquery

135
TextArea Remaining Characters

php

154
GD Image Filters

javascript

183
iOS and Android Detection

jquery

135
Fixed Position on Scroll

php

120
Multiples Of

html

120
Useful HTML Character Entities

php

140
Generate Random Password

jquery

128
Simple AJAX Using jQuery

shell

124
Show Hidden Files on Mac

html

107
Favicons

javascript

165
Restrict Input to Numbers

jquery

114
setInterval Function

php

128
Twitter Timeline API Results

jquery

98
Smooth Scroll To Top

php

115
Time Ago Function

css

105
Text Emboss Technique

server

102
301 Redirect

php

111
Convert Twitter Links To URLs

jquery

243
Smooth Slide Toggle

css

100
Border Radius

php

121
PHP Range

php

90
Generate Random Colour

css

150
Embedding Fonts

css

103
Browser Selection Colour

html

110
Social Bookmark URLs

php

1427
Date to Roman Numerals

php

107
Copyright Trick

php

151
Sorting an Array in PHP

jquery

131
Calculate Lighter Shade of RGB

sql

121
Inline MySQL Replace Statement