d
Amit DhamuSoftware Engineer

Snippets

274

javascript

115
Get object key based on value

typescript

61016
Use as const to create union type

typescript

15105
Chunking arrays

javascript

188
Sort an object

typescript

164
Human friendly file size

javascript

944
Overwrite console output in Node

javascript

1902
Encode image as base64 using fetch

javascript

119
String to camelCase

python

2092
Flatten a directory

css

1184
3 ways to center a div

typescript

820
Convert roman numeral to number

javascript

157
Check if phrase is a palindrome

javascript

132
10 handy regular expressions

typescript

1087
Recursively deep merging objects

shell

1789
Flags in Bash with getopts

shell

1663
Switch statement in Bash

javascript

78
Leading zeros with padStart

javascript

1150
is_numeric

javascript

1937672
Scroll Into View With Offset

sql

145
Using string_agg in PostgreSQL

shell

1793
Git Status Porcelain

testing

38322
Spying on localStorage in Jest

testing

1219
Advance Timers in Jest

typescript

33023
Debounce

javascript

166
Omit property from object

typescript

106
Time of day greeting

react

281
Scroll Progress Bar Indicator

javascript

163
Unique values from array of objects

shell

98
Commit case changed filenames in Git

react

129
Smooth Scroll to Top

typescript

130
Read Time in minutes

typescript

551
Cartesian Product

javascript

65
Sharing with navigator.share

shell

68
Git status - files only

shell

59
Search in files and move to directory

javascript

6522
Get domain without subdomain

javascript

88
Find a HTML Element With Text

shell

127
Create A Folder For Each File

javascript

87
Capitalize Word

misc

128
CTRL+CMD+DOWN in VSCode

css

75
Invert Images

javascript

61
Sort Array of Objects by Property

javascript

63
Write to a File in Node

php

66
Valid PHP Types

php

121
is_countable

php

311
Replacing MsSQL_ functions

php

208
Migrating from mysql_ to mysqli_

javascript

71
YYYY-MM-DD in Javascript

misc

128
List Available Makefile Commands

javascript

142
Generate Initials From String

misc

55
Restore macOS Desktop

misc

80
Delete Git Tag

misc

62
Prevent Safari Reopening Previous Session

python

171
Using argparse For Script Arguments

shell

50
Truncate A File

python

71
File Operations In Python

python

55
Loops In Python

shell

62
Bash - For Loop With Range

misc

53
Handy Docker Commands

misc

86
macOS - Get Serial Number

misc

62
Recent Items in macOS Dock

shell

86
Bash - If In Array

sql

62
Helpful mysqldump Commands

css

75
Bootstrap 4 SCSS Breakpoint Utility Mixins

misc

85
Trim Whitespace Pixels with Imagemagick

shell

45
What's Using A Port

misc

72
Chrome (macOS) - Delete URL Suggestion

misc

1778
Solr - Select Distinct Field

misc

535
Change Sublime Text 3 Title Bar Colour on macOS

misc

72
Test /etc/fstab

shell

95
Reformat A Hard Drive on Ubuntu

python

52
Write File Contents in Python

misc

348
Force Delete iCloud Account on macOS

shell

811
Step Through Commits On A Branch In Git

php

399
Case Insensitive Multi Dimensional Array Sort

javascript

59
Is Element Visible In Viewport

shell

55
Search For String In Files

misc

1106
Pip - Install Specific Hash, Branch or Tag

misc

120
Plex Downloads API

misc

39
Eject Disc From CD/DVD Drive on Mac

shell

59
Generate LetsEncrypt SSL Certificate

shell

397
Update Plex From Command Line on Ubuntu

javascript

59
Upgrade Node From NPM

shell

65
Use Heredoc In Bash Script

javascript

80
Get List of NPM Packages

server

49
Redirect to https & non-www in NGINX

javascript

72
Escape HTML

javascript

58
Get Query Parameters

shell

67
Create Multiple Subdirectories At Once

css

177
Clear Button On Input Field

javascript

62
Redirect to HTTPS in Express

javascript

12712
Strip Trailing Slashes From Express Requests

misc

51
Install VirtualBoxGuestAdditions In Ubuntu

shell

48
Recursively Find and Delete File

misc

242
Restart Plex From Command Line

misc

100
Install Ruby Gem Behind Proxy

misc

88
Hide Minified File Contents From Git History

shell

39
Search Occurrences In Between Two Strings

misc

45
Git - Change Remote Origin

php

56
Convert XML to Array

css

48
If Statements in SASS

shell

204
Watch Filesize On Command Line

html

628
Placeholder Image if Src Unavailable

shell

101
Get Number of Commits by Author in Git

shell

67
Temporarily Ignore File in Git

shell

53
Search Git Commit History

javascript

150
Social Media Share Counts

misc

48
Solr - Delete By Query

javascript

58
Default Parameter in Function

css

57
Generate Colour Classes in SASS

shell

209
Use Terminal Through Proxy

misc

82
Vim Commands

shell

55
Git Commands

shell

58
UNIX Commands

jquery

860
Insert Character At Position

php

76
MySQL to CSV Export

jquery

106
Check If Radio Button Has Been Checked

jquery

66
Open External Links In New Tab

misc

74
Use Browser As Notepad

sql

43
Get Date If After Interval

misc

70
Mac Recovery Tools

misc

83
Restart Mac In Safe Mode

php

291
Load Random Image From Directory

css

147
Fullscreen Styling

jquery

52
On The Fly Form With jQuery

javascript

55
Comma Separated String To Array

css

44
Make Images Black and White

shell

69
FTP Upload Using Command Prompt or Terminal

jquery

32
Wrap Element Around Other Element

php

52
Exif Image Data

misc

55
Add Close All To Sublime Text Tab Menu

php

94
Search Files Using glob()

php

126
Write To A Text File

shell

84
Handy Shell Commands (Windows)

javascript

87
Double Click Event

server

75
HTTP Authentication

jquery

75
Toggle Text Function

php

36
Useful Folder and File Functions in PHP

jquery

111
Select Nth Class of Element

jquery

54
Scroll To Bottom of Element

css

88
Pure CSS Speech Bubble

jquery

54
Implement Keyboard Shortcuts For Your Website

html

47
Favicon For Windows 8 Tile

php

65
Append To Text File

php

384
mysql_real_escape_string on Array

php

38
Autoload Class

php

56
Use An Array Recursively

javascript

101
Save Canvas as PNG

php

96
Detect AJAX Request in PHP

php

62
Ignore nl2br() Inside Pre/Code Tag

php

120
List System Drives - Windows Only

sql

63
Capitalise Field in Row

misc

75
Create A Lockscreen Shortcut in Windows

php

70
Remove File Extension

jquery

46
Self Executing Function

php

52
Social Bookmark Share Function

php

73
Recursive Directory Scanning

jquery

60
Get Mouse Coordinates

php

60
Get File Extension

css

173
Available List Style Types

css

46
Maintain Aspect Ratio

php

70
Check If Uppercase or Lowercase

php

111
Case Insensitive In Array Check

php

187
List System Drives

misc

58
Remove Empty Lines In SublimeText

php

89
CRUD Functions with PDO

php

60
Simple Select Query with PDO

misc

53
Query Fetch Types in PDO

php

117
PDO Database Connection

sql

49
Duplicate Table Into New Table

jquery

72
Scroll To Position

php

50
Cacheable Tweets

css

53
Mixins in LESS

css

83
Variables in LESS

php

51
Serialize and Unserialize Array

html

69
Viewport Meta Tag For Mobile

javascript

62
Prompt For User Input

css

62
Minify CSS On The Fly

php

64
cURL

jquery

57
Element Is Not

php

30
Specify Decimal Places

php

60
Page Last Modified

php

61
Add Month or Year to Date

javascript

56
OnClick Function

php

36
Embed Images With Data URIs

php

43
Conditional Vs Ternary

php

118
Loop Between Date Range

css

53
CSS3 Animation

css

88
CSS3 Transitions

sql

52
Return Row Count

jquery

50
Filter Table Results

css

65
Box Shadow

shell

35
Dividing The Dock In OSX

php

57
Remove Value From Array

jquery

61
Select Where Attribute Is

server

68
Set Timezone

jquery

57
FadeIn Image When Loaded

php

36
Leading Zeroes

jquery

44
Toggle Password Characters

php

62
Width and Height of SWF

sql

50
Add 1 To Number In Field

html

68
Get Site Favicon

javascript

86
HTML5 Desktop Notifications

php

823
Create an ICS file

css

68
Full Screen Background Image

css

41
CSS3 Attribute Selectors

php

58
Current File Name

php

56
Delete File From Server

php

62
Highlight Search Keyword

server

178
Force or remove www from URL

jquery

46
Check If Element Exists

css

34
Multiple Background

html

68
Phone and SMS Prefixes

sql

55
Date of Birth to Age

jquery

48
Disable Right Click Context Menu

css

52
Cross Browser Opacity

php

43
Flickr Photo Search API

server

56
Optimise Site Using DEFLATE

html

103
HTML5 Audio Tag

javascript

95
Popup Window

css

37
Target By Attribute

server

75
Error Document

html

128
Hide Broken Image Icon

javascript

44
Random Colour

php

60
Encode & Decode JSON

php

47
SimpleXML

css

44
Using RGBa

javascript

53
Detect CSS Property

jquery

83
Hover Animations

html

57
RSS Structure

css

57
Append Ellipsis To Long Text

css

57
Target Nth Child in CSS

server

49
Clean URLs

javascript

156
Client Location From Google

html

68
Conditional IE Statements

php

47
Mail in PHP

css

63
Device and Size Detection

sql

56
New Table in MySQL

css

35
CSS Greater Than Sign

jquery

46
ID Is Like

php

57
Email Using PHPMailer

php

69
ZipArchive in PHP

html

44
Full Table Structure

jquery

49
Wordpress Login Shake

jquery

70
TextArea Remaining Characters

php

74
GD Image Filters

javascript

113
iOS and Android Detection

jquery

58
Fixed Position on Scroll

php

53
Multiples Of

html

45
Useful HTML Character Entities

php

51
Generate Random Password

jquery

47
Simple AJAX Using jQuery

shell

47
Show Hidden Files on Mac

html

43
Favicons

javascript

87
Restrict Input to Numbers

jquery

42
setInterval Function

php

56
Twitter Timeline API Results

jquery

39
Smooth Scroll To Top

php

41
Time Ago Function

css

47
Text Emboss Technique

server

44
301 Redirect

php

46
Convert Twitter Links To URLs

jquery

139
Smooth Slide Toggle

css

28
Border Radius

php

47
PHP Range

php

34
Generate Random Colour

css

79
Embedding Fonts

css

40
Browser Selection Colour

html

50
Social Bookmark URLs

php

1294
Date to Roman Numerals

php

52
Copyright Trick

php

84
Sorting an Array in PHP

jquery

62
Calculate Lighter Shade of RGB

sql

53
Inline MySQL Replace Statement