Posts

add score in Screen libgdx

Image
Clash Royale CLAN TAG #URR8PPP add score in Screen libgdx I have a sprite that collides with obstacle, but i have a problem with the score in the top of my screen. In the update of my class, The collisions are specified by an array, but when it collides with an object, the score is still growing and I can not stop it. this is my code: private Array<Polen> polen; private Score score; public PlayState(GameStateManager gsm) super(gsm); score = new Score(110, 310); polen = new Array<Polen>(); for(int i = 1; i <= COUNT; i++) polen.add(new Polen(i * (Polen.WIDTH))); @Override public void update(float dt) handleInput(); for(int i = 0; i < polen.size; i++) Polen pol= polen.get(i); if(pol.collides(aliado.getBounds())) pol.changeExplosion(); flagScore = 1; if (pol.collides(aliado.getBounds())==false) flagScore = 0; if (flagScore == 1) Score.count++; flagScore=0; //auxCount = Score.count +1; score.update(dt); updateGround(); cam.update(); Score Clas

Angular 6 - Update *ngIf after Component Loads

Image
Clash Royale CLAN TAG #URR8PPP Angular 6 - Update *ngIf after Component Loads Component: import Component, OnInit from '@angular/core'; // Services import AuthService from './services/auth.service'; @Component( selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.less'] ) export class AppComponent implements OnInit user: Object; authorized: boolean; constructor(private authService: AuthService) ngOnInit() this.authorized = this.authService.loggedIn(); HTML: <app-navbar *ngIf="authorized"></app-navbar> <div id="content" *ngIf="authorized"> <app-sidebar></app-sidebar> <div class="wrapper full-width"> <router-outlet></router-outlet> </div> </div> <div class="container mt-6" *ngIf="!authorized"> <router-outlet></router-outlet> </div> this.authService.logg

Is it posibble to prevent the outer transaction context from rollback even after a exception that marked as rollBackFor thrown?

Image
Clash Royale CLAN TAG #URR8PPP Is it posibble to prevent the outer transaction context from rollback even after a exception that marked as rollBackFor thrown? Suppose a user signup process like this: @Service public class UserService @Resource private EmailService emailService; @Resource private Jmstemplate jmsTemplate; @Transactional(rollbackFor = Exception.class) public void signUp(User user) //save user to DB, etc postSignUp(User user); /** * Business that not so important * suppose this method may throw any exception * **/ public void postSignUp(User user) emailService.sendEmail(user); jmsTemplate.sendSignUpEvent(user); ... We make the signUp() method as transactional. if any exception thrown within signUp() method, the transaction will rollback. And of course, any exception thrown within postSignUp() will also result in the rollback of the transaction. But, since the logic in postSignUp() was not so important, I wonder how can I prevent the outer transactio

How to specify tint as custom attribute on ImageView when using MotionLayout

Image
Clash Royale CLAN TAG #URR8PPP How to specify tint as custom attribute on ImageView when using MotionLayout How do I specify a tint color to an imageView as a custom attribute when using MotionLayout. Currently I can only specify a custom background color in my MotionScene xml file: MotionScene <ConstraintSet android:id="@+id/end"> <Constraint android:id="@+id/imageView" android:layout_width="180dp" android:layout_height="180dp" motion:layout_constraintBottom_toBottomOf="parent" motion:layout_constraintEnd_toEndOf="parent" motion:layout_constraintStart_toStartOf="parent" motion:layout_constraintTop_toTopOf="parent" motion:layout_constraintVertical_bias="0.75" motion:srcCompat="@drawable/ic_android_black_24dp" > <CustomAttribute motion:attributeName="backgroundColor" motion:customColorValue="#9999FF" /> </Constraint> </Constr

Netlogo: how to register the tick-advance counter as a variable?

Image
Clash Royale CLAN TAG #URR8PPP Netlogo: how to register the tick-advance counter as a variable? I would like to register the tick-advance counter as a variable and use it for calculation in mathematical formulas, for example, (A + B) * tickadvance. However, Netlogo seems to be unable to register the tick-advance counter as a variable. Below is a sample syntax where "Expected reporter" error has been issued. This does not go well. globals [tickadvance example-f] ;Omission; set tickadvance (tick-advance 0.001) ;"Expected reporter" is occurring with this syntax. set example-f ((A + B) * tickadvance) Any advice? 2 Answers 2 You need to do it the other way around. In setup you can include set tickadvance 0.001 , and then in your code, you can call tick-advance tickadvance . setup set tickadvance 0.001 tick-advance tickadvance Alternatively, if you really just want ticks , see the answer of @JensB. ticks If you are simply wanting the value of the counter, then

evaluate relational operator from a string

Image
Clash Royale CLAN TAG #URR8PPP evaluate relational operator from a string I have relational expressions stored in a database, that i have as strings in an iOS app. I would like to evaluate the conditions within the strings in C#, similar to the logic in the following psudo code: string str1= "x > 0"; string str2= "y < 1"; int x = 1; int y=0; if(str1 && str2) //do stuff stackoverflow.com/questions/5029699/… – Arslan Ali Aug 6 at 0:00 It really would help if you explained why you need to do this. – Dour High Arch Aug 6 at 0:02 I agree, if they are simple numerical comparisons, and they are related to entities within your database, you could easily just do this in a table, with min max and enum to choose the variable your comparing with and so forth. this could be fast , server side, and easy as a LINQ / EF expression – Saruman Aug 6 at 0:06 enum 2 Answers 2 If the expressions are simple like the one in the example, then you

How to store a value of variable in javascript for new tab opened in browser

Image
Clash Royale CLAN TAG #URR8PPP How to store a value of variable in javascript for new tab opened in browser This function works fine as well as I'm getting currentUrl here: currentUrl var currentUrl; function onFileSelected(event) var selectedFile = event.target.files[0]; var reader = new FileReader(); var result = document.getElementById("result"); reader.onload = function(event) currentUrl = event.target.result; result.innerHTML = event.target.result; ; reader.readAsText(selectedFile); return currentUrl; The problem is that this is launching a new Chrome window and the value of my currentUrl variable is lost: currentUrl function launchChromeAndRunLighthouse(currentUrl, opts, config = null) const cmd = `lighthouse $currentUrl --chrome-flags="--headless"`; exec(cmd, (error, stdout, stderr) => if (error !== null) console.log(`exec error: $error`, stderr); ); I have an HTML file which takes a text file as input and the text file contains mu

yield n files from disk

Image
Clash Royale CLAN TAG #URR8PPP yield n files from disk I am trying to read file from the disk and then split it into [features and labels] [features and labels] def generator(data_path): x_text= counter=0 _y= for root, dirs, files in os.walk(data_path): for _file in files: if _file.endswith(".txt"): _contents = list(open(data_path+_file, "r", encoding="UTF8",errors='ignore').readlines()) _contents = [s.strip() for s in _contents] x_text=x_text+_contents y_examples=[0,0,0] y_examples[counter]=1 y_labels = [y_examples for s in _contents] counter+=1 _y=_y+y_labels return [x_text, _y] I have huge 3.5GB of data in the disk and I cant read it into the memory at the same time. How can I modify this code to generate n files at a time for processing. for X_batch, y_batch in generator(data_path): feed_dict = X: X_batch, y: y_batch Is there an more efficient way to read this huge data in tensorflow? stackoverflow.com/questions/6475328/…

AttributeError using scipy.sparse.toarray()

Image
Clash Royale CLAN TAG #URR8PPP AttributeError using scipy.sparse.toarray() import scipy as sp import numpy as np a=sp.sparse.coo_matrix(np.random.randint(0,9,[4,5])) b=sp.sparse.coo_matrix(np.random.randint(0,9,[4,2])) sp.hstack([a,b]).toarray() is giving me AttributeError: 'numpy.ndarray' object has no attribute 'toarray' could you help me with my silly mistake here? 1 Answer 1 sp.hstack (i.e. numpy.hstack ) is the ordinary, dense hstack, which won't combine the sparse arrays correctly. It builds a 1D numpy array already (of object dtype; in other words, it just wraps the Python-level objects and crams them in there.) You want scipy.sparse.hstack : sp.hstack numpy.hstack scipy.sparse.hstack In [332]: sp.hstack([a, b]) Out[332]: array([<4x5 sparse matrix of type '<class 'numpy.int64'>' with 17 stored elements in COOrdinate format>, <4x2 sparse matrix of type '<class 'numpy.int64'>' with 7 stored eleme

CSS: how to set a min-width that is overridden by a max-width?

Image
Clash Royale CLAN TAG #URR8PPP CSS: how to set a min-width that is overridden by a max-width? From this question, I know min-width has precedence over max-width. My question is how do I achieve the following: I want a div to be 50% width, but no less than 350px width, unless the view port width is less than 350px, in which case I want the max-width to be 100%. If I use the following: .half-right width: 50%; float: right; padding: 2em 4em; min-width: 300px; max-width: 100%; the min-width overrides the max-width, and there is some bleeding outside 100% of the width. Help appreciated. Use a media query – spectras Aug 6 at 1:19 1 Answer 1 Add a media query @media screen and (max-width: 350px) .half-right width: 100%; By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Transferring specific data in Excel into individual slides in PowerPoint

Image
Clash Royale CLAN TAG #URR8PPP Transferring specific data in Excel into individual slides in PowerPoint I have to take information in a large spreadsheet and transfer it into a PowerPoint. Each row in the spreadsheet is one individual's information. There are 1000 rows in the spreadsheet, meaning I need to create 1000 slides, one for every individual. However, not all columns are needed. Here is an example of my data: A small similar data set What I want in the end: One slide, note that not all columns are needed Another slide Is there a way to do this without the manual copy and paste? There must be code to speed up the process. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Table referencing multiple tables. Error in save “Referential integrity constraint violation.”

Image
Clash Royale CLAN TAG #URR8PPP Table referencing multiple tables. Error in save “Referential integrity constraint violation.” I have tables in the following structure. Table1 Key, DocKey, Name Table2 Key, DocKey, Name Table3 Key, DocKey, Name Table4 Key, DocKey, T1Key, T2Key, T3Key, Name, Value I have defined the foreign key relation ship in the following way. What i am trying to do is, to make the T4 dependent and have navigational properties to T1, T2 and T3. modelBuilder.Entity<Table4>() .HasRequired<Table3>(d => d.Table3Nav) .WithMany() .HasForeignKey(k => new k.DocKey, k.T3Key ); modelBuilder.Entity<Table4>() .HasRequired<Table2>(d => d.Table2Nav) .WithMany() .HasForeignKey(k => new k.DocKey, k.T2Key ); modelBuilder.Entity<Table4>() .HasRequired<Table1>(d => d.Table1Nav) .WithMany() .HasForeignKey(k => new k.DocKey, k.T1Key ); I am able to add objects, but when i am trying to save, i am getting the followin

Can I have multiple “categories” on one connection?

Image
Clash Royale CLAN TAG #URR8PPP Can I have multiple “categories” on one connection? I'll be designing a SPA with Angular 6 and .netcore 2 as a backend API. I'm going to need a socket implementation for live data streaming and charting purposes. I have a page that requires 3 different data types "live streamed" and my question is - can I do this with one websocket connection? As far as I know, I think that there is a way to create some kind of a queue in the connection or something like a substream, so I can have something like the following: socket = new WebSocket(url); socket.on('dataOne', () => // proccess here socket.on('dataTwo', () => // proccess here socket.on('dataThree', () => // proccess here I'm wondering if this is possible and if it is, can you advise me on a lib that I can use for the Client and the API? I've researched libs like SignalR for C# and Substream, but I'm not completely sure. All kinds of advise

Strategy for getting a “real” device time while offline

Image
Clash Royale CLAN TAG #URR8PPP Strategy for getting a “real” device time while offline We allow users to clock-in via our react native app. We also allow offline clock-in by saving the GEO location and timestamp of the action and waiting for an active internet connection. Is there a way to detect whether a clever user changed the time of the device while being offline and clocking in? We thought we could start some interval when the app last contacted the server but is it the best option? I am not sure whether an interval would properly run when the app is in the background and such. If someone really wants to trick you out he will be able to work around every countermeasure. – Jonas Wilms Aug 5 at 17:10 @JonasW. I assume this is correct but we're aiming to find a way to prevent this from the average user rather than Snowden or so... ;-) – Guy Aug 5 at 22:11 5 Answers 5 Using Node.JS you can grab the system's uptime. See: https://nodejs.org/api/os.html#

Ionic 3 add class dynamically if the input is not valid

Image
Clash Royale CLAN TAG #URR8PPP Ionic 3 add class dynamically if the input is not valid Hi I am using Ionic 3 and I am using formBuilder of Angular to validate my form inputs and display some validation messages to the UI of the component when something goes wrong with the input . Now everything works fine except for one. I want to add class dynamically to my input when the input field is not valid . input field Picture below. Here is what it looks like in my html <ion-input class="input-cover" id="firstName" formControlName="firstName" type="text" placeholder="First Name *" [class.invalid]="form.controls['firstName'].errors && (form.controls['firstName'].dirty || form.controls['firstName'].touched)"></ion-input> and in my scss I have this below .invalid border: 1px solid #ea6153; border-radius: 5px; .text-input-ios, .text-input-md border-radius: 5px; border: 1px s

Animation positioning on window resize

Image
Clash Royale CLAN TAG #URR8PPP Animation positioning on window resize I was wondering if it was possible to use jquery window.resize() to ensure the two donuts positioning never collides with the home text in the middle. I'm not sure how to link the x and y of the window size to change the top/left and bottom/right positioning values. Or is there a way I could decrease the width and height of the donuts on window resize? Any help would be appreciated! html, body margin: 0; #container width: 100vw; height: 100vh; background-color: pink; display: flex; align-items: center; overflow: hidden; position: relative; #donut img, #donut2 img width: 500px; height: 500px; #donut width: auto; height: auto; position: absolute; animation: donut 2s; animation-fill-mode: forwards; @keyframes donut 0% left: -20%; top: -20%; transform: translateZ(-100px); 100% left: -5%; top: -5%; transform: translateZ(100px); #donut2 width: auto; height: auto; position: absolute; a

Select between two tables, two columns

Image
Clash Royale CLAN TAG #URR8PPP Select between two tables, two columns I am trying to find all records in TableA which are not in TableB by comparing 2x columns in each table. I have tried all sorts of queries but I cannot figure it. Any help would be much appreciated. TableA Has ColumnA and ColumnDate TableB Has ColumnA and ColumnDate So I only want to see which records in TableA do not match TableB for both columns. Also, TableA may have several matching fields so I need to group them to have only 1 entry into TableB for each match. Yes I want to insert the new records into TableB. It appears harder than expected. Something like this: select ColumnDate, ColumnA from TableA where (( ColumnDate not in (select ColumnDate from TableB) ) and ( ColumnA not in (select ColumnA from TableB) )) group by ColumnA, ColumnDate; See meta.stackoverflow.com/questions/333952/… – Strawberry Aug 6 at 6:56 Thank you Strawberry. I have searched for an answer, explained what I'm looking