Skip to content

Instantly share code, notes, and snippets.

View monis01's full-sized avatar
🏠
Working from home

Mohd Monis monis01

🏠
Working from home
View GitHub Profile
@monis01
monis01 / addZeroesToTime.js
Last active June 22, 2019 16:30
it's a timer with proper addition of zeroes
function showTime(){
let todayDate = new Date(),
hour = todayDate.getHours(),
mins = todayDate.getMinutes(),
sec = todayDate.getSeconds() ;
const amPm = hour>=12 ? 'PM' : 'AM' ;
//12 hours format
hour = hour % 12 || 12 ;
<!-- taken from -->
<!-- http://www.rssheap.com/article/?p=YXJ0aWNsZWlkPTE3MjkyMTUmdGFiPXdlZWsmZ3VpZD1mMDRhNDZiZDRiOTY0ZDMxYWJhNDkyZGQ3OWE2YzQ2ZSZmaWx0ZXI9 -->
<!-- @demo -->
<!-- https://jsfiddle.net/cferdinandi/mqwwpL6u/ -->
<style>
textarea {
min-height: 5em;
max-height: 50vh;
width: 100%;
@monis01
monis01 / fileReader.js
Last active November 15, 2022 02:16
Detect file extension with javascript FileReader
//@ https://stackoverflow.com/questions/25095863/how-to-detect-file-extension-with-javascript-filereader
var fileTypes = ['jpg', 'jpeg', 'png', 'what', 'ever', 'you', 'want']; //acceptable file types
function readURL(input) {
if (input.files && input.files[0]) {
var extension = input.files[0].name.split('.').pop().toLowerCase(), //file extension from input file
isSuccess = fileTypes.indexOf(extension) > -1; //is extension in acceptable types
if (isSuccess) { //yes
var reader = new FileReader();
@monis01
monis01 / directiveInNgBindHtml.html
Created January 9, 2018 12:10
allowing directive in ng-bind-html
<div ng-app="vkApp">
<div ng-controller="vkController">
<vk></vk>
<div compile="data.article"></div>
</div>
</div>
<script>
angular.module('vkApp', []);
angular.module('vkApp')
.controller('vkController', ['$scope', '$compile', function ($scope, $compile) {
@monis01
monis01 / browserType.js
Created December 8, 2017 10:30
Detect Browser Type
var is_chrome = navigator.userAgent.indexOf('Chrome') > -1;
var is_explorer = navigator.userAgent.indexOf('MSIE') > -1;
var is_firefox = navigator.userAgent.indexOf('Firefox') > -1;
var is_safari = navigator.userAgent.indexOf("Safari") > -1;
var is_opera = navigator.userAgent.toLowerCase().indexOf("op") > -1;
if ((is_chrome)&&(is_safari)) { is_safari = false; }
if ((is_chrome)&&(is_opera)) { is_chrome = false; }
//@ Or for Safari only
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {alert('Its Safari');}
@monis01
monis01 / caps.js
Created October 11, 2017 06:18
Caps Each Letter In The Sentense
//@ changing values like 'hi this is my first gist' to 'Hi This Is My First Gist';
function changeAllToCaps(string){
return (string.split(' ').map(function(x){
x = x.charAt(0).toUpperCase() + x.slice(1);
return x ;
})).reduce(function(sum,value){
return sum+' '+value;
});
}