Posts

Showing posts from July, 2014

sql server - SQL query count elements in other table -

i have 2 sql tables, projects , milestones: projects pk -> proid milestones combined pk -> proid , mstno for reason cannot use proid foreign key link 2 tables (foreign key constraint). however, need write query show me details of of projects table records, number of milestones each project. can use inner join achieve somehow? i'm not writing sql queries. try 1 - select p.* , cnt = isnull(m.cnt, 0) dbo.projects p left join ( select proid, cnt = count(1) dbo.milestones group proid ) m on m.proid = p.proid

c# - Circular reference when trying to serialize database -

i'm trying serialize whole bunch of information lot of linked tables can pass through web service , call ajax. problem i'm having there 1 many relationships, , many many relationships , i'm new i'm not sure how stop json following infinite loops through database. is there missing script ignore on or should trying find different solution? i need data in pagedata public class sitedata { public sitedata() { this.urlresponse = new list<response>(); } public sitedata(string url, string robots, string sitemap, bool googleverification, bool bingverification, list<response> urlresponse) { this.domainurl = url; this.robots = robots; this.sitemap = sitemap; this.googleverification = googleverification; this.bingverification = bingverification; this.urlresponse = urlresponse; } public sitedata(string url) { // todo: complete member initialization this.do

html - Browser does not get defined css selector -

i have following markup: <div class="won-container"> <div class="circle b"></div> <div class="circle b"></div> <div class="circle b"></div> <div class="circle b"></div> <div class="circle b"></div> <div class="circle r"></div> </div> and have defined following classes in external css stylesheet: .won-container { float: left; } .circle { width: 24px; height: 24px; position: relative; margin-top: -12px; } .won-container .b { background-image: url('../images/circle_blue.png') ; }​ .won-container .g { background-image: url('../images/circle_green.png'); }​ .won-container .r { background-image: url('../images/circle_red.png'); }​ and turns out browser .won-container .b class showing blue image. browser not aware of .won-container .r selector. idea why?

php - mysql prepared statement "truncate table ?" returns null -

in function truncate table can use $stmt = $mysqli->prepare("truncate table packed_items"); and $stmt set mysqli_stmt object, but if try $stmt = $mysqli->prepare("truncate table ?"); then $stmt set null , statment: $stmt->bind_param("s", $mytable) will crash error call member function bind_param() on non-object in i using parameterized prepared statements select,insert , update no problem. you cannot bind sql literal data one. no keyword, no operator, no identifier. if need truncate tables dynamically, knowing no name (as truncating tables @ random sign of bad design), check table name against white list, format correctly, , interpolate in query string.

javascript - SVG: Moving mouse to <image> element triggers mouseout event of parent <g> element (d3.js) -

i have <g> element <rect> , <image> inside. <g> has mouseout event listener. problem when move mouse rect image (within same g ), mouseout event triggered (followed 'mouseover'). here's example. (and jsfiddle ) var x = 120; var g = d3.select("svg") .append("g") .on('mouseover', function() { d3.select(this).append("text").text("mouseover").attr('transform','translate(0,'+x+')'); x+=20; }) .on('mouseout', function() { d3.select(this).append("text").text("mouseout").attr('transform','translate(0,'+x+')'); x+=20; }) g.append("rect") .attr('width', 100) .attr('height', 100) .style('fill', 'lightgreen') g.append('image') .attr("width", 30) .attr("height", 30) .attr("x

jsf.ajax.request not work on Firefox -

i have application based on jsf 2.1 , primefaces. need make ajax request using jquery , update page status. here code: <?xml version="1.0"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets"> <f:view> <h:head> </h:head> <h:body> <h:outputtext id="counterviewer" value="#{datacontroller.outputmessage}" styleclass="counter-viewer" /> <h:form id="dataform" > <h:outputscript> jquery(document).ready(function() { jquery(document).on("count", function(event,

php - MySQL I can not write data into the database -

hello guys have problem inserting data in mysql database.i accepted project friend worked. i make simple php test file , try insert in table _content_city . query executed bu no records in database column when check in phpmyadmin. $handler = mysql_connect($server, $user, $pass); $database = mysql_select_db($dbname); if(!$handler) : die("faild connect mysql :" . mysql_error()); endif; if(!$database) : die("db name ". $dbname . " no exists " . mysql_error()); endif; mysql_query("insert _content_grad (wishlist) values('blablabla') ") or die(mysql_error()); printf ("inserterd records: %d\n", mysql_affected_rows()); when execute code in browser have message inserterd records: 1 when check in phpmyadmin data no exist in column. dont know whay. you guys can see image , u see column wishlist empty. http://img710.imageshack.us/img710/1852/5hfw.png i check foreign_keys , remove foreign_keys , again dont

plot - Create faceted graph in R, keeping other points as greyed out -

Image
i have data ( allpca ) divided site. have used qplot (pc1, pc2, data=allpca, colour=population, facets=~population) + scale_colour_manual (values=cbbpalette) facet scatterplot of 2 variables site. example allpca: id pc1 pc2 population syd1 0.0185 0.0426 sydney was1 0.0167 0.0415 washington rea1 0.0182 0.0431 reading aar1 0.0183 0.0427 aarhus this works fine, gives data each site in each of windows. i create same plot, keeping rest of data in each facetted plot, greyed out. can help? one way use 2 geom_point() calls. in first use data=allpca[,-4] - data without column population , set color="grey" . points plotted in facets in grey. add second geom_point() data , color=population . add points in facets corresponding each population in separate colors (when facet_wrap() used). ggplot()+ geom_point(data=allpca[,-4],aes(pc1,pc2),color="grey")+ geom_point(data=allpca,aes(pc1,pc2,color=population))+ facet_wrap(~population)

Error while connecting Sonar in Eclipse -

i trying use eclipse plugin connect instance of sonar have installed locally on machine: using following details: http:// localhost:9000 username:admin password:admin but showing error instance the stack trace: java.lang.nosuchfielderror: instance @ org.sonar.ide.eclipse.core.internal.servers.serversmanager.getservers(serversmanager.java:41) @ org.sonar.ide.eclipse.ui.internal.preferences.sonarserverpreferencepage.inittable(sonarserverpreferencepage.java:92) @ org.sonar.ide.eclipse.ui.internal.preferences.sonarserverpreferencepage.createcontents(sonarserverpreferencepage.java:81) @ org.eclipse.jface.preference.preferencepage.createcontrol(preferencepage.java:232) @ org.eclipse.jface.preference.preferencedialog.createpagecontrol(preferencedialog.java:1501) @ org.eclipse.jface.preference.preferencedialog$14.run(preferencedialog.java:1258) @ org.eclipse.core.runtime.saferunner.run(saferunner.java:42) @ org.eclipse.ui.internal.jfaceutil$1.run(jfaceutil.java:49) @ org.eclip

windows 8 - WinJS binding to nested control -

i trying implement semantic zoom control in application. here fragment of 1 of pages: <div id="semanticzoomdiv" data-win-control="winjs.ui.semanticzoom"> <div id="zoomedinlistview" class="win-selectionstylefilled" data-win-control="winjs.ui.listview" data-win-bind="wincontrol.itemdatasource: groupedlist.datasource; wincontrol.groupdatasource: groupedlist.groups.datasource;" data-win-options="{ itemtemplate: select('#mediumlisticontexttemplate'), groupheadertemplate: select('#headertemplate'), selectionmode: 'none', tapbehavior: 'none', swipebehavior: 'none' }"> </div> <div id="zoomedoutlistview" data-win-control="winjs.ui.li

c# - Adding a controller to edit profiles -

i writing small intranet page. displays employees , basic details in list using entity framework interact db , create "employee" class. adding logic allow users edit profiles. current problems : the forms work when navigated localhost; using pc-name/webaddress results in 404. causing ? how can fix ? the forms empty; want edit user profile id=1 example, of input boxes displayed, empty need type in of information again. can add functionality? access not restricted admins , owner of profile (where your current domain login == "domainac" column in database of users should permitted edit account , not otherwise). whats best solution here? any in solving of these issues appreciated. here current setup/flow of information : displaying users using html/razor : (index.cshtml) <table id="employeetable"> <thead> <tr> <th>name</th> <th>branch</th>

c# - Retrieve Images from sql server database Error -

i storing images database on table called test contain (id,name,image), when try retrieve images using code : sqlconnection cn = new sqlconnection(constring); sqlcommand cmd = new sqlcommand("select * test id ='"+txtid.text+"'", cn); sqldatareader myreader; try { cn.open(); myreader = cmd.executereader(); if (myreader.hasrows) { txtid.text = myreader[0].tostring(); txtname.text = myreader[1].tostring(); byte[] img = (byte[])(myreader[2]); if (img == null) picturebox1.image = null; else { memorystream ms = new memorystream(img); picturebox1.image = image.fromstream(ms); } } else { messagebox.show("do not found"); } cn.close(); } catch (exception ex) { messagebox.show(ex.message); } i have error : invalid attempt read when no data present . hasrows determines whether there rows. need read() reade

C++ SSE and aligned array of ints and vector of ints -

thanks of you, have used sse speeding computation of 1 of function of scientific app in c++ use sse instructions comparing huge vectors of ints . the final version of optimized sse function is: int getbestdiffssse(int nodeid, const vector<int> &goalnodeidtemp) { int positionnodeid = 2 * nodeid * nof; int mynewindex = 2 * nof; int result[4] __attribute__((aligned(16))) = {0}; __m128i vresult = _mm_set1_epi32(0); __m128i v1, v2, vmax; (int k = 0; k < mynewindex; k += 4) { v1 = _mm_loadu_si128((__m128i *) & distances[positionnodeid + k]); v2 = _mm_loadu_si128((__m128i *) & goalnodeidtemp[k]); v1 = _mm_xor_si128(v1, vke); v2 = _mm_xor_si128(v2, vko); v1 = _mm_sub_epi32(v1, vke); v2 = _mm_sub_epi32(v2, vko); vmax = _mm_add_epi32(v1, v2); vresult = _mm_max_epi32(vresult, vmax); } _mm_store_si128((__m128i *) result, vresult); return max(max(max(result[0], result[1

jquery - apply sort arrows to the second row -

Image
i using jquery data tables. i want have sort arrows applied second row of table not first. html: <table id="tableusers" class="datatable"> <thead> <tr class="filterrow"> <td></td> <td></td> <td data-rownum="2"> @html.partial("_filterdropdown", model.rolelist) </td> <td></td> <td></td> <td></td> <td data-rownum="8"> @html.partial("_filterdropdown", model.enabledlist) </td> <td></td> <td></td> </tr> <

What is -0.0 in matlab? -

i have been working on finding parabola 3 points using determinant method. coefficients returned -0.0000 what mean? why there negative sign , signify? try format long g see more significant digits. number negative.

paypal - Recurly.js Integration: How to override the subscription value? -

i trying achieve following: ?php require_once('recurly/lib/recurly.php'); // required api recurly_client::$subdomain = 'xxxxxx'; recurly_client::$apikey = 'xxxxxxxxxxxxxxxxxxx'; recurly_js::$privatekey = 'xxxxxxxxxxxxxxxxxxx'; $signature = recurly_js::sign( array( 'subscription' => array( 'plan_code' => 'testplan1', 'unit_amount_in_cents' => 5000, 'currency' => 'usd' ) ) ); ?> <html> <head> <link href="recurly-js/themes/default/recurly.css" rel="stylesheet"> <script src="js/jquery.js"></script> <sc

Why does a working batch command only partially work when redirected? -

i'm writing batch script that, among other things, opens macro enabled excel file (.xlsm): 2>nul ( >>%csf% echo off ) && (start "cmdtitle" /b excel %csf% /e /automation) || (echo not open) %csf% variable referring full path excel file i.e. "c:\test\testfile.xlsm" (including quotes cases there may spaces in directory / filename) this code checks if file locked editing, if not opens file (start command) otherwise echos not open. if open file windows explorer or run following in batch script file opens fine. set csf="c:\test folder\test.xlsm" start "cmdtitle" /b excel %csf% /e /automation however, running batch file when checking locked file causes excel say, "excel found unreadable content in 'filename.xlsm' want recover contents of workbook?" removes macros file. edit: in addition file not opening correctly, excel add-ins upon excel opening, example, removing , recreating command bar fail

asp.net - Solution on resource (css, images) sharing between IIS sub web applications -

i have large website hosted in iis, within there numbers of sub web applications. each web application developed either asp.net webform application or asp.net mvc application. web applications work enable web site. so, question: there best solution share common resources (css, images, js) among applications? currently, resources duplicated in each web application , quite pain maintain them.

login - Android first window to open -

i created project chat.java , activity_main.xml. "window" opens up. want change window, login wrote (login.java & loginxml.xml) appears first. have write that? couldn't find :( thank you! add activity want load. <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> and remove code other activity loading now.

Perl: read data file as map -

i have configuration file follows, name=test password = test i need read data file , set map can set data. now, have tried in way, $path_to_file ="c:\\perl\\bin\\data.txt"; open(file, $path_to_file) or die("unable open file"); @data = <file>; close(file); print "data ",$data[0],"\n"; but not getting desired output. output name=test. can body give other suggestion?. help. you use tie::file::ashash . use tie::file::ashash; tie %map, tie::file::ashash::, $path_to_file, split => qr/\s*=\s*/, join => '=' or die "failed open: $!"; $map{password} = 'swordfish'; # changes file! print 'the password ', $map{password}, "\n";

Why doesn't this html5 track tag work? -

this code: <video controls="" src="arrested%20development.s04e11.a%20new%20attitude.mkv"> <track kind="subtitles" label="english subtitles" src="subs\arrested development.s04e11.a new attitude-eng.vtt" srclang="en" default=""> </track> </video> i can see video fine, not subtitles (not subtitles button on controls). (on chrome) i don't use control parameter in video tag , default parameter in track tag not sure if solve problem. use playr: https://github.com/delphiki/playr makes life little easier!

javascript - jQuery validation for empty textbox, and focus, disable button if validation false result -

i have more jquery validation ajax. want make validation : if textbox empty, disable button. if while validation database false, focus textbox , disable button. and make code far jquery validation : $("#button_submit").attr("disabled", "true"); $("#accessories_sheet").keyup(function() { var accessories_sheet = $("#accessories_sheet").val(); var acc_no = $("#acc_no").val(); var revision = $("#revision").val(); var combine_part = $("#combine_part").val(); if(accessories_sheet.length >= 16) { $("#status_acc").html('<div class="pos_loader">processing...</div>'); $.ajax( { type: "post", url: "check_accs.php", data: 'accessories_sheet='+

amazon web services - install magento on AWS EC2 instance -

i want install magento production site on ec2 instance. looking @ bitnami magento stack , installed it. can use production , things must changed? is there ami ready production? or else recommendation case? regards, bitnami instances testing , development dont prefer use production. better configure own magento stack using base os instance ubuntu centos or amazon linux. i dont suggest of third party instances production.

sed - How to get "all but the last N fields/things" in shell script? -

i encounter case need beginning of string without last part. for example, host part of fqdn without domain name: www.example.org -> www foo.bar.example.org -> foo.bar foo.bar.baz.some.domain.name -> foo.bar.baz.some (the same applies other examples need strip end of input.) i use mix of cut , rev this, such as: echo "foo.bar.example.org" | rev | cut -d "." -f 3- | rev this trick, wonder if there better way this? with awk do: $ awk '{nf=nf-2}1' fs=. ofs=. file www foo.bar foo.bar.baz.some generalize last n feilds n=2 : $ awk '{nf=nf-n}1' fs=. ofs=. n=2 file www foo.bar foo.bar.baz.some with sed do: $ sed 's/[.][^.]*[.][^.]*$//' file www foo.bar foo.bar.baz.some generalized: $ sed -r 's/([.][^.]*){2}$//' file www foo.bar foo.bar.baz.some

download - SAP Netweaver Trial for Linux -

i have installed sap netweaver trial version (server, logon, etc.) on windows. i'm searching linux version not find it. can me? best regards bernhard http://www.sdn.sap.com/irj/scn/downloads?rid=/library/uuid/60d6c8b7-5d8f-2910-31bf-ebdf74fefd8b version trial linux here

shell - Most compatible method for reading a file line-by-line in reverse -

okay, have script generates list of values (separated newlines simplicity) they're generated , stored file in 1 order, need process file in reverse order (i can't change how first step operates efficiency reasons dataset can quite large). i'm familiar useful commands tac , tail -r in bash, unfortunately environment i'm working within has neither (i don't believe has @ in addition main posix standard). so i'm looking best way read lines file in reverse-order, preferably little memory overhead possible, file may grow quite large (though individual lines should relatively small). this method uses sort have high memory overhead cat -n filename | sort -rn | cut -f2- if have perl installed, use module file::readbackwards .

qt5 - What is the difference between a QWindow and QWidget -

the qt 5.0 provides new qwindow class. while documentation on class quite comprehensive, failing see how qwindow different qwidget class, , in cases prefer former. both provide handy way of visualising sorts of things screen, both can use qpainter drawing, , both have way interact opengl. in api description , says that: an application typically use qwidget or qquickview ui, , not qwindow directly. so doesn't seem advantage window. moreover, states: windows can potentially use lot of memory. usual measurement width times height times color depth. window might include multiple buffers support double , triple buffering, depth , stencil buffers. which doesn't seem in favour of using qwindow . in cases use it? qwindow has been introduced in qt 5.0 due gui / widgets split. qwidget lives in own library ( qtwidgets ); necessary provide abstraction of "toplevel window" non-widgets based applications, , qwindow created -- , lives in qtgui .

wso2 api for API Publisher and API Store throws error -

i have installed wso2 api manager , wso2 bam. can access ip::9443/publisher/, ip:9443/stores/, ip:9443/carbon/ , :9444/publisher/ application browser. i'm trying access publishers , stores via apis in order have available customers. i'm referring documentation @ http://docs.wso2.org/wiki/display/am140/publisher+apis when try hit application curl -x post -c cookies http://ip:9763/publisher/site/blocks/user/login/ajax/login.jag -d 'action=login&username=my_username&password=my_password' it gives output below {"error" : false} and see following in cookie file. # cat cookies # netscape http cookie file # http://curl.haxx.se/rfc/cookie_spec.html # file generated libcurl! edit @ own risk # httponly_ip_here false /publisher/ false 0 jsessionid xyz_session_id_here i couldnt find article related posting here. tried same /stores , failing same messeage. missing working? appreciate resolution if 1 aware of. thank yo

hibernate - OneToMany using a Map: Order has items, each item has quantity -

i have design db such have table called item (to sold). when item created 1 of part quantity. plan have table item_qty has item_id , quantity (original quantity shopkeeper has). now customers see item online , place order. desired design such order can have many items , each item have quantity associated (this quantity coming customer e.g. want buy 2 pens). i ideally want have order class having: map<item, integer> items; integer field quantity. , corresponding table order_items has (order_id, item_id, requested_qty). is right way? if not - what's best way this. current code have: @onetomany(cascade = cascadetype.all, fetch = fetchtype.lazy) @mapkeyjoincolumn(name="id") public map<item, integer> getitem() { return item; } i getting: caused by: org.hibernate.annotationexception: use of @onetomany or @manytomany targeting unmapped class: com.test.shop.jpa.entity.order.item[java.lang.integer] many tutorials including hibernate's suggest

vb.net - Stuck on Byte Conversion -

i'm trying virtual click , in order need give keybd_event() byte value in order tell do. have function takes in passed string ( it's letter a-z ) , converts byte. when run program error conversion type 'byte()' type 'byte' not valid here function: private function getbytevalue(byval letter string) dim byt = system.text.encoding.unicode.getbytes(letter) return byt end function i don't know why error occurring, , i'm not sure returning byte value, rather how many bytes letter converts to, , need byte bvk value? encoding.getbytes() returns array of bytes, not single byte. error message telling you trying convert byte array byte. you have iterate on elements in array , process each 1 through keybd_event() .

ruby on rails - Add model atribute to result of a query -

i have 3 models , (simplified): class airline < activerecord::base attr_accessible :name has_many :airplanes has_many :airplane_switches end class airplane < activerecord::base attr_accessible :airline_id, :register belongs_to :airline has_many :airplane_switches end class airplaneswitch < activerecord::base attr_accessible :airline_id, :airplane_id belongs_to :airplane belongs_to :airline end airplanes have been in airlines , needed model indicates if airplane in 1 or more airlines . i building form let users upload info airplane , select airplane register (callsign) , list choose in airline was. this work on ajax request. but, trying figure out how show airline name controller, avoid ajax call fetching json file name of airline based on airline_id in airplaneswitch . @airplane = airplane.find_by_register(params[:register]) @airplane_switches = @airplane.airplane_switches # here need join each airline.name i think way more efficient, h

authentication - Google drive API and auth -

i want create web app letting user upload file google drive , able view through browser. far looking @ google's examples seems have auth google drive on server side (makes sense....) end-users have auth before uploading drive using oauth. there way prevent having ask users authenticate prior uploading documents given authorized through server google drive account? allowing view document more straightforward through use of public folder...

visual studio - Conflict with VS project dependencies and lib files -

i have big vs2008 solution containing >30 vs projects legacy code. 1 of these projects (let's call a) generates header file, needed few other projects (for example b). when go "project dependencies" of vs solution, can check project project b's dependencies - vs includes in project b's linker command line options additional argument project a's lib ("a.lib"). unfortunately, since project not create lib file, project b never find 1 , cannot built. is there feasible solution problem? thanks in advance! cheers, chris you should set ignore import library in project a. this option specifies (import) library generated configuration should not imported dependent projects.

ios - Push View Controller, Black Screen -

i'm pushing new view controller , passing data it. when run application can press button , push new view screen black. appreciated. - (ibaction)button:(id)sender { nsstring *firstfield = self.field.text; nsstring *secondfield = self.field2.text; self.resultsarray = [[nsarray alloc] initwithobjects:firstfield, secondfield, nil]; nsuinteger randomresult = arc4random_uniform(self.resultsarray.count); self.label.text = [self.resultsarray objectatindex:randomresult]; imagesviewcontroller *ivc = [[imagesviewcontroller alloc] init]; ivc.label = self.label.text; [self.navigationcontroller pushviewcontroller:ivc animated:yes]; } when you're using storyboard, , want push view controller in code (rather segue), need give controller identifier, , create this: imagesviewcontroller *ivc = [self.storyboard instantiateviewcontrollerwithidentifier:@"myidentifier"]; ivc.label = self.label.text; [self.navigationcontroller

google app engine - Static_dir working locally on Development sever not in Production - PHP GAE 1.8.2 -

i getting following error logs in production server on php version of gae static file referenced handler not found: stylesheets/it%20issue/style.css static file referenced handler not found: scripts/it%20issue/script.js static file referenced handler not found: scripts/it%20issue/jquery.min.js but not these errors when run them locally using d:\python\python.exe d:/google_appengine_1.8.2/google_appengine/dev_appserver.py --php_executable_path=d:\php\php-cgi.exe . here part app.yaml file handlers: - url: /stylesheets/ static_dir: stylesheets/ - url: /images/ static_dir: images/ - url: /scripts/ static_dir: scripts/ and here part of php file calls these files. <?php <html lang="en"> <head> <meta charset="utf-8" /> <title>secured page</title> <link rel="stylesheet" type="text/css" href="/stylesheets/it issue/style.css" /> <script type="text/javascript&

jquery - Opinion about migrate and use 2 tables on Rails 4 -

i trying build reservation system. until now, did reservation table , check availability using model: class reservations < activerecord::base # user_id # room_id # start_date # end_date # day (integer) # iscanceled (false automatically) belongs_to :user, :class_name => "users", :foreign_key => "user_id" belongs_to :room, :class_name => "rooms", :foreign_key => "room_id" end now want add "music lessons" table fetch , add courses repeats every day. model: class roomschedule < activerecord::base # name # start_date # end_date # room_id # day (integer) belongs_to :room, :class_name => "rooms", :foreign_key => "room_id" end in reservations controller, display programs using sql query: @all = reservations.where("start_date > ?", time.now.beginning_of_day).order("start_date asc") but want merge reservations table roomschedule table check , display current on

css - Twitter Bootstrap Navbar Dropdown Styling -

Image
i in process of styling top navbar can not see how remove top caret on dropdown panel (please see image below). please let me know if can help. thanks you can remove overriding bootstrap css this.. /* remove triangle */ .navbar .nav>li>.dropdown-menu:before,.navbar .nav>li>.dropdown-menu:after { content: none; } working example: http://bootply.com/66576

Python: Read data via serial port from Velleman k8090 [solved] -

i have velleman k8090 relay board trying read data. can write board fine, whenever output read data, strange characters diamond or upside-down question mark. here part of code: import serial com_port = 'com4' class velleman8090: def __init__(self, port=com_port): self.port = port self.baud_rate = 19200 self.data_bits = 8 self.parity = 'n' self.stop_bits = 1 self.flow_control = 'n' def open_device(self): self.talk = serial.serial(self.port, self.baud_rate, self.data_bits, self.parity, self.stop_bits) def firmware_version(self): data = packet(0x71, 0x00, 0x00, 0x00) self.talk.write(data) print self.talk.read() def close_device(self): self.talk.close() def chksum(cmd,msk,p1,p2): return (((~(0x04 + cmd + msk + p1 + p2)) + 0x01) & 0xff) def packet(cmd,msk,p1,p2): return str(bytearray([0x04, cmd, msk, p1, p2, chksum(cmd, msk, p1, p2), 0x0f])

php - Dynamic links linking to root domain -

i building site directory , having trouble linking sites.. the directory stores site domain in table , calls through foreach loop listing 25 separate domains on page, when click on links greeted localhost/directory (my site root) /linkeddomain.com rather displaying linkeddomain.com i put http://www. in front of array call href='http://www.".$row['siteurl']." however useless production because if enters domain http://www.theirdomain.com come out http://www.http://www.theirdomain.com does know how fix issue? thanks in advance luke make sure base url full url, including scheme , subdomain (if applicable). so: $base_url = "http://livesite.com"; $base_url = "http://localhost/john/customerx"; $base_url = "https://secure.livesite.com"; if links prefix base url should fine. note in urls left off trailing / . can chose include it, make sure in same way - have clear normalized form.

static Hashtable<Leader, ArrayList<Integer>> assignedLeader=new Hashtable<Leader, ArrayList<Integer>>(20); -

i need add elements hashtable , hashtable needs have array list. not able find way add elements in table properly. please me out. static hashtable<integer, arraylist<integer>> assignedleader = new hashtable<integer, arraylist<integer>>(20); just reference . static hashtable<integer, arraylist<integer>> assignedleader = new hashtable<integer, arraylist<integer>>(20); arraylist<integer> al=new arraylist<integer>(); al.add(1); al.add(2); al.add(3); assignedleader.put(1, al);

javascript - UI does not update when Updating ObservableArray -

when user clicks on row list in ui (html table tblallcert), have click event fires populate observable array should populate second html table (tblcertdetails). click event fires, can see data come back, , can see data in observable array, view not update. here overview of sequence in code- 1. user clicks on row html table tblallcert, fires selectthing method. 2. in viewmodel code, selectthing passes row data row selected getcertificatedetails(row) method. 3. getcertificatedetails(row) method calls getcertdetails(certificatedetails, source) function on data service (the data service gets data web api). getcertdetails(certificatedetails, source) function returns observable array. 4. once data returned selectthing, certificatedetails observable array populated. data point. step 5 should updating ui (specifically tblcertdetails html table), ui not updated. here view- <table id="tblallcert" border="0&q

How to join to an alias column in SQL Server? -

i have followig problem. when input empty want replace 'yellow_code' column aliased 'code'. when attempt inner join on aliased column 'code' 'grantcode' on table, following error description: "invalid column name 'code'". anyways bypass this? the select-column alias practically last thing applied statement , such not available joins "lower down" form part of query whole. can access alias if referenced outer select e.g. select my_code ( select 1 my_code .... ) x

c# - Modifying GCSettings.IsServerGC -

i have c# application loads default in workstation gc mode. application loads various libraries via reflection. if library loaded, i'd use server gc instead of workstation gc. possible? tried adding library's app.config file , doesn't anything, seems mesh msdn article: http://msdn.microsoft.com/en-us/library/ms229357.aspx this element can used in application configuration file. so out of luck here, or there way enable server gc? use app.config file this: <configuration> <runtime> <gcserver enabled="true" /> </runtime> </configuration>

c# - Stored Procedure has too many parameters -

posibale duplicate getting 'too many parameters passed' stored procedure on aspx page i'm using sqldatasource control update , delete functionality within gridview. keep getting runtime error procedure or function spupdatetest has many arguments specified. when run stored procedure in sql server works fine. when click on delete portion of gridview, works. however, when try update above error. <asp:sqldatasource id="sqldatasource1" runat="server" connectionstring="<%$ connectionstrings:dbcsdrugcards %>" deletecommand="spdeletetest" deletecommandtype="storedprocedure" insertcommand="spinserttest" insertcommandtype="storedprocedure" selectcommand="spgetalltest" selectcommandtype="storedprocedure" updatecommand="spupdatetest" updatecommandtype="storedprocedure">

c# - Check to see if row exists before adding it? -

i have certification process. right add people certification table if certified item in question. on view page, have procedureid , there active directory username. pass controller method adds them table. however if exist don't need add them update certification date , leave else alone. what having trouble checking if exist. [httppost] public actionresult addcertification(int procedureid, formcollection collection) { string[] certifiedusers = collection["members"].split(','); ipacs_certification ipacs_certification = new ipacs_certification(); foreach (var item in certifiedusers) { // certification exist? ipacs_certification doesexist = db.ipacs_certification.where(m => m.adusername == item && m.procedureid == procedureid).select(m => m); ipacs_certification.procedureid = procedureid; ipacs_certification.certifieddate = datetime.now; ipacs_certification.adusername = item;

Multiple OAuth redirect URIs for Dropbox Datastore API? -

i wonder how oauth 2.0 redirect uri works, app console on @ dropbox allows me add multiple url;s wonder need add every url needs access api? a small exemple: at page index.html user prompt connect dropbox, when connected user sent app.html there app self is. should redirect uri, index.html, app.html or both? you don't have register each url access api, 1 user redirected after authorizing app. you'll have 1 of these in production, might use localhost url during development.

Django. Restrict each user to only vote once -

i have situation , happy either 1 of 2 solutions, depending on more feasible/possible. have page displays event. event's name may not correct, , users have option suggest corrections. corrections stored in own table foreign key relationship event. once suggestion has been made, users can vote or down on suggestion. need restrict each logged in user's maximum vote 1. don't have slightest idea how this. my ideal solution: there many 5 suggestions displayed. each logged in user can vote on each of these 5 suggestions. once on each. my less ideal, still acceptable solution: there many 5 suggestions displayed. logged in user allowed vote or down on 1 of 5 suggestions. i'm not sure more practical. i'll provide models event , suggested name. please let me know if there's else need see. in advance! class event(models.model): def __unicode__(self): return unicode(self.id) id = models.bigintegerfield(blank = 'true', primary_key='tru

javascript - How to check if an AJAX response has HTML contents in jQuery? -

i have page 1 form , 2 possible responses in event of successful ajax call, 1 of returns status code. what need check response object in success callback html contents can display them on page. i know can access response in callback adding parameter, so: function success(response) { } the thing can't figure out how check if object has html contents. how can this? you want @ response headers html mime type. $.ajax pass jqxhr object success callback, can call .getresponseheader() on: function success( response, status, jqxhr ) { if( jqxhr.getresponseheader('content-type').indexof('text/html') >= 0 ) { ... } }