Posts

Showing posts from July, 2012

c++ - Getline string input to create a word -

i have program receives input , goes character through character avoid white spaces. need each 1 of characters aren't white spaces , stores them in string word. someone told me getline stores each character, has memory: then create while loop has (!= ' ')condition , use string.append('x') function "add" each character string variable you've created until have word. i understand concept don't know how it. here simple application takes string , filters out spaces. // reading text file #include <iostream> #include <sstream> #include <fstream> #include <string> using namespace std; int main () { string input; stringstream filter; cout << "enter string \n"; cin >> input; for(int = 0; i<input.length(); i++){ if(input.at(i)!=' '){ //chech see space or not filter << input.at(i); //if not space add stringstream filter } } string outp

sql - TSQL Comparing 2 uniqueidentifier values not working as expected -

i'm trying compare 2 uniqueidentifier values shown in query below. however, if 1 value null , 1 value isn't, result 'same'?! i'm sure both values uniqueidentifiers, , have tried casting both values uniqueidentifier make absolutely sure. 2 values being compared coming different databases different collations. collation make difference? ideas appreciated. select [result] = case when [target].staffid <> [source].staffid 'different' else 'same' end ... if replace <> = query thinks 2 null values don't match. edit: i used: declare @empty uniqueidentifier set @empty = '00000000-0000-0000-0000-000000000000' ... isnull(somevalue, @emtpy) <> isnull(othervalue, @empty) ... null neither equal nor equal nothing. you'd check null values comparing is null . example, somefield null you using coalesce you're trying -- make sure use same data types (in case uniqueidentifier): ...

jquery selectors - call the change event after the SELECT is populated? -

so, have dynamically generated select, gets populated php-mysql table. have on change event select, deals times user changes selected value on page. when change event fired, populate 3 input boxes values select option. it works fine, except, when enter (or refresh) page select, select gets populated, onchange event not fire. sure onchange gets fired, happens before select populated there no values offer. can do? how can call change event after select populated properly php? my code onchange is: $(document).ready(function(){ $('#myselect').change(function(){ var selected = $(this).find('option:selected'); $('#pux').val(selected.data('foo')); }).change(); }); so basically, want input name , id = pux filled data-foo value of select option. mean, structure of options of select like: <option id="1" value="whatever" data-foo="something_important">first option</option> and of cours

css3 - css, ios, iPad, -webkit-overflow-scrolling: touch bug, large content gets cut off -

i have table thousands of rows (2317 precise) data coming database. putting table inside div scrollable. html: <div class="longlist"> <!-- table thousands of rows --> </div> css: .longlist {overflow: auto; height: 550px; margin: 0 auto; -webkit-overflow-scrolling: touch;} the problem is, list cutting off on mobile safari on ipad (on desktop browsers works fine) @ row number 1900 (half of row shown) , rest of list showing blank. rows not showing after 1900th row. all rows shows if remove '-webkit-overflow-scrolling: touch;' styles. has come across or has idea how fix this? adding position:fixed resolved issue different problem started that, that's story (see -webkit-overflow-scrolling: touch, large content gets cut off when specifying width ). .longlist {overflow: auto; height: 550px; margin: 0 auto; -webkit-overflow-scrolling: touch; position:fixed; }

iOS: Autolayout with child view controllers -

i've been using autolayout couple of weeks now. currently, i'm using 3rd party library called flkautolayout makes process easier. i'm @ point can construct views way want, without problem. however, on past 4 days @ work i've been struggling autolayout once viewcontrollers involved. i'm fine sorts of uiviews... reason, every viewcontroller.view total demon. i've had nothing problems getting viewcontroller.view size way want , ever deeper problem uiviews of child viewcontrollers not receive events when using autolayout. child viewcontrollers work fine when designating frames manually, breaks down autolayout. i don't understand what's different viewcontroller's uiview makes different others... mind melting in frustration. ios messing viewcontroller views behind scenes or something? sample image http://i39.tinypic.com/6qeh3r.png in image, red area belongs child view controller. area should not going past bottom subview (the card says three). sh

pointers - Lisp, cffi, let and memory -

i've build toy c++ library create qt window lisp. know common-qt exists, i'm trying learn how use cffi. right now, have 4 binded functions : create-application : create qapplication , return pointer create-window : create qmainwindow , return poiner show : show window specified argument exec : qt exec function here lisp code work : (defctype t-app :pointer) (defctype t-window :pointer) (defcfun (create-application "create_application" ) t-app) (defcfun (exec "exec") :void (app t-app)) (defcfun (create-window-aalt "create_window_aalt") t-window) (defcfun (show "show") :void (o t-window)) (defparameter (create-application)) (defparameter w (create-window-aalt)) (show w) (exec a) but if use let or let*...i have memory fault ! (let* ((a (create-application)) (w (create-window-aalt))) (show w) (exec a)) corruption warning in sbcl pid 1312(tid 140737353860992): memory fault @ a556508 (pc=0x7ffff659b7f1, sp=0x7ff

html - Sticky footer with a variable height -

i know there lot of same topics, there css way stick bottom footer height in % without overflowing body , header because of absolute position ? i'm trying stick 1 : html,body{ height: 100%; } #header{ background-color: yellow; height: 100px; width: 100%; } #holder { min-height: 100%; position:relative; } #body { padding-bottom: 100px; } #footer{ background-color: lime; bottom: 0; height: 100%; left: 0; position: relative; right: 0; } with html : <div id="holder"> <div id="header">title</div> <div id="body">body</div> <div id="footer">footer</div> </div> code here : http://jsfiddle.net/tsrkb/ thanks ! if use display:table base , sticky footer can size , pushed down if content grows. http://dabblet.com/gist/5971212 html { height:100%; width:100%; } body { height:100%; width:100%;

ruby on rails - before(:each) vs just before -

i new ruby on rails. , playing around testing is there difference between before(:each) #some test code end and before #some test code end the before method accepts scope parameter defaults :each . when leave out, it's implied mean :each , 2 examples exact same thing. here helpful tidbit rspec rdoc, module: rspec::core::hooks#before : parameters: scope (symbol) — :each , :all , or :suite (defaults :each ) conditions (hash) — constrains hook examples matching these conditions e.g. before(:each, :ui => true) { ... } run examples or groups declared :ui => true .

mysql - Merge Multiple .sql Table Dump Files Into A Single File -

suppose have database , table b. given multiple .sql files b1,b2,...,bn each of corresponds mutually exclusive table dump of b how go combining files b1,b2,...,bn single .sql table file? or how combine import of individual files single table? there no special tools this. can concatenate files: $ cat b1.sql b2.sql b3.sql > b_all.sql except typical content of these .sql files drop table, create table, lot of insert statements. if each of individual dump files formatted that, if restore them in sequence, each drop table , erase data imported preceding file. you can create dump file without drop/create statements: $ mysqldump --no-create-info <database> <table> ... but if have dump files (can't re-dump them), , want rid of drop/create statements in first file: $ ( cat b1.sql ; cat b2.sql b3.sql | sed -e '/^drop table/,/^-- dumping data/d' ) > b_all.sql

symfony - Access a bundle (sncRedisBundle) from within an Extension -

i have installed sncredisbundle , used predis element of within controller, using: $this->container->get('snc_redis.default'); i want same within extension: class myextension extends extension { /** * {@inheritdoc} */ public function load(array $configs, containerbuilder $container) { $configuration = new configuration(); $config = $this->processconfiguration($configuration, $configs); $redis = $container->get('snc_redis.default'); } } but get: the service definition "snc_redis.default" not exist. is scoping issue? how access redis within extension? thanks! services: site: class: emlaktown\appbundle\site\site arguments: [%api_url%, "@request_stack", "@service_container"] .... use symfony\component\dependencyinjection\container; .... public function __construct($apiurl, requeststack $requeststack, container $container) {

file - How to find, filter and copy directory and contents to a location dictated by part of find result ) in Powershell -

using powershell preferably, otherwise vbscript. perl or batch. (any way it's not manual job). i have list of user profiles: \\fileserver\profiles\user1\findmedirectory\dir1 \\fileserver\profiles\user2\findmedirectory\dir1 \\fileserver\profiles\user3\notfindme\dir1 i wish copy instances of "findmedirectory" recursively down to \\fileserver\newprofilesdirectory\user1\ \\fileserver\newprofilesdirectory\user2\ \\fileserver\newprofilesdirectory\user3\ by finding example first entry: \\fileserver\profiles\user1\appdata\findmedirectory\dir1 `$dest = \\fileserver\newprofiledirectory $user = user1 (from result above) $copydir = findmedirectory $complete_dest = $dest & $user & $copydir (i.e. \\fileserver\newprofiledirectory\user1\findmedirectory ) ` there other files in both locations underneath user1, user2 , user3. so far have: get-childitem "\\fileserver\profiles" -filter "findmedirectory" -force -recurse | where-object {$_.psis

sql - Why does MySQL DATE_FORMAT function return NULL when formatting a TIME value? -

select date_format('8:48:30 am', '%h:%i:%s') it returns null why ? but when using select date_format(curtime(), '%h:%i:%s') it return formatted value. it's returning null because mysql isn't parsing string valid datetime value. to fix problem, use str_to_date function parse string time value, select str_to_date('8:48:30 am', '%h:%i:%s %p') then, time value converted string in particular format, use time_format function, e.g. 24-hour clock representation: select time_format(str_to_date( '8:48:30 am', '%h:%i:%s %p'),'%h:%i:%s') returns: -------- 08:48:30

wcf - Could not find default endpoint element that references contract -

i know has been beaten death, cannot work should. have wcf service several contracts. work fine when calling them directly e.g. http://merlin.com/companyservices/companywcfservice.svc/get_document_dates_received/223278 have used wcf service on infopath forms , nintex workflows. create simple asp.net application, such done in http://www.webcodeexpert.com/2013/04/how-to-create-and-consume-wcf-services.html . able add service reference described in article. added button form, , added following code in button1_click event: protected void button1_click(object sender, eventargs e) { servicereference1.companywcfserviceclient x = new servicereference1.companywcfserviceclient(); var result = x.get_document_dates_received("223278"); } when click on button error: "could not find default endpoint element references contract 'servicereference1.icompanywcfservice' in servicemodel client configuration section. might because no configuration file found

python while loop does not terminate -

i writing program counting score of 2 users. game ends when either of them scores ten , respective player wins. i wrote while loop as: while (score1 != 10) or (score2 != 10): ... and program not terminate. here code: player1 = input("enter name player1") player2 = input("enter name player2") score1=0 score2=0 print ("score player1 is: %d,score player2 :%d" %(score1,score2)) while (score1 != 10) or (score2 != 10): player =input("enter name player") if player player1: score1=score1+1 if player player2: score2=score2+1 print ("score player1 is: %d,score player2 :%d" %(score1,score2)) looks want while (score1 != 10) , (score2 != 10): since want loop end either 1 of scores reaches 10 , @ point score != 10 false and, consequently, entire loop-condition no longer satisfied. (score1 != 10) or (score2 != 10) require both scores 10 before exiting.

Facebook Token returns Empty Android -

im having issue when try sign face book following in log cat 07-11 10:15:07.757: w/com.facebook.session(8910): should not pass read permission (user_likes) request publish or manage authorization 07-11 10:15:07.772: w/com.facebook.session(8910): should not pass read permission (email) request publish or manage authorization 07-11 10:15:07.777: w/com.facebook.session(8910): should not pass read permission (user_birthday) request publish or manage authorization 07-11 10:15:07.787: w/com.facebook.session(8910): should not pass read permission (user_location) request publish or manage authorization 07-11 10:15:08.797: v/log_tag(8910): token= 07-11 10:15:08.797: v/log_tag(8910): token=false i followed proper documentation of facebook used code generate sha key , placed on console disable sand box enable face book login disable deep linking still no luck code used face book following facebookbtn.setonclicklistener(new view.onclicklistener() { @override pub

audio - Play virtual surrounding sound without a usual speaker (with a single device) -

i know whether possible play sound without usual speaker. requirement is... 1. want simulate same experience of surrounding system without usual speaker 2. expected device single device, simulate sorrounding effect thanks in advance sharing knowledge.... i think feonic devices doing same thing. pls refer wikipedia link http://en.wikipedia.org/wiki/feonic

java - where are the Google app engine endpoints -

im developing simple app android. created few entity's, nothing poem filled in them string. ive been using google app engine , works in browser fine, deployed little project. want use retrofit lib grab list of entity's made in simple loop object class make them, how define endpoints! cant seem find them. new @ networking stuff i'm trying hard. https://developers.google.com/eclipse/docs/endpoints-androidconnected-gae looks need create app linked google engine. way? if had team needed access end points on iphone app/ if having android app not created using appengine connected app option, can still create app engine code right clicking , choosing options google->generate app engine backend . after modifying backend code, can generate client library backend right clicking , choosing option google->generate cloud endpoint client library ,then deploy app engine , start accessing endpoints android app. if having android app , app engine code not yet conn

fetch - Fetching data from database using PHP -

i have tried fetch data priority table of elective_mgmt database.the source code given below : <?php $connect = mysql_connect("localhost","root",""); mysql_select_db("elective_mgmt",$connect); $result = mysql_query($con,"select * priority"); echo "<table border='1'> `<tr> <th>name</th> <th>roll</th> <th>email</th> <th>priorityone</th> <th>prioritytwo</th> <th>prioritythree</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['roll'] . "</td>"; echo "<td>" . $row['email']. "</td>"; echo "<td>" . $row['priorityone']."</td>"; echo "<td&quo

C compare pointers -

recently, wrote code compare pointers this: if(p1+len < p2) however, staff said should write this: if(p2-p1 > len) to safe. here, p1 , p2 char * pointers, len integer. have no idea that.is right? edit1: of course, p1 , p2 pointer same memory object @ begging. edit2:just 1 min ago,i found bogo of question in code(about 3k lines),because len big p1+len can't store in 4 bytes of pointer,so p1+len < p2 true .but shouldn't in fact,so think should compare pointers in some situation : if(p2 < p1 || (uint32_t)p2-p1 > (uint32_t)len) in general, can safely compare pointers if they're both pointing parts of same memory object (or 1 position past end of object). when p1 , p1 + len , , p2 conform rule, both of if -tests equivalent, needn't worry. on other hand, if p1 , p2 known conform rule, , p1 + len might far past end, if(p1-p2 > len) safe. (but can't imagine that's case you. assume p1 points beginning of memory

c# - Cannot open Service Control Manager on computer ''. This operation might require other privileges -

i have used impersonation process privilages remote computer username , password of administrator. i'm still getting above error. computer not in domain. in workgroup. , logonuser function advapi32.dll used impersonate has domain 1 of parameter. logonuser(user, domain, password, logon32_logon_network, logon32_provider_default, ref tokenhandle); i've passed null value domain. problem or else. there way have access services of remote computer in workgroup.

html - Sticky Footer not working -

i'm trying make footer going down contents appears, i'm getting footer in middle of page, right below of navbar, want @ bottom of page , automatically pushed content, tried tutorial here don't know if did right, didn't, because isn't working, can me? <div id="wrapper"> <div id="banner"> <img src="../img/banner2.png" width="1024" height="173" longdesc="../index.php" alt=""/> </div> <div id="navigation"><?php include('c:/xampp/htdocs/legendofgames/includes/navbar.php'); ?> <div id="apdiv4"> <?php include('c:/xampp/htdocs/legendofgames/includes/menu_cat.php'); ?> </div> <div id="fb-root"></div> <div id="like"> <div class="fb-like-box"></div></div> <div id="apdiv2"> <!-- templatebegineditable name=&qu

Remove Duplicate title in database table mysql -

we have 2 tables called : "post" , "post_extra". summary construction of "post" table's are: id, postdate, title, description. and post_extra are: eid, news_id, rating, views "id" filed in first table connected "news_id" second table. there more 100,000 records on table, many of them duplicated. want keep 1 record , remove duplicate records on "post" table have same title, , remove connected record on "post_extra" i ran query on phpmyadmin server crashed, , had restart it. delete e post p1, post p2, post_extra e p1.postdate > p2.postdate , p1.title = p2.title , e.news_id = p1.id how can this? i think the id maximum in case of highest posteddate if can try code delete post id in (select max(id) post group title)

Calling functions in array index -

short 1 time. why doesn't work? function identity($x){$x} @(1,2,3)[identity(1)] (these work) identity(1) @(1,2,3)[1] you need make execute identity(1) first putting parenthesis. @(1,2,3)[(identity(1))]

asp.net mvc 3 - How to check checkbox for only checked item on jquery success function -

as need check items has value true controller on jquery success function. <script type="text/javascript"> $("#pid").change(function () { $.ajax({ url: '@url.action("getcheckedchannel","channels")', type: 'post', data: { pid: $(this).val() }, success: function (data) { (var = 0; < data.length; i++) { //if (data[i].ischecked == "1") { var status = data[i].ischecked ? true : false; $(".ischeck").attr("checked", status); //} } } }); }); </script> you can write this data[i].ischecked ? $(".ischeck").prop("checked", true) : ''; also consider using . prop instead of . attr set checked property

g wan - comet.c hanged when there are more than 6 connections -

another question coment.c in gwan. in browser, open many pages of csp_comet.html, start same feed same freq. of 1 sec. ajax calls comet.c timestamp. but, when there many pages(about 6 pages), newly opened page keep opening without data displaying. at moment, other browser, other scripts , static pages of same vhost cannot accessed. browsers display nothing. tried visit other vhosts( of same listener in gwan), works fine latency. i tried kill pages, , found had been dead( 0 ok shown instead of gmt time in csp_comet.html, , stop updating). keep on killing pages, last hanging request became responsing show data. @ state, there 6 active comet-feeding. who can tell happened? or, can reproduced in side? my gwan version 4.3.14 ubuntu 12.04.2 lts \n \l (3.2.0-49) 64-bit result of ../?report --------------------------- requests all: 39 (76.92% of cache misses) http: 13 (33.33% of requests) errors: 1 (2.56% of requests) csp: 50 (128.21% of requests) exceptions: 0

image - How do I change my background on scroll using CSS? -

my website has perfect full page background image. grabbed code css tricks . if visit my site can see in action. what i'd know is, there way can have image change different image once scroll length? my aim have same image speech bubble coming out of dogs mouth , i'm guessing 2 images this. is possible in css only?????? here code using. html { background: url(http://robt.info/wp-content/uploads/2013/06/funny-kids-comic-animals.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } as others said, nop, can't css , little js code can you. ex. jquery(window).scroll(function(){ var fromtoppx = 200; // distance trigger var scrolledfromtop = jquery(window).scrolltop(); if(scrolledfromtop > fromtoppx){ jquery('html').addclass('scrolled'); }else{ jquery('html').removeclass('scrolled'); }

facebook android integration not working for share with friends -

i have made simple program in android facebook android integaration,i have tried below:it shows facebook login dialog box , logged in after shows myapp , ask share facebook friends when press"yes"..it says failed post on wall"....please tell me whats problem,, code below: main.java package com.example.facbk; import com.facebook.android.asyncfacebookrunner; import com.facebook.android.dialogerror; import com.facebook.android.facebook; import com.facebook.android.facebook.dialoglistener; import com.facebook.android.facebookerror; import com.parse.logincallback; import com.parse.parse; import com.parse.parsefacebookutils; import com.parse.parseuser; import android.net.parseexception; import android.os.bundle; import android.provider.syncstatecontract.constants; import android.app.activity; import android.content.context; import android.content.intent; import android.content.sharedpreferences; import android.content.sharedpreferences.editor; import android.util.log;

Python: get ordinal from time -

i want regression on several features, , 1 of them time. therefore, need convert time quantitative variable, e.g. integer. in particular, obtain ordinal number datetime.time object. there direct method it? i know can done method toordinal() datetime.date objects, same method not exist datetime.time there doesn't seem built-in method in datetime module . format not meant ordinal values since doesn't include date , comparing events different dates give wrong order. if own code returning datetime.time recommend using timestamps time.time() in time module instead. timestamps can converted formatted time if need make human readable. even though datetime.time doesn't have built in converter timestamp it's easy self, convert each time value seconds , add them up: def dtt2timestamp(dtt): ts = (dtt.hour * 60 + dtt.minute) * 60 + dtt.second #if want microseconds ts += dtt.microsecond * 10**(-6) return ts

rest - Jasper webservice: Invalid resource descriptor -

i try upload simple image via rest webservice jasper server. this http request/response, i'm getting "400 bad request: invalid resource descriptor" . tried copy valid resource descriptor repository , re-upload gives same error! (the dots represent \r\n , \t chars.) t 10.84.6.166:36057 -> 10.84.6.166:8080 [ap]. put /jasperserver/rest/resource/reports/customers/3221/image01.gif http/1.1. user-agent: useragent. host: 10.84.6.166:8080. accept: */*. cookie: jsessionid=5d8d24835e61ed65abd982964243c06b. content-type: multipart/form-data; boundary="72e01e9922f8bb1669638258c2a2a155". content-length: 23796. expect: 100-continue. . t 10.84.6.166:8080 -> 10.84.6.166:36057 [ap] http/1.1 100 continue. . t 10.84.6.166:36057 -> 10.84.6.166:8080 [ap] --72e01e9922f8bb1669638258c2a2a155. content-disposition: form-data; name="resourcedescriptor". content-length: 811. content-type: text/plain; charset=utf-8. content-transfer-encoding: 8bit. . <

Thunderbird mac always send return receipts even after i set "never send" -

i using thunderbird mac 17.0.7, send "return receipts" have set "never send return receipt". did act expected, don't know when , why become so. have check global setting , account setting, "never send return receipt". ideas? thanks! if server exchange, it's a feature .

java - How to profile hibernate JPA session information? -

we have spring hibernate jpa web application in production. there suspect of memory leak in session objects. uploading excel records using apache poi mysql. commit frequency 10 records, each commit takes 5 10 seconds pause , cpu reaches 100% throughout import process. there way profile hibernate sessions in application , find process causing such high cpu usage. checking out rhinos hibernate profiler seems confusing in configuration , needs changes in code. since need profile production or stage instance, there jpa hibernate session information profiler without changes application configuration/code? use visual vm, plug-ins installed. attach app's jvm pid when start up. it'll show memory, threads, , lots more. i don't think it'll idea profile on production server. put code on box , run significant load long period of time. that'll show problem.

Android: Unable to get same keystore from Personal Information Exchange file -

i have update android app on google play store. signing apk, previous developer had used personal information exchange file, named mycert.p12. used following command keystore file: keytool -importkeystore -srckeystore e:\mycert.p12 -destkeystore e:\dstmobile2013\key\mycert.keystore -srcstoretype pkcs12 the keystore imported successfully, when signed apk keystore , uploaded on google play, gave me following error: you uploaded apk signed different certificate previous apks. must use same certificate. existing apks signed certificate(s) fingerprint(s): [ sha1: c7:be:c1:f7:72:f6:1d:87:53:49:74:2e:63:67:5a:63:27:07:f1:72 ] , certificate(s) used sign apk uploaded have fingerprint(s): [ sha1: 26:20:f8:1f:48:43:ff:8e:ae:a8:0b:37:ce:22:c8:3d:85:89:f8:b3 ] from, error, clear keystore used sign previous apk , 1 used sign apk not same. not getting why not generating same keystore or did made mistake. please suggest.

android - Intent for Google Maps 7.0.0 with location -

at first know there several similar questions on stackoverflow. curriently use geo scheme addressing points can handled other apps. like in example of android documentation (by way seems outdated rfc out!) tried use this: geo:50.95144,6.98725?q=50.95144,6.98725%20(disneyland) so intent chooser can select app showed me in case of google maps disneyland marker on it. seems update installed removes support. message place cannot been found. i tried understand rfc 5870 defines 'geo' uri scheme. don't exactly. correct not possible @ define lable? how can link position google maps? the whatsapp intent is: start u0 {act=android.intent.action.view cat=[android.intent.category.browsable] dat= https://maps.google.com/maps?q=loc:lat,lng+(you)&rlz=1y1txls_ende543de543 flg=0x3000000 cmp=com.android.browser/.browseractivity (has extras)} pid 2115 so if use following intent uri: string geouri = "http://maps.google.com/maps?q=loc:"

where condition is not working in rails -

in usrshow.html.erb <%= form_for userview_path, :method => 'get' |f|%> <%= f.collection_select :city, place.all, :id, :name, :prompt => 'select place' %> <%= text_field_tag :search %> <%= submit_tag "search"%> <% end %> in hotels_controller def usrshow if params[:search].present? @hotels = hotel.where(["city_id = ? , hotels ?",params[:city], "%#{params[:search]}%"]) else @hotels = hotel.all(:order => 'id desc') end respond_to |format| format.html # index.html.erb format.json { render :json => @hotels } end end i have search , display hotels based on selected city.but code not working. you don't need [] brackets in where : @hotels = hotel.where("city_id = ? , hotels ?",params[:city], "%#{params[:search]}%") specify error. not working bad description you can check sql query in co

histogram - change 'breaks' argument of hist() function with R -

i want following : open window (easy tcl/tk) add " breaks " field, " apply " button, , " accept " button window (easy too) loop while < nbfiles read file (easy) display histogram of data in current file in window (need help) user can provide breaks argument of hist() function in field, , once pushes apply button, new histogram configuration displayed in window (need help) wait accept button pushed (need help) >> histogram saved in file (easy) close window (easy) is possible ? can r , tcl tk ? idea ? thanks yes, possible, tcltk.. this need ? ciao

javascript - When does it become too many libraries? -

i have been asked create small javascript application, takes in data (invoices) , returns outcomes (eg whether paid?) to me creation have used multiple libraries , frameworks, have used; backbone js jquery bootstrap i looking @ other plugins use? point ever come have used much? if so, when happen? many thanks, luke when have multiple libraries being used, come across case code being run simultaneously, causing massive slow down. if there slow down of performance, it's programmer move of processing server. if have multiple levels of encapsulation of code, can have multiple libraries being used simultaneously. even if have many libraries, problem may cause bandwidth used during transfer. please remember, can move of business logic server. can make code: readable scalable structure secure but, these come programming.

oop - Realization in C++ -

need in understanding "realization" relationship classes. can give me c++ example on this? i browsed , got know that, class implementing interface example of realization. didn't better picture. how represent same using uml? thanks realization specifies contract between 2 or more types. 1 type (here interface imammals) defines contract , other type (cat, dog) promises carry out. below code lazy example of realization... #include<iostream> using namespace std; class imammals{ public: virtual void walk() = 0; }; class cats: public imammals { public: void walk() { cout<< "cat walking" << endl; } }; class dogs: public imammals { public: void walk(){ cout<< "dog walking" << endl; } }; int main(void) { cats acat; dogs adog; imammals *ptrmammals = null; ptrmammals = &acat; ptrmammals->walk(); ptrmammals = &adog; ptrmammals->wal

html - How to print the characters in the next line for a <td> tag with fixed layout? -

whenever tried add more characters in <td> tag, table expands according size. use table-layout:fixed; , overflow:scroll; overcome characters missing. need have characters printed in next line inside <td> tag. .styletable { margin:0px;padding:0px; width:97.9%; box-shadow: 10px 10px 5px #888888; border:1px solid #000000; -moz-border-radius-bottomleft:0px; -webkit-border-bottom-left-radius:0px; border-bottom-left-radius:0px; -moz-border-radius-bottomright:0px; -webkit-border-bottom-right-radius:0px; border-bottom-right-radius:0px; -moz-border-radius-topright:0px; -webkit-border-top-right-radius:0px; border-top-right-radius:0px; -moz-border-radius-topleft:0px; -webkit-border-top-left-radius:0px; border-top-left-radius:0px; }.styletable table{ border-collapse: collapse; border-spacing: 0; width:100%; height:100%; margin:0px;padding:0px; table-layout:fixed; }.stylet

sql server - SQL Group By and window function -

Image
i struggling little bit sql statement , hoping if willing point me in right direction. below picture of table: as can see here have column called 'state'. want group 'state' associated particular buildid , display them in column on sql output. i close not quite there. in next picture below example of statement have used try , achieve this: as can see here, has done sum , added totaltime , created columns require. instead of grouping 1 record, has created 2 lines per buildid. 1 value 'running' state, record value state of 'break' , record contains value 0 on both states. now want group 1 record each buildid. picture have added below: the above image how want records displayed. problem have added [state] = running, know wrong using example. can see 'break' column has no value. i hope makes sense , hoping if point me in right direction? here example on sql fiddle http://sqlfiddle.com/#!3/7b6b9/2 thanks taking time read

Android: change text color of an item in listview -

Image
i have implemented side menu navigation . left side menu listview , onclick of item opens activity. want change text color of item when user clicks on , remain color of item until clicks on item. , after click on item change color of first item default color , change other item color , on. or code example highly appreciated. in advance. use checkedtextview text of list item , set android:textcolor value color state list resource . remember set list view: android:choicemode="singlechoice" well

python - numpy savetxt formated as integer is not saving zeroes -

i trying save numpy.array .csv in following way. with open("resulttr.csv", "wb") f: f.write(b'imageid,label\n') numpy.savetxt(f, result, fmt='%i', delimiter=",") result numpy.array consists of 2 columns, first column indices (numbers 1 through n) , second column values (0,9). unfortunately have problem whenever there 0 in second column nothing written resulting .csv file in second column. in other words first 5 rows of array looks this: [[ 1.00000000e+00 2.00000000e+00] [ 2.00000000e+00 0.00000000e+00] [ 3.00000000e+00 9.00000000e+00] [ 4.00000000e+00 9.00000000e+00] [ 5.00000000e+00 3.00000000e+00] and first 5 rows of .csv file this: imageid,label 1,2 2 3,9 4,9 5,3 it looks me code should work , not saving zeroes seems me weird. have idea can possibly wrong code writing .csv file? edit: just compleetnes python version 2.7.2 , it's running on mac os x 10.9.2 thank in advance help.

android - onActivityResult in dialog fragment -

i'm taking photo dialog fragment. , need startactivityforresult(takepictureintent, actioncode); @override public void onactivityresult(int requestcode, int resultcode, intent imagereturnedintent) { super.onactivityresult(requestcode, resultcode, imagereturnedintent); switch (requestcode) { case select_photo: getactivity(); if (resultcode == activity.result_ok) { uri selectedimage = imagereturnedintent.getdata(); string[] filepathcolumn = { mediastore.images.media.data }; cursor cursor = getactivity().getcontentresolver().query(selectedimage, filepathcolumn, null, null, null); cursor.movetofirst(); int columnindex = cursor.getcolumnindex(filepathcolumn[0]); setpic(); } break; case action_take_photo_b: { getactivity(); i

database - Calculate resources in a webbrowser game in real time -

i decided write web browser game. mind comes sick when try think how code resources shown of each player when display website. for example: user 1 have 500 gold now, , produces +100 gold each hour, how can show real resources when user open website? what best way? i think update database of each user adding resources every second suicidal. the think have no idea how code. any ideas? thanks when user interacts website, @ date of last time updated gold amount. if it's more 1 hour, increment amount of gold of number of hours passed since it's last interaction, , update stored date. you may optimisation on principle avoid testing @ each user request during session (use cache, of store date in session). update: store next update time instead of last, avoid multiple calculations (that store timestamp of current update + 1 hour). , compare current time stored time.

qt - QUdpSocket setSockOpt -

i have old code, use flags in socket: unsigned char str_optval [8] = {0xfc, 0x08, 0xff, 0x33, 0xcc, 0xff, 0xaa, 0x0}; res=setsockopt(sid,sol_ip,ip_options, (char*)&str_optval,sizeof(str_optval)); how can change place use qudpsocket? can't find analog setsockopt in qudpclass. qabstractsocket provide setsocketoption, allow 4 variants flags (enum). need in linux version, if native func it's ok. http://qt-project.org/doc/qt-5.0/qtnetwork/qabstractsocket.html#socketoption-enum socket options not limited udp datagrams. having said that, qt has limited number of options can set on socket. common options being able set. rest platform specific stuff. aside: hardcoded literals, in quoted code, big no-no. non-portable , nightmare maintain. whatever do, @ least change literals names defined in standard headers.

javascript - adding an InfoBox google map -

i'm trying incorporate info box google map: have following code function initializeswansea() { var latlng = new google.maps.latlng(51.656591, -3.902619); var styles = [ { featuretype: 'landscape.natural', elementtype: 'all', stylers: [ { hue: '#ffffff' }, { saturation: -100 }, { lightness: 100 }, { visibility: 'on' } ] },{ featuretype: 'water', elementtype: 'geometry', stylers: [ { hue: '#93ddf6' }, { saturation: 72 }, { lightness: 4 }, { visibility: 'simplified' }

html - Absolute positioning inside relative? Why doesn't this work? -

i'm complete beginner @ webprogramming here's problem: this have right now: http://jsfiddle.net/h2v7w/5/ <div> <ul> <li>1</li> </ul> <ol> <li>a</li> </ol> </div> div{ position: relative; border: 1px blue solid; } ul, ol { border: 1px red solid; } but add "position: absolute" 2 listings height of div-element decreases 1px not want. http://jsfiddle.net/h2v7w/6/ div{ position: relative; border: 1px blue solid; } ul, ol { border: 1px red solid; position: absolute; } why happening 2 listings seem have jumped out of div? thought have "full control" once absolute positioning inside relative? according spec , absolute box's position (and possibly size) specified 'top', 'right', 'bottom', , 'left' properties. these properties specify offsets respect box