Posts

Showing posts from March, 2015

How would you vectorize this nested loop in matlab/octave? -

i stuck @ vectorizing tricky loop in matlab/octave: [nr, nc] = size(r); p = rand(nr, k); q = rand(k, nc); = 1:nr j = 1:nc if r(i,j) > 0 eij = r(i,j) - p(i,:)*q(:,j); k = 1:k p(i,k) = p(i,k) + alpha * (2 * eij * q(k,j) - beta * p(i,k)); q(k,j) = q(k,j) + alpha * (2 * eij * p(i,k) - beta * q(k,j)); end end end end the code tries factorize r p , q, , approaching nearest p , q update rule. example, let r = [3 4 0 1 1; 0 1 0 4 4; 5 4 3 1 0; 0 0 5 4 3; 5 3 0 2 1], k=2, alpha=0.01 , beta=0.015. in real case, use huge sparse matrix r (that's why need vectorization), , k remain small (less 10). goal of whole script producing prediction value every 0 elements in r, based on non 0 elements. got code here , written in python. this looks 1 of cases not code can vectorized. still, can make bit better now. [nr, nc] = size(r); p = rand(nr, k); q = rand(k, nc); = 1:nr j = 1:nc if r(i,j) > 0 ...

Unifying Task<T> and F# MailboxProcessor exception handling -

when using task<t>, exception during execution of task thrown during task.wait(); when using f#'s mailboxprocessor, exception gets swallowed , needs explicitly dealt per this question . this difference makes difficult expose f# agents c# code via task. example, agent: type internal incrementmessage = increment of int * asyncreplychannel<int> type incrementagent() = let counter = agent.start(fun agent -> let rec loop() = async { let! increment(msg, replychannel) = agent.receive() match msg | int.maxvalue -> return! failwith "boom!" | _ -> replychannel.reply (i + 1) return! loop() } loop()) member x.postandasyncreply = async.startastask (counter.postandasyncreply (fun channel -> increment(i, channel))) can called c#, exception not returned c#: [test] public vo...

call third party web service from wcf service -

i have call third party web service wcf service library. when call third party web service test application, there no problem, when call wcf service, there error: an error occurred while receiving http response xxx.svc/ws. be... i've added third party web service add service reference . bindings web service generated automatically as: <wshttpbinding> <binding name="wshttpbinding_xxxservice" closetimeout="00:01:00" opentimeout="00:01:00" receivetimeout="00:10:00" sendtimeout="00:01:00" bypassproxyonlocal="false" transactionflow="false" hostnamecomparisonmode="strongwildcard" maxbufferpoolsize="524288" maxreceivedmessagesize="65536" messageencoding="text" textencoding="utf-8" usedefaultwebproxy="true" allowcookies="false"> <readerquot...

ios - Modal view at right half of ipad's screen? -

i need modify view's modal presentation parameters: 1 - modal view fills ipad's right half of screen. 2 - animation runs left half of screen. i have search in iosframeworks.com, cocoacontrols.com, books big nerd rach, ios recipes, ios pushing limits, stackoverflow , google. posibility that? assistance for testing, after 2 days of searching answers, create following code, i'm executing following code since root view controller cmmainview, viewcontroller cmvistamodal empty, doesn't have overrided method nor xib nor variable, device family ipad -(ibaction)accion:(id)sender { cmvistamodal *modal = [[cmvistamodal alloc] init]; [modal setmodalpresentationstyle:uimodalpresentationformsheet]; [self presentviewcontroller:modal animated:no completion:nil]; [modal.view.superview setautoresizingmask:uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleheight]; [modal.view.superview setframe:cgrectmake(800, 120, 200, 500)]; [uiview animatewithduration:1 anima...

ruby on rails - Carrierwave upload to ftp -

i've been searching while gem allow me set storage type :ftp. how solve this? this might little late but, try gem out: https://github.com/luan/carrierwave-ftp

python - Regular expression unicode replace not working -

i have following example in python, , it's not working: >>> replace = re.compile(ur'најавени', flags=re.ignorecase) >>> doctext = replace.sub("најавени1",doctext) >>> print doctext трендафилов во мвр се Најавени нови смени поврзани со безбедноста и борбата против организираниот криминал >>> doctext = replace.sub(u"најавени1",doctext) >>> print doctext трендафилов во мвр се Најавени нови смени поврзани со безбедноста и борбата против организираниот криминал >>> doctext = replace.sub(u"најавени1",doctext,re.ignorecase) >>> print doctext трендафилов во мвр се Најавени нови смени поврзани со безбедноста и борбата против организираниот криминал any hints? want make replace of string in text, it's working in english not in native language. second attempt: >>> doctext = "трендафилов во мвр се Најавени нови смени поврзани со безбедноста и борбата проти...

c# - How to make a tooltip on a image? -

Image
i'm trying find make tooltip on image. for example: i don't know how can make one. thanks i think system.web.ui.webcontrols.image have tooltip property msdn entry asp:image control ^ <asp:image alternatetext="string" cssclass="string" id="string" runat="server" tooltip="string"/> otherwise, alt property of html image control act tooltip

c++ - How to properly configure libraries for an SGE job? -

i have access cluster run heavy stuff , computation (i user, not root) i have program called rnnlib compiled , running. uses external libraries installed in folder (/udd/$user/local). now when try submit job sge here get: /udd/$user/test_rnn_lib/ag_rnnlib/bin/rnnlib: error while loading shared libraries: libhdf5_hl.so.7: cannot open shared object file: no such file or directory /udd/$user/test_rnn_lib/ag_rnnlib/bin/rnnlib: error while loading shared libraries: libhdf5.so.7: cannot open shared object file: no such file or directory i have copied libs rnnlib uses (listed ldd) in floder (/udd/$user/local/libs_for_sge/) then submited job, here get: /udd/$user/test_rnn_lib/ag_rnnlib/bin/rnnlib: relocation error: /udd/$user/test_rnn_lib/local/libs_for_sge/libc.so.6: symbol _dl_starting_up, version glibc_private not defined in file ld-linux-x86-64.so.2 link time reference i tried load libc.so.6 on sge got this: /udd/$user/test_rnn_lib/ag_rnnlib/bin/rnnlib:...

android view creation steps detailed explanation -

this general question, has been nightmare me trying solve out view-related problems in android. not logic, takes lots of time, , follow wrong approach know wrong: try else , if see right thing in screen ok. know not right approach. want clear out mind learning internal operations while creating views in xml. what need reference or tutorial explains happens when create view, layout, view tree etc. want know parser operates during creation. in ios platform have developed simple , intuitive storyboard designer , feel , developer doesn't have spend time solving ui issues. want draw easy in way. @ least there should can drive me think easy draw ui. suggestions? thanks first, never find quite apple's interface builder android. reason is, apple lot of hidden "magic" behind scenes never see, , can never about. both blessing , curse work you. google/android not this. an android xml layout 1:1 equivalent building layout using java code. properties define view...

ms access 2007 - Using Attachment field with Classic ASP -

i trying use attachment datatype in microsoft access , classical asp access database. trying insert attachement classical asp form. got error "cannot insert multiple values". tried lot online cannot find best fit solution this. in advance. afaik, support new accdb attachment field type has not been included in ado object model. need find different method interact access database. don't know method work , appropriate classic asp. my inclination revise database without attachment fields. may seem painful suggestion you, less painful trying use attachment fields classic asp.

canvas - FabricJS - Setting object position with pivot being top-left corner -

i started using quite awesome fabricjs framework, , noticed object positioning works bit different css conventions. css places positioning pivot on top-left corner, fabricjs has placed @ center of object: css @------------ | | | | | | | | | | ------------- fabricjs ------------- | | | | | @ | | | | | ------------- is there way control setting? thanks. edit: this exiting item on roadmap project. it'll happen in future, not supported. you can specify "origin" of positioning of object when create it. originx defaults "center", can change "left" or "right" originy defaults "center" can change "bottom" or "top" it's specified in docs . , here test .

c# - Scanner connected notification -

i'm developing scanning application , i'd enable scan button when my/any scanner available. i tried achieve gdpicture without success (btw. it's poor library, don't use it). tried kind of similar event using atalasoft's twain , lower-level twain library (which found post ). none worked. i have idea detect new devices connected computer , rescan twain devices maybe of know better solution. ideas? you may need write wrapper scanner. if above mentioned libraries have no api tell scanner's status, can try connect scanner, if connected means scanner up. think provide connection api scanner.

javamail - How to upload files to google drive using java-Google Docs Api? -

already used older version of api upload files google docs api version revised, couldn't upload. previously used these lines authorization: docsservice service = new docsservice("mydocumentslistintegration-v1"); service.setusercredentials(username, password); but giving error: exception in thread "main" java.lang.noclassdeffounderror: javax/mail/messagingexception @ sample.main(sample.java:15) caused by: java.lang.classnotfoundexception: javax.mail.messagingexception @ java.net.urlclassloader$1.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ sun.misc.launcher$appclassloader.loadclass(unknown source) @ java.lang.classloader.loadclass(unknown source) ... 1 more can me? it seems missing 1 of external dependencies, mail.jar, part of sun's javamail api. check page inst...

jquery - Resizing Elements to fit their container -

i have container used show breadcrumb path through series of documents selected. each breadcrumb element single div, floated left stack nicely behind 1 another. width set text content, title of document. lengths vary greatly. what should happen: when breadcrumb list of elements becomes long displayed in container should resize, ensuring of them remain visible within container. the problem: seems work, point. once list of breadcrumbs become long container divide container width number of breadcrumb elements exist, , set elements widths accordingly. however, not work consistently, showing last document in list, refusing show direct parent if selected. ideally breadcrumb elements should keep shrinking make sure displayed, in same way window icons sized display in windows taskbar. iv made little fiddle highlight going on, , here can see elements not resizing correctly make sure displayed. obvious 8 or more elements added. http://jsfiddle.net/maxvk/drw9j/30/ can tell me ...

opengl - Where does glCopyTexImage2D save its pixels to? -

name glcopyteximage2d — copy pixels 2d texture image c specification void glcopyteximage2d(glenum target, glint level, glenum internalformat, glint x, glint y, glsizei width, glsizei height, glint border); apparently, pixels must stored somewhere, where? function returns void , not use pointer parameter. so, glcopyteximage2d save pixels to? into texture specify target (e.g. gl_texture_2d , mean bound 2d texture). after using can use glgetteximage fetch pixels texture own buffer.

javascript - map.setcenter & map.setzoom not working properly -

i have left side menu bar when clicks on link, jumps marker location on map. works fine. but, i'd update click link in left-side bar, map centers on marker , zooms level. isn't working proplerly. the error i'm receiving in firebug is: missing ) after argument list map.setcenter(latlng:latlng); code: <div id="leftarea" style="width: 220px; float: left; border-bottom: 1px solid #dedede; padding: 5px 0 5px 0;"> <div style="color: #a41d21;font-size: 13px; font-weight: bold;"> <script language="javascript" type="text/javascript"> document.write('<a href="javascript:myclick(' + (i) + ')">' + '[[title]]' + '<\/a><br>'); </script> </div> <div> [[address]]<br /> [[city]], [[state]] [[zip]] </div> </div> myclick = function(i) { google.maps.event...

python - Make a window top priority -

i have root window panel on it. there function, in create toplevel (another window) asking input user. i'm trying find way make compulsory user either enter input , click ok or cancel dismiss window before being able access root window. it's when error message pops up, can't ignore , other things in root window. have suggestion me? have @ dialog windows . can use widget.wait_window(window) achieve this.

Where can I store this property for use by Maven and Java? -

i'm using maven 3.0.3 , java 6. want put wsdl url property somewhere both maven build process can acccess , runtime java code (i'm building maven jar project) can access. how structure/configure this? in runtime java code, have like string wsdlurl = getproperty("wsdl.url"); and in maven, want access wsdl url in plugin ... <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>jaxws-maven-plugin</artifactid> <executions> <execution> <goals> <goal>wsimport</goal> </goals> <configuration> <wsdlurls> ...

javascript - setTimeout() triggering without delay -

i have following code ext.onready(function () { settimeout(everything(), 30000); }); i trying wait ext.net finish compiling page before applying javascript elemtents. not problem in browsers $(document).load provides enough of delay. of course horrid internet explorer triggers .load prematurely means have put in hard coded delay in. above code however, nothing delay execution of everything(). any ideas? remove () everything settimeout(everything, 30000); by including () , telling browser execute everything , send it's return value callback function settimeout .

Attempted to read or write protected memory error while c++ dll is being accessed by c# -

below c++ dll class class { public: int __thiscall check(char *x,char *y,char *z); private: b *temp; }; class b { friend class a; public: b(); b(string x,string y,string z); ~b(); private: string x; string y; string z; }; c++ dll method definition below __declspec(dllexport) int __thiscall a::check(char *x,char *y,char *z) { temp=new b(x,y,z); //getting error @ point when assigning memory temp return 1; } c# dll import this [dllimport("mydll.dll", callingconvention = callingconvention.thiscall, exactspelling = true, entrypoint = "check")] public static extern int check(intptr val,string x,string y,string z); c++ dll build works fine when c# calls c++ dll method looks , when enters function , in first line of method try's create memory temp pointer has been declared in class pointer of class b private. error giving attempted read or write protected memory. indication other memory corrupt. the __de...

Using Visual Studio as a Compiler for QT Creator -

i've been trying visual studio compiler use qt creator, can link boost libraries reason build in msvc. when @ build , run tab auto found 5 different visual studio compilers, yet none of them have paths debugger. i tried cloning 1 , realized couldn't find path supposed put in debugger. qt creator 2.4.1 based on qt 4.7.4 (32 bit) built on jan 26 2012 @ 09:48:31 from revision 8cd370e163 visual studio 2010 my computer windows 7 64bit you can install debugging tools windows (x64) microsoft windows sdk windows 7 , .net framework 4 . qt should find automagically.

c# - Adobe PDF Form submitted but Request.Form collection is empty -

Image
i created pdf form containing textbox , submit button. users may open pdf file in adobe acrobat reader or in browser. after filling in textbox , click on submit button, asp.net generic handler process submitted data. but problem i'm having there no submitted form data. the pdf form submit button setup follow: and server side code: public class pdfformhandler : ihttphandler { public void processrequest(httpcontext context) { if (context.request.requesttype == "post") { var name = context.request.form["txtname"]; // <-- name null. why? } } public bool isreusable { { return false; } } } the context.request.form collection empty. txtname form element go? i solved myself. problem need change export format html .

XNA Drawing a series of squares -

i trying draw series of squares in xna. looking @ these articles trianglestrips , dynamicvertexbuffers. but, not sure begin. current step able draw 1 square using vertexpositioncolor, trianglelist , indices. want draw series of squares varying colors. end goal keep in mind number of such squares able draw, eventually. if assume 5px width, on 1920x1080 screen, can calculate number of squares (1920 * 1080) / 25 = 82944. any pointers on how accomplish great! generally, can draw more squares in same way draw first one. however, there significant loss in performance. instead, can add triangles 1 vertex buffer / index buffer. able draw 2 triangles triangle list. should able adjust routine draw more 2 triangles. add according vertices , indices buffers , modify draw call. if need vertices @ same position different colors, need add 2 vertices buffer. this way, performance loss little, because draw 1 draw call. although amount of triangles should no problem graphic ca...

php - Parsing a string which I am not able to identify as Object or Array or Json -

i receiving array in response of request. , when print_r on it, getting array( [receiver] => {:email=>"email@domain.com"}) . i not able understand how can access value of ":email". please help. edit: here var_dump of response. array ( 'receiver' => '{:email=>"email@domain.com"}' ) thanks. use regular expression email. $arr = array('recebodor' => '{:email=>"someone@example.com"}'); $email = preg_replace('/{:email=>"([^"]+)"}/', '$1', $arr['recebodor']); echo $email; // someone@example.com explanation: {:email=> match "{:email=>" in string "([^"]+)" character within double quotes } match last "}" $1 replace text text found inside parentheses

c# - Validate textbox depending on external parameter -

i have window 8 rows representing 8 output channels, in each channel can have timesteps. have textbox in front of each channel set upper , lower limit value of timesteps. want write validator checks user input if it's inside of limits. i'm not sure how this, because when validator invoked has no knowledge timestep in channel it's called , see no possibility pass information validator. edit: public class numbervalidator : validationrule { public override validationresult validate (object value, system.globalization.cultureinfo cultureinfo) { double number = 0; try { number = convert.todouble(value.tostring()); // check numeric value } catch (exception) { return new validationresult(false, "value must numeric"); } if (number == 0) // check non-zero value { return new validationresult(false, "value must non-zero"); ...

cannot download images in Corona -

i using corona sdk. parse json , in listener function try load images using links json, says network error. seems cannot run network methods in parallel? even default corona demo code doesn't work reason: local function networklistener2( event ) if ( event.iserror ) print ( "network error - download failed" ) else event.target.alpha = 0 transition.to( event.target, { alpha = 1.0 } ) end print ( "response: " .. event.response ) end myimage2 = display.loadremoteimage( "http://developer.anscamobile.com/demo/hello.png", "get", networklistener2, "hellocopy2.png", system.temporarydirectory, 60, 280 ) it fails run on android emulator.

c++ - Is it possible to avoid repeating the class name in the implementation file? -

is there way avoid graph:: repetition in implementation file, yet still split class header + implementation? such in: header file: #ifndef graph_h #define graph_h class graph { public: graph(int n); void printgraph(); void addedge(); void removeedge(); }; #endif implementation file: graph::graph(int n){} void graph::printgraph(){} void graph::addedge(){} void graph::removeedge(){} i'm guessing avoid lots of "unnecessary typing". sadly there's no way rid of scope (as many other answers have told you) class defined function prototypes in nice rows, copy/paste implementation file ctrl-c classname:: on clip board , run line ctrl-v.

Tumblr AVATAR API grabbing -

i'm doing website , want visitors leave comment instead of showing tipical gravatar, want display tumblr avatar putting url. see, i'm using wordpress, there's plugin it's twitter only. does know need change make work tumblr? the plug in called twitter avatar reloaded i tried change tumblr api id didn't work or know method? i'm kind of desperate, want grab tumblr avatar in website tumblrplug.com thanks i'd appreciate solution! here can see plugin http://wordpress.org/extend/plugins/twitter-avatar-reloaded/ have tried along call : http://api.tumblr.com/v2/blog/david.tumblr.com/avatar check documentation more information - http://www.tumblr.com/docs/en/api/v2#blog-avatar

asp.net mvc 3 - MVC3 Razor JQuery client side validation with an additional alert box -

i being asked create login form when user input doesn't pass validation pops alert box. i have wire using model based validation. ex: public class logonviewmodel { [required( errormessage = "user name required")] public string username { get; set; } [required( errormessage = "password required")] public string password { get; set; } } i have validation summary on page: html.validationsummary() i summary on page in case user has javascript off. if client side validation fires want catch validation event , put errors alert box being asked. my form ... @html.validationsummary() @using (html.beginform(null, null, formmethod.post, new { id = "loginform" })) { username: @html.textboxfor(m => m.username) <br/> password: @html.textboxfor(m => m.password) <br/> <input type="submit" value="login"/> } one of things tried ...

python - jQuery autocomplete doesn't want to send particular POST data -

i'm trying add item (fund). autocomplete succeeds in showing funds. should retrieve fund.id corresponding 'fund'. if set of eyes on this, appreciated... just clear: i'm not getting specific error. view redirects if there no 'fund' in post. i'm trying figure out why autocomplete isn't posting fund post value' (fund.id). -- thank advance template : <script type="text/javascript" src="{{ static_url }}js/autocomplete/add_fund_autocomplete.js"></script> ... <form method="post" action="/profile/edit/"> {% csrf_token %} <input type="hidden" name="fund" id="id_fund" /> <div class="inline-block"> <label for="id_omnibox">fund</label> <input id="id_omnibox" name="omnibox" placeholder="enter fund name or search existing..." type="text" /> ...

html - How do I I create a simple javascript page, allowing the user to enter text & display it? -

i took web programming courses while ago i'm relearning scratch. i want build page using html/javascript has box user enter question or phrase , submit button. when user presses submit button, question/phrase instantly shows in bubble below. each question/phrase must show in separate bubble , can enter multiple questions/phrases. i'm looking suggestions of ways accomplish task using javascript. i suggest using jquery, awesome javascript library makes things easier. http://jquery.com/ they have great tutorials @ http://docs.jquery.com/tutorials with ajax , forms @ http://docs.jquery.com/tutorials:safer_contact_forms_without_captchas#simple_contact_form:

Convert hex string to number in mySQL -

i have column has value '11b3' in it. want write sql statement (in mysql) ands (&) value 0x1880 , returns result. have been unable treat string column hex number. grateful assistance. this not work: select szversion, hex(szversion), concat("0x",szversion) this functions desired (but doesn't pull database: select 0x11bx & 0x1880 you can use unhex(str) change hex text , concatenate them.

ggplot2 - R ggplot geom_tile without fill color -

Image
i trying add geom_tile layer plot without filled color (just outline). there way transparent tile boundary visible? thanks i think after alpha parameter. minimal example: create plot dummy data set color (for "boundary") , no fill : p <- ggplot(pp(20)[sample(20*20, size=200), ], aes(x = x, y = y, color = z)) add geom_tile() alpha set zero : p <- geom_tile(alpha=0) add theme_bw() transparent tiles lame dark gray background :) p + theme_bw()

How can I declare a pointer with filled information in C++? -

extern "c" { typedef struct pair_s { char *first; char *second; } pair; typedef struct pairofpairs_s { pair *first; pair *second; } pairofpairs; } pair pairs[] = { {"foo", "bar"}, //this fine {"bar", "baz"} }; pairofpairs pops[] = { {{"foo", "bar"}, {"bar", "baz"}}, //how can create equivalent of neatly {&pairs[0], &pairs[1]} //this not considered neat (imagine trying read list of 30 of these) }; how can achieve above style declaration semantics? in c++11 write: pairofpairs pops[] = { { new pair{"a", "a"}, new pair{"b", "b"} }, { new pair{"c", "c"}, new pair{"d", "d"} }, // grouping braces optional }; do note implications of using free store: objects allocated there not destructed @ end of execution of program ...

winapi - PlaySound() In C++ Doesn't Work -

i've been trying figure out, , can't seem to. when include window.h @ top, there supposed playsound() function inside of it. i added window.h keep on getting "playsound not declared in scope" error. i tried going project's build options , adding "-lwinmm" linker settings, still doesn't work. i'm using code::blocks. anyone have solution? you need #include both windows.h , mmsystem.h , in order. noted in community section of the documentation .

android - start service from activity and wait until its ready -

i want start service activity. first tried localbinder. works, service bound activity. don't want stop service when activity gone. found no solution localbinder removed , tried this: use singleton instance in service call startservice methode in new thread , waits until instance available: final intent recordservice = new intent(recordactivity.this, recordservice.class); runnable r = new runnable() { @override public void run() { startservice(recordservice); } }; new thread(r).start(); log.i(mmlf.t, "service instance: "+serviceinstance); final progressdialog mprogressdialog = progressdialog.show( recordactivity.this, "waiting", "wait until record service loaded", true); while (serviceinstance == null) { serviceinstance = recordservice.get(); try { thread.sleep(1000); } catch (interruptedexception e) { log.e(mmlf...

Monitoring heroku instances' workload -

what's best way monitor heroku instances' workloads (besides top ), know when scale? i'd rather not use auto-scaling program. a combination of tailing heroku logs (possibly using 1 of logging addons papertrail or loggly) , new relic.

jQuery DatePicker calendar not returning correct month -

i soooo close here. i'm hoping guru can me last piece. i'm populating jquery datepicker calendar xml rss feed. upon clicking highlighted date there's event, i'm creating url query string can display event clicked day. working... until change month clicking previous or next month. script return correct day, returning current month. example, navigate may , click 5th, url events.htm?month=june&day=5. ideas on why not return selected month? here's code: var data = $.ajax({ url: "news.xml", type: "get", datatype: "xml", async:false, success: function(xml){ return xml; } } ).responsetext; $(document).ready(function() { var events = getselecteddates(); $("div.datepicker").datepicker({ beforeshowday: function(date) { var result = [true, '', null]; var matching = $.grep(events, function(event) { return event.published.getdate() === date.ge...

security - WCF options for secure internet connectivity -

the scenario follows: wcf service hosted on internet. needs highly secure, thinking of security on transport message level. ssl used on iis, use certificates on transport layer. the message needs encrypted , signed. @ message level using certificates best option? main concern identity of sender , encryption. service has cross platform compatible. possible kind of configuration talking about. thanks. wcf service hosted on internet. needs highly secure, thinking of security on transport message level. there no need combine message , transport level security. select 1 , should enough. at message level using certificates best option? certificate reliable option if building secure solution. cannot defend against man-in-the-middle attack without valid certificate or similar ssl handshake work you. also service has cross platform compatible. it if use wshttpbinding binding. nettcpbinding proprietary 1 , not work you. is possible kind of conf...

c++ - Why would I ever use push_back instead of emplace_back? -

c++11 vectors have new function emplace_back . unlike push_back , relies on compiler optimizations avoid copies, emplace_back uses perfect forwarding send arguments directly constructor create object in-place. seems me emplace_back push_back can do, of time better (but never worse). what reason have use push_back ? push_back allows use of uniform initialization, i'm fond of. instance: struct aggregate { int foo; int bar; }; std::vector<aggregate> v; v.push_back({ 42, 121 }); on other hand, v.emplace_back({ 42, 121 }); not work.

css - OL numbering in chrome not left-aligning, appearing on the right -

i'm experiencing strange behavior ol numbering in chrome, here's markup: <ol> <li> <div class="block left"> <span class="block">main title<span class="alert">!</span></span> <input type='text' name='title-1' /> </div> <div class="block left"> <span class="block">subtitle<span class="alert">!</span></span> <input type='text' name='title-2' /> </div> <div class="block left"> <span class="block">add image<span class="alert">!</span></span> <input type='file' name='image' size='30' /> </div> </li> <ol> the classes used are: .block { display:block; } .left { float:left; } .alert { color:red; } the p...

php - explode new line in javascript -

how convert php code below javascript? google , found st.replace(/,/g,"\n") how apply variable? have low knowledge javascript , trying learn it. $items = explode("\n", $model); the answer is: items = model.split("\n")

java - Theory : List declaration Object list = new ArrayList(); -

i have exam coming i'm studying for.. , thinking of elegant way answer following question, current answer (based on information answer on stackoverflow) the above initialization not possible, compile missing identifier in declaration, , other functions such add, remove not available. the question.. consider following code snippet. possible assign instance of arraylist variable declared object done in line 1? explain. object strings = new arraylist(); strings.tostring(); what other ways answer this? , please provide wikipedia/resources, can research further how compiler translate bytecode? thank you consider following code snippet. possible assign instance of arraylist variable declared object done in line 1? explain. object strings = new arraylist(); strings.tostring(); yes possible. object super type of arraylist (in fact, object super type of java reference types). legal declare variable of super type of actual type assig...

web applications - Options for making _web_ apps using smartphone and ipad cameras -

i considering if possible web app (not native app or phone gap app, javascript/html5 app running in smartphone/tablet browser): user takes picture user shares picture on server comment. as far know, web app has no access device's camera or camera roll, options ? my best idea have mail service, users can send photo mail, questions are: 1) right in asumptions? 2) better ideas mail service? 3) if decided go native way, possible make phonegap app access camera , photos? yes, can create web application has access device's camera roll. there catch, though. while photo uploading works android, not work on stock ios safari browser. users have download browser able upload images (i believe icab browser allows uploading). deal-breaker depending on users be. if you're building public, can't tell them use different browser. if you're building internal apps, away it. here's example of such app, seems you're trying accomplish: http://www.cr...

javascript - how to check whether user like my page or not using facebook JS SDK? -

i working in 1 facebook application going run outside facebook in 1 webpage having functionality of page, on bases of have redirect page on different pages, i tried lots of code check whether user liked page or not failed. so if 1 knows how check please me. thanks in advance. note : want using js sdk not php sdk. to access data form facebook need user_likes permission. <div id="fb-root"> </div> var page_id = 'your page / url id'; (function() { var e = document.createelement('script'); e.type = 'text/javascript'; e.src = document.location.protocol + '//connect.facebook.net/en_us/all.js'; e.async = true; document.getelementbyid('fb-root').appendchild(e); } ()); window.fbasyncinit = function() { fb.init({ appid: 'your app id', status: true, cookie: true, xfbml: true, oauth: true }); fb.login(function(response) { if (response.authrespons...

selenium - should i able to load entire html page using htmlUnitDriver -

i using chrome driver selenium test case. working fine. there performance issue in project, want migrate testcase chromedriver htmlunitdriver . when trying use htmlunitdriver in testcase, changing driver name htmlunitdriver , selenium testcase not working. after working around driver, thought htmlunitdriver not loading entire page. why telling because htmlunitdriver can find div id's in beginning of page. other div s not found driver. getting nosuchelementexception div id's. so please me resolve problem in project. aren't elements looking created javascript/ajax calls? you might need enable javascript support in htmlunitdriver first. but beware, work well, behave differently see in real browsers. otherwise, using implicit/explicit waits searches? js enabled, takes while before asynchronous requests handled.

Identifying Redirect/Forward Action in Struts2 Incerceptor -

i looking way identify struts 2 actions of type 'redirect/forward' in interceptor, can add common code particular type of action. is there way in struts2 find type of action is? thanks in advance. there nothing called redirectaction or forwardaction, need redirect result type. in interceptor have instance of actioninvocation passes intercept method, can result actioninvocation object , check per use case. different results listed here public string intercept(actioninvocation actioninvocation) { //after invoking action can result of actioninvocation. result result = actioninvocation.getresult(); //as per use case can check against different types. }

captcha - Perl: GD:SecurityImage, angle property not working -

Image
i trying create security image text using perl module gd:securityimage following object: my $image = gd::securityimage->new( width => 220, height => 60, lines => 5, scramble => 1, angle => 45, gd_font => 'giant', ); $image->create( normal => 'circle' ); $image->particle(30, 70); but text in resulted image doesn't have text angled @ 45 degrees rather random. if make scramble = 0 , have angle = 45, text doesn't rotate @ angle, text default in image seen in attach screen. please me out, doing wrong here?. note: image scramble = 0; please note must have math::trig rotate gd, otherwise no rotation. don't need imagemagick backend - try that. (and use ttf :))

Can't connect with admin user after CouchDB fresh install on Ubuntu 12.04 -

i have couchdb installing issue on ubuntu 12.04, not installing issue, configuring. after installed with sudo apt-get couchdb i edit /etc/couchdb/local.ini , add adminuser = mypass to [admin] section , try curl http://adminuser:mypass@127.0.0.1:5984 but get {"error":"unauthorized","reason":"name or password incorrect."} of course, restarted server after edited local.ini i tried says here too: http://wiki.apache.org/couchdb/installing_on_ubuntu : "fix problems adding admin hangs or setting admins in local.ini ..." still no luck :( after tested lastest version git error still present. have after rebooting ubuntu works, need work out of box without rebooting install script. it's safer modify .ini files using _config follow escaping , spacing rules (in case spaces around = problem) curl -x put localhost:5984/_config/admins/adminuser -d '"mypass"'"

web services - webservices on android eclipse -

i new android/eclipse(java),in fact forum too. has 1 met situation? get input user , display appropriate result consuming web service android/eclipse.is there examples available? thank much. i posting link of tutorial here basic android tutorial access web service in android basic ksoap android tutorial and creating webservice in java use tutorial how create java based web service write web service using java , using ksoap library response. format response according requirement. code reference: private static final string namespace = "http://tempuri.org/"; private static final string url ="http://localhost/web_service.asmx?";// replace webservice url private static final string method_name = "function_name"; private static final string soap_action = "soap action"; soapobject request = new soapobject(namespace, method_name); request.addproperty("parm_name",prm_value);// parameter method soapserializationenv...

php - jQuery input form validate -

if have html form on validate works <form method="post" action="" name="loginform" id="loginform"> <p><input type="text" name="user" id="user" "/></p> <div class="forminputmistake" id="erroremail"></div> <p><input type="password" name="passwd" id="passwd" /></p> <div class="forminputmistake"></div> <input type="submit" name="login" id="login" value="login" /> <div class="forminputmistake"></div><!--here want show error "wrong password or user"--> </form> php-file usr.php if(isset($_get['login']) && isset($_post['user']) && isset($_post['passwd']) && isset($_post['login'])) { if($_post['user...

mongodb $pull not working php -

i have object in db. array( [_id] => mongoid object ( [$id] => 4fcdb3b8749d786c03000002 ) [email] => foo@bar.com [folder] => array ( [root] => array ( [feeds] => array ( [0] => array ( [feedid] => mongoid object ( [$id] => 4fcdaa9e749d786c03000001 ) [title] => title.com ) ) [title] => root ) ) [status] => 1 [username] => foouser) i want pull item [0] [feeds]. use code not working: $userscollection->update(array("username" => "foouser"), array('$pull'=> array('folder'=>array('root'=>array(...

xml - How do I read a variable output from an html form and use it in the webpage? -

ok, i've tried work - can't seem see way... what trying have form ask index, when submit read xml file (bowlist.xml) , give me data matching index. here entire code: <!doctype html> <html> <body> <form action=""> bowl #: <input type="text" name="bowlidx" value="" /><br /> <input type="submit" value="submit" /> </form> <script type="text/javascript"> var index = <%=request.querystring(bowlidx)%> document.write('index ' + index) if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.open("get","bowlist.xml",false); xmlhttp.send(); xmldoc=xmlhttp.responsexml; document.write("<table border='1'>"); var x=xmldoc.getelementsbytagname(...

asp.net - Display only the Time in C# -

i'm new here, i'm stuck in converting array of strings values of "1024" , "2255" time value. i need convert strings times format: "10:24 am". how that? thanks in advance. something (off mind): var mystring = "2255"; var datetime = datetime.parseexact(mystring,"hhmm", system.globalization.cultureinfo.currentculture); var convertedstring = datetime.tostring("hh:mm tt"); convertedstring should have "10:25 pm"

email - Google Appengine daily budget not reflected in quota -

dear appengine people (i understand appengine support has moved stackoverflow - if mistaken sorry posting here), have serious problem hope can me resolve. yesterday enabled billing daily budget of $500 on application (friendbazaar.appspot.com), , billing status "enabled". however, still showing have maxed out usage of recipients emailed @ 100 of 100. the quota reset 2 hours ago, , don't understand why has not reflected updated quotas based on billing settings. this big problem, since sent out invitations members of other sites (over 100k people) sign new site - , since email authorization required complete registration process, totally hosed , have pissed off lot of customers making them register , never sending them email complete process. please let me know if can fixed, , normal delay appengine quotas reflect billing settings. per billing faq's why did mail quota not increase after enabled billing? google wait until first payment cleared be...

c# - PDFNet - how do I get all bookmarks -

i'm using pdfnet sdk c#. want list in own window bookmarks. however, find way first bookmark, not other bookmarks. this code: namespace david.pdftest { public partial class pdfview : pdfviewctrl { protected override void onmousedown(mouseeventargs e) { trace.writeline(getdoc().getfirstbookmark().gettitle()); } } } is there possibility bookmarks? it seems there bookmark.getnext() method use. so write this: namespace david.pdftest { public partial class pdfview : pdfviewctrl { protected override void onmousedown(mouseeventargs e) { var bm = getdoc().getfirstbookmark(); while ( bm!=null ) { trace.writeline(bm.gettitle()); bm = bm.getnext(); } } } }

ajax - Can Google track nested hashbang URLs? -

i've created onepager website google able track ajax loaded content of main site loading each content via !#my-url <-> _escaped_fragment_ "translation" in 1 of ajax loaded contents more hashbang urls included displaying/loading product data. google not seems read 2nd level ajax content. is there way tell google read such content?? thanks in advance :) tbh i'm not 100% sure asking here, perhaps update question give more details (more specific url "this vs. this" examples, what wanting track (a general page view? event? etc..) assuming looking track page view, can pop _gaq.push(['_trackpageview']); whenever want, , can keep calling (for instance, inject response ajax calls). allows option 2nd element array pass, specify want page name (by default if don't specify, current url): _gaq.push(['_trackpageview','whatever want here']);

javascript - Get key value of dictionary by index in jQuery -

i have javascript dictionary object has pre-set keys defaulted 0 . need loop through elements of dictionary index , use value of key set value. below code make things easier understand: var _map = { 'severity-normal': 0, 'severity-minimal': 0, 'severity-moderate': 0, 'severity-severe': 0, 'severity-highly-severe': 0 }; mapseverities: function () { (var = 0; < _map.length; i++) { //get key value, ex: severity-normal, index (which i) var key = //retrieved key value _map[key] = this.data(key); } } in other words, suppose we're dealing c#, want keyvaluepair @ index, access key , value properties. any suggestions? for object _map , should use for .. in . for (var key in _map) { _map[key] = this.data[key]; }

bmp - Drawing text on bitmap image -

i'm looking c/c++ library (cross-platform, preferably) draw text on bmp image. i've looked @ easybmp, has font extension. however, need display arial text - not available in easybmp. suggestions appreciated! use qpainter qt framework. it's cross-platform , dual licensed(lgpl , commercial)

sql server 2008 - I need help to bring following output in SQL Query -

this question has answer here: simulating group_concat mysql function in microsoft sql server 2005? 9 answers please sql query solve following issue. i have table input values - column header x , y x | y ------------------- 1 | a1 1 | a2 2 | a3 2 | a4 2 | a2 i need output this x | y ---------- 1 |a1,a2 2 |a3,a4,a2 please advice! select nto.x, stuff((select cast(',' varchar(max)) + nti.y mytable nti nti.x = nto.x xml path('')), 1, 1, '') y mytable nto group nto.x

amazon web services - AWS own email domain and some generic questions -

i'm getting started amazon web services , have few question i'm not sure about. every (company) webpage want use "office@companyname.com" email adress, how done? looked @ godaddy.com (for domain registration), offer me email adress want, 3 dollars per month. is possible aws? because @ aws have complex domain not userfriendly or serious. also want host dynamic webpage on amazon cloud, i'm not sure if i'm doing right. i've read many guides, , know have purchase elastic compute cloud, , simple storage service... , every guide working basic linux package, why not windows? more expensive? want host mysql server dynamic webpage, reached on normal domain. and 1 last question, if sign aws account asks me email account. found little bit unserious write there free-webmailer-adress... how done normal way? thanks in advance! best regards, john. you have lot of non-specific non-technical questions, , might better served asking them on 1 of amazon f...

knockout.js - Best method to use external templates with knockout -

i have built html page internal templates. see url jsfiddle: http://jsfiddle.net/hoven002/jqtdh/ what best method make templates external , how? regards, kenneth the best method, in opinion, use plugin: https://github.com/ifandelse/knockout.js-external-template-engine . it enables new template engine pull templates external files. has configuration options determine templates pulled from.

Email Id validation for real or not using jQuery -

is possible validate email in way whether existing emailid(that in use, not fake) using builtin functions in jquery. then website forms recognize if non-existing id's entered. when try send confirmation mail, & if it's not sent successfully, come know it's fake one? first off, email validation using built-in jquery function not going option you; it's built support wide range of functionality , considered niche. email validation can take many shapes; i'll try summarize them here, in order of accuracy / reliability: it matches regular expression (bad) or validated according rfc2822 (good) - http://tools.ietf.org/html/rfc2822#section-3.4.1 the domain part of email address has @ least 1 associated mx record; if not present, associated (ipv4) / aaaa (ipv6) record should used (less reliable though) - http://tools.ietf.org/html/rfc5321#section-2.3.5 the established connection listed mail exchange server responds positively rcpt to: command - http...

websocket - How to leave all rooms that the socket is connected to at one go in Node.js -

i have code socket made join multiple rooms. @ point in code, want leave rooms @ 1 go, without disconnecting socket. possible this? if yes, how can this? in advance.. that's possible. can leave rooms without disconnecting socket. socket disconnects when make call socket.disconnect(). to you'll have maintain list of rooms each client joins , leaves. leave rooms iterate through list , make call socket.leave(roomname);

Android java source explanation -

txtfar.settext(result.getproperty(0).tostring()); in general can tell me above line saying. left objects txtfar & result. any idea? thanks precious time! it getting 0th property of result , setting txtfar converting property string . are expecting else?

asp.net mvc - javascript code from DB -

i have field in database contain big javascript code. how can add code view ? $(document).ready(function() { // javascript code db in raphaelobject property "@model.raphaelobject"; }); thanks. try @html.raw(model.raphaelobject)

c# - the color of the first row in gridview is not changing -

ive got gridview in asp.net webpage , backcolor of row changed according data in specific cell, first row of grid not changing. why this? here code use change color: protected void gridview1_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow) { int stationstatus1 = int32.parse(gridview1.datakeys[e.row.rowindex].values[0].tostring()); foreach (gridviewrow row in gridview1.rows) { switch (stationstatus1) { case 0: case 3: e.row.backcolor = system.drawing.color.red; break; case 12: e.row.backcolor = system.drawing.color.blue; break; default: e.row.backcolor = system.drawing.color.white; break; ...

linux - Error adding a Patch with a diff file -

i have trouble adding patch using diff file. created diff file using 2 c sources in way: $diff gitrans.c.origin gifstrans > giftrans.diff when try create patch using diff file obtain error: $patch -p1 < giftrans.diff patch: **** garbage found in patch input. could me please? can't find solution. you should use unified diff format given patch syntax $diff -u gitrans.c.origin gifstrans > giftrans.diff $patch < giftrans.diff or default diff format following patch syntax $diff gitrans.c.origin gifstrans > giftrans.diff $patch gitrans.c.origin giftrans.diff

java - JTable throwing IndexOutOfBoundsException during paint -

hi i'm building application using jtable display data database , keep getting indexoutofboundexception tablemodel.getvalueat(row,col) during painting. debugged code , seems data isn't being saved defaulttablemodels data vector. this code... public class tableframe extends jframe{ public static void main(string[] args){ tableframe frame = new tableframe(); } private tablepanel tablepanel; public tableframe(){ super(); setsize(new dimension(500,500)); setdefaultcloseoperation(jframe.exit_on_close); tablepanel = new tablepanel(); add(tablepanel); updatelabels(); setvisible(true); } public void updatelabels() { settitle("main frame"); tablepanel.updatelabels(); } private static class tablepanel extends jpanel{ private defaulttablemodel tablemodel; ...

Facebook like button on pages that are accessible from multiple urls -

i have website accessible multiple domains, mydomain.com , mydomain.net , mydomain.org , etc. , i'm using rewrite create search-engine friendly urls, /news/12345-news-alias , thing important in url item id. if open mydomain.com/news/12345 same page if open mydomain.org/news/12345-news-alias . i've inserted facebook, twitter , google+ icons in page, , problem when open mydomain.com/news/12345 shows 260 likes , if open same page via address: mydomain.org/news/12345-news-alias shows 0 likes. what can make facebook understand these pages same?