Variable declarations and datatypes

Uncategorized
Question: In the following statements first three are definitions and the last one is the declaration:auto int i; static int j; register int k; extern int l; What's the reason for the same? Answer: In first three(int i, static int j, register int k) is a definition. It denotes the space for the integer to be in this translation unit and advices the linker to link all references to i against this entity. If you have more or less than exactly one of these definitions, the linker will complain. But in last extern int l, is a declaration, since it just introduces/specifies l, no new memory address/space is allocated. You can have as many extern int l in each compilation unit as you want. A declaration introduces names into a…
Read More

Possible to make text in a tag with class “btn btn-default” (Bootstrap 3.3.7) match background? [duplicate]

Uncategorized
Question: This question already has an answer here:Transparent text cut out of background 9 answers Is it possible to make the text in an a tag with the class "btn btn-default" match the background image? I am using Bootstrap 3.3.7 in Razor. Here is the code in question:Log in I want to make the button's text match the background. The button as it currently is is shown in the image provided by the following link: Log in button As you can see, the text in the button is just grey, but I want the text to match the background, exactly. Would it be possible to make the text in this button match the background in a Razor view (Bootstrap 3.3.7)? Here is an example of what I want but implemented…
Read More

Default phing log file location?

Uncategorized
Question: I am debugging a phing-based workflow and wish to see errors in detail. (An error is being sent to standard output when I run my phing-based migration script, but it is fairly minimal.) The main file that seems to be prescribing phing behaviors is called migrate.xml, and I have checked in that file for any mention of the string "log" with no results. So I assume that phing is logging to whatever location it logs to by default. So far, I have looked in /var/log and found no file containing the string "phing." So my question is this: Is there a default location for phing logs? A quick perusal of Google and the phing documentation has so far found nothing, but I'd be quite happy if it turned out…
Read More

File upload/download servlet code from reactjs

Uncategorized
Question: Am getting "isMultipart" is false while am pushing file from ajax to servlet. Could anyone help me out on this file upload/download functionality. Am writting ajax in reactjs. Ajax call request for file upload API :upload(data) { ajax({ url: 'api/UploadDocServlet', data: data, enctype: 'multipart/form-data', cache: false, processData: false, contentType: false, method:'POST', }, (data) => { console.log("Print data::::"+data); if (data.error == null) { this.search({}); } else { alert(data.error); } }); } Servlet code for file upload :boolean isMultipart = ServletFileUpload.isMultipartContent(request); // process only if it is multipart content if (isMultipart) { // Create a factory for disk-based file items FileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); try { System.out.println("UploadDocServlet:::" + upload.parseRequest(request)); List multiparts = upload.parseRequest(request); for (FileItem item : multiparts)…
Read More

Calculate percentage of a value in a column when count is given

sql
Question: I have a table with values below id name approved count 3 az 1 10 3 az 0 5 2 az 1 10 2 az 0 5 3 bz 1 10 3 bz 0 5 2 bz 1 10 2 bz 0 5 I need to calculate the % of approved =1 with my final view that shows id name Rate 3 az 66.66 3 bz 66.66 2 az 66.66 2 bz 66.66 Where rate is (10/15)*100 i.e (count of approved = 1/sum of count for that id,name combination)*100 Answer: Here is one way using conditional aggregation SELECT id, NAME, Isnull(Sum(CASE WHEN approved = 1 THEN [count] END) / Sum([count] * 1.0) * 100,0) FROM your_table GROUP BY id, NAME * 1.0 is used to avoid integer division Read…
Read More

Unity C# Passing Data Between Scenes [duplicate]

Uncategorized
Question: This question already has an answer here:Unity - pass data between scenes 3 answers I am currently working on a in-app purchase store for my game which is found on a different scene. The trouble I am having is when I click a button for example for a new skin like white skin, in that scene it will save the data that the bool of "didwhiteskin" becomes true although when I load the gamescene it wont save this data therefore not run whats inside the if statement.Thank you for yall help and I will answer any questions if needed. Additional Info: The function ChoseWhiteSkin() is called when a button clicked on StoreView. Heres my code:using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class StoreScript : MonoBehaviour { bool…
Read More

Why the concept of starting and stopping context and beans in spring

Uncategorized
Question: There are different ways in which a bean initializaiton/cleanup can be done. Also there are other event mechanisms. Along with all this why does spring have the concept of starting the context which I believe invokes the respective start and stop methods of beans. To test this, I have a piece of code that looks like this - public class Car implements InitializingBean, DisposableBean, SmartLifecycle { private Engine engine; private volatile boolean isRunning = false; @Override public void afterPropertiesSet() throws Exception { logger.debug("Car -- afterPropertiesSet"); } @Override public void destroy() throws Exception { logger.debug("Car -- destroy"); } @PostConstruct public void postConstruction() { logger.debug("Car -- postConstruct"); } @PreDestroy public void preDestruction() { logger.debug("Car -- preDestroy"); } @Override public void stop() { //Note that this stop notification is not guaranteed to…
Read More

Google App Engine NDB – Cursor on query working on local dev but not in production

Uncategorized
Question: I have an issue. I call a query with a cursor which is set to the Cursor() first time around. I fetch 50 items from the query qry = cls.query(cls.store == store_id, cls.user != exclude_user, cls.active == True, cls.offline == False).order(cls.user, cls._key, -cls.created) I return that qry to the calling class and run the following fetch result, next_cursor, more = qry.fetch_page(pagination, start_cursor=cursor) This works no problem, I then do the following with the cursor and pass it back to the client as per the docs:client_params['next_page'] = next_cursor.urlsafe() I have logged this cursor to make sure it is the same on the return call to the server, which it is I get it thus:cursor = Cursor(urlsafe=page) However the second attempt to retrieve the next 50 or less items always results…
Read More