Posts

Showing posts from May, 2014

Converting time stamps in excel to dates -

i have large excel spread sheet has column of time stamps. know convert on date? there function can use? tried format cell date doesn't work. file 91,568 kb. if there simpler way great. i'm open ideas. thank in advance :) p.s. don't know programming languages use formula , set formatting desired time format: =(((column_id_here/60)/60)/24)+date(1970,1,1) source: http://www.bajb.net/2010/05/excel-timestamp-to-date/ tested in libreoffice

apache - In a Struts Action, can I write out a byte array as well as redirect the page? (Struts 1, Java) -

i'm working on project in which, after user submits form, i'd have them download pdf file (filled out information form) redirect them page. know how redirect (returning actionforward set redirect correct jsp) , know how send pdf (i build using itext library, write byte array out httpservletresponse 's output stream), i'm not sure how both without sort of kludge. i'm guessing i'll have 1 of 2 using javascript/ajax, wondering if there more elegant way struts. not servlets. what end doing in these situations request file timestamp request parameter. when write response set cookie timestamp. every few moments on client side check see if cookie exists, if does, window.location 'redirect' page.

php - How to create hierarchical json using data from a psql database? -

Image
i using php connect psql database , have initial code connect database, access table , set column array etc. i, however, have been struggling data desired format code running on. input in json hierarchical data form, following. function getdata() { return { "name": "data", "children": [ { "name": "america", "children": [ { "name": "ma", "children": [ {"name": "westborough", "order": 30}, {"name": "southborough", "order":20} ] }, { "name": "nh", "children": [ {"name": "nashua", "order": 12} ] }, { "name": "ca", "children": [ {"name": "sanfransico", "order": 17} ] } ] } ] }; this code have using php: <

bash - Replacing strings in one file with strings from second file -

i've been searching couple of days haven't got right answer i have 2 files this: file1: >contig-100_23331 length_200 read_count_4043 tcag... >contig-100_23332 length_200 read_count_4508 ttca... >contig-100_23333 length_200 read_count_184 ttcc... file2: >contig-100_23331_cov:_30.9135 >contig-100_23332_cov:_125.591 >contig-100_23333_cov:_5.97537 i want replace lines names (>contig... length...) in file1 lines names in file2. note file2 contains contig names (no sequence). i suppose theres way sed , can't find solution thanks in advance! one possibility use sed create sed -script file2 used on file1 : sed 's/^\(>contig-[0-9]*_[0-9]*\)_.*/s%^\1 %& %/' file2 > sed.script sed -f sed.script file1 > file.out rm -f sed.script for sample file2 , sed.script contain: s%^>contig-100_23331 %>contig-100_23331_cov:_30.9135 % s%^>contig-100_23332 %>contig-100_23332_cov:_125.591 % s%^>contig-100

javascript - Wordpress slider not showing up/transparent text/ and missing drop down menu -

i have seen issue on other posts can't seem find answer fixes particular site issue. site working fine until transferred host- had edit lot of wordpress php code work again, did nothing template. www.tnapothecary.com for whatever reason visual editor buttons gone on wordpress page editor. have updated lastest wordpress , nothing still working. ideas on how can text show again? the other issue i'm having slider not showing , drop down menu isn't working. thinking js issue, after replacing theme js , tinymce files- nothing did trick. ideas appreciated. thanks ben

php - display different tables based on a selected checkbox value for a current user in session -

when user registers there multiple healthcondition checkboxes user select ever applies them. allowed select 1 or more condition. i want set query when user logs in automatically see table showing foodoptions based on selected healthcondition/s upon registeration. able store these values in database i'm not sure how go retrieving these values , setting specific condition pull foods each of checkboxes database depending on on ever stored in database.... currently healthcondition stored diabetes, high cholesterol etc under field name healthcondition in member table. totally new , stressed out... please me .... please select of following conditions apply you: diabetes type1 diabetes type2 anemia high cholesterol pregnant none of above this code inserts data database if(isset($_post['healthcondition'])) { $healthcondition = implode(",", $_post['healthc

stylesheet - css: many sibling selectors on the same line -

in stilesheet have similar of follows: h2.foo1 ~ p.bar1 { ... } h2.foo2 ~ p.bar2 { ... } h2.foo3 ~ p.bar3 { ... } since properties defined within brackets same all, can combine above lines in one, , how? is, similar to: h2.foo1 ~ p.bar1 (?) h2.foo2 ~ p.bar2 (?) h2.foo3 ~ p.bar3(?) { ... } comma. h2.foo1 ~ p.bar1, h2.foo2 ~ p.bar2, h2.foo3 ~ p.bar3 { ... }

.net - Need help converting MVVM commanding Logic to Caliburn.Micro -

i have behavior created work plain vanilla mvvm , guidance on how make work caliburn.micro. my behavior follows: public class dropeventbehavior : behavior<dragsource> { protected override void onattached() { base.onattached(); this.associatedobject.drop += associatedobject_drop; } protected override void ondetaching() { this.associatedobject.drop -= associatedobject_drop; base.ondetaching(); } void associatedobject_drop(object sender, dropeventargs e) { if (dropeventcommand != null) dropeventcommand.execute(e); } #region command public icommand dropeventcommand { { return (icommand)getvalue(dropeventcommandproperty); } set { setvalue(dropeventcommandproperty, value); } } // using dependencyproperty backing store dropeventcommand. enables animation, styling, binding, etc... public static readonly dependencyproperty dropeventcommandproper

Switch locations on google map using a dropdown -

i'm new google maps, , have map multiple markers, , want switch between them using dropdown menu. i'm using code populate dropdown menu markers' title: // select marker dropdown menu $("select#myselect").change(function(){ gotomarker($(this).val()); }); function makemarkerlist() { var options = ""; $("select#myselect").empty(); (var in markers) { options += "<option value='" + + "'>" + markers[i].map.title + "</option>"; } $("select#myselect").html(options); } this have far jsfiddle this shows dropdown menu above map, don't know how markers titles in dropdown menu. i appreciate help. thank you. regarding second problem: original code, shown below, trying pass value of selected item in drop down list panto() method. however, due way you've set up, value index of markers in markers array , not

json - Disappearing SubDetail TObjectList when JSonToObject -

this first question. sorry english. i have classes this: tsfis_s = class(tpersistent) private _sfis_mid : integer; public property sfis_mid : integer read _sfis_mid write _sfis_mid; end; tsfis_d = class(tpersistent) private _sfis_mid : integer; _sfis_s : tobjectlist<tsfis_s>; public property sfis_mid : integer read _sfis_mid write _sfis_mid; property sfis_s : tobjectlist<tsfis_s> read _sfis_s write _sfis_s; end; tsfis_m = class(tpersistent) private _sfis_mid : integer; _sfis_d : tobjectlist<tsfis_d>; public property sfis_mid : integer read _sfis_mid write _sfis_mid; property sfis_d : tobjectlist<tsfis_d> read _sfis_d write _sfis_d; function tojson:tjsonvalue; destructor destroy; end; i trying convert tsfis_m object json , revert object datasnap application. use converts , reverters datatypes (tobjectlist , tobjectlist) { tsfis_m } function jsontosfis_m(json: tjsonvalue): tsfis_m; var unmarshaller: tjso

asp.net mvc 4 - MVC4 C# Populating data in a viewmodel from database -

i have viewmodel needs data 2 models person , address: models: public class person { public int id { get; set; } public string name { get; set; } public int age { get; set; } public int gender { get; set; } } public class address { public int id { get; set; } public string street { get; set; } public int zip { get; set; } public int personid {get; set; } } the viewmodel such public class personaddviewmodel { public int id { get; set; } public string name { get; set; } public string street { get; set; } } i have tried several ways data viewmodel , pass view. there multiple records returned display. my latest method populating view model such: private appcontexts db = new appcontexts(); public actionresult listpeople() { var model = new personaddviewmodel(); var people = db.persons; foreach(person p in people) { address address = db.addresses.singleordefault(a => a.personid == p.id) model.id = p.i

java - Passing an array between classes... stuck -

i have 3 java files working can't seem array print. have tried various things , seems going in circles. confused how work array different class. thank in advance help. here main: public class main { /** * @param args */ public static void main(string[] args) { testinteger ti = new testinteger(); testdouble td = new testdouble(); distance tdist = new distance(); mainmenu(); } public static void mainmenu() { int option; scanner sc = new scanner(system.in); while(true){ system.out.println("please choose type of numbers stored in array"); system.out.println(); system.out.println("******* main menu ********"); system.out.println("** 1. integers **"); system.out.println("** 2. double **"); system.out.println("** 3. distance **");

SQL Server is there a way around repeated conditional lines -

hello trying clean query , there 1 line repeated 6 times. there way set constant in sql? here example of issue: select distinct dsf.cityname, ( select count (distinct dsf1.incdtkey) dbo.incidentfile dsf1 dsf1.incidentmostsevere in ('1', '2', '4', '5', '6') , dsf1.categorykey in ('15', '01', '02', '03', '04', '05', '06')<----- , dsf1.cityname = dsf.cityname) 'weapons possession 11-12', ( select count (distinct dsf2.incdtkey) dbo.incidentfile dsf2 dsf2.incidentmostsevere in ('7', '8', '9', '10', '11', '12') , dsf2.categorykey in ('15', '01', '02', '03', '04', '05', '06') <----- , dsf2.cityname = dsf.cityname) 'drugs related 11-12', ( select count (distinct dsf3.incdtkey) dbo.incidentfile dsf3 dsf3.incidentmostsevere in ('14', &#

core graphics - iOS: Rotating a line with respect to a point that could be adjusted by touch -

Image
man, have been struggling this... in reference image above, have line fixed specific point. @ other end of line have point not fixed , dragged position on screen. need line able follow point , rotated respect it's position without changing lengths. i know of accomplished quite without having line fixed length. you draw uibezierpath in drawrect: this: uibezierpath *bezpath = [uibezierpath bezierpath]; [bezpath movetopoint:fixedpointstart]; [bezpath addlinetopoint:draggedpointend]; [bezpath stroke]; then call [self setneedsdisplay] in -(void)touchesmoved:(nsset *)touches withevent:(uievent *)event in uiview pass new coordinates of point dragged , have redrawn. but mentioned, need line fixed length. one other thing (not sure if make difference), line part of larger uibezierpath of irregular shape. "specific fixed point" shown in picture point of attachement of line larger irregular uibezierpath . line drawn part of same uibezierpath see in followin

PHP and MySQL are related to each other? -

in way php , mysql related each other ? i learnt sql , never learnt php. see web tools written in php used perform mysql operations , read interacting mysql makes php far more interesting tool. when these 2 used together, or recommended use them ? php programming language that's used server-side web programming. mysql relational database. the reasons see them used follows: both free , open-source both available on web hosts (even shared hosting providers) php used create dynamic web pages, while mysql used store , access data in more convenient manner flat files (see "why databases better flat files"). play complementary roles on server used together, can create interesting, dynamic web sites (wikipedia), applications (facebook), , frameworks (wordpress).

Accessing ruby variables in nested objects -

i have gem working on. in executable parses config file , instantiates couple of objects. 1 of these objects instantiates number of "handler" objects. parsing config file array, config , settings within not accessible in of other objects. needed in handlers. when try use them, variable not exist. i understand variable scope issue. not sure need make these accessible throughout entire program (including sub/nested objects) , not initial executable. while each of objects in program within module, actions in executable not. constants global, live in namespace in defined. if define config in main context, global @ root-level. if define in class or module, must refer full name outside of context. for example: class foo config = file.read(...) end config # => error, not defined foo::config # => defined it's bad form reference constants name, run against grain of proper object-oriented design. such, if define constants, should used intern

Call CMake from python script results in "Could not create named generator" -

i'm building project should able move freely between machines. in order not have hundreds of mb of libs i'm writing series of python scripts download , build dependencies own project. i'm using cmake generate vs projects. to call cmake build command line , use python subprocess.check_call below cmakecmd = ["cmake.exe", '-g "visual studio 11 win64"', build_path] retcode = subprocess.check_call(cmakecmd, stderr=subprocess.stdout, shell=true) the problem if use -g option cmake following error regardless of generator choose: cmake error: not create named generator "visual studio 11 win64" i thinking should enviroment variable missing python path complete systems' variables. what odd if don't set generator , let cmake choose default 1 script runs fine. have no ideia why. you need split -g flag value in command. python appears invoking cmake "-g visual studio 11 win64" <build_path> wha

java - generating stubs from wsdl using axis 2 for client -

i new bie world of webservices , have develop client side code java code,i have been provided wsdl can see opening wsdl in browser , have access wsdl , using axis 2 , have use wsdl2java tool, available in axis2 distribution generate stubs.. using stub need write client, please share url or example in generating stubs wsdl shown using axis 2 have generate client wsdl this tutorial http://axis.apache.org/axis2/java/core/docs/userguide-creatingclients.html#createclients may you. there client java class well.

mysql - Adding primary key as a part of INSERT INTO table VALUES query -

just demonstration purposes. have 2 tables "quiz" , "question". the quiz table contains following columns quiz_id (pk) quiz_title the question table contains following columns question_id (pk) quiz_id (fk) question_text i trying insert question text "question_text" in question table. i can retrieve latest quiz_id , insert question table. insert question (quiz_id) select max(quiz_id) quiz but need add question text. tried this: insert question (question_text) values ("question_text_sample") but getting error because fk info (quiz_id) not provided in query. i combine queries above can't figure out working solution. i tried following: insert quiz (quiz_title) values ("quiz_title_sample") insert question (quiz_id, question_text) values (last_insert_id(), "question_text") another try: insert question (quiz_id, question_text) values (select max(quiz_id) quiz , "question_text_s

Looping through variables in JAVA -

it possible loop through variables of primitive type char (using foreach loop)? i have 3 characters char char1 = 'a'; char chartest = 'p'; char character = 'r'; currently have long list of "if" statements applied char1: if (char1 == 'a') dosomething; else if (char1 == 'k') dosomethingelse; else if (charprev == 'g') dosomethingagain; else dosomethingyetagain; however, applying same set of "if" statements other character variables (in example chartest , character). what way accomplish this? input! the easiest way put variables array , loop through them. like char[] chararray = {char1, chartest, character}; // says, each char in chararray (char character : chararray) { if (character == 'a') // else if (character == 'k') // else // }

MATLAB .m file to mex file conversion -

i have matlab program need call php. converted exe of deploytool slow. want convert mex file or c file exe execution time speeds up. best method this?i looked @ matlab coder don't think supports program. method convert matlab .m file mex file executable? i want method speeds execution time. i don't believe mere converting .m file .mex compiling speed program (mind you'd still need mcr installed). maybe, depending on problem , skill of programmer, re-implementing of scratch trick.

iphone - How can I set maskToBounds effect on CAShapeLayer(Rounded-Recr cornered UIView)? -

i want make glow effect spread outside of thisview. i used code make half-rounded rect cornered uivew . round 2 corners in uiview here code. + (uiview *)makeupperhalfroundedview:(uiview *)view { cashapelayer *masklayer = [cashapelayer layer]; masklayer.frame = view.bounds; uibezierpath *roundedpath = [uibezierpath bezierpathwithroundedrect:masklayer.bounds byroundingcorners:uirectcornertopleft | uirectcornertopright cornerradii:cgsizemake(8.f, 8.f)]; masklayer.fillcolor = [[uicolor blackcolor] cgcolor]; masklayer.backgroundcolor = [[uicolor clearcolor] cgcolor]; masklayer.path = [roundedpath cgpath]; // masklayer.maskstobounds = no; //don't add masks layers in hierarchy! uiview *superview = [view superview]; [view removefromsuperview]; view.layer.mask = masklayer; [superview addsubview:view]; return view; } and there two image buttons in view closed boun

What does this code mean? (jquery) -

i reading plugin , can understand part $('<ul />', { 'class': settings.ulclass, html: albumitem.join('') }).appendto($this); what html: albumitem.join('') . html keyword or user defined? can't search because word html return generic result is selection similar $('p').appendto($this) ? if can search grammar of this? thanks .join() native method of array objects, joins elements of array string. assuming albumitem array, albumitem.join('') join elements in array create string joining character empty string. ex: var albumitem = ['one', 'two', 'three']; albumitem.join('') // give 'onetwothree' your code $('<ul />', { 'class': settings.ulclass, html: albumitem.join('') }).appendto($this); will create ul element class returned settings.ulclass , have contents of array albumitem childre

javascript - jQuery slideToggle callback function and toggleclass -

html <div class="a"> <div class="b">click</div> <div class="c"></div> </div> <div class="a"> <div class="b">click</div> <div class="c"></div> </div> <div class="a"> <div class="b">click</div> <div class="c"></div> </div> jquery $('.c').hide(); $('.b').click(function(){ $(this).next('.c').fadetoggle(); if($('.b').eq(0).is(this)){ $(this).toggleclass('yellow'); } }); online sample how make once slidetoggle finishes start toggleclass , 1st box, i'd change yellow color once fadetoggle finishes you can use fadetoggle 's callback function: working demo: http://jsfiddle.net/kqc2b/ $('.b').click(function () { var = this; $(this).next('.c').fadetoggle(function() {

c++ - User inputs stringstream, then need convert to string to pass in function parameters -

i trying ask user stringstream, convert string can pass in functions parameters. how can ? : string nm; stringstream ss; cout << " please enter charge made " << endl; cin >> nm; ss.str(); cca.docharge(nm); are asking pass actual stream function, or string? following passes stream: std::string str; std::stringstream ss; std::getline(std::cin, str); ss.str( str ); cca.docharge(ss); this passes string: cca.docharge(str);

java - Editable JCombobox and the key listener -

how add key event listener in jcombobox accepts whole string ex. if add 's' should search string start 's' in database .if there no result should wait user type other character in combobox similar results check if helps- combobox.addkeylistener(new keyadapter() { @override public void keyreleased(keyevent ke) { // text typed , search // text combo box, , not key event } });

php - Search a string replace a word with array's value -

the idea search string words , change them else according specific array. let me show mean. $string = "hello buddy, i'm friend or maybe fellow"; let's friends swear word. want change word want. made this: $swears = array( "friend" => "fri**d", "buddy" => "bu**y", "fellow" => "fe**ow" ); i want search string according array's key , replace it's value. did search web replace value in array according array key. after trying came this: $string = "hello buddy, i'm friend or maybe fellow"; $swears = array( "friend" => "fri**d", "buddy" => "bu**y", "fellow" => "fe**ow" ); $foreach = $string; foreach($swears $bad => $good){ $foreach = str_replace($bad,$good,$foreach); $filtered = $foreach; } echo $filtered; i know works, there easy way feel complicated whole thing. if i'm g

mysql - How to create extra columns use column value? -

i'm having following problem i have table this +------+---------+------------+ | imei | channel | sys_date | +------+---------+------------+ | 1111 |unknown01| 2013-04-15 | | 2222 |unknown02| 2013-04-15 | | 3333 |unknown03| 2013-04-15 | | 4444 |unknown01| 2013-04-16 | | 5555 |unknown02| 2013-04-17 | | 6666 |unknown02| 2013-04-17 | +------+---------+------------+ now need write sql let result this(let channel's value column) +----------+---------+---------+---------+ | sys_date |unknown01|unknown02|unknown03| +----------+---------+---------+---------+ |2013-04-15| 1 | 1 | 1 | |2013-04-16| 1 | 0 | 0 | |2013-04-17| 0 | 2 | 0 | +----------+---------+---------+---------+ i have no idea sql,so need ,thanks you can use case that select sys_date ,sum(case channel when 'unknown01' 1 else 0 end) unknown01 ,sum(case channel when 'unknown02' 1 else 0 end) unknown02 ,sum(case channel when '

unable inject grails app context in src/groovy -

i have created custom event listener extends abstractpersistenceeventlistener described in grails docs http://grails.org/doc/latest/guide/gorm.html , works fine, however. unable inject service in listener if doing follows. def context = servletcontextholder.servletcontext.getattribute(grailsapplicationattributes.application_context) def myservice = context.myservice the 'context' returns null. any ideas may problem. thank p.s. grails 2.1.2 pass in applicationcontext listener constructor argument when register it.

asp.net - how to config or handle iis when my website change its directory -

when developed , deployed asp.net mvc application in past,my code this: <script src="../../scripts/jquery-1.4.4.min.js" type="text/javascript"> </script> <img src="../../content/images/logout.png"/> <div class="menu_home" style="background-image:url('../../content/images/menu_home.png');background-color:#919191;"></div> $.ajax({ type: "get", url: "/home/details", data: { id: id }, success: function (jsonresult) {//something}}); there no problem while testing locally casini or deploy website in iis root directory. now when add application in iis root, move application new application,i have rewrite code forexample in 3: `<img src="url.content("~/content/images/logout.png")" /> ` in 4 $.ajax({ type: "get", url: "myweb/home/details", data: { id: id }, success: functi

objective c - How can I find whether an exact sub string is present or not in NSString -

how can find whether exact substring present or not in nsstring . currently assume string "1000 * roomtemperature" , want check whether "roomtemperature" present or not. ["1000 * roomtemperature" rangeofstring:"roomtemperature"].location != nsnotfound give me true . if check ["1000 * roomtemperature" rangeofstring:"temperature"].location != nsnotfound . return me true . my requirement false second scenario. please me out solution. try using following code. return true if word exist , false if not exist nsstring *str = @"1000 * roomtemperature"; nsarray *array = [str componentsseparatedbystring:@" "]; return [array containsobject:@"roomtemperature"];

ruby on rails - Form for one model in view for another -

i writing simple rails app , have 2 models, location user, have same relationship message model. is, location has many messages, user has many messages, , message belongs user , location. trying add form create new message on location show view. here code: app/views/locations/show.html.erb: <h1><%= @locaton.name %></h1> <p><%= @location.location %></p> <p><%= @location.discription %></p> <%= link_to "find different location", crags_path %> <h2> messages <ul> <% @location.messages.each |message|%> </li> <h3><%=message.user.username%></h3> <p><%=message.content%></p> </li> <% end %> </ul> locations controller: class locationscontroller < applicationcontroller def index @locations = location.all end def show @location = location.find(params[:id]) end def new @location = location.

Hashing a string to an integer in c++ -

i trying figure out conversion process strings ints. doing program hashing, in key value hashed name of state. research, seems atoi() not work. do need break each letter of word down , individually convert? use ascii? going in wrong direction? i lost, information fantastic. thanks! c++11 introduces implementation defined hashing function called std::hash in header <functional> has speciality string classes std::string , std::wstring , etc. it's simple doing this: #include <iostream> #include <functional> //for std::hash #include <string> int main() { std::string str = "hello world"; std::hash<std::string> hasher; auto hashed = hasher(str); //returns std::size_t std::cout << hashed << '\n'; //outputs 2146989006636459346 on machine } specializing std::hash user defined types isn't complex either. note there no std::hash specialization const char* or of c-strings.

java - Is there any possibilities to store JPanel object in arraylist -

hi got assignment team leader store employee details user entered in textfield whatever in panel, after in other frame admin have check details of each employee calling arraylist, list should show panel in cardlayout,, here coding employee registration.can please me registration() { frm=new jframe("welcome login page"); left=new jpanel(new gridlayout(0,1)); left.setbackground(color.light_gray); right=new jpanel(new gridlayout(0,1)); right.setbackground(color.light_gray); sp=new jsplitpane(jsplitpane.horizontal_split,left,right); lb9=new jlabel("member"); lb9.setfont(new font("serif",font.plain, 18)); lb9.setforeground (color.blue); lb10=new jlabel("create account"); lb10.setfont(new font("serif", font.plain, 16)); lb10.setforeground (color.blue); lb1=new jlabel("username"); tf1=new jtextfield(10); lb2=new jlabel("password"); tf6=new jtextfield(10);

Using NLog's MappedDiagnosticsContext with ServiceStack -

i'm using nlog servicestack service. i'd use nlog's mappeddiagnosticscontext append variable each log entry. in case, i'd generate unique identifier each request , have identifier logged log entries logged during request. the servicestack.logging.ilog interface (or other servicestack logging class matter) doesn't seem support this. i can nlog.mappeddiagnosticscontext.set("somekey", "some value") . works ties me nlog (i'm not worried though). two questions: is there better way servicestack. is safe assume values set nlog's mappeddiagnosticscontext scoped request? i'm planning use mappeddiagnosticscontext these purposes: eventid's event log targets: ${mdc:item=eventid}. had been considering using eventcontext property instead, changes way have log items. sessionid's other targets when logging asp.net code: ${mdc:item=sessionid} since ${aspnet-sessionid} way doesn't seem work correctly non-asp co

objective c - Why does an NSInteger variable have to be cast to long when used as a format argument? -

nsinteger myint = 1804809223; nslog(@"%i", myint); <==== the code above produces error: values of type "nsinteger" should not used format arguments: add explicit cast 'long' instead. the correct nslog message nslog(@"%lg", (long) myint); why have convert integer value of myint long if want value display? you warning if compile on os x (64-bit), because on platform nsinteger defined long , 64-bit integer. %i format, on other hand, int , 32-bit. format , actual parameter not match in size. since nsinteger 32-bit or 64-bit, depending on platform, compiler recommends add cast long generally. update: since ios 7 supports 64-bit well, can same warning when compiling ios.

c - How to detect empty epoll set -

i'm learning use epoll, , wrote following example #include <assert.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <sys/epoll.h> #include <unistd.h> int main() { int epfd; struct epoll_event ev; struct epoll_event ret; char buf[200]; int n,k,t; epfd = epoll_create(100); assert(0 == fcntl(0, f_setfl, fcntl(0, f_getfl) | o_nonblock) ); ev.data.fd = 0; ev.events = epollin | epollet; if(epoll_ctl(epfd, epoll_ctl_add, 0, &ev) != 0) perror("epoll_ctl"); while((n = epoll_wait(epfd, &ret, 1, -1)) > 0) { printf("tick!\n"); if(ret.data.fd == 0) { k=0; while((t=read(0, buf, 100)) > 0) { k+=t; } if(k == 0) { close(0); printf("stdin done\n"); } }

mysql - Want to get all data from three tables in single query with group by function -

what need: want show sales dish category i have 3 tables problem: 1.order(dish_id,dish_price,dish_quantity) 2.dish(dish_id,dish_name,dish_cat_id) 3.dish_category(dish_cat_id,dis_cat_name what result want : want show report , how many quantity has been sold, dish category wise , , total price , total_quantity result expected: dish_cat_id, dish_cat_name, total_price , total_quantity_sold what have tried: select d.dish_name, d.dish_id, sum(o.price) total_price, sum(o.dish_quantity) total_qauntity order o , dish d o.dish_id = d.dish_id group o.dish_id now here can dish , total price dish wise , how them dish_category wise as right getting no idea expected fire query on selected result query them dish_category wise select dc.dis_cat_name, sum(o.price) total_price, sum(o.dish_quantity) total_quantity order o inner join dish d on o.dish_id = d.dish_id inner join dish_category

android - Viewpager OffscreenPageLimit issue -

i've multiple choice (radio buttons) questions on pages. i'm getting user answers hashmap. set previous question answer on start of next question. result start using set hashmap on start 2.page. but problem is: think viewpager loads first 2 pages @ same time ; "set hashmap" on start 2.page goes null ; because 1. page isnt loaded / or loaded @ same time how can rid of problem ? page: list answers (1) page: user choice(1), clear list(1), set list answers (2) page: user choice(2), clear list(2), set list answers (3) ... maybe setoffscreenpagelimit 0 solution lowest value 1 this older answer can you. want know when fragment visible, , update there.

objective c - Application icon badge number not increasing : Xcode -

i facing problem push notification application badge number value updation. i doing like: -(void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo { uiapplicationstate state = [application applicationstate]; if (state == uiapplicationstateactive) { // stuff when app active }else{ // stuff when app in background [uiapplication sharedapplication].applicationiconbadgenumber = [uiapplication sharedapplication].applicationiconbadgenumber+1; /* increment icon badge number */ } } but, icon showing badge number '1' always, , not incrementing when more notifications there/ 1 notification came after another. any advice appreciable... the badge number set operating system when receive json notification payload resembles following: { "aps" : { "alert" : "new notification!", &quo

wpf - How to filter a collection when binding it to ItemsSource? -

i created treeview modelizes directories , files on hard drive. each treeviewitem has checkbox, binded isselected property. i'd achieve display each parent node count of selected files on total files count (10 / 12 10 files on twelve total selected). is there way binding property ...? <contentpresenter content="{binding myitems.count myitems.isselected, mode=onetime}" margin="2,0" /> there no way directly filter collection in binding. however, wpf allows filtering (and sorting , grouping) collections collectionviewsource . one approach define collectionviewsource in resources of itemtemplate filters itemssource number of elements pass filter binding count property of collectionviewsource . have define filter in codebehind, though. this: <treeview x:name="tree" itemssource="{binding items}"> <treeview.itemtemplate> <hierarchicaldatatemplate itemssource="{binding ch

java - Better technique for MyThread class -

this question has answer here: “implements runnable” vs. “extends thread” 37 answers better post : "implements runnable" vs. "extends thread" i can create own thread class mythread 2 ways, class mythread extends thread or class mythread implements runnable which technique better , why? and in case of implementing runnable, have create thread object mythread object, like mythread mt = new mythread(); thread t = new thread(mt); then advantage of implementing runnable interface technique? while creating thread implementing runnable interface better. because can extend new class other class, otherwise can not extend it.

jsp - Action method not being called while calling from window.open() in javascript -

i trying open new window , call action in process in struts 2. the problem jsp opens action not being called till press refresh or go new jsp. i want action execute , redirect corresponding jsp right redirects jsp corresponding first mapped result. action call javascript: function displaygraph(graphname) { alert("displaygraph"); var url = 'drawcmgraph?data=' + encodeuricomponent(graphname); alert(url); window.open(url, "_blank", "directories=no, status=no,width=550, height=200,top=0,left=0"); } action mapping in struts.xml <action name="drawcmgraph" class="com.casealerts.action.homeaction" method="drawgraph"> <result name="success">/casealerts/test.jsp</result> <result name="error">/casealerts/error.jsp</result> </action> web.xml <?xml version="1.0" encoding=

javascript - HTML5 canvas toDataURL sometimes returns "data:," instead of the image -

i have created canvas document.createelement("canvas") : var canvas = document.createelement("canvas"); canvas.width = width; // width = 4000 or more canvas.height = height; // height = 5000 or more then use canvas.todataurl() base64 string: var str = canvas.todataurl(); but 'str' returns "data:," , no image data in it. 6 chars. sometimes returns correct string "data:image/png;base64,ivborw0kggoaaaansuheugaaeggaabpscayaaabg/ah3aaagaeleqvr4xuzcqreaaajdm..." i canvas.width large .... you should try create 2d context explicitly , draw in empty shape, like: var canvas = document.createelement("canvas"); canvas.width = 4000; canvas.height = 5000; var ctx=canvas.getcontext('2d'); ctx.fillrect(0,0,0,0); canvas.todataurl(); edit: seems canvas contains data exported datauri: var canvas = document.createelement("canvas"); canvas.width = 400000000; canvas.height = 500000000; var ctx=

java - Super big size sprite sheet to load in android - outofmemoryerror -

my question best possible solution or work around problem? this problem. doing 2d android game flash game. have png image dimension 8000 x 4800. sprite sheet 10 columns , 10 rows, each frame has 800 x 480 dimension. know super big size sprite sheet because flash game super animated , has graphics, exported each action/scene png sequence retain animation , quality of graphics , avoid calculation of animation. if load picture in android, got outofmemoryerror. think because of image size. got 4 more image same dimension load on same screen. please me. best possible solution or work around this. you need sale down image before display same. http://developer.android.com/training/displaying-bitmaps/load-bitmap.html . check topic under loading scaled down version in memory. also should recycle bitmaps when not in use. load bitmaps in onresume() , in onpause() recycle bitmaps. bitmap.recycle() http://www.youtube.com/watch?v=_cruqy55hok the talk in video memory m

jquery - Javascript regex get the number part from a specific word -

say have element these classes: "floatleft item4". if want save number "4" variable "item4" how that? i think use pattern "/item(\d+)/" use replace or match , how? you can use match this: var str = "item4", num = +str.match(/item(\d+)/)[1]; // => 4 i used unary + cast number. can use parseint or number constructor instead.

yii - How to extend cactiverecord -

i want add aditional methods in cactiverecord, if class project_model extends cactiverecord {} error the table "project_activerecord" active record class "project_activerecord" cannot found in database. i want create simple structure: cactiverecord->project_activerecord (only extend methods)->table (real table). how can this? the error clear: don't have table named project_activerecord in db! if project_model going base model others active record models should like: //a base classe example has behavior shared inherited class abstract class project_model extends cactiverecord { public function behaviors(){ return array( 'ctimestampbehavior' => array( 'class' => 'zii.behaviors.ctimestampbehavior', 'setupdateoncreate' => true ), ); } } and can declare other class will have table in db : class yourclass ex