Skip to content

Instantly share code, notes, and snippets.

const MONTHS = {
jan: 'January',
feb: 'February',
mar: 'March',
apr: 'April',
may: 'May',
jun: 'June',
jul: 'July',
aug: 'August',
sep: 'September',
@zevwl
zevwl / show-filename.html
Last active May 29, 2019 19:01
Show the filename in Bootstrap custom-file-label (v4.1+)
<div class="custom-file">
<input type="file" class="custom-file-input" id="file" name="file">
<label for="file" class="custom-file-label">File</label>
</div>
<script>
// Helper function
const addFileNameToLabel = file => {
const fileName = file.target.files[0].name
const customLabel = file.target.nextElementSibling
const MILLISECONDS_IN_DAY = 864e+5
@zevwl
zevwl / .js
Last active May 7, 2019 02:16
Find if given number is prime
function isPrime(num) {
if (num > 1) {
for (let i = 2; i < num; i++) {
if (num % i === 0) {
console.log(`${num} is not a prime number`)
console.log(`${i} * ${num / i} is ${num}`)
return false
}
}
console.log(`${num} is a prime number`)
@zevwl
zevwl / update-inbox-title.js
Last active December 7, 2017 19:48
Add a number to Google Inbox title to show the count for unread emails
(function() {
'use strict';
// Store initial title to prevent apending to already modified title
const docTitle = document.title;
let lastUnreadCount;
// Calling this function will do the work
function checkForUnread() {