d
Amit DhamuSoftware Engineer

Snippets

274

javascript

138
Get object key based on value

typescript

71119
Use as const to create union type

typescript

15118
Chunking arrays

javascript

197
Sort an object

typescript

178
Human friendly file size

javascript

1030
Overwrite console output in Node

javascript

1927
Encode image as base64 using fetch

javascript

125
String to camelCase

python

2130
Flatten a directory

css

1189
3 ways to center a div

typescript

838
Convert roman numeral to number

javascript

164
Check if phrase is a palindrome

javascript

138
10 handy regular expressions

typescript

1150
Recursively deep merging objects

shell

1810
Flags in Bash with getopts

shell

1671
Switch statement in Bash

javascript

82
Leading zeros with padStart

javascript

1153
is_numeric

javascript

2038536
Scroll Into View With Offset

sql

161
Using string_agg in PostgreSQL

shell

1850
Git Status Porcelain

testing

38372
Spying on localStorage in Jest

testing

1255
Advance Timers in Jest

typescript

33055
Debounce

javascript

171
Omit property from object

typescript

112
Time of day greeting

react

296
Scroll Progress Bar Indicator

javascript

168
Unique values from array of objects

shell

104
Commit case changed filenames in Git

react

138
Smooth Scroll to Top

typescript

137
Read Time in minutes

typescript

565
Cartesian Product

javascript

72
Sharing with navigator.share

shell

73
Git status - files only

shell

62
Search in files and move to directory

javascript

6577
Get domain without subdomain

javascript

103
Find a HTML Element With Text

shell

137
Create A Folder For Each File

javascript

94
Capitalize Word

misc

139
CTRL+CMD+DOWN in VSCode

css

81
Invert Images

javascript

67
Sort Array of Objects by Property

javascript

71
Write to a File in Node

php

69
Valid PHP Types

php

128
is_countable

php

319
Replacing MsSQL_ functions

php

222
Migrating from mysql_ to mysqli_

javascript

74
YYYY-MM-DD in Javascript

misc

134
List Available Makefile Commands

javascript

152
Generate Initials From String

misc

59
Restore macOS Desktop

misc

86
Delete Git Tag

misc

68
Prevent Safari Reopening Previous Session

python

184
Using argparse For Script Arguments

shell

57
Truncate A File

python

77
File Operations In Python

python

61
Loops In Python

shell

66
Bash - For Loop With Range

misc

57
Handy Docker Commands

misc

96
macOS - Get Serial Number

misc

68
Recent Items in macOS Dock

shell

90
Bash - If In Array

sql

67
Helpful mysqldump Commands

css

81
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

93
Trim Whitespace Pixels with Imagemagick

shell

51
What's Using A Port

misc

81
Chrome (macOS) - Delete URL Suggestion

misc

1812
Solr - Select Distinct Field

misc

552
Change Sublime Text 3 Title Bar Colour on macOS

misc

82
Test /etc/fstab

shell

102
Reformat A Hard Drive on Ubuntu

python

54
Write File Contents in Python

misc

355
Force Delete iCloud Account on macOS

shell

823
Step Through Commits On A Branch In Git

php

405
Case Insensitive Multi Dimensional Array Sort

javascript

63
Is Element Visible In Viewport

shell

60
Search For String In Files

misc

1115
Pip - Install Specific Hash, Branch or Tag

misc

129
Plex Downloads API

misc

43
Eject Disc From CD/DVD Drive on Mac

shell

66
Generate LetsEncrypt SSL Certificate

shell

420
Update Plex From Command Line on Ubuntu

javascript

62
Upgrade Node From NPM

shell

70
Use Heredoc In Bash Script

javascript

85
Get List of NPM Packages

server

54
Redirect to https & non-www in NGINX

javascript

77
Escape HTML

javascript

62
Get Query Parameters

shell

70
Create Multiple Subdirectories At Once

css

189
Clear Button On Input Field

javascript

67
Redirect to HTTPS in Express

javascript

12742
Strip Trailing Slashes From Express Requests

misc

54
Install VirtualBoxGuestAdditions In Ubuntu

shell

52
Recursively Find and Delete File

misc

282
Restart Plex From Command Line

misc

104
Install Ruby Gem Behind Proxy

misc

96
Hide Minified File Contents From Git History

shell

41
Search Occurrences In Between Two Strings

misc

50
Git - Change Remote Origin

php

61
Convert XML to Array

css

52
If Statements in SASS

shell

213
Watch Filesize On Command Line

html

652
Placeholder Image if Src Unavailable

shell

105
Get Number of Commits by Author in Git

shell

73
Temporarily Ignore File in Git

shell

66
Search Git Commit History

javascript

158
Social Media Share Counts

misc

50
Solr - Delete By Query

javascript

62
Default Parameter in Function

css

60
Generate Colour Classes in SASS

shell

215
Use Terminal Through Proxy

misc

84
Vim Commands

shell

59
Git Commands

shell

64
UNIX Commands

jquery

875
Insert Character At Position

php

80
MySQL to CSV Export

jquery

114
Check If Radio Button Has Been Checked

jquery

69
Open External Links In New Tab

misc

79
Use Browser As Notepad

sql

50
Get Date If After Interval

misc

74
Mac Recovery Tools

misc

87
Restart Mac In Safe Mode

php

298
Load Random Image From Directory

css

156
Fullscreen Styling

jquery

57
On The Fly Form With jQuery

javascript

61
Comma Separated String To Array

css

48
Make Images Black and White

shell

78
FTP Upload Using Command Prompt or Terminal

jquery

35
Wrap Element Around Other Element

php

55
Exif Image Data

misc

60
Add Close All To Sublime Text Tab Menu

php

99
Search Files Using glob()

php

133
Write To A Text File

shell

92
Handy Shell Commands (Windows)

javascript

91
Double Click Event

server

81
HTTP Authentication

jquery

80
Toggle Text Function

php

42
Useful Folder and File Functions in PHP

jquery

118
Select Nth Class of Element

jquery

57
Scroll To Bottom of Element

css

97
Pure CSS Speech Bubble

jquery

59
Implement Keyboard Shortcuts For Your Website

html

52
Favicon For Windows 8 Tile

php

70
Append To Text File

php

395
mysql_real_escape_string on Array

php

43
Autoload Class

php

58
Use An Array Recursively

javascript

107
Save Canvas as PNG

php

99
Detect AJAX Request in PHP

php

65
Ignore nl2br() Inside Pre/Code Tag

php

124
List System Drives - Windows Only

sql

67
Capitalise Field in Row

misc

81
Create A Lockscreen Shortcut in Windows

php

73
Remove File Extension

jquery

51
Self Executing Function

php

55
Social Bookmark Share Function

php

80
Recursive Directory Scanning

jquery

65
Get Mouse Coordinates

php

64
Get File Extension

css

178
Available List Style Types

css

49
Maintain Aspect Ratio

php

80
Check If Uppercase or Lowercase

php

117
Case Insensitive In Array Check

php

205
List System Drives

misc

62
Remove Empty Lines In SublimeText

php

95
CRUD Functions with PDO

php

63
Simple Select Query with PDO

misc

57
Query Fetch Types in PDO

php

126
PDO Database Connection

sql

55
Duplicate Table Into New Table

jquery

81
Scroll To Position

php

53
Cacheable Tweets

css

59
Mixins in LESS

css

85
Variables in LESS

php

57
Serialize and Unserialize Array

html

73
Viewport Meta Tag For Mobile

javascript

66
Prompt For User Input

css

66
Minify CSS On The Fly

php

67
cURL

jquery

62
Element Is Not

php

34
Specify Decimal Places

php

65
Page Last Modified

php

65
Add Month or Year to Date

javascript

58
OnClick Function

php

39
Embed Images With Data URIs

php

49
Conditional Vs Ternary

php

123
Loop Between Date Range

css

60
CSS3 Animation

css

91
CSS3 Transitions

sql

56
Return Row Count

jquery

56
Filter Table Results

css

69
Box Shadow

shell

38
Dividing The Dock In OSX

php

62
Remove Value From Array

jquery

67
Select Where Attribute Is

server

73
Set Timezone

jquery

62
FadeIn Image When Loaded

php

39
Leading Zeroes

jquery

52
Toggle Password Characters

php

67
Width and Height of SWF

sql

55
Add 1 To Number In Field

html

74
Get Site Favicon

javascript

96
HTML5 Desktop Notifications

php

850
Create an ICS file

css

70
Full Screen Background Image

css

43
CSS3 Attribute Selectors

php

61
Current File Name

php

60
Delete File From Server

php

66
Highlight Search Keyword

server

185
Force or remove www from URL

jquery

51
Check If Element Exists

css

41
Multiple Background

html

75
Phone and SMS Prefixes

sql

61
Date of Birth to Age

jquery

50
Disable Right Click Context Menu

css

57
Cross Browser Opacity

php

45
Flickr Photo Search API

server

60
Optimise Site Using DEFLATE

html

109
HTML5 Audio Tag

javascript

100
Popup Window

css

41
Target By Attribute

server

79
Error Document

html

134
Hide Broken Image Icon

javascript

47
Random Colour

php

66
Encode & Decode JSON

php

52
SimpleXML

css

49
Using RGBa

javascript

58
Detect CSS Property

jquery

86
Hover Animations

html

60
RSS Structure

css

62
Append Ellipsis To Long Text

css

59
Target Nth Child in CSS

server

57
Clean URLs

javascript

162
Client Location From Google

html

73
Conditional IE Statements

php

49
Mail in PHP

css

67
Device and Size Detection

sql

59
New Table in MySQL

css

42
CSS Greater Than Sign

jquery

55
ID Is Like

php

62
Email Using PHPMailer

php

75
ZipArchive in PHP

html

47
Full Table Structure

jquery

54
Wordpress Login Shake

jquery

71
TextArea Remaining Characters

php

79
GD Image Filters

javascript

118
iOS and Android Detection

jquery

63
Fixed Position on Scroll

php

58
Multiples Of

html

51
Useful HTML Character Entities

php

57
Generate Random Password

jquery

54
Simple AJAX Using jQuery

shell

54
Show Hidden Files on Mac

html

47
Favicons

javascript

104
Restrict Input to Numbers

jquery

47
setInterval Function

php

63
Twitter Timeline API Results

jquery

41
Smooth Scroll To Top

php

43
Time Ago Function

css

52
Text Emboss Technique

server

49
301 Redirect

php

50
Convert Twitter Links To URLs

jquery

149
Smooth Slide Toggle

css

32
Border Radius

php

57
PHP Range

php

37
Generate Random Colour

css

87
Embedding Fonts

css

43
Browser Selection Colour

html

55
Social Bookmark URLs

php

1302
Date to Roman Numerals

php

55
Copyright Trick

php

89
Sorting an Array in PHP

jquery

66
Calculate Lighter Shade of RGB

sql

61
Inline MySQL Replace Statement