Posts

javascript - Angular UI router - can't get my data in component after resolve -

i have router configured this: .state('home.view-profile', { url: '/view-profile/:profileurl', template: '<view-profile input="$resolve.profiledata"></view-profile>', title: 'view profile', resolve: {profiledata: function(artistservice, $stateparams){ return artistservice.getartist($stateparams.profileurl).then((data) => { const timer = new date(); console.log(timer.getseconds() + ':' + timer.getmilliseconds()); console.log(data.data.artist); return data.data.artist; }); } } }) and component module.component('view-profile', { templateurl: 'view-profile/view-profile.component.html', bindings: { input: '=' }, controller: ['$state', '$scope', '$stateparams', function ($state, $scope, $stateparams) { const model = this; console.log('***************'); console...

clojure - Intersecting a list of lists of maps overriding equality -

i have list of lists of maps: (( {:id 1 :temp 1} {:id 2} ) ( {:id 1 :temp 2} ) ( {:id 1 :temp 3} {:id 2} )) i want ids @ intersection of these 3 sets :id key. result here 1 i came solution it's hurting eyes: (def coll '(( {:id 1 :temp 1} {:id 2} ) ( {:id 1 :temp 2} ) ( {:id 1 :temp 3} {:id 2} ))) (apply clojure.set/intersection (map set (map (fn [m] (map #(select-keys % '(:id)) m)) coll))) returns #{{:id 1}} which ok, other suggestions? if fine getting #{1} (as mention initially) instead of #{{:id 1}} , can improved: (apply set/intersection (map (fn [c] (into #{} (map :id c))) coll))

html - Divs overlapping when resizing window -

Image
i'm making website using twitter bootstrap , having issue when resizing browser windows. have tried using width , height both div s, making child div position: absolute; , parent div position: relative; , no avail. this code the element i'm trying show pulled through php (a map) , how overlaps. i realize shouldn't doing styling within html, wanted show details in 1 place. i able map scale without overlapping using 2 classes come twitter bootstrap, called embed-responsive embed-responsive-16by9 and source code .embed-responsive { position: relative; display: block; height: 0; padding: 0; overflow: hidden; } .embed-responsive-16by9 { padding-bottom: 56.25%; } even though tried manually make div s parent position: relative; , child of every positioning, didn't work, guess it's height , padding. thank responding, , hope answer helps more people.

How do I run typescript file after compile without generating javascript file -

type script using tsc -w -p . watch mode. , generate .js files. so, typescript run node example.js normal. but, run typescript without node example.js command how can it? will run typescript without node example.js command how can it you can use ts-node compile + run directly (without ever writing disk): ts-node example.ts more https://github.com/typestrong/ts-node

javascript - JS - Debounce a delegated event -

take @ this js code (here's snippet): //debounce function davidwalsh: https://davidwalsh.name/javascript-debounce-function //returns function, that, long continues invoked, not //be triggered. function called after stops being called //n milliseconds. if `immediate` passed, trigger function on //leading edge, instead of trailing. function debounce(func, wait, immediate) { var timeout; return function() { var context = this, args = arguments; var later = function() { timeout = null; if (!immediate) func.apply(context, args); }; var callnow = immediate && !timeout; cleartimeout(timeout); timeout = settimeout(later, wait); if (callnow) func.apply(context, args); }; }; $(document).on('click', '#foo-one, #bar-one', debounce(function(e) { $('#counter-one').append('<span>1</span>'); }, 350)); $('#foo-two').click(debounce(function(e) { $(...

c++ - Merging K Sorted Arrays/Vectors Complexity -

Image
while looking problem of merging k sorted contiguous arrays/vectors , how differs in implementation merging k sorted linked lists found 2 relatively easy naive solutions merging k contiguous arrays , nice optimized method based off of pairwise-merging simulates how mergesort() works. 2 naive solutions implemented seem have same complexity, in big randomized test ran seems 1 way more inefficient other. naive merging my naive merging method works follows. create output vector<int> , set first of k vectors given. merge in second vector, third, , on. since typical merge() method takes in 2 vectors , returns 1 asymptotically linear in both space , time number of elements in both vectors total complexity o(n + 2n + 3n + ... + kn) n average number of elements in each list. since we're adding 1n + 2n + 3n + ... + kn believe total complexity o(n*k^2) . consider following code: vector<int> mergeinefficient(const vector<vector<int> >& multilist) { ...

node.js - How can I use data passed into jade template in the views javascript? -

rendering data template res.render('account/pets/allpets', { petmap, title: 'all pets' }) have tried 2 thing make work a) var neighborhoods = []; (var = 0; < petmap.length; i++) { neighborhoods.push(new google.maps.latlng(petmap[i].location.loc[0],pet.location.loc[1])) } b) var neighborhoods = [ each pet in petmap new google.maps.latlng(petmap[i].location.loc[0],pet.location.loc[1]) ] assuming patmap javascript object, required few hacky things make work. pug renders serverside, while javascript on client, cannot directly access pug variable in js. can convert js object string when pug compiles, parse json when client executes. var petmap = json.parse(("#{json.stringify(petmap)}").replace(/&quot;/g, '"')); /* let me break down in terms of execution "#{json.stringify(petmap)}" -> executes server side, converts #{} accesses pug variable petmap, h...