d
Amit DhamuSoftware Engineer

Snippets

274

javascript

205
Get object key based on value

typescript

71428
Use as const to create union type

typescript

15192
Chunking arrays

javascript

263
Sort an object

typescript

280
Human friendly file size

javascript

1306
Overwrite console output in Node

javascript

11014
Encode image as base64 using fetch

javascript

191
String to camelCase

python

2329
Flatten a directory

css

1240
3 ways to center a div

typescript

916
Convert roman numeral to number

javascript

232
Check if phrase is a palindrome

javascript

180
10 handy regular expressions

typescript

1353
Recursively deep merging objects

shell

1942
Flags in Bash with getopts

shell

1737
Switch statement in Bash

javascript

145
Leading zeros with padStart

javascript

1207
is_numeric

javascript

2241096
Scroll Into View With Offset

sql

218
Using string_agg in PostgreSQL

shell

2058
Git Status Porcelain

testing

38551
Spying on localStorage in Jest

testing

1418
Advance Timers in Jest

typescript

33173
Debounce

javascript

217
Omit property from object

typescript

165
Time of day greeting

react

361
Scroll Progress Bar Indicator

javascript

217
Unique values from array of objects

shell

142
Commit case changed filenames in Git

react

202
Smooth Scroll to Top

typescript

201
Read Time in minutes

typescript

665
Cartesian Product

javascript

112
Sharing with navigator.share

shell

108
Git status - files only

shell

105
Search in files and move to directory

javascript

6785
Get domain without subdomain

javascript

166
Find a HTML Element With Text

shell

200
Create A Folder For Each File

javascript

140
Capitalize Word

misc

197
CTRL+CMD+DOWN in VSCode

css

130
Invert Images

javascript

127
Sort Array of Objects by Property

javascript

120
Write to a File in Node

php

132
Valid PHP Types

php

213
is_countable

php

405
Replacing MsSQL_ functions

php

321
Migrating from mysql_ to mysqli_

javascript

124
YYYY-MM-DD in Javascript

misc

191
List Available Makefile Commands

javascript

1286
Generate Initials From String

misc

110
Restore macOS Desktop

misc

173
Delete Git Tag

misc

123
Prevent Safari Reopening Previous Session

python

234
Using argparse For Script Arguments

shell

101
Truncate A File

python

133
File Operations In Python

python

110
Loops In Python

shell

115
Bash - For Loop With Range

misc

101
Handy Docker Commands

misc

156
macOS - Get Serial Number

misc

131
Recent Items in macOS Dock

shell

160
Bash - If In Array

sql

115
Helpful mysqldump Commands

css

139
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

154
Trim Whitespace Pixels with Imagemagick

shell

114
What's Using A Port

misc

121
Chrome (macOS) - Delete URL Suggestion

misc

1922
Solr - Select Distinct Field

misc

648
Change Sublime Text 3 Title Bar Colour on macOS

misc

136
Test /etc/fstab

shell

159
Reformat A Hard Drive on Ubuntu

python

103
Write File Contents in Python

misc

426
Force Delete iCloud Account on macOS

shell

898
Step Through Commits On A Branch In Git

php

487
Case Insensitive Multi Dimensional Array Sort

javascript

109
Is Element Visible In Viewport

shell

94
Search For String In Files

misc

1184
Pip - Install Specific Hash, Branch or Tag

misc

188
Plex Downloads API

misc

85
Eject Disc From CD/DVD Drive on Mac

shell

113
Generate LetsEncrypt SSL Certificate

shell

562
Update Plex From Command Line on Ubuntu

javascript

107
Upgrade Node From NPM

shell

128
Use Heredoc In Bash Script

javascript

136
Get List of NPM Packages

server

92
Redirect to https & non-www in NGINX

javascript

127
Escape HTML

javascript

107
Get Query Parameters

shell

122
Create Multiple Subdirectories At Once

css

247
Clear Button On Input Field

javascript

116
Redirect to HTTPS in Express

javascript

12871
Strip Trailing Slashes From Express Requests

misc

100
Install VirtualBoxGuestAdditions In Ubuntu

shell

98
Recursively Find and Delete File

misc

609
Restart Plex From Command Line

misc

158
Install Ruby Gem Behind Proxy

misc

164
Hide Minified File Contents From Git History

shell

82
Search Occurrences In Between Two Strings

misc

97
Git - Change Remote Origin

php

109
Convert XML to Array

css

103
If Statements in SASS

shell

278
Watch Filesize On Command Line

html

785
Placeholder Image if Src Unavailable

shell

168
Get Number of Commits by Author in Git

shell

118
Temporarily Ignore File in Git

shell

132
Search Git Commit History

javascript

245
Social Media Share Counts

misc

114
Solr - Delete By Query

javascript

115
Default Parameter in Function

css

133
Generate Colour Classes in SASS

shell

262
Use Terminal Through Proxy

misc

149
Vim Commands

shell

107
Git Commands

shell

112
UNIX Commands

jquery

959
Insert Character At Position

php

136
MySQL to CSV Export

jquery

188
Check If Radio Button Has Been Checked

jquery

113
Open External Links In New Tab

misc

129
Use Browser As Notepad

sql

89
Get Date If After Interval

misc

134
Mac Recovery Tools

misc

138
Restart Mac In Safe Mode

php

358
Load Random Image From Directory

css

194
Fullscreen Styling

jquery

98
On The Fly Form With jQuery

javascript

117
Comma Separated String To Array

css

95
Make Images Black and White

shell

152
FTP Upload Using Command Prompt or Terminal

jquery

70
Wrap Element Around Other Element

php

100
Exif Image Data

misc

111
Add Close All To Sublime Text Tab Menu

php

180
Search Files Using glob()

php

194
Write To A Text File

shell

158
Handy Shell Commands (Windows)

javascript

165
Double Click Event

server

132
HTTP Authentication

jquery

124
Toggle Text Function

php

91
Useful Folder and File Functions in PHP

jquery

182
Select Nth Class of Element

jquery

102
Scroll To Bottom of Element

css

175
Pure CSS Speech Bubble

jquery

111
Implement Keyboard Shortcuts For Your Website

html

96
Favicon For Windows 8 Tile

php

109
Append To Text File

php

473
mysql_real_escape_string on Array

php

83
Autoload Class

php

110
Use An Array Recursively

javascript

159
Save Canvas as PNG

php

151
Detect AJAX Request in PHP

php

120
Ignore nl2br() Inside Pre/Code Tag

php

168
List System Drives - Windows Only

sql

112
Capitalise Field in Row

misc

154
Create A Lockscreen Shortcut in Windows

php

122
Remove File Extension

jquery

99
Self Executing Function

php

110
Social Bookmark Share Function

php

142
Recursive Directory Scanning

jquery

127
Get Mouse Coordinates

php

115
Get File Extension

css

253
Available List Style Types

css

109
Maintain Aspect Ratio

php

132
Check If Uppercase or Lowercase

php

186
Case Insensitive In Array Check

php

326
List System Drives

misc

113
Remove Empty Lines In SublimeText

php

151
CRUD Functions with PDO

php

133
Simple Select Query with PDO

misc

99
Query Fetch Types in PDO

php

196
PDO Database Connection

sql

110
Duplicate Table Into New Table

jquery

135
Scroll To Position

php

97
Cacheable Tweets

css

105
Mixins in LESS

css

134
Variables in LESS

php

102
Serialize and Unserialize Array

html

153
Viewport Meta Tag For Mobile

javascript

119
Prompt For User Input

css

113
Minify CSS On The Fly

php

120
cURL

jquery

106
Element Is Not

php

80
Specify Decimal Places

php

124
Page Last Modified

php

105
Add Month or Year to Date

javascript

98
OnClick Function

php

81
Embed Images With Data URIs

php

99
Conditional Vs Ternary

php

206
Loop Between Date Range

css

122
CSS3 Animation

css

142
CSS3 Transitions

sql

102
Return Row Count

jquery

118
Filter Table Results

css

121
Box Shadow

shell

79
Dividing The Dock In OSX

php

105
Remove Value From Array

jquery

119
Select Where Attribute Is

server

111
Set Timezone

jquery

109
FadeIn Image When Loaded

php

81
Leading Zeroes

jquery

116
Toggle Password Characters

php

131
Width and Height of SWF

sql

96
Add 1 To Number In Field

html

115
Get Site Favicon

javascript

151
HTML5 Desktop Notifications

php

1019
Create an ICS file

css

112
Full Screen Background Image

css

85
CSS3 Attribute Selectors

php

107
Current File Name

php

111
Delete File From Server

php

125
Highlight Search Keyword

server

1142
Force or remove www from URL

jquery

88
Check If Element Exists

css

83
Multiple Background

html

144
Phone and SMS Prefixes

sql

122
Date of Birth to Age

jquery

94
Disable Right Click Context Menu

css

96
Cross Browser Opacity

php

99
Flickr Photo Search API

server

93
Optimise Site Using DEFLATE

html

160
HTML5 Audio Tag

javascript

142
Popup Window

css

86
Target By Attribute

server

110
Error Document

html

235
Hide Broken Image Icon

javascript

90
Random Colour

php

112
Encode & Decode JSON

php

95
SimpleXML

css

100
Using RGBa

javascript

104
Detect CSS Property

jquery

137
Hover Animations

html

102
RSS Structure

css

106
Append Ellipsis To Long Text

css

113
Target Nth Child in CSS

server

98
Clean URLs

javascript

227
Client Location From Google

html

143
Conditional IE Statements

php

112
Mail in PHP

css

111
Device and Size Detection

sql

115
New Table in MySQL

css

91
CSS Greater Than Sign

jquery

97
ID Is Like

php

110
Email Using PHPMailer

php

142
ZipArchive in PHP

html

87
Full Table Structure

jquery

104
Wordpress Login Shake

jquery

123
TextArea Remaining Characters

php

136
GD Image Filters

javascript

172
iOS and Android Detection

jquery

118
Fixed Position on Scroll

php

105
Multiples Of

html

110
Useful HTML Character Entities

php

129
Generate Random Password

jquery

107
Simple AJAX Using jQuery

shell

109
Show Hidden Files on Mac

html

90
Favicons

javascript

152
Restrict Input to Numbers

jquery

97
setInterval Function

php

113
Twitter Timeline API Results

jquery

83
Smooth Scroll To Top

php

97
Time Ago Function

css

93
Text Emboss Technique

server

90
301 Redirect

php

94
Convert Twitter Links To URLs

jquery

228
Smooth Slide Toggle

css

89
Border Radius

php

111
PHP Range

php

78
Generate Random Colour

css

137
Embedding Fonts

css

92
Browser Selection Colour

html

98
Social Bookmark URLs

php

1399
Date to Roman Numerals

php

97
Copyright Trick

php

137
Sorting an Array in PHP

jquery

116
Calculate Lighter Shade of RGB

sql

110
Inline MySQL Replace Statement