Posts

knockout.js - Knockout component with observable object doesn't update data -

i have following component: <template id="fruits-tpl"> <p>name: <input data-bind="value: name" /></p> <p>type: <input data-bind="value: color" /></p> </template> ko.components.register('fruits', { viewmodel: function(params) { this.name = params.name; this.color = params.color; }, template: { element: 'fruits-tpl' } }); i'm using component view model below, items in observable list of different types , have different properties: function fruit(data) { this.name = ko.observable(data.name); this.color = ko.observable(data.color); } function dessert(data) { this.name = ko.observable(data.name); this.packaging = ko.observable(data.packaging); } function vm(){ var data = [{name:"apples",color:"yellow"},{name:"cookies",packaging:"box"}]; this.items = ko.observablearray([new fruit(dat...

c# - Correct way to use StackExchange.Redis in WebApi -

i want add counters several c# webapi controllers using redis , stackexchange.redis client. i have never used redis before, however, have read docs, setup server , appears straightforward results looking for. having read stackexchange.redis docs, concerned following... connectionmultiplexer lot, designed shared , reused between callers. should not create connectionmultiplexer per operation. i have googled , found several examples simple c# console apps (the technique here obvious not relevant webapi), have found examples of using stackexchange.redis client on microsoft pages, emphasize importance of sharing connectionmultiplexer, after hours, still no further forwards in understanding how achieve in c# .net webapi would kind enough point me in right direction? i need make simple calls redis, namely incr counter 1, decr counter 1 , getset counter 0 (to reset) as counters not critical, want ensure if reason connection redis server unavailable code continues in t...

Understanding how to use arg/3 and univ/2 in Prolog -

i have database in prolog , i'm trying return henry owns , owns car , truck. i've tried can think of return henry owns , can't find solution. know how return owns car or truck individually ?- owns(x,car( , ,_))., not @ same time. appreciated. owns(bill, car(ford, mustang, 1964)). owns(sue, car(pontiac, gto, 1967)). owns(george, car(honda, civic, 2013)). owns(betty, truck(ford, f150, 2013)). owns(henry, motorcycle(honda, goldwing, 2010)). prolog has relational data model, allows recursive terms instead of atomics only, sql, , doesn't give names 'columns'. loosely: ╒═════════════╤═════════════╕ │ sql │ prolog │ ╞═════════════╪═════════════╡ │ table │ predicate │ │ record │ clause │ │ table name │ functor │ │ column │ argument │ ╘═════════════╧═════════════╛ so, knowledge attributes position required. conventionally, can associate attribute' names in functors: % owner of kind listed kinds_owner(k...

javascript - Trying to serialize form with ajax and jquery -

i'm trying form submit user input modal in jquery via ajax ajax call isn't picking user input. ajax call being made server when check if user input has registered server it's blank. html: <body> <div id="home"> <p>home</p> </div> <div id="welcome"> <span>welcome <?php echo $_session['user']; ?></span> </div> <form id="form"> <p1>please enter in hotkey below</p1> <input type="text" id="hotkey" placeholder="hotkey"> <input id="submit" type="button" value="submit"> </form> <div id="keyshortcut"> <input type="text" id="keyshortcut" placeholder="hotkey"> </div> <div id="select_button"> <button id="select-hotkey">select hotkey</button> <...

api - what are the difference between particle.publish event and particle.subscribe event in particle.cloud? -

what particle.publish , particle.subscribe event in particle.cloud api .i sort of confused on application while building android application internet of thing product. particle.publish() publish event through particle cloud forwarded registered callbacks, subscribed streams of server-sent events, , other devices listening via particle.subscribe().this feature allows device generate event based on condition. example, connect motion sensor device , have device generate event whenever motion detected. particle.subscribe() subscribe events published devices.this allows devices talk each other easily. example, 1 device publish events when motion sensor triggered , subscribe these events , respond sounding alarm. to use particle.subscribe(), define handler function , register in setup(). references: https://docs.particle.io/reference/firmware/photon/#cloud-functions

Laravel TypiCMS redirects to root -

i using typicms laravel here : github.com/typicms/base , facing following problem: i created new module named "news" executing command: composer require typicms/news. added providers in config/app.php, have publish views , migrations , migrated database too. the problem facing whenever url given, redirects me root directory of project, is, http://localhost/mywebsite/public/ even, if give invalid route localhost/mywebsite/public/foobar, instead of showing me error, again redirects root directory. i have checked .htaccess , routes.php file , there not modifications. regards: adnan typicms cannot installed in subfolder, root of site must http://localhost .

gis - Using Python fiona read polygons -

for now, can use fiona read 1 specific polygon , plot this: ## read shapefile import fiona import shapely shapely.geometry import shape c = fiona.open("xxx.shp") pol = c.next() geom = shape(pol['geometry']) poly_data = pol["geometry"]["coordinates"][0] poly = polygon(poly_data) output this: http://i13.tietuku.com/65d7d9d6a423a5d3.png but when shapefile composed several shapefile this: fig = plt.figure(figsize =(8,6)) ax = plt.gca() map = basemap(llcrnrlon=114.3,llcrnrlat=37.95,urcrnrlon=114.75,urcrnrlat=38.2) map.readshapefile("xxx",'xxx',zorder =1,) patches=[] cs=plt.cm.blues_r(np.arange(21)/21.) info, shape in zip(map.xxx_info, map.xxx): x,y=zip(*shape) patches.append( polygon(np.array(shape), true) ) # facecolor= '#6582b3' ax.add_collection(patchcollection(patches, facecolor= cs,edgecolor='none', linewidths=1.5, zorder=2,alpha = 0.8)) http://i13.tietuku.com/a331edcbee...