d
Amit DhamuSoftware Engineer

Snippets

274

javascript

197
Get object key based on value

typescript

71417
Use as const to create union type

typescript

15184
Chunking arrays

javascript

256
Sort an object

typescript

274
Human friendly file size

javascript

1297
Overwrite console output in Node

javascript

11009
Encode image as base64 using fetch

javascript

189
String to camelCase

python

2316
Flatten a directory

css

1235
3 ways to center a div

typescript

910
Convert roman numeral to number

javascript

227
Check if phrase is a palindrome

javascript

179
10 handy regular expressions

typescript

1344
Recursively deep merging objects

shell

1934
Flags in Bash with getopts

shell

1733
Switch statement in Bash

javascript

141
Leading zeros with padStart

javascript

1204
is_numeric

javascript

2141024
Scroll Into View With Offset

sql

214
Using string_agg in PostgreSQL

shell

2047
Git Status Porcelain

testing

38545
Spying on localStorage in Jest

testing

1409
Advance Timers in Jest

typescript

33167
Debounce

javascript

215
Omit property from object

typescript

161
Time of day greeting

react

357
Scroll Progress Bar Indicator

javascript

216
Unique values from array of objects

shell

139
Commit case changed filenames in Git

react

200
Smooth Scroll to Top

typescript

196
Read Time in minutes

typescript

660
Cartesian Product

javascript

108
Sharing with navigator.share

shell

105
Git status - files only

shell

103
Search in files and move to directory

javascript

6776
Get domain without subdomain

javascript

156
Find a HTML Element With Text

shell

194
Create A Folder For Each File

javascript

138
Capitalize Word

misc

195
CTRL+CMD+DOWN in VSCode

css

126
Invert Images

javascript

123
Sort Array of Objects by Property

javascript

117
Write to a File in Node

php

126
Valid PHP Types

php

208
is_countable

php

401
Replacing MsSQL_ functions

php

317
Migrating from mysql_ to mysqli_

javascript

120
YYYY-MM-DD in Javascript

misc

186
List Available Makefile Commands

javascript

1278
Generate Initials From String

misc

107
Restore macOS Desktop

misc

166
Delete Git Tag

misc

118
Prevent Safari Reopening Previous Session

python

231
Using argparse For Script Arguments

shell

100
Truncate A File

python

130
File Operations In Python

python

107
Loops In Python

shell

110
Bash - For Loop With Range

misc

98
Handy Docker Commands

misc

154
macOS - Get Serial Number

misc

125
Recent Items in macOS Dock

shell

155
Bash - If In Array

sql

112
Helpful mysqldump Commands

css

136
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

147
Trim Whitespace Pixels with Imagemagick

shell

111
What's Using A Port

misc

120
Chrome (macOS) - Delete URL Suggestion

misc

1920
Solr - Select Distinct Field

misc

643
Change Sublime Text 3 Title Bar Colour on macOS

misc

133
Test /etc/fstab

shell

155
Reformat A Hard Drive on Ubuntu

python

100
Write File Contents in Python

misc

423
Force Delete iCloud Account on macOS

shell

894
Step Through Commits On A Branch In Git

php

482
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

551
Update Plex From Command Line on Ubuntu

javascript

104
Upgrade Node From NPM

shell

125
Use Heredoc In Bash Script

javascript

131
Get List of NPM Packages

server

88
Redirect to https & non-www in NGINX

javascript

124
Escape HTML

javascript

105
Get Query Parameters

shell

117
Create Multiple Subdirectories At Once

css

245
Clear Button On Input Field

javascript

114
Redirect to HTTPS in Express

javascript

12863
Strip Trailing Slashes From Express Requests

misc

98
Install VirtualBoxGuestAdditions In Ubuntu

shell

96
Recursively Find and Delete File

misc

593
Restart Plex From Command Line

misc

152
Install Ruby Gem Behind Proxy

misc

157
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

99
If Statements in SASS

shell

274
Watch Filesize On Command Line

html

781
Placeholder Image if Src Unavailable

shell

164
Get Number of Commits by Author in Git

shell

115
Temporarily Ignore File in Git

shell

127
Search Git Commit History

javascript

238
Social Media Share Counts

misc

108
Solr - Delete By Query

javascript

113
Default Parameter in Function

css

126
Generate Colour Classes in SASS

shell

257
Use Terminal Through Proxy

misc

144
Vim Commands

shell

104
Git Commands

shell

109
UNIX Commands

jquery

951
Insert Character At Position

php

134
MySQL to CSV Export

jquery

185
Check If Radio Button Has Been Checked

jquery

112
Open External Links In New Tab

misc

128
Use Browser As Notepad

sql

87
Get Date If After Interval

misc

128
Mac Recovery Tools

misc

135
Restart Mac In Safe Mode

php

356
Load Random Image From Directory

css

190
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

69
Wrap Element Around Other Element

php

96
Exif Image Data

misc

107
Add Close All To Sublime Text Tab Menu

php

173
Search Files Using glob()

php

191
Write To A Text File

shell

155
Handy Shell Commands (Windows)

javascript

159
Double Click Event

server

129
HTTP Authentication

jquery

120
Toggle Text Function

php

88
Useful Folder and File Functions in PHP

jquery

180
Select Nth Class of Element

jquery

102
Scroll To Bottom of Element

css

172
Pure CSS Speech Bubble

jquery

107
Implement Keyboard Shortcuts For Your Website

html

95
Favicon For Windows 8 Tile

php

107
Append To Text File

php

469
mysql_real_escape_string on Array

php

80
Autoload Class

php

106
Use An Array Recursively

javascript

157
Save Canvas as PNG

php

148
Detect AJAX Request in PHP

php

116
Ignore nl2br() Inside Pre/Code Tag

php

164
List System Drives - Windows Only

sql

108
Capitalise Field in Row

misc

148
Create A Lockscreen Shortcut in Windows

php

120
Remove File Extension

jquery

95
Self Executing Function

php

107
Social Bookmark Share Function

php

140
Recursive Directory Scanning

jquery

120
Get Mouse Coordinates

php

113
Get File Extension

css

245
Available List Style Types

css

105
Maintain Aspect Ratio

php

129
Check If Uppercase or Lowercase

php

182
Case Insensitive In Array Check

php

318
List System Drives

misc

109
Remove Empty Lines In SublimeText

php

148
CRUD Functions with PDO

php

128
Simple Select Query with PDO

misc

96
Query Fetch Types in PDO

php

191
PDO Database Connection

sql

105
Duplicate Table Into New Table

jquery

132
Scroll To Position

php

94
Cacheable Tweets

css

103
Mixins in LESS

css

130
Variables in LESS

php

99
Serialize and Unserialize Array

html

149
Viewport Meta Tag For Mobile

javascript

115
Prompt For User Input

css

111
Minify CSS On The Fly

php

117
cURL

jquery

105
Element Is Not

php

77
Specify Decimal Places

php

121
Page Last Modified

php

103
Add Month or Year to Date

javascript

95
OnClick Function

php

78
Embed Images With Data URIs

php

96
Conditional Vs Ternary

php

200
Loop Between Date Range

css

119
CSS3 Animation

css

140
CSS3 Transitions

sql

99
Return Row Count

jquery

116
Filter Table Results

css

120
Box Shadow

shell

77
Dividing The Dock In OSX

php

103
Remove Value From Array

jquery

115
Select Where Attribute Is

server

110
Set Timezone

jquery

105
FadeIn Image When Loaded

php

80
Leading Zeroes

jquery

111
Toggle Password Characters

php

126
Width and Height of SWF

sql

95
Add 1 To Number In Field

html

112
Get Site Favicon

javascript

148
HTML5 Desktop Notifications

php

1012
Create an ICS file

css

107
Full Screen Background Image

css

81
CSS3 Attribute Selectors

php

104
Current File Name

php

107
Delete File From Server

php

121
Highlight Search Keyword

server

1139
Force or remove www from URL

jquery

87
Check If Element Exists

css

83
Multiple Background

html

135
Phone and SMS Prefixes

sql

117
Date of Birth to Age

jquery

91
Disable Right Click Context Menu

css

94
Cross Browser Opacity

php

96
Flickr Photo Search API

server

90
Optimise Site Using DEFLATE

html

159
HTML5 Audio Tag

javascript

141
Popup Window

css

85
Target By Attribute

server

109
Error Document

html

228
Hide Broken Image Icon

javascript

88
Random Colour

php

109
Encode & Decode JSON

php

95
SimpleXML

css

96
Using RGBa

javascript

98
Detect CSS Property

jquery

134
Hover Animations

html

101
RSS Structure

css

105
Append Ellipsis To Long Text

css

112
Target Nth Child in CSS

server

95
Clean URLs

javascript

222
Client Location From Google

html

137
Conditional IE Statements

php

107
Mail in PHP

css

107
Device and Size Detection

sql

108
New Table in MySQL

css

86
CSS Greater Than Sign

jquery

95
ID Is Like

php

104
Email Using PHPMailer

php

135
ZipArchive in PHP

html

83
Full Table Structure

jquery

99
Wordpress Login Shake

jquery

121
TextArea Remaining Characters

php

132
GD Image Filters

javascript

168
iOS and Android Detection

jquery

114
Fixed Position on Scroll

php

101
Multiples Of

html

106
Useful HTML Character Entities

php

124
Generate Random Password

jquery

103
Simple AJAX Using jQuery

shell

107
Show Hidden Files on Mac

html

89
Favicons

javascript

148
Restrict Input to Numbers

jquery

95
setInterval Function

php

111
Twitter Timeline API Results

jquery

82
Smooth Scroll To Top

php

93
Time Ago Function

css

89
Text Emboss Technique

server

89
301 Redirect

php

89
Convert Twitter Links To URLs

jquery

227
Smooth Slide Toggle

css

83
Border Radius

php

109
PHP Range

php

77
Generate Random Colour

css

133
Embedding Fonts

css

86
Browser Selection Colour

html

96
Social Bookmark URLs

php

1391
Date to Roman Numerals

php

94
Copyright Trick

php

134
Sorting an Array in PHP

jquery

112
Calculate Lighter Shade of RGB

sql

105
Inline MySQL Replace Statement