d
Amit DhamuSoftware Engineer

Snippets

274

javascript

196
Get object key based on value

typescript

71413
Use as const to create union type

typescript

15182
Chunking arrays

javascript

255
Sort an object

typescript

272
Human friendly file size

javascript

1294
Overwrite console output in Node

javascript

11009
Encode image as base64 using fetch

javascript

188
String to camelCase

python

2314
Flatten a directory

css

1235
3 ways to center a div

typescript

909
Convert roman numeral to number

javascript

227
Check if phrase is a palindrome

javascript

179
10 handy regular expressions

typescript

1341
Recursively deep merging objects

shell

1932
Flags in Bash with getopts

shell

1733
Switch statement in Bash

javascript

141
Leading zeros with padStart

javascript

1203
is_numeric

javascript

2141012
Scroll Into View With Offset

sql

213
Using string_agg in PostgreSQL

shell

2046
Git Status Porcelain

testing

38543
Spying on localStorage in Jest

testing

1406
Advance Timers in Jest

typescript

33165
Debounce

javascript

215
Omit property from object

typescript

161
Time of day greeting

react

357
Scroll Progress Bar Indicator

javascript

215
Unique values from array of objects

shell

139
Commit case changed filenames in Git

react

199
Smooth Scroll to Top

typescript

195
Read Time in minutes

typescript

659
Cartesian Product

javascript

108
Sharing with navigator.share

shell

103
Git status - files only

shell

101
Search in files and move to directory

javascript

6774
Get domain without subdomain

javascript

155
Find a HTML Element With Text

shell

190
Create A Folder For Each File

javascript

137
Capitalize Word

misc

194
CTRL+CMD+DOWN in VSCode

css

125
Invert Images

javascript

121
Sort Array of Objects by Property

javascript

117
Write to a File in Node

php

125
Valid PHP Types

php

207
is_countable

php

400
Replacing MsSQL_ functions

php

316
Migrating from mysql_ to mysqli_

javascript

118
YYYY-MM-DD in Javascript

misc

185
List Available Makefile Commands

javascript

1277
Generate Initials From String

misc

107
Restore macOS Desktop

misc

165
Delete Git Tag

misc

117
Prevent Safari Reopening Previous Session

python

230
Using argparse For Script Arguments

shell

99
Truncate A File

python

130
File Operations In Python

python

106
Loops In Python

shell

108
Bash - For Loop With Range

misc

97
Handy Docker Commands

misc

153
macOS - Get Serial Number

misc

125
Recent Items in macOS Dock

shell

154
Bash - If In Array

sql

112
Helpful mysqldump Commands

css

135
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

146
Trim Whitespace Pixels with Imagemagick

shell

111
What's Using A Port

misc

120
Chrome (macOS) - Delete URL Suggestion

misc

1919
Solr - Select Distinct Field

misc

642
Change Sublime Text 3 Title Bar Colour on macOS

misc

132
Test /etc/fstab

shell

155
Reformat A Hard Drive on Ubuntu

python

100
Write File Contents in Python

misc

421
Force Delete iCloud Account on macOS

shell

894
Step Through Commits On A Branch In Git

php

480
Case Insensitive Multi Dimensional Array Sort

javascript

107
Is Element Visible In Viewport

shell

91
Search For String In Files

misc

1182
Pip - Install Specific Hash, Branch or Tag

misc

185
Plex Downloads API

misc

81
Eject Disc From CD/DVD Drive on Mac

shell

112
Generate LetsEncrypt SSL Certificate

shell

549
Update Plex From Command Line on Ubuntu

javascript

103
Upgrade Node From NPM

shell

125
Use Heredoc In Bash Script

javascript

130
Get List of NPM Packages

server

88
Redirect to https & non-www in NGINX

javascript

123
Escape HTML

javascript

104
Get Query Parameters

shell

112
Create Multiple Subdirectories At Once

css

244
Clear Button On Input Field

javascript

114
Redirect to HTTPS in Express

javascript

12862
Strip Trailing Slashes From Express Requests

misc

97
Install VirtualBoxGuestAdditions In Ubuntu

shell

95
Recursively Find and Delete File

misc

591
Restart Plex From Command Line

misc

151
Install Ruby Gem Behind Proxy

misc

156
Hide Minified File Contents From Git History

shell

78
Search Occurrences In Between Two Strings

misc

95
Git - Change Remote Origin

php

106
Convert XML to Array

css

98
If Statements in SASS

shell

273
Watch Filesize On Command Line

html

781
Placeholder Image if Src Unavailable

shell

163
Get Number of Commits by Author in Git

shell

115
Temporarily Ignore File in Git

shell

127
Search Git Commit History

javascript

237
Social Media Share Counts

misc

107
Solr - Delete By Query

javascript

113
Default Parameter in Function

css

125
Generate Colour Classes in SASS

shell

257
Use Terminal Through Proxy

misc

143
Vim Commands

shell

102
Git Commands

shell

109
UNIX Commands

jquery

950
Insert Character At Position

php

134
MySQL to CSV Export

jquery

182
Check If Radio Button Has Been Checked

jquery

112
Open External Links In New Tab

misc

127
Use Browser As Notepad

sql

86
Get Date If After Interval

misc

123
Mac Recovery Tools

misc

134
Restart Mac In Safe Mode

php

355
Load Random Image From Directory

css

189
Fullscreen Styling

jquery

94
On The Fly Form With jQuery

javascript

110
Comma Separated String To Array

css

94
Make Images Black and White

shell

149
FTP Upload Using Command Prompt or Terminal

jquery

68
Wrap Element Around Other Element

php

96
Exif Image Data

misc

105
Add Close All To Sublime Text Tab Menu

php

173
Search Files Using glob()

php

190
Write To A Text File

shell

154
Handy Shell Commands (Windows)

javascript

158
Double Click Event

server

128
HTTP Authentication

jquery

120
Toggle Text Function

php

87
Useful Folder and File Functions in PHP

jquery

179
Select Nth Class of Element

jquery

101
Scroll To Bottom of Element

css

171
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

469
mysql_real_escape_string on Array

php

79
Autoload Class

php

105
Use An Array Recursively

javascript

155
Save Canvas as PNG

php

146
Detect AJAX Request in PHP

php

115
Ignore nl2br() Inside Pre/Code Tag

php

164
List System Drives - Windows Only

sql

107
Capitalise Field in Row

misc

146
Create A Lockscreen Shortcut in Windows

php

118
Remove File Extension

jquery

94
Self Executing Function

php

105
Social Bookmark Share Function

php

139
Recursive Directory Scanning

jquery

120
Get Mouse Coordinates

php

113
Get File Extension

css

242
Available List Style Types

css

105
Maintain Aspect Ratio

php

129
Check If Uppercase or Lowercase

php

182
Case Insensitive In Array Check

php

316
List System Drives

misc

108
Remove Empty Lines In SublimeText

php

147
CRUD Functions with PDO

php

127
Simple Select Query with PDO

misc

95
Query Fetch Types in PDO

php

191
PDO Database Connection

sql

105
Duplicate Table Into New Table

jquery

130
Scroll To Position

php

93
Cacheable Tweets

css

103
Mixins in LESS

css

129
Variables in LESS

php

98
Serialize and Unserialize Array

html

147
Viewport Meta Tag For Mobile

javascript

115
Prompt For User Input

css

111
Minify CSS On The Fly

php

116
cURL

jquery

104
Element Is Not

php

77
Specify Decimal Places

php

121
Page Last Modified

php

102
Add Month or Year to Date

javascript

95
OnClick Function

php

78
Embed Images With Data URIs

php

95
Conditional Vs Ternary

php

200
Loop Between Date Range

css

118
CSS3 Animation

css

140
CSS3 Transitions

sql

99
Return Row Count

jquery

115
Filter Table Results

css

119
Box Shadow

shell

77
Dividing The Dock In OSX

php

102
Remove Value From Array

jquery

113
Select Where Attribute Is

server

110
Set Timezone

jquery

105
FadeIn Image When Loaded

php

80
Leading Zeroes

jquery

110
Toggle Password Characters

php

125
Width and Height of SWF

sql

95
Add 1 To Number In Field

html

112
Get Site Favicon

javascript

147
HTML5 Desktop Notifications

php

1010
Create an ICS file

css

107
Full Screen Background Image

css

80
CSS3 Attribute Selectors

php

102
Current File Name

php

106
Delete File From Server

php

120
Highlight Search Keyword

server

1138
Force or remove www from URL

jquery

86
Check If Element Exists

css

82
Multiple Background

html

134
Phone and SMS Prefixes

sql

116
Date of Birth to Age

jquery

90
Disable Right Click Context Menu

css

94
Cross Browser Opacity

php

94
Flickr Photo Search API

server

90
Optimise Site Using DEFLATE

html

158
HTML5 Audio Tag

javascript

141
Popup Window

css

85
Target By Attribute

server

109
Error Document

html

227
Hide Broken Image Icon

javascript

88
Random Colour

php

109
Encode & Decode JSON

php

95
SimpleXML

css

95
Using RGBa

javascript

97
Detect CSS Property

jquery

134
Hover Animations

html

101
RSS Structure

css

103
Append Ellipsis To Long Text

css

111
Target Nth Child in CSS

server

95
Clean URLs

javascript

222
Client Location From Google

html

136
Conditional IE Statements

php

106
Mail in PHP

css

106
Device and Size Detection

sql

106
New Table in MySQL

css

86
CSS Greater Than Sign

jquery

93
ID Is Like

php

104
Email Using PHPMailer

php

135
ZipArchive in PHP

html

82
Full Table Structure

jquery

98
Wordpress Login Shake

jquery

121
TextArea Remaining Characters

php

131
GD Image Filters

javascript

168
iOS and Android Detection

jquery

114
Fixed Position on Scroll

php

101
Multiples Of

html

105
Useful HTML Character Entities

php

124
Generate Random Password

jquery

103
Simple AJAX Using jQuery

shell

106
Show Hidden Files on Mac

html

89
Favicons

javascript

148
Restrict Input to Numbers

jquery

94
setInterval Function

php

111
Twitter Timeline API Results

jquery

82
Smooth Scroll To Top

php

90
Time Ago Function

css

89
Text Emboss Technique

server

88
301 Redirect

php

89
Convert Twitter Links To URLs

jquery

227
Smooth Slide Toggle

css

83
Border Radius

php

107
PHP Range

php

76
Generate Random Colour

css

132
Embedding Fonts

css

85
Browser Selection Colour

html

95
Social Bookmark URLs

php

1390
Date to Roman Numerals

php

93
Copyright Trick

php

133
Sorting an Array in PHP

jquery

111
Calculate Lighter Shade of RGB

sql

105
Inline MySQL Replace Statement