d
Amit DhamuSoftware Engineer

Snippets

274

javascript

160
Get object key based on value

typescript

71279
Use as const to create union type

typescript

15143
Chunking arrays

javascript

222
Sort an object

typescript

220
Human friendly file size

javascript

1159
Overwrite console output in Node

javascript

1973
Encode image as base64 using fetch

javascript

146
String to camelCase

python

2210
Flatten a directory

css

1212
3 ways to center a div

typescript

860
Convert roman numeral to number

javascript

187
Check if phrase is a palindrome

javascript

155
10 handy regular expressions

typescript

1255
Recursively deep merging objects

shell

1865
Flags in Bash with getopts

shell

1689
Switch statement in Bash

javascript

107
Leading zeros with padStart

javascript

1175
is_numeric

javascript

2040138
Scroll Into View With Offset

sql

186
Using string_agg in PostgreSQL

shell

1927
Git Status Porcelain

testing

38474
Spying on localStorage in Jest

testing

1321
Advance Timers in Jest

typescript

33104
Debounce

javascript

191
Omit property from object

typescript

130
Time of day greeting

react

319
Scroll Progress Bar Indicator

javascript

186
Unique values from array of objects

shell

119
Commit case changed filenames in Git

react

162
Smooth Scroll to Top

typescript

158
Read Time in minutes

typescript

597
Cartesian Product

javascript

88
Sharing with navigator.share

shell

86
Git status - files only

shell

77
Search in files and move to directory

javascript

6668
Get domain without subdomain

javascript

123
Find a HTML Element With Text

shell

159
Create A Folder For Each File

javascript

117
Capitalize Word

misc

163
CTRL+CMD+DOWN in VSCode

css

98
Invert Images

javascript

95
Sort Array of Objects by Property

javascript

91
Write to a File in Node

php

90
Valid PHP Types

php

149
is_countable

php

351
Replacing MsSQL_ functions

php

264
Migrating from mysql_ to mysqli_

javascript

95
YYYY-MM-DD in Javascript

misc

155
List Available Makefile Commands

javascript

1202
Generate Initials From String

misc

80
Restore macOS Desktop

misc

116
Delete Git Tag

misc

87
Prevent Safari Reopening Previous Session

python

196
Using argparse For Script Arguments

shell

71
Truncate A File

python

98
File Operations In Python

python

80
Loops In Python

shell

84
Bash - For Loop With Range

misc

73
Handy Docker Commands

misc

117
macOS - Get Serial Number

misc

82
Recent Items in macOS Dock

shell

118
Bash - If In Array

sql

85
Helpful mysqldump Commands

css

98
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

114
Trim Whitespace Pixels with Imagemagick

shell

70
What's Using A Port

misc

99
Chrome (macOS) - Delete URL Suggestion

misc

1872
Solr - Select Distinct Field

misc

588
Change Sublime Text 3 Title Bar Colour on macOS

misc

98
Test /etc/fstab

shell

119
Reformat A Hard Drive on Ubuntu

python

73
Write File Contents in Python

misc

388
Force Delete iCloud Account on macOS

shell

852
Step Through Commits On A Branch In Git

php

426
Case Insensitive Multi Dimensional Array Sort

javascript

82
Is Element Visible In Viewport

shell

75
Search For String In Files

misc

1150
Pip - Install Specific Hash, Branch or Tag

misc

150
Plex Downloads API

misc

59
Eject Disc From CD/DVD Drive on Mac

shell

81
Generate LetsEncrypt SSL Certificate

shell

481
Update Plex From Command Line on Ubuntu

javascript

77
Upgrade Node From NPM

shell

88
Use Heredoc In Bash Script

javascript

103
Get List of NPM Packages

server

66
Redirect to https & non-www in NGINX

javascript

95
Escape HTML

javascript

80
Get Query Parameters

shell

85
Create Multiple Subdirectories At Once

css

214
Clear Button On Input Field

javascript

87
Redirect to HTTPS in Express

javascript

12795
Strip Trailing Slashes From Express Requests

misc

75
Install VirtualBoxGuestAdditions In Ubuntu

shell

67
Recursively Find and Delete File

misc

443
Restart Plex From Command Line

misc

116
Install Ruby Gem Behind Proxy

misc

112
Hide Minified File Contents From Git History

shell

57
Search Occurrences In Between Two Strings

misc

72
Git - Change Remote Origin

php

74
Convert XML to Array

css

66
If Statements in SASS

shell

238
Watch Filesize On Command Line

html

721
Placeholder Image if Src Unavailable

shell

128
Get Number of Commits by Author in Git

shell

90
Temporarily Ignore File in Git

shell

88
Search Git Commit History

javascript

186
Social Media Share Counts

misc

66
Solr - Delete By Query

javascript

80
Default Parameter in Function

css

76
Generate Colour Classes in SASS

shell

236
Use Terminal Through Proxy

misc

103
Vim Commands

shell

80
Git Commands

shell

77
UNIX Commands

jquery

911
Insert Character At Position

php

100
MySQL to CSV Export

jquery

137
Check If Radio Button Has Been Checked

jquery

87
Open External Links In New Tab

misc

102
Use Browser As Notepad

sql

63
Get Date If After Interval

misc

91
Mac Recovery Tools

misc

108
Restart Mac In Safe Mode

php

328
Load Random Image From Directory

css

172
Fullscreen Styling

jquery

73
On The Fly Form With jQuery

javascript

79
Comma Separated String To Array

css

64
Make Images Black and White

shell

108
FTP Upload Using Command Prompt or Terminal

jquery

45
Wrap Element Around Other Element

php

68
Exif Image Data

misc

76
Add Close All To Sublime Text Tab Menu

php

124
Search Files Using glob()

php

151
Write To A Text File

shell

115
Handy Shell Commands (Windows)

javascript

108
Double Click Event

server

97
HTTP Authentication

jquery

98
Toggle Text Function

php

60
Useful Folder and File Functions in PHP

jquery

143
Select Nth Class of Element

jquery

72
Scroll To Bottom of Element

css

126
Pure CSS Speech Bubble

jquery

77
Implement Keyboard Shortcuts For Your Website

html

72
Favicon For Windows 8 Tile

php

84
Append To Text File

php

432
mysql_real_escape_string on Array

php

57
Autoload Class

php

73
Use An Array Recursively

javascript

123
Save Canvas as PNG

php

118
Detect AJAX Request in PHP

php

84
Ignore nl2br() Inside Pre/Code Tag

php

139
List System Drives - Windows Only

sql

85
Capitalise Field in Row

misc

102
Create A Lockscreen Shortcut in Windows

php

94
Remove File Extension

jquery

68
Self Executing Function

php

74
Social Bookmark Share Function

php

105
Recursive Directory Scanning

jquery

83
Get Mouse Coordinates

php

85
Get File Extension

css

200
Available List Style Types

css

76
Maintain Aspect Ratio

php

98
Check If Uppercase or Lowercase

php

134
Case Insensitive In Array Check

php

263
List System Drives

misc

78
Remove Empty Lines In SublimeText

php

121
CRUD Functions with PDO

php

84
Simple Select Query with PDO

misc

74
Query Fetch Types in PDO

php

156
PDO Database Connection

sql

77
Duplicate Table Into New Table

jquery

102
Scroll To Position

php

68
Cacheable Tweets

css

79
Mixins in LESS

css

101
Variables in LESS

php

74
Serialize and Unserialize Array

html

103
Viewport Meta Tag For Mobile

javascript

82
Prompt For User Input

css

80
Minify CSS On The Fly

php

83
cURL

jquery

77
Element Is Not

php

54
Specify Decimal Places

php

84
Page Last Modified

php

79
Add Month or Year to Date

javascript

72
OnClick Function

php

56
Embed Images With Data URIs

php

67
Conditional Vs Ternary

php

160
Loop Between Date Range

css

86
CSS3 Animation

css

108
CSS3 Transitions

sql

74
Return Row Count

jquery

81
Filter Table Results

css

90
Box Shadow

shell

56
Dividing The Dock In OSX

php

77
Remove Value From Array

jquery

86
Select Where Attribute Is

server

90
Set Timezone

jquery

81
FadeIn Image When Loaded

php

52
Leading Zeroes

jquery

71
Toggle Password Characters

php

90
Width and Height of SWF

sql

77
Add 1 To Number In Field

html

88
Get Site Favicon

javascript

119
HTML5 Desktop Notifications

php

928
Create an ICS file

css

86
Full Screen Background Image

css

55
CSS3 Attribute Selectors

php

75
Current File Name

php

81
Delete File From Server

php

89
Highlight Search Keyword

server

1110
Force or remove www from URL

jquery

65
Check If Element Exists

css

58
Multiple Background

html

92
Phone and SMS Prefixes

sql

77
Date of Birth to Age

jquery

67
Disable Right Click Context Menu

css

72
Cross Browser Opacity

php

59
Flickr Photo Search API

server

72
Optimise Site Using DEFLATE

html

127
HTML5 Audio Tag

javascript

116
Popup Window

css

56
Target By Attribute

server

90
Error Document

html

162
Hide Broken Image Icon

javascript

68
Random Colour

php

86
Encode & Decode JSON

php

73
SimpleXML

css

64
Using RGBa

javascript

75
Detect CSS Property

jquery

106
Hover Animations

html

80
RSS Structure

css

81
Append Ellipsis To Long Text

css

82
Target Nth Child in CSS

server

71
Clean URLs

javascript

187
Client Location From Google

html

93
Conditional IE Statements

php

62
Mail in PHP

css

84
Device and Size Detection

sql

75
New Table in MySQL

css

58
CSS Greater Than Sign

jquery

73
ID Is Like

php

80
Email Using PHPMailer

php

105
ZipArchive in PHP

html

64
Full Table Structure

jquery

67
Wordpress Login Shake

jquery

92
TextArea Remaining Characters

php

98
GD Image Filters

javascript

139
iOS and Android Detection

jquery

82
Fixed Position on Scroll

php

75
Multiples Of

html

73
Useful HTML Character Entities

php

80
Generate Random Password

jquery

71
Simple AJAX Using jQuery

shell

76
Show Hidden Files on Mac

html

63
Favicons

javascript

121
Restrict Input to Numbers

jquery

62
setInterval Function

php

81
Twitter Timeline API Results

jquery

58
Smooth Scroll To Top

php

60
Time Ago Function

css

66
Text Emboss Technique

server

63
301 Redirect

php

67
Convert Twitter Links To URLs

jquery

184
Smooth Slide Toggle

css

57
Border Radius

php

75
PHP Range

php

56
Generate Random Colour

css

106
Embedding Fonts

css

61
Browser Selection Colour

html

70
Social Bookmark URLs

php

1325
Date to Roman Numerals

php

68
Copyright Trick

php

108
Sorting an Array in PHP

jquery

85
Calculate Lighter Shade of RGB

sql

80
Inline MySQL Replace Statement