d
Amit DhamuSoftware Engineer

Snippets

274

javascript

172
Get object key based on value

typescript

71323
Use as const to create union type

typescript

15153
Chunking arrays

javascript

233
Sort an object

typescript

236
Human friendly file size

javascript

1202
Overwrite console output in Node

javascript

1985
Encode image as base64 using fetch

javascript

155
String to camelCase

python

2244
Flatten a directory

css

1219
3 ways to center a div

typescript

872
Convert roman numeral to number

javascript

196
Check if phrase is a palindrome

javascript

164
10 handy regular expressions

typescript

1268
Recursively deep merging objects

shell

1885
Flags in Bash with getopts

shell

1702
Switch statement in Bash

javascript

116
Leading zeros with padStart

javascript

1183
is_numeric

javascript

2140442
Scroll Into View With Offset

sql

195
Using string_agg in PostgreSQL

shell

1962
Git Status Porcelain

testing

38492
Spying on localStorage in Jest

testing

1356
Advance Timers in Jest

typescript

33117
Debounce

javascript

197
Omit property from object

typescript

134
Time of day greeting

react

329
Scroll Progress Bar Indicator

javascript

194
Unique values from array of objects

shell

124
Commit case changed filenames in Git

react

171
Smooth Scroll to Top

typescript

169
Read Time in minutes

typescript

611
Cartesian Product

javascript

94
Sharing with navigator.share

shell

91
Git status - files only

shell

86
Search in files and move to directory

javascript

6693
Get domain without subdomain

javascript

131
Find a HTML Element With Text

shell

167
Create A Folder For Each File

javascript

121
Capitalize Word

misc

172
CTRL+CMD+DOWN in VSCode

css

105
Invert Images

javascript

103
Sort Array of Objects by Property

javascript

99
Write to a File in Node

php

98
Valid PHP Types

php

162
is_countable

php

359
Replacing MsSQL_ functions

php

276
Migrating from mysql_ to mysqli_

javascript

101
YYYY-MM-DD in Javascript

misc

166
List Available Makefile Commands

javascript

1220
Generate Initials From String

misc

87
Restore macOS Desktop

misc

125
Delete Git Tag

misc

97
Prevent Safari Reopening Previous Session

python

205
Using argparse For Script Arguments

shell

76
Truncate A File

python

104
File Operations In Python

python

89
Loops In Python

shell

93
Bash - For Loop With Range

misc

80
Handy Docker Commands

misc

127
macOS - Get Serial Number

misc

92
Recent Items in macOS Dock

shell

126
Bash - If In Array

sql

91
Helpful mysqldump Commands

css

106
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

125
Trim Whitespace Pixels with Imagemagick

shell

80
What's Using A Port

misc

103
Chrome (macOS) - Delete URL Suggestion

misc

1887
Solr - Select Distinct Field

misc

596
Change Sublime Text 3 Title Bar Colour on macOS

misc

104
Test /etc/fstab

shell

128
Reformat A Hard Drive on Ubuntu

python

78
Write File Contents in Python

misc

399
Force Delete iCloud Account on macOS

shell

864
Step Through Commits On A Branch In Git

php

437
Case Insensitive Multi Dimensional Array Sort

javascript

88
Is Element Visible In Viewport

shell

79
Search For String In Files

misc

1157
Pip - Install Specific Hash, Branch or Tag

misc

158
Plex Downloads API

misc

64
Eject Disc From CD/DVD Drive on Mac

shell

88
Generate LetsEncrypt SSL Certificate

shell

496
Update Plex From Command Line on Ubuntu

javascript

82
Upgrade Node From NPM

shell

97
Use Heredoc In Bash Script

javascript

110
Get List of NPM Packages

server

71
Redirect to https & non-www in NGINX

javascript

101
Escape HTML

javascript

87
Get Query Parameters

shell

91
Create Multiple Subdirectories At Once

css

217
Clear Button On Input Field

javascript

95
Redirect to HTTPS in Express

javascript

12807
Strip Trailing Slashes From Express Requests

misc

80
Install VirtualBoxGuestAdditions In Ubuntu

shell

72
Recursively Find and Delete File

misc

495
Restart Plex From Command Line

misc

121
Install Ruby Gem Behind Proxy

misc

120
Hide Minified File Contents From Git History

shell

61
Search Occurrences In Between Two Strings

misc

77
Git - Change Remote Origin

php

81
Convert XML to Array

css

75
If Statements in SASS

shell

246
Watch Filesize On Command Line

html

737
Placeholder Image if Src Unavailable

shell

140
Get Number of Commits by Author in Git

shell

96
Temporarily Ignore File in Git

shell

95
Search Git Commit History

javascript

200
Social Media Share Counts

misc

76
Solr - Delete By Query

javascript

88
Default Parameter in Function

css

88
Generate Colour Classes in SASS

shell

242
Use Terminal Through Proxy

misc

112
Vim Commands

shell

86
Git Commands

shell

85
UNIX Commands

jquery

924
Insert Character At Position

php

110
MySQL to CSV Export

jquery

151
Check If Radio Button Has Been Checked

jquery

92
Open External Links In New Tab

misc

110
Use Browser As Notepad

sql

70
Get Date If After Interval

misc

99
Mac Recovery Tools

misc

115
Restart Mac In Safe Mode

php

337
Load Random Image From Directory

css

178
Fullscreen Styling

jquery

78
On The Fly Form With jQuery

javascript

84
Comma Separated String To Array

css

70
Make Images Black and White

shell

119
FTP Upload Using Command Prompt or Terminal

jquery

49
Wrap Element Around Other Element

php

77
Exif Image Data

misc

82
Add Close All To Sublime Text Tab Menu

php

130
Search Files Using glob()

php

161
Write To A Text File

shell

122
Handy Shell Commands (Windows)

javascript

121
Double Click Event

server

104
HTTP Authentication

jquery

104
Toggle Text Function

php

66
Useful Folder and File Functions in PHP

jquery

156
Select Nth Class of Element

jquery

78
Scroll To Bottom of Element

css

142
Pure CSS Speech Bubble

jquery

86
Implement Keyboard Shortcuts For Your Website

html

77
Favicon For Windows 8 Tile

php

90
Append To Text File

php

439
mysql_real_escape_string on Array

php

64
Autoload Class

php

84
Use An Array Recursively

javascript

131
Save Canvas as PNG

php

125
Detect AJAX Request in PHP

php

89
Ignore nl2br() Inside Pre/Code Tag

php

144
List System Drives - Windows Only

sql

91
Capitalise Field in Row

misc

109
Create A Lockscreen Shortcut in Windows

php

99
Remove File Extension

jquery

77
Self Executing Function

php

86
Social Bookmark Share Function

php

112
Recursive Directory Scanning

jquery

88
Get Mouse Coordinates

php

92
Get File Extension

css

209
Available List Style Types

css

88
Maintain Aspect Ratio

php

106
Check If Uppercase or Lowercase

php

146
Case Insensitive In Array Check

php

275
List System Drives

misc

83
Remove Empty Lines In SublimeText

php

127
CRUD Functions with PDO

php

96
Simple Select Query with PDO

misc

82
Query Fetch Types in PDO

php

166
PDO Database Connection

sql

82
Duplicate Table Into New Table

jquery

108
Scroll To Position

php

77
Cacheable Tweets

css

83
Mixins in LESS

css

106
Variables in LESS

php

81
Serialize and Unserialize Array

html

112
Viewport Meta Tag For Mobile

javascript

88
Prompt For User Input

css

88
Minify CSS On The Fly

php

93
cURL

jquery

85
Element Is Not

php

58
Specify Decimal Places

php

92
Page Last Modified

php

83
Add Month or Year to Date

javascript

76
OnClick Function

php

62
Embed Images With Data URIs

php

77
Conditional Vs Ternary

php

166
Loop Between Date Range

css

96
CSS3 Animation

css

112
CSS3 Transitions

sql

79
Return Row Count

jquery

88
Filter Table Results

css

97
Box Shadow

shell

62
Dividing The Dock In OSX

php

86
Remove Value From Array

jquery

93
Select Where Attribute Is

server

98
Set Timezone

jquery

89
FadeIn Image When Loaded

php

57
Leading Zeroes

jquery

79
Toggle Password Characters

php

97
Width and Height of SWF

sql

82
Add 1 To Number In Field

html

94
Get Site Favicon

javascript

129
HTML5 Desktop Notifications

php

945
Create an ICS file

css

93
Full Screen Background Image

css

62
CSS3 Attribute Selectors

php

81
Current File Name

php

89
Delete File From Server

php

96
Highlight Search Keyword

server

1116
Force or remove www from URL

jquery

69
Check If Element Exists

css

65
Multiple Background

html

102
Phone and SMS Prefixes

sql

84
Date of Birth to Age

jquery

72
Disable Right Click Context Menu

css

76
Cross Browser Opacity

php

69
Flickr Photo Search API

server

75
Optimise Site Using DEFLATE

html

136
HTML5 Audio Tag

javascript

126
Popup Window

css

61
Target By Attribute

server

94
Error Document

html

174
Hide Broken Image Icon

javascript

71
Random Colour

php

92
Encode & Decode JSON

php

80
SimpleXML

css

74
Using RGBa

javascript

80
Detect CSS Property

jquery

109
Hover Animations

html

86
RSS Structure

css

89
Append Ellipsis To Long Text

css

89
Target Nth Child in CSS

server

77
Clean URLs

javascript

196
Client Location From Google

html

101
Conditional IE Statements

php

72
Mail in PHP

css

88
Device and Size Detection

sql

80
New Table in MySQL

css

66
CSS Greater Than Sign

jquery

80
ID Is Like

php

87
Email Using PHPMailer

php

114
ZipArchive in PHP

html

70
Full Table Structure

jquery

73
Wordpress Login Shake

jquery

97
TextArea Remaining Characters

php

108
GD Image Filters

javascript

144
iOS and Android Detection

jquery

95
Fixed Position on Scroll

php

80
Multiples Of

html

80
Useful HTML Character Entities

php

86
Generate Random Password

jquery

77
Simple AJAX Using jQuery

shell

85
Show Hidden Files on Mac

html

71
Favicons

javascript

128
Restrict Input to Numbers

jquery

70
setInterval Function

php

89
Twitter Timeline API Results

jquery

64
Smooth Scroll To Top

php

67
Time Ago Function

css

70
Text Emboss Technique

server

71
301 Redirect

php

72
Convert Twitter Links To URLs

jquery

192
Smooth Slide Toggle

css

61
Border Radius

php

81
PHP Range

php

63
Generate Random Colour

css

113
Embedding Fonts

css

66
Browser Selection Colour

html

76
Social Bookmark URLs

php

1338
Date to Roman Numerals

php

76
Copyright Trick

php

117
Sorting an Array in PHP

jquery

90
Calculate Lighter Shade of RGB

sql

89
Inline MySQL Replace Statement