d
Amit DhamuSoftware Engineer

Snippets

274

javascript

205
Get object key based on value

typescript

71425
Use as const to create union type

typescript

15191
Chunking arrays

javascript

263
Sort an object

typescript

279
Human friendly file size

javascript

1306
Overwrite console output in Node

javascript

11012
Encode image as base64 using fetch

javascript

191
String to camelCase

python

2327
Flatten a directory

css

1239
3 ways to center a div

typescript

916
Convert roman numeral to number

javascript

231
Check if phrase is a palindrome

javascript

179
10 handy regular expressions

typescript

1352
Recursively deep merging objects

shell

1940
Flags in Bash with getopts

shell

1736
Switch statement in Bash

javascript

145
Leading zeros with padStart

javascript

1207
is_numeric

javascript

2241092
Scroll Into View With Offset

sql

217
Using string_agg in PostgreSQL

shell

2057
Git Status Porcelain

testing

38550
Spying on localStorage in Jest

testing

1417
Advance Timers in Jest

typescript

33172
Debounce

javascript

217
Omit property from object

typescript

164
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

200
Read Time in minutes

typescript

665
Cartesian Product

javascript

111
Sharing with navigator.share

shell

108
Git status - files only

shell

105
Search in files and move to directory

javascript

6782
Get domain without subdomain

javascript

166
Find a HTML Element With Text

shell

198
Create A Folder For Each File

javascript

140
Capitalize Word

misc

197
CTRL+CMD+DOWN in VSCode

css

129
Invert Images

javascript

127
Sort Array of Objects by Property

javascript

120
Write to a File in Node

php

129
Valid PHP Types

php

212
is_countable

php

404
Replacing MsSQL_ functions

php

321
Migrating from mysql_ to mysqli_

javascript

123
YYYY-MM-DD in Javascript

misc

190
List Available Makefile Commands

javascript

1284
Generate Initials From String

misc

110
Restore macOS Desktop

misc

172
Delete Git Tag

misc

120
Prevent Safari Reopening Previous Session

python

234
Using argparse For Script Arguments

shell

101
Truncate A File

python

132
File Operations In Python

python

110
Loops In Python

shell

114
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

114
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

135
Test /etc/fstab

shell

159
Reformat A Hard Drive on Ubuntu

python

103
Write File Contents in Python

misc

424
Force Delete iCloud Account on macOS

shell

897
Step Through Commits On A Branch In Git

php

486
Case Insensitive Multi Dimensional Array Sort

javascript

108
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

561
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

91
Redirect to https & non-www in NGINX

javascript

127
Escape HTML

javascript

107
Get Query Parameters

shell

119
Create Multiple Subdirectories At Once

css

247
Clear Button On Input Field

javascript

116
Redirect to HTTPS in Express

javascript

12870
Strip Trailing Slashes From Express Requests

misc

100
Install VirtualBoxGuestAdditions In Ubuntu

shell

98
Recursively Find and Delete File

misc

606
Restart Plex From Command Line

misc

157
Install Ruby Gem Behind Proxy

misc

162
Hide Minified File Contents From Git History

shell

82
Search Occurrences In Between Two Strings

misc

96
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

243
Social Media Share Counts

misc

112
Solr - Delete By Query

javascript

115
Default Parameter in Function

css

132
Generate Colour Classes in SASS

shell

262
Use Terminal Through Proxy

misc

147
Vim Commands

shell

107
Git Commands

shell

112
UNIX Commands

jquery

959
Insert Character At Position

php

136
MySQL to CSV Export

jquery

187
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

132
Mac Recovery Tools

misc

138
Restart Mac In Safe Mode

php

358
Load Random Image From Directory

css

193
Fullscreen Styling

jquery

98
On The Fly Form With jQuery

javascript

116
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

179
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

123
Toggle Text Function

php

90
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

108
Append To Text File

php

472
mysql_real_escape_string on Array

php

83
Autoload Class

php

110
Use An Array Recursively

javascript

158
Save Canvas as PNG

php

150
Detect AJAX Request in PHP

php

119
Ignore nl2br() Inside Pre/Code Tag

php

167
List System Drives - Windows Only

sql

111
Capitalise Field in Row

misc

151
Create A Lockscreen Shortcut in Windows

php

122
Remove File Extension

jquery

98
Self Executing Function

php

109
Social Bookmark Share Function

php

142
Recursive Directory Scanning

jquery

126
Get Mouse Coordinates

php

115
Get File Extension

css

251
Available List Style Types

css

109
Maintain Aspect Ratio

php

132
Check If Uppercase or Lowercase

php

186
Case Insensitive In Array Check

php

325
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

195
PDO Database Connection

sql

109
Duplicate Table Into New Table

jquery

135
Scroll To Position

php

97
Cacheable Tweets

css

105
Mixins in LESS

css

133
Variables in LESS

php

101
Serialize and Unserialize Array

html

152
Viewport Meta Tag For Mobile

javascript

119
Prompt For User Input

css

112
Minify CSS On The Fly

php

120
cURL

jquery

106
Element Is Not

php

79
Specify Decimal Places

php

124
Page Last Modified

php

105
Add Month or Year to Date

javascript

97
OnClick Function

php

80
Embed Images With Data URIs

php

99
Conditional Vs Ternary

php

205
Loop Between Date Range

css

122
CSS3 Animation

css

142
CSS3 Transitions

sql

101
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

118
Select Where Attribute Is

server

111
Set Timezone

jquery

107
FadeIn Image When Loaded

php

81
Leading Zeroes

jquery

115
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

1018
Create an ICS file

css

112
Full Screen Background Image

css

84
CSS3 Attribute Selectors

php

107
Current File Name

php

110
Delete File From Server

php

124
Highlight Search Keyword

server

1141
Force or remove www from URL

jquery

88
Check If Element Exists

css

83
Multiple Background

html

142
Phone and SMS Prefixes

sql

121
Date of Birth to Age

jquery

92
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

89
Random Colour

php

112
Encode & Decode JSON

php

95
SimpleXML

css

99
Using RGBa

javascript

100
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

97
Clean URLs

javascript

225
Client Location From Google

html

142
Conditional IE Statements

php

112
Mail in PHP

css

111
Device and Size Detection

sql

113
New Table in MySQL

css

91
CSS Greater Than Sign

jquery

96
ID Is Like

php

110
Email Using PHPMailer

php

141
ZipArchive in PHP

html

86
Full Table Structure

jquery

103
Wordpress Login Shake

jquery

123
TextArea Remaining Characters

php

135
GD Image Filters

javascript

172
iOS and Android Detection

jquery

118
Fixed Position on Scroll

php

105
Multiples Of

html

109
Useful HTML Character Entities

php

129
Generate Random Password

jquery

106
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

93
Convert Twitter Links To URLs

jquery

228
Smooth Slide Toggle

css

88
Border Radius

php

111
PHP Range

php

78
Generate Random Colour

css

137
Embedding Fonts

css

91
Browser Selection Colour

html

98
Social Bookmark URLs

php

1398
Date to Roman Numerals

php

97
Copyright Trick

php

137
Sorting an Array in PHP

jquery

115
Calculate Lighter Shade of RGB

sql

110
Inline MySQL Replace Statement