Posts

Showing posts from August, 2010

delete row in an html doc using python -

i writing python script writes html code html document. however, printing html doc thing can do. have rows don't need, i'm not sure how delete rows printing? i've tried using deleterow(index) method, doesn't work because have not created table objects. can write html code inside, such as resultfile.write("<td> %s </td>" %line) resultfile.write("<td> 0 </td>") please, if don't question, don't mark down. i'm new stackoverflow, , 1 reputation can't anything. assuming working in context of append-only operations file point of view, should add want write list first, scan , delete not want, , write file. more specifically, can create mylines = [] , , replace occurrences of resultfile.write mylines.append . then, loop through copy of mylines , keep lines like. finally, loop through remaining items , call resultfile.write on each item. for item in mylines: resultfile.write(item)

OpenCL Matrix multiplication: inner product versus outer product -

i'm hoping familiar standard "naive" method of multiplying 2 ( n x n square simplicity) matrices. in c is: for(int = 0; < n; ++i) for(int j = 0; j < n; ++j) for(int k = 0; k < n; ++k) c[i*n + j] += a[i*n + k] * b[k*n + j]; the above method computes dot (inner) product of row of a column of b , easy implement in opencl follows: __kernel void matmul_ocl( __global const float *a, __global const float *b, __global float *c, const int n ) { const int row = get_global_id(1); // row const int col = get_global_id(0); // col for(int = 0; < n; i++) c[row*n + col] += a[row*n + i]*b[i*n + col]; } interchanging 2 inner-most loops of original c implementation results in method computes outer products, i.e., computes rank-1 updates of rows of c matrix: for(int = 0; < n; ++i)

c# - XML String to JSON using only native .NET methods -

i'm trying rewrite php function c#. php function converts xml string json. at first, came this: string[] zips = { "27249","27215"}; // request.form.get("zip").toarray(); list<string> listings = new list<string>(); var webclient = new webclient(); (int = 0; != zips.length; i++) { string returnxml = webclient.downloadstring("http://gateway.moviefone.com/movies/pox/closesttheaters.xml?zip=" + zips[i]); var json = new system.web.script.serialization.javascriptserializer().serialize(returnxml); listings.add(json); response.write(json); } but output included encoded characters, wasn't wanted. then, using json.net, replaced loop body this: string returnxml = webclient.downloadstring("http://gateway.moviefone.com/movies/pox/closesttheaters.xml?zip=" + zips[i]); var xmldoc = new system.xml.xmldocument();

bar chart - adding space between x axis and xtics in gnuplot histogram -

Image
currently created graphs small size. spacing important @ case. want add more vertical space between xticlabels , x axis. have tried set x bar set xtics offset 0,graph 0.05 my gnuplot output: the data , gnuplot script still same previous question here . you can following: first add little bit of bmargin set bmargin 3 since need add vertical space between xticlabels , x-axis , need adjust y-offset, can done following set xtics offset 0,-1,0 you can play around values suite need.

Running a Jar with Java ProcessBuilder gives me null output -

Image
i have been trying following code work. package com.compressor; import java.io.bufferedreader; import java.io.file; import java.io.inputstreamreader; public class jscompressor { public static void main(string[] args) { try { string currentdir = system.getproperty("user.dir"); string[] commands = { "java", "-jar","yuicompressor.jar"}; processbuilder pb = new processbuilder(commands); pb.directory(new file(currentdir)); process p = pb.start(); bufferedreader output = new bufferedreader(new inputstreamreader(p.getinputstream())); system.out.println("result : " + output.readline()); } catch (exception ex) { ex.printstacktrace(); } } } my project directory looks shown in image below : but still when run program inside eclipse gives me null output given below : result : null i have tried googling several o

pyopengl - Is it possible to use together pyggel and GLUT libraries -

i'm new pyopengl , i'm working on code based on pyggel library, i'd add features glut (menu & text) , i'm not sure how should join both (if possible). in glut, running glutmainloop() required, on other hand have run() routine: def run(self): while 1: self.clock.tick(60) self.getinput() self.processinput() pyggel.view.clear_screen() self.mouse_over_object = self.scene.render(self.camera) pyggel.view.refresh_screen() #glutmainloop() putting glut routine inside run() doesn't work (it crashes when gets glutmainloop). so, how can join both loops? can i? i'm guessing that's need make both things work. thanks in advance! you not going find easy do. pyggel based on pygame gui framework, while glut own gui framework. may able text-rendering working, under covers glut doing regular opengl that, menus not going work under pyggel. pyggel has both text-rendering , gui framework inc

python - Using Matplotlib to create adjacent graphs -

Image
how can make first image second using matplotlib? each "column" blue graph represents inverse of corresponding green graph "column". think format informative. edit: code should give idea of i'm doing. import tkinter tk import numpy np matplotlib.figure import figure matplotlib.font_manager import fontproperties matplotlib.backends.backend_tkagg import figurecanvastkagg infoframe = tk.frame(tk.tk(), width=1200, height=750, padx=5, pady=5) infoframe.grid() graphcanvas = tk.canvas(infoframe) graphcanvas.grid(columnspan=5, rowspan=2, row=1) infograph = figure(figsize=(7, 6), dpi=100) firstgraph = infograph.add_subplot(2, 1, 2, axisbg="#9ddeff") secondgraph = infograph.add_subplot(2, 1, 1, axisbg="#b2f0b2") entries = ["one", "two"] types = ["x", "y"] _tkcolors = ["black", "yellow", "magenta", "cyan", "red", "green", "blue&

python - mitmproxy replace entire HTML tag -

well....looks first post stackoverflow. totally stumped , wasted hours working on little project , i'm ready give up. can me. i've been working mitmproxy. i'm writing python script replace body tag in http response custom content when user loads page. from libmproxy import controller, proxy import re import os import sys class bodyinjector(controller.master): def __init__(self, server): controller.master.__init__(self, server) def run(self): try: return controller.master.run(self) except keyboardinterrupt: self.shutdown() def handle_request(self, msg): print 'new request detected.' if 'accept-encoding' in msg.headers: msg.headers["accept-encoding"] = ["none"] print 'changing encoding.' msg.reply() def handle_response(self, msg): if 'content-type' in msg.headers: if msg.headers[&

python - Best way to replace values in a list based on many indexes -

i have list this: l = [1,2,3,4,5,6,7,8,9,10] idx = [2,5,7] i want replace values in l 0, using indexes idx. do: for in idx: l[i] = 0 this give: l = [1, 2, 0, 4, 5, 0, 7, 0, 9, 10] is there better, faster, more pythonic way. small example, if have huge lists? i think fine. write list comprehension, this: [v if not in idx else 0 i, v in enumerate(l)] or change in place iterating on l for i, v in enumerate(l): if in idx: l[i] = 0 but find harder read, , slower. don't think other solution beat yours significant margin, ignoring cpu caching.

c# - How to convert string from a configuration file to a readable key? -

i have configuration .xml file contains following keys: <add key="key1" value="d1"/> <add key="key2" value="d2"/> <add key="key3" value="d3"/> <add key="key4" value="d4"/> <add key="key5" value="d5"/> now need keys used here, tried doesn't work: string k1 = system.configuration.configurationmanager.appsettings["key1"]; string k2 = system.configuration.configurationmanager.appsettings["key2"]; string k3 = system.configuration.configurationmanager.appsettings["key3"]; string k4 = system.configuration.configurationmanager.appsettings["key4"]; string k5 = system.configuration.configurationmanager.appsettings["key5"]; keys key1 = (keys)enum.parse(typeof(keys), k1); keys key2 = (keys)enum.parse(typeof(keys), k2); keys key3 = (keys)enum.parse(typeof(keys), k3); keys key4 = (keys)enum.parse(typeof(keys

javascript - Meteor AutoForm - Is it possible to manually call the onSuccess or onError hooks? -

i have form checks user's captcha input. when captcha valid, should send e-mail, otherwise should display error. autoform.addhooks(["form1", "form2", "form3"], { onsubmit: function(doc) { meteor.call('validatecaptcha', formdata, function(error, result) { if (result.success == true) { meteor.call('sendemail', doc); } else { recaptcha.reload(); // call onerror here console.log("error!"); } }); }, onsuccess: function(operation, result, template) { // display success, reset form status console.log("captcha validation success! email sent!"); }, onerror: function(operation, error, template) { // display error, reset form status console.log("error: captcha validation failed!"); } } now problem code when user submits correct captch

Spring Data Rest Without HATEOAS -

i boilerplate code spring data rest writes you, i'd rather have 'regular?' rest server without hateoas stuff. main reason use dojo toolkit on client side, , of widgets , stores set such json returned straight array of items, without links , things that. know how configure java config mvc code written me, without hateoas stuff? so want rest without things make rest? :) think trying alter (read: dumb down) restful server satisfy poorly designed client library bad start begin with. here's rationale why hypermedia elements necessary kind of tooling (besides familiar general rationale ). exposing domain objects web has been seen critically of rest community. reason boundaries of domain object not boundaries want give resources. however, frameworks providing scaffolding functionality (rails, grails etc.) have become hugely popular in last couple of years. spring data rest trying address space @ same time citizen in terms of restfulness. so if start plain da

Performance Tuning Angularjs ng-repeat for large lists -

i have angularjs directive have written acts form select component. has search field search through choices. when click on choice removes choice list of choices , displays it, above search field, selection. when click on selection removes selections, above search field, , places in choices list. i have done lot of research on ng-repeat , it's potential performance issues, have seen. in current iteration using bindonce, limitto , track by, , infinite scroll. on laptop directive fast, on iphone 5, still fast, on iphone 4 pretty fast , on iphone 3 junk. on iphone 3 text search filtering through choices fast, selecting choice or selection slow. here ng-repeat using choices: <a bindonce refresh-on="'refreshselect'" ng-repeat="choice in choices | filter:{name: searchfilter.name, selected: false}:strict | orderby:'name' | limitto: limitnumberofchoices track choice.id" ng-click="addtoselections(choice)"> <div class="

qt - How can I set just `Widget` size? -

Image
how can set widget size? my code: from pyside.qtgui import qapplication, qwidget, qlabel import sys app = qapplication(sys.argv) mainwindow = qwidget() gamewidget = qwidget(mainwindow) #gamewidget.setgeometry(gamewidth, gameheight) <-- want set size of gamewidget such this. how can this. gamewidget.move(100,0) gamelabel = qlabel("this game widget", gamewidget) mainwindow.show() output: description: this create window contain widget . want set widget size. know there method widget.setgeometry , takes 4 parameter (x, y, width, height) . want method widget.setgeometry takes size parameter (width, height) . p.s. feel free modify question. because i'm learning english!! thanks. just use qwidget.resize(weight, height) . for example: gamelabel.resize(200, 100); besides, can use qwidget.sizehint() proper size automatically, example: gamelabel.resize(gamelabel.sizehint());

What is Java Regex to check "=2245" or "= 545" or "= 22", etc? -

ok, want check if string has = first character & followed number, if there space between = & number ok. ok, here example, string s="=2245"; --> return true string s="= 545"; --> return true string s="= 22"; --> return true string s="= m 545"; --> return false string s="=m545"; --> return false so here did if(s.matches("=[0-9]+")){ return true; } this work if there not space between = & number so changed to: if(s.matches("=\\s[0-9]+")){ return true; } then work if there 1 space between = & number & won't work in other cases. so how fix it? "=\\s*\\d+" the * means "zero or more repetitions", work if spaces there or not. \d alternative way write [0-9] .

javascript - ways to convert array to object in my case -

i face problem lots , tired of writing conversion function i can do function toobject(arr) { var rv = {}; (var = 0; < arr.length; ++i) rv[i] = arr[i]; return rv; } but there short-cut that? case below : angular.foreach($scope.data, function(item){ if(thread.checked === true){ var links = item.url; chrome.tabs.create(links, function(tab) { }); } }); i'm using chrome api links obj : chrome.tabs.create(obj, function(tab) { }); in es5 browser can do: var obj = {}; [0,1,2].foreach(function(v, i){obj[i] = v}); or [0,1,2].foreach(function(v, i, arr){this[i] = v}, obj); as function: function toobj(arr) { var obj = {}; arr.foreach(function(v, i){obj[i] = v}); return obj; } if object passed in may not array object properties 0 n, then: function toobj(arr) { var obj = {}; [].foreach.call(arr, function(v, i){obj[i] = v}); return obj; }

ant - calling a target from a particular directory -

i have script call below target before calling target want should @ following location stored in below variable .. todir="${release.deployment.tool} the target called shownb below.. <target name="deploy-ion" description="used deploy given aaa."> so when target deploy-ion being called should make sure should in directory stored in todir , please advise how achieve this. i meant can use absolute path of property reference while performing set of tasks inside target, default uses basedir default value cur-dir or 1 specified @ project level @ beginning of build.xml file. also alternatively can use ant's ant task : https://ant.apache.org/manual/tasks/ant.html usage like <ant dir="${release.deployment.tool}" target="deploy-ion" />

peoplesoft - 8.51 tools PSAPPSRV crash -

tried install fresh instance of pt on vm running linux following versions: os: linux centos 6.5 64bit database: oracle 11.2.0.1 64bit app serv: tuxedo 11gr1 11.1.1.3 64bit rp015 web serv: weblogic 10.3.6 jdk: jrockit linux jdk 1.6.0_45 r28.2.7-4.1.0 64bit pt: 8.51.25 i could: - start db, able connect w sqlplus, app designer, data mover - start app serv (listening on ports 7000, 9000) - start web serv - access web page (web serv running fine) once load pia login page, got tpesvcerr error (default setting error). same error if try login via pia. web serv log (same error can seen repeatedly) severe psft.pt8.net.netreqrepsvc sendrequest tpesvcerr - server error while handling request severe psft.pt8.net.netreqrepsvc sendrequest error occurred on application server within jolt while running service. cancel current operation , retry. if problem persists contact system administrator. error code:10 severe psft.pt8.net.netreqrepsvc sendrequest appl

php - How to execute the nord cms yii framework? -

hi have integrated yii nord cms.. here code config.php 'import'=>array( 'application.models.*', 'application.components.*', 'application.modules.cms.cmsmodule', 'application.controllers.*', ), 'modules'=>array( 'cms', ), 'components'=>array( 'urlmanager'=>array( 'rules'=>array( 'page/<name>-<id:\d+>.html'=>'cms/node/page', // clean urls pages ), ), 'cms'=>array( 'class'=>'cms.components.cms', ), in site controller have wriiten code this public function actionindex() { $this->widget('cms.widgets.cmsblock',array('name'=>'bar')); $this->render('index',array('model'=>$model)); } i dont know how run nordcms. have got empty output. please me you should put wid

objective c - Pinch zoom limit in core plot iOS -

i have implement pinch zoom limit in core plot. think method pinch zoom. please should in mehtod: (bool)plotspace:(cptplotspace *)space shouldscaleby:(cgfloat)interactionscale aboutpoint:(cgpoint)interactionpoint { return yes; } could please share sample code. if more concerned resulting plot range rather relative scaling amount (a common case), use delegate method: -plotspace:willchangeplotrangeto:forcoordinate: this method informs plot range change range in parameters. should inspect range, modify needed meet requirements, , return range want plot space use. called before change. there several examples of usage in plot gallery example app.

javascript - Move arrow to each menu when its selected -

i have list of 3 items like <ul id="tab_sel35116"> <li><a href="#description35116" class="job_content" data-id="35116">description</a></li> <li><a href="#msg_body35116" class="job_content select_tab" data-id="35116">messages</a></li> <li><a class="job_content" data-id="35116">applicants</a></li> <div id="down_blue_arr"><span class="about_down_arrow" style="left: 20px;"></span><span class="about_down_arrow1" style="left: 20px;"></span></div> </ul> in want when select item of list arrow under menu. arrow div down_blue_arr here css .about_down_arrow{position:absolute;border-color: #4793d8 transparent transparent transparent; border-width:9px;border-style:solid;width:0;height:0;float:right;top:25px;left:20px;} .about

arrays - Sort JSON data based on UTC timestamp in php from client side -

i have json data. 1 of fields timestamp. there way sort data based on timestamp? please don't recommend me jquery plugins datatables. , don't want fetch data database in sorted order either. use following sql command. select * tablename; i don't want data in sorted form database using command this. select * tablename order by..... is possible sort json data i've said using php??? want data sorted in descending order based on timestamp. suggestions??? here sample data http://codepad.viper-7.com/tylowv i tried this... function sortbyyear($a, $b) { $da = new datetime($a['date']); $db = new datetime($b['date']); return $da->format('y') - $db->format('y'); } $d = json_decode($sample_data, true); $info = $d['date']; usort($info, 'sortbyyear'); print_r($info); try array_multisort function in php $date = array(); $d = json_decode($sample_data, true); foreach ($d $key => $r

android - Singed apk doesn't show the google map -

i implementing google map in application , every time run through source code runs correctly means google map appears when run through signed apk doesn't show google map. make singed apk several times problem still there. help you have change sha in google play console. generate new sha keystore file(which have used generate signed apk) & add on google play console package name. keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android after change google map key in code. create new signed apk, install in device check google map.

I'm new to verilog and please help me figure out what might be the error -

module ram_1_verilog(input ena,input enb, input wea, input web, input oe, input clk); line :25 input [7:0] addr_a; //error line :26 input [7:0]addr_b; //error line :27 input reg [7:0] dout1; //error line :28 output reg [7:0] dout_2; //error reg [7:0] ram [255:0]; @(posedge clk) begin if(ena == 1 && wea == 1) begin line 35 ram(addr_a) <= dout1; //error end end @(posedge clk) begin if(enb == 1 && web == 0) begin line : 44 dout_2 <= ram(addr_b); //error end end endmodule errors: syntax error near "<=". line 35 line 25: port addr_a not defined verilog file c:/documents , settings/verilog_examples/ram_1_verilog.v ignored due errors line 25: port declaration not allowed in ram_1_verilog formal port declaration list line 26: port addr_b not defined line 26: port addr_b not defined line 26: port declaration not allowed in ram_1_verilog formal port declaration list line 27: port dout1 not defined lin

ssl - Is expired but obsolete certificate in a keystore an issue? -

i have keystore has multiple certificates. 1 of certificate expiring soon, apps not using certificate longer. issue if continue using keystore such? will issue if continue using keystore such? not if applications aren't using it.

asp.net - "Length cannot be less than zero. Parameter name: length" when calling ASPX WebMethod in site using Sitecore -

i'm receiving "length cannot less zero. parameter name: length" errors when calling webmethod on plain asp.net webforms (aspx) page. error gives no clear idea (that can see) problem is, , both , post calls other webmethods similar signatures on page work. i'm guess it's in sitecore causing problem. the full error in response is: [argumentoutofrangeexception: length cannot less zero. parameter name: length] system.string.internalsubstringwithchecks(int32 startindex, int32 length, boolean falwayscopy) +10929307 sitecore.web.requesturl.get_itempath() +138 sitecore.pipelines.httprequest.siteresolver.getitempath(httprequestargs args, sitecontext context) +32 sitecore.pipelines.httprequest.siteresolver.updatepaths(httprequestargs args, sitecontext site) +69 sitecore.pipelines.httprequest.siteresolver.process(httprequestargs args) +49 sitecore.support.pipelines.httprequest.siteresolver.process(httprequestargs args) +261 (object , object[]

xamarin - Getting wrong position in custom ListView while scrolling -

i getting wrong position in custom listview while scrolling. i have tried viewholder pattern , arrayadapter both giving same problem. if reproduce code using java getting proper position while scrolling. so xamarin architecture bug ? below sample code: activity class namespace arrayadapterdemoapp { [activity(label = "arrayadapterdemoapp", mainlauncher = true, icon ="@drawable/icon")] public class mainactivity : activity { private static list<databean> _itemslist = new list<databean>(); private static customadapter _adapter; private listview _listview; protected override void oncreate(bundle bundle) { base.oncreate(bundle); // set our view "main" layout resource setcontentview(resource.layout.main); // our button layout resource, // , attach event _listview = findviewbyid<listview>(resource

Why can I not move lines in my Livecode DataGrid anymore? -

i have stack has been running quite well. changed have launcher stack calls main application stack password protected. running on livecode 6.7 , use datagrid helper well. of sudden, datagrid not act way did before - when select line, can no longer move or down within datagrid before.

c# - Can't access a Console hosted WCF service from a remote client on LAN -

for days now, i'm trying access wcf service computer on lan , can't access it. locally works fine though. majority of similar questions find using iis host service. i tried shut down firewall couldn't effect. here config files, please ask if need more : client's app.config : <?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedruntime version="v4.0" sku=".netframework,version=v4.5"/> </startup> <system.servicemodel> <client> <endpoint name="default" address="http://myhostip:3100/" binding="basichttpbinding" contract="serviceinterface.iservice"/> </client> </system.servicemodel> </configuration> here host app.config : <?xml version="1.0" encoding="utf-

r - Attribute information gain -

i r user , interested in finding out significant/important attributes/predictors classifier naive bayes multinomial package rweka . i aware of function infogainattributeeval . function uses filter approach attribute selection. classifier independent. i classifier dependent evaluation. tried wrappersubseteval . here did: library("rweka") dt <- data.frame( sex = as.character(c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1)), att1 = as.character(c(4, 4, 3, 4, 2, 3, 2, 3, 4, 2)), att2 = as.character(c(4, 4, 4, 5, 3, 7, 6, 7, 8, 9))) wse <- make_weka_filter("weka/attributeselection/wrappersubseteval") wse(sex ~ att1 + att2, data = dt, control = weka_control( b = list("weka.classifiers.bayes.naivebayes"))) i error: error in .jcall(filter, "z", "setinputformat", instances) : method setinputformat signature (lweka/core/instances;)z not found i have no idea error. weka problem? or r problem? or syntax erro

Python Property method for protecting private variables -

i'm trying learn python's oops concepts , i'm trying learn handling private data in python. got know can achived using "property" method , i'm executing below code thowing me error while i'm trying access attribute. class hello(object): def __init__(self, name): self.__name = name def __setname(self, name): self.__name = name def __getname(self): return self.__name name = property(__setname, __getname) h = hello("saumya") print h.name typeerror: __setname() takes 2 arguments (1 given) can anynody me , going wrong ? thanks, saumya the property function takes getter first, setter: name = property(__getname, __setname)

jquery - I have two Partial view and I want to hide them depending on dropdownList value change -

i have 2 customer type , use service known type in wcf customer type main customer , sub customer. have dropdown list select customer type when select main customer need sub customer partial view hidden , vice versa @model soqiarazorproject.customerservice.customerdata <script src="~/scripts/jquery-1.8.2.min.js"></script> <script src="~/scripts/jquery.validate.min.js"></script> <script src="~/scripts/jquery.validate.unobtrusive.min.js"></script> @{ viewbag.title = "customer data"; } <h2>customerdata</h2> @using (html.beginform()) { @html.antiforgerytoken() @html.validationsummary(true) <fieldset> <legend>customer data</legend> <div class="editor-label"> @html.labelfor(model => model.customerid) </div> <div class="editor-field"> @html.editorfor(model =>

Convert Array in PHP -

i have array database this { 0 : "test1", 1 : "test2", 2 : "test3" } how can convert array in php? this array[0] = "test1" array[1] = "test2" array[2] = "test3" ------------------------------------------ update ------------------------------------ it doesn't work json_decode. allredy test (i work xajax): $value = $obj->getvalue($id); //get array database $json = $value["datas"]; //save datas in $json print_r($json); //print out data in console print_r("\n"); var_dump(json_decode($json,true)); //print out decoded value in console then shows in console message: {0:"rechenzentren.png",1:"software.png"} <pre class='xdebug-var-dump' dir='ltr'><font color='#3465a4'>null</font></pre> <?xml version="1.0" encoding="utf-8" ?><xjx></xjx> $text = '{ 0 : "test1", 1 :

objective c - ShinobiCharts x axis labels folding when zoom out -

Image
im using shinobicharts line type kind ,my x values date strings , y values - longs. the chars points displayed correctly x values lables shown along whole chart points, , shown on top of each other this chart initialisation i'm using: mainchart = [[shinobichart alloc] initwithframe:frame withprimaryxaxistype:schartaxistypecategory withprimaryyaxistype:schartaxistypenumber]; and how create datapoint: schartdatapoint* datapoint = [schartdatapoint new]; datapoint.xvalue =key; datapoint.yvalue = value; any ideas missing? you need make x-axis schartdatetimeaxis, not schartcategoryaxis. xvalue needs nsdate, not nsstring. use nsdateformatter datefromstring: nsdateformatter *dateformatter = [nsdateformatter new]; dateformatter.dateformat = @"dd/mm/yy"; datapoint.xvalue = [dateformatter datefromstring:key]; ...

security - Plain-text password and "remember me", node.js and js client -

i'm trying understand little bit more security in node.js (with passport.js) , client (pure javascript) web application. i'm new web programming. i have implemented localstrategy , it's ok. gain access api have log in normal account, or log in admin in others. i'm testing browser authentication (still don't have "remember me" feature each time have retype password) , i'm testing curl: curl --cookie-jar jarfile --data "username=admin&password=pass" http://localhost:5000/login curl --cookie jarfile "http://localhost:5000/api/admin" now, following "expect worse" paradigm, i'd protected little bit man-in-the-middle attack don't want send plain-text password: have crypt password in browser (sha256), send it, , store/compare hashed password. what don't understand salt thing. more used pattern? generate in server , send login page? how test curl ? has different one? user has insert in login form?

PHP populate dropdown from mysql and get ID -

i have tried search stackoverlow (and google) cant find looking for. basically need list of id , text mysql table. table: id: 1 - text: title1 id: 2 - text: title2 etc. but want populate dropdown text, , when select item in dropdown, gives me id of text (string or int). so if select title2, should give me 2 <? include 'db.php'; $query="select topic_id,topic help_topic isactive=1 order topic"; /* can add order clause sql statement if names displayed in alphabetical order */ $result = mysql_query ($query); echo "<select name=category value='' id=category></option>"; // printing list box select command while($nt=mysql_fetch_array($result)){//array or records stored in $nt echo "<option value=$nt[topic_id]>$nt[topic]</option>"; /* option values added looping through array */ } echo "</select>";// closing of list box ?> use loop generate values <select> <?php for

javascript - input type image click event in jquery -

i trying navigate page using jquery markup : <input type="image" name="imagebutton1" id="btncancel" src="../images/btn_cancel.gif" /> js $('input[type="image"][id^="btncancel"]').live('click', function () { window.location.replace('default.aspx'); }); page refreshes, not navigate desired page. when change type=button works. how achieve same keeping type image ? $("#btncancel").on('click', function () { window.location.href = 'default.aspx'; });

parse.com - Querying inside Parse.Cloud.beforeSave -

here trying parse.cloud.beforesave("users", function(request, response) { parse.cloud.usemasterkey(); var user = request.object; var query = new parse.query(parse.installation); query.equalto("installationid", user.get("installationid")); query.find({ success: function(results) { if(results !== undefined ) { console.log("beforesave users:" + results + " user exists :" +user.get("installationid")); response.error(); } else{ console.log("beforesave users:" + results + " creating user :" +user.get("installationid")); response.success(); } }, error: function(error) { // on error, log , return empty array console.log("beforesave users error :" + error.message); } }); }); it works fine in result i2014-06-30t01:51:02.578z] v99: before_save triggered users input: {"original":null,&qu

android - Unable to view chart -

i have created application want view chart.but when clicking on specified button,the app stops.. code follows..: bloodsugarchart2.java package com.example.app; import org.achartengine.chartfactory; import org.achartengine.chart.barchart.type; import org.achartengine.model.xymultipleseriesdataset; import org.achartengine.model.xyseries; import org.achartengine.renderer.xymultipleseriesrenderer; import org.achartengine.renderer.xyseriesrenderer; import android.app.activity; import android.content.intent; import android.graphics.color; import android.os.bundle; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; public class bloodsugarchart2 extends activity { private string[] mmonth = new string[] { "jan-10-14", "jan-11-14" , "jan-12-14", "jan-13-14", "jan-14-14", "jan-15-14", "jan-16-14", "jan-17-14&quo

Find defects in bottle shape using image processing using openCV -

Image
i using image processing, opencv , c++ check misshapes of bottles. new opencv. great if can guide me right direction how achieve this. how can detect defects of shape of bottle using opencv , c++. giving bottle images inputs system.when misshaped bottle input system should detect it. defected bottle image : good bottle image : basic approach: can extract edges register 2 images. in opencv couple of filters this. perfect approach: can use statistical shape modeling algorithm, not sure if there in opencv.

java - WICKET - DataView refresh with ajaxButton -

i'm trying refresh dataview onsubmit function in ajaxbutton. create form 2 dropdownchoice , ajaxbutton. when click on ajaxbutton in onsubmit function call dao function , replace listdataprovider, null before, new list dao. final private webmarkupcontainer wmc = new webmarkupcontainer("wmc"); private listdataprovider<comparephoto> datap = new listdataprovider<comparephoto>(); dataview = (dataview<comparephoto>)new dataview<comparephoto>("vcomponents", datap){ private static final long serialversionuid = 1l; @override protected void populateitem(final item<comparephoto> item) { comparephoto c = item.getmodelobject(); system.out.println("idcarto : "+c.getidcarto()); repeatingview repeatingview = new repeatingview("datarow"); repeatingview.add(new label(repeatingview.newchildid(), c.getidcarto())); [.

c# - Using a POCO in MongoDB and Entity framework with spatial indexes -

there couple classes in external library have coordinate property needs stores in mongodb , in sql server, ideally spatial indexes, without having modify class. mongodb has no problem creating geospatial spherical index on coordinate property following code: var collection = _database.getcollection<someclass>("somecollection") collection.createindex(indexkeys<someclass>.geospatialspherical(x => x.coordinate)); according documentation create geojson point under covers. can query object such: var point = geojson.point(geojson.geographic(coordinate.longitude, coordinate.latitude)); var geoclause = query<someclass>.near(x => x.coordinate, point, distance); return collection.asqueryable().where(x => geoclause.inject()) with sql server , ef, however, dbgeography property needed spacial index. what nice if there's extension point mappings object sql data type in ef, google search returned nothing of like. such thing exist? i thought g

cordova - Phonegap device on/offline -

i'm trying send app error page if there no internet connection. i've installed relevant plugins , added code below. i can detect type of connection , if device offline alert message. i'm struggling send app error page if offline , home page when device online. // device apis available // function ondeviceready() { document.addeventlistener("offline", app.onoffline, false); }, // handle offline event // onoffline: function() { alert("off line"); }, checkconnection: function() { var networkstate = navigator.connection.type; var states = {}; states[connection.unknown] = 'unknown connection'; states[connection.ethernet] = 'ethernet connection'; states[connection.wifi] = 'wifi connection'; states[connection.cell_2g] = 'cell 2g connection'; states[connection.cell_3g] = 'cell 3g connection'; states[connection.cell_4g] = 'cell 4g connection'; stat

.net - Can an ASP.NET MVC PartialView have a _Layout -

can asp.net mvc partialview directly use layout ? msdn i have looked @ msdn partialviewresult , compared viewresult : viewresult has property mastername partialviewresult not. but.. can still define layout property in partial views razor. background i remediating large code base huge amount of partial views used fill iframes. ideally converted normal views (ideally not use iframes) wondering adding layout these partials take out <head> element @ least have more control on script versioning (everything replicated in each partial view). i'm looking light-touch solution since of code expected thrown away. yes, in partial view can set layout property turns partial view normal view layout . @{ layout = "~/views/shared/_layout.cshtml"; }

Add page number in Word using VBA -

i looking hours 1 of simplest things (but ms things never simple...): how can programmatically add in word footer 'page #', using vba ? there zillions of different ways on internet none working. couple of examples code fails @ fields.add: sub pagenumber() activedocument.sections(activedocument.sections.count) _ .headers(wdheaderfooterprimary).range.select selection .paragraphs(1).alignment = wdalignparagraphcenter .typetext text:="page " .fields.add range:=selection.range, type:=wdfieldempty, text:= _ "page ", preserveformatting:=true .typetext text:=" of " .fields.add range:=selection.range, type:=wdfieldempty, text:= _ "numpages ", preserveformatting:=true end end sub this code doesn't allow me add word 'page' before: with activedocument.sections(1) .footers(wdheaderfooterprimary).pagenumbers.add _ pagenumberalignment:=wdalignp