d
Amit DhamuSoftware Engineer

Snippets

274

javascript

142
Get object key based on value

typescript

71148
Use as const to create union type

typescript

15122
Chunking arrays

javascript

203
Sort an object

typescript

187
Human friendly file size

javascript

1059
Overwrite console output in Node

javascript

1938
Encode image as base64 using fetch

javascript

129
String to camelCase

python

2151
Flatten a directory

css

1193
3 ways to center a div

typescript

844
Convert roman numeral to number

javascript

171
Check if phrase is a palindrome

javascript

140
10 handy regular expressions

typescript

1175
Recursively deep merging objects

shell

1819
Flags in Bash with getopts

shell

1675
Switch statement in Bash

javascript

85
Leading zeros with padStart

javascript

1158
is_numeric

javascript

2038911
Scroll Into View With Offset

sql

169
Using string_agg in PostgreSQL

shell

1867
Git Status Porcelain

testing

38390
Spying on localStorage in Jest

testing

1271
Advance Timers in Jest

typescript

33064
Debounce

javascript

177
Omit property from object

typescript

117
Time of day greeting

react

302
Scroll Progress Bar Indicator

javascript

173
Unique values from array of objects

shell

107
Commit case changed filenames in Git

react

144
Smooth Scroll to Top

typescript

141
Read Time in minutes

typescript

572
Cartesian Product

javascript

75
Sharing with navigator.share

shell

77
Git status - files only

shell

66
Search in files and move to directory

javascript

6610
Get domain without subdomain

javascript

108
Find a HTML Element With Text

shell

141
Create A Folder For Each File

javascript

99
Capitalize Word

misc

144
CTRL+CMD+DOWN in VSCode

css

84
Invert Images

javascript

73
Sort Array of Objects by Property

javascript

76
Write to a File in Node

php

75
Valid PHP Types

php

134
is_countable

php

330
Replacing MsSQL_ functions

php

230
Migrating from mysql_ to mysqli_

javascript

78
YYYY-MM-DD in Javascript

misc

138
List Available Makefile Commands

javascript

165
Generate Initials From String

misc

65
Restore macOS Desktop

misc

94
Delete Git Tag

misc

76
Prevent Safari Reopening Previous Session

python

186
Using argparse For Script Arguments

shell

60
Truncate A File

python

80
File Operations In Python

python

65
Loops In Python

shell

71
Bash - For Loop With Range

misc

62
Handy Docker Commands

misc

100
macOS - Get Serial Number

misc

72
Recent Items in macOS Dock

shell

94
Bash - If In Array

sql

70
Helpful mysqldump Commands

css

84
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

97
Trim Whitespace Pixels with Imagemagick

shell

56
What's Using A Port

misc

86
Chrome (macOS) - Delete URL Suggestion

misc

1825
Solr - Select Distinct Field

misc

565
Change Sublime Text 3 Title Bar Colour on macOS

misc

84
Test /etc/fstab

shell

104
Reformat A Hard Drive on Ubuntu

python

58
Write File Contents in Python

misc

361
Force Delete iCloud Account on macOS

shell

832
Step Through Commits On A Branch In Git

php

411
Case Insensitive Multi Dimensional Array Sort

javascript

67
Is Element Visible In Viewport

shell

64
Search For String In Files

misc

1121
Pip - Install Specific Hash, Branch or Tag

misc

137
Plex Downloads API

misc

45
Eject Disc From CD/DVD Drive on Mac

shell

70
Generate LetsEncrypt SSL Certificate

shell

437
Update Plex From Command Line on Ubuntu

javascript

65
Upgrade Node From NPM

shell

74
Use Heredoc In Bash Script

javascript

89
Get List of NPM Packages

server

57
Redirect to https & non-www in NGINX

javascript

80
Escape HTML

javascript

63
Get Query Parameters

shell

74
Create Multiple Subdirectories At Once

css

194
Clear Button On Input Field

javascript

70
Redirect to HTTPS in Express

javascript

12752
Strip Trailing Slashes From Express Requests

misc

59
Install VirtualBoxGuestAdditions In Ubuntu

shell

54
Recursively Find and Delete File

misc

309
Restart Plex From Command Line

misc

108
Install Ruby Gem Behind Proxy

misc

98
Hide Minified File Contents From Git History

shell

46
Search Occurrences In Between Two Strings

misc

55
Git - Change Remote Origin

php

66
Convert XML to Array

css

55
If Statements in SASS

shell

221
Watch Filesize On Command Line

html

662
Placeholder Image if Src Unavailable

shell

110
Get Number of Commits by Author in Git

shell

77
Temporarily Ignore File in Git

shell

71
Search Git Commit History

javascript

167
Social Media Share Counts

misc

53
Solr - Delete By Query

javascript

67
Default Parameter in Function

css

63
Generate Colour Classes in SASS

shell

220
Use Terminal Through Proxy

misc

90
Vim Commands

shell

64
Git Commands

shell

67
UNIX Commands

jquery

881
Insert Character At Position

php

84
MySQL to CSV Export

jquery

119
Check If Radio Button Has Been Checked

jquery

74
Open External Links In New Tab

misc

84
Use Browser As Notepad

sql

54
Get Date If After Interval

misc

80
Mac Recovery Tools

misc

92
Restart Mac In Safe Mode

php

303
Load Random Image From Directory

css

159
Fullscreen Styling

jquery

61
On The Fly Form With jQuery

javascript

65
Comma Separated String To Array

css

51
Make Images Black and White

shell

86
FTP Upload Using Command Prompt or Terminal

jquery

37
Wrap Element Around Other Element

php

59
Exif Image Data

misc

64
Add Close All To Sublime Text Tab Menu

php

106
Search Files Using glob()

php

137
Write To A Text File

shell

97
Handy Shell Commands (Windows)

javascript

95
Double Click Event

server

83
HTTP Authentication

jquery

85
Toggle Text Function

php

46
Useful Folder and File Functions in PHP

jquery

124
Select Nth Class of Element

jquery

61
Scroll To Bottom of Element

css

106
Pure CSS Speech Bubble

jquery

62
Implement Keyboard Shortcuts For Your Website

html

56
Favicon For Windows 8 Tile

php

74
Append To Text File

php

403
mysql_real_escape_string on Array

php

45
Autoload Class

php

62
Use An Array Recursively

javascript

111
Save Canvas as PNG

php

104
Detect AJAX Request in PHP

php

70
Ignore nl2br() Inside Pre/Code Tag

php

129
List System Drives - Windows Only

sql

70
Capitalise Field in Row

misc

84
Create A Lockscreen Shortcut in Windows

php

79
Remove File Extension

jquery

55
Self Executing Function

php

61
Social Bookmark Share Function

php

86
Recursive Directory Scanning

jquery

70
Get Mouse Coordinates

php

70
Get File Extension

css

182
Available List Style Types

css

54
Maintain Aspect Ratio

php

83
Check If Uppercase or Lowercase

php

122
Case Insensitive In Array Check

php

218
List System Drives

misc

67
Remove Empty Lines In SublimeText

php

99
CRUD Functions with PDO

php

69
Simple Select Query with PDO

misc

57
Query Fetch Types in PDO

php

131
PDO Database Connection

sql

61
Duplicate Table Into New Table

jquery

85
Scroll To Position

php

58
Cacheable Tweets

css

65
Mixins in LESS

css

89
Variables in LESS

php

63
Serialize and Unserialize Array

html

79
Viewport Meta Tag For Mobile

javascript

72
Prompt For User Input

css

69
Minify CSS On The Fly

php

71
cURL

jquery

67
Element Is Not

php

39
Specify Decimal Places

php

69
Page Last Modified

php

70
Add Month or Year to Date

javascript

61
OnClick Function

php

43
Embed Images With Data URIs

php

53
Conditional Vs Ternary

php

133
Loop Between Date Range

css

65
CSS3 Animation

css

97
CSS3 Transitions

sql

61
Return Row Count

jquery

60
Filter Table Results

css

76
Box Shadow

shell

42
Dividing The Dock In OSX

php

66
Remove Value From Array

jquery

73
Select Where Attribute Is

server

80
Set Timezone

jquery

69
FadeIn Image When Loaded

php

43
Leading Zeroes

jquery

58
Toggle Password Characters

php

74
Width and Height of SWF

sql

61
Add 1 To Number In Field

html

77
Get Site Favicon

javascript

102
HTML5 Desktop Notifications

php

866
Create an ICS file

css

74
Full Screen Background Image

css

45
CSS3 Attribute Selectors

php

65
Current File Name

php

66
Delete File From Server

php

70
Highlight Search Keyword

server

190
Force or remove www from URL

jquery

54
Check If Element Exists

css

46
Multiple Background

html

79
Phone and SMS Prefixes

sql

65
Date of Birth to Age

jquery

54
Disable Right Click Context Menu

css

60
Cross Browser Opacity

php

46
Flickr Photo Search API

server

62
Optimise Site Using DEFLATE

html

113
HTML5 Audio Tag

javascript

104
Popup Window

css

46
Target By Attribute

server

83
Error Document

html

137
Hide Broken Image Icon

javascript

50
Random Colour

php

71
Encode & Decode JSON

php

58
SimpleXML

css

52
Using RGBa

javascript

65
Detect CSS Property

jquery

90
Hover Animations

html

65
RSS Structure

css

66
Append Ellipsis To Long Text

css

64
Target Nth Child in CSS

server

59
Clean URLs

javascript

167
Client Location From Google

html

75
Conditional IE Statements

php

52
Mail in PHP

css

72
Device and Size Detection

sql

62
New Table in MySQL

css

45
CSS Greater Than Sign

jquery

59
ID Is Like

php

66
Email Using PHPMailer

php

81
ZipArchive in PHP

html

51
Full Table Structure

jquery

57
Wordpress Login Shake

jquery

76
TextArea Remaining Characters

php

83
GD Image Filters

javascript

122
iOS and Android Detection

jquery

67
Fixed Position on Scroll

php

62
Multiples Of

html

56
Useful HTML Character Entities

php

63
Generate Random Password

jquery

56
Simple AJAX Using jQuery

shell

60
Show Hidden Files on Mac

html

51
Favicons

javascript

109
Restrict Input to Numbers

jquery

53
setInterval Function

php

67
Twitter Timeline API Results

jquery

49
Smooth Scroll To Top

php

46
Time Ago Function

css

56
Text Emboss Technique

server

53
301 Redirect

php

54
Convert Twitter Links To URLs

jquery

156
Smooth Slide Toggle

css

37
Border Radius

php

61
PHP Range

php

41
Generate Random Colour

css

92
Embedding Fonts

css

49
Browser Selection Colour

html

59
Social Bookmark URLs

php

1308
Date to Roman Numerals

php

58
Copyright Trick

php

94
Sorting an Array in PHP

jquery

71
Calculate Lighter Shade of RGB

sql

65
Inline MySQL Replace Statement