Skip to content

Instantly share code, notes, and snippets.

View amitkhare's full-sized avatar
🤔
Brainstorming

Amit Kumar Khare amitkhare

🤔
Brainstorming
View GitHub Profile
@amitkhare
amitkhare / Let's encrypt install.sh
Last active March 15, 2020 16:09
Let's encrypt certificate install Ubuntu + Apache
# stop apache server
service apache2 stop
systemctl stop apache2
apache2ctl stop
# run certificate wizard
sudo certbot --authenticator standalone --installer apache
# start apache server
apache2ctl start
@amitkhare
amitkhare / gist:d1d606d4a6c29b041dafba357be559a8
Created January 27, 2018 09:57 — forked from adamstac/gist:7462202
Install and configure Sendmail on Ubuntu

Install and configure Sendmail on Ubuntu

This should help you get Sendmail installed with basic configuration on Ubuntu.

  1. If sendmail isn't installed, install it: sudo apt-get install sendmail
  2. Configure /etc/hosts file: nano /etc/hosts
  3. Make sure the line looks like this: 127.0.0.1 localhost yourhostname
  4. Run Sendmail's config and answer 'Y' to everything: sudo sendmailconfig
  5. Restart apache sudo service apache2 restart
@amitkhare
amitkhare / MusicControlsNotification.java
Last active February 26, 2018 09:38
cordova-music-controls-plugin android api 26 : fixed
package com.homerours.musiccontrols;
import org.apache.cordova.CordovaInterface;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.File;
import java.net.HttpURLConnection;
@amitkhare
amitkhare / project.properties
Last active March 9, 2018 16:28
Solution to build failed cordova -> android ----- # https://stackoverflow.com/a/49172982/1126340
# solution to build failed cordova -> android
# https://stackoverflow.com/a/49172982/1126340
# This file was originally created by the Android Tools, but is now
# used by cordova-android to manage the state of the various third party
# libraries used in your application
# This is the Library Module that contains the Cordova Library, this is not
# required when using an AAR
@amitkhare
amitkhare / service-worker.js
Created April 18, 2018 12:23
basic cache all service-worker
const PRECACHE = 'precache-v2';
const RUNTIME = 'runtime';
// A list of local resources we always want to be cached.
const PRECACHE_URLS = [
'./' // Alias for index.html
// 'fonts/MaterialIcons-Regular.012cf6a.woff',
// 'fonts/Roboto-Bold.ad140ff.woff',
// 'fonts/Roboto-Light.37fbbba.woff',
// 'fonts/Roboto-Medium.303ded6.woff',
@amitkhare
amitkhare / youtubeID.js
Created April 26, 2018 12:49 — 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\/)/);
@amitkhare
amitkhare / Recursive_Tree_Menu_Gererator.js
Last active June 2, 2018 07:54
Generates Tree menu parent>child relation array
const listToTree = (list) => {
var map = {}
var node
var roots = []
var i
for (i = 0; i < list.length; i += 1) {
map[list[i].id] = i // initialize the map
list[i].children = [] // initialize the children
}
for (i = 0; i < list.length; i += 1) {
// Run from the dev tools console of any Youtube video
// Accurate as of June 23, 2017.
// ES6 version
const videoUrls = ytplayer.config.args.adaptive_fmts
.split(',')
.map(item => item
.split('&')
.reduce((prev, curr) => (curr = curr.split('='),
Object.assign(prev, {[curr[0]]: decodeURIComponent(curr[1])})
@amitkhare
amitkhare / server.js
Last active June 20, 2018 10:34
Express + Socket.IO Server
var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.sendFile(__dirname + '/public/default.html');
})
app.use('/', express.static('public'));
@amitkhare
amitkhare / pm2start.sh
Created July 14, 2018 05:45
PM2 Start server
pm2 kill
pm2 start /var/www/<PATH>/server.js -i max --name "NAME"