Skip to content

Instantly share code, notes, and snippets.

@sudhir600
sudhir600 / count_keys_in_array.js
Created August 1, 2019 05:02
Get total numbers of same key in array
// E.g
// let array = ["sudhir", "hello", "test", "sudhir", "a", "a", "a"]
//output = sudhir:2, hello:1, test: 1 and a:3
countKey(array){
let obj = {}
array.forEach(function(i){
if(obj[i] == undefined){
obj[i] = 0
}
@sudhir600
sudhir600 / dynamically_chosen.html
Created July 12, 2019 06:54
Apply Jquery Chosen On Dynamically Added Select-element
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://harvesthq.github.io/chosen/chosen.css">
</head>
<body>
<div style="margin-bottom:10px;display: inline-block;">
<div class="here">
<select data-placeholder="choose Team" class="chosen-select" id="abcd">
<option value=""></option>
@sudhir600
sudhir600 / camelCase.js
Created May 29, 2019 11:34 — forked from johnsmith17th/camelCase.js
To convert string to camel case in javascript.
function toCamelCase(str) {
return str.toLowerCase().replace(/(?:(^.)|(\s+.))/g, function(match) {
return match.charAt(match.length-1).toUpperCase();
});
}
@sudhir600
sudhir600 / nuxt.config.js
Last active February 22, 2019 09:50
add settings.js in middleware
module.exports = {
mode: 'spa',
router: {
middleware: ['settings']
},
...
@sudhir600
sudhir600 / settings.js
Last active February 22, 2019 09:51
global settings in nuxt vuejs
global.$s = require('../settings.json')
if(!process.server){
Object.defineProperty(Vue.prototype, '$s', { value: $s })
}
#uses
/*created(){
var a = $s['key']
}
or in html
<html><head>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style type="text/css">
.wrp{
margin:20px;
padding:10px
}
body{
background-color: transparent;
}
@sudhir600
sudhir600 / set-custom-domain-on-localhost-with-xampp
Last active July 26, 2021 03:45 — forked from oozman/custom-domain-localhost-xampp
How to add a custom domain name on your localhost using XAMPP. Codes are based on Windows, but Step 2 onward are pretty much applicable on other operating system.
Step 1:
Go to: C:\Windows\System32\Drivers\etc\hosts
And add this to the bottom of the file:
=============
127.0.0.1 your.domain.com
=============
Step 2:
Go to [your XAMPP directory]/apache/conf/httpd-xampp.conf
how to do the same in php
<?php
error_reporting(E_ALL);
$from = 'sudhirgupta.456@gmail.com';
$headers = "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-Type: text/html; charset=UTF-8" . PHP_EOL;
$headers .= "From: " . $from . "\r\n";
$headers .= "Reply-To: " . $from . "\r\n";
$headers .= "Return-Path: " . $from . "\r\n";
$headers .= "CC: sudhirgupta500@yahoo.com \r\n";