d
Amit DhamuSoftware Engineer

Snippets

274

javascript

191
Get object key based on value

typescript

71399
Use as const to create union type

typescript

15176
Chunking arrays

javascript

252
Sort an object

typescript

265
Human friendly file size

javascript

1287
Overwrite console output in Node

javascript

11003
Encode image as base64 using fetch

javascript

181
String to camelCase

python

2302
Flatten a directory

css

1232
3 ways to center a div

typescript

900
Convert roman numeral to number

javascript

221
Check if phrase is a palindrome

javascript

174
10 handy regular expressions

typescript

1329
Recursively deep merging objects

shell

1923
Flags in Bash with getopts

shell

1723
Switch statement in Bash

javascript

138
Leading zeros with padStart

javascript

1198
is_numeric

javascript

2140911
Scroll Into View With Offset

sql

208
Using string_agg in PostgreSQL

shell

2034
Git Status Porcelain

testing

38537
Spying on localStorage in Jest

testing

1398
Advance Timers in Jest

typescript

33157
Debounce

javascript

211
Omit property from object

typescript

156
Time of day greeting

react

352
Scroll Progress Bar Indicator

javascript

210
Unique values from array of objects

shell

135
Commit case changed filenames in Git

react

198
Smooth Scroll to Top

typescript

188
Read Time in minutes

typescript

652
Cartesian Product

javascript

106
Sharing with navigator.share

shell

103
Git status - files only

shell

100
Search in files and move to directory

javascript

6763
Get domain without subdomain

javascript

148
Find a HTML Element With Text

shell

180
Create A Folder For Each File

javascript

133
Capitalize Word

misc

192
CTRL+CMD+DOWN in VSCode

css

120
Invert Images

javascript

119
Sort Array of Objects by Property

javascript

111
Write to a File in Node

php

116
Valid PHP Types

php

198
is_countable

php

393
Replacing MsSQL_ functions

php

308
Migrating from mysql_ to mysqli_

javascript

116
YYYY-MM-DD in Javascript

misc

181
List Available Makefile Commands

javascript

1262
Generate Initials From String

misc

107
Restore macOS Desktop

misc

158
Delete Git Tag

misc

115
Prevent Safari Reopening Previous Session

python

227
Using argparse For Script Arguments

shell

95
Truncate A File

python

126
File Operations In Python

python

101
Loops In Python

shell

105
Bash - For Loop With Range

misc

92
Handy Docker Commands

misc

150
macOS - Get Serial Number

misc

121
Recent Items in macOS Dock

shell

144
Bash - If In Array

sql

106
Helpful mysqldump Commands

css

131
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

140
Trim Whitespace Pixels with Imagemagick

shell

104
What's Using A Port

misc

119
Chrome (macOS) - Delete URL Suggestion

misc

1912
Solr - Select Distinct Field

misc

632
Change Sublime Text 3 Title Bar Colour on macOS

misc

129
Test /etc/fstab

shell

149
Reformat A Hard Drive on Ubuntu

python

94
Write File Contents in Python

misc

414
Force Delete iCloud Account on macOS

shell

886
Step Through Commits On A Branch In Git

php

476
Case Insensitive Multi Dimensional Array Sort

javascript

103
Is Element Visible In Viewport

shell

86
Search For String In Files

misc

1179
Pip - Install Specific Hash, Branch or Tag

misc

179
Plex Downloads API

misc

79
Eject Disc From CD/DVD Drive on Mac

shell

106
Generate LetsEncrypt SSL Certificate

shell

534
Update Plex From Command Line on Ubuntu

javascript

97
Upgrade Node From NPM

shell

122
Use Heredoc In Bash Script

javascript

128
Get List of NPM Packages

server

83
Redirect to https & non-www in NGINX

javascript

118
Escape HTML

javascript

100
Get Query Parameters

shell

106
Create Multiple Subdirectories At Once

css

238
Clear Button On Input Field

javascript

108
Redirect to HTTPS in Express

javascript

12853
Strip Trailing Slashes From Express Requests

misc

93
Install VirtualBoxGuestAdditions In Ubuntu

shell

90
Recursively Find and Delete File

misc

573
Restart Plex From Command Line

misc

143
Install Ruby Gem Behind Proxy

misc

146
Hide Minified File Contents From Git History

shell

73
Search Occurrences In Between Two Strings

misc

90
Git - Change Remote Origin

php

101
Convert XML to Array

css

94
If Statements in SASS

shell

267
Watch Filesize On Command Line

html

771
Placeholder Image if Src Unavailable

shell

158
Get Number of Commits by Author in Git

shell

109
Temporarily Ignore File in Git

shell

120
Search Git Commit History

javascript

232
Social Media Share Counts

misc

100
Solr - Delete By Query

javascript

108
Default Parameter in Function

css

116
Generate Colour Classes in SASS

shell

253
Use Terminal Through Proxy

misc

139
Vim Commands

shell

98
Git Commands

shell

102
UNIX Commands

jquery

946
Insert Character At Position

php

129
MySQL to CSV Export

jquery

177
Check If Radio Button Has Been Checked

jquery

109
Open External Links In New Tab

misc

124
Use Browser As Notepad

sql

82
Get Date If After Interval

misc

116
Mac Recovery Tools

misc

129
Restart Mac In Safe Mode

php

351
Load Random Image From Directory

css

186
Fullscreen Styling

jquery

92
On The Fly Form With jQuery

javascript

102
Comma Separated String To Array

css

90
Make Images Black and White

shell

144
FTP Upload Using Command Prompt or Terminal

jquery

64
Wrap Element Around Other Element

php

94
Exif Image Data

misc

100
Add Close All To Sublime Text Tab Menu

php

166
Search Files Using glob()

php

185
Write To A Text File

shell

149
Handy Shell Commands (Windows)

javascript

150
Double Click Event

server

124
HTTP Authentication

jquery

115
Toggle Text Function

php

83
Useful Folder and File Functions in PHP

jquery

175
Select Nth Class of Element

jquery

98
Scroll To Bottom of Element

css

165
Pure CSS Speech Bubble

jquery

101
Implement Keyboard Shortcuts For Your Website

html

91
Favicon For Windows 8 Tile

php

103
Append To Text File

php

461
mysql_real_escape_string on Array

php

77
Autoload Class

php

102
Use An Array Recursively

javascript

149
Save Canvas as PNG

php

141
Detect AJAX Request in PHP

php

108
Ignore nl2br() Inside Pre/Code Tag

php

163
List System Drives - Windows Only

sql

105
Capitalise Field in Row

misc

138
Create A Lockscreen Shortcut in Windows

php

113
Remove File Extension

jquery

93
Self Executing Function

php

100
Social Bookmark Share Function

php

130
Recursive Directory Scanning

jquery

112
Get Mouse Coordinates

php

111
Get File Extension

css

234
Available List Style Types

css

102
Maintain Aspect Ratio

php

124
Check If Uppercase or Lowercase

php

177
Case Insensitive In Array Check

php

305
List System Drives

misc

101
Remove Empty Lines In SublimeText

php

142
CRUD Functions with PDO

php

119
Simple Select Query with PDO

misc

92
Query Fetch Types in PDO

php

185
PDO Database Connection

sql

100
Duplicate Table Into New Table

jquery

128
Scroll To Position

php

89
Cacheable Tweets

css

101
Mixins in LESS

css

125
Variables in LESS

php

95
Serialize and Unserialize Array

html

139
Viewport Meta Tag For Mobile

javascript

109
Prompt For User Input

css

108
Minify CSS On The Fly

php

111
cURL

jquery

100
Element Is Not

php

75
Specify Decimal Places

php

115
Page Last Modified

php

98
Add Month or Year to Date

javascript

92
OnClick Function

php

77
Embed Images With Data URIs

php

91
Conditional Vs Ternary

php

194
Loop Between Date Range

css

114
CSS3 Animation

css

132
CSS3 Transitions

sql

95
Return Row Count

jquery

108
Filter Table Results

css

116
Box Shadow

shell

75
Dividing The Dock In OSX

php

97
Remove Value From Array

jquery

109
Select Where Attribute Is

server

108
Set Timezone

jquery

102
FadeIn Image When Loaded

php

74
Leading Zeroes

jquery

103
Toggle Password Characters

php

120
Width and Height of SWF

sql

92
Add 1 To Number In Field

html

108
Get Site Favicon

javascript

147
HTML5 Desktop Notifications

php

997
Create an ICS file

css

103
Full Screen Background Image

css

75
CSS3 Attribute Selectors

php

98
Current File Name

php

102
Delete File From Server

php

115
Highlight Search Keyword

server

1133
Force or remove www from URL

jquery

80
Check If Element Exists

css

79
Multiple Background

html

129
Phone and SMS Prefixes

sql

110
Date of Birth to Age

jquery

85
Disable Right Click Context Menu

css

91
Cross Browser Opacity

php

85
Flickr Photo Search API

server

87
Optimise Site Using DEFLATE

html

157
HTML5 Audio Tag

javascript

138
Popup Window

css

81
Target By Attribute

server

107
Error Document

html

213
Hide Broken Image Icon

javascript

88
Random Colour

php

107
Encode & Decode JSON

php

89
SimpleXML

css

92
Using RGBa

javascript

94
Detect CSS Property

jquery

130
Hover Animations

html

98
RSS Structure

css

102
Append Ellipsis To Long Text

css

107
Target Nth Child in CSS

server

92
Clean URLs

javascript

218
Client Location From Google

html

130
Conditional IE Statements

php

97
Mail in PHP

css

102
Device and Size Detection

sql

96
New Table in MySQL

css

83
CSS Greater Than Sign

jquery

91
ID Is Like

php

97
Email Using PHPMailer

php

132
ZipArchive in PHP

html

82
Full Table Structure

jquery

92
Wordpress Login Shake

jquery

117
TextArea Remaining Characters

php

126
GD Image Filters

javascript

165
iOS and Android Detection

jquery

107
Fixed Position on Scroll

php

96
Multiples Of

html

96
Useful HTML Character Entities

php

115
Generate Random Password

jquery

98
Simple AJAX Using jQuery

shell

104
Show Hidden Files on Mac

html

83
Favicons

javascript

145
Restrict Input to Numbers

jquery

91
setInterval Function

php

107
Twitter Timeline API Results

jquery

80
Smooth Scroll To Top

php

84
Time Ago Function

css

82
Text Emboss Technique

server

86
301 Redirect

php

86
Convert Twitter Links To URLs

jquery

219
Smooth Slide Toggle

css

79
Border Radius

php

101
PHP Range

php

72
Generate Random Colour

css

127
Embedding Fonts

css

82
Browser Selection Colour

html

91
Social Bookmark URLs

php

1379
Date to Roman Numerals

php

91
Copyright Trick

php

130
Sorting an Array in PHP

jquery

104
Calculate Lighter Shade of RGB

sql

103
Inline MySQL Replace Statement