d
Amit DhamuSoftware Engineer

Snippets

274

javascript

159
Get object key based on value

typescript

71273
Use as const to create union type

typescript

15143
Chunking arrays

javascript

220
Sort an object

typescript

217
Human friendly file size

javascript

1156
Overwrite console output in Node

javascript

1972
Encode image as base64 using fetch

javascript

145
String to camelCase

python

2206
Flatten a directory

css

1212
3 ways to center a div

typescript

859
Convert roman numeral to number

javascript

186
Check if phrase is a palindrome

javascript

154
10 handy regular expressions

typescript

1254
Recursively deep merging objects

shell

1863
Flags in Bash with getopts

shell

1688
Switch statement in Bash

javascript

105
Leading zeros with padStart

javascript

1175
is_numeric

javascript

2040037
Scroll Into View With Offset

sql

185
Using string_agg in PostgreSQL

shell

1926
Git Status Porcelain

testing

38471
Spying on localStorage in Jest

testing

1318
Advance Timers in Jest

typescript

33102
Debounce

javascript

190
Omit property from object

typescript

129
Time of day greeting

react

319
Scroll Progress Bar Indicator

javascript

184
Unique values from array of objects

shell

119
Commit case changed filenames in Git

react

162
Smooth Scroll to Top

typescript

156
Read Time in minutes

typescript

594
Cartesian Product

javascript

88
Sharing with navigator.share

shell

85
Git status - files only

shell

76
Search in files and move to directory

javascript

6666
Get domain without subdomain

javascript

121
Find a HTML Element With Text

shell

156
Create A Folder For Each File

javascript

115
Capitalize Word

misc

161
CTRL+CMD+DOWN in VSCode

css

97
Invert Images

javascript

95
Sort Array of Objects by Property

javascript

90
Write to a File in Node

php

90
Valid PHP Types

php

147
is_countable

php

348
Replacing MsSQL_ functions

php

259
Migrating from mysql_ to mysqli_

javascript

93
YYYY-MM-DD in Javascript

misc

155
List Available Makefile Commands

javascript

1201
Generate Initials From String

misc

79
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

95
File Operations In Python

python

79
Loops In Python

shell

83
Bash - For Loop With Range

misc

71
Handy Docker Commands

misc

116
macOS - Get Serial Number

misc

81
Recent Items in macOS Dock

shell

117
Bash - If In Array

sql

83
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

98
Chrome (macOS) - Delete URL Suggestion

misc

1870
Solr - Select Distinct Field

misc

587
Change Sublime Text 3 Title Bar Colour on macOS

misc

97
Test /etc/fstab

shell

119
Reformat A Hard Drive on Ubuntu

python

72
Write File Contents in Python

misc

387
Force Delete iCloud Account on macOS

shell

849
Step Through Commits On A Branch In Git

php

425
Case Insensitive Multi Dimensional Array Sort

javascript

80
Is Element Visible In Viewport

shell

72
Search For String In Files

misc

1145
Pip - Install Specific Hash, Branch or Tag

misc

147
Plex Downloads API

misc

59
Eject Disc From CD/DVD Drive on Mac

shell

80
Generate LetsEncrypt SSL Certificate

shell

478
Update Plex From Command Line on Ubuntu

javascript

77
Upgrade Node From NPM

shell

87
Use Heredoc In Bash Script

javascript

102
Get List of NPM Packages

server

65
Redirect to https & non-www in NGINX

javascript

94
Escape HTML

javascript

78
Get Query Parameters

shell

85
Create Multiple Subdirectories At Once

css

211
Clear Button On Input Field

javascript

86
Redirect to HTTPS in Express

javascript

12794
Strip Trailing Slashes From Express Requests

misc

73
Install VirtualBoxGuestAdditions In Ubuntu

shell

65
Recursively Find and Delete File

misc

431
Restart Plex From Command Line

misc

115
Install Ruby Gem Behind Proxy

misc

112
Hide Minified File Contents From Git History

shell

55
Search Occurrences In Between Two Strings

misc

70
Git - Change Remote Origin

php

74
Convert XML to Array

css

64
If Statements in SASS

shell

236
Watch Filesize On Command Line

html

718
Placeholder Image if Src Unavailable

shell

127
Get Number of Commits by Author in Git

shell

89
Temporarily Ignore File in Git

shell

87
Search Git Commit History

javascript

181
Social Media Share Counts

misc

65
Solr - Delete By Query

javascript

78
Default Parameter in Function

css

74
Generate Colour Classes in SASS

shell

235
Use Terminal Through Proxy

misc

102
Vim Commands

shell

80
Git Commands

shell

76
UNIX Commands

jquery

908
Insert Character At Position

php

99
MySQL to CSV Export

jquery

136
Check If Radio Button Has Been Checked

jquery

87
Open External Links In New Tab

misc

100
Use Browser As Notepad

sql

62
Get Date If After Interval

misc

90
Mac Recovery Tools

misc

107
Restart Mac In Safe Mode

php

326
Load Random Image From Directory

css

172
Fullscreen Styling

jquery

71
On The Fly Form With jQuery

javascript

76
Comma Separated String To Array

css

64
Make Images Black and White

shell

105
FTP Upload Using Command Prompt or Terminal

jquery

45
Wrap Element Around Other Element

php

67
Exif Image Data

misc

76
Add Close All To Sublime Text Tab Menu

php

122
Search Files Using glob()

php

149
Write To A Text File

shell

114
Handy Shell Commands (Windows)

javascript

105
Double Click Event

server

95
HTTP Authentication

jquery

98
Toggle Text Function

php

59
Useful Folder and File Functions in PHP

jquery

141
Select Nth Class of Element

jquery

72
Scroll To Bottom of Element

css

125
Pure CSS Speech Bubble

jquery

74
Implement Keyboard Shortcuts For Your Website

html

70
Favicon For Windows 8 Tile

php

83
Append To Text File

php

430
mysql_real_escape_string on Array

php

56
Autoload Class

php

72
Use An Array Recursively

javascript

121
Save Canvas as PNG

php

117
Detect AJAX Request in PHP

php

83
Ignore nl2br() Inside Pre/Code Tag

php

139
List System Drives - Windows Only

sql

83
Capitalise Field in Row

misc

101
Create A Lockscreen Shortcut in Windows

php

92
Remove File Extension

jquery

66
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

198
Available List Style Types

css

75
Maintain Aspect Ratio

php

98
Check If Uppercase or Lowercase

php

134
Case Insensitive In Array Check

php

261
List System Drives

misc

78
Remove Empty Lines In SublimeText

php

119
CRUD Functions with PDO

php

83
Simple Select Query with PDO

misc

71
Query Fetch Types in PDO

php

155
PDO Database Connection

sql

76
Duplicate Table Into New Table

jquery

101
Scroll To Position

php

67
Cacheable Tweets

css

78
Mixins in LESS

css

101
Variables in LESS

php

74
Serialize and Unserialize Array

html

101
Viewport Meta Tag For Mobile

javascript

81
Prompt For User Input

css

80
Minify CSS On The Fly

php

82
cURL

jquery

77
Element Is Not

php

53
Specify Decimal Places

php

82
Page Last Modified

php

79
Add Month or Year to Date

javascript

71
OnClick Function

php

54
Embed Images With Data URIs

php

64
Conditional Vs Ternary

php

160
Loop Between Date Range

css

86
CSS3 Animation

css

107
CSS3 Transitions

sql

74
Return Row Count

jquery

80
Filter Table Results

css

89
Box Shadow

shell

55
Dividing The Dock In OSX

php

77
Remove Value From Array

jquery

85
Select Where Attribute Is

server

89
Set Timezone

jquery

78
FadeIn Image When Loaded

php

52
Leading Zeroes

jquery

69
Toggle Password Characters

php

90
Width and Height of SWF

sql

76
Add 1 To Number In Field

html

88
Get Site Favicon

javascript

119
HTML5 Desktop Notifications

php

922
Create an ICS file

css

85
Full Screen Background Image

css

53
CSS3 Attribute Selectors

php

74
Current File Name

php

80
Delete File From Server

php

86
Highlight Search Keyword

server

1108
Force or remove www from URL

jquery

65
Check If Element Exists

css

56
Multiple Background

html

91
Phone and SMS Prefixes

sql

76
Date of Birth to Age

jquery

65
Disable Right Click Context Menu

css

72
Cross Browser Opacity

php

58
Flickr Photo Search API

server

72
Optimise Site Using DEFLATE

html

127
HTML5 Audio Tag

javascript

115
Popup Window

css

55
Target By Attribute

server

88
Error Document

html

159
Hide Broken Image Icon

javascript

67
Random Colour

php

84
Encode & Decode JSON

php

70
SimpleXML

css

64
Using RGBa

javascript

74
Detect CSS Property

jquery

105
Hover Animations

html

79
RSS Structure

css

79
Append Ellipsis To Long Text

css

81
Target Nth Child in CSS

server

70
Clean URLs

javascript

186
Client Location From Google

html

92
Conditional IE Statements

php

61
Mail in PHP

css

84
Device and Size Detection

sql

75
New Table in MySQL

css

57
CSS Greater Than Sign

jquery

71
ID Is Like

php

79
Email Using PHPMailer

php

104
ZipArchive in PHP

html

64
Full Table Structure

jquery

67
Wordpress Login Shake

jquery

92
TextArea Remaining Characters

php

97
GD Image Filters

javascript

137
iOS and Android Detection

jquery

81
Fixed Position on Scroll

php

75
Multiples Of

html

71
Useful HTML Character Entities

php

80
Generate Random Password

jquery

70
Simple AJAX Using jQuery

shell

75
Show Hidden Files on Mac

html

63
Favicons

javascript

120
Restrict Input to Numbers

jquery

62
setInterval Function

php

79
Twitter Timeline API Results

jquery

57
Smooth Scroll To Top

php

60
Time Ago Function

css

66
Text Emboss Technique

server

62
301 Redirect

php

67
Convert Twitter Links To URLs

jquery

182
Smooth Slide Toggle

css

56
Border Radius

php

74
PHP Range

php

55
Generate Random Colour

css

106
Embedding Fonts

css

61
Browser Selection Colour

html

69
Social Bookmark URLs

php

1324
Date to Roman Numerals

php

67
Copyright Trick

php

108
Sorting an Array in PHP

jquery

84
Calculate Lighter Shade of RGB

sql

77
Inline MySQL Replace Statement