This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = env => { | |
entry:'filename.js', | |
output: { | |
filename: "[name].bundle.js", | |
path: path.resolve(__dirname, "dist") | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.m?js$/, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://triin.net/2010/01/13/Fighting_the_uglyness_of_Array.push() | |
var buttons = [ | |
new OpenButton(), | |
isPayingCustomer() ? new ExportButton() : null, | |
new SaveButton(), | |
new DeleteButton() | |
].compact(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = {"results":[{"answers":{"text":"A1"},"confidence":0.5,"name":"N1"},{"answers":{"text":"A2","type":"text"},"confidence":0.4,"name":"N2"},{"answers":{"text":"A3","type":"text"},"confidence":0.3,"name":"N3"},{"answers":{"text":"A4","type":"text"},"confidence":0.2,"name":"N4"},{"answers":{"text":"A5","type":"text"},"confidence":0.1,"name":"N5"}]}; | |
// Version 1 | |
var output = data.results.filter(ans => ans.confidence>0.2).map(ans => ({answer:ans.name,confidence:ans.confidence})); | |
// Version 2 | |
var output = data.results.reduce((f,s)=>{ | |
if(s.confidence > 0.2) f.push({answer:s.name,confidence:s.confidence}) | |
return f; | |
},[]); | |
// version 3 | |
var output = data.results.reduce((f,s)=> s.confidence > 0.2? [...f,{answer:s.name,confidence:s.confidence}] :f,[]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reject(obj, keys) { | |
return Object.keys(obj) | |
.filter(k => !keys.includes(k)) | |
.map(k => Object.assign({}, {[k]: obj[k]})) | |
.reduce((res, o) => Object.assign(res, o), {}); | |
} | |
console.log(reject({a: 2, b: 3, c: 4}, ['a', 'b'])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check if nested property exists or not | |
var propertyexists = (objectname,path) => path.split(".").reduce((k,v) => (typeof k=="undefined")?k:k[v],objectname); | |
var myobject = {info:{name:"vibhas"}}; | |
console.log(propertyexists(myobject,"info.name.jhgfdsa.asdfghj")); | |
// If exists it return that value or "undefined" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- need to add jquery and jquery.cookie.js--> | |
<body onload="loadLocation()"> | |
<div id="container"> | |
<div class="inner-container"> | |
<div class="box box-50"> | |
<div class="boxin"> | |
<div class="header"> | |
<h3>HTML5 Geo-Location</h3> | |
</div> | |
<div class="content"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cmp($a, $b) { | |
if ($a['TotalEarnings'] == $b['TotalEarnings']) { | |
return 0; | |
} | |
if ($_GET['sortby'] == "earnings"): | |
$orderBy = ($_GET['order'] == 'a') ? "DESC" : "ASC"; | |
endif; | |
if ($orderBy == "DESC"): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTML : | |
<input type="text" name="userid" /> | |
JAVAASCRIPT : | |
<script> | |
jQuery.noConflict(); | |
jQuery(document).ready(function(){ | |
jQuery('#userid').autocomplete({source:function(request,response){ | |
jQuery.ajax({ | |
type:'post', |
NewerOlder