Posts

c++11 - C++ - Is there a way to create alias for field -

is there way create alias class/stuct filed in c++11 ? mean i've got class class vector4 { public: float x,y,z,w; } i got alias typedef vector4 color; is there way create aliases vector4 x,y,z,w fields work color r,g,b,a ? just define vector4 this, using anonymous unions (without anonymous structs, though common extension). typedef struct vector4 { union{float x; float r;}; union{float y; float g;}; union{float z; float b;}; union{float w; float a;}; } vector4; typedef vector4 color; if cannot redefine vector4, might instead define layout-compatible standard-layout class , use dreaded reinterpret_cast . works because standard layout classes having layout-compatible members compatible. struct color { float r, g, b, a; } standard quote: a standard-layout class class that: — has no non-static data members of type non-standard-layout class (or array of such types) or reference, — has no virtual functions (10.3) ...

xml - How do I display an image that I just took from my camera in my android app? -

i trying take picture , view on screen following code: public class mainactivity extends actionbaractivity { private static final int picture_request_code = 100; public button camera, gallery; private uri fileuri; private static file mediafile; imageview image; public string filename; @override protected void oncreate(bundle savedinstancestate) { system.out.println("started main activity"); super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); camera = (button) findviewbyid(r.id.button1); gallery = (button) findviewbyid(r.id.button2); createlisteners(); } private static uri getoutputmediafile(){ file mediastoragedir = new file(environment.getexternalstoragepublicdirectory(environment.directory_pictures), "mustache"); if (! mediastoragedir.exists()){ if (! mediastoragedir.mkdirs()){ log.d("mycameraapp...

mysql - expensive query takes down database server -- looking for ways to mitigate -

i have expensive query creates temporary table reporting purposes. having problem denial of service attack takes place 50+ of these queries pile (all same user). causes database server pretty taken down. query can take 1-10 seconds run , can have lot of rows in resulting temporary table. i not sure if there easy way improve query performance without re-architecting entire reporting piece of application. what solutions can use apply solve problem these queries piling , taking down server. my questions are: can think of solution improving query performance (query below) does make sense place session limit of 1 query can run once , prevent pile up any other ideas on how prevent attack. here query: create temporary table phppos_sales_items_temp (select phppos_sales.deleted deleted,phppos_sales.deleted_by deleted_by, sale_time, date(sale_time) sale_date, phppos_sales_items.sale_id, comment,payment_type, customer_id, employee_id, phppos_items.item_id, null item_kit_id, ...

eclipse - loop issue for java -

whenever run loop: system.out.println("how many gerbils in lab?"); int population = keyboard.nextint(); gerbil[] gerbil = new gerbil[population]; (int i=0; i<population; i++){ gerbil = new gerbil[population]; idnumber: (int b = 0; b<population; b++){ system.out.println("what id number of gerbil " + (b+1)); string idnumberx = keyboard.next(); if (b>0){ (int c = 0; c<gerbil.length; c++){ if (idnumberx.equals(gerbil[c].getid())){ system.out.println("repeat, try again"); c--; } else { return; } } } } i end output: how many gerbils in lab? 2 id number of gerbil 1 123 id number of gerbil 2 456 excepti...

arrays - C++ Enum values from string input -

been @ 1 while now, appreciate help. i'm create , object card enum values rank , suit based on string input. string in format of '2c, ad' etc. 2 clubs , ace diamonds respectively. i tried using linear search function found elsewhere on stackoverflow, it's in there returns -1 because doesn't seem getting right type of input. i've been able convert other way using char * array, can't life of me opposite way around. see below implementation: card.h #ifndef _card_h #define _card_h #include <string> #include <iostream> using namespace std; enum rank{ two, three, four, five, six, seven, eight, nine, ten, jack, queen, king, ace}; enum suit{ clubs, diamonds, hearts, spades}; //character sets used convert enums strings static const char * rankstrings[] = { "2", "3", "4", "5", "6", "7", "8", "9", "t", "j", "q",...

jquery - How do I render a list in Jade with a distinct javascript function for each item? -

i'm using express , jade on top of node.js build web app. have express route pulls list of words database , sends list jade array object rendering. want render jade page on client side each word, when clicked on, send distinct message server. my code far looks this... ./routes/show_words_to_user.js: exports.render_page = function(req, res){ dbclient.query('select word words;', function(err, result){ res.render('pagetitle',{wordlist:result,userdata:userobj}); }); }; ./views/words.jade: ul each word in wordlist li= word ./routes/update_preference.js (expects receive message client): exports.update_word = function(req, res){ dbclient.query('update words set userliked = 1 word=($1) , userid=($2)', [clickedword,userid],function(err, result){ res.send('your word updated.'); }; }; i need each word rendered in jade list act hyperlink send message server containing 1) name of word clicked...

c# - Team foundation Service Configuration in a workgroup -

Image
i'm trying configure tfs 2010,while i'm using vs2012.in visual studio when follow steps below after entering server name form prompts me username , password or shows error message cannot connect remote server,but since don't have experiences configuring tfs don't know how find these information. i go eam explorer in vs i connect team projects i write server name colleague's system then i'm prompted credentials or shows error message cannot connect remote server,so can not continue... thanks in advance i found problem.the account not set correctly in team foundation administration console , after setting correctly,i able create new team projects , other clients able connect team project on server. thanks