Posts

Showing posts from January, 2013

OCaml: retain value of variable with control statements -

i'm new ocaml / functional programming, , i'm confused implementation of things relatively simple other languages know. use , help. chiefly: in program i'm working on, either increment or decrement variable based on parameter. here's representative of have: let tot = ref 0 in = 0 s if test_num > 0 tot := !tot + other_num else tot := !tot - other_num done;; this not way go it, because if else statement never taken, code acts if is, each , every time, presumably because it's closer bottom of program? know ocaml has pretty sophisticated pattern matching, within level of coed need access handful of lists i've created, and, far understand, can't access lists top-level function without passing them parameters. i know i'm going wrong way, have no idea how idiomatically. suggestions? thanks. edit here's more concise example: let ex_list = [1; -2; 3; -4] in let max_mem = ref 0 in let mem = ref 0 in let () =

javascript - Draw a table inside an infowindow of Google maps v3? -

when user click on marker infowindow appear , shows information. it's better show information in beautiful way using table. how can draw table inside infowindow? here loop-for creates markers on map , create infowindow(s) each one. want show تاریخ , ساعت , سرعت in table aligned. for(var counter = 0; counter < arraylatitude.length; counter++) { var marker = new google.maps.marker({ position:new google.maps.latlng(arraylatitude[counter], arraylongitude[counter]), info:arrayutcdate[counter]+" :تاریخ<br>"+arraysatellite_derived_time[counter]+" :ساعت<br>"+arrayspeed[counter].tofixed(2)+" :سرعت" }); marker.setmap(map); //event. when click on marker, infowindow show content of specified marker. google.maps.event.addlistener(marker, 'click', function () { infowindow.setcontent(this.info); infowi

microphone - windows phone 7 Recording Issue -

i working on recording functionality in windows phone 7 app. implemented recording functionality through reference link . it works fine @ there , in case also. actually scenario is, in application created first page works recording screen same above referred link. , when stop recording redirected second page , saved recording in isolated storage , @ second page bound recorded sounds. @ here played recorded sounds @ works fine. now, when m again go recording screen(first page) , starts recording. times records fine , times skip sounds during recording beep sounds , looks noise in recording , not getting recording sounds. my code like, public partial class nikhilrecord : phoneapplicationpage { //xna objects record , playback microphone mphone; //used storing captured buffers list<byte[]> memobuffercollection = new list<byte[]>(); //used displaying stored memos observablecollection<memoinfo> memofiles = new observablecollection<

date - Getting last day of the current month -

i can last day in php using cal_days_in_month(cal_gregorian, 03, 2014); function , assign view. want know possible last day in current month using smarty date_format function? in advance i'm not sure can solve using date_format function. wouldn't anyway, since put way application logic template. but... if want anyway, add template function want. php: $tpl = new smarty(); $tpl->registerplugin("function","lastdayofmonth", "smarty_function_lastdayofmonth"); $tpl->display('your_template.tpl'); function smarty_function_lastdayofmonth($params, smarty_internal_template $template) { return date("y-m-t", strtotime($params['date'])); } smarty: {assign var='datevar' value='2014-03-06'} {lastdayofmonth date=$datevar} output: 2014-03-31 keep in mind, easy example. there more 1 way use plugins within smarty.

python - html css example in django -

i wanted use third-party html/css example in django, doesn't work. <!doctype html> <html> <head> <title>example</title> <link rel="stylesheet" type="text/css" href="/static/css/style.css" /> </head> <body> example code </body> </html> i have used example, , commented other code. django recognizes css file, checked it. however, don't sticky footer , header. transform in plain text, main body. i put example in codeacademy engine , works there well. what hidden stones of django might missing? there no hidden stones in django. there no such option recognize css file django. django has nothing css files. i recommend u open network panel in browser developer tools console , check, css file downloaded browser or not. in case if u use django development server there manual how serve static files in development mode https://docs.djangoproject.com/en/1.2/howto/

javascript - Getting Parsley 2.x working with Bootstrap 3 correctly -

i using twitter bootstrap 3.1.1 parsley v2.0.0-rc3 . made work apart classhandler option. i have html this: <div class="form-group"> <label class="control-label" for="username">user name</label> <input class="form-control" id="username" name="username" required="" type="text" value=""> </div> and run parsley this: $("#register_form").parsley({ successclass: "has-success", errorclass: "has-error", classhandler: function(el) { return $(el).closest(".form-group"); }, errorswrapper: "<span class='help-block'></span>", errortemplate: "<span></span>" }); everything works fine, success / error classes applied wrong element. after page loaded, this: <div class="form-group"> <label class="control-la

list - can i not do - if nums[i] == nums[i+]: in python -

i new programming , python. (ref code below) - trying compare elements in list eliminate duplicates in adjacent numbers in list (so numbers in resulting list unique). dont hit nested "if" statement because code skips internal if. when try without external if, error: file "list2.py", line 22, in remove_adjacent if nums[i] == nums[i+1]: typeerror: list indices must integers, not tuple def remove_adjacent(nums): x = len(nums) print x in enumerate(nums): if < x-1: if nums[i] == nums[i+1]: del nums[i] return it should for in range(len(nums)) . enumerate returns key/value tuple - not integer, error message says.

javascript - How to get the position and width of a tspan element -

Image
i working d3js lib create nodes , links according data. @ place have specific requirement add multiple text in same line url "www.xyz.com/home/user" (here 3 strings "www.xyz.com","/home","/user"). not separate nodes can't find position d3. it's <text> element 3 <tspan> children. <text id="taxfilingresource_url" class="label url" dy="24" dx="30"> <tspan id="taxfilingresource.url.1">www.xyz.com</tspan> <tspan id="taxfilingresource.url.2">/home</tspan> <tspan id="taxfilingresource.url.3">/user</tspan> </text> and displaying below www.xyz.com/home/user i need position , width of each <tspan> element. code var el = document.getelementbyid(d.source); x = el.getstartpositionofchar('').x (or) x = el.getclientrects().left; that give relative position on text inside g element , i

c++ - How to make aliases of member function or variable of specific class(like an STL container) -

when using std::pair or std::map, need use "first" or "second" access data. 2 variable name not have clear meanings of store other co-workers did not write code. if can make aliases "first" or "second", enhance readability. for example, following code static const std::map<std::string, std::pair<std::string, pfconvert>> comm_map = { // keyword-> (caption, function) {std::string("1"), {std::string("big5 utf16le"), &fileconvert_big5toutf16le}}, {std::string("2"), {std::string("utf16le utf8"), &fileconvert_utf16letoutf8}}, {std::string("3"), {std::string("utf8 big5"), &fileconvert_utf8tobig5}} }; auto itertoexe = comm_map.find(strtranstype); itertoexe->second.second(); the itertoexe->second.second(); has bad readability. so try use inherit give aliases following template<typename pfcomm> class ccommcontent : p

android - Enter Key Does not Work on Key Listner -

i'm using onkeylistner address 'enter' key pressed via soft keyboard on edit text. [android.]i want when user press enter key soft keyboard should perform action-->take input edit box , pass function process. here's code: editbox.setonkeylistener(new view.onkeylistener() { @override public boolean onkey(view v, int keycode, keyevent event) { // todo auto-generated method stub if ((event.getaction() == keyevent.action_down) && (keycode == keyevent.keycode_enter)) { // code action on key press input = editbox.gettext().tostring(); if(mengine.init(input, getapplicationcontext())) { sharepref = getsharedpreferences("info",mode_private); edit = sharepref.edit(); edit.putstring("ed

python - Request variable not found in pluggable view -

i have pluggable view defined follows class listview(view): methods = ["get", "post"] def __init__(self, model, template_name="list_view.html"): self.model = model self.template_name = template_name def dispatch_request(self, *args, **kwargs): if request.method == "get": objects = self.model.query.all() return render_template(self.template_name, objects=objects) else: #do post request i'm trying create pluggable view that'll handle both , post requests. when try above, following error however nameerror: global name 'request' not defined according flask docs, request should present in dispatch_request method, isn't in case. i'm using flask 0.10.1 request global context variable; need import in module: from flask import request see quickstart documentation on accessing request d

c++ - Reorder vector according to a vector of indices - update -

this update previous question reordering in place there confusion vector of indices. calling vector reordered va, , vector of indices vi, va should reordered in order, va[vi[0]], va[vi[1]], va[vi[2], ... . example usage initialize vi set of va.size() indices, 0 va.size()-1, sort vi according va (compare using va[vi[...]]). reorder function used sort va according vi. consider initial va permutation of sorted va. after sorting vi according va, reordering va according vi "unpermutes" va sorted permutation. example functions shown below, reordering va reorders vi it's initialized state (0 va.size()-1). the example below shows non-working version of reorder called reorderfail() followed working version called reorder(). both functions return vi it's original state of 0 va.size()-1, reorderfail() fails reorder va because it's missing level of indirection needed "unpermute" va. #include <algorithm> #include <vector> using namespac

c++ - Is it possible to have a cv::Mat that contains pointers to scalars rather than scalars? -

i attempting bridge between vtk (3d visualization library) , opencv (image processing library). currently, doing following: vtkwindowtoimagefilter converts vtkrenderwindow (scene) vtkimagedata (pixels of render window). i have copy each pixel of vtkimagedata cv::mat processing , display opencv. this process needs run in real time, redundant copy (scene pixels imagedata mat ) severely impacts performance. map directly scene pixels cv::mat . as scene changes, cv::mat automatically reference scene. essentially, cv::mat<uchar *> , rather cv::mat<uchar> . make sense? or overcomplicating it? vtksmartpointer<vtkimagedata> image = vtksmartpointer<vtkimagedata>::new(); int dims[3]; image->getimagedata()->getdimensions(dims); cv::mat matimage(cv::size(dims[0], dims[1]), cv_8uc3, image->getimagedata()->getscalarpointer());` i succeeded implementing vtkimagedata* directly cv::mat pointer array.. some functions such cv::flip

activerecord - Get the result of SUM and group field from Active record in Codeigniter -

i need build query in codeigniter don't know how result of sum: select description, sum(amount) payment (date_payment between '2014-02-01 00:00:00' , '2014-02-28 23:59:59') group description; i'm trying result this: $qwer = $this->db->query(" select description, sum(amount) payment (date_payment between '$min_date' , '$max_date') group description;"); $i = 0; foreach ($qwer->result() $payment) { $det_payment[$i] = array( 'description'=>$payment->description, 'amount'=>$payment->amount ); $i++; } of course "$payment->amount" wrong, if use alias sum, model doesn't work. edit: right can choose between description or sum, can't use both select , select_sum $this->db->select('description'); //$this->db->select_sum('amount', 'amount'); $this->db->where('date_payment &

javascript - html dropdown menu change dynamically -

i have following code. have 2 select option menu. every time of them changed, want send ajax request servlet. using data comes servlet, want write in html. how can that? thanks <div class="p_inforoom"> <input type="hidden" th:value="${hoteldetail.deal.id}" id="dealid" /> <h3>oda bilgileri :<b th:text="${hoteldetail.deal.room.name}"></b></h3> <select name="numberofnights" id="night" onchange="getnights(this)"> <option th:each="rooms:${roomsleft}" th:text="${rooms}" th:value="${rooms}" id="roomleft" > </option> </select> <select name="roomtype" id="room" onchange="getrooms()"> <option class="1" value="1" >tek kiÅŸilik</option> <option class="2" selected="selected"

javascript - AngularJS not linking with MVC Model -

we building form within ng-repeat tag. ng-model not seem linking mvc control model. <li ng-repeat="item in favourites"> <form ng-submit="delete()" id="frmspec"> <input ng-model="item.description"/> <input ng-model="item.refno"/> <button type="submit"class="btn">{{item.description}} <span class="glyphicon glyphicon-remove"></span></button> </form> </li> <script type="text/javascript"> $scope.delete = function () { var url = '/list/deletefavourites/'; $http.post(url, $scope.formdata) .success(function (data) { }); };</script> within mvc controller public actionresult deletefavourites(models.mymodel mm, string buttontype) { } this issue mm being returned null any appreciate

html - Using CSS3 to give per three table rows a background color -

an odd question maybe, want use css3 this, not sure if it's possible. tried experiment nth-child , nth-of-type , not work. guess it's hard want without using javascript . anyhow, let me tell want... i have 3 <tr> elements in table want give background color. beneath these table rows, have 3 more table rows. not different color. problem: how select them? even or odd , it's not possible... is there possibility combine nth-of-type or odd ? or utopia? i know can give these rows class , make work, not aiming for. love solve css3, if ie won't support it. there way this? html: <table class="dummyclass"> <tbody> <tr class="this_should_get_a_background_color"> <th>dummytext</th> <td><a href="#">dummy dummy</a></td> </tr> <tr class="this_should_get_a_background_color">

php - jquery is resetting my div content -

i'm trying change content of div using jquery. content flashes , resets div. cannot use return false; because there button post text field value. want keep changes of div. here code: <html> <head> <meta charset="utf-8"> <title></title> <script type="text/javascript" src="jquery.js"></script> </head> <body> <div> <form id="form" method="post"> <input type="text" name="gname" id="gname"/></br> <button id="btn">set</button> <button id="nbtn">view</button> </form> </div> <div id="outp"> </div> </body> <script> $("#btn").click(function(event) { $.post("send.php", { named: $("#gname").val()}, function(d

asp.net - Error in web.config with membership AD provider -

try this: <configuration> <connectionstrings> <add name="adservice" connectionstring="ldap://mossdc02/, dc=expgroup, dc=ru" /> </connectionstrings> <system.web> <membership defaultprovider="aspnetactivedirectorymembershipprovider"> <providers> <add name="aspnetactivedirectorymembershipprovider" type="system.web.security.activedirectorymembershipprovider, system.web, version=2.0.3600, culture=neutral, publickeytoken=b03f5f7f11d50a3a" connectionstringname="adservice" connectionusername="domain\\username" connectionpassword="password"/> </providers> </membership> <compilation debug="true" targetframework="4.0"/> <httpruntime/> <authentication m

Rails iterate over objects array -

i want this @groups = community::groupmember.where(:member_id => current_user.id) user_ids = [] @groups.each |group| user_ids << @group.community_group_members.where(:group_id => group.id).pluck(:member_id) end but error nomethoderror - undefined method `community_group_members' think im not iterating @groups way want. you should have: user_ids << group.community_group_members.pluck(:member_id) ( group instead of @group ). it's because inside each block, element of array represented local variable (which unprefixed) instead of instance variable (prefixed @ ). @group instance variable unset , evaluated nil , doesn't respond community_group_members method. also, deleted where clause, since it's reduntant - you're doing in group.community_group_members call.

protected virtual methods in f# -

f# not support definition of protected methods. here explained why f# replaces virtual methods abstract methods defined in abstract classes (see here ). i wondering if there way prevent access abstract methods outside derived classes @ all. like patryk Ćwiek, don't think it's possible, here's 1 alternative: from design patterns know should favour composition on inheritance . in experience, can inheritance, can composition. example, can replace template method strategy. a template method typical use of abstract method, if replace strategy, can (sort of) hide clients: type foo(strategy : ibar) = member this.createstuff() = // 1. concrete here // 2. use strategy here // 3. else concrete here // 4. return result no outside client of foo can invoke strategy , accomplishes same goal making member protected. you may argue original creator of foo may keep reference strategy , , still able invoke it. that's tru

html5 - Getting translation text from Google Translate [HTML] -

i developing application have free-text object user add comments. after submit button clicked, sent info db. my question is: can use google translate translate text before sending db? for example, if enter "this test" , want translate dutch, can use link: http://translate.google.com/#en/nl/this%20is%20a%20test but don't know how value translate.google. thanks in advance!

java - Code not working unless a simple print statement is inserted in while loop -

this question has answer here: value not update in while loop unless printed out [duplicate] 4 answers i have following piece of code public string ls() throws ioexception, interruptedexception { string pwd = getpwd(); string inodepath = "upload/files" + pwd + "inode"; // request inode file first peer.setfilereceivedcheck(false); inode = new inode(); i.requestinode(pwd + "inode"); boolean filecheck = peer.getfilereceivedcheck(); system.out.println(filecheck); while (filecheck == false) { system.out.println(); // not work if line removed!! filecheck = peer.getfilereceivedcheck(); } system.out.println(filecheck); return i.readfrominode(inodepath); } in above java method, filecheck variable keeps track of when file downloaded network , becomes true when file download c

webdav - How do I get rid of security warning in IT Hit Ajax File Browser when opening docs? -

when double click on file open non-ms office document it hit ajax file browser following warning: some files can harm computer. if file information looks suspicious or not trust source, not open file. can suppress warning somehow? this warning comes java applet , similar warning raised microsoft office web browsers add-ins , activex when user opens ms office documents. provided consistency ms office add-ins , activex behavior. the applets sources shipped part of hit ajax file browser. remove need change applet sources, compile , sign applet code signing certificate.

java - what are basic functionality of operator? -

hi, can tell me ":" operator , please explain below condition statement? for(string key:keyset) -----> : operator it's not operator, it's part of syntax. see enhanced loop or for-each loop. iterates on keyset , binds each string contains variable key 1 after in each iteration.

regex - Perl one-liner to convert first character uppercase - logic understanding -

in following perl command lines, trying turn first , second char uppercase echo pet | perl -pe 's/^(.{0})(.)/$1\u$2/' # ans: pet echo pet | perl -pe 's/^(.{1})(.)/$1\u$2/' # ans: pet but not understand syntax (.{0})(.) , (.{1})(.) could clarify how works? however, found above can achieved following syntax: echo pet | perl -pe 's/(\w)/\u$1\e/' # ans: pet echo pet | perl -pe 's/(\w)(\w)/$1\u$2/' # ans: pet the reference when placed between \u , \e converted uppercase the difference between: echo pet | perl -pe 's/^(.{0})(.)/$1\u$2/' # ans: pet echo pet | perl -pe 's/^(.{1})(.)/$1\u$2/' # ans: pet is nothing matched in first capture group in first case, whereas p captured in first group in second case. a shorter equivalent of first case be: $ echo pet | perl -pe 's/^(.)/\u$1/' pet additionally, following should clarify it: $ echo pet | perl -pe 's/^(.{0})(.)/$1\u$2$2/' pp

Excel VBA hyperlink in userform -

i have created userform , when insert name in userform data written on first empty cell , creates new sheet same name. problem im having need create hyperlink name sheet when press on name directly takes me sheet. code im getting subscript out of range in hyperlink private sub okbutton_click() dim test worksheet sheet11.copy after:=sheets("clients") set test = activesheet test.name = nametextbox.value range("b9").value = nametextbox.value dim emptyrow long 'make sheet1 active sheet1.activate 'determine emptyrow emptyrow = worksheetfunction.counta(range("a:a")) + 1 'transfer information cells(emptyrow, 1).value = nametextbox.value cells(emptyrow, 2).value = test.range("e51").value 'add hyperlink sheets("sheet1").hyperlinks.add sheets("sheet1").cells(emptyrow, 1), "", sheets("nametextbox.value").name & "!a1", "nametextbox.value" 'empty

c++ - Regex with Qt capture some text -

i capture second occurence of text replaced star in following string: &nbsp;sw * <br> ie string starting &nbsp;sw ending <br> in qstring, using regex qt. an example here: string &nbsp;&nbsp;sw = min(1, max(0, pow(10, -0.2 - 6.5 ) ** (1.0 / 0.2)))<br> and expected result = min(1, max(0, pow(10, -0.2 - 6.5 ) ** (1.0 / 0.2))) so far, have qregexp rx("^[\&nbsp;sw](.*)[<br>]$"); not compiling. how ? the compilation issue due trying escape ampersand ( \& ). other that, regex right, overusing character groups ( [] ), not grouping. expression works in tests: &nbsp;sw(.*)<br> , in case you'd like qregexp rx("&nbsp;sw(.*)<br>")

pass reference of primitive data types to functions in ruby -

by default ruby passes copy of primitive values , references object types. how pass references of primitive type variables (ex: integers, floating points) function? ruby doesn't pass arguments reference: def change(x) x = 2 # assigns local variable 'x' end = 1 change(a) #=> 1 you pass mutable object instead, e.g. hash "containing" integer: def change(h) h[:x] = 2 end h = {x: 1} change(h) h[:x] #=> 2

android: graphical layout doesnt match emulator with same screen size -

when hit emulate or use app on smartphone, looks different graphical layout editing, more height gets messed up my graphical layout xml this: <scrollview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/scrollview1" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity" > <linearlayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:gravity="center" > <relativelayout android:layout_width="1050dp" android:layout_height="1450dp" android:background="@drawable/backright3" > and have 100 textviews in relativelayout. know goes wrong when emulate? seems fine on edit mode. messes height, when use same screen (edi

jquery - addClass not working in IE8 -

it seems addclass not working ie8 reaosn. made <div> , <p> , , want assign class <p> when <div> clicked not working in ie8. .test { width: 100px; height: 100px; background: red; } <div class="test"></div> <p>deeded</p> $('.test').click(function() { $('p').addclass('code'); }); the class not added in ie8. why? you didn't define code class , write in comment (you should write in question..) want use class flag for purpose should use html data attribute: see: http://www.w3schools.com/tags/att_global_data.asp and: is there problem using html5's "data-*" attributes older browsers? as you're interested in supporting ie8

spring - Programmatically register'ing WebMvcConfigurationSupport instead of @Configuration -

[this question similar " preventing @enablewebmvc-annotated class being picked @componentscan ", different attack vector problem, got problem in spring 4] since @componentscan finds @configuration instances, picks extension of webmvcconfigurationsupport want in servlet environment. in integration test mode, don't want that, since complains servletcontext not being present. java.lang.illegalstateexception: failed load applicationcontext @ org.springframework.test.context.cacheawarecontextloaderdelegate.loadcontext(cacheawarecontextloaderdelegate.java:99) @ ... caused by: java.lang.illegalargumentexception: servletcontext required configure default servlet handling @ org.springframework.util.assert.notnull(assert.java:112) @ org.springframework.web.servlet.config.annotation.defaultservlethandlerconfigurer.(defaultservlethandlerconfigurer.java:54) @ org.springframework.web.servlet.config.annotation.webmvcconfigurationsupport.defaultservlethandler

.net - What's the purpose of IAuthenticationFilter.OnAuthenticationChallenge() -

i have custom iauthenticationfilter implementation registered in registerglobalfilters() . in project i'm witnessing following call sequence: iauthenticationfilter.onauthentication authorization (if any) controller action iauthenticationfilter.onauthenticationchallenge why happen after controller action? this blog post read the key thing remember onauthenticationchallenge not run before every other action filter. can run @ various stages. how can useful if can't tell when called? source "the onauthenticationchallange method called mvc framework whenever request has failed authentication or authorization policies action method. onauthenticationchallenge method passed authenticationchallengecontext object, derived controllercontext class" so, practical example be: 1 - set custom authorize filter 2 - users fails on authorizing method 3 - onauthenticationchallenge method called.

C# Windows Form post status update on Twitter -

c# windows form post status update on twitter i have tried solutions can find , pieced following code gives 401 authorisation error. when set twitter application in twitter asked callback url, developing on local machine , need use windows forms tweets can data local database. want tweet own account data database insert tweets when add new items. i have tried changing encoding utf8 (left previous string definitions commented out show where), after reading problem somewhere. i not know if there wrong authorisation have required keys or if callback url, , if can use windows form client no website. if paste curl dev.twitter site browser "bad authentication data" when using https://api.twitter.com/1.1/statuses/update.json (it defaults 1 , gives message saying has been deprecated). website have entered callback url mine, not know if there needs code there test function. any appreciated have been trying resolve week now. public static void anothertweet(string sta

uigraphicscontext - draw CGImageRef (not UIImage) into image context -

here's how draw uiimage in context: uigraphicsbeginimagecontextwithoptions(size, no, 0.0f); [someuiimage drawinrect:cgrectmake(...)]; [someotheruiimage drawinrect:cgrectmake(...)]; [someotheruiimage drawinrect:cgrectmake(...)]; uiimage *yourresult = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); no problem. however, have cgimageref built somehow. cgimageref happyimageref = cgimagecreatewithimageinrect(blah blah); i want draw in context. uigraphicsbeginimagecontextwithoptions(size, no, 0.0f); [ happyimageref .. somehowdrawinrect:cgrectmake(...)]; uiimage *yourresult = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); how do that? to clear, can convert uiimage uiimage *wasteful = [uiimage imagewithcgimage:happyimageref]; but seems incredibly inefficient. how it? i'm sure i'm confused or missing simple, thanks. use cgcontextdrawimage uigraphicsbeginimagecontextwithoptions(size, no, 0.0f); cg

javascript - Html Input=text performs postback when enter is pressed -

i using signalr make chat , works when enters text , presses return performs postback , previous chat lost , no message sent. primary goal avoid performing postback ideally call send button click event. i have tried make javascript function on keypressed should cancel postback did not change anything. have tried change asp:textbox autopostback attribute set false. my current code: <div class="container"> <input type="text" id="message" /> <input type="button" id="sendmessage" value="send"/> <ul id="discussion"> </ul> </div> <script src="scripts/jquery-1.6.4.min.js" ></script> <script src="scripts/jquery.signalr-2.0.2.min.js"></script> <script src="signalr/hubs"></script> <script type="text/javascript"> $(function () { // declare proxy reference hub. var

.net - Find out DirectX Version -

how can detect if directx version on windows 7 machine 11 or 11.1 ? preferably using .net language maybe via pinvoke or sharpdx? just try create device specific feature level (along other parameters). in native code (use 1 of d3d11createdevice* functions) . if function not succeed - feature level not supported. make easier, pass array of feature levels, , then, if device not nullptr , can check 1 highest supported: const d3d_feature_level arrfeatlevels[] = { d3d_feature_level_11_1, d3d_feature_level_11_0, d3d_feature_level_10_1, d3d_feature_level_10_0, d3d_feature_level_9_3, d3d_feature_level_9_2, d3d_feature_level_9_1, }; const unsigned int nfeatlevels = _countof(arrfeatlevels); d3d11createdeviceandswapchain(..., arrfeatlevels, nfeatlevels, ..., &m_device, &featurelevel, &m_context); if (m_device && m_context) { featurelevel // can access highest supported feature level

java - How to configure concurrency to a single queue -

i configure number of consumers single queue in jms template. tried implement this: jmstemplate - define concurrency per queue? in activemqqueue stiil shows 1. messanging context: <bean id="parentcontainer" abstract="true" class="org.springframework.jms.listener.defaultmessagelistenercontainer"> <property name="connectionfactory" ref="connectionfactory" /> </bean> <bean id="parentcontainer" abstract="true" class="org.springframework.jms.listener.defaultmessagelistenercontainer"> <property name="connectionfactory" ref="connectionfactory" /> </bean> <bean id="playerstatslistener" parent="parentcontainer"> <property name="destination" ref="playerstatsqueue" /> <property name="messagelistener" ref="playerstatsservice"

dsl - XText w/ XBase - Initialize generated variable -

i'm using xtext xbase grammar. in every generated java class need initialize class variable in model inferer. variable isn't defined in model, makes no difference. can generate variable via function element.tofield("issomethingset", newtyperef("boolean")) , can't initialize it. i'm sure should use tofield function additional parameter called initializer , of type procedure1 don't know how use it. here changed example taken xtext documentation. grammar: grammar org.xtext.example.mydsl.mydsl org.eclipse.xtext.xbase.xbase generate mydsl "http://www.xtext.org/example/mydsl/mydsl" domainmodel: (elements += abstractelement)*; abstractelement: entity; entity: 'entity' name = id ('extends' supertype = jvmtypereference)? '{' (features += feature)* '}'; feature: name = id ':' type = jvmtypereference; modelinferrer.xtend import com.google.inject.inject import org.eclipse

uri - Java: How to use AbsolutePath as a Link -

i´m writing java , 1 of task convert input/output in html. going good, can read files , path of files. i´m trying convert path in normal link so: "<a href=" + file.getabsolutepath() + " target=_parent>" works pretty good, but: one, explorer show error can´t read file, example: jpg or word file.. two, if path have blank like: "my picture.jpg" recognize after blank normal text... can give me tipp, how fix that, or using wrong method? you can use touri() method turns file path uri: file.getabsolutefile().touri().tostring()

c++ - Arm NEON and poly8_t and poly16_t -

i've been looking neon optimisation intrinsics , have come across poly8_t , poly16_t data types. i'm left wondering on earth are. i've searched across net far have been unable find explanation of are. can explain them me? edit : answers why, if different way of multiplying etc, have totally different data type? left = regular multiplication, right = carryless multiplication 1 1 0 1 1 1 0 1 * 1 0 0 1 1 0 0 1 ------------ --> -------------- (1)1 1 0 1 <-- (1) carry 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 + 1 1 0 1 + gf(2) or xor ------------- --------------- 1 1 1 0 1 0 1 1 1 0 0 1 0 1 each 1 or 0 in diagonally descending matrix represents partial product of 1 source bit vec

c# - DataGridView dynamic selected row Color -

i working on custom datagridview derived system.windows.forms.datagridview . in desired grid rows may have different colors due state, , want current row little different other rows, , difference in color being highlighted dynamic rather being static. when select row, want keep previous color of row, highligh color relatively, have done whit code snippet: color oldcolor; private void dgvmain_selectionchanged(object sender, eventargs e) { oldcolor = dgvmain.currentrow.defaultcellstyle.backcolor; color newcolor = color.fromargb(oldcolor.r < 235 ? oldcolor.r + 20 : 0, oldcolor.g, oldcolor.b); dgvmain.currentrow.defaultcellstyle.backcolor = newcolor; } but have 2 problems: when select row, first code changes row's color, row gets selected color changes default selection color. when row loses selection (is deselcted) can not recover it's old color - have oldcolor don't know when currentrow changed, know rows

How to write the retrieved DB from MS SQL server into new CSV File with headers using python 2.7.6 -

i trying view database retrieved ms sql server in csv file using python headers(column names)and without braces , quotes. code follows: import csv import pyodbc outpath="path\\test1.csv" output = open(outpath, "w") cnxn = pyodbc.connect('driver={sql server};server=sipldt0115;database=first_eg;uid=sa;pwd=wisdom') cursor = cnxn.cursor() sql = "select * first1" cursor.execute(sql) rows = cursor.fetchall() desc = cursor.description header = (desc[0][0], desc[1][0], desc[2][0], desc[3][0], desc[4][0]) print "%s %3s %s %3s %3s" % header row in rows: print row value = str(row).strip('(') output.write(str(value.replace(')','\n'))) output.close() f = open("path\\test1.csv").read() print f output: f_name l_name s_id branch course ('jash', 'u', 123, 'c', 'b') ('jash', 'u', 123, 'c', 'b') ('jash', 'u', 123, '

c++ - Use of undefined identifier ? Pointer to function -

i have compile error , don't know why. here's header code : file: authsession.hpp class authsession : public player, public boost::enable_shared_from_this<authsession> { public: authsession(boost::asio::io_service& io_service, playerlist& player_list) : socket_(io_service), player_list_(player_list) { } ~authsession(){ } //some functions }; file : opcodes.hpp #include "../player/authsession.hpp" struct opcodehandler { char const* name; sessionstatus status; void (authsession::*handler)(authmessage& recvpacket); //error here : undefined authsession }; my file large, removed unnecessary code.. can me?

javascript - Adding a class to an array of elements with forEach not working? -

i converted node list returned queryselector() method array still can't foreach work (i want add class). can tell me i'm doing wrong? my code extremely simple i'm new js. this html: <table> <tr> <th>this th</th> <th>this th</th> <th>target</th> <th style="display: none;"></th> </tr> <tr> <td>this table cell</td> <td>this table cell</td> <td>target</td> <td style="display: none;"></td> </tr> </table> js: (function(){ "use strict"; var th = array.prototype.slice.call(document.queryselectorall("th")), td = array.prototype.slice.call(document.queryselectorall("td")); function test(index, el, array) { el.classname = "color"; } th.foreach(test()); })();

c++ - Why is this code on vectors giving runtime error? -

what wrong code , why giving runtime error ? #include <iostream> #include <vector> using namespace std; int main() { vector < int > a[2]; a[0][0]=1; a[1][0]=2; cout << a[0][0]; cout << a[1][0]; return 0; } also please correct . why giving runtime error ? because 2 vectors empty, can't access elements using [] . also please correct . vector < int > a[2]; a[0].push_back(1); a[1].push_back(2);

vb.net - Extract whole row/line using Lumenworks CSV Parser -

how read whole row while using lumenworks cvs parser? far able read entry entry not whole row. i.e. if row a,b,c,d,e,f , able pluck out each individual alphabet. however, want able read whole row currently have: my_csv = new csvreader(new streamreader(file_path), false, ",", resetpoint) field_count = my_csv.fieldcount while my_csv.readnextrecord() 'process data here 'this code process each individual alphabet in 1 row the above reads each individual alphabet. want have like row = my_csv.row is option available or similar? 'edited' when have basic vb programming skills me, come solve problem dim my_string string = "" x integer = 0 my_csv.fieldcount - 1 my_string += my_csv(x).tostring.trim + "," next my_string = mid(my_string, 1, len(my_string) - 1) return my_string by means use code in marked answer. super elegant! i haven't found available, should work:

run from Shell R function with parameter, that contains quotes -

suppose, have function: my_function<-function(string) return(string) when run r: >my_function('string"with"quotes') [1] "string\"with\"quotes" it works well. when try run function shell: r -e "source('./my_function.r'); my_function('string"with"quotes')" it fails error, because shell can't deal quotes. is there solution problem? p.s. need run function directly shell.

c++ - How to move string from QTextEdit to another QTextEdit using pushButton in Qt? -

i using 2 text edit , 2 push buttons in between them. objective list out files particular folder in first qtextedit implemented successfully. want select particular file(s) , send them second qtextedit using pushbutton in between them , in case, want delete file(s) reverse should happen second pushbutton. the following sample code of mainwindow.cpp::: #include "mainwindow.h" #include "ui_mainwindow.h" #include <qfiledialog> #include <qdebug> #include <qdiriterator> #include <qtextedit> #include <qtextcursor> #include <qtextcharformat> #include <qwidget> #include <qstring> qstring dirpath; mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); connect(ui->pushbrowse,signal(clicked()),this,slot(pushbrowseclicked())); connect(ui->pushadd,signal(clicked()),this,slot(pushaddclicked)); } mainwindow::~mainwindow() { delete ui; } vo

privacy - How to prevent someone having your TeamViewer ID from seeing your computer status -

i've noticed little strange teamviewer. if has teamviewer account, he/she can add partner using id only, , see partner's status, meaning whether computer online or offline. i haven't figured teamviewer's security model, wondering how prevent that. for example, let's running teamviewer , gave id. did session once , it's over. password changed , partner can no longer connect computer. however, id remains same. thus, partner can watch status, when computer online , when offline. isn't there way prevent that? i had same problem , found way browsing through options. should select extras>options, advanced, click on show advanced options, tick field "hide online status teamviewer id" in subsection: "advanced settings computers , contacts". this way, can still connect computer, displayed offline users having id. hope helps.

couchbase - CBLite Android - Get values in second level -

using cblite android, , storing docs (similar android grocery sync example) this: { "check" : true, "created_at" : "2014-02-25t10:16:46.026z", "text" : "soap", "prices":[ { "date" : "2014-02-25" , "value" : 12 } ] } i value in "text" field ​​as shown in documentation: ... document document = row.getdocument(); string text = ((string)document.getcurrentrevision().getproperty("text")); ... but, how should value in, example, "value" field? thanks. edit: getting documents api reference search in doc allow array, read array value.

regex - JavaScript - Understanding the role of a variable in a function passed as an argument -

i'm trying work regular expressions , in particular i've shuffle middle content of string . found example fits needs here , answer i'm studying 1 brian nickel. this code proposed brian nickel in question: mystr.replace(/\b([a-z])([a-z]+)([a-z])\b/ig, function(str, first, middle, last) { return first + middle.split('').sort(function(){return math.random()-0.5}).join('') + last; }); i'm beginner in javascript , regex, see here function passed argument, don't understand why there 4 parameters, in particular not understand first parameter str , why if remove it, function doesn't work anymore correctly. i it's silly question, don't found want on web, or maybe don't know how search properly. in advance when using replace regexp, function use callback receive 1+n parameters n match inside parenthesis. the come in order : the complete matched string. the first parenthesis. the second parenthesis.