Skip to content

Instantly share code, notes, and snippets.

View sagar-gavhane's full-sized avatar
🏠
Working from home

Sagar sagar-gavhane

🏠
Working from home
View GitHub Profile
@sagar-gavhane
sagar-gavhane / youtubeID.js
Created November 27, 2017 11:01 — forked from takien/youtubeID.js
Get YouTube ID from various YouTube URL using JavaScript
/**
* Get YouTube ID from various YouTube URL
* @author: takien
* @url: http://takien.com
* For PHP YouTube parser, go here http://takien.com/864
*/
function YouTubeGetID(url){
var ID = '';
url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
@sagar-gavhane
sagar-gavhane / form.html
Created February 27, 2018 18:20 — forked from runspired/form.html
How to turn off password and email/username autocomplete.
<!--
<form autocomplete="off"> will turn off autocomplete for the form in most browsers
except for username/email/password fields
-->
<form autocomplete="off">
<!-- fake fields are a workaround for chrome/opera autofill getting the wrong fields -->
<input id="username" style="display:none" type="text" name="fakeusernameremembered">
<input id="password" style="display:none" type="password" name="fakepasswordremembered">
{
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"editor.fontSize": 14,
"editor.tabSize": 4,
"editor.dragAndDrop": false,
"editor.emptySelectionClipboard": false,
"editor.folding": false, // it might be useful
"editor.lightbulb.enabled": false,
"editor.mouseWheelZoom": true,
@sagar-gavhane
sagar-gavhane / convertToSeconds.js
Created June 11, 2018 12:03
function convert to seconds
const convertToSeconds = (time) => {
if (!Array.isArray(time.split(':'))) {
return false;
}
let result =
time.split(':').length > 2 &&
time.split(':').map((t, i) => {
t = parseInt(t);
@sagar-gavhane
sagar-gavhane / generatorAndIterators.js
Last active June 11, 2018 17:34
Generator and Iterators Example
const fetch = require('node-fetch');
const co = require('co');
/*
fetch('https://jsonplaceholder.typicode.com/posts/2')
.then(res => res.json())
.then(res => console.log(title));
*/
// Trying to implement above function using generator and iterator
// Ref:
// 1. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators
// 2. https://davidwalsh.name/es6-generators
// ------------------------------------
function makeIterator(array) {
var nextIndex = 0;
return {
@sagar-gavhane
sagar-gavhane / RegExp.js
Last active January 19, 2019 17:03
Regular Expression for JavaScript
// Matching a ip address version 4
const IPV4_1 = /^(25[0-5]|2[0-4][0-9]|1?[0-9][0-9]{1,2})(\.(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})){3}$/;
const IPV4_2 = /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/;
const IPV4WithPort = /^((?:2[0-5]{2}|1\d{2}|[1-9]\d|[1-9])\.(?:(?:2[0-5]{2}|1\d{2}|[1-9]\d|\d)\.){2}(?:2[0-5]{2}|1\d{2}|[1-9]\d|\d)):(\d|[1-9]\d|[1-9]\d{2,3}|[1-5]\d{4}|6[0-4]\d{3}|654\d{2}|655[0-2]\d|6553[0-5])$/;
// Matching a ip address version 6
const IPV6_1 = /^([0-9a-f]|:){1,4}(:([0-9a-f]{0,4})*){1,7}$/i;
// Matching a Username
const username_1 = /^[a-z0-9_-]{5,16}$/;
#Add the Ubuntu 12.04(precise) repositories
cat <<EOF >> /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu precise main restricted universe
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe
deb http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse
EOF
# Update the repos
apt-get update
@sagar-gavhane
sagar-gavhane / removeCookie.js
Created June 20, 2018 06:24
Remove all cookies from browser - Important set path
removeCookie(){
var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
var eqPos = cookie.indexOf("=");
var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT"+";path=/";
}
}
@sagar-gavhane
sagar-gavhane / sublimetext.txt
Created June 20, 2018 08:18
Sublime Text Licence Key Build 3176
----- BEGIN LICENSE -----
sgbteam
Single User License
EA7E-1153259
8891CBB9 F1513E4F 1A3405C1 A865D53F
115F202E 7B91AB2D 0D2A40ED 352B269B
76E84F0B CD69BFC7 59F2DFEF E267328F
215652A3 E88F9D8F 4C38E3BA 5B2DAAE4
969624E7 DC9CD4D5 717FB40C 1B9738CF
20B3C4F1 E917B5B3 87C38D9C ACCE7DD8