d
Amit DhamuSoftware Engineer

Snippets

274

javascript

195
Get object key based on value

typescript

71408
Use as const to create union type

typescript

15181
Chunking arrays

javascript

254
Sort an object

typescript

269
Human friendly file size

javascript

1293
Overwrite console output in Node

javascript

11007
Encode image as base64 using fetch

javascript

184
String to camelCase

python

2311
Flatten a directory

css

1234
3 ways to center a div

typescript

907
Convert roman numeral to number

javascript

225
Check if phrase is a palindrome

javascript

178
10 handy regular expressions

typescript

1338
Recursively deep merging objects

shell

1930
Flags in Bash with getopts

shell

1730
Switch statement in Bash

javascript

140
Leading zeros with padStart

javascript

1202
is_numeric

javascript

2140987
Scroll Into View With Offset

sql

212
Using string_agg in PostgreSQL

shell

2041
Git Status Porcelain

testing

38543
Spying on localStorage in Jest

testing

1404
Advance Timers in Jest

typescript

33163
Debounce

javascript

214
Omit property from object

typescript

159
Time of day greeting

react

356
Scroll Progress Bar Indicator

javascript

214
Unique values from array of objects

shell

138
Commit case changed filenames in Git

react

199
Smooth Scroll to Top

typescript

193
Read Time in minutes

typescript

658
Cartesian Product

javascript

108
Sharing with navigator.share

shell

103
Git status - files only

shell

101
Search in files and move to directory

javascript

6772
Get domain without subdomain

javascript

153
Find a HTML Element With Text

shell

187
Create A Folder For Each File

javascript

135
Capitalize Word

misc

194
CTRL+CMD+DOWN in VSCode

css

123
Invert Images

javascript

120
Sort Array of Objects by Property

javascript

115
Write to a File in Node

php

121
Valid PHP Types

php

205
is_countable

php

398
Replacing MsSQL_ functions

php

313
Migrating from mysql_ to mysqli_

javascript

118
YYYY-MM-DD in Javascript

misc

185
List Available Makefile Commands

javascript

1274
Generate Initials From String

misc

107
Restore macOS Desktop

misc

164
Delete Git Tag

misc

116
Prevent Safari Reopening Previous Session

python

230
Using argparse For Script Arguments

shell

99
Truncate A File

python

129
File Operations In Python

python

105
Loops In Python

shell

107
Bash - For Loop With Range

misc

96
Handy Docker Commands

misc

151
macOS - Get Serial Number

misc

123
Recent Items in macOS Dock

shell

150
Bash - If In Array

sql

110
Helpful mysqldump Commands

css

135
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

144
Trim Whitespace Pixels with Imagemagick

shell

111
What's Using A Port

misc

120
Chrome (macOS) - Delete URL Suggestion

misc

1918
Solr - Select Distinct Field

misc

640
Change Sublime Text 3 Title Bar Colour on macOS

misc

131
Test /etc/fstab

shell

154
Reformat A Hard Drive on Ubuntu

python

100
Write File Contents in Python

misc

420
Force Delete iCloud Account on macOS

shell

891
Step Through Commits On A Branch In Git

php

479
Case Insensitive Multi Dimensional Array Sort

javascript

106
Is Element Visible In Viewport

shell

89
Search For String In Files

misc

1180
Pip - Install Specific Hash, Branch or Tag

misc

183
Plex Downloads API

misc

81
Eject Disc From CD/DVD Drive on Mac

shell

111
Generate LetsEncrypt SSL Certificate

shell

546
Update Plex From Command Line on Ubuntu

javascript

101
Upgrade Node From NPM

shell

124
Use Heredoc In Bash Script

javascript

130
Get List of NPM Packages

server

86
Redirect to https & non-www in NGINX

javascript

122
Escape HTML

javascript

103
Get Query Parameters

shell

111
Create Multiple Subdirectories At Once

css

243
Clear Button On Input Field

javascript

113
Redirect to HTTPS in Express

javascript

12861
Strip Trailing Slashes From Express Requests

misc

96
Install VirtualBoxGuestAdditions In Ubuntu

shell

93
Recursively Find and Delete File

misc

586
Restart Plex From Command Line

misc

150
Install Ruby Gem Behind Proxy

misc

154
Hide Minified File Contents From Git History

shell

77
Search Occurrences In Between Two Strings

misc

92
Git - Change Remote Origin

php

106
Convert XML to Array

css

97
If Statements in SASS

shell

273
Watch Filesize On Command Line

html

780
Placeholder Image if Src Unavailable

shell

163
Get Number of Commits by Author in Git

shell

112
Temporarily Ignore File in Git

shell

125
Search Git Commit History

javascript

236
Social Media Share Counts

misc

105
Solr - Delete By Query

javascript

112
Default Parameter in Function

css

123
Generate Colour Classes in SASS

shell

257
Use Terminal Through Proxy

misc

142
Vim Commands

shell

102
Git Commands

shell

108
UNIX Commands

jquery

950
Insert Character At Position

php

133
MySQL to CSV Export

jquery

181
Check If Radio Button Has Been Checked

jquery

112
Open External Links In New Tab

misc

126
Use Browser As Notepad

sql

85
Get Date If After Interval

misc

121
Mac Recovery Tools

misc

132
Restart Mac In Safe Mode

php

354
Load Random Image From Directory

css

189
Fullscreen Styling

jquery

93
On The Fly Form With jQuery

javascript

107
Comma Separated String To Array

css

92
Make Images Black and White

shell

149
FTP Upload Using Command Prompt or Terminal

jquery

67
Wrap Element Around Other Element

php

96
Exif Image Data

misc

104
Add Close All To Sublime Text Tab Menu

php

169
Search Files Using glob()

php

190
Write To A Text File

shell

153
Handy Shell Commands (Windows)

javascript

156
Double Click Event

server

128
HTTP Authentication

jquery

117
Toggle Text Function

php

86
Useful Folder and File Functions in PHP

jquery

178
Select Nth Class of Element

jquery

100
Scroll To Bottom of Element

css

168
Pure CSS Speech Bubble

jquery

105
Implement Keyboard Shortcuts For Your Website

html

94
Favicon For Windows 8 Tile

php

107
Append To Text File

php

467
mysql_real_escape_string on Array

php

79
Autoload Class

php

104
Use An Array Recursively

javascript

152
Save Canvas as PNG

php

144
Detect AJAX Request in PHP

php

113
Ignore nl2br() Inside Pre/Code Tag

php

163
List System Drives - Windows Only

sql

107
Capitalise Field in Row

misc

144
Create A Lockscreen Shortcut in Windows

php

117
Remove File Extension

jquery

94
Self Executing Function

php

103
Social Bookmark Share Function

php

135
Recursive Directory Scanning

jquery

116
Get Mouse Coordinates

php

113
Get File Extension

css

241
Available List Style Types

css

104
Maintain Aspect Ratio

php

129
Check If Uppercase or Lowercase

php

181
Case Insensitive In Array Check

php

311
List System Drives

misc

106
Remove Empty Lines In SublimeText

php

145
CRUD Functions with PDO

php

125
Simple Select Query with PDO

misc

94
Query Fetch Types in PDO

php

187
PDO Database Connection

sql

102
Duplicate Table Into New Table

jquery

130
Scroll To Position

php

93
Cacheable Tweets

css

103
Mixins in LESS

css

128
Variables in LESS

php

98
Serialize and Unserialize Array

html

145
Viewport Meta Tag For Mobile

javascript

112
Prompt For User Input

css

110
Minify CSS On The Fly

php

115
cURL

jquery

104
Element Is Not

php

77
Specify Decimal Places

php

118
Page Last Modified

php

102
Add Month or Year to Date

javascript

94
OnClick Function

php

77
Embed Images With Data URIs

php

93
Conditional Vs Ternary

php

198
Loop Between Date Range

css

118
CSS3 Animation

css

139
CSS3 Transitions

sql

98
Return Row Count

jquery

115
Filter Table Results

css

119
Box Shadow

shell

77
Dividing The Dock In OSX

php

99
Remove Value From Array

jquery

112
Select Where Attribute Is

server

109
Set Timezone

jquery

104
FadeIn Image When Loaded

php

77
Leading Zeroes

jquery

110
Toggle Password Characters

php

123
Width and Height of SWF

sql

95
Add 1 To Number In Field

html

110
Get Site Favicon

javascript

147
HTML5 Desktop Notifications

php

1007
Create an ICS file

css

104
Full Screen Background Image

css

78
CSS3 Attribute Selectors

php

101
Current File Name

php

106
Delete File From Server

php

118
Highlight Search Keyword

server

1138
Force or remove www from URL

jquery

82
Check If Element Exists

css

81
Multiple Background

html

133
Phone and SMS Prefixes

sql

114
Date of Birth to Age

jquery

89
Disable Right Click Context Menu

css

93
Cross Browser Opacity

php

89
Flickr Photo Search API

server

89
Optimise Site Using DEFLATE

html

158
HTML5 Audio Tag

javascript

140
Popup Window

css

84
Target By Attribute

server

109
Error Document

html

222
Hide Broken Image Icon

javascript

88
Random Colour

php

109
Encode & Decode JSON

php

94
SimpleXML

css

94
Using RGBa

javascript

96
Detect CSS Property

jquery

133
Hover Animations

html

100
RSS Structure

css

103
Append Ellipsis To Long Text

css

111
Target Nth Child in CSS

server

94
Clean URLs

javascript

222
Client Location From Google

html

135
Conditional IE Statements

php

103
Mail in PHP

css

106
Device and Size Detection

sql

103
New Table in MySQL

css

85
CSS Greater Than Sign

jquery

92
ID Is Like

php

103
Email Using PHPMailer

php

133
ZipArchive in PHP

html

82
Full Table Structure

jquery

95
Wordpress Login Shake

jquery

120
TextArea Remaining Characters

php

130
GD Image Filters

javascript

168
iOS and Android Detection

jquery

111
Fixed Position on Scroll

php

101
Multiples Of

html

102
Useful HTML Character Entities

php

123
Generate Random Password

jquery

102
Simple AJAX Using jQuery

shell

105
Show Hidden Files on Mac

html

87
Favicons

javascript

148
Restrict Input to Numbers

jquery

94
setInterval Function

php

111
Twitter Timeline API Results

jquery

81
Smooth Scroll To Top

php

89
Time Ago Function

css

89
Text Emboss Technique

server

88
301 Redirect

php

87
Convert Twitter Links To URLs

jquery

224
Smooth Slide Toggle

css

81
Border Radius

php

105
PHP Range

php

75
Generate Random Colour

css

131
Embedding Fonts

css

85
Browser Selection Colour

html

94
Social Bookmark URLs

php

1389
Date to Roman Numerals

php

92
Copyright Trick

php

133
Sorting an Array in PHP

jquery

109
Calculate Lighter Shade of RGB

sql

105
Inline MySQL Replace Statement