Monday 15 June 2015

entity framework - AsQueryable().ToList() not returning any result in C# -



entity framework - AsQueryable().ToList() not returning any result in C# -

i have implemented odata web service. in url passing on odata queries , in controller have used

var obj1 = [dbcontext class object].[dbset].asqueryable();

i want convert obj1 list() , info manipulation on it.so used

var obj1 = [dbcontext class object].[dbset].asqueryable().tolist();

but not getting response, debugged code, went in long time line. have searched lot solution no luck. please help.

thanks in advance.

c# entity-framework odata

orientdb - Renaming existing edge relationships? -



orientdb - Renaming existing edge relationships? -

is there simple way update name of of type of existing border relationships?

alter class edge_name name new_edge_name

updates name of base of operations border class, doesn't impact existing relationships.

ie:

create class person extends v create class auto extends v create class owns extends e create vertex person set name="bob" create vertex auto set name="jeep" create border owns (select person name="bob") (select auto name="jeep") alter class owns name drives

does nil delete old border type , create new border type, leaving existing relationship unaffected (bob still owns jeep, yet owns doesn't exist)

what supposed if thousands of these relationships exist?

you should rename attributes next commands re-create new name , drop previous ones both in , out directions:

update v set out_drives = out_owns out_owns not null update v set in_drives = in_owns in_owns not null update v remove out_owns out_owns not null update v remove in_owns in_owns not null

orientdb

c# - Entity Framework 6 two different collections referring same entity -



c# - Entity Framework 6 two different collections referring same entity -

i got next scenario:

users can presidents or managers of communities. when specifying navigation property connect community president , manages, got this:

public class community { ... [foreignkey("president")] public int? presidentid { get; set; } public virtual user president { get; set; } [foreignkey("manager")] public int? managerid { get; set; } public virtual user manager { get; set; } }

but here comes part can't find solution. have 2 collections on users reffering each communities manage, , ones preside:

public class user { ... public virtual icollection<community> managedcommunities { get; set; } public virtual icollection<community> presidedcommunities { get; set; } }

and can't find documentation on how create first 1 point ones user manages , sec ones he's presising. in advance.

as documented in code first info annotations (msdn), can utilize inverseproperty attribute.

[inverseproperty("manager")] public virtual icollection<community> managedcommunities { get; set; } [inverseproperty("president")] public virtual icollection<community> presidedcommunities { get; set; }

c# entity-framework

order - Ordering values within each factor in R -



order - Ordering values within each factor in R -

i have been having problem while , have been using time consuming methods this. know there must improve way this. suppose have next data:

set.seed(123) grouping <- c(rep("a",3),rep("b",3),rep("c",3)) score <- runif(9) score.2 <- rnorm(9) df <- data.frame(group,score,score.2) df grouping score score.2 1 0.2875775 -0.1089660 2 0.7883051 -0.1172420 3 0.4089769 0.1830826 4 b 0.8830174 1.2805549 5 b 0.9404673 -1.7272706 6 b 0.0455565 1.6901844 7 c 0.5281055 0.5038124 8 c 0.8924190 2.5283366 9 c 0.5514350 0.5490967

what want similar info top 2 values score each factor or character column (might different if grouping factor class or character class?), want score.2 remain in data. final output should have 6 rows of data. can help me out?

one alternative slice dplyr 0.3 devel version

library(dplyr) df%>% group_by(group)%>% arrange(desc(score))%>% slice(1:2) #or # do(head(., 2)) # in `dplyr 0.2` # source: local info frame [6 x 2] #groups: grouping # grouping score score.2 #1 0.7883051 -0.1172420 #2 0.4089769 0.1830826 #3 b 0.9404673 -1.7272706 #4 b 0.8830174 1.2805549 #5 c 0.8924190 2.5283366 #6 c 0.5514350 0.5490967

using data.table

library(data.table) setdt(df)[order(group, -score), head(.sd,2), by=group] # grouping score score.2 #1: 0.7883051 -0.1172420 #2: 0.4089769 0.1830826 #3: b 0.9404673 -1.7272706 #4: b 0.8830174 1.2805549 #5: c 0.8924190 2.5283366 #6: c 0.5514350 0.5490967

r order

ios - Instruments Indicates Memory Leak on Instantiation of NSMutableDictionary -



ios - Instruments Indicates Memory Leak on Instantiation of NSMutableDictionary -

locating memory leaks not strong suit, appears me instruments indicating memory leak upon creation of, , setting of values for, nsmutabledictionary. (i using arc). makes no sense me of yet, might know happening.

i have delegate method called on completion of taking photo device's camera: (i have added comment lines raising issue).

- (void)finishimagecaptureforbuffer:(cmsamplebufferref)imagedatasamplebuffer witherror:(nserror *)error shouldsave:(bool)save { //do stuff... if (save) { cfdictionaryref attachments = cmcopydictionaryofattachments(kcfallocatordefault, self.imagedatasamplebuffer, kcmattachmentmode_shouldpropagate); cfmutabledictionaryref mutableattachments = cfdictionarycreatemutablecopy(null, 0, attachments); //memory leak!!!!!// nsmutabledictionary *gps = [nsmutabledictionary dictionary]; cllocation *location = [manager location]; [gps setobject:@"" forkey:(nsstring *)kcgimagepropertygpsversion]; nsdateformatter *formatter = [[nsdateformatter alloc] init]; [formatter setdateformat:@"hh:mm:ss.ssssss"]; [formatter settimezone:[nstimezone timezonewithabbreviation:@"utc"]]; //memory leak!!!!!// [gps setobject:objectornull([formatter stringfromdate:location.timestamp]) forkey:(nsstring *)kcgimagepropertygpstimestamp]; [gps setobject:(location.coordinate.latitude < 0) ? @"s" : @"n" forkey:(nsstring *)kcgimagepropertygpslatituderef]; //memory leak!!!!! [gps setobject:objectornull([nsnumber numberwithdouble:fabs(location.coordinate.latitude)]) forkey:(nsstring *)kcgimagepropertygpslatitude]; [gps setobject: (location.coordinate.longitude < 0) ? @"w" : @"e" forkey:(nsstring *)kcgimagepropertygpslongituderef]; //memory leak!!! [gps setobject:objectornull([nsnumber numberwithdouble:fabs(location.coordinate.longitude)]) forkey:(nsstring *)kcgimagepropertygpslongitude]; cfdictionarysetvalue(mutableattachments, kcgimagepropertygpsdictionary, cfbridgingretain(gps)); nsdata *imagedata = [avcapturestillimageoutput jpegstillimagensdatarepresentation:self.imagedatasamplebuffer]; alassetslibrary *library = [[alassetslibrary alloc] init]; [library writeimagedatatosavedphotosalbum:imagedata metadata:(__bridge id)mutableattachments completionblock:completionblock]; if ([[self delegate] respondstoselector:@selector(capturemanagerstillimagecaptured:)]) { [[self delegate] capturemanagerstillimagecaptured:self]; } cfrelease(attachments); cfrelease(mutableattachments); cfrelease(self.imagedatasamplebuffer); } else { ...

where objectornull checks see if value inserting exists, , if not, [nsnull null] added dictionary.

as aside, issue appears when running ios7 not ios8.

try replacing

cfdictionarysetvalue(mutableattachments, kcgimagepropertygpsdictionary, cfbridgingretain(gps));

with

cfdictionarysetvalue(mutableattachments, kcgimagepropertygpsdictionary, (__bridge cfdictionaryref)gps);

ios memory-management memory-leaks instruments nsmutabledictionary

android: connecting mysql through php (WAMP setup) - app crashes -



android: connecting mysql through php (WAMP setup) - app crashes -

i new android advise helpful.

i trying connect mysql through php app crashes while trying connect.

private class processlogin extends asynctask<string, string, jsonobject> { private progressdialog pdialog; string email,password; @override protected void onpreexecute() { super.onpreexecute(); inputemail = (edittext) findviewbyid(r.id.email); inputpassword = (edittext) findviewbyid(r.id.pword); email = inputemail.gettext().tostring(); password = inputpassword.gettext().tostring(); pdialog = new progressdialog(login.this); pdialog.settitle("contacting servers"); pdialog.setmessage("logging in ..."); pdialog.setindeterminate(false); pdialog.setcancelable(true); pdialog.show(); } protected jsonobject doinbackground(string... args) { userfunctions userfunction = new userfunctions(); jsonobject json = userfunction.loginuser(email, password); homecoming json; }

the db_config file like:

define('db_user', "root"); // db user define('db_password', ""); // db password (mention db password here) define('db_database', "aap1"); // database name define('db_server', "localhost"); // db server

i have added table entry in database.

moreover, function calls below:

public jsonobject loginuser(string email, string password){ // building parameters list<basicnamevaluepair> params = new arraylist<basicnamevaluepair>(); params.add(new basicnamevaluepair("tag", custlogin_tag)); params.add(new basicnamevaluepair("email", email)); params.add(new basicnamevaluepair("password", password)); jsonobject json = jsonparser.getjsonfromurl(loginurl, params); homecoming json; } private static string loginurl = "http://127.0.0.1/app1/index.php";

below logcat:

10-07 23:22:40.596: e/buffer error(2003): error converting result java.lang.nullpointerexception: lock == null 10-07 23:22:40.676: e/json parser(2003): error parsing info org.json.jsonexception: end of input @ character 0 of 10-07 23:22:40.766: e/androidruntime(2003): fatal exception: main 10-07 23:22:40.766: e/androidruntime(2003): process: com.example.app1, pid: 2003 10-07 23:22:40.766: e/androidruntime(2003): java.lang.nullpointerexception 10-07 23:22:40.766: e/androidruntime(2003): @ com.example.app1.login$processlogin.onpostexecute(login.java:180) 10-07 23:22:40.766: e/androidruntime(2003): @ com.example.aap1.login$processlogin.onpostexecute(login.java:1) 10-07 23:22:40.766: e/androidruntime(2003): @ android.os.asynctask.finish(asynctask.java:632) 10-07 23:22:40.766: e/androidruntime(2003): @ android.os.asynctask.access$600(asynctask.java:177) 10-07 23:22:40.766: e/androidruntime(2003): @ android.os.asynctask$internalhandler.handlemessage(asynctask.java:645) 10-07 23:22:40.766: e/androidruntime(2003): @ android.os.handler.dispatchmessage(handler.java:102) 10-07 23:22:40.766: e/androidruntime(2003): @ android.os.looper.loop(looper.java:136) 10-07 23:22:40.766: e/androidruntime(2003): @ android.app.activitythread.main(activitythread.java:5017) 10-07 23:22:40.766: e/androidruntime(2003): @ java.lang.reflect.method.invokenative(native method) 10-07 23:22:40.766: e/androidruntime(2003): @ java.lang.reflect.method.invoke(method.java:515) 10-07 23:22:40.766: e/androidruntime(2003): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 10-07 23:22:40.766: e/androidruntime(2003): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 10-07 23:22:40.766: e/androidruntime(2003): @ dalvik.system.nativestart.main(native method)

json parser follows:

`public jsonobject getjsonfromurl(string url, list<?> params) { // making http request seek { // defaulthttpclient defaulthttpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(url); httppost.setentity(new urlencodedformentity ((list<? extends namevaluepair>) params)); httpresponse httpresponse = httpclient.execute(httppost); httpentity httpentity = httpresponse.getentity(); = httpentity.getcontent(); } grab (unsupportedencodingexception e) { e.printstacktrace(); } grab (clientprotocolexception e) { e.printstacktrace(); } grab (ioexception e) { e.printstacktrace(); }`

and php script is:

`if ($tag == 'login') { // request type check login $email = $_post['email']; $password = $_post['password']; // check user $user = $db->getuserbyemailandpassword($email, $password); if ($user != false) { // user found // echo json success = 1 $response["success"] = 1; $response["user"]["email"] = $user["email"]; $response["user"]["uname"] = $user["username"]; $response["user"]["uid"] = $user["unique_id"]; $response["user"]["created_at"] = $user["created_at"]; echo json_encode($response); } else { // user not found // echo json error = 1 $response["error"] = 1; $response["error_msg"] = "incorrect email or password!"; echo json_encode($response); }`

and db function is:

` public function getuserbyemailandpassword($email, $password) {         $result = mysqli_query("select * users email = '$email'") or die(mysqli_error());         // check result         $no_of_rows = mysqli_num_rows($result);         if ($no_of_rows > 0) {             $result = mysqli_fetch_array($result);             $salt = $result['salt'];             $encrypted_password = $result['encrypted_password'];             $hash = $this->checkhashssha($salt, $password);             // check password equality             if ($encrypted_password == $hash) {                 // user authentication details right                 return $result;             }         } else {             // user not found             return false;         }    }`

i have tested db connection testmysql.php , fine.

change

list<basicnamevaluepair> params = new arraylist<basicnamevaluepair>();

as list<namevaluepair> params = new arraylist<namevaluepair>();

android mysql

math - Calculate differential in Fortran -



math - Calculate differential in Fortran -

i want calculate w j=0 n in below function. there written library in fortran?

actually want write programme n user, , print w in output. shall differential , creating equation ln(x)?

that recurrence relation generate n-th order legendre polynomial, , xj , wj, assume writing programme perform gauss-legendre integration (no thought why q(x) there).

this florida state page provides lgpl fortran90 program calculates nodes , weights using tridiagonal-eigenvalue method , writing them external file. seek , collect of contained functions , place them module run-time calculation of nodes , weights.

math fortran mathematical-optimization fortran90 fortran95

c++ cli - how to return byte array , uint value from c# dll, dll called by c++/cli -



c++ cli - how to return byte array , uint value from c# dll, dll called by c++/cli -

i writing c# dll calculate , produce:-

-byte array [byte array] -unit [2 byte error code] -bool [true/false success , failure]

this function called c++/cli project. function can homecoming 1 value need these 3 values after c# function execute.

what function prototype in c# , how called c++/cli code.

thanks in advance

maybe can utilize out modifier.

void mymethod(out byte[] ba, out short code, out bool success) { ... }

as here, phone call be:

array<system::byte>^ ba; int16 code; bool success; myclass::mymethod(ba, code, success);

i tested it. hope helps.

c# c++-cli

symfony2 - JMS Serializer: Dynamically change the name of a virtual property at run time -



symfony2 - JMS Serializer: Dynamically change the name of a virtual property at run time -

i utilize jms serializer bundle , symfony2. using virtualproperties. currently, set name of property using serializedname annotation.

/** * @jms\virtualproperty() * @jms\serializedname("some_name") */ public function getsomething() { homecoming $this->something }

is possible set serialized name dynamically within function? or possible dynamically influence name using post/pre serialization events?

thanks!

i don't think can directly, accomplish similar having several virtual properties, 1 each possible name. if name not relevant particular entity, have method homecoming null, , disable null serialization in jms config.

symfony2 jmsserializerbundle jms-serializer

sql - Display content to certain rank PHP -



sql - Display content to certain rank PHP -

i'm creating simple staff panel consists of 10 pages , uses single sql table. sql table consists of user_id, user_name, user_email, password , rank

i'm trying display specific content based on users rank in database although, i'm beginner @ php i'm not sure if i'm pulling database properly.

$sql = "select user_name, user_email, user_password_hash, user_id, rank users user_name = '" . $user_name . "' or user_email = '" . $user_name . "';"; $result_of_login_check = $this->db_connection->query($sql); // if user exists if ($result_of_login_check->num_rows == 1) { // result row (as object) $result_row = $result_of_login_check->fetch_object(); // using php 5.5's password_verify() function check if provided password fits // hash of user's password if (password_verify($_post['user_password'], $result_row->user_password_hash)) { // write user info php session (a file on server) $_session['user_name'] = $result_row->user_name; $_session['rank'] = $result_row->rank; $_session['user_email'] = $result_row->user_email; $_session['user_login_status'] = 1;

this login.php file. code i'm using seek , display specific rank.

i've managed display depending on users name leads me believe haven't called rank properly.

<?php if (isset($_session['rank']) && $_session['rank'] == admin) { echo '<a href="/admin/" class="btn btn-danger">admin</a>'; } else { echo " "; } ?>

if code have posted exact same code have on files, believe next line of code problem:

if (isset($_session['rank']) && $_session['rank'] == admin) {

unless admin been defined through define function take it string, hence code should be:

if (isset($_session['rank']) && $_session['rank'] == 'admin') {

or:

if (isset($_session['rank']) && $_session['rank'] == "admin") {

either single or double quotes fine. don't see other reason code fail.

i hope helps.

follow up:

you can utilize next piece of code utilize different ranks per comment:

if (isset($_session['rank'])) { if ($_session['rank'] == 'admin') { // admin } elseif ($_session['rank'] == 'mod') { // mod } elseif ($_session['rank'] == 'member') { // fellow member } }

you can utilize switch / case clause:

if (isset($_session['rank'])) { switch ($_session['rank']) { case: 'admin': // admin break; // not forget breaks! case: 'mod': // mod break; case: 'member': // fellow member break; } }

hope helps more.

php sql

javascript - JS how to call this function? -



javascript - JS how to call this function? -

how can phone call 'del' function? because name.del() , this.name no work :(

var name = function(){ this.del = function(){ } name.del(); // no work this.del(); // no work }

in order help you, must understand trying do. if solely want phone call function in anonymous one, this:

var name = function(){ function del(){ } del(); }

however, if utilize name in class-instance way, on right track.

function myclass(){ this.del = function(){ } } // instantiate var name = new myclass(); name.del();

there numerous additional ways to things. shoud go heavily depends on utilize case.

javascript

parsing - How to parse form elements from html response -



parsing - How to parse form elements from html response -

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="head1"><title> online-edu-help.com </title></head> <body> <form name="form1" method="post" action="post.aspx" id="form1"> <input type="hidden" name="__viewstate" id="__viewstate" value="/wepdwukmtyxntmxotk3mgrktkizyxxt1usqvfzywkcnecsqxls=" /> <span id="lblerror"></span> <span id="lblnoerror">accepted: 3231401</span> <br /> </form> </body> </html>

i want parse value of lblerror , lblnoerror above html response in php.

<?php $html = '<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="head1"><title> online-edu-help.com </title></head> <body> <form name="form1" method="post" action="post.aspx" id="form1"> <input type="hidden" name="__viewstate" id="__viewstate" value="/wepdwukmtyxntmxotk3mgrktkizyxxt1usqvfzywkcnecsqxls=" /> <span id="lblerror"></span> <span id="lblnoerror">accepted: 3231401</span> <br /> </form> </body> </html>'; $dom = new domdocument(); $dom->loadhtml($html); $lblnoerror = $dom->getelementbyid('lblnoerror'); echo $lblnoerrorvalue = $lblnoerror->nodevalue; $lblerror = $dom->getelementbyid('lblerror'); echo $lblerrorvalue = $lblerror->nodevalue; ?>

parsing domdocument simpledom

oop - private method in an javascript object -



oop - private method in an javascript object -

i've object looks this:

var obj ={ property : '', myfunction1 : function(parameter){ //do stuff here } }

i need set private properties , functions, can not accessed/seen outside of object. not working var property:, or var myfunction1

next question is, if phone call function within or outside object, have obj.myfunction(). asign "this" variable. self : this. , phone call within object functions , variables self.property , self.myfunction.

how? :)

there many ways this. in short: if dou define function within function, inner function private, long not provide reference if.

(function obj(){ var privatemethod = function() {}; var publicmethod = function() { privatemethod(); ... }; homecoming { pubmethod: publicmethod } }());

javascript oop object private

java - Can JMX work asynchronously and how performant is this technology? -



java - Can JMX work asynchronously and how performant is this technology? -

i know jmx technology allows talk remotely among jvms making rpc phone call synchronous.

can jmx work asynchronously (with listeners example)? assume hundreds of agents create rpc jmx phone call same function on 1 jvm-process simultaneously. more performant respond asynchronously jvm? possible. has mbean server internally threadpool (a thread per jmx-connection) connection-management?

java asynchronous jmx

jquery - Preventing form submittion with enter key on all but one submit button -



jquery - Preventing form submittion with enter key on all but one submit button -

i have aspx web form master page contains 2 submit buttons, 1 business relationship login , 1 site search. want come in key submit login not other button on site login more used. every time nail come in after entering login info search button fires , brings me empty results page. next i've tried without success:

1) create login button type=submit , others type=button

2) set usesubmitbehavior="false" buttons except login set true.

3) utilize various jquery code on id of inputs disable keydown event come in key.

the code had effect following, disable come in key every thing. when substituted window selector failed work. since whole page form did not add together additional form tags. there must way allow come in key work on 1 button. thanks

$(function () { $(window).keydown(function (event) { if (event.keycode == 13) { event.preventdefault(); homecoming false; } }); }); search: <div id="searchform"> <fieldset> <asp:textbox id="searchquery" runat="server" size="15" /> </fieldset> <asp:imagebutton id="searchbutton" runat="server" onmouseover="this.src='/resources/buttons/search_hover.png'" onmouseout="this.src='/resources/buttons/search_active.png'" imageurl="/resources/buttons/search_active.png" type="button" style="font-size: 11px;" class="searchbtn" alt="search" onclick="searchbutton_click" usesubmitbehavior="false" causesvalidation="false" /> </div> login: <div id="logonbox"> <asp:label id="label1" class="loginlabel1" runat="server" text="account number"></asp:label> <asp:textbox id="acctnum" class="acctnumtexbox" runat="server"></asp:textbox> <asp:label id="label2" runat="server" class="loginlabel2" text="access code"></asp:label> <asp:textbox id="mtrnum" class="mtrnumtexbox" runat="server"></asp:textbox> <asp:imagebutton id="login1" type="submit" runat="server" class="boxsubmitbtn" src="/resources/buttons/login.gif" onclick="loginbtn_click" usesubmitbehavior="true" causesvalidation="false" /> <p> <a href="/accounts/accounts.aspx">need help logging in?</a> </p> </div>

there many ways accomplish want, easiest find is:

in code behind, in page load method add together line :

protected void page_load(object sender, eventargs e) { this.form.defaultbutton = login1.uniqueid; }

jquery webforms master-pages form-submit enter

javascript - Multiple baseUrl in RequireJS config -



javascript - Multiple baseUrl in RequireJS config -

i have 2 locations javascript files, possible set 2 baseurls can move them later without having update loads of paths?

e.g.:

require.config({ baseurl: 'bower_components', paths: { backbone: 'backbone/backbone', underscore: 'underscore/underscore' } }); requirejs.config({ baseurl: 'js', paths: { main: 'main' } });

this format overwrites baseurl on sec call. declare 2 variables hold this, there more elegant, requirejs-ish way of doing this?

i don't believe possible. require's not going seek loading 1 base-url , fall retry others upon failure. if don't want paths in scripts' require calls can consider specifying bundles. see configuration docs. set path config app js/main.

javascript requirejs

java - String passed from Android POST request to PHP in sevrer not being recognized properly in MySQL SELECT query -



java - String passed from Android POST request to PHP in sevrer not being recognized properly in MySQL SELECT query -

i've been hacking @ 1 while, can't find reason next behavior:

i have android app send multipart/form-data http post. request has next form:

private final string delimiter = "--"; private final string boundary = "swa" + long.tostring(system.currenttimemillis()) + "swa"; private final string charset = "utf-8"; private final string linespace = "\r\n"; private final string domain = (domain); private httpurlconnection configureconnectionformultipart(string url) throws malformedurlexception, ioexception { httpurlconnection con = (httpurlconnection) (new url(url)) .openconnection(); con.setrequestmethod("post"); con.setdoinput(true); con.setdooutput(true); con.setrequestproperty("connection", "keep-alive"); con.setrequestproperty("content-type", "multipart/form-data;boundary=" + boundary); homecoming con; } private void addformpart(string paramname, string value, dataoutputstream os) throws ioexception { os.writebytes(linespace + delimiter + boundary + linespace); os.writebytes("content-disposition: form-data; name=\"" + paramname + "\"" + linespace); os.writebytes("content-type: text/plain; charset=" + charset + linespace); os.writebytes(linespace + value + linespace); os.flush(); } private void addfilepart(string paramname, file data, dataoutputstream os) throws ioexception { os.writebytes(linespace + delimiter + boundary + linespace); os.writebytes("content-disposition: form-data; name=\"" + paramname + "\"" + linespace); os.writebytes("content-type: application/octet-stream\r\n"); os.writebytes("content-transfer-encoding: binary" + linespace); os.writebytes(linespace); os.flush(); fileinputstream fis = new fileinputstream(data); byte[] buffer = new byte[4096]; int bytesread = -1; while ((bytesread = fis.read(buffer)) != -1) { os.write(buffer, 0, bytesread); } os.writebytes(linespace); os.flush(); fis.close(); } private void finishmultipart(dataoutputstream os) throws ioexception { os.writebytes(linespace); os.flush(); os.writebytes(delimiter + boundary + delimiter + linespace); os.close(); } private string getresponse(httpurlconnection con) throws ioexception { string response = ""; int status = con.getresponsecode(); if (status == httpurlconnection.http_ok) { bufferedreader reader = new bufferedreader(new inputstreamreader( con.getinputstream())); string line = ""; while ((line = reader.readline()) != null) { response += line; } reader.close(); } else { bufferedreader reader = new bufferedreader(new inputstreamreader(con.geterrorstream())); string line = ""; while ((line = reader.readline()) != null) { response += line; } reader.close(); throw new ioexception("server returned non-ok status: " + status+", "+response); } homecoming response; } public searchqueryrunnable initsearchqueryrunnable(string query) { homecoming new searchqueryrunnable(query); } private class searchqueryrunnable implements runnable { private final string _query; private final string _url = domain + "search_query.php"; public searchqueryrunnable(string query) { _query = query; } @override public void run() { seek { httpurlconnection con = configureconnectionformultipart(_url); dataoutputstream os = new dataoutputstream( con.getoutputstream()); addformpart("tag", _query, os); finishmultipart(os); string result = getresponse(con); log.i("searchquery", result); con.disconnect(); } grab (malformedurlexception e) { e.printstacktrace(); } grab (ioexception e) { e.printstacktrace(); } } }

in search_query.php, have following:

include 'hashtags_table_api.php'; $tag = $_post["tag"]; $res = queryhashtagstable($tag);

in hashtags_table_api.php, there is:

include 'connect.php'; function queryhashtagstable($hashtag) { global $pdo; $sql = "select * `tbl_hashtags` hashtag = :hashtag"; $stmt = $pdo->prepare ( $sql ); echo $hashtag; $stmt->bindvalue(':hashtag', $hashtag); if ($stmt->execute()) { $result = $stmt->fetchall(); echo count($result); } }

connect.php (omitted of import variables):

try { $pdo = new pdo ( "mysql:host=$host;dbname=$dbname;charset=utf8", $username, $password ); $pdo->setattribute(pdo::attr_emulate_prepares, false); $pdo->setattribute(pdo::attr_errmode, pdo::errmode_exception); echo 'connected database'; } catch(pdoexception $e) { echo $e->getmessage(); }

when run code , pass value "hash" initsearchqueryrunnable, result of 0, though have row value "hash" in column hashtag. what's weird when hardcode next in search_query.php:

include 'hashtags_table_api.php'; $tag = 'hash'; $res = queryhashtagstable($tag);

i desired result of 1 query. double checked , $_post["tag"] passing value 'hash' server, reason sql query not recognize beingness equal value in db, though exact same hardcoded value recognized beingness equal.

any clue else need in order have dynamically-passed parameter recognized equal value mysql data?

edit

after testing, realized $_post["tag"] coming through quotes, , strlen[$tag] = 6. think might reason why sql isn't matching query string what's in db. sure plenty strlen['hash'] = 4, sql matches query. how can remove quotation marks value of of $tag, query works? fyi, server running php 5.4.24, if that's relevant.

i solved own problem here. turns out text beingness sent through http post had 2 invisible whitespaces observe tests using strlen , using statement see spaces beingness appended. solution utilize trim() function (http://php.net/manual/en/function.trim.php) , add together $tag = trim($tag) search_query.php before running queryhashtagstable($tag). hope helps else doesn't realize http post request beingness sent invisible characters , needs exact string sql query.

java php android mysql mysqli

Verify Email Entered in a Google Form Using Google Apps Script -



Verify Email Entered in a Google Form Using Google Apps Script -

my question same question [here], asnwer given not detailed enough. want have users submit email address in google form. email address used periodically send emails people have entered information. however, don't want users able come in random email address spam people. therefore, want verify user has entered email address belonging themselves, similar things such adding secondary email address in gmail. i not want know how check proper syntax.

to rephrase: want verify email entered user belongs user.

generate random verification id var characterstouse = "0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; //set length of id number generate. var varlngthid = 5; var makepubid = ''; (var i=0; i<varlngthid; i++) { var randnum = math.floor(math.random() * characterstouse.length); makepubid += characterstouse.substring(randnum,randnum+1); };

and send number user in initial email. when user gets email, can come site, , come in verification code. if want check if email valid without sending email address, question has been asked here:

stackoverflow check email without sending it

email google-apps-script google-spreadsheet google-form

html - saving multiple checkbox to database in PHP -



html - saving multiple checkbox to database in PHP -

i having problem in printing values of different checkbox same name & different values..

php

//$infect_type=array(); $infect_type = isset($_post['infect_type']) ? $_post['infect_type'] : null; $values= implode(",",$infect_type); print_r($values);

html

<input type="checkbox" name="infect_type" value="blood born" /> <input type="checkbox" name="infect_type" value="air born" />

i can value selected lastly before submitting.

use array notation checkboxes names:

<input type="checkbox" name="infect_type[]" value="blood born" /> <input type="checkbox" name="infect_type[]" value="air born" />

in case $_post['infect_type'] going array of checked values.

php html

Error while adding cordova platform ios -



Error while adding cordova platform ios -

i update cordova version 3.6.0 4.0.0, latest 1 on today's date. allow add together me android platform while going add together ios platform gives next error.

unable fetch platform ios: error: no compatible version found: cordova-ios@'>=8458588.0.0-0 <8458589.0.0-0' valid install targets: ["3.5.0","3.6.0","3.6.1","3.6.3"]

i have xcode6 install on system. can't figure out problem.

i solve problem, re installing cordova using command $ sudo npm install -g cordova

cordova cordova-3

Allow 2 duplicate ip addresses maximum php csv -



Allow 2 duplicate ip addresses maximum php csv -

i have issue processing script. allow 2 duplicate ip addresses maximum in csv file, prevent spamming , take consideration user create error in form fill. cant seem reference $ip variable correctly in script, or there might missing altogether. here code snippet far:

<?php #variable declarations (filename , post vars) go here $counter = 0; if (file_exists($filename)) { $file = fopen($filename, "a"); while($data = fgetcsv($filename)){ if(isset($data[$ip])){ $counter++; continue; if((isset($data[$ip])){ $counter++; if($counter == 2){ echo ""; } } } } ##file write goes here } ?>

any help on appreciated,

jim

you have read elements in array first , after have number of occurrences of each ip address ready, should go ahead writing file (a separate file may be?).

you can first prepare array ip indexes , rows corresponding ip value attributes key. done -

$csvarray = str_getcsv(file_get_contents('mycsvfile.csv')); foreach($csvarray $eachrow) { //prepare ip indexed array every detail row attribute of corresponding ip key. $properlyformattedarray[$eachrow[5]][] = $eachrow; }

you array -

array(['92.27.21.171'] => [0] => array("mr","test","davis","07972889989","01159174767","92.27.21.171"), [1] => array("mr","bob","jones","07998998008","01159174767","92.27.21.171"), ... ['92.27.21.172'] => ... )

once have array, loop on it, , write @ max 2 rows every ip.

foreach($properlyformattedarray $ip => $details) { $count = 0; foreach($details $eachdetail) { if($count<2) { //write $eachdetail file $count++; } } }

but, in case, order of info (compared input file) changed, , duplicates written in consecutive rows in csv file (not sure if okay it).

php csv ip

jquery - Adding image by javascript changes position -



jquery - Adding image by javascript changes position -

i beginner in web development, trying learn, doing little game in html without using canvas. game consists of table of boxes , user can navigate through them using arrow keys , can add together image current box pressing enter.

when press enter, position of box on page changes, goes little original position. can't post image new site, link image instead.

https://www.dropbox.com/s/er6e0ez6w0fd149/screenshot_1.png?dl=0

class="snippet-code-js lang-js prettyprint-override"> //loading constant.js $.getscript("constants.js", function(){ // loaded }); /*var stage = document.getelementbyid("gamecanvas"); stage.width = stage_width; stage.height = stage_height; var ctx = stage.getcontext("2d"); ctx.fillstyle = "black"; ctx.font = game_fonts; */ var gameloop = setinterval(update, time_per_frame); var counter = 0; var current_x = starting_x + 1; var current_y = starting_y; var element = current_y.tostring() + current_x.tostring();; var element; // updating selected box. function positionupdate() { element = current_y.tostring() + current_x.tostring(); document.getelementbyid(element).focus(); //------------- //disabling tabs //------------- $.prototype.disabletab = function() { this.each(function() { $(this).attr('tabindex', '-1'); }); }; $('button').disabletab(); } //------------ //game loop //------------ function update() { counter++; //clear canvas //ctx.fillstyle = "#aaa"; //ctx.fillrect(0, 0, stage.width, stage.height); //draw timer //ctx.fillstyle = "white"; //ctx.filltext("time is: "+counter, counter_x, counter_y); } //------------ //key handlers //------------ function keyuphandler(event) { var keypressed = event.which || event.keycode; if (keypressed == 38) //up key { if(current_y>0) { current_y--; } else { current_y = 9; } changefocus(); } else if (keypressed == 40) //down key { if(current_y<9) { current_y++; } else { current_y = 0; } changefocus(); } else if (keypressed == 39) //right key { if(current_x<9) { current_x++; } else { current_x = 0; } changefocus(); } else if (keypressed == 37) //left key { if(current_x>0) { current_x--; } else { current_x = 9; } changefocus(); } else if (keypressed == 13) // come in key { var selection = document.activeelement if(document.activeelement.haschildnodes()) { } else { document.activeelement.innerhtml = "<img src='canal control.png' width='50'>"; } } else { // nil other keys. } } //------------- //changing location on key press //------------- function changefocus() { positionupdate(); } class="snippet-code-css lang-css prettyprint-override">body { margin: 0; padding: 0; } #main{ cursor: none; width: 600px; height: 600px; background-color: #53b1f5; text-align: center; margin-left: auto; margin-right: auto; } button { cursor: none; /*disabling cursors*/ pointer-events: none; /*disabling mouse clicks*/ width: 50px; padding: 0px; height: 50px; border: 2px solid; border-color: white; border-style: outset; background: -webkit-linear-gradient(left top, #0e23a0 , #77b5fe , white); /* safari 5.1 6.0 */ background: -o-linear-gradient(bottom right, #0e23a0 , #77b5fe , white); /* opera 11.1 12.0 */ background: -moz-linear-gradient(bottom right, #0e23a0 , #77b5fe , white); /* firefox 3.6 15 */ background: linear-gradient(to bottom right, #0e23a0 , #77b5fe , white); /* standard syntax */ } button:focus { border: 5px; border-color: #1aaad9; border-style: outset; } class="snippet-code-html lang-html prettyprint-override"> <!doctype html> <html> <head> <title>canal command plus</title> <link rel="stylesheet" type="text/css" href="stylesheet.css"> <script src="jquery-1.11.1.min.js"></script> <script type="text/javascript" src="constants.js"></script> <script type="text/javascript" src="game.js"></script> <script>$(document).ready(positionupdate); </script> </head> <body onkeypress="keyuphandler(event)"> <div id="main"> <button type="button" id="00"></img></button ><button type="button" id="01"></button ><button type="button" id="02"></button ><button type="button" id="03"></button ><button type="button" id="04"></button ><button type="button" id="05"></button ><button type="button" id="06"></button ><button type="button" id="07"></button ><button type="button" id="08"></button ><button type="button" id="09"></button> <br> <button type="button" id="10"></button ><button type="button" id="11"></button ><button type="button" id="12"></button ><button type="button" id="13"></button ><button type="button" id="14"></button ><button type="button" id="15"></button ><button type="button" id="16"></button ><button type="button" id="17"></button ><button type="button" id="18"></button ><button type="button" id="19"></button> <br> <button type="button" id="20"></button ><button type="button" id="21"></button ><button type="button" id="22"></button ><button type="button" id="23"></button ><button type="button" id="24"></button ><button type="button" id="25"></button ><button type="button" id="26"></button ><button type="button" id="27"></button ><button type="button" id="28"></button ><button type="button" id="29"></button> <br> <button type="button" id="30"></button ><button type="button" id="31"></button ><button type="button" id="32"></button ><button type="button" id="33"></button ><button type="button" id="34"></button ><button type="button" id="35"></button ><button type="button" id="36"></button ><button type="button" id="37"></button ><button type="button" id="38"></button ><button type="button" id="39"></button> <br> <button type="button" id="40"></button ><button type="button" id="41"></button ><button type="button" id="42"></button ><button type="button" id="43"></button ><button type="button" id="44"></button ><button type="button" id="45"></button ><button type="button" id="46"></button ><button type="button" id="47"></button ><button type="button" id="48"></button ><button type="button" id="49"></button> <br> <button type="button" id="50"></button ><button type="button" id="51"></button ><button type="button" id="52"></button ><button type="button" id="53"></button ><button type="button" id="54"></button ><button type="button" id="55"></button ><button type="button" id="56"></button ><button type="button" id="57"></button ><button type="button" id="58"></button ><button type="button" id="59"></button> <br> <button type="button" id="60"></button ><button type="button" id="61"></button ><button type="button" id="62"></button ><button type="button" id="63"></button ><button type="button" id="64"></button ><button type="button" id="65"></button ><button type="button" id="66"></button ><button type="button" id="67"></button ><button type="button" id="68"></button ><button type="button" id="69"></button> <br> <button type="button" id="70"></button ><button type="button" id="71"></button ><button type="button" id="72"></button ><button type="button" id="73"></button ><button type="button" id="74"></button ><button type="button" id="75"></button ><button type="button" id="76"></button ><button type="button" id="77"></button ><button type="button" id="78"></button ><button type="button" id="79"></button> <br> <button type="button" id="80"></button ><button type="button" id="81"></button ><button type="button" id="82"></button ><button type="button" id="83"></button ><button type="button" id="84"></button ><button type="button" id="85"></button ><button type="button" id="86"></button ><button type="button" id="87"></button ><button type="button" id="88"></button ><button type="button" id="89"></button> <br> <button type="button" id="90"></button ><button type="button" id="91"></button ><button type="button" id="92"></button ><button type="button" id="93"></button ><button type="button" id="94"></button ><button type="button" id="95"></button ><button type="button" id="96"></button ><button type="button" id="97"></button ><button type="button" id="98"></button ><button type="button" id="99"></button> <br> </div> </body> </html>

p.s. there way acheive div instead of buttons? give thanks you!

figured out, added float:left css of buttons , worked out.

javascript jquery html css

javascript - Reading the active slide # on angular ui boostrap carousel -



javascript - Reading the active slide # on angular ui boostrap carousel -

i'm using angular bootstrap carousel ui need utilize carousel image selector, can't find way bind selected $index. there way it, hacky way?

here's plunkr mess with.

i've tried putting ng-click=($index) on <slide> tag under slider controls, doesn't fire when carousel slid.

<carousel interval="carouselinterval" class="no-animate" > <slide ng-repeat="slide in token.images | eligiblewidth:200" class="no-animate" ng-click="slideselect($index)"> <!-- doesn't fire cuz under controls --> <img ng-src="{{slide.src}}" style="margin:auto;"> <div class="carousel-caption"> <h4>{{$index+1}} of {{(token.images | eligiblewidth:200).length}}</h4> <p >{{slide.caption}}</p> </div> </slide> </carousel>

with hacky way. utilize onclick trigger angular scope function.

<slide onclick="angular.element(this).scope().clickitem(this)" data-index="{{$index}}" > ... <slide>

in controller:

$scope.clickitem = function(target){ var ele = angular.element(target); var index = ele.attr('data-index'); };

here plunker demo link

hope can work.

javascript jquery angularjs twitter-bootstrap

java - Correct way to parse XML using Simple Framework -



java - Correct way to parse XML using Simple Framework -

i'm using simple framework deserialize xml on android app .

the issue on portion of xml because can objects of other portions of .

here part of xml struggle :

<webtv name="channelname" date="2014-10-31"> <config> <pathvideo extension="mp4">http://vodflash.channelname.com/tv_conn/1/country/</pathvideo> <pathbigimage extension="jpg">http://vodflash.channelname.com/tv_conn/1/country/pic/320x180/</pathbigimage> <pathimage extension="jpg">http://vodflash.channelname.com/tv_conn/1/country/pic/160x90/</pathimage> <pays>gb;ie</pays> </config>

here xmlmapper class :

@root(name="webtv", strict = false) public class xmlmodelmapper { public configobject getconfigobjects() { homecoming configobject; } @element(name="config") public configobject configobject = new configobject(); @elementlist(name = "itemlist") private list<videos> itemlist = new arraylist<videos>(); public list<videos> getitemlist() { homecoming itemlist; } @elementlist(name = "chainelist") private list<chaine> chainelist = new arraylist<chaine>(); public list<chaine> getchainelist() { homecoming chainelist; } }

if alter mapper class :

@root(name="webtv", strict = false) public class xmlmodelmapper { public list<configobject> getconfigobjects() { homecoming configobject; } //change here using list not object @elementlist(name="config") public list<configobject> configobjects = new arraylist<configobject>(); @elementlist(name = "itemlist") private list<videos> itemlist = new arraylist<videos>(); public list<videos> getitemlist() { homecoming itemlist; } @elementlist(name = "chainelist") private list<chaine> chainelist = new arraylist<chaine>(); public list<chaine> getchainelist() { homecoming chainelist; } }

and log size of list 4 right , how each object in distinct way including extension (attribute)

please help me solving issue .

thanks

@elementlist(name="config") public list<configobject> configobjects = new arraylist<configobject>();

this wont match xml listed above. while @element-based solution (example 1) create proper config-tag, list adds "list-tag"; here's example:

<config> <!-- list's tag, wrapping elements --> <config> <!-- actual element's tag --> <pathvideo extension="mp4">http://video.com</pathvideo> <pathbigimage extension="jpg">http://bigimg.com</pathbigimage> <pathimage extension="jpg">http://image.com</pathimage> <pays>gb;ie</pays> </config> <!-- more <config>...</config> --> </config>

the solution: utilize athe inline list - don't have "list-tag".

@elementlist(name = "config", inline = true, entry = "config") public list<configobject> configobjects = new arraylist<>();

for sake of completeness, here classes used testing:

class chaine { /* empty - plenty testing */ } class videos { /* empty - plenty testing */ } @root public class configobject { @element(name = "pathvideo") private pathconfig video; @element(name = "pathbigimage") private pathconfig bigimage; @element(name = "pathimage") private pathconfig image; @element(name = "pays") private string pays; // ... } @root public class pathconfig { @attribute(name = "extension") private string extension; @text private string path; // ... }

java xml xml-parsing simple-framework

netbeans - Error "main.java.lang.IndexOutOfBoundsException: Index: 0, size: 0" and others in Jar file -



netbeans - Error "main.java.lang.IndexOutOfBoundsException: Index: 0, size: 0" and others in Jar file -

let me describe project first.i have source code in java programming language (not programmed me , it's in netbeans ide) .this programme has 4 classes chksubmission.class , parameters.class , plib.class , final relation.class .the programme accepts input dataset folder named "data" contains .zip files , each 1 of .zip files has c++ source codes.then makes complicated compares , extracts results in .txt file name clustering.txt within folder "results" .the programme passes success clean , build progress , got jar file want phone call in html <object></object> tag.i test programme double click , in command line , produced results expected.but after phone call in html didn't produce anything, , if seek run double click doesn't work.if seek run in command line these errors.are parameters ok run applet?please help me .i got confused.the errors are:

exception in thread main.java.lang.indexoutofboundsexception: index:0 size:0 @ java.util.arraylist.rangecheck<unknown source> @ java.util.arraylist.get<unknown source> @ gr.edu.teikav.lmous.research.deltatbl.max <deltatbl.java:37> @ gr.edu.teikav.lmous.research.acf.clust<acf.clust <acf.java:80> @ gr.edu.teikav.lmous.research.chksubmission.submit <chksubmission.java:113> @ gr.edu.teikav.lmous.research.chksubmission.main <chksubmission.java:122>

code:

chksubmission.java

package gr.edu.teikav.lmous.research; import java.applet.applet; import java.io.file; import java.io.filewriter; import java.io.ioexception; import java.io.printwriter; import java.util.arraylist; class relation { string f1, f2; double rel; relation(string fa, string fb, double sim) { f1=fa; f2=fb; rel=sim; } @override public string tostring() { homecoming f1+" "+f2+" "+rel; } } public class chksubmission extends applet{ public static arraylist<string> listfilesforfolder(final file folder) { arraylist<string> rval=new arraylist<>(); (final file fileentry : folder.listfiles()) { if (fileentry.isdirectory()) { listfilesforfolder(fileentry); } else { string fname=fileentry.getname(); if (fname.endswith(".zip")) { rval.add(fname); } } } homecoming rval; } public static arraylist<relation> chk(string inputfolder, string rsltfolder, arraylist<string> keywordlist, double cutoff) throws ioexception, exception { file inputf=new file(parameters.pathofsources+file.separator+inputfolder); arraylist<string> filelist=listfilesforfolder(inputf); arraylist<relation> rval=new arraylist<>(); arraylist<string> invalidsources=new arraylist<>(); (int i=0; i<filelist.size()-1; i++) { string fi=filelist.get(i); if (invalidsources.contains(fi)) continue; (int j=i+1; j<filelist.size(); j++) { string fj=filelist.get(j); if (invalidsources.contains(fj)) continue; //system.out.println(fi+" "+fj); seek { double sim=plib.similarity(inputfolder, fi, fj, keywordlist, invalidsources); if (sim>cutoff) rval.add(new relation(fi,fj,sim)); } grab (exception e) { if (invalidsources.contains(fi)) break; if (invalidsources.contains(fj)) continue; } } } file rfolder=new file(parameters.pathofsources+file.separator+rsltfolder); file rfile=new file(rfolder, "invalidsources.txt"); printwriter out = new printwriter(new filewriter(rfile)); (int i=0; i<invalidsources.size(); i++) out.println(invalidsources.get(i)); out.close(); homecoming rval; } public static void saveclustering(graph g, clustering c, string rsltfolder) throws ioexception, exception { file rfolder=new file(parameters.pathofsources+file.separator+rsltfolder); file rfile=new file(rfolder, "clustering.txt"); printwriter out = new printwriter(new filewriter(rfile)); g.print(out); out.println("-- clustering --"); //out.println(); out.println(c); out.close(); } public static clustering submit(string chkfolder, string rsltfolder, arraylist<string> keywordlist, double cutoff, criterionfunction cf) throws exception { arraylist<relation> rels=chk(chkfolder, rsltfolder,keywordlist,cutoff); arraylist<vertex> verts=new arraylist<>(); arraylist<link> links=new arraylist<>(); (int i=0; i<rels.size(); i++) { relation crel=rels.get(i); vertex v1=new vertex(crel.f1); int v1idx=verts.indexof(v1); if (v1idx<0) verts.add(v1); vertex v2=new vertex(crel.f2); int v2idx=verts.indexof(v2); if (v2idx<0) verts.add(v2); link l=new link(v1,v2,crel.rel); links.add(l); } lib.initiateproject(); graph g=new graph(verts, links, chkfolder); clustering c=new acf().clust(g, cf,0, null); saveclustering(g,c,rsltfolder); homecoming c; } public static void main(string[] args) throws ioexception, exception { parameters.init(); arraylist<string> keywordlist=plib.loadkeywords(); clustering c=submit("data", "results", keywordlist, 0.3, new ilr()); system.out.println(c); } }

so runs applet? applet signed? if no, run in sandbox, , cannot access user files.

heres short peek: http://docs.oracle.com/javase/tutorial/deployment/applet/security.html

java netbeans applet

vb.net - Return an inherited type from a method -



vb.net - Return an inherited type from a method -

suppose have next classes defined:

public class baseclass ... end class public class derivedclass inherits baseclass ... fields, methods, etc ... end class

and then, in code, have function signature of:

public function dosomething(...) list(of baseclass)

and when seek , homecoming object of type list(of derivedclass) it, error:

value of type 'system.collections.generic.list(of baseclass)' cannot converted 'system.collections.generic.list(of derivedclass)'

i know not fields of derivedclass filled, give me needed.

is there way this, or considered bad programming practice? and, if so, right way this?

have @ this:

http://msdn.microsoft.com/en-us/library/dd799517(v=vs.110).aspx

understanding covariance , contravariance clear things bit :)

covariance

enables utilize more specific type specified. can assign instance of ienumerable (ienumerable(of derived) in visual basic) variable of type ienumerable.

example:

ienumerable<derived> d = new list<derived>(); ienumerable<base> b = d; contravariance

enables utilize more generic (less derived) type specified. can assign instance of ienumerable (ienumerable(of base) in visual basic) variable of type ienumerable.

example:

action<base> b = (target) => { console.writeline(target.gettype().name); }; action<derived> d = b; d(new derived()); invariance

means can utilize type specified; invariant generic type parameter neither covariant nor contravariant. cannot assign instance of ienumerable (ienumerable(of base) in visual basic) variable of type ienumerable or vice versa.

vb.net visual-studio

vba - Excel function or Macro to find and move to new line -



vba - Excel function or Macro to find and move to new line -

i need help linking images right item. need function or macro to: find b2(8552) value in row e , first 1 move in c2 next 1 in new line c3 , a2 re-create new line a3 , repeat until moves on matched values , move next 1 (8553). i'm new excel , if text above not create sense please allow me know , re-explain. have tried post image of excel screen can't bcouse need 10 reputation able post images:(. , sorry broken english.

before

a b c e 1 handle sku sorted_image unsorted_image 2 item-loc-501 8552 8552-image-1 3 item-dox-502 8553 8552-image-2 4 mov-loc-item 8554 8552-image-3 5 222-loc-mov 8555 8553-image-1 6 8553-image-2 7 8554-image-1 8 8554-image-2 9 8554-image-3 10 8554-image-4 11 8555-image-1 12 8555-image-2 13

after

a b c e 1 handle sku sorted_images unsorted_images 2 item-loc-501 8552 8552-image-1 3 item-loc-501 8552-image-2 4 item-loc-501 8552-image-3 5 item-dox-502 8553 8553-image-1 6 item-dox-502 8553-image-2 7 mov-loc-item 8554 8554-image-1 8 mov-loc-item 8554-image-2 9 mov-loc-item 8554-image-3 10 mov-loc-item 8554-image-4 11 222-loc-mov 8555 8555-image-1 12 222-loc-mov 8555-image-2 13

this can performed couple of standard (non-array) formulas using native excel functions.

      

the formula in g2 =index(a:a,match(--left($e2,find("-",$e2)-1),$b:$b,0)). fill right h2 fill g2:h2 downwards necessary. formula in i2 =e2.

these formulas assume excel looking @ true numbers in column b. if skus text numbers, remove double unary (e.g. --) converts text pulled left function real number , leave sku text.

copy paste special, values move info column a:c.

excel vba excel-formula

firebird2.1 - C# connection to firebird failed by IP, succeeded by hostname -



firebird2.1 - C# connection to firebird failed by IP, succeeded by hostname -

i have weird issue: c# connection firebird. @ string below, , check datasource parameter:

user=sysdba;password=masterke; database=c:\\example\\example.fdb; datasource=hostname;port=3050; dialect=3; charset=ascii;role=; connection lifetime=0; connection timeout=15; pooling=true; packet size=8192; server note=0 if datasource=hostname, works fine. if datasource=192.168.x.x, got: unable finish network request host "192.168.x.x"

can 1 help?

c# firebird2.1

c - Unable to terminate forked process -



c - Unable to terminate forked process -

i have process has terminated using ctrl-c or sigint. in case cannot utilize ctrl-c physically keyboard, has done using kill command in c. code reads gpio input , starts , stops script record.sh , gstreamer command line script.

i want terminate kid process created in startvideorecording(). need start, stop, start, stop recording many times like. it's not one-off thing.

however, when alter gpio value , trigger stopallrecordings(), doesn't send sigint kid process. hangs there @ "sending interrupt gstreamer process.. status 0"

how can create sure video recording process terminated ctrl-c equivalent?

thanks.

here's code :

int main() { pollgpioswitch(&vn200); } void* pollgpioswitch(void* arg) { vn200* vn200 = (vn200*)arg; int fd; char buf[100]; char value; int videorecerror; bool videorecon = false; sprintf(buf, "/sys/class/gpio/gpio56/value"); while (keep_going) { fd = open(buf,o_rdonly); lseek(fd,0,seek_set); // move origin of file read(fd,&value,1); if (value=='0') { if (videorecon) { // recording on, switch off, end recording stopallrecordings(); videorecon = false; triggergpsinsthreadexit = 0; // reset variables printf("reset gpsins thread variables.\n"); } } else if (!videorecon) { // recording off, switch on, start recording if (pthread_create(&gpsinsloggingthread, null, rungpsins,(void*) vn200) != 0) { printf("error: fail create rungpsins thread\n"); } videorecerror = startvideorecording(); if (videorecerror == -1) pthread_exit(&videorecerror); videorecon = true; } usleep(500000); } close(fd); printf("exited polling!"); } int startvideorecording() { int error; error = 0; if ((avrecordingprocess = fork()) != -1) { switch (avrecordingprocess) { case -1: printf("error: fail create avrecordingprocess\n"); error = -1; case 0: execl("record.sh", "0", null); //system("//root//record.sh"); printf("error: fail execute avrecordingprocess\n"); error = -1; default: printf("video recording...process id %d\n", avrecordingprocess); break; } } else { printf("error: mainhost failed fork avrecordingprocess\n"); error = -1; } homecoming error; } void stopallrecordings() { int ret; file *infile, *outfile; int ch; printf("terminating kid processes..%d\n", avrecordingprocess); ret = kill(avrecordingprocess, sigint); printf("sending interrupt gstreamer process.. status %d\n", ret); int status; printf("wait gstreamer process %d end....", avrecordingprocess); wait(avrecordingprocess); printf("gstreamer ended.\n"); }

is possible starting multiple kid processes , sending sigint lastly kid process created , not before ones? type 'ps' , nail come in after starting programme , see how many processes have started.

c linux gpio

MySQL , How to Select by rand() and update colums in same query? -



MySQL , How to Select by rand() and update colums in same query? -

i need way select row rand() , update @ same query on mysql tried code did not answer:

set autocommit=0; begin transaction; select * articles status = 3 , name not null order rand() limit 0,1; update articles set status = 4 ; commit transaction;

this worked me:

update articles set `status` = 4 id in ( select id ( select id articles status = 3 , name not null order rand() limit 0,1 ) tmp );

mysql select sql-update

javascript - How to create Flare.json like data with size information for zoomable sunburst with labels -



javascript - How to create Flare.json like data with size information for zoomable sunburst with labels -

i have create json file flare.json zoomable sunburst label visualization.

on basis size value have give creating json info file. couldn't find reference regarding size information. random value or node values or how generate it..? please upload sample code create dynamic json file size information?

http://bl.ocks.org/metmajer/5480307

javascript json svg d3.js sunburst-diagram

javascript - Remove string from array -



javascript - Remove string from array -

i have array contain number , string, want remove string array. here array:

var numbonly = [1, 3, "a", 7];

in case, want remove a numbonly (result numbonly = [1, 3, 7]).

thanks.

you can utilize this:

var numbonly = [1, 3, "a", 7]; var newarr = numbonly.filter(isfinite) // [1, 3, 7]

the above works if don't have strings "1" in array. overcome that, can filter array this:

newarr = numbonly.filter(function(x){ homecoming typeof x == "number"; });

javascript arrays

vb.net - Selected item in combo box to individual forms -



vb.net - Selected item in combo box to individual forms -

i want selected item on combo box open in individual forms.

i'm using code in button when select item 2 forms opening

combobox.selectedvalue = "1" form4.show() combobox1.selecteditem = "2" form5.show()

try this:

dim value string = combobox1.selectedvalue select case value case "1" form4.show() case "2" form5.show() case else messagebox.show("choose something...") end select

vb.net

java - Add basic value to Ontology individuals @Jena -



java - Add basic value to Ontology individuals @Jena -

i have ontology classes , setup run. way fill individuals , data?? in short one-way mapping database (as input) ontology.

public class main { static string source = "http://www.umingo.de/ontology/bento.owl"; static string ns = source+"#"; public static void main(string[] args) throws exception { ontmodel model = modelfactory.createontologymodel( ontmodelspec.owl_mem ); // read rdf/xml file model.read(source); ontologypreloader loader = new ontologypreloader(); model = loader.init(model); model.write(system.out,"rdf/xml"); } }

my preloader has method init goal re-create info database ontology. here excerpt.

public ontmodel init(ontmodel model) throws sqlexception{ resource r = model.getresource( main.ns + "tag" ); property tag_name = model.createproperty(main.ns + "tag_name"); ontclass tag = r.as( ontclass.class ); // statements allow issue sql queries database statement = connect.createstatement(); // resultset gets result of sql query resultset = statement .executequery("select * niuu.tags"); // resultset initialised before first info set while (resultset.next()) { // possible columns via name // possible columns via column number // starts @ 1 // e.g., resultset.getstring(2); string id = resultset.getstring("id"); string name = resultset.getstring("name"); individual tag_tmp = tag.createindividual(main.ns+"tag_"+id); tag_tmp.addproperty(tag_name,name); system.out.println("id: " + id); system.out.println("name: " + name); } homecoming model; }

everything working, sense unsure way preload ontologies. every individual should own id can match database @ later point. can define property id , add together every individual?

i thought adding id "thing" basic type in owl ontologies.

at first sight seems ok. 1 tip seek convert jena model rdf serialization , run through protégé more clear image on how ontology mapping looks like.

you can create own property describe id of every individual. beneath illustration on how can create similar property in turtle format.(i did not add together prefixes owl , rdfs since common) can add together in jena aswell if needed. (or load model in jena.)

@prefix you: <your domain> . you:dbidentificator owl:datatypeproperty . you:dbidentificator rdfs:label "<your database identifcator>"@en . you:dbidentificator rdfs:comment "<some valuable info if needed>"@en . you:dbidentificator rdfs:isdefinedby <your domain> . you:dbidentificator rdfs:domain owl:thing .

you add together owl:thing every resource, not best practice because vague definition of resource. around vocabularies defines more resource is. take @ goodrelations. defined vocabulary can describe info though not commercial use. check out classes there.

hope answered of question.

java mysql jena ontology preloading

javascript - I am trying to manage a small number of users control of a webpage -



javascript - I am trying to manage a small number of users control of a webpage -

so start off, have raspberry pi, running lighttp server on arch. have webpage have max of 10 people connected @ time. each user given tag "master," or "observer." webpage have controls "master," can use.

just heads up: learning of may making mistakes how accomplish this.

my original thought has follows. when user connects database ip address grabbed , inserted sqlite database, along user tag, , time of connection. there able query database users tag when tried execute various commands.

whatever utilize needs lightweight , not store cookies on users device.

here javascript have, isn't efficient, plan on getting working making nice.

this code supposed connect databases , insert user.

<script type="text/javascript" src="http://l2.io/ip.js?var=myip"></script> <script type="application/javascript"> var db = opendatabase('usercon.contbl.sqlite', '1.0', 'contbl', 1024); db.transaction(function(transaction) { var ip = myip; var constatus = "master" var date = new date(); console.log('inserting database ' + ip + ',' + constatus +',' + date); transaction.executesql('insert contbl(ipad, contype, lastactive) values (?,?,?,?)',[ip,constatus,date], function(transaction, results) { }, function (transaction, err){ console.log(err.message+":error"); // here error }); }); </script> <script type="application/javascript" src="http://jsonip.appspot.com/?callback=getip"> </script>

i unable connect sqlite database created on pi, after research may because sqlite supposed run locally , not on server.

is there sort of work around point sqlite database on pi, or there improve resource utilize type of task?

edit:

i guess original post not specific enough. basic thought need able pass tiny bit of info webpage, server hosting it. i.e. user connect server , sends ip server tags ip observer of controller. there server treat each person viewing webpage differently based on how user tagged.

my original plan utilize lite weight database sqlite, found out, sqlite local utilize only. need on sever lower 10 connections.

my hope has suggestion, or illustration solve problem.

the mutual way javascript running on web page talk server these days kind of restful web service.

you'll want find server-side programming language runs on pi. maybe node.js? it's javascript on server, see here: http://weworkweplay.com/play/raspberry-pi-nodejs/

you write whatever methods want in server-side language, methods talk database, have client-side javascript phone call methods. google "rest services node.js" , you'll find plenty of how-tos.

javascript sql-server database sqlite3 raspberry-pi

c++ - Using opencv + viola jones running slow -



c++ - Using opencv + viola jones running slow -

i trying implement face detection viola jones classifier using opencv cascade. code using:

int main( ){ systemtime tm; getlocaltime(&tm); printf("date: %02d.%02d.%d, %02d:%02d:%02d:%02d\n", tm.wday, tm.wmonth, tm.wyear, tm.whour, tm.wminute, tm.wsecond, tm.wmilliseconds); //cstring t = ctime::getcurrenttime().format("%h:%m:%s:%ms"); mat image; mat frame_gray; image = imread("test.jpg", cv_load_image_color); namedwindow( "window1", 1 ); imshow( "window1", image ); // load face cascade (.xml file) cascadeclassifier face_cascade; face_cascade.load( "cascades.xml" ); cvtcolor( image, frame_gray, cv_bgr2gray ); equalizehist( frame_gray, frame_gray ); getlocaltime(&tm); printf("date: %02d.%02d.%d, %02d:%02d:%02d:%02d\n", tm.wday, tm.wmonth, tm.wyear, tm.whour, tm.wminute, tm.wsecond, tm.wmilliseconds); float pyramidscale = 1.5f; // observe faces std::vector<rect> faces; face_cascade.detectmultiscale( frame_gray, faces, pyramidscale, 3, 0, size(20, 20), size(50, 50)); getlocaltime(&tm); printf("date: %02d.%02d.%d, %02d:%02d:%02d:%02d\n", tm.wday, tm.wmonth, tm.wyear, tm.whour, tm.wminute, tm.wsecond, tm.wmilliseconds); // draw circles on detected faces for( int = 0; < faces.size(); i++ ) { point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 ); ellipse( image, center, size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, scalar( 255, 255, 255 ), 4, 8, 0 ); } imshow( "detected face", image ); systemtime tm1; getlocaltime(&tm); printf("date: %02d.%02d.%d, %02d:%02d:%02d:%02d\n", tm.wday, tm.wmonth, tm.wyear, tm.whour, tm.wminute, tm.wsecond, tm.wmilliseconds); //cout<< "time : "<<tm.whour<<":"<<tm.wminute << ":"<< tm.wsecond << ":" << tm.wmilliseconds << "\n"; waitkey(0); homecoming 0; }

the problem says viola jones implementation in opencv , takes 30fps run (from author side) taking 6 seconds run normal hd image face detection of around 1920x1080. wanted inquire implementation right or there problem way implementing method , there way can create faster ? cascade.xml file trained using sample images. give thanks you.

c++ opencv cascade haar-classifier viola-jones

vb.net - Crystal Report Windows Forms Viewer : Object Reference not set to an instance on an object -



vb.net - Crystal Report Windows Forms Viewer : Object Reference not set to an instance on an object -

i working crystal reports in vb.net forms application. huge study consists of 10-12 sub-reports,there many formulas used in report, study shows "object reference not set instance on object" can't figure out, have handled exceptions well. when click "next page" button shows below dialog.

i can't figure out why happening. read many blogs, says, formula error, says, "mouse move" error.

below code have added, check now

private sub crystalreportviewer1_handleexception(byval source _ object, byval e crystaldecisions.windows.forms.exceptioneventargs) _ handles crystalreportviewer1.handleexception 'label1.text = e.exception.tostring(); 'here trap. end sub

below stack trace have found applying above code exception:

source:crystaldecisions.crystalreports.engine message:object reference not set instance of object. st: @ crystaldecisions.crystalreports.engine.reportdocument.get_isloaded() @ crystaldecisions.reportsource.nonhttpcachedreportsource.getreport(requestcontext context, boolean baddtocachewhencreated) @ crystaldecisions.reportsource.localreportsourcebase.getpage(pagerequestcontext pagereqcontext) @ crystaldecisions.windows.forms.mainreportdocument.getpage(pagerequestcontext context)

i looking solution this, anyway found issue problem , posting here.

my study had subreport , links not set main report. in scenario when seek set parameters of main study , seek load report, getting object reference error.

so either link subreport parameters main study parameter or may can seek setting sub study parameters too. have set subreport parameters link main study parameters , works.

vb.net exception crystal-reports

c# - Performance hit when Ldloca instruction exists in method -



c# - Performance hit when Ldloca instruction exists in method -

i ran unusual behavior, , hoping shed lite on issue:

class sample { public static void main() { const int count = 10000000; while (true) { // move allocation here allocate more more 50x slowdown problem var stopwatch = stopwatch.startnew(); var total = 0; (int = 1; <= count; ++i) { total += i; } console.write("{0}, ", stopwatch.elapsedmilliseconds); if (total > total + 1) console.writeline(((object)total).tostring()); } } }

note cast object in lastly line (which incidentally never run). without it, code takes pretty important performance nail - on macbook pro 15" 2012 running windows 7 .net 4.5 in release, adds 16ms overhead, while running time without overhead when total variable int 3ms, or 11ms if it's double.

the difference can see in ildasm seems added ldloca instruction - existence of instruction affects memory layout somehow?

c# .net performance optimization cil

php - Turn string into text file -



php - Turn string into text file -

in website possible user come in rather big amount of text in html textarea info later handle php. thing need save text user have input in textarea, preferably txt file in directory.

i have no thought how convert string txt file, have tried reply on net have found nothing. , there particular info sanitizing functions should add together if save user input text in directory?

thanks

$filename='fish'.uniqid(); //unique filename per fred's comments file_put_contents ($filename , $_post['your_form_field_name'] );

php html file textarea

indexing - Drop an Index from SQL Server by Object ID -



indexing - Drop an Index from SQL Server by Object ID -

using sql server 2012 , have somehow ended w/ index named:

<name of missing index, sysname,>

i'm not sure how or when happened. i've tried dropping index using:

drop index email_address.<name of missing index, sysname,>

it won't of course of study since receive expected error message:

incorrect syntax near '<'.

querying dmv in sql server tells me should drop index it's more frustrating cannot. has been 1 of little things has gnawed @ me few years now. i've looked answers few times on years. i've poured 4 hours finding way drop index other name. nothing.

can help me? running query:

select * sys.indexes name = '<name of missing index, sysname,>'

produces object_id of 281104092. there way drop object using id? there must be, right? stuck w/ crazy index forever?

drop index email_address.[<name of missing index, sysname,>]

should trick.

object indexing

java - Apache Spark: what's the designed behavior if master fails -



java - Apache Spark: what's the designed behavior if master fails -

we running our calculations in standalone spark cluster, ver 1.0.2 - previous major release. not have ha or recovery logic configured. piece of functionality on driver side consumes incoming jms messages , submits respective jobs spark.

when bring single & spark master downwards (for tests), seems driver programme unable figure out cluster no longer usable. results in 2 major problems:

the driver tries reconnect endlessly master, or @ to the lowest degree couldn't wait until gives up. because of previous point, submission of new jobs blocks (in org.apache.spark.scheduler.jobwaiter#awaitresult). presume because cluster not reported unreacheable/down , submission logic waits until cluster comes back. means run out of jms listener threads fast since blocked.

there couple of akka failure detection-related properties can configure on spark, but:

the official documentation doesn't recommend enabling akka's built-in failure detection. i want understand how supposed work default.

so, can please explain what's designed behavior if single spark master in standalone deployment mode fails/stops/shuts down. wasn't able find proper doc on net this.

in default, spark can handle workers failures not master (driver) failure. if master crashes, no new applications can created. therefore, provide 2 high availability schemes here: https://spark.apache.org/docs/1.4.0/spark-standalone.html#high-availability

hope helps,

le quoc do

java cluster-computing akka apache-spark

javascript - How to inject service from external file using AngularJS and RequireJS? -



javascript - How to inject service from external file using AngularJS and RequireJS? -

i'm injecting controller external file , want same thing service external file. should registered in mill statement.

injecting of controller working

controllers

'use strict'; define(['angular', 'services'], function (angular) { homecoming angular.module('vcapp.controllers', ['vcapp.services']) .controller('authctrl', ['$scope', '$injector','authservice', function($scope, $injector, authservice) { require(['auth/authctrl'], function(authctrl) { $injector.invoke(authctrl, this, {'$scope': $scope, 'authservice':authservice}); }); }]); });

authctrl

define([], function() { homecoming ['$scope', '$routeparams', '$location', '$http', 'authservice', function($scope, $routeparams, $location, $http, authservice) { $scope.signin = function() { ... } $scope.$apply(); }]; });

and want inject service

services

'use strict'; define(['angular'], function (angular) { angular.module('vcapp.services', []) .factory('authservice', ['$http', '$injector', function($http, $injector) { require(['auth/authservice'], function(authservice) { $injector.invoke(authservice, this, {'$http': $http}); }); }]); });

authservice

define([], function() { homecoming ['$http', function ($http) { homecoming { login: login }; function login(username, password) { var request = $http(...); return(request); } }] });

when authcontroller calls authservice.login(...), throws error error: [$injector:undef] provider 'authservice' must homecoming value $get mill method..

this code inspired angular-requirejs-seed project.

as says, angular's factory() expected homecoming service object. may have luck like:

define(['angular'], function (angular) { angular.module('vcapp.services', []) .factory('authservice', ['$http', '$injector', function($http, $injector) { var stub = {}; require(['auth/authservice'], function(authservice) { angular.extend(stub, $injector.invoke(authservice, this, {'$http': $http})); }); homecoming stub; }]); });

here define stub service , extend it, when service lazy-loaded.

(by way think lastly 2 arguments of $injector.invoke() redundant in case.)

if want thought mixing requirejs , angular, plays lazy loading , r.js optimizer, may take @ angular-require-lazy.

javascript angularjs dependency-injection requirejs

coldfusion - JQuery Two dropdowns second submits on load -



coldfusion - JQuery Two dropdowns second submits on load -

i have 2 dropdowns / list boxes, on first submit, page queries database , pulls possible options. trying have sec dropdown on load pull / display results. going in circles.

jquery

$(function() { $('#firstone').change(function() { this.form.submit(); }); }); $(function() { $('#secondone').change(function() { this.form.submit(); }); });

cfml

<select id="firstone" name="filterone"> <option value="all">-- show --</option> <option value="state">state</option> </select> <cfif isdefined( "url.filter") , url.filter neq ""> <cfif url.filter eq 'state'> <cfquery name="qrystate"> select distinct state database </cfquery> <select id="secondone" name="filtertwo"> <cfoutput query="qrystate"> <option value="state">state</option> </cfoutput> </select> </cfif> </cfif>

thanks.

dan right, start simple when you're trying understand what's going on. place in submit button in form.

you did renaming before pasting code here, since can't know sure, strikes me odd primary select list named firstone , cfif checks url.filter.

the code below assumes identifier value nvarchar type. if it's int, alter cf_sql_varchar cf_sql_integer. if you're not familiar cfqueryparam, up. defends site against sql injections aimed @ altering tables/databases. read more.

while here's sample reply below.. 1 of 2 things.

i set each box on it's own page. i jquery or javascript, since it's exclusively possible it. i'll share implementation wrote below.

you can seek this

<form method="post" action="boxes.cfm"> <select id="firstone" name="filterone"> <option value="all">-- show --</option> <option value="state">state</option> </select> <cfif isdefined("form.firstone") , form.firstone eq 'state'> <cfquery name="qrystate"> select distinct state database somethingid = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.firstone#"> </cfquery> <select id="secondone" name="filtertwo"> <cfoutput query="qrystate"> <option value="state">state</option> </cfoutput> </select> </cfif> <input type="submit" name="submit" value="filter data"> </form>

html jquery demonstration

<div class="prodselectbox"> <div id="box1">category: <select id="selectcat" name="categoryselected"> <option value="" class="rhth">select type</option> <option value="colors">colors</option> <option value="books">books</option> <option value="animals">animals</option> <option value="furniture">furniture</option> </select> </div> <div id="box2">items: <select id="selectprod" name="articleid"> <option value="">select subtype</option> <option value="red" class="colors">red</option> <option value="blue" class="colors">blue</option> <option value="bible" class="books">bible</option> <option value="phonebook" class="books">phonebook</option> <option value="cat" class="animals">cat</option> <option value="dog" class="animals">dog</option> </select> </div> </div>

the script:

$(document).ready(function () { $('#selectcat').change(function () { if ($('option:selected', this).attr('value') == '') { $('#box2').hide(); $('#selectprod option').hide(); } else { if ($('#selectprod option.'+$('option:selected', this).attr('value')).length > 0) { $('#selectprod option').hide(); $('#box2').show(); $('#selectprod option.'+$('option:selected', this).attr('value')).show(); } else { $('#selectprod option').hide(); $('#box2').hide(); alert('no items in category'); } } }); $('#box2').hide(); $('#selectprod option').hide(); });

the way works id of first select corresponds class of sec select.

so create id of options of first select "c#categoryid#" , create classes of options of sec select "c#categoryid#".

jquery coldfusion listbox