Posts

Showing posts from March, 2011

c# - How to pass parent view data when using partial view -

i have dropdownlist in parent view , when select value want save value , use when click button in partial view. if click button in partial view not have value of parent view. however, if move dropdownlist partial view works fine, keep in parent view. parent view (this dropdownlist is) <div class="btn-toolbar"> <div class="btn-group"> <button type="button" class="btn btn-primary" id="fetchprocessid">fetch process id</button> </div> </div> <div class="col-md-3" style="@displayadminlead"> <div class="dropdown div-inline"> @{ var envlist = new list<selectlistitem>() { new selectlistitem() {value = "oak", text = "oak"}, new selectlistitem() {value = "qa", text = "qa"}, new selectlistitem() {value = "prod&quo

javascript - Get index of elements nested in different divs -

is possible index of checked input, of them nested in different divs. eg such situation: <div class="parent"> <div> <input></input> <input></input> <input></input> </div> <div> <input checked="checked"></input> <input></input> <input></input> </div> </div> so checked input show index = 3 how build such selector? possible? or can show index of children nested directly withing same parent? try invoke .index() on entire collection passing target element, var inputs = $(".parent input:checkbox"); var index = inputs.index(inputs.filter(":checked")); //3 demo a demonstration valid html given here .

c# - Hidden form not closing -

i have c# form , have form1 shown @ start, , when press go taken form2 . form1 hidden , form2 shown. now when exit form2 , whole application should closed. using application.exit() when press exit button. facing problems if user presses x or alt+f4 or rightclick->close . form close hidden form stay opened. how can fix that? when press 1 of these control button, hidden forms close? i tried form1_close , form1_closing function didn't seem work. try this: hide(); form2 form2 = new form2(); form2.closed += (s, args) => this.close(); form2.show(); this close form1 when close form2 . if user presses x or alt + f4 or rightclick -> close on form2 form2 , hidden form1 close.

Cannot deploy grails war in Tomcat 7 and Ubuntu - 404 error -

i've create simple grails 3 application test issue deploying tomcat on ubuntu server (digital ocean). to create app : grails create-app test to ensure tomcat not embedded in deployed war : provided "org.springframework.boot:spring-boot-starter-tomcat" to create war grails war i'm uploading , deploying war using tomcat application manager. the app manager reports application deployed. catalina.out reports finding app , explodes war. however, visiting http://ipaddress:8080/test results in 404 i've deployed sample war file (from tomcat 6) , sample app deploys without issue , can access on http://ipaddress:8080/sample so difference between grails (3) war , more typical war. deploying test war/app works on local installation of tomcat (mac os) not on ubuntu server. i've seen number of similar problems on issue none have provided working solution. one thing notice don't see (that in local environment) h2 database : proddb.h2.db

javascript - Automapping ajax data during ajax put or post in knockout -

during ajax request, can use ko.mapping.fromjs data server , automapping. also, can use ko.mapping.tojs post or put ajax data server in knockout. however, assumption every value in ko.mapping.tojs pass in ajax call. use delete or ignore remove property should not pass server. recently, have came problem follow. how pass data want without explicitly assign or ignore data 1 one cumbersome. thinking restructuring view model may job not know how start. function myviewmodel() { var self = this; // these data should not pass in ajax call self.data1 = ko.observable(); self.data2 = ko.observable(); self.data3 = ko.observable(); ... self.data50 = ko.observable(); // these data should not pass in ajax call self.nodata1 = ko.observable(); ... self.nodata10 = ko.observable(); // these should not pass in ajax call self.function1 = function() { } self.function2 = function() { } self.function3 = function() { $.ajax({

jquery - Ajax form with different actions in ASP MVC -

in asp.net mvc have following input form (simplified): <div id="ajaxtarget"> @using (ajax.beginform("submitform", "home", new ajaxoptions { updatetargetid = "ajaxtarget" })) { @html.dropdownlistfor(x => x.postalcode, model.postalcodeitemlist, new { @name = "postalcodeid" , @id="postalcodeid" }) @html.labelfor(x => x.streetcode) @html.dropdownlistfor(x => x.streetcode, model.streetitemlist, new { @id="streetcodeid" }) ... <input type="submit" value="@global.execute" id="btnsubmit" /> } </div> when user selects first dropdownlist, second dropdownlist should populated via ajax. can send 'call' controller via javascript update view: $(document).ready(function () { $('#postalcodeid').on('change', function () { $(this).parents('form').submit(); }); });

javascript - no element error on ajaxing to php file -

i'm trying connect javascript , php files , no element error , couldn't figure out. in advance! +anyone can recommend ways debug these..? <html> <head> <title>ajax!!!!</title> <meta charset="utf-8"/> <link href="main.css" rel="stylesheet" type="text/css"/> </head> <body> <h1>home</h1> <h4>enter id</h4> <p>summoners name: <input type="text" id="summonername"></p> <button id="sumname">search!</button> <button id="renewdata"> renew data</button> <button id="testing"> renew data</button> <div id="result">display result</div> <script src="jquery/jquery.js"></script> <script type = "text/javascript"> $(document).ready(function(){ $('#testing').on('click', function(){ $.ajax

Arduino softwareserial clashing with SPI? -

i have arduino project using nrf24l01+ radio module on spi (using library: http://tmrh20.github.io/rf24/ ) , rfid reader on softwareserial. sleeping arduino , having them wake via interrupt when message has been received or rfid tag ready read. rfid on pins 4 , 5, while nrf covers pins 9 - 13 number 2 interrupt. both of these modules work fine sleep , interrupt code separately, when combined in single sketch, arduino wake due rfid tag, read it, try send on radio , hang, waiting library call write() return. i have delved bit 2 libraries, can't make heads or tails of softwareserial library. seems maybe using same isr behind scenes nrf module, don't see why should big problem, , don't understand why should cause radio hang. i know may long shot, have idea might going on? maybe knows these libraries? thoughts on work around? thanks. i experiencing same symptoms, , problem turned out buffer overrun in code. overrun due softwareserial dropping bytes because rf

node.js - Isn't mongoose contradictory to nosql? -

i've watched many videos , tutorials on mongodb , mongoose, , while think mongoose it's job well, isn't contradictory flexibility nosql datastore offers? being schema-less environment. what if want add new property, or array document? have update mongoose schema correct? seems counter-intuitive whole point of flexible document store. if want application more flexible, isn't mongoose wrong choice application? disclaimer: i've been using mongoose 2 years in large enterprisey application, , have been using mongo year on top of pre-mongoose. the docs mention let's face it, writing mongodb validation, casting , business logic boilerplate drag. that's why wrote mongoose. this statement hard appreciate unless you've been through pain. here's dream: application perfect, , store need in 1 collection. can throw data or fetch it. fits linux pipeline , works! i think reality underestimate our data at least relational , implicat

mysql - Opencart report module Query -

i need report form i'm trying list category, customername, email, telephone etc. except category, works when click filter button. query: select min(o.date_added) date_start, max(o.date_added) date_end, count(*) `orders`, sum((select sum(op.quantity) `oc_order_product` op left join `oc_product_to_category` pc on (op.product_id = pc.product_id) op.order_id = o.order_id group op.order_id)) products, sum((select sum(ot.value) `oc_order_total` ot ot.order_id = o.order_id , ot.code = 'tax' group ot.order_id)) tax, sum(o.total) `total` `oc_order` o o.order_status_id > '0' , date(o.date_added) >= '2015-10-01' , date(o.date_added) <= '2015-10-22' , o.shipping_postcode = '4545456' , pc.category_id = '72' please correct query. pc (oc_product_to_category) known in inner query. think helps: select min(o.date_added) date_start, max(o.date_added) date_end,

thrust - Get unique elements of multiple arrays in CUDA -

here problem: there number of arrays, example, 2000 arrays, 256 integers in each array. , range of integers quite considerable, [0, 1000000] instance. i want unique elements each array, in other words, remove duplicate elements. have 2 solutions: use thrust unique element every array, have 2000 times thrust::unique . each array pretty small, way may not performance. implement hash table in cuda kernel, use 2000 blocks, 256 thread in each block. , make use of shared memory implement hash table, every single block produce element-unique array. the above 2 methods seem unprofessional, there elegant ways solve problem cuda ? you can use thrust::unique if modify data similar done in question: segmented sort cudpp/thrust for simplification, let's assume each array contains per_array elements , there total of array_num arrays. each element in range [0,max_element] . demo data per_array=4 , array_num=3 , max_element=2 this: data = {1,0,1,2},{2,2,0,0},{0,0

Can Swift optional be nested? -

i cannot find answer question, example can have optional of optional of string? tried write small test check out: let : string? = nil; let b : string?? = a; if b!=nil { // error println("has value"); } else { println("fail"); } but since not swift programmer don't know error saying "cannot assign result of expression". yes can; syntax incorrect though. line: if b!=nil is digested compiler as: if (b!) = nil ... thinks you're trying assign nil unwrapped optional. swift doesn't allow make assignments within if statements (in contrast objective-c). instead clearer: if b != nil edit: and, finish thought, proving syntactic sugar making optional optional, if add: if let b = b { print("\(b)") } you should see nil printed output.

html - How to plot latitude and longitude in google map? -

i plotting location in google map webpage, have search location in google map , copied longitude , latitude , pasted kml file. got example kml file,and longitude , latitude looks long when paste longitude , latitude in google map didnt come location. works fine in website , showed location in webpage. -87.89289951324463,41.97881025520548,0 -87.89184808731079,41.97788506340239,0 -87.89150476455688,41.97762983571196,0 -87.8912901878357,41.97750222148314,0 -87.89090394973755,41.977326751500996,0 -87.89047479629517,41.97719913666485,0 but when replace longitude , latitude got google map , didnt work, show whole earth in map. longitude , latitude wanted plot are -37.806606,144.962063,0 37.806055,144.957139,0 -37.805334,144.955969,0 -37.804224,144.956152,0 i following tutorial google map , example code changing latitude , longitude doesnt work, fine original latitude , longitude. https://developers.google.com/maps/documentation/javascript/examples/laye

javascript - Promise.map not waiting for resolution before proceeding to .then() -

i've had problem trying wrap mind around javascript promises. here lately frustration: var rp = require('request-promise'); function process1000() { //gets 1000 objects db process get1000objects() .then(function (docs) { promise.map(docs, addapidata) }) .then(function (objects) { console.log(objects) }) } function addapidata(element) { return rp(url).then(function (res) { resolve(res); }) .catch(console.error); } when rp(url) called in addapidata(), doesn't wait until function resolved before beginning next item in array i'm passing promise.map in process1000(). rp(url) called in addapidata, addapidata called on next item in array. second .then() function in process1000 called, prematurely before has had chance resolve in promise.map. i've tried few different libraries make request they're having same issue. doing wrong here? appreciated. i think you'

javascript - How should I best search through a custom list generated dynamically based on id for a specific element? -

so, have scenario have list of div elements of class 'item', , want traverse through elements elements specific attribute. example html: <div> <div class='item' data-id='bob123'>bob</div> <div class='item' data-id='tedddd'>ted</div> <div class='item' data-id='mikester'>mike</div> <div class='item' data-id='joeyboy'>joe</div> </div> with list, current method of selecting specific element through dataset property, store person's id under data-id. using jquery, have: var specificelement = $('.item[data-id=(user id)]); then, perform operations on element such highlighting, showing , hiding. now, dilemma whether efficient method of sifting through list, since heard accessing dataset slow. should change html schema , store id different way (such using classlist)? hesitant on marking each id such user_bob123 since feel

vim - Replace character and the characters before and after text with pattern -

i need replace character pattern characters before selected character need replaced, using search , replace function. for instance: . has replace 1/2 , hugo.ignatz becomes hug1/2gnatz . how should go this? if understood right, want this? :%s#.[.].#1/2#g this replace x.y 1/2

java - Gson.toJson() misordering items -

i have output json: { "id": 42950262095, "name": "lol", "players": [ { "avatar": { "userid": 25771876384, "username": "yhht", "role": "leader", "level": 40, "league": 0, "trophies": 1011, "donatedtroops": 0, "receivedtroops": 0 } }, { "avatar": { "userid": 146035414262, "username": "ari", "role": "new member", "level": 8, "league": 0, "trophies": 428, "donatedtroops": 0, "receivedtroops": 0 } }, { "avatar": { "userid": 300659467521, "username": "cp 221", "role": "new

PHP/Laravel I can't seem to upload .GIF images -

what happens when upload regular images .jpeg, .jpg, .png files, uploads , posts on site nothing wrong. try upload .gif file. site refreshes, empties out input field, , prompts out error message saying field required (say's when input field empty). my method: public function upload(requests\createpostsrequest $request) { $target_dir = "uploads/"; $target_file = $target_dir . basename($_files['filetoupload']["name"]); $uploadok = 1; $findme = "."; $pos = strpos($target_file, $findme); //dd($_post); $imagefiletype = strtolower(substr($target_file,$pos+1)); if(isset($_post["submit"])) { $check = getimagesize($_files["filetoupload"]["tmp_name"]); //dd($check); if($check !== false) { echo "file image - " . $check["mime"] . "."; $uploadok = 1;

recursion - C# Recursivly populate treeview from paths in registry -

question : how can recursivly populate treeview multiple path values strings registry treeview nodes using c#? what do : recursivly populate treeview1 string values each registry value gathered in list[] array used listbox (listbox1) , ofcourse adding values registry not null . grateful or input problem. how load path treeview1 : private void populatetreeview() { try { treenode rootnode; nodeinfo ninfo; string path = global.getstartuppath(); directoryinfo info = new directoryinfo(path); if (info.exists) { rootnode = new treenode(info.name, 3, 3); rootnode.name = info.name; ninfo = new nodeinfo(nodeinfo.types.root, info.fullname); rootnode.tag = ninfo; getdirectories(info, rootnode); treeview1.nodes.add(rootnode);

Maven plugin - pass parameters to a lifecycle phase -

we have custom maven plugin generates code artifacts our project. plugin has configured lifecycle this, 'generate-resources' phase calling our custom class. <?xml version="1.0" encoding="utf-8"?> <component-set> <components> <component> <role>org.apache.maven.lifecycle.mapping.lifecyclemapping</role> <role-hint>zip</role-hint> <implementation>org.apache.maven.lifecycle.mapping.defaultlifecyclemapping</implementation> <configuration> <phases> <generate-resources>com.b.e:productconfig-maven-plugin:generate</generate-resources> <package>com.b.e:productconfig-maven-plugin:zip</package> <install>org.apache.maven.plugins:maven-install-plugin:install</install> <deploy>org.apache.maven.plugins:m

if statement - if else vs switch performance in java -

i wonder if there efficiency difference between using if statement or switch. example: if(){ \\code } else if(){ \\code } else{ \\code } i believe program needs go , check of if statement if first if statement true. switch(i){ case 1: //code break; case 2: \\code break; but in switch, there break command. approaching right? if not, explain efficiency difference between them? switch perf better if else in case of switch there 1 time evaluation . once evaluated switch knows case needs executed in case of if else has go through conditions in case of worst scenario. the longer list condition, better switch performance shorter list (just 2 conditions), can slower also from why switch faster if with switch jvm loads value compare , iterates through value table find match, faster in cases

c# - Issue with loaded Midi.Net DLL -

lately i'm having issues in different applications have made. of these applications use midi-controller send midi-notes lighting desk. issue same of these applications. in runtime, when i'm working on application, occurs complete application freezes. don't warningmessages, nor debugger popping tell me what's wrong. occurs when want play midi-note. thing can @ point, reboot entire machine, not funny. because application hangs , don't debugging information, i'm has dll use send midi-notes , there's issue there or in way have implemented dll. i've posted code below , appreciate it, if tell me i'm doing wrong? this de code in mainform initializing midi miditools midi; private void initmidi() { midi = new miditools(); midi.enabled = true; } the initmidi() called inside form_load-function. the code play midi-note is: midi.playnote(22,0) below code inside miditools-class file using midi; namespace miditest { class midito

c - Iterating over multiple file objects -

i iterate on list/array of file objects: file_x,file_y,file_z,..., calling function on each file object, in c. question how can create function take (i) file object, , (ii) string arguments function , write string file object. for loop execute function on list/array of file objects. void file_write(file_object, string_to_write){ fprintf(file_object, "%s\n", string_to_write); } research i have searched google, watched parts of several youtube tutorials , searched relevant questions on so, following best achieve. advice on how better answer above question, ideal function, appreciated. file *file_x, *file_y, *file_z, *file_vx, *file_vy file_x = fopen("./data/x.dat","w"); file_y = fopen("./data/y.dat","w"); file_z = fopen("./data/z.dat","w"); file_vx = fopen("./data/vx.dat","w"); file_vy = fopen("./vy.dat","w"); fprintf(file_x, "#x(t) coordinate

javascript - Jquery - Calling a ajax function within ajax function -

can use ajax function withing ajax function. in case there 2 ajax calls. first ajax return data , if successful second ajax should called . below code snippet, $.ajax({ type: "post", contenttype: "application/json; charset=utf-8", async: false, url: "my service url here" datatype = "json", //success - 1 success: function(data) { //i ll collect data service //now second ajax must run. //because in first call ll receive data //that data going use in second call $.ajax({ alert('inside ajax-2'); type: "get", contenttype: "application/json; charset=utf-8", async: false, url: "my second service url here", datatype: "json", //success - 2 success: function(data) {

excel - Syntax error in subroutine 'Test' -

i have following sub function in vba: sub test() index_match_array(range("d5").value,range("bz:bz").dataseries,"hardware",1,2) end sub this calls function starts: option explicit function index_match_array(loookup string, table_array range, criteria_search string, criteria_line_add integer, return_line_add integer) string() dim lookup_array() string dim result_array() string ... ... index_match_array = result_array end function when compile error message: compile error: syntax error i suspect it's second parameter, range one, i'm not sure? ' data series return type variant , change table_array variant ' function in array, change function index_match_array string option explicit sub test() dim sstring(10) string sstring(1) = index_match_array(range("d5").value, range("bz:bz").dataseries, "hardware", 1, 2) end sub function index_match_array(loookup string, table_

JSF Table Column Widths (Default behavior) -

can explain default behavior of columns? data in columns vary, wondering do evenly distribute, do give larger column larger data, smaller smaller ... is there minimum width give header, when determine going word wrap? there times not word wrap , make length wide need manually control width? my research tells me best way control via css? jsf h:datatable generates plain html <table> reacts html <table> . can refer answer if want know more default column width. anyhow, here how going react according questions : it not evenly distribute. larger data given more column width. a minimum header width not required. it word wrap when there no more available width not break words. also css not best way control table appearance recommended way.

go - How to access/Install/Setup Web Panel on live application RethinkDB -

i've looked extensively , hit many brick walls. we utilising rethinkdb in invmail.io portion of tech stack have acquired , intergrated lb source invite system, understand database driven. though finding experienced developers in rethinkdb's prooving quiet difficult, http://rethinkdb.com/docs/administration-tools/ . have web panel active yet can not find guide on how on live application can login , see invite , update wording. any advice appreciated. the dashboard should available without doing extra. when runs it, see thing like $ rethinkdb info: creating directory .../rethinkdb_data info: listening intracluster connections on port 29015 info: listening client driver connections on port 28015 info: listening administrative http connections on port 8080 info: server ready when run rethinkdb, web panel admin runs on port 8080 default.but default binds loopback address: 127.0.0.1 . when putting on production server, cannot access using server_ip:8080 . howe

Insert element into dynamic char array in C programming -

i having problem when trying add element dynamic char array in c programming. here expected output: how many characters want input: 5 input string:datas string is: datas want 1-insert or 2-remove or 3-quit?: 1 character want insert: resulting string: adata i did user input part in main function , here code in main take in string input, size , pass them insert(): printf("how many characters want input: "); scanf("%d", &n); str = malloc(n + 1); printf("input string class: "); scanf("%s", str); case '1': printf("what character want insert: "); scanf(" %c", &input); insert(str, input, n); break; and part insert(): void insert(char *str, char input, int n) { int i; size_t space = 1; (i = 0; < n; i++) { str[i] = (char)(input + i); space++; str = realloc(str, space); if (i > 2) { break; } } (i = 0; < n; i++) { printf("

php - CodeIgniter 3 Query ESCAPE '!' Ignoring the WHERE statement? -

i building site search select boxes categories & regions. if selected including in query, reason, using ignoring section of query!?!? why or doing wrong? when echo query built codeigniter fololowing: (note escape '!' ) query echo: select sql_calc_found_rows null rows, ads.id id, location, provlabel, text, adcat.id catid, ads.subcatid subcatid, ads.province r_rand, r_option, addate, adcat.name catname, adsubcat.name subname, f_value, adtitle, ads.area, regionlabel, adlink `ads` join `search_town` on `search_town`.`townid`=`ads`.`townid` join `search_region` on `search_region`.`regionid`=`ads`.`area` join `search_prov` on `search_prov`.`provid`=`ads`.`province` join `adcat` on `adcat`.`id`=`ads`.`catid` join `adsubcat` on `adsubcat`.`id`=`ads`.`subcatid` left join `adfields` on `adfields`.`ad_id`=`ads`.`id` `ads`.`catid` != 8 , `ads`.`adactive` = 1 , `scam` =0 , `ads`.`province` = '1' , `ads`.`catid` = '3' ,

python - Django field error messages -

Image
i have fields in django form require integer. default value in field '-'. means when user ignores field, form field error returned. annoyingly message has annoying 'u' in it. how rid of u? the html <div class="col-sm-1"> {% childform.age field %} <div class="form-group{% if field.errors %} has-error{% endif %}" id="children-age"> {{ field }} {% if field.errors %}<p class="help-block">{% error in field.errors %}{{ error }}{% endfor %}</p>{% endif %} </div> {% endwith %} </div> the error forms.py class travelgeneralenquiryform(forms.modelform): children = forms.choicefield(choices=(('','-'),) + tuple(((str(x), x) x in range(0, 11))), required=true) adults = forms.choicefield(choices=(('','-'),) + tuple(((str(x), x) x in range(1, 11))), required=true) pets = forms.choicefield(choices=((str(x), x) x in range(0

asp.net mvc - Multiple File Selector jquery plugin -

i used multifile , works great, can't customize files appeneded. don't want file uploader, tried blueimp , others want select mulitple images preview/remove , send them server side on form submit. is there way customize multifire or other plugin that's customizable?? or way values blue imp on form submit rather directly upload? i'm using asp.net mvc 5 record. thanks in advance you may use dropzone customizable html5 upload plugin

android - Disadvantages of cross-platform mobile app development using Visual Studio -

microsoft has introduced new visual studio, compatibility develop multi-platform applications android, ios , windows. this news, developers, large , reliable company produced such thing. can make life easier, lot. but, know, there disadvantages when advantages. want know: 1) difference between developing native apps each platform, , using kind of tools? disadvantage compared using example objective-c or java ios , android separately? 2) there dependencies in order running developed apps on different oss? .net framework? 3) there performance cost? or works native ones? 4) kind of apps supposed developed such tools? in point of view , not idea develop android or ios application in xamarin. first of performance issue occurs. can not achieve performance native application. there dependencies xamarin compiles c# native code, still relies on mono runtime lot of work. native, no cheating – native. there overhead, isn’t objectivec native. apps going larger – minor st

javascript - Email validation for specific domain not working -

i have following form register.php <form class="form" action="home.php" method ="post" enctype="application/x-www-form-urlencoded"> <input type="email" name="email" placeholder="email address" id="email"/> home.php <script = "text.javasccript> $('button').on('click', function(){ str = $('input').val(); str = str.split('@').slice(1); var alloweddomains = [ 'correct.com' ]; if ($.inarray(str[0], alloweddomains) !== -1) { alert(str + ' allowed'); }else{ alert('not allowed'); } }); </script> i know question has been asked before there no actual answers it. where integrate following function work registration form this new, edited code doesnt work can help? my output message 1 saying domain not allowed when type 'allowed' domain in. here code: regis

session - Page returns blank when running the following PHP code(503) -

i running code that's supposed pull questionnaire database evaluation user valid session. however, page returns blank incomplete page while running php code. am missing here? <?php session_start(); try { if(!isset($_session['logged-in'])) { header("location: ../index.php"); } } catch(exception $e) { } // php classes require_once("../classes/database.php"); require_once("../classes/questionnaire.php"); require_once("../classes/competency.php"); require_once("../classes/candidate.php"); require_once("../classes/participant.php"); require_once("../classes/progress.php"); require_once("../classes/user.php"); require_once("../classes/page.php"); // candidate details if($_session['usertype'] == 'candidate') // if user doing self evaluation {