d
Amit DhamuSoftware Engineer

Snippets

274

javascript

210
Get object key based on value

typescript

71438
Use as const to create union type

typescript

15201
Chunking arrays

javascript

265
Sort an object

typescript

288
Human friendly file size

javascript

1311
Overwrite console output in Node

javascript

11021
Encode image as base64 using fetch

javascript

195
String to camelCase

python

2337
Flatten a directory

css

1244
3 ways to center a div

typescript

919
Convert roman numeral to number

javascript

234
Check if phrase is a palindrome

javascript

182
10 handy regular expressions

typescript

1358
Recursively deep merging objects

shell

1950
Flags in Bash with getopts

shell

1743
Switch statement in Bash

javascript

147
Leading zeros with padStart

javascript

1209
is_numeric

javascript

2241112
Scroll Into View With Offset

sql

219
Using string_agg in PostgreSQL

shell

2063
Git Status Porcelain

testing

38555
Spying on localStorage in Jest

testing

1425
Advance Timers in Jest

typescript

33178
Debounce

javascript

222
Omit property from object

typescript

167
Time of day greeting

react

364
Scroll Progress Bar Indicator

javascript

218
Unique values from array of objects

shell

146
Commit case changed filenames in Git

react

203
Smooth Scroll to Top

typescript

205
Read Time in minutes

typescript

669
Cartesian Product

javascript

115
Sharing with navigator.share

shell

109
Git status - files only

shell

107
Search in files and move to directory

javascript

6789
Get domain without subdomain

javascript

171
Find a HTML Element With Text

shell

205
Create A Folder For Each File

javascript

142
Capitalize Word

misc

200
CTRL+CMD+DOWN in VSCode

css

131
Invert Images

javascript

128
Sort Array of Objects by Property

javascript

123
Write to a File in Node

php

140
Valid PHP Types

php

218
is_countable

php

408
Replacing MsSQL_ functions

php

324
Migrating from mysql_ to mysqli_

javascript

125
YYYY-MM-DD in Javascript

misc

195
List Available Makefile Commands

javascript

1294
Generate Initials From String

misc

112
Restore macOS Desktop

misc

175
Delete Git Tag

misc

125
Prevent Safari Reopening Previous Session

python

236
Using argparse For Script Arguments

shell

103
Truncate A File

python

134
File Operations In Python

python

111
Loops In Python

shell

117
Bash - For Loop With Range

misc

102
Handy Docker Commands

misc

159
macOS - Get Serial Number

misc

148
Recent Items in macOS Dock

shell

165
Bash - If In Array

sql

119
Helpful mysqldump Commands

css

141
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

157
Trim Whitespace Pixels with Imagemagick

shell

115
What's Using A Port

misc

122
Chrome (macOS) - Delete URL Suggestion

misc

1925
Solr - Select Distinct Field

misc

652
Change Sublime Text 3 Title Bar Colour on macOS

misc

139
Test /etc/fstab

shell

164
Reformat A Hard Drive on Ubuntu

python

104
Write File Contents in Python

misc

431
Force Delete iCloud Account on macOS

shell

902
Step Through Commits On A Branch In Git

php

491
Case Insensitive Multi Dimensional Array Sort

javascript

111
Is Element Visible In Viewport

shell

95
Search For String In Files

misc

1196
Pip - Install Specific Hash, Branch or Tag

misc

190
Plex Downloads API

misc

85
Eject Disc From CD/DVD Drive on Mac

shell

114
Generate LetsEncrypt SSL Certificate

shell

567
Update Plex From Command Line on Ubuntu

javascript

109
Upgrade Node From NPM

shell

131
Use Heredoc In Bash Script

javascript

138
Get List of NPM Packages

server

94
Redirect to https & non-www in NGINX

javascript

134
Escape HTML

javascript

109
Get Query Parameters

shell

126
Create Multiple Subdirectories At Once

css

250
Clear Button On Input Field

javascript

118
Redirect to HTTPS in Express

javascript

12880
Strip Trailing Slashes From Express Requests

misc

102
Install VirtualBoxGuestAdditions In Ubuntu

shell

103
Recursively Find and Delete File

misc

618
Restart Plex From Command Line

misc

172
Install Ruby Gem Behind Proxy

misc

168
Hide Minified File Contents From Git History

shell

84
Search Occurrences In Between Two Strings

misc

99
Git - Change Remote Origin

php

113
Convert XML to Array

css

105
If Statements in SASS

shell

280
Watch Filesize On Command Line

html

790
Placeholder Image if Src Unavailable

shell

170
Get Number of Commits by Author in Git

shell

120
Temporarily Ignore File in Git

shell

135
Search Git Commit History

javascript

250
Social Media Share Counts

misc

116
Solr - Delete By Query

javascript

118
Default Parameter in Function

css

136
Generate Colour Classes in SASS

shell

265
Use Terminal Through Proxy

misc

150
Vim Commands

shell

109
Git Commands

shell

114
UNIX Commands

jquery

965
Insert Character At Position

php

138
MySQL to CSV Export

jquery

190
Check If Radio Button Has Been Checked

jquery

115
Open External Links In New Tab

misc

131
Use Browser As Notepad

sql

90
Get Date If After Interval

misc

138
Mac Recovery Tools

misc

140
Restart Mac In Safe Mode

php

361
Load Random Image From Directory

css

196
Fullscreen Styling

jquery

99
On The Fly Form With jQuery

javascript

119
Comma Separated String To Array

css

97
Make Images Black and White

shell

158
FTP Upload Using Command Prompt or Terminal

jquery

73
Wrap Element Around Other Element

php

104
Exif Image Data

misc

115
Add Close All To Sublime Text Tab Menu

php

185
Search Files Using glob()

php

195
Write To A Text File

shell

161
Handy Shell Commands (Windows)

javascript

168
Double Click Event

server

134
HTTP Authentication

jquery

127
Toggle Text Function

php

93
Useful Folder and File Functions in PHP

jquery

185
Select Nth Class of Element

jquery

104
Scroll To Bottom of Element

css

178
Pure CSS Speech Bubble

jquery

113
Implement Keyboard Shortcuts For Your Website

html

102
Favicon For Windows 8 Tile

php

111
Append To Text File

php

476
mysql_real_escape_string on Array

php

84
Autoload Class

php

113
Use An Array Recursively

javascript

163
Save Canvas as PNG

php

154
Detect AJAX Request in PHP

php

123
Ignore nl2br() Inside Pre/Code Tag

php

169
List System Drives - Windows Only

sql

114
Capitalise Field in Row

misc

159
Create A Lockscreen Shortcut in Windows

php

124
Remove File Extension

jquery

101
Self Executing Function

php

112
Social Bookmark Share Function

php

144
Recursive Directory Scanning

jquery

131
Get Mouse Coordinates

php

117
Get File Extension

css

256
Available List Style Types

css

112
Maintain Aspect Ratio

php

136
Check If Uppercase or Lowercase

php

187
Case Insensitive In Array Check

php

332
List System Drives

misc

116
Remove Empty Lines In SublimeText

php

153
CRUD Functions with PDO

php

134
Simple Select Query with PDO

misc

101
Query Fetch Types in PDO

php

199
PDO Database Connection

sql

114
Duplicate Table Into New Table

jquery

139
Scroll To Position

php

98
Cacheable Tweets

css

106
Mixins in LESS

css

136
Variables in LESS

php

104
Serialize and Unserialize Array

html

157
Viewport Meta Tag For Mobile

javascript

123
Prompt For User Input

css

115
Minify CSS On The Fly

php

123
cURL

jquery

109
Element Is Not

php

82
Specify Decimal Places

php

126
Page Last Modified

php

107
Add Month or Year to Date

javascript

101
OnClick Function

php

83
Embed Images With Data URIs

php

101
Conditional Vs Ternary

php

213
Loop Between Date Range

css

125
CSS3 Animation

css

144
CSS3 Transitions

sql

103
Return Row Count

jquery

119
Filter Table Results

css

123
Box Shadow

shell

81
Dividing The Dock In OSX

php

107
Remove Value From Array

jquery

122
Select Where Attribute Is

server

113
Set Timezone

jquery

111
FadeIn Image When Loaded

php

83
Leading Zeroes

jquery

120
Toggle Password Characters

php

135
Width and Height of SWF

sql

97
Add 1 To Number In Field

html

118
Get Site Favicon

javascript

154
HTML5 Desktop Notifications

php

1025
Create an ICS file

css

114
Full Screen Background Image

css

96
CSS3 Attribute Selectors

php

109
Current File Name

php

113
Delete File From Server

php

128
Highlight Search Keyword

server

1145
Force or remove www from URL

jquery

90
Check If Element Exists

css

86
Multiple Background

html

148
Phone and SMS Prefixes

sql

124
Date of Birth to Age

jquery

95
Disable Right Click Context Menu

css

99
Cross Browser Opacity

php

100
Flickr Photo Search API

server

95
Optimise Site Using DEFLATE

html

161
HTML5 Audio Tag

javascript

144
Popup Window

css

88
Target By Attribute

server

112
Error Document

html

238
Hide Broken Image Icon

javascript

91
Random Colour

php

113
Encode & Decode JSON

php

96
SimpleXML

css

101
Using RGBa

javascript

106
Detect CSS Property

jquery

138
Hover Animations

html

105
RSS Structure

css

108
Append Ellipsis To Long Text

css

115
Target Nth Child in CSS

server

99
Clean URLs

javascript

227
Client Location From Google

html

146
Conditional IE Statements

php

115
Mail in PHP

css

113
Device and Size Detection

sql

121
New Table in MySQL

css

93
CSS Greater Than Sign

jquery

98
ID Is Like

php

111
Email Using PHPMailer

php

143
ZipArchive in PHP

html

90
Full Table Structure

jquery

108
Wordpress Login Shake

jquery

125
TextArea Remaining Characters

php

139
GD Image Filters

javascript

175
iOS and Android Detection

jquery

120
Fixed Position on Scroll

php

107
Multiples Of

html

112
Useful HTML Character Entities

php

132
Generate Random Password

jquery

110
Simple AJAX Using jQuery

shell

111
Show Hidden Files on Mac

html

92
Favicons

javascript

154
Restrict Input to Numbers

jquery

101
setInterval Function

php

115
Twitter Timeline API Results

jquery

85
Smooth Scroll To Top

php

99
Time Ago Function

css

95
Text Emboss Technique

server

92
301 Redirect

php

98
Convert Twitter Links To URLs

jquery

232
Smooth Slide Toggle

css

90
Border Radius

php

113
PHP Range

php

79
Generate Random Colour

css

139
Embedding Fonts

css

93
Browser Selection Colour

html

101
Social Bookmark URLs

php

1408
Date to Roman Numerals

php

98
Copyright Trick

php

138
Sorting an Array in PHP

jquery

119
Calculate Lighter Shade of RGB

sql

112
Inline MySQL Replace Statement