Posts

Showing posts from June, 2012

java - Sum of integers in an array and multiplying integer by 1.5 -

i having issue getting sum of integers in array , issue getting product of integer * 1.5. code below off new java , have been @ hours , hours. purpose of program enter number of hours worked, each day, 5 days. that, , pay rate, you're supposed output average hours worked, total hours, , total pay. pay should include overtime if there any. appreciated. string name; string id; int payrate; int[] hours = new int[5]; int avghours; int totalpay; int totalhours = 0; int counter; int overtime = 0; //housekeeping system.out.print("enter employee's name: "); inputstring = input.readline(); name = inputstring; system.out.print("enter employee's id: "); inputstring = input.readline(); id = inputstring; system.out.print("enter employee's pay rate: "); inputstring = input.readline(); payrate = integer.parseint(inputstring); //hourspay counter = 0; for(hours[counter] = 0; counter < 5; counter++) { system.out.print("how many ho...

ios - Sort by string and ignore number for display in UITableView -

i need sort alphabetic data in table view , ignore numbers, : - 123 test - 939 urne - 403 vase currently, data loaded this: - 939 urne - 123 test - 403 vase what's best choice ignoring numbers? you can store data separately in dictionaries, like, array ( { "number" = 403 "text" = "vase" }, { "number" = 403 "text" = "vase" } ) then can sort using, nssortdescriptor * descriptor = [nssortdescriptor sortdescriptorwithkey:@"text" ascending:yes]; [array sortusingdescriptors:[nsarray arraywithobject:descriptor]];

Android Typeface createFromAsset -

i have custom view draws text onto canvas. want change font font stored in assets folder. i using android studio created folder src/main/assets , placed ttf files in there. paint txt = new paint() typeface font = typeface.createfromasset(getassets(), "robotobold.ttf"); txt.settypeface(font); problem android studio doesn't recognize getassets() inside custom view, recognizes inside activity. have tried passing typeface through activity when it doesn't change font. you can use view 's getcontext() method current context , use assets : typeface font = typeface.createfromasset(getcontext().getassets(), "robotobold.ttf");

set the width and height of jquery popup large images -

i have used jquery popup gallery website want set resizable image fixed height , width. cant exact code here code gallery <script type="text/javascript" src="javascripts/top_up-min.js"></script> <script type="text/javascript"> topup.addpresets({ "#images a": { fixed: 0, group: "images", modal: 0, title: "gallery" }, "#movies": { resizable: 0 } }); </script> and code images in body part <span id="images"> <a href="images/photos/1.jpg" toptions="overlayclose = 1"> <img src="images/thumbnails/1.jpg"/> </a> <a href="images/photos/1.jpg" toptions="overlayclose = 1"> <img src="images/thumbnails/1.jpg"/> </a> </span> image dimensions can controlled thr...

css - Proper way to use divs to align divisions of web page on left or right side -

i getting web development project , trying learn how setup divs elements left aligned , others right aligned. many moons ago before 's around use table , set alignment of cells can't seem find equivalent div's. in below html code trying make text "my brand" on left , "link 1" , "link 2" blocks of text on right. 3 blocks of text should on same line , vertically aligned. <html> <head> <title>hi mom</title> <style> .header { background-color:#bfefff; height:50px; } .tagline { color: #00a5d8; font-size: 20pt; font-family: helvetica neue; font-weight: bold; vertical-align: middle; text-indent: 20pt; display: inline; } body { margin:0px; } </style> </head> <body > <div class="header"><div class="tagline"><p>my brand</p></div><div class="tagline"><p>...

android - How to disable hidden buttons in Corona? -

let's say -i have button listens "tap" event, , directs function something. -i put imageract covers button. 1 layer up. when click on cover image above area buttons lies behind , event function still executes. how avoid this? example: local function hidebg() display.remove(logo3) logo3=nil end local logo2= display.newimage("logo.png") logo2.x=display.contentcenterx logo2.y=280 logo2.width=200 logo2.height=74 logo2:addeventlistener("tap", hidebg) local cover =display.newimagerect("new game a.png", 480,320) cover.x=display.contentcenterx/2 cover.y=display.contentcentery/2 the hidebg() function still executed although "logo2" covered "cover" image. i know make button isvisible=false , solve problem, have dozens of buttons in different groups in different layers, , wonder how in smart way. maybe somehow disable whole group? don't know. there 2 ways can disable button in project. 1)...

php - what is the difference between printing from a class or returning the output and printing from a function -

i've created class takes output frpm mysql query , formats , returns it. here's class: <?php class sql_output_two_rows extends sql { function __construct($sql) { $this->sql = $sql; $this->output = ""; parent::__construct($this->sql); $this->output .= "<table class='tablenarrow bordered'>\n"; $this->output .= "<tr>\n"; ($f = 0; $f < $this->num_fields; $f++) { if($f%($this->num_fields/2) == 0){ $this->output .= "<tr>\n"; } if($f>0 && $f%($this->num_fields/2) != (($this->num_fields/2) - 1) || $f == ($this->num_fields - 1)){ $this->output .= "<th style='border-radius:0px;'>".$this->field_name[$f]."</th>\n"; }else{ $this->output .= "<th>".$this-...

Stop dpad focus going outside current fragment in android -

my current app requires control using d-pad remote. using focus/select, automatic calculation of nearest neighbour works expected want limit up, down, left, right movements occur in current fragment contains focused view, , cancel change of focus before moves fragment. i programatically changing focus new fragment upon selecting view. is possible do? can assume onfocuschange() event allow me check whether new focus outside fragment , return no luck here... in short, can call setdescendantfocusability(viewgroup.focus_block_descendants) on container holds fragment block focusability fragment descendants. bring focusability can call setdescendantfocusability(viewgroup.focus_after_descendants) details: suppose have framelayout containing 2 fragments, 1 on top another, , want limit focus navigation top_fragment when in place , back_fragment otherwise: <?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://...

java - Which Spring Framework provides REST Services? -

this question has answer here: spring 4.x/3.x (web mvc) rest api , json2 post requests, how right once all? 2 answers in spring have spring ws soap api's. my concern : i want implement rest services spring want follow proven best practices want deliver in time ( avoid redo ) is there spring framework rest services ( spring ws soap api ) ? i unable find one answer blueprint restful services , best practices . ( feel free leave comments ) update : if don't need framework how make sure follow best practices i mean, developer might unknowingly miss or might overdo some. so, why don't have rest , should 1 refer void ? you don't need framework implement rest services spring, it's possibile way how can implement services in spring. as official doc spring - creating restful services says: spring's annot...

Unable to display images in FTL template (Java, FreeMaker, Vaadin) -

i can't display images in ftl template (freemaker tool). images loading web content, can't load app resources. in app use vaadin, spring framework , freemaker. how fix problem? reply. login.ftl: http://pastebin.com/n1vx30zr 1 servlet-context.xml: http://pastebin.com/1sfswmjt 1 web.xml: http://pastebin.com/ntzd5zsy 1 logincontroller.java: package pl.controlprocess.flota.web; import com.vaadin.server.themeresource; import java.io.serializable; import javax.servlet.http.httpservletrequest; import org.springframework.stereotype.controller; import org.springframework.ui.modelmap; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.bind.annotation.requestparam; @controller @requestmapping("/") public class logincontroller implements serializable { private static final long serialversionuid = 1l; @requestmapping(value = "/", method = requestmeth...

node.js - mongo - better solution when i have to update each mongo document usually? -

let say, if have document this, , collection have huge documents. { _id: objectid('e1312313dddqqe….'), ra: { energy: 80, times: 1377496519 } } i have update ra.energy (per 15 mins), use formula var pow = (now - ra.times) / 86400; ra.energy = ra.energy * ( math.pow(0.5, pow) ); currently, use cronjob, query each documents, calculate , update each ra.energy field, slow down our mongodb. is there have better design update. suggestion? thanks.

pixels - DICOM Convert 16 bit to 8bit -

big trees: want find solution of follow question: want convert pixeldata of dicom file 8bit(byte[]) file bitsallocated 16bit. whatever it's grayscale or color. know color's simpleperpixel 3. 3q!!!! you cannot take pixel data , transform 8 bit (unless sure values in range supported byte). because alter important data: dicom file may store pixel data in visual density units or hounsfield units, , modifying values may screw things. you can apply transformation 8 bits presentation data, values resulting modality voi/lut , presentation voi/lut transformations. this example uses imebra library uses presentation data obtain 8 bits per color channel image, saved in jpeg format. modify color space ybr_full rgb in both color transform , image allocation in order rgb image. example (in case link changes): /* imebra 2011 build 2013-07-16_08-42-08 imebra: c++ dicom library copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 paol...

Telerik:Radgridview Export to excel -

i using telerik radgridview in 1 of reports. have export result excel, using telerik's inbuild exporttoexcel function export result excel format. requirement want show header in generated excel please advise i found solution this. achieve need add following event: protected void radgrid1_excelmlexportrowcreated(object sender, telerik.web.ui.gridexcelbuilder.gridexportexcelmlrowcreatedargs e) { if (e.rowtype == telerik.web.ui.gridexcelbuilder.gridexportexcelmlrowtype.headerrow) { e.worksheet.worksheetoptions.pagesetup.pageheaderelement.data = "this draft data"; } } it work me.

django - Crontab Jobs didn't execute shell script -

i'm developing django-python project , stuck in doing django-crontab automate file backup, code: in settings.py installed_apps = ( . . . 'django-crontab', ) crontab_django_manage_path = '/home/path/to/my/project/manage.py' cronjobs = [ ('25 15 * * *', 'cd /home/path/to/my/project && /usr/bin/sh myscript.sh'), ] in myscript.sh #!/bin/sh set -e cd /home/path/to/my/project/ exec cp file some_dir/copy_file i test code on server run @ 15:25 o'clock , it's not executing myscript.sh the script doing copy file directory (for up) , i've tested manually using ./myscript.sh in server, script working well... i've been trying various methodology, nothing seems works i take reference django-crontab ( https://pypi.python.org/pypi/django-crontab/0.5.1 ) , site ( https://superuser.com/questions/81262/how-to-execute-shell-script-via-crontab ) + http://github.com/kraiz/django-crontab edit i'v...

How to call a C# function from javascript? -

i want call csharpfunction code behind javascript. tried code below. problem whether condition true or false , compiler call csharpfunction anyway! how can control that? javascript code: if (javascriptcondition > 0) { <%csharpfunction();%> } c# code behind: protected void csharpfunction() { // notification.show(); } thanks help! you can use web method , ajax <script type="text/javascript"> //default.aspx function deletekartitems() { $.ajax({ type: "post", url: 'default.aspx/deleteitem', data: "", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (msg) { $("#divresult").html("success"); }, error: function (e) { ...

c# - Using excel attached in an email as a source in SSIS package -

i want use excel sheet comes attachment in email source , want export data database table. although don't have restriction on using third party tool avoid that. pointers regarding appreciated. i don't know of lets ssis read email, let alone extract attachments , process them spreadsheets. (biztalk can, that's subject entirely.) it's easier have person receiving email save attachment predefined location (typically network share) , launch ssis package read spreadsheet , load database accordingly.

php - How to get the row of the last insert on Oracle using PDO? -

i need last row inserted using pdo in php. i've been searching , i've found pdo::lastinsertid doesn't work on oracle. what alternatives have? other ways that? think current value of sequence (in table use sequence increment id) using pdo don't know if can. update 1: here's code. static function insertarproveedor($name, $address, $phone, $email) { $con = conexionbd(); try { $stmt = $con->prepare("insert proveedores (nombre, direccion, telefono, email) values (?, ?, ?, ?) returning oid_proveedor :id"); $stmt->bindparam(1, $nombre); $stmt->bindparam(2, $direccion); $stmt->bindparam(3, $telefono); $stmt->bindparam(4, $correo); $stmt->bindparam('oid_proveedor', $id, pdo::param_int, 8); } catch (pdoexception $e) { echo "error".$e->getmessage(); } return $id; } i got following message error: errorsqlstate[hy...

On Click of of a ImageView Change the Background of the Layout Android -

on click of imageview want change background of layout .how can have created selector <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/blue_bar" android:state_pressed="true"/> <item android:drawable="@drawable/gray_bg"/> </selector> xml is <imageview android:id="@+id/bookbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:onclick="reviewitineary" android:src="@drawable/book" /> mylayout = (relativelayout) findviewbyid(r.layout.main);//your layout instance imageview=(imageview)findvi...

listview - Search Suggestions In Android -

Image
i have done search suggestions in android using edittext , listview. what need in activity there many buttons after edittext, when type letters in edit text show corresponding search in list view buttons appearing after listview. my xml file looks this.. <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!-- editext search --> <edittext android:id="@+id/inputsearch" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="search products.." android:inputtype="textvisiblepassword"/> <!-- list view --> <listview android:id="@+id/list_view" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <button andro...

c# - ICustomTypeDescriptor with display -

Image
hi guys implementing interface icustomtypedescriptor , binding wpf grid. having issues result, expecting single column "random" getting totally different. appreciated. andy /// <summary> /// property descriptor test result row wrapper /// </summary> public class testresultpropertydescriptor : propertydescriptor { //- properties -------------------------------------------------------------------------------------------------------------- #region properties /// <summary> /// component type /// </summary> public override type componenttype { { return typeof(dictionary<string, testresultvalue>); } } /// <summary> /// gets whether read /// </summary> public override bool isreadonly { { return false; } } /// <summary> /// gets property type /// </summary> public override type propertytype { { return typeof(string); } ...

mongodb - How to reference each _id in a collection -

i have 2 collections on db. at first have "tvs" collection have list of tvs, @ second have tvcomments holds comments made in each tv. i update "tvs" collection new field shows count of comments each tv. the "tv" field "_id" field "tvs" collection references commented tv. i prove code bellow isn´s works db.tvs.update( { $set: { numcomments: db.tvcomments.find( { tv: this._id } ).count() } }, { multi: true } ) default _id keys in mongo mongo object ids. have convert this._id objectid: objectid(this._id) . your command becomes: db.tvs.update( { $set: { numcomments: db.tvcomments.find( { tv: objectid(this._id) } ).count() } }, { multi: true } ) objectid 12-byte bson type, constructed using: a 4-byte value representing seconds since unix epoch, a 3-byte machine identifier, a 2-byte process id, and a 3-byte counter, starting random value. see more information in documentation .

php - tweet button script not functioning when loaded in through ajax -

the twitter code below: <script>!function(d,s,id){var js,fjs=d.getelementsbytagname(s)[0];if(!d.getelementbyid(id)){js=d.createelement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentnode.insertbefore(js,fjs);}}(document,"script","twitter-wjs");</script> this code on page comments.php , gets loaded social.php when first load it. twitter button works fine @ point. however, when post comment , comments.php reloads social.php not reload, twitter script not work , tweet button doesn't appear. please may me. sorry if unclear in way. ok, should load twitter widget outside comments.php because script won't loaded via ajax. that easier manage , avoid twitter widget loaded each time. there no need call script external source (twitter) each post, no efficient , error-prone. by doing fix problem.

Update method in Rails -

i need update table(mysql db) json received different table controller. have "lists" controller(for list table in db) , "table" (for tables table in db)controller. json insert new row in lists table. json received, need pick table number , update tables table too. below json recieved started post "/lists.json" 192.168.1.2 @ 2013-08-26 16:55:51 +0530 processing listscontroller#create json parameters: {"list"=>[{"amount"=>"10.50", "orderno"=>"0220130826163623", "quan tity"=>"1", "itemname"=>"patatas ali oli", "tableno"=>"02", "ordstatus"=>"ordere d"}, {"amount"=>"10.50", "orderno"=>"0220130826163623", "quantity"=>"1", "itemna me"=>"garlic bread", "tableno"=>"02", "ordstatus"=...

asp.net - Searching on 404 page returns back to 404 page back -

we have 404 page. when in 404 page, have search box. if try search search box, again returns 404 page. how handle this? ps: search button inside user control , user control inside masterpage. when go site below; http://www.x.com/dk it goes 404. then if make search th,s 404 page directs link below; http://www.x.com/dk?404%3bhttp%3a%2f%2fwww.x.com%3a80%2fdk my web config sets <customerrors mode="off" defaultredirect="error.aspx"> <error statuscode="404" redirect="pagenotfound.aspx" /> </customerrors> <httperrors> <remove statuscode="404" substatuscode="-1" /> <error statuscode="404" path="/pagenotfound.aspx" prefixlanguagefilepath="" responsemode="executeurl" /> </httperrors> i solved problem via javascript <script type="text/javascript"> $("#btnsearch"...

c++ - A terminal inside a qt GUI application -

Image
i have finished ui console application qt , want have panel (container not important) console version too. something this: how can this? need solutions windows , linux. the qtermwidget sounds if should usable situation. i haven't tried myself (i'm not qt developer). also, doesn't seem maintained, @ least give try.

java - get value from json object in jsp -

i have java function return output in json format {"loyalty_score":{"end value":0.0,"difference":0.0},"activity_level":{"end value":0.0,"difference":0.0}} i want fetch each value of object i try below code jsonobject json = new jsonobject(); json = fb.summary(); system.out.print("\n\n\n json"+json); //{"loyalty_score":{"end value":0.0,"difference":0.0},"activity_level":{"end value":0.0,"difference":0.0}} system.out.print( json.get("loyalty_score")); //{end value=0.0, difference=0.0} now how end value , difference? you said json.get("loyalty_score") gives {end value=0.0, difference=0.0} , must again json object. can type cast string : <% string jloyaltyscore = json.get("loyalty_score").tostring();%> now split jloyaltyscore using , delimeter. <% string splitloyalty[] = jloyaltysc...

python - BaseHTTPRequestHandler with custom instance -

this http server: from basehttpserver import basehttprequesthandler,httpserver class test: def show(self): return "aaaa" class http_server: def __init__(self, t1): self.t1 = t1 server = httpserver(('', 8080), myhandler) server.serve_forever() class myhandler(basehttprequesthandler): def do_get(self): self.send_response(200) self.send_header('content-type','text/html') self.end_headers() self.wfile.write(self.t1.show()) #doesnt work return class main: def __init__(self): self.t1 = test() self.server = http_server(self.t1) if __name__ == '__main__': m = main() i need acces instance t1 inside of myhander. is there way how ? thanks! there way set property class : from basehttpserver import basehttprequesthandler,httpserver class test: def show(self): return "aaaa" class http_server: def ...

pivot on multiple column sql server -

i have below table , want use pivot on multiple column using sum aggregate. category station1 station2 station3 ------------------------------------------------------------- category1 5.26 6.25 7.28 category2 4.22 5.00 6.00 category3 5.00 4.00 8.00 category1 4.00 7.00 9.00 category2 2.00 5.00 8.00 and want output like my_station category1 category2 category3 ------------------------------------------------------------------------ station1 sum_of_cat1 sum_of_cat2 sum_of_cat3 station2 sum_of_cat1 sum_of_cat2 sum_of_cat3 station3 sum_of_cat1 sum_of_cat2 sum_of_cat3 with single query. not using loop thanks this isn't pivot. unpivot , repivot. i'm inclined write sql it: sel...

ios - <GoogleMaps/GoogleMaps.h> file not found -

Image
i'm trying integrate google maps xcode project. strictly followed instructions here . unfortunately error: error: 'googlemaps/googlemaps.h' file not found <angled> include; use "quotes" instead #import <googlemaps/googlemaps.h> ^~~~~~~~~~~~~~~~~~~~~~~~~ "googlemaps/googlemaps.h" i changed <> "", finds googlemaps.h! however, same error on other 35 headers included in sdk. can't edit each 1 of them, don't want take lots of time + that's wrong way that. i'm not experienced xcode, found topics on internet, none of helped me. what doing wrong here? waiting answer, adam. go search navigator (cmd+3) select replace on left hit "replace all"

c++ - Vector losing data after coming out of function that writes to it -

i'm getting c++ after 10 year absence , decided try , program ascii blackjack game. decided use vector hold both deck , players hand finding when call initial deal function should assign 2 cards both dealer vector hand , player vector hand, writes cards fine when comes out , later on want print hand, out of bounds exception. code snippets below! void deck::initialdeal(player dealer, player player1) { for(int = 0; < 2 ; i++) { dealer.addhand(mydeck[i]); mydeck.erase(mydeck.begin()); player1.addhand(mydeck[i]); mydeck.erase(mydeck.begin()); } } the above takes couple of cards main deck , calls addhand routine add card players vector hand: void player::addhand(card dealtcard) { hand.push_back(dealtcard); } if put in routine output hand vector inside addhand function, works fine , shows data put in. however, later on want print hand screen , have function called printhand() void player::printhand() { if (dealer ==...

java - Maven project compiles but there are missing imports in the workspace -

i'm using eclipse kepler m2e plugin , want modify maven project , compile it. first converted maven project configure -> convert maven project , there still many missing imports. when use run as... -> maven install project compiles. how can fix missing imports? tell m2e update project: context menu of project / maven / update project... m2e read pom again , update classpath , build project again. make sure have in .classpath file: <classpathentry kind="con" path="org.eclipse.m2e.maven2_classpath_container"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> note: actual syntax might different depending on m2e version use. another common pitfall scope provided : provided compile , indicates expect jdk or container provide dependency @ runtime. example, when building web application java enterprise edition, set depe...

CSS based image preloader doesn't work -

i wanted create preloader download images before showing website, later needed switch <img> css-styled ul -s , after stopped working - browser doesn't wait images load. html: <head> [...] <ul id="imgpreloader"> <li></li> <li></li> <li></li> <li></li> </ul> [...] </head> css : #imgpreloader { display:none; } #imgpreloader li:nth-child(1) { background-image: url('...'); } #imgpreloader li:nth-child(2) { background-image: url('...'); } #imgpreloader li:nth-child(3) { background-image: url('...'); } #imgpreloader li:nth-child(4) { background-image: url('...'); } this because have set display:none . think many browsers not load background image if display none though load source of non-displayed img element. instead of setting display:none , try this: #imgpreloader { visibility:hidden; ...

javascript - Google maps set different zoom based on window resize -

following previous question google maps responsive resize implement different zoom level based on windows resize, if browser windows "less then" apply x number of zooming , if "major than" apply zooming level automatically. the following code works in regards of recentering map on windows resize, need apply new zoom levels it: var map; function initialize() { var mapoptions = { center: new google.maps.latlng(40.5472,12.282715), zoom: 6, maptypeid: google.maps.maptypeid.roadmap }; map = new google.maps.map(document.getelementbyid("map-canvas"), mapoptions); } google.maps.event.adddomlistener(window, 'load', initialize); google.maps.event.adddomlistener(window, "resize", function() { var center = map.getcenter(); google.maps.event.trigger(map, "resize"); map.setcenter(center); map.setzoom(zoom level needs automatically set according window size); }); construct area want in view creating la...

javascript - When Zoomed the canvas and then pan, now if I am trying to drag the objects within canvas then not able to do so. But canvas is panning only -

1) without scaling / zooming able pan canvas , able drag images. 2) able drag images within canvas if scaling / zooming. 3) but when pan canvas after zooming if trying drag images canvas panning. not able drag images in imageshittests(x, y) , imageshittests2(x, y) finding hits on images drawn on main svg file. there points panx , pany. how should solve this? following code: var datajson = data || []; var datajson2 = data2 || []; window.onload = function(){ var canvas=document.getelementbyid("mycanvas"); var ctx=canvas.getcontext("2d"); var canvasoffset=$("#mycanvas").offset(); var offsetx=canvasoffset.left; var offsety=canvasoffset.top; var lastx=0; var lasty=0; var panx=0; var pany=0; var dragging=[]; var dragging2=[]; var isdown=false; function loadimages(sources, callback){ var images = {}; var loadimages = 0; var numimages = 0; //get num of sou...

ruby on rails - Why is this group clause not working -

i have payment model 5 rows. 4 of them same user_id , 1 different. try group results user_id. should return 2 results, when trying 5 results. idea why? (i'm using postgres) payment.find(:all, group: "user_id,id").count => 5 also tried payment.find(:all, group: "id,user_id").count => 5 updated: if not add "user_id" i'm getting error activerecord::statementinvalid: pg::error: error: column "payments.id" must appear in group clause or used in aggregate function line 1: select "payments".* "payments" group user_id ^ : select "payments".* "payments" group user_id updated 2: query payment.joins(:user).select('payments.id,users.username,payments.user_id,payments.token,payments.period_start_at,payments.amount_cents,payments.currency').group("user_id") returns pg::error: error: column "payments.id" must appear in group clause or ...

python - Count occurrences in several xml-files -

is there way count occurrences of identity of type on several xml-files? here's example mean. xml-files have following structure: <data> <geo> <g type="mount" stid="s727" level="geo"/> <g type="bike" stid="g12" level="geo"/> <g type="lake" stid="g12432" level="geo"/> <g type="mount" stid="s0" level="geo"/> </geo> </data> what i'd count number of occurences of "s0", "s"+any number, "s12" per type , same 3 categories g's. can show me how work? of course, last have example on category - important me how save intermediate results , how main-function (i suppose you'll sys.arg - @ least, do...) thanks help. i use lxml library type of thing. it's documented. here little script wrote kind of think want. if care count , not items, increment v...

ios - How can I implement a button in my app so every time a user presses it, the whole app default colour changes -

as title says, implement button when user presses once, general default colour changes. user presses button once , app theme becomes green , when pressed again, theme changes red , pressed again goes initial theme colour. have quick example? on google, when search above, how change colour of button. in advance! yes hook action , whenever uibutton pressed call: cgfloat red = (cgfloat)arc4random() / (cgfloat)rand_max; cgfloat blue = (cgfloat)arc4random() / (cgfloat)rand_max; cgfloat green = (cgfloat)arc4random() / (cgfloat)rand_max; uicolor *color = [uicolor colorwithred:red green:green blue:blue alpha:1.0]; self.view.backgroundcolor = color; these lines of code generate random rgb numbers , turnes views color color. to change other view controllers view: yourviewcontroller.view.backroundcolor = color;

objective c - Xcode wants to use _bridge to close sqlite3 database -

though have linked sqlite3 framework , included headers in application delegate file, xcode wants change: - (void)applicationdidenterbackground:(uiapplication *)application { if ([mydatabase database]) sqlite3_close([mydatabase database]); } to this: - (void)applicationdidenterbackground:(uiapplication *)application { if ([mydatabase database]) sqlite3_close((__bridge sqlite3 *)([mydatabase database])); } in code above, database singleton reference instance of mydatabase works in other aspects of program.

file - VB: Changing shortcut properites -

i have code, task changing .url or .lnk (shortcuts) properties, not seem anything. imports system.io imports shell32 module module1 sub main() 'references microsoft shell controls , automation. 'http://msdn.microsoft.com/en-us/library/bb776890%28v=vs.85%29.aspx end sub public sub change_shortcut() dim shell shell32.shell dim folder shell32.folder dim folderitem shell32.folderitem dim shortcut shell32.shelllinkobject shell = new shell32.shell folder = shell.namespace("c:\users\grzegop\desktop\xxx") 'shortcut path if not folder nothing folderitem = folder.parsename("o2.url") 'shortcut name if not folderitem nothing shortcut = folderitem.getlink if not shortcut nothing shortcut.path = "www.o2.ie" 'new shortcut address shortcut.save() msgbox("shortcut changed") else ...

java - Insert ICON/PNG inside TextArea -

without resorting wrapping gwt textarea in separate div, how add search icon/magnifier icon inside text area? no, not possible. text area not normal widget . gwt's textarea maps directly html textarea thats why can set text it. thing can ist create grid/verticalpanel/horizontalpanel , put in each cell separate textarea. google groups similar question

Accessing members of a jsclass Set in javascript -

how can specific element set in jclass set. there how add not how get. if try var oo = new set([2,4,6,8]); alert("ok?"+oo.get(2)); i'v tryed acces array var oo = new set([2,4,6,8]); alert("ok?"+oo[2]); both of them failed docs: http://jsclass.jcoglan.com/set.html make use of .toarray() var oo = new set([2,4,6,8]); alert("ok?"+oo.toarray()[0]);

php - Imagick convert SVG to PNG - colors replaced by black and white -

i'am trying convert svg image created svggraph library ( http://www.goat1000.com/svggraph.php ). the svg colored (red, green, yellow, gray, ...) in browser , fine. when convert it, black , white. with code convert it: //new instance of imagick $im = new imagick(); //read svg file/data (its not saved on filesystem) $im->readimageblob($svgfile); $im->setimageformat("png24"); $im->writeimage('cylinder.png'); $im->clear(); $im->destroy(); i've tried jpeg , png output format result same, colors replaced black does have idea how fix ? try way: $im = new imagick(); $im->setbackgroundcolor(new imagickpixel('transparent')); $im->readimageblob($svgfile); $im->setimageformat("png24"); $im->writeimage('cylinder.png'); $im->clear(); $im->destroy()

c++ - Is there ever a reason to use std::list? -

this question has answer here: under circumstances linked lists useful? 14 answers after having read this question , looking @ results here , seems 1 should altogether avoid lists in c++. expected linked lists containers of choice cases need iterate on contents because insertion matter of pointer manipulation , there never need reallocate. apparently, because of "cache locality," lists iterated on slowly, benefit having use less reserve memory or faster addition (which not faster, seems, second link) doesn't seem worth it. having said that, when should i, performance standpoint, use std::list on std::deque or, if possible, std::vector ? on side note, std::forward_list have lots of cache misses? when should i, performance standpoint, use std::list from performance standpoint, rarely. situation comes mind if have many lists need s...

IOS Core Data Fetch LAST object from Entity? -

i'm not finding reference "last" i'll ask hope simple need fulfill. have objects in core data entity. not implement sort of "time stamp" on entity not anyway because users travel coast coast suppose stamp in zulu time. i need retrieve last object added refer attribute's value. know core data stores it's own unique incrementing "key" don't know how reference it. need check see if odometer reading user trying enter less last 1 entered or varies beyond normal bounds check user input error before saving new object , present alertview if so. i can't @max because user may have made erroneous high entry prior. can deal issue separately once user has determined has made invalid entry somewhere needs addressed , dealt accordingly. thanks.

Synchroize Eclipse workspace -

i'm searching method synchroize eclipse workspace. have apache server strato php, sql databeses, ftp , on. there want store projects. there eclipse plugin (maybe in conjunction web cms or else) can synchronize whole workspace other workstations? always use project settings instead of workspace preferences. use version control system , check-in code and project settings. sharing workspace on multiple machines works chance. .metadata machine specific. if have different operating systems, different eclipse installations, different java runtimes, run dubious errors. found 1 similar question , there have been more.

multithreading - Java : One thread needs to wait for other to be done -

i have following use case. can suggest implementation of method t1() assuming run on java 6 ? tried think of accomplishing using wait() , notify() not proper solution. appreciated. (note both of these methods t1() , m1() called in different threads) class test { static volatile int flag = 0; public static void t1() { //this method called in thread called t2 /*this method must wait flag become 1. becomes 1 must return. should wait maximum n seconds. after if flag 0 must return.*/ } public static void m1() { //this method called in thread called t1 flag = 1; } } this tried far implementation of t1() public static void t1() throws interruptedexception { while(flag == 0) { thread.currentthread().sleep(100); } } above works problem timeout not implemented , while loop not seem good. use countdownlatch . initialize b...