Earlejuliestacie's Profile

265
Points

Questions
51

Answers
42

  • Check whether this works

    new Handler().postDelayed(new Runnable() {     @Override     public void run() {         Intent mySuperIntent;         mySuperIntent = new Intent(ActivityHome.this, ActivityLogin.class);         startActivity(mySuperIntent);          //You might be closing the newly opened activity previously         ActivityHome.this.finish();      } }, SPLASH_TIME); 

    Hope this helps. Feel free to ask for clarifications…

    • 357 views
    • 2 answers
    • 0 votes
  • Asked on July 16, 2020 in XML.

    The pattern used in your template (using two attributes simultaniously) match will not match anything.

    If you want to use your code pattern, then try:

     <xsl:template match="PiecesTransportationQuantity">     <xsl:element name="{name()}">         <xsl:copy-of select="@* except @text"/>         <xsl:value-of select="@text"/>     </xsl:element>   </xsl:template> 

    else you can use the 2nd suggestion from @michael.hor257k’s answer:

     
    • 346 views
    • 3 answers
    • 0 votes
  • Asked on July 16, 2020 in Mysql.

    Why would you write a stored procedure? MySQL now supports check constraints:

    alter table employee add constraint chk_employee_eid     check (eid regexp '^E[0-9]{2}') 

    Note that this allows anything after the first 3 characters. If you don’t want anything, then add $ to the pattern:

    alter table employee add constraint chk_employee_eid     check (eid regexp '^E[0-9]{2}$') 
    • 412 views
    • 1 answers
    • 0 votes
  • There are several more techniques, each with pros and cons. But let me start by pointing out two techniques that hit a brick wall at some point in scaling up. Let’s assume you have billions of items, probably scattered across multiple server either by sharding or other techniques.

    Brick wall #1: UUIDs are handy because clients can create them without having to ask some central server for values. But UUIDs are very random. This means that, in most situations, each reference incurs a disk hit because the id is unlikely to be cached.

    Brick wall #2: Ask a central server, which has an AUTO_INCREMENT under the covers to dole out ids. I watched a social media site that was doing nothing but collecting images for sharing crash because of this. That’s in spite of there being a server whose sole purpose is to hand out numbers.

    Solution #1:

    Here’s one (of several) solutions that avoids most problems: Have a central server that hands out 100 ids at a time. After a client uses up the 100 it has been given, it asks for a new batch. If the client crashes, some of the last 100 are "lost". Oh, well; no big deal.

    That solution is upwards of 100 times as good as brick wall #2. And the ids are much less random than those for brick wall #1.

    Solution #2: Each client can generate its own 64-bit, semi-sequential, ids. The number includes a version number, some of the clock, a dedup-part, and the client-id. So it is roughly chronological (worldwide), and guaranteed to be unique. But still have good locality of reference for items created at about the same time.

    Note: My techniques can be adapted for use by individual tables or as an uber-number for all tables. That distinction may have been your ‘real’ question. (The other Answers address that.)

    • 329 views
    • 4 answers
    • 0 votes
  • Like @BentCoder has rightly answered, MySQL has a dedicated function FIND_IN_SET() that returns the field index, if the value is found in a string containing comma-separated values.

    SELECT * FROM products where product = 'carpet' and 'new' like concat('%',selling,'%'); 

    Or you could also try this by adding commas to the left and right:

    select * from products where product= 'carpet' and CONCAT(',', selling, ',') like '%,new,%' 
    • 341 views
    • 2 answers
    • 0 votes
  • Asked on July 16, 2020 in AngularJS.

    Take a look to the Route interface:

    interface Route {   path?: string   pathMatch?: string   matcher?: UrlMatcher   component?: Type<any>   redirectTo?: string   outlet?: string   canActivate?: any[]   canActivateChild?: any[]   canDeactivate?: any[]   canLoad?: any[]   data?: Data   resolve?: ResolveData   children?: Routes   loadChildren?: LoadChildren   runGuardsAndResolvers?: RunGuardsAndResolvers } 

    The path is declared as of type string, so you cannot change that to an array of string. If you do so you will get this error:

    Type 'string[]' is not assignable to type 'string'.ts(2322) 

    Instead, try something like:

    const routes: Routes = [     {         path: 'Data/:EntityID/:Date',         component: MyFormComponent,`children`:[             {                 path: '',                 loadChildren: () => import('../data-entry/data-entry.module').then(m => m.DataEntryModule)             }         ],      } ,     {          path: 'Settings/:EntityID/:Date',         redirectTo: 'Data/:EntityID/:Date', pathMatch: 'full'     } ... ]; 

    This way you will not repeat at least the component and children part.

    • 307 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    writerow does not instantly write to the file, most of the writing is done when closing the file. You can enforce the writing to the file with

    file.flush() 

    do this whenever you want to save your writings to the file.

    For further information https://www.tutorialspoint.com/python/file_flush.htm

    • 309 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    A great idea to use Numba for this type of thing but unfortunately, as you suspect, it doesn’t support the hypergeom function. You didn’t do anything wrong here — it’s just not supported so I think you won’t be able to use Numba in this case.

    A list of what is supported is at https://numba.pydata.org/numba-doc/latest/reference/numpysupported.html

    An approach I have taken in the past when something like this happens is to try to write my own version of the unsupported function using the subset of numpy that numba does support but success rate is variable and it can cause a whole new array of problems (Swapping out a debugged, tested library function for your own implementation of something can result in dumpster fires). Without looking at the source of hypergeom.pmf, I have no idea if this would be viable route here.

    • 327 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    Same opinion with @Sedy Vlk. Use hash(that is dictionary in python) instead.

    clines_count = {l: 0 for l in clines} for line in nlines:     if len(line) > 1 and line in clines_count:         pass     else:         if counter % 10000 == 0:             print ("%d: %s already checked or not valid " % (counter, line) )         counter += 1 
    • 318 views
    • 2 answers
    • 0 votes
  • Asked on July 16, 2020 in HTML.

    You cannot access class members in a static context. The name property also needs to be static.

    • 289 views
    • 2 answers
    • 0 votes