Posts

Showing posts from March, 2012

c# - Which numeric type conversion is better for simple math operation? -

i want know conversion better (regarding performance/speed , precision/most less loss) simple math operation , makes them different? example: double double1 = integer1 / (5 * integer2); var double2 = integer1 / (5.0 * integer2); var double3 = integer1 / (5d * integer2); var double4 = (double) integer1 / (5 * integer2); var double5 = integer1 / (double) (5 * integer2); var double6 = integer1 / ((double) 5 * integer2); var double7 = integer1 / (5 * (double) integer2); var double8 = convert.todouble(integer1 / (5 * integer2)); var double9 = integer1 / convert.todouble(5 * integer2); actually question conversion not type itself. edit in response totally changed question: the first line double double1 = integer1 / (5 * integer2); integer division, don't that. also line var double8 = convert.todouble(integer1 / (5 * integer2)); doing integer division before converting result double, don't either. other that, different approaches list end calling il instru...

c - Error "'strcpy' makes pointer from integer without a cast" -

struct phaseshiftpin { int _psppin_index; //psp = phase shift pin int _pspvalue; char _pspname[512]; }; struct phaseshiftpin *_phaseshiftpin[500000]; int p3int = 0; strcpy ( _phaseshiftpin[i]->_pspvalue, p3int ); the above code part of full code. when compiled full program happened error strcpy' makes pointer integer without cast @ line strcpy ( _phaseshiftpin[i]->_pspvalue, p3int ); i have referred post @ here makes pointer integer without cast strcpy after tried use strncpy , follow method showed in post still fail in compilation.hope can guide me problem.thanks. if @ definition of strcpy can see char *strcpy(char *dest, const char *src); but _phaseshiftpin[i]->_pspvalue integer , p3int also. you can use memcpy void *memcpy(void *dest, const void *src, size_t n); strcpy ( &(_phaseshiftpin[i]->_pspvalue), &(p3int), sizeof(p3int) ); or said in comment _phaseshiftpin[i]->_pspvalue = p3int; if try copy p3i...

javascript - Running CSS keyframes on click -

i'm trying have message appear when button clicked. want have "go!" fade in/out signify start of game when start button clicked. i'm trying javascript @ moment using jquery , library teacher gives combination of on mouse click , on screen tap 'ontap' lter use mobiles. i have set add animation class when button clicked animation won't play, if add animation class beginning animation plays not when button clicked. went wrong adding javascript , how can achieve basic click button , text fades in/out? <script type="text/javascript"> $(document).ready(function() { $("#addfrogbut").ontap(function() { $("#gotext").addclass(".goanim"); }); }); </script> <head> #addfrogbut { position: fixed; bottom: 20px; font-family: fantasy; font-size: 32px; left: 20px; text-transform: uppercase; text-shadow: -1px 0 white, 0 1px white, 1px 0 white, 0 -1px white; padding: 2px 18px; backgro...

java - org.hibernate.util.JDBCExceptionReporter] Duplicate entry X for key 'PRIMARY' -

i writing back-end java code active-mq in producer consumer model. when multiple consumers runs using , try update in table question following exception occured , transaction rollbacked. multiple threads running inside each consumer task. warn [org.hibernate.util.jdbcexceptionreporter] sql error: 1062, sqlstate: 23000 07:10:31,609 error [org.hibernate.util.jdbcexceptionreporter] duplicate entry '69-947' key 'primary' 07:10:31,615 error [com.xminds.bestfriend.consumers.questiongeneration] exception failed question generation org.springframework.dao.dataintegrityviolationexception: not insert: [com.xminds.bestfriend.frontend.model.friendship]; any 1 can suggest solution this. i think trying insert record using existing primary key. make sure primary key unique.

c# - Apply Where conditionally (OR between them) LINQ -

i have filters in asp.net project , want add expression list condition: expression<func<mymodel, bool>> func; var list = new list<expression<func<mymodel, bool>>>(); i want conditionally apply (or between them). example: if(sth){ func = p => p.a <= b; list.add(func); } if (sth else){ func = p => p.c >= d; list.add(func); } var fq = session.query<mymodel>(); fq = list.aggregate(fq, (current, expression) => current.where(expression)); how can this? looks extension method public static class enumerableextensions { public static ienumerable<t> conditionalwhere<t>(this ienumerable<t> list, bool condition, func<t,bool> predicate) { if(!condition) return list; return list.where(predicate); } } usage be: var fq = session.query<mymodel>(); var result = fq.conditionalwhere(sth, p => p.a...

How to enable php run python script on GPU? -

in php website, call python script using theano , running on gpu. however, when calling python script php, seems apache doesn't have permissions on gpu program falls on cpu, far less efficient compared gpu. how can grant apache rights run programs on gpu? i split up, save requirement event in storage (redis example or rabbitmq) , listen daemonized script (cron bad joice since hard make run more every minute). script update storage entry results , can access again in http stack. can implement functionallity via ajax or utilize usleep command in php wait results. if using while loop, dont forget break after 1 second or something, request not running long. your problem might configured user, executes php binary - maybe not permitted access binaries on system. typically www-data user. adding www-data user necessary group, might able solve without splitting up. have @ binary's ownerships , permissions figure out.

PHP / HTML - Load image from outside root folder -

i trying load in image in <img> tag within html. images folder in same folder root folder, meaning need go 1 folder access images folder. i looked around internet , found method using requests within src attribute image, unfortunately without success. folder structure: img > somefile.png foo.png bar.png html > index.php imagerequest.php //other root files i cannot use following: <img src="../img/somefile.png"> because points towards non existant (duh!). attempted use request. my html <div> <img src="imagerequest.php?requested=somefile.png"> </div> my php (imagerequest.php) $filename = $_get['requested']; fetchimage(); function fetchimage(){ global $filename; if(!isset($filename)) return; $filepath = dirname($_server['document_root'])."/img/".$filename; if(file_exists($filepath)){ readfile($filepath); ...

php - javascript from codeigniter into jsp -

i have method javascript in codeigniter when try put jsp, javascript doesn't work. in codeigniter, if call function, page refresh, when try put code jsp, function doesn't refresh page. the code this: <script type="text/javascript"> function submit_page(from){ var doc = document.frm_data; if(from == 1){ doc.tipe_lst.value = ""; doc.cab2_lst.value = ""; }else{ doc.wil_lst.value = ""; doc.cab_lst.value = ""; } doc.action = "<?php echo $page_action;?>"; doc.target=""; doc.submit(); } i call codeigniter this: <form name="frm_data" method="post"> <div style="float:left; position:relative; width:350px;"> <div> <label>kantor wilayah : </label> <select name="wil_lst" onchange="submit_page(1);"...

swift - Loading nib into NSScrollView -

i trying implement view no horizontal scrolling (will resize , down) , variable vertical scrolling. i've trying embedding view on scroll view in storyboard , after lot of fiddling got working content hidden outside window never see while editing thought i'd put content in separate nib file , load onto scroll view. i got working if resize main window view nib not resize scrollview size width doesn't change , stays in top left corner. in view has scroll view have simple code load in content nib file called detailedview.swift: self.detailedview = detailedview(nibname: nil, bundle: nil) self.scrollview.documentview = self.detailedview.view in detailedview have elements constrained view adding top, leading , trailing constraints. anyone got thoughts or can point me in right direction? thanks

php - Ubuntu sendmail spam -

i have installed sendmail in ubuntu send mails , works fine, have detected every 30' receive e-mail subject: cron [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime) and every 20 minutes receive other e-amil subject: cron test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp what happened? how can avoid send e-mails?

vb.net - Searching file based on pattern -

struggling write code find file based on pattern name of file: dailyload_yyyymmddhhmmgifkm.csv (dailyload , time stamp, set of 5 characters , extension) so daily need match if receive above file in our source directory. struggling write code comparison file name in database: dailyload_yyyymmddhhmmgifkm.csv file name received in source directory: dailyload_201307231010gifkm.csv we need check time stamp in file name of of today files other day might exist in same folder can please help? regards try this: dim dir new io.directoryinfo("c:\docs\parentdirectory") dim iofileinfo = dir.getfiles("dailyload_" & now.tostring("yyyymmdd") & "*gifkm.csv")

csv - How do I stop bash from adding ^@ before each letter in vim -

a problem occured no reason, in code worked previously. there data in myfile.csv mp 0,20,60,200,60,95,100,1,20,50,30,20,20,250,115,200,0,8,85,150,465817 mp 1,17.89,60,200,60,93.945,100,1,20,50,30,20,20,250,115,200,0,10,85,150,465927 mp 2,16.33,60,200,60,93.16,100,1,20,50,30,20,20,250,115,200,0,12,85,150,464987 mp 3,15.12,60,200,60,92.56,100,1,20,50,30,20,20,250,115,200,0,14,85,150,463440 ... i extracted last 25 lines of files tail -n 25 myfile.csv > test1.txt when cat test1.txt ... mp 16,20,60,200,60,95,100,1,20,120,30,20,20,250,115,200,0,8,85,150,529469 mp 17,20,60,200,60,95,100,1,20,130,30,20,20,250,115,200,0,8,85,150,534335 no problem... want go in text editor, every letters preceded ^@ : vim test1.txt ^@m^@p^@ ^@0^@,^@2^@0^@,^@6^@0^@,^@2^@0^@0^@,^@6^@0^@,^@9^@5^@,^@1^@0^@0^@,^@1^@,^@2^@0^@,^@5^@0^@,^@3^@0^@,^@2^@0^@,^@2^@0^@,^@2^@5^@0^@,^@1^@1^@5^@,^@2^@0^@0^@,^@0^@,^@8^@,^@8^@5^@,^@1^@5^@0^@,^@4^@6^@5^@8^@1^@7^@ and problem want make pattern search (...

swift - Google url shortener iOS -

trying short version of url using googleshortener api. using afnetworking 3.0 , error: 'anyobject not subtype of 'nsproxy' let manager = afhttpsessionmanager() manager.requestserializer = afjsonrequestserializer() let params = ["longurl": "myurl"] manager.post("https://www.googleapis.com/urlshortener/v1/url?key=mykey", parameters: params, success: {(operation: nsurlsession!,responseobject: anyobject!) in println("json" + responseobject.description) }, failure: { (operation: nsurlsession!,error: nserror!) in println("error while requesting shortened: " + error.localizeddescription) }) it highlighted on line 'println("json" + responseobject.description)' on begging of 'description'. i had same error while using afnetworking 3. documentation indicated there changes. however, here code able run. hope works out. let manage...

ssas - Understanding the Cube display in SQL Studio Manager -

Image
i have built small data warehouse using adventure works database. have deployed sql studio manager. have written first mdx query select customer.[full name].members on rows, order (measures.[sales amount],asc) on columns [adventure works dw2012] please see screenshot below: i understand top level of hierarchy dimensions i.e. customer, date, due date, interne sales, order date, product , ship date. understand dimensions have attributes. example: model name, product line, product name attributes of product dimension , product model lines hierarchy of product dimension. what meant by: financial; history , stocking? you've come against think genuinely confusing , ill-designed aspect of ssas. you're correct model name, product line , product name attributes of product dimension. you're seeing here (in screenshot) hierarchies called model name, product line , product name. these not "hierarchies" in sense people use term (a structure m...

java - Spring Data JPA save new Entity and get its all dependencies -

im saving entity database via spring data jpa save() method. method returns saved entity object, if im saving new entity, returned object isn't filled example @manytomany full entities. as far know, when spring data jpa save new entity, uses entitymanager.persist() method, , if entity exist in database, save() method uses entitymanager.merge() method. my question is, how save new entity in database , full dependencies in 1 transaction? i trying add helper class, bean services extends, like: public abstract class helperpersistenceservice<e extends abstractentity<i>, extends serializable> { @persistencecontext private entitymanager entitymanager; @transactional public e savewithmerge(e e) { if (e.getid() == null) { entitymanager.persist(e); } return entitymanager.merge(e); } } and works without @transactional method. got excepton: javax.persistence.transactionrequiredexception: no entitymanager act...

c# - Windows 10 Development: How to refresh ListView whenever there is a change in the items inside ListView? -

i new concept of data binding , don't think understood completely. have class named project linkedlist of type todo 1 of properties. when navigate 1 instance of project , display linkedlist of type todo in listview . have created functions allow me change sequences of nodes in linkedlist (move up, move down) , remove selected node (delete). want listview refresh whenever there change in linkedlist , (move up, move down or delete). however, cannot achieve that. here code: (not parts included) xaml of page: <listview x:name="mylistview" itemssource="{binding source={staticresource todos}, mode=twoway}"> <listview.itemtemplate> <datatemplate> <stackpanel> <checkbox x:name="mycheckbox" content="{binding todotitle, mode=twoway}" ischecked="{binding iscompleted, mode=twoway}"> ...

r - What roxygen should I put when I use a function of another package in my function -

i writing many functions , trying document using roxygen2 i use futile.logger package lot, use flog.debug function in function. @* should use document ? first, being aware of your sessioninfo() getwd() # r's working directory .libpaths() # r's library location step0 download , install necessary packages: library(roxygen2) library(devtools) library(digest) step1 put related ".r" files (yourfunction1.r, yourfunction2.r, yourfunction3.r) r's working directory. step2 create package skeleton in r's working directory: sure there no folder named "yourpackage" in r's working directory before running following command. (from r's console) package.skeleton(name = "yourpackage", code_files = c("yourfunction1.r", "yourfunction2.r", "yourfunction3.r"), path = ".") after running package.skeleton , folder yourpackage created in r's working directory. delete read-and-...

python - Having trouble creating a function that takes one argument, and returns a result of adding odd numbers between 1 and argument? -

so far have this... def sumofodds(n): result = 0 in range(1, n+1, 2): result = result + print(result) this gives me sum, prints numbers come before it. need sum, not rest of values. you can use loop , range() 2 step sum = 0 max = 11 in range(1, max, 2): # not including max sum += print sum #out:25 (1 + 3 + 5 + 7 + 9)

ios - How to read string between to html node -

i getting response json webservice , have 1 node "name". { "name": "<style>b\n {\n font-family:'helvetica';\n line-height: 200%;\n text-align: justify;\n } \n </style><b>corn idlis</b><br/>" } i trying food name between corn idlis . so 1 please suggest me how read or remove html tag node. you can retrieve string nsstring *htmlstr = responsedic[@"name"]; nsarray *temparray = [htmlstr componentsseparatedbystring:@"<b>"]; nsarray *temparray1 = [temparray[1] componentsseparatedbystring:@"</b>"]; nsstring *yourstring = [temparray1 firstobject];

Extract only date from datetime for calculating total time in PHP -

i have date time data in database , im calculating total hours taking date not timing. im using strtotime calculations. ex: $lastdate = '2016-04-27 17:27:28'; $enddate = strtotime($lastdate); // 1461770848 $lastdate = '2016-04-27'; $enddate = strtotime($lastdate); // 1461708000 i want second value only. want extract date $lastdate . ///////////getting data employee outstation(travel) details database///////////// $employeetravel = new employeetravelrecord(); $travelentrylist = $employeetravel->find("employee = 2 , (date(travel_date) <= ? , ? <= date(return_date))",array($req['date_end'],$req['date_start'])); $startdate = $req['date_start']; $enddate = $req['date_end']; foreach($travelentrylist $travelentry){ $key = $travelentry->employee; if($startdate >= $travelentry->travel_date) { ...

Filtering nodes and edges neo4j on shortest path -

is there way run shortest path algorithm in neo4j whilst filtering on edges or nodes > operator. filtering on nodes higher of timestamp? cheers to extent, can use query predicates ( http://neo4j.com/docs/3.0.1/query-predicates.html ). here example using built-in example movie graph. query finds shortest paths 1 movie , filters paths go through kevin bacon. match p = shortestpath((m1:movie)-[*]-(m2:movie)) m1.title = 'the birdcage' , m2.title = 'sleepless in seattle' , any(x in nodes(p) x.name = 'kevin bacon') return p

azureportal - How do you delete a Department in the Azure EA Portal? -

how delete department in azure ea portal? i know can go ea portal , manually delete it, there way programmatically delete it? ... , corollary question ... is there way programmatically create one? to knowledge, , of today (2016-05-09) there no management / rest interface ea portal. there azure management rest apis (both azure service , resource managers). there billing api, read-only , can pricies - both offered services , consumed services. there no rest api, using can manage ea portal. through ea portal.

Java runtime using cmd commands -

i writing tool simplify launching program needs run in command line. having problem windows 8 , xp need run command c:\program files (x86)\juniper networks\network connect\ncluancher.exe + ....now reason in windows 7 nclauncher found not in windows 8 keep getting error not locate c:\program. or invalid program arguments have been specified. string version_number = getprogramversion(); string url_location = "\"c:\\program files (x86)\\juniper networks\\network connect " + version_number + "\\nclauncher" + "\""; string[] location = {url_location + " -url " + url + " -u " + user_name + " -p " + pass_word + " -r s1ad"}; // location of network connect specified. process pr = runtime.getruntime().exec(location); bufferedreader input = new bufferedreader(new inputstreamreader( pr.getinputstream())); is there way make more univers...

ios - How to exclude special characters in tesseract? -

Image
i using tesseract , mcr.traineddata read micr numbers cheque. part of cheque want read. the below part of text has been detected image. my question is..... **how exclude special characters image? training tesseract special characters option? ** except special characters rest of numbers getting detected. my code let tesseract = g8tesseract() tesseract.language = "mcr" tesseract.enginemode = .tesseractonly tesseract.pagesegmentationmode = .auto tesseract.maximumrecognitiontime = 60.0 imageview.image = imageview.image?.g8_grayscale() imageview.image = imageview.image?.g8_blackandwhite() tesseract.image = imageview.image tesseract.recognize() i created new traineddata file(my.traineddata). trained special characters recognized 'x'. more images use accurate traineddata file. can accordingly manipulate recongized text.

cmd - How can i open a port in firewall with java -

i search way open port java socket in firewall, have idea cmd command or way thank you. using cmd if want open port on windows vista , higher can use following command netsh advfirewall firewall add rule name="my_rule_name_incoming" dir=in action=allow protocol=tcp localport=4000 netsh advfirewall firewall add rule name="my_rule_name_outgoing" dir=out action=allow protocol=tcp localport=4000 note have run command on pc in question

How to use django.core.files.storage.get_available_name? -

i storing files , need unique file name. found a suggestion use django.core.files.storage.get_available_name missing something. tried this: class mymodel(models.model): name = models.charfield( max_length=200, null=true ) filecontent = models.filefield( null=true, upload_to=storage.get_available_name(name) ) and got error: typeerror: unbound method get_available_name() must called storage instance first argument (got charfield instance instead) interpret meaning trying run method on class need storage-instance run on. there exist called defaultstorage supposed something "provides lazy access current default storage system" 1 not have get_available_name method method _setup can't called on class either. how supposed instance work on here? the upload_to argument directory path want upload files to. argument storage named storage so should if want change default django's storage implementation use example filecontent = m...

java - Speed optimization of Website with a lot of images -

i working on website involves lot of images. problem images uploaded user can't alter images. website runs quiet ok on local system speed drops on server,it becomes slow i'd suggest use timthumb . creates thumbnail generating url on fly , uses minimal disk space.

how to show blank instead of 0 in datagridview c#.net -

i working on window application visual studio 2010 , sql server 2008. code working fine. need 1 thing if value 0.000 in database, should shown blank in datagridview . please, give me solution. in advance. code given below: sda = new sqldataadapter("select item, cast (val1 decimal (10,3)), cast (val2 decimal (10,2)), cast (val3 decimal (10,2)), cast (val4 decimal (10,3)), sno opstk vno ='" + txtvno.text + "'", con); datatable dt = new datatable(); sdaq.fill(dt); datagridview1.rows.clear(); foreach (datarow item in dt.rows) { int n = datagridview1.rows.add(); datagridview1.rows[n].cells[0].value = item["item"].tostring(); datagridview1.rows[n].cells[1].value = item[1].tostring(); datagridview1.rows[n].cells[2].value = item[2].tostring(); datagridview1.rows[n].cells[3].value = item[3].tostring(); datagridview1.rows[n].cells[4].value...

javascript - How to show bootstrap bottom pophover an image click in java script -

can tell how show bootstrap bottom pophover image button click in java script thanks bootstrap has usefull documentation popovers. can read here: http://getbootstrap.com/javascript/#popovers here simple example how use: <img src="so.jpg" data-toggle="popover" data-title="top title" data-content="body text" /> don't forget include jquery , bootstrap.js . need declare popover, because doesn't work default, can use example: $(document).ready(function() { $('[data-toggle="tooltip"]').tooltip(); $('[data-popover="popover"]').popover({ trigger: "hover" }); }); this example contains solution hovering image. replace data-toggle="popover" data-popover="popover" . i hope you.

vba - Can I create and add a text attachment to an Outlook message that is no file? -

i trying create outlook macro forward incoming message attachment contains particular piece of text. it should plain text file attachment, created on fly. attachments.add supports adding items of type olembeddeditem , the documentation says must messages; code examples found elsewhere have them appointments or contacts, can't find lets them pieces of plain text can viewed , saved files. a workaround create attachment plain text file on disk , attach file, brittle. there way avoid that? no, outlook object model lets pass file name olbyvalue attachments. extended mapi (c++ or delphi) oom based on not deal files @ - 1 need open pr_attach_data_bin property istream , populate stream data want. if c++ or delphi not option, redemption allows pass variant array of byte rdomail. attachments.add (you can set attachment.filename property later).

Python - how to show differences between two numbers(strings) -

import random def run_all(): print "welcome" name = get_name() welcome(name) guess = get_guess() print guess dice1 = get_dice() dice2 = get_dice() dice3 = get_dice() total = dice1 + dice2 + dice3 print "dice 1: " + str(dice1) print "dice 2: " + str(dice2) print "dice 3: " + str(dice3) print "the dices total sum is: " + str(total) print "your guess was: " + guess def get_name(): '''ask name''' return raw_input("hi, what's name?") def welcome(name): ''' welcome''' print name + ", welcome!" def get_guess(): return raw_input("we throw 3 dices, think total sum be? ") def get_dice(): return random.randint(1,6) run_all() i want show player difference between guess , total, can't figure out how to. difference = abs(total - int(guess)) ...

c# - How to define response error metadata in swagger/swashbuckle WebAPI 2 -

i have figured out how create response object metadata in swashbuckle: [route("x/{y:guid}")] [httpget] [swaggerresponse(httpstatuscode.ok, "bla", typeof(bladto))] public ihttpactionresult getsomething([fromuri] guid someguid) { bla returnobject; try { returnobject = _service.get(someguid); } catch (databaseexception databaseexception) { modelstate.addmodelerror("databaseexception", databaseexception.message); return badrequest(modelstate); } return ok(returnobject); } i still looking examples define request object meta data , meta data 400 errors etc. pointers appreciated. object metadata of operation detected swashbuckle automatically. object metadata of errors can specified adding more swaggerresponseattribute s. here's example: [route("x}")] [httppost] [swaggerresponse(httpstatuscode.created, "bla", typeof(bladto))] [swaggerresponse(httpstatuscode...

how to maping column from oledbsource to oledbdestination using SSIS in C# -

can 1 me, want make mapping oledbsource (select mfk_prefix,mfk_sufix,melement_base,mbase_value,mperiode_start,mperiode_end,msandi_pelapor,morder [dbo].[stg_aakl]) to oledbdestination(select fk_prefix,fk_sufix,element_base,base_value,periode_start,periode_end,sandi_pelapor,order [dbo].[tm_aakl]) how programmatically make mapping oledbsource oledbdestination using ssis inc#. for complete or program there @ below this [microsoft.sqlserver.dts.tasks.scripttask.ssisscripttaskentrypointattribute] public partial class scriptmain : microsoft.sqlserver.dts.tasks.scripttask.vstartscriptobjectmodelbase { public void main() { string destinationcs = @"data source=.\sql2012;initial catalog=dwh_lsmk;provider=sqloledb.1;integrated security=sspi;application name=ssis-package;auto translate=false;"; string sourcecs = @"data source=.\sql2012;initial catalog=dwh_lsmk;provider=sqloledb.1;integrated security=sspi;application name=ssis-package;auto t...

how to retrieve data from sql server to DataTable using c# -

string j = "data source=fujitsu-pc\\sqlexpress;initial catalog=attendance_system;integrated security=true"; datatable dt = new datatable(); using (sqlconnection cn = new sqlconnection(j)) { sqlcommand cmd = new sqlcommand("select dbo.faculty_status.username dbo.faculty_status", cn); cn.open(); sqldatareader dr = cmd.executereader(); dr.read(); dt.load(dr); cn.close(); } int x = dt.rows.count; foreach (datarow row in dt.rows) { foreach (var item in row.itemarray) { string xx = item.tostring(); } } mysql server database table i used code wors not show me desire first row value givs me out put like---- 13-24516-2 i think problem way reading. try this: string j = "data source=fujitsu-pc\\sqlexpress;initial catalog=attendance_system;integrated security=true"; using (sqlconnection cn = new sqlconnection(j)) { ...

javascript - regexp excluye char -

i trying create regexp has following characteristics. begin {{ may contain line breaks , character may not contain }} example **this ok. {{ dog car blue #hello# this not ok. {{ dog car blue }} #hello# i tried regexp: {{2}([\s\s]*?)[^\{]#hello# but returns ok you need tempered greedy token solution because need first match multicharacter leading delimiter {{ , need match any text other #hello# , {{ (multicharacter sequences) . if had negate 1 character, [^{] suffice. not case here. use /{{[^#}]*(?:}(?!})[^#}]*|#(?!hellow#)[^#}]*)*#hello#/g see regex demo note unrolled variant of {{(?:(?!}}|#hellow#)[\s\s])*#hello# more readable highly inefficient , more prone catastrophic backtracking issue. details: {{ - matches {{ [^#}]* - 0+ characters other # , } (?:}(?!})[^#}]*|#(?!hellow#)[^#}]*)* - matches 0+ sequences of either }(?!})[^#}]* - } not followed } , followed 1+ characters other # , } | - or #(?!hellow#)[^#}]* - # ...

node.js - model.fetch with related models bookshelfjs -

i have below models company.js var company = db.model.extend({ tablename: 'company', hastimestamps: true, hastimestamps: ['created_at', 'updated_at'] }); user.js var user = db.model.extend({ tablename: 'user', hastimestamps: true, hastimestamps: ['created_at', 'updated_at'], companies: function() { return this.belongstomany(company); } }); with many-to-many relation between company , user handle via following table in database. user_company.js var usercompany = db.model.extend({ tablename: 'user_company', hastimestamps: true, hastimestamps: ['created_at', 'updated_at'], users: function() { return this.belongstomany(user); }, companies: function() { return this.belongstomany(company); } }); the problem when run following query. var user = new user({ id: req.params.id }); user.fetch({withrelated: ['companies']}).then(function( user ) { conso...

Refused opml file by slack RSS feed -

i'm trying subscribe rss feeds using slack. following message: that doesn't valid rss/atom feed. here rejected file: https://gist.github.com/mpagli/e84d0e4d7d7efd4def9cec696555b8a4 i have subscribed several other feeds without problem. instance following feed gets accepted: https://github.com/rushter/data-science-blogs/blob/master/data-science.opml the 2 files seem similar in syntax , both validated same warnings using https://validator.w3.org/feed/ any idea on why feed list gets rejected?

javascript - Unsupported number of argument for pure functions -

i have problem in angular2 (rc-1), passing array of strings function component binding. array length exceed 10 have error: unsupported number of argument pure functions: 11 which sounds bit strange me because of 2 reason: the array single parameter why set limit of number of function params? (only thing have in mind performance optimization not use arguments keyword) component selector: <tb-infinite-scroll [tbdataproperty]="[ 'prop1', 'prop2', 'prop3', 'prop4', 'prop5', 'prop6', 'prop7', 'prop8', 'prop9', 'prop10', 'prop11' ]"></tb-infinite-scroll> in component: @component({ selector: 'tb-infinite-scroll', inputs: [ 'dataprop:tbdataproperty', ], /*...*/ }) export class tbinfinitescrollcomponent { public dataprop:any = ''; then inside component template: <div *ngi...

machine learning - OneVsRestClassifier(svm.SVC()).predict() gives continous values -

i trying use y_scores=onevsrestclassifier(svm.svc()).predict() on datasets iris , titanic .the trouble getting y_scores continous values.like iris dataset getting : [[ -3.70047231 -0.74209097 2.29720159] [ -1.93190155 0.69106231 -2.24974856] ..... i using onevsrestclassifier other classifier models knn,randomforest,naive bayes , giving appropriate results in form of [[ 0 1 0] [ 1 0 1]... etc on iris dataset .please help. well not true. >>> sklearn.multiclass import onevsrestclassifier >>> sklearn.svm import svc >>> sklearn.datasets import load_iris >>> iris = load_iris() >>> clf = onevsrestclassifier(svc()) >>> clf.fit(iris['data'], iris['target']) onevsrestclassifier(estimator=svc(c=1.0, cache_size=200, class_weight=none, coef0=0.0, degree=3, gamma=0.0, kernel='rbf', max_iter=-1, probability=false, random_state=none, shrinking=true, tol=0.001, verbose=false), ...

email - Configure sendmail to send mail only to local mail address -

i need configure sendmail in order test websites , app mail function locally; i wish if on production mail() function sends mail user@hisdomain.com , same code tested locally sends mail myfolder@localhost in order check messages details, functionalities , on. i'm on lamp machine. is possible? you may configure sendmail deliver outgoing mail local mailbox/alias. should catch message non local mailboxes. sendmail.mc file (used generate sendmail.cf file): define(`smart_host`,`local:myfolder`)dnl restart/reload sendmail daemon after compiling new sendmail.cf file sendmail.mc file.

javascript - parameter url in XMLHttpRequest.open() AJAX -

i'm practicing in ajax , i'm stuck html page respondes user's click on button, showing specific html file; this code: <!doctype hmtl> <html> <body> <button type="button" name="button1" >button1</button> <button type="button" name="button2" >button2</button> <button type="button" name="button3" >button3</button> <button type="button" name="button4" >button4</button> <hr/> <p id="demo">visualize document here!</p> </body> <script> var documenti= document.getelementbytagname("button"); for(var i=0; i<documenti.length; i++) { documenti[i].onclick= loaddoc; } function loaddoc() { var httpreq= new xmlhttprequest(); httpreq.onreadystatechange= caricadocumento; httpreq.open("get", "this file i'm trying visualize!...

c# - How to do Silent installation without UAC or App Is running as admin? -

i want silent installation. know command "msiexec.exe /qn", can't if application isn't running administrator. note:- msi installer created using wix toolset process process = new process { startinfo = { filename = @"msiexec.exe", arguments = string.format(@"/i ""e:\build 16\coliboconnect.msi"" /qn"), useshellexecute = false, redirectstandardinput = true, redirectstandardoutput = true, redirectstandarderror = true, createnowindow = false } }; process.start(); process.waitforexit(); you requesting silent msi installation therefore msi not display ui - nor uac dialog. your parent process must run elevated privileges, or must request elevation windows , use privileges token run new process.

JConsole not connecting to java process -

when start jconsole identifies java process(local) not able connect it. connection failed: retry? connection 17424 did not succeed. try again? selecting connect again gives same error(17424 pid of java process).on other hand jvisualvm works perfectly. in jvisualvm see following details pid: 17424 host: localhost main class: conatainer jvm: java hotspot(tm) 64-bit server vm (23.6-b04, mixed mode) java: version 1.7.0_11, vendor oracle corporation java home: /home/aniket/jdk1.7.0_11/jre jvm flags: <none> has encountered situation before? bug? there work around? you may running jvisualvm different user user running java application. make sure you're running same user or super user.

entity framework - LinQ: How to Write single Query to retrieve records while passing List/string collection in efficient way? -

i have written linq query retrieve records more quick way. take more time retrieve while passing local collection values linq query: here working linq query entity framework. need forumthread based on platformid passed string collection here goal: how can retrieve records matched id's collection in single linq query more efficient way? ex: slow execution query: public void getthreadcollection(string[] platformid) { using (supportentity support=new supportentity()) { var threadcollection = (from platid in platformid thread in support.forumthread platform in support.platforms platid == thread.platformid && platform.platformid==platid select new { threadid = thread.threadid, title = th...

How to use isset() in PHP -

this question has answer here: does condition after && evaluated 6 answers i tried out code: <?php if(isset($a) && ($a ==4)) echo "$a ==4"; ?> and surprised did not error, because $a not defined. thought 1 needs write <?php if(isset($a)) if($a == 4) echo "$a == 4"; ?> why first version not throwing error if check isset($a) , ($a ==4) simultaneously? there disadvantage when using short code if(isset($a) && ($a ==4)) ? not trust it, becomes handy when else branch needed. php checks if condition left right. isset() returns false doesn't check ($a == 4) aborts if , continues script. if other way around: if(($a ==4) && isset($a)) echo "$a ==4"; this return undefined notice.

javascript - jQuery assign click event handler on page load -

i want assign click handler button in page load function. want handle actual click of button @ later time following code snippet: $("#finish").off('click').on('click', function () { var sku = $("#productsku").val(); var name = $("#productname").val(); var affiliateid = $("#affiliateid").val(); var errors = ""; var category = null; var defaultname = $('#defaultimgname').val(); if ($("#childcategories_" + categorylevel).length == 0) { category = $("#categorylist").val(); } else if ($("#childcategories_" + categorylevel).val() == 0) { category = null; } else { category = $("#childcategories_" + categorylevel).val(); } if (!sku) { errors += "<li...

plsql - Oracle named parameters -

how can use keywords oracle named parameters syntax ? following gives me 'ora-00936: missing expression' because of 'number'-argument: select b.g3e_fid , a.g3e_fid , sdo_nn_distance( 1) acn a, b$gc_fitface_s b mdsys.sdo_nn ( geometry1 => a.g3e_geometry, geometry2 => b.g3e_geometry, param => 'sdo_num_res=1', number=>1) = 'true' , b.g3e_fid = 57798799; if run without named parameters fine. thanks, steef although can around reserved word issue in call enclosing name in double quotes @avrajitroy suggested, i.e. ... "number"=>1) = 'true'... , aren't achieving much. oracle letting refer parameters name isn't doing information. mdsys.sdo_nn spatial operator , not direct call function. there function backing - can see schema scripts mdsys it's calling prtv_idx.nn - names of formal parameters of function not relevant. digging can see called geom , geom2 , mask etc., , there isn't ...

javascript - Choose Directory/Folder to save to? -

i have online application , want clients save files particular folder of own choosing, documents, desktop or newly created folder. file attribute in html not help. there choose directory dialog functionality in html or javascript, or php. how can achieve this? in html , javascript, feature isn't available causes security problems. the user have manually set file location can toggled in browsers chrome , mozilla shilly said in comments.

java - How can I load a .conll file into an Annotation object with Corenlp? -

i have files outputted corenlp in .conll format, , want deserialize them annotation object. corenlp provide conll-x documentreader method transform .conll file annotation object or have create own documentreader? you can try tsvsentenceiterator , reads sentences conll-like formatted tsv file. but, note number of annotations hanging off of annotation object far more number of columns in conll file (e.g., character offsets, etc.), , serialization wouldn't lossless , may have unexpected behavior if want keep annotating object. not 1 of officially supported lossless serialization strategies.

C#, JSON Parsing, dynamic variable. How to check type? -

i'm parsing json texts. array , object types in text. tried check type follows: dynamic obj = jsonconvert.deserializeobject(text); //json text if (obj array) { console.writeline("array!"); } else if (obj object) { console.writeline("object!"); } i checked types while debugging. obj had type property object when parsing objects , array when parsing arrays. console output object! both situations. i'm checking type in wrong manner. correct way check type? edit json contents: [ {"ticket":"asd", ...}, {..} ] or { "asd":{...}, "sdf":{...} } in both situations output object! . edit#2 i changed typechecking order @houssem suggested. still same output. therefore changed op well. code right now, , still same result. try this, since json.net return object of type jtoken if (((jtoken)obj).type == jtokentype.array) { console.writeline("array!"); } else if (((jt...

regex - javascript replace last occurrence of string -

i've read many q&as in stackoverflow , i'm still having hard time getting regex. have string 12_13_12 . how can replace last occurrence of 12 with, aa . final result should 12_13_aa . i explanation how did it. newstring = oldstring.substring(0,oldstring.lastindexof("_")) + 'aa';

android - Why does my app close when swiping tabs in ViewPager? (Only on Huawei devices) -

this happens on huawei devices (except honor 5x). app (music player): https://play.google.com/store/apps/details?id=com.ms.musicplayer code viewpager , tabs: // viewpager setup viewpager = (viewpager)findviewbyid(r.id.pager); // tabs tablayout = (tablayout)findviewbyid(r.id.sliding_tabs); viewpager.setadapter(new myadapter(fragmentmanager)); if (tablayout != null) { tablayout.setupwithviewpager(viewpager); } xml tabs: <android.support.design.widget.tablayout android:id="@+id/sliding_tabs" android:layout_below="@id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:elevation="4dp" app:tabindicatorheight="4dp" android:overscrollmode="ifcontentscrolls" app:tabtextcolor="@color/transparetwhitefifty" ...

java - jodatime -> parse error utc datetime string -

currently, i'm trying parse datetime using jodatime library. string stringliteral = "09/05/2016 12:25:39" try { datetime utcdatetime = new datetime(stringliteral, datetimezone.utc); this.expressiontype = expressionenumtype.date; this.expressions.add(constantimpl.create(utcdatetime.todate())); } catch (illegalargumentexception e) { this.expressiontype = expressionenumtype.string; this.expressions.add(constantimpl.create(stringliteral)); } however, jodatime tells me: java.lang.illegalargumentexception: invalid format: "09/05/2016 12:25:39" malformed @ "/05/2016 12:25:39" the constructor of datetime cannot parse string in arbitrary format datetime object. if want use constructor in way, string must in 1 of iso 8601 formats, , string "09/05/2016 12:25:39" not. use method parse date, can specify format yourself. example: datetimeformatter formatter = datetimeformat.forpattern("dd/mm/yyyy hh:mm:ss")...

database - Update sqlite not working on android -

i have login , reset password activity. when enter new updated password , try login again, cannot new password. logging in old password works fine. basically, password field not getting updated/overwritten. there no error in logcat. password not updated. please new android development. code update( dataregister class , set functions): public int updatepassword(dataregister dataregister) { db = dbhelper.getwritabledatabase(); contentvalues updated = new contentvalues(); updated.put("password", dataregister.getpassword()); return db.update(dataregister.table, updated, "email=?" , new string[] {dataregister.getemail()}); } code retrieval: public string getpass(dataregister dataregister) { db = dbhelper.getwritabledatabase(); cursor cursor = db.query(dataregister.table, null, "email=?", new string[]{dataregister.getemail()}, null, null, null, null); if (cursor != null && cursor.movetofirst()) { pass = cursor.getstrin...

data modeling - Confusing about Database schema of SO -

i investigated sede need develop qa platform internal use, noticed there table votes storing user's upvote/downvote/favorite/etc posts, userid of table null when vote type upvote or downvote, illustrated here , there upvote & downvote history under profile's votes cast! how happen? tables exposed stackexchange incomplete, or missing something? thanks reply. this because stack exchange keeping information secret. hence userid 's left empty in public queryable votes table. information not present in datadumps . you can query amounts. favorites, userid seems available.

mysql - What is the solution for Configuration failed because libmysqlclient was not found.? -

configuration failed because libmysqlclient not found. try installing: * deb: libmariadb-client-lgpl-dev (debian, ubuntu 16.04) libmariadbclient-dev (ubuntu 14.04) * rpm: mariadb-devel | mysql-devel (fedora, centos, rhel) * csw: mysql56_dev (solaris) * brew: mariadb-connector-c (osx) if libmysqlclient installed, check 'pkg-config' in path , pkg_config_path contains libmysqlclient.pc file. if pkg-config unavailable can set include_dir , lib_dir manually via: r cmd install --configure-vars='include_dir=... lib_dir=...' try this: sudo apt-get install libmysqlclient-dev intalling mysql client solve problem in ubuntu.

Jquery - Modify a string into a span without remplacing everything -

i have following code , try modify 'delivered' string @ beginning of span. end remplacing content of span if use text() method. i tried: $('#delivered-on').parent().text(' delivered on: '); $('span.wizard-filter-delivery-date').not('#delivered-on,.deliverydays-container').text(' delivered on: '); do have idea how that? best, nicolas <span class="wizard-filter-delivery-date col-sm-12"> delivered <span id="delivered-on"> <div data-reactroot="" class="deliverydays-container"> <div class="deliverydays-no-touch-dropdown-container"> <div class="select select--single is-searchable has-value"> <div class="select-control"> <div class="select-value"><span class="select-value-label">friday, 13th may</span>...