Posts

c# - Exclude linq join condition based on parameter -

i want able dynamically exclude join based on boolean parameters, @ code below, how can exclude join if 'includejoin' variable false or there way dynamically add joins class program { static void main(string[] args) { list<foo> foolist = new list<foo>(); foolist.add(new foo{foo_id = 1}); foolist.add(new foo{foo_id = 2}); list<bar> barlist = new list<bar>(); barlist.add(new bar{foo_id = 1}); barlist.add(new bar{foo_id = 1}); iqueryable<foo> fooquery = foolist.asqueryable(); iqueryable<bar> barquery = barlist.asqueryable(); bool includejoin = false; var foos = f in foolist //exclude join if includejoin vairable false!! join b in barlist on f.foo_id equals b.foo_id g result in g.defaultifempty() select new foo { foo_id = f.foo_id }; var results = foos.tolist(); ...

java - How to decode a 9 digit integer to some random 4 digit word -

how encode 7 digit integer 4 digit string in java? i have base36 decoder, generating 6 characters, ex:230150206 converted 3t0x1a. the code follows: string f = "230150206"; int d = integer.parseint(f.tostring()); stringbuffer b36num = new stringbuffer(); { b36num.insert(0,(base36(d%36))); d = d/ 36; } while (d > 36); b36num.insert(0,(base36(d))); system.out.println(b36num.tostring()); } /** take number between 0 , 35 , return character reprsenting number. 0 0, 1 1, 10 a, 11 b... 35 z @param int number change base36 @return character resprenting number in base36 */ private static character base36 (int x) { if (x == 10) x = 48; else if (x < 10) x = x + 48; else x = x + 54; return new character((char)x); } can 1 share me other way achieve this?. the obtained string can made in substring, looking other way it. here method, in simple test...

python - Partial Collision Error -

i trying make version of pong using pygame, having issues detecting collision between ball , paddle. got detection working both paddles, came realize left player cannot move paddle when ball collides without ball passing through. player on right has no such issue, , keeping left player still allows ball reflect normally. import pygame, sys pygame.locals import * pygame.init() pygame.mixer.init() pygame.font.init() black = (0, 0, 0) white = (255, 255, 255) screenx = 1080 screeny = 720 clock = pygame.time.clock() pygame.mouse.get_pos in (screenx, screeny): pygame.mouse.set_visible(false) # blueprint creating player character class player: # defines initial conditions player def __init__(self): self.xpos = 0 self.ypos = 0 self.width = 20 self.length = 100 self.speed = 10 self.move = 0 self.upkey = 0 self.downkey = 0 self.score = 0 self.rect = pygame.rect((self.xpos, self.ypos, self.w...

c++ cli - how to fix "error C2872: 'IDictionary' :ambiguous symbol[ VS2012 - C++/CLI] -

i need use idictionary in project. when add compiler not , report obvious error “error c2872: 'idictionary' : ambiguous symbol” . if create new sample project compiler never reports error below code snippet temp.h #pragma once #using "system.dll" using namespace::system; using namespace::system::collections; using namespace::system::collections::specialized; public ref class mycollection : public nameobjectcollectionbase { private: dictionaryentry^ _de; // gets key-and-value pair (dictionaryentry) using index. public: property dictionaryentry^ default[ int ] { dictionaryentry^ get(int index) { _de->key = this->basegetkey( index ); _de->value = this->baseget( index ); return( _de ); } } // adds elements idictionary new collection. mycollection( idictionary^ d ) { _de = gcnew dictionaryentry(); each ( dictionaryentry^ de in d ) { this->baseadd( (string^) de->key, de->value...

spring-data-mongodb @indexed doesn't work when multi-tenant collections -

the project based on spring-data-mongodb use @indexed doesn't work when use multi-tenant collections.the following code: @document(collection = "#{ @tenantprovider.gettenant()}activity") @data public class activity { @id private string id; @indexed private string activityid; } if collection definition dynamic of course have make sure you're creating indexes manually there's no way determine possible collections might affected. users go ahead , create indexes manually using indexoperations .

c++ - How to set a default value to flagfile in gflags? -

i set flagfile this: declare_string(flagfile); int main(int argc, char** argv) { flags_flagfile = "./conf/default.conf" parsecommandlineflags(&argc, &argv, true); .... } then change flagfile command line ./main --flagfile=./conf/another.conf but flagfile still "./conf/default.conf" how set flagfile's default value , accept changes command line? you can check parameters before calling parsecommandlineflags function. for example like: std::regex flag_regex("--flagfile=(.+.conf)") std::smatch reg_match; if(std::regex_match(std::string(argv[1]), reg_match, flag_regex){ flags_flagfile = reg_match[0]; } that way use other configuration file. can change regex match differently depending on need.

Border not showing up in table, HTML, CSS, PHP -

the border isn't showing in table reason when i'm using css style it. however, if style in directly inside table tag, works. please take @ code: test.php <head> <style> table { border: 1px solid black; } </style> </head> <?php echo "<body>"; echo "<table>"; echo "<tr>"; echo "<td> hello1 </td>"; echo "<td> hello2 </td>"; echo "<td> hello3 </td>"; echo "</tr>"; echo "</table>"; echo "</body>"; ?> try code... table { border-collapse: collapse; } table td { border: 1px solid #333; } <html> <head><title>demo</title></head> <body> <table> <tr> <td>test1</td> <td>test2</td> <td>test3</td> <td>test4</td...