Posts

Showing posts from April, 2010

sql server 2008 - SSRS Top N for Dates -

so writing ssrs report want calculate lead time based on arbitrary number deliveries. i have query in ssrs filter show last 5 deliveries. use top n filtering ssrs rightly complains number 5 not date. how filter last 5 latest dates without knowing exact dates of records returning? dataset follows (lead time calculation of order date less delivery date) order | del_date | lead_time ------|------------|----------- 00001 | 2015-05-01 | 20 00002 | 2015-01-08 | 21 00003 | 2015-02-05 | 22 00004 | 2015-03-11 | 26 00005 | 2015-01-21 | 8 00006 | 2015-04-12 | 12 00007 | 2015-03-02 | 12 00008 | 2015-02-01 | 12 the query should return order | del_date | lead_time ------|------------|----------- 00001 | 2015-05-01 | 20 00003 | 2015-02-05 | 22 00004 | 2015-03-11 | 26 00006 | 2015-04-12 | 12 00007 | 2015-03-02 | 12 thanks, can try this: select top 5 order, del_date, lead_time [table] ... order del_date desc

c# - Split dictionary into multiple equal sized dictionaries -

i have dictionary shown below. there 400 elements in dictionary want split dictionary 4 equal sized dictionaries. how do this? list there range method can use not sure here? i not care how dictionary split equally sized. dictionary<string, companydetails> codic; you can use simple modulus group dictionary in parts: int numberofgroups = 4; int counter = 0; var result = dict.groupby(x => counter++ % numberofgroups); the modulus ( % ) makes groupby restricted number in range 0..3 (actually 0..numberofgroups - 1 ). make grouping you. a problem though 1 doesn't preserve order. 1 does: decimal numberofgroups = 4; int counter = 0; int groupsize = convert.toint32(math.ceiling(dict.count / numberofgroups)); var result = dict.groupby(x => counter++ / groupsize);

symfony - Textarea field with data Transformer -

i have form textarea field(where user adds domains names, each per line) , data transformer transforms string array: $builder->add( $builder->create('domains', 'textarea', [ 'trim' => false, 'constraints' => [ new assert\notblank(), new assert\all([ 'constraints' => [ new assert\notblank(), new domain(), new registerdomain(), ] ]) ] ])->addmodeltransformer(new arraytostringtransformer()) ); arraytostringtransformer public function transform($values) { if (empty($values)) { return ''; } return implode($this->delimiter, $values); } public function reversetransform($string) {

Excel create date stamp when an cell is updated -

Image
i have excel sheet has 'last updated' field in column n. need make automatic update todays date, whenever status in column h changed row. can on simple solution? thank in advance! kriss include following event macro in worksheet code area: private sub worksheet_change(byval target range) dim rng range, r range, h range set h = range("h:h") set rng = intersect(h, target) if rng nothing exit sub application.enableevents = false each r in rng cells(r.row, "n").value = date next r application.enableevents = true end sub because worksheet code, easy install , automatic use: right-click tab name near bottom of excel window select view code - brings vbe window paste stuff in , close vbe window if have concerns, first try on trial worksheet. if save workbook, macro saved it. if using version of excel later 2003, must save file .xlsm rather .xlsx to remove macro: bring vbe windows above clear code out clos

paw app - How do I share a Paw extension privately -

i have created paw extension want share privately. is there filename extension can use share it, users can double click install (i.e. bundle). or have share extension directory , ask users put extension container directory. solution 1 what recommend make private git repository code, containing install script (a makefile style script) users can run have extension installed @ right place. here's example: https://github.com/luckymarmot/paw-regexdynamicvalue there cakefile manages build , install @ right place. if clone repo, , run cake install you'll have extension installed cleanly. solution 2 as said, may easier share bundle (zip or tar archive) users can manually open , drag right folder. extension folder can found in paw menu > preferences > extensions hit "open extensions directory".

java - How can I create RequiredFieldValidattion in Android? -

here code. looks bit complicated it's working fine. want know how can create when click btncreateproduct should validate required edit text field , add code? package com.prinsapps.whatson; import java.util.calendar; import android.app.activity; import android.app.datepickerdialog; import android.app.dialog; import android.os.bundle; import android.view.view; import android.app.progressdialog; import android.content.intent; import android.os.asynctask; import android.util.log; import android.widget.button; import android.view.view.onclicklistener; import android.widget.datepicker; import android.widget.edittext; import android.widget.imagebutton; import java.util.arraylist; import java.util.list; import org.apache.http.namevaluepair; import org.apache.http.message.basicnamevaluepair; import org.json.jsonexception; import org.json.jsonobject; import com.prinsapps.whatson.addevent.createnewproduct; public class addevent extends activity implements onclicklistener { privat

Android: package com.google.api.services.gmail does not exist -

as documentation: https://github.com/google/google-api-java-client to use gradle, add following lines build.gradle file: repositories { mavencentral() } dependencies { compile 'com.google.api-client:google-api-client:1.18.0-rc' } done, get: error: package com.google.api.services.gmail not exist what reason ? you adding google api , trying use gmail api. why getting error: package com.google.api.services.gmail not exist .if want use gmail api add gmail api client library adding compile 'com.google.apis:google-api-services-gmail:v1-rev29-1.20.0' ref: https://developers.google.com/api-client-library/java/apis/gmail/v1

Characters limitation in INI file? -

are there known characters limitation value string have put ini file? i have line 1800 characters, , consider extend , save 200 characters on line. make sense? i found this thread not mention relevant limitation (it talks 32k limitation of file size, not case). thank you!

java - How to Sort WebElements in a ArrayList in WebDriver? -

please how sort below piece of code find max,min , average ? want navigate question has views , use selenium take screen shot of question's page using https://stackoverflow.com/ home page sample page list<webelement> views = driver.findelements(by.xpath("//*[@class='mini-counts']/span")); system.out.println("size = " + views.size()); string maxvalue = "maxvalue after sorting"; for(int i=2;i< views.size();i+=3){ if(views.get(i).gettext().equals(maxvalue)){ views.get(i).click(); file scrfile = ((takesscreenshot)driver).getscreenshotas(outputtype.file); fileutils.copyfile(scrfile, new file(system.getproperty("user.dir")+"\\screenshots\\"+"most_views.png")); } you can use comparator , create comparator class like public class viewcomparator implements comparator { @override public int compare(webelement w1, webelement w2) { // extract view coun

bash - Is there an option to wget to force it to write the response even when it's erroneous? -

i have written bash soap library uses wget interface http servers. it's intentional avoid curl, since not available or not installed default on systems library used. the basis of library query wsdl, determine parameters , allow functions / methods invoked command line, through simple wrapper setup soap urls: $ ./mysoap.sh mymethod skey=1234 banotherparameter=false sanotherparam="hello" however, when wget receives 500 response, doesn't write response body output document defined -o . response contains soap errors server generated, useful client. there way force wget write response output document, regardless of state? documentation seems unclear function of -o in event of error, me, it's not working intended. this option: parameter: --content-on-error, available wget 1.14: https://superuser.com/a/648466

javascript - How do I use JObject if the names are slightly different? -

i have jobject json.net following: var jobject = {"schedule.id" : 1, "schedule.name" : "nameschedule"} the above using javascript return id's , values of textboxes in mvc form in view. in controller using c#, convert schedule object has following properties: public class schedule { public int id {get;set;} public string name {get;set;} } i cannot schedule sched = jsonobject.toobject<schedule>(); because names different properties on jobject prepended 'schedule'. is there query or way conversion allows me remove 'schedule' in jsonobject such can simple conversion in 1 line? one simple way working use jsonproperty attribute specify json key want map c# property: public class schedule { [jsonproperty("schedule.id")] public int id {get;set;} [jsonproperty("schedule.name")] public string name {get;set;} } then can use jsonconvert.deserializeobject

php - Yii cant validate file input -

i'm doing project in php yii framework. have form requires user upload file. during registration, user uploaded file, however, when user submits form, form detected blank on file input, it's if there no attachment on form. below code: model - candidateresume: return array( array('resume_file','file','types'=>'doc,docx,pdf', 'allowempty'=>true, 'safe'=>true, 'on'=>'register'), ); model - candidate: return array( array('can_email,name,repeat_can_email, can_password,repeat_can_password','required', 'on'=>'simplereg'), ); view: $form = $this->beginwidget('bootstrap.widgets.tbactiveform',array( 'id'=>'candidate-form', 'enableajaxvalidation'=>true, 'type'=>'horizontal', 'htmloptions' => array( 'enctype' => 'multipart/form-d

java - remove last comma of dynamic jTextFields -

i getting value of dynamically added jtextfield using code : edited: component[] children = jpanel1.getcomponents(); // iterate on subpanels... (component sp : children) { if (sp instanceof subpanel) { component[] spchildren = ((subpanel)sp).getcomponents(); // iterate on jtextfields... (component spchild : spchildren) { if (spchild instanceof jtextfield) { string text = ((jtextfield)spchild).gettext(); system.out.println(text); } } } } output text file got: text1,text2,text3, now appeared next problem - "last comma". found guava can solve problem, due less experience couldn't implement. if possible give me advice or suggestion. thank in advance. use stringjoiner : stringjoiner joiner=new stringjoiner(","); (component spchild : spchildren) { if (spchild instanceof jtextfield) { string text = ((jtextfield)s

rCharts/Highcharts reversedStacks not working in R -

i want reverse order of stacking in column plot using highcharts rcharts . found yaxis.reversedstacks in api did not manage work within r. have idea? library(data.table) library(dplyr) library(rcharts) mydata <- data.table(xaxis = c(0,1,0,1), value = c(0.6,0.8,0.4,0.55), type = c("a", "b")) plot <- rcharts:::highcharts$new() plot$chart(type = "column") plot$plotoptions(column = list(stacking = "normal")) (.type in unique(mydata$type)) { .currdata <- mydata %>% filter(type == .type) # .productionplot$series(name = .type, data = .currdata$availability, # type = "line", yaxis = 1, stack = .type, # marker = list(enabled = false)) plot$series(name = .type, data = .currdata$value, type = "column") } # jfiddle of api page: # http://api.highcharts.com/highcharts#yaxis.reversedstacks # # yaxi

java Kendo UI grid how to access model fields -

i displaying kendo ui grid in jsp page . here code . have designed webservice create method . method getting called . not able access model fields . means want access fields values of selected row , insert database. how can access ? . <div id="example"> <div id="grid"></div> <script> $(document).ready(function () { var crudservicebaseurl = "http://localhost:8081/app/personcontacttypes", datasource = new kendo.data.datasource({ transport: { read: { url: crudservicebaseurl + "/getall", datatype: "json" }, update: { url: crudservicebaseurl + "/update", datatype: "json"

javascript - Uncaught TypeError: Cannot read property '0' of null in Chrome extension -

i'm trying create google extension, , among problems had while doing so, had problem can't figure out how fix looking @ soooo answers in stackoverflow. basically, code supposed open popup replaces existing popup when click on link in popup. so code, when click on "clickme" link, opens "popup2.html". maybe answer obvious, javascript knowledges more rusty... var hrefs = document.getelementbyid("clickme"); function openlink() { var href = this.href; chrome.tabs.query({active: true, currentwindow: true}, function(tabs) { var tab = tabs[0]; chrome.tabs.update(tab.id, {url: href}); }); } (var i=0,a; a=hrefs[i]; ++i) { hrefs[i].addeventlistener('click', openlink); } document.getelementbyid('clickme').addeventlistener('click', hello); thank in advance ! the problem accessing 0 property hrefs variable, null. hrefs[i].addeventlistener('click', openlink); your code ass

mongodb - mongo java driver returning stale data from primary -

i using mongo version 2.4.5 , mongo-java-driver version 2.12.4 . have primary node , replica. now run code following: save 1 - inserts new document default write concern ...waits time read 1 - reads document read preference primary ...modifies save 2 - save modified doc default write concern read 2 - reads saved doc read preference primary in last read operation, done after save, see stale data returned in cases(that modifications not reflecting). however, in cases modifications reflect. question - if writing mongo default write concern(which acknowledged) , reading preference primary, isn't consistency guaranteed? more details: application connecting replica set 1 primary , 1 secondary host. i tried overriding default write concern following: acknowledged, journaled, relpica_acknowledged in cases, read preference primary. still issue observed. private dbcollection customers = mydb.getcollection("customers"); writeresult wr = customers.save(cu

iOS UISegmentedControl with image overlaps by tint color -

i have problem uisegmentedcontrol image. when put image text on in segment tintcolor paints image , text. can it? setting uiimage in segment uiimage *tmp = [uiimage imagenamed:@"uisegmentedcontrol-active"]; uiimage *imagewithtext = [uiimage imagefromimage:tmp string:@"20" color:[uicolor whitecolor]]; [self.segmentedcontrol setimage:imagewithtext forsegmentatindex:0]; imagefromimage code: + (id) imagefromimage:(uiimage*)image string:(nsstring*)string color:(uicolor*)color { uifont *font = [uifont systemfontofsize:16.0]; cgsize expectedtextsize = [string sizewithattributes:@{nsfontattributename: font}]; int width = image.size.width + 5; int height = max(expectedtextsize.height, image.size.width); cgsize size = cgsizemake((float)width, (float)height); uigraphicsbeginimagecontextwithoptions(size, no, 0); cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsetfillcolorwithcolor(context, color.cgcolor); in

mysql - SQL query: Speed up for huge tables -

we have table 25,000,000 rows called 'events' having following schema: table events - campaign_id : int(10) - city : varchar(60) - country_code : varchar(2) the following query takes long (> 2000 seconds): select count(*) counted_events, country_code events campaign_id` in (597) groupy city, country_code order counted_events we found out it's because of group by part. there index idx_campaign_id_city_country_code on (campaign_id, city, country_code) used. maybe can suggest solution speed up? update: 'explain' shows out of many possible index mysql uses one: 'idx_campaign_id_city_country_code', rows shows: '471304' , 'extra' shows: 'using where; using temporary; using filesort' – here whole result of explain: id: '1' select_type: 'simple' table: 'events' type: 'ref' possible_keys: 'index_campaign,idx_campaignid_paid,idx_city_country_code,idx_city_country_co

sql - Joining 2 tables to calculate the time difference -

we have couple of seperate event tables. given id know time difference between 2 events. now, there can several of same events given id, interested in "next" event. example: http://sqlfiddle.com/#!4/1f724/6/0 schema create table event_a ( timestmp timestamp(3), id varchar2(50) ); create table event_b ( timestmp timestamp(3), id varchar2(50) ); insert event_a values (to_timestamp('2015-05-12 10:22:00', 'yyyy-mm-dd hh24:mi:ss'), 'x'); insert event_b values (to_timestamp('2015-05-12 10:22:05', 'yyyy-mm-dd hh24:mi:ss'), 'x'); insert event_a values (to_timestamp('2015-05-12 10:22:08', 'yyyy-mm-dd hh24:mi:ss'), 'x'); insert event_b values (to_timestamp('2015-05-12 10:22:10', 'yyyy-mm-dd hh24:mi:ss'), 'x'); query this query came with, seems me little complex. wondering if there better way this. this query takes long time run if there lot of data in

rest - Multiple dex files define Lorg/springframework/http/ContentCodingType$1 -

i test androidannotations framework, have error when add spring-android libs. create repo test project open_git_repo ! at moment, have in gradle console agpbi: {"kind":"simple","text":"unexpected top-level exception:","position": {},"original":"unexpected top-level exception:"} agpbi: {"kind":"simple","text":"com.android.dex.dexexception: multiple dex files define lorg/springframework/http/contentcodingtype$1;","position{},"original":"com.android.dex.dexexception: multiple dex files define lorg/springframework/http/contentcodingtype$1;"} agpbi: {"kind":"simple","text":"\tat com.android.dx.merge.dexmerger.readsortabletypes(dexmerger.java:594)","position":{},"original":"\tat com.android.dx.merge.dexmerger.readsortabletypes(dexmerger.java:594)"} agpbi: {"kind&quo

oauth 2.0 - PHPMailer SMTP Gmail authentification error -

i'm sending emails using phpmailer 5.2.10 next code: function sendgmail($to,$subj,$body) { $mail = new phpmailer(); // create new object $mail->issmtp(); // enable smtp $mail->smtpdebug = 1; // debugging: 1 = errors , messages, 2 = messages $mail->smtpauth = true; // authentication enabled $mail->smtpsecure = 'ssl'; // "ssl" secure transfer enabled required gmail $mail->host = "smtp.gmail.com"; $mail->port = 465; // 465 or 587 $mail->ishtml(true); $mail->username = "admin@mydomain.ru"; $mail->password = "********"; $mail->setfrom("admin@mydomain.ru"); $mail->subject = $subj; $mail->body = $body; $mail->addaddress($to); return $mail->send(); } note: use google apps, mail domain not google.com, other, let's say, mydomain.ru. everything fine until google had implemented "security enhancement" (afaik for

java - read an unformatted text file and store its value in hashmap -

i have text file containing data in below format vehicle:bike model:fz make: yamaha description abcdefgh ijklmn problems gear problem, fork bend. auto data ***********************************end*********************** vehicle:bike model:r15 make: yamaha description 1234, 567. 890 problems gear problem, fork bend. oil leakage auto data ***********************************end*********************** i have given 2 datas there many more such in text file want read , store in hashmap such that bike:fz:yamaha:abcdefghijklmn:gear problem,fork bend. bike:r15:yamaha:1234,567.890:gear problem,fork bend.oil leakage my sample code: public static void main(string[] args) { try { bufferedreader br = new bufferedreader(new filereader("data.txt")); string scurrentline; int = 0; int j = 0; hmap = new hashmap<string, integer>(); while ((scur

mpandroidchart - Set pie chart to non touchable -

Image
i'm using awesome plotter framework ios-charts. documentation android version states 1 can disable touch events on charts "settouchenabled(false). can't find function in ios version. "touchesbegan" might way go here? i'm new ios programming i'm not familiar touch events. you can disable user interaction via attributes inspector or with chartview.userinteractionenabled = false

objective c - NSPopButton with list of font families -

Image
how can create nspopupbutton list of font families each item in own font shown in attached screenshot. want use bindings achieve this. i able populate nspopupbutton binding nspopupbutton content value returned [[nsfontmanager sharedfontmanager] availablefontfamilies] can't figure out how each individual row in own font? i wasn't sure it, following appears work. // fontpopup1 instance of nspopupmenu nsmenu *menu = [[nsmenu alloc] init]; nsarray *familynames = [[nsfontmanager sharedfontmanager] availablefontfamilies]; nsmutablearray *fontarray = [[nsmutablearray alloc] initwithobjects:nil]; (nsstring *family in familynames) { [fontarray addobject:family]; } (nsinteger i2 = 0; i2 < fontarray.count; i2++) { nsstring *family = [fontarray objectatindex:i2]; nsmutableattributedstring *attrstr =[[nsmutableattributedstring alloc]initwithstring:family]; cgfloat fontsize = [nsfont systemfontsize]; [attrstr addattribute:nsfontattributename value:[

actionscript 3 - AS3 Starling: How to remove black bars on top and bottom of iPhone 6+/...? -

Image
i'm trying out starling framework actionscript 3 , have "big" problem removing these ugly black bars on top , bottom of iphone 6+. i tried fix with: http://wiki.starling-framework.org/manual/multi-resolution_development , http://forum.starling-framework.org/topic/game-not-full-screen-when-testing-in-ios but still wont work :( any ideas? package { import flash.display.sprite; import flash.display.stagealign; import flash.display.stagescalemode; import flash.events.event; import flash.geom.rectangle; import starling.core.starling; import starling.events.resizeevent; import starling.utils.halign; import starling.utils.valign; public class foobar extends sprite { private var _starling: starling; public function chouseapp() { super(); stage.align = stagealign.top_left; stage.scalemode = stagescalemode.no_scale; starling.handlelostcontext = true; var screenwidth:

performance - How to track memory usage of the networking subsystem in the Linux kernel? -

is there way determine how physical memory being used network subsystem in linux kernel @ given point in time? understand per-connection memory limits can specified via sysctl. there tool peek inside tcp/ip stack , ask how buffered data has per connection? did try: ss -m ? documentation of reported values seems scarce can make educated guesses based on full names defined in linux/sock_diag.h .

api - Box.com update/delete folder using curl -

i trying update folder name in box.com using curl tool in windows command prompt. however, not able , getting "insufficient permissions" error. following exact curl command using request parameters updating folder: curl -i https://api.box.com/2.0/folders/0 -h "authorization: bearer rn4lh6kst6bhmaleuzdjmtxxptforg1b" -d "{\"name\":\"new folder name!\"}'-x put and getting following error: {"type":"error","status":403,"code":"access_denied_insufficient_permissions","help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"access denied - insufficient permission","request_id":"11155318795551a7373138a"} i same error "delete" folder command in curl. can please me this? i believe issue quote escaping. also, have -d "....' (note mismatched " , ' try following commands box a

android - Building wpa_supplicant with 'mm' command -

i new android. have entire source code of android imx platform. build wpa_supplicant folder present under external folder. everytime make change, instead of building entire source, build wpa_supplicant folder. have read using 'mm' command can it. however, not sure find 'mm' command. when type #mm external/wpa_supplicant_8, following error message displayed: the program 'mm' can found in following packages: * mountmanager * multimail try: apt-get install i not sure if need apt-get install or binary present somewhere else. can me this? also, how compile single application present in external folder? please help. run build/envsetup.sh script root folder: path/to/android# . ./build/envsetup.sh then lunch device, , you'll able mm necessary.

javascript - How to update Document in MongoDB via Node.js and Angular.js -

my document in mongodb looks like: { "_id" : objectid("5550e710dad47584cbfe9da1"), "name" : "serverraum1", "tables" : [ { "name" : "table1", "nummer" : "1", "reihe" : "2", } ] } post method: app.post('/serverraeume', function (req, res) { console.log(req.body); db.serverraeume.update(req.body, function (req, res) { }); }); and http post in angular controller: $scope.addschrank = function (serverraum){ $http.post('/serverraeume', $scope.table); } i want update in document serverraum1 tables. how can push $scope.table in tables? to update in document serverraum1 tables pushing $scope.table , mongodb update function post method should use $addtoset operator adds value array unless value present, in

jquery - How to merge two JavaScript Object litterals -

if have objects data1 , data2, how can make data3? i send data3 parameter later in ajax request calling mvc server controller. (just saying can't have data3 array think). var data1 = { managementpointid: 1, businessunitid: 2 }; var data2 = { computerpackageid: 3 }; var data3 = { managementpointid: 1, businessunitid: 2, computerpackageid: 3 }; use $.extend method: var data1 = { managementpointid: 1, businessunitid: 2 }; var data2 = { computerpackageid: 3 }; var data3 = $.extend({}, data1, data2); document.write('<pre>' + json.stringify(data3, null, 4) + '</pre>'); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

docker - I have working with dockerfile to build and image and it build and run successfully but tomcat is not up -

i using dockerfile build image. content of docker file: from ubuntu # update ubuntu run apt-get update && apt-get -y upgrade # add oracle java 7 repository run apt-get -y install software-properties-common run add-apt-repository ppa:webupd8team/java run apt-get -y update # accept oracle java license run echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 boolean true" | debconf-set-selections # install oracle java run apt-get -y install oracle-java7-installer # install tomcat run apt-get -y install tomcat7 run echo "java_home=/usr/lib/jvm/java-7-oracle" >> /etc/default/tomcat7 expose 8080 # download slashdot homepage run mkdir /var/lib/tomcat7/webapps/slashdot run wget http://www.slashdot.org -p /var/lib/tomcat7/webapps/slashdot # start tomcat, after starting tomcat container stop. use 'trick' keep running. cmd service tomcat7 start && tail -f /var/lib/tomcat7/logs/catalina.out when try build image using command do

ios - How Reduce the Width of ContentSize in UITableViewCell -

how reduce size of contentsize width of uitableviewcell . -> tried,in uitableview property there had options reduce uitableviewcell contentsize of height not width. -> want reduce uitableviewcell contentsize width in uitableview . you can not reduce cell width using cell property. need change uitableview frame size. set width whatever want set.

parsing - how to read from a particular line upto a particular line in python -

i haave file , want read specific part of it. file. ..... ..... admin server interface begins ... .... .... .... .... admin server interface ends .... .... i want read part of file between 'admin server interface begins' till 'admin server interface ends'. found way of doing in perl can't find way in python. in perl while (<inp>) { print $_ if(/^adminserver interface definitions begins/ .. /^adminserver interface definitions ends/); } could anyonle please help. you can read file line line , gather in between markers. def dispatch(inputfile): # if separator lines must included, set true need_separator = true new = false rec = [] open(inputfile) f: line in f: if "admin server interface begins" in line: new = true if need_separator: rec = [line] else: rec = [] elif "admin server inter

mysql - Convert sql query with a join on a subselect to a linq statement -

i trying convert following sql query linq statement select t.* ( select unique_id, max(version) mversion test group unique_id ) m inner join test t on m.unique_id = t.unique_id , m.mversion = t.version linq statement var testalt = (from altt in cs.test group altt altt.unique_id g join bp in cs.alerts on g.firstordefault().unique_id equals bp.unique_id select new abcbe { abcname= bp.name, number = bp.number, unique_id = g.key, version = g.max(x=>x.version) }); i getting error of clause. please help sql fiddle this not easy straight forward conversion can accomplish same thing using linq method syntax. first query executed expression tree, joining expression tree grouping against cs.alerts. combines expression tree cs.test query expression tree of cs.alerts join 2 expression trees. the expression tree evaluated build query , execute said query upon enumeration. enumeration in case tolist() call gets result enumerati

php - Error with image display -

please check below code , me out if going wrong in image display code untitled document <body> <p>how display image</p> <p>image not seeingd</p> <?php $con= mysql_connect("localhost","root",""); $d= mysql_select_db("matrimonial",$con); $id=$_request['id']; $sql = "select * advertiesment s_no ='1'" or die(mysql_error()); $result = mysql_query($sql,$con); if($rows=mysql_fetch_assoc($result)) { $image = $rows['filepath']; echo "<img style='width:150px;height:150px' src='$image'>"; echo "<br>"; } ?><p>how display image</p> </body> </html> if($rows=mysql_fetch_assoc($result)) the condition bad. if have more results sql query,you need use while . while ($rows = mysql_fetc

recursion - Recursive Method StackOverflow Error - Minesweeper -

i writing recursive method minesweeper game , encountering stackoverflow error in recursive method clears out empty spaces, error not occur when checking 3 of surrounding spaces when checking eight. can please identify issue? the stack trace : exception in thread "awt-eventqueue-0" java.lang.stackoverflowerror @ java.awt.component.firepropertychange(component.java:8419) @ javax.swing.abstractbutton.settext(abstractbutton.java:306) @ minesweeper.minesweeper.showtile(minesweeper.java:105) @ minesweeper.minesweeper.clearempty(minesweeper.java:137) @ minesweeper.minesweeper.clearempty(minesweeper.java:177) the class: public class minesweeper implements actionlistener { jframe frame = new jframe("minesweeper"); jbutton reset = new jbutton("reset"); jbutton solve = new jbutton("solve"); jtogglebutton[][] buttons = new jtogglebutton[20][20]; int[][] counts = new int [20][20]; container grid = new

sparse matrix - MySQL (SQL in general) limiting columns -

without correct phrase it's hard describe this, give example. consider following data: cola colb colc cold cole ------------------------------------------------ hello can please? columns pop'd as can see, many columns empty. in end, following output: col1 col2 col3 col4 col5 ------------------------------------------------ hello can please? columns pop'd basically, data shifted left. thought of using case when statement, gets pretty complex since it's 7 columns (not 5 outlined in example above). what efficient way result. name of resultant columns doesn't matter, renamed in case. treating nothing more thought exercise, because seems best left better structure, or done @ application level - can accomplish want single, horrendously

In Scala/Java, how to inspect where a method is defined? -

for example, saw scala expression this: objx.methody there seems no way see methody came from, may came from: (1) class of objx , let's call classx (2) super class of objx ( classx ), let's call superclassx (3) class called classz , classz irrelevant objx , there implicit conversion classx classz . so there may 3 possibilities source of methody , have ideas how find out methody defined? in other words, in scala, how inspect information of method (especially method came implicit conversion ) @ runtime? there possibility class has method declared reflection. namings: objx.getclass().getmethod("methody").getdeclaringclass();

android - how to bind list adapter in fragment class -

i have following fragment class: public class home extends fragment { public static final string tag = home.class.getsimplename(); public static homenewinstance() { return new home(); } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view v = inflater.inflate(r.layout.homegrag, container, false); return v; } } when used work perferct. when add below code in class give me error : public class home extends fragment { private list<rowitem> rowitems; private static integer[] images = { r.drawable.red, r.drawable.red, r.drawable.red, r.drawable.red, r.drawable.red, r.drawable.red, r.drawable.red, r.drawable.red }; public static final string tag = home.class.getsimplename(); public static homenewinstance() {

php - Sonata admin "sonata_type_collection" tries to remove entity -

i have 2 entities , 2 admin classes(stripepage , stripe) them. form looks good, has fields , button add new subforms. when "add new" button clicked, new subform form admin class rendered, if click second time on button or try save entity error appears: catchable fatal error: argument 1 passed fred\corebundle\entity\stripepage::removestripe() must instance of fred\corebundle\entity\stripe, null given in c:\users\lubimov\openserver\domains\tappic.dev\src\fred\corebundle\entity\stripepage.php so symfony tries remove entity instead of adding it. stripepageadmin class: class stripepageadmin extends admin { protected function configurelistfields(listmapper $listmapper) { $listmapper ->addidentifier('id', null, array('label' => 'id')) ->add('name', null, array('label' => 'page name')); } protected function configureformfields(formmapper $formmapper)

javascript - Highcharts - Display only specific series in specific category? -

i'm trying figure out if possible using highchart's various options display specific series columns in specific categories. i'm trying split data in groups, not groups have data series, , large number of categories , series, reserving ton of space every series in every category, , have not render specific columns in specific categories, if possible. also i'd know if i'm doing incorrectly, conceptually speaking, , should approach different angle. realize make single-series chart categories cleverly named, i'm trying group these things visually together, not mention reports being generated proprietary generator, hard "know" kind of data coming back, in terms of how human want see it. you can see example here: ref: http://jsfiddle.net/gmpa7f7h/ $(function () { $('#container').highcharts({ chart: { type: 'column' }, title: { text: 'stacked bar chart' },

linux - Amazon EC2 Tomcat7 instance unable to access MySQL db on same system -

i think i've seen variety of similar posts on topic, still unable resolve issue, figured i'd post specifics. i have amazon aws linux ec2 instance running tomcat7 web server. on same machine running mysql5 server, unable tomcat app talk mysql database. my java app on tomcat tries connect mysql reading properties file: jdbc.mysql.host.path=jdbc:mysql://localhost/ jdbc.mysql.schema=prod jdbc.mysql.username=root jdbc.mysql.password=<password> i accessing app system via web browser, when app tries connect database following error in catalina.out: java.sql.sqlexception: access denied user 'root'@'localhost' (using password: yes) i'm pretty sure issue has permissions , communication between tomcat , mysql, because i've written simple java program utilizing same code read same properties file, , connection made successfully . here things have attempted remedy issue: change owner of properties file (currently owned 'tomc