Questions Tagged with #Try catch

try-catch is a syntactic construct for catching exceptions raised by a code section

Why catch and rethrow an exception in C#?

I'm looking at the article C# - Data Transfer Object on serializable DTOs. The article includes this piece of code: public static string SerializeDTO(DTO dto) { try { XmlSerializer xmlSe..

How to catch and print the full exception traceback without halting/exiting the program?

I want to catch and log exceptions without exiting, e.g., try: do_stuff() except Exception, err: print(Exception, err) # I want to print the entire traceback here, # not just the excep..

How to capture no file for fs.readFileSync()?

Within node.js readFile() shows how to capture an error, however there is no comment for the readFileSync() function regarding error handling. As such, if I try to use readFileSync() when there is no ..

powershell 2.0 try catch how to access the exception

This is the try catch in PowerShell 2.0 $urls = "http://www.google.com", "http://none.greenjump.nl", "http://www.nu.nl" $wc = New-Object System.Net.WebClient foreach($url in $urls) { try { ..

Catch KeyError in Python

If I run the code: connection = manager.connect("I2Cx") The program crashes and reports a KeyError because I2Cx doesn't exist (it should be I2C). But if I do: try: connection = manager.connec..

Convert String to Double - VB

Is there an efficient method in VB to check if a string can be converted to a double? I'm currently doing this by trying to convert the string to a double and then seeing if it throws an exception. B..

Can I try/catch a warning?

I need to catch some warnings being thrown from some php native functions and then handle them. Specifically: array dns_get_record ( string $hostname [, int $type= DNS_ANY [, array &$authns ..

Error handling with try and catch in Laravel

I want to implement a good error handling in my app, I have forced this file for catching the error. App\Services\PayUService try { $this->buildXMLHeader; // Should be $this->buildXMLHeader(..

C# try catch continue execution

I have a question that might seem fairly simple (of course if you know the answer). A certain function I have calls another function but I want to continue execution from the caller even though the c..

sql try/catch rollback/commit - preventing erroneous commit after rollback

I am trying to write an MS sql script that has a transaction and a try/catch block. If it catches an exception, the transaction is rolled back. If not, the transaction is committed. I have seen a f..

Try-catch speeding up my code?

I wrote some code for testing the impact of try-catch, but seeing some surprising results. static void Main(string[] args) { Thread.CurrentThread.Priority = ThreadPriority.Highest; Process.Ge..

C# catch a stack overflow exception

I have a recursive call to a method that throws a stack overflow exception. The first call is surrounded by a try catch block but the exception is not caught. Does the stack overflow exception behav..

Try-catch block in Jenkins pipeline script

I'm trying to use the following code to execute builds, and in the end, execute post build actions when builds were successful. Still, I get a MultipleCompilationErrorsException, saying that my try bl..

Is it possible in Java to catch two exceptions in the same catch block?

I need to catch two exceptions because they require the same handling logic. I would like to do something like: catch (Exception e, ExtendsRuntimeException re) { // common logic to handle both ex..

Why is "except: pass" a bad programming practice?

I often see comments on other Stack Overflow questions about how the use of except: pass is discouraged. Why is this bad? Sometimes I just don't care what the errors are and I want to just continue wi..

How to add a Try/Catch to SQL Stored Procedure

CREATE PROCEDURE [dbo].[PL_GEN_PROVN_NO1] @GAD_COMP_CODE VARCHAR(2) =NULL, @@voucher_no numeric =null output AS BEGIN DECLARE @NUM NUMERIC DECLARE @PNO NUMERIC ..

How to catch integer(0)?

Let's say we have a statement that produces integer(0), e.g. a <- which(1:3 == 5) What is the safest way of catching this?..

Throwing exceptions in a PHP Try Catch block

I have a PHP function in a Drupal 6 .module file. I am attempting to run initial variable validations prior to executing more intensive tasks (such as database queries). In C#, I used to implement IF..

Java Try and Catch IOException Problem

I am trying to use a bit of code I found at the bottom of this page. Here is the code in a class that I created for it: import java.io.LineNumberReader; import java.io.FileReader; import java.io.IOE..

PowerShell try/catch/finally

I recently wrote a PowerShell script that works great - however, I'd like to now upgrade the script and add some error checking / handling - but I've been stumped at the first hurdle it seems. Why won..

Why are empty catch blocks a bad idea?

I've just seen a question on try-catch, which people (including Jon Skeet) say empty catch blocks are a really bad idea? Why this? Is there no situation where an empty catch is not a wrong design deci..

How do you implement a re-try-catch?

Try-catch is meant to help in the exception handling. This means somehow that it will help our system to be more robust: try to recover from an unexpected event. We suspect something might happen wh..

EOFException - how to handle?

I'm a beginner java programmer following the java tutorials. I am using a simple Java Program from the Java tutorials's Data Streams Page, and at runtime, it keeps on showing EOFException. I was wond..

How to write trycatch in R

I want to write trycatch code to deal with error in downloading from the web. url <- c( "http://stat.ethz.ch/R-manual/R-devel/library/base/html/connections.html", "http://en.wikipedia.org/..

Java Try Catch Finally blocks without Catch

I'm reviewing some new code. The program has a try and a finally block only. Since the catch block is excluded, how does the try block work if it encounters an exception or anything throwable? Does..

Should try...catch go inside or outside a loop?

I have a loop that looks something like this: for (int i = 0; i < max; i++) { String myString = ...; float myNum = Float.parseFloat(myString); myFloats[i] = myNum; } This is the main..

How to catch segmentation fault in Linux?

I need to catch segmentation fault in third party library cleanup operations. This happens sometimes just before my program exits, and I cannot fix the real reason of this. In Windows programming I co..

How to efficiently use try...catch blocks in PHP

I have been using try..catch blocks in my PHP code, but I'm not sure if I've been using them correctly. For example, some of my code looks like: try { $tableAresults = $dbHandler->doSometh..

Raise an error manually in T-SQL to jump to BEGIN CATCH block

Is it possible to raise an error in a stored procedure manually to stop execution and jump to BEGIN CATCH block? Some analog of throw new Exception() in C#. Here is my stored procedure's body: BEGIN..

Capture keyboardinterrupt in Python without try-except

Is there some way in Python to capture KeyboardInterrupt event without putting all the code inside a try-except statement? I want to cleanly exit without trace if user presses Ctrl+C...

Try-Catch-End Try in VBScript doesn't seem to work

I'm trying the following code: Try ' DOESN'T WORK Throw 2 ' How do I throw an exception? Catch ex 'What do I do here? End Try but I'm getting the error Statement expected in the catch claus..

How to return a value from try, catch, and finally?

So when I do a code of blocks inside a try{}, and I try to return a value, it tells me no return values import org.w3c.dom.ranges.RangeException; public class Pg257E5 { public static void ma..

Is it a good practice to use try-except-else in Python?

From time to time in Python, I see the block: try: try_this(whatever) except SomeException as exception: #Handle exception else: return something What is the reason for the try-except-else..

Try-catch-finally-return clarification

By reading all the questions already asked in this forum related to the topic above (see title), I thoroughly understand that finally gets always called. (except from System.exit and infinite loops). ..

Multiple try codes in one block

I have a problem with my code in the try block. To make it easy this is my code: try: code a code b #if b fails, it should ignore, and go to c. code c #if c fails, go to d code d exce..

IsNumeric function in c#

I know it's possible to check whether the value of a text box or variable is numeric using try/catch statements, but IsNumeric is so much simpler. One of my current projects requires recovering value..

Can I catch multiple Java exceptions in the same catch clause?

In Java, I want to do something like this: try { ... } catch (/* code to catch IllegalArgumentException, SecurityException, IllegalAccessException, and NoSuchFieldException at t..

How using try catch for exception handling is best practice

while maintaining my colleague's code from even someone who claims to be a senior developer, I often see the following code: try { //do something } catch { //Do nothing } or sometimes they write ..

How to get the day of week and the month of the year?

I don't know much about Javascript, and the other questions I found are related to operations on dates, not only getting the information as I need it. Objective I wish to get the date as below-forma..

How can I generate Unix timestamps?

Related question is "Datetime To Unix timestamp", but this question is more general. I need Unix timestamps to solve my last question. My interests are Python, Ruby and Haskell, but other approaches..

What is the difference between C and embedded C?

Can any body tell me the differences between them?..

How can I handle the warning of file_get_contents() function in PHP?

I wrote a PHP code like this $site="http://www.google.com"; $content = file_get_content($site); echo $content; But when I remove "http://" from $site I get the following warning: Warning: fil..

Repeat rows of a data.frame

I want to repeat the rows of a data.frame, each N times. The result should be a new data.frame (with nrow(new.df) == nrow(old.df) * N) keeping the data types of the columns. Example for N = 2: ..

how to run mysql in ubuntu through terminal

trying to run mysql in ubuntu typing mysql in terminal and getting error ERROR 1045(28000): Access denied for user 'root'@'localhost' (using password: NO) Can anybody please sort out this problem....

How to debug a GLSL shader?

I need to debug a GLSL program but I don't know how to output intermediate result. Is it possible to make some debug traces (like with printf) with GLSL ?..

What is Domain Driven Design?

Can somebody please explain (in succinct terms) what exactly is domain driven design? I see the term quite a lot but really don't understand what it is or what it looks like. How does it differ from n..

How to know the version of pip itself

Which shell command gives me the actual version of pip I am using? pip gives with pip show all version of modules that are installed but excludes itself...

Java: Clear the console

Can any body please tell me what code is used for clear screen in Java? For example in C++ system("CLS"); What code is used in Java for clear screen? Thanks!..

Why do we check up to the square root of a prime number to determine if it is prime?

To test whether a number is prime or not, why do we have to test whether it is divisible only up to the square root of that number?..

How do I give text or an image a transparent background using CSS?

Is it possible, using CSS only, to make the background of an element semi-transparent but have the content (text & images) of the element opaque? I'd like to accomplish this without having the te..

What is the default username and password in Tomcat?

I installed Netbeans and tryed to access the server's manager using: (id/pass)manager/manager, admin/admin, system/password... None of them worked. ..

Delete file from internal storage

I'm trying to delete images stored in internal storage. I've come up with this so far: File dir = getFilesDir(); File file = new File(dir, id+".jpg"); boolean deleted = file.delete(); And this is f..

Display fullscreen mode on Tkinter

How can I make a frame in Tkinter display in fullscreen mode? I saw this code, and it's very useful…: >>> import Tkinter >>> root = Tkinter.Tk() >>> root.overrideredirect..

How do I get the web page contents from a WebView?

On Android, I have a WebView that is displaying a page. How do I get the page source without requesting the page again? It seems WebView should have some kind of getPageSource() method that returns ..

Iframe positioning

This is iframe code of google translate. <div id="contentframe" style="top: 160px; left: 0px;"> <iframe src="/translate_p?hl=en&amp;ie=UTF8&amp;prev=_t&amp;sl=auto&amp;tl=en&..

No newline after div?

Is there a way to not have a newline inserted before a div without using float: left on the previous element? Maybe some tag on the div that will just put it to the right?..

What is the best way to search the Long datatype within an Oracle database?

I am working with an Oracle database that stores HTML as a Long datatype. I would like to query the database to search for a specific string within the HTML data stored in the Long. I tried, "sele..

How To Format A Block of Code Within a Presentation?

I am preparing a presentation using Google Slides, though I can also work on the presentation within Open Office that will include code snippets. Is there any easy way to perform basic syntax highli..

Set a variable if undefined in JavaScript

I know that I can test for a JavaScript variable and then define it if it is undefined, but is there not some way of saying var setVariable = localStorage.getItem('value') || 0; seems like a much cle..

Dynamically add script tag with src that may include document.write

I want to dynamically include a script tag in a webpage however I have no control of it's src so src="source.js" may look like this. document.write('<script type="text/javascript">') document.w..

How to change context root of a dynamic web project in Eclipse?

I developed a dynamic web project in Eclipse. I can access the app through my browser using the following URL: http://localhost:8080/MyDynamicWebApp I want to change the access URL to: http://lo..

c# regex matches example

I am trying to get values from the following text. How can this be done with Regex? Input Lorem ipsum dolor sit %download%#456 amet, consectetur adipiscing %download%#3434 elit. Duis non nunc nec..

How to read XML response from a URL in java?

I need to write a simple function that takes a URL and processes the response which is XML or JSON, I have checked the Sun website https://swingx-ws.dev.java.net/servlets/ProjectDocumentList , but the..

Android Studio suddenly cannot resolve symbols

Android Studio 0.4.2 was working fine and today I opened it and almost everything was red and the auto-completion had stopped working. I look at the imports and AS seems to be telling me it can't find..

Referencing another schema in Mongoose

if I have two schemas like: var userSchema = new Schema({ twittername: String, twitterID: Number, displayName: String, profilePic: String, }); var User = mongoose.model('User') v..

How can I exclude a directory from Visual Studio Code "Explore" tab?

I'm trying to exclude several folders on the "Explore" tab in Visual Studio Code. To do that I have added a following jsconfig.json to the root of my project: { "compilerOptions": { "targ..

Getting a UnhandledPromiseRejectionWarning when testing using mocha/chai

So, I'm testing a component that relies on an event-emitter. To do so I came up with a solution using Promises with Mocha+Chai: it('should transition with the correct event', (done) => { const cF..

How to use multiple conditions (With AND) in IIF expressions in ssrs

I just want to hide rows in SSRS report having Zero Quantity.. There are following multiple Quantity Columns like Opening Stock , Gross Dispatched,Transfer Out, Qty Sold, Stock Adjustment and Closing ..

Multi-gradient shapes

I'd like to create a shape that's like the following image: Notice the top half gradients from color 1 to color 2, but theres a bottom half that gradients from color 3 to color 4. I know how to ma..

Why do I need an IoC container as opposed to straightforward DI code?

I've been using Dependency Injection (DI) for a while, injecting either in a constructor, property, or method. I've never felt a need to use an Inversion of Control (IoC) container. However, the mor..

Unable to open a file with fopen()

I've been trying to open a file and output text, but I keep getting errors. So I thought I would start at the very beginning and just try opening the file. This is my code: #include <stdio.h>..

Jquery: how to sleep or delay?

i want move up the object, delay 1000ms , then hide it, i get the code: $("#test").animate({"top":"-=80px"},1500) .animate({"top":"-=0px"},1000) .animate({"opacity":"0"},500); i use "...

How to generate .env file for laravel?

From the documentation I see it's possible to create a laravel project via laravel installer: $laravel new blog or via composer: $composer create-project laravel/laravel --prefer-dist If I try t..

How to install pip in CentOS 7?

CentOS 7 EPEL now includes Python 3.4: yum install python34 However, when I try that, even though Python 3.4 installs successfully, it doesn't appear to install pip. Which is weird, because pip shoul..

Can a constructor in Java be private?

Can a constructor be private? How is a private constructor useful?..

how do I get eclipse to use a different compiler version for Java?

It seems like this should be a simple task, with the options in the Preferences menu for different JREs and the ability to set different compiler and build paths per project. However, it also seems to..

Blade if(isset) is not working Laravel

Hi I am trying to check the variable is already set or not using blade version. But the raw php is working but the blade version is not. Any help? controller: public function viewRegistrationForm() ..

Install numpy on python3.3 - Install pip for python3

For python 3.2 I used sudo apt-get install python3.2-numpy.It worked. What to do for python3.3? Nothing I could think of works. Same goes for scipy, etc. Thanks. Edit: this is how it looks like radu..

@RequestBody and @ResponseBody annotations in Spring

Can someone explain the @RequestBody and @ResponseBody annotations in Spring 3? What are they for? Any examples would be great...

If Python is interpreted, what are .pyc files?

I've been given to understand that Python is an interpreted language... However, when I look at my Python source code I see .pyc files, which Windows identifies as "Compiled Python Files". Where ..

Remove empty array elements

Some elements in my array are empty strings based on what the user has submitted. I need to remove those elements. I have this: foreach($linksArray as $link) { if($link == '') { unset..

How to create an Excel File with Nodejs?

I am a nodejs programmer . Now I have a table of data that I want to save in Excel File format . How do I go about doing this ? I found a few Node libraries . But most of them are Excel Parsers rath..

C: What is the difference between ++i and i++?

In C, what is the difference between using ++i and i++, and which should be used in the incrementation block of a for loop?..

Pandas groupby month and year

I have the following dataframe: Date abc xyz 01-Jun-13 100 200 03-Jun-13 -20 50 15-Aug-13 40 -5 20-Jan-14 25 15 21-Feb-14 60 80 I need to group the data by yea..

jQuery toggle animation

I have this jQuery: $(document).ready(function() { $("#panel").hide(); $('.login').toggle( function() { $('#panel').animate({ height: "150", padding:"20px 0", ba..

How to add a color overlay to a background image?

I have seen this question a lot both on SO and the Web. But none of them has been what I am looking for. How do I add a color-overlay to a background image using CSS only? Example HTML: <div cla..

How to use HTTP.GET in AngularJS correctly? In specific, for an external API call?

I have the following code in the controller.js, var myApp = angular.module('myApp',[]); myApp.service('dataService', function($http) { delete $http.defaults.headers.common['X-Requested-With']; this..

How to Increase browser zoom level on page load?

How to increase browser zoom level on page load? here is my web link recently i got the task to increase its width just like if Firefox we press Ctrl + and browser zoom level is increases is there an..

How do you display a Toast from a background thread on Android?

How can I display Toast messages from a thread? ..

Boxplot show the value of mean

In this boxplot we can see the mean but how can we have also the number value on the plot for every mean of every box plot? ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplo..

JQuery .hasClass for multiple values in an if statement

I have a simple if statement as such: if ($('html').hasClass('m320')) { // do stuff } This works as expected. However, I want to add more classes to the if statement to check if any of the class..

Bootstrap 3 - Set Container Width to 940px Maximum for Desktops?

I am adding a whole new section to a website using Twitter Bootstrap 3, however the container cannot go wider than 940px in total for Desktop - as it will throw out the Header and Footer {includes}. ..

How do I run .sh or .bat files from Terminal?

I have a pretty basic problem here, that has happened so haphazardly to me that up until now, I've just ignored it. I downloaded tomcat web server and "Murach's Java Servlets and JSP" book is telling ..

ResourceDictionary in a separate assembly

I have resource dictionary files (MenuTemplate.xaml, ButtonTemplate.xaml, etc) that I want to use in multiple separate applications. I could add them to the applications' assemblies, but it's better i..

Razor Views not seeing System.Web.Mvc.HtmlHelper

I am in the process of upgrading to MVC4. I have followed the instructions at http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806 but in my Razor views and layouts I have errors like 'S..

Genymotion, "Unable to load VirtualBox engine." on Mavericks. VBox is setup correctly

I keep getting the following error: I have reinstalled, deleted and tried about EVERYTHING to get Genymotion to work again. I do not have the device I need, but Genymotion was PERFECT for the job,..

Subquery returned more than 1 value.This is not permitted when the subquery follows =,!=,<,<=,>,>= or when the subquery is used as an expression

I have a stored procedure that select * from book table , using sub query my query is USE [library] GO /****** Object: StoredProcedure [dbo].[report_r_and_l] Script Date: 04/17/2013 12:42:39 **..

Hadoop MapReduce: Strange Result when Storing Previous Value in Memory in a Reduce Class (Java)

If I wish to store the current value of an iterator to compare to the next value of the iterator in a Reduce method, Hadoop requires that I clone it instead of simply assigning its reference to a temp..

Get JSF managed bean by name in any Servlet related class

I'm trying to write a custom servlet (for AJAX/JSON) in which I would like to reference my @ManagedBeans by name. I'm hoping to map: http://host/app/myBean/myProperty to: @ManagedBean(name="myBean..

What's the difference between window.location= and window.location.replace()?

Is there a difference between these two lines? var url = "http://www.google.com/"; window.location = url; window.location.replace(url); ..

Docker can't connect to docker daemon

After I update my Docker version to 0.8.0, I get an error message while entering sudo docker version: Client version: 0.8.0 Go version (client): go1.2 Git commit (client): cc3a8c8 2014/02/19 12:54:16..

Laravel 5 Application Key

I am new to Laravel. I just started it tonight. Actually, I have the following code: 'key' => env('APP_KEY', 'SomeRandomString'), In xampp/htdocs/laravel/blog/config/app.php. I want to change t..

How to change dot size in gnuplot

How to change point size and shape and color in gnuplot. plot "./points.dat" using 1:2 title with dots I am using above command to plot graph ,but it shows very small size points. I tried to use c..

nodemon not working: -bash: nodemon: command not found

I'm on a Mac running El Capitan. I have node v5.6.0 and npm v3.6.0. When I try to run nodemon, I get: -bash: nodemon: command not found I thought this may mean that I didn't have nodemon installe..

Finding rows containing a value (or values) in any column

Say we have a table 'data' containing Strings in several columns. We want to find the indices of all rows that contain a certain value, or better yet, one of several values. The column, however, is un..

View's SELECT contains a subquery in the FROM clause

I have two tables and I need to create a view. The tables are: credit_orders(id, client_id, number_of_credits, payment_status) credit_usage(id, client_id, credits_used, date) I use the following qu..

Difference between window.location.href and top.location.href

Can Anyone tell me the difference between window.location.href and top.location.href ? And also where to use which one. And which one will be better when redirecting after an ajax call in mvc?..

Image resolution for new iPhone 6 and 6+, @3x support added?

I have looked on few articles and discussion like one here and Here about image resolutions that new iPhones will use @3x images for display. Is it true? So does it mean we will have to keep three i..

django order_by query set, ascending and descending

How can I order by descending my query set in django by date? Reserved.objects.all().filter(client=client_id).order_by('check_in') I just want to filter from descending all the Reserved by check_in..

How to read a single char from the console in Java (as the user types it)?

Is there an easy way to read a single char from the console as the user is typing it in Java? Is it possible? I've tried with these methods but they all wait for the user to press enter key: char tmp..

How to do a newline in output

How do I make \n actually work in my output? At the moment it just writes it all in 1 long block. Thanks for any help Dir.chdir 'C:/Users/name/Music' music = Dir['C:/Users/name/Music/*.{mp3, MP3}'] p..

PHP AES encrypt / decrypt

I found an example for en/decoding strings in PHP. At first it looks very good but it wont work :-( Does anyone know what the problem is? $Pass = "Passwort"; $Clear = "Klartext"; $crypted = fnEncry..

__init__() got an unexpected keyword argument 'user'

i am using Django to create a user and an object when the user is created. But there is an error __init__() got an unexpected keyword argument 'user' when calling the register() function in view.py...

How do you set the max number of characters for an EditText in Android?

How do you set the max number of characters for an Android EditText input? I see setMaxLines, setMaxEMS, but nothing for the number of characters...

How to make child element higher z-index than parent?

Suppose I have this code: <div class="parent"> <div class="child"> Hello world </div> </div> <div class="wholePage"></div> This jsFiddle: http:/..

How to write one new line in Bitbucket markdown?

Is it possible to write a new line (NOT a paragraph) in the Bitbucket markdown? Two new lines in the source creates one new paragraph. I only want a new line. And I don't want to use a code block...

How can I SELECT rows with MAX(Column value), DISTINCT by another column in SQL?

My table is: id home datetime player resource ---|-----|------------|--------|--------- 1 | 10 | 04/03/2009 | john | 399 2 | 11 | 04/03/2009 | juliet | 244 5 | 12 | 04/03/2009 | bor..

What is the difference between Eclipse for Java (EE) Developers and Eclipse Classic?

What is the difference between Eclipse for Java (EE) Developers and Eclipse Classic? Both are marked as version 3.6. Which one should I use?..

How many files can I put in a directory?

Does it matter how many files I keep in a single directory? If so, how many files in a directory is too many, and what are the impacts of having too many files? (This is on a Linux server.) Backgroun..

How to read keyboard-input?

I would like to read data from the keyboard in python I try this: nb = input('Choose a number') print ('Number%s \n' % (nb)) But it doesn't work, neither with eclipse nor in the terminal, it's alw..

What are rvalues, lvalues, xvalues, glvalues, and prvalues?

In C++03, an expression is either an rvalue or an lvalue. In C++11, an expression can be an: rvalue lvalue xvalue glvalue prvalue Two categories have become five categories. What are these..

How can I create and style a div using JavaScript?

How can I use JavaScript to create and style (and append to the page) a div, with content? I know it's possible, but how?..

GIT_DISCOVERY_ACROSS_FILESYSTEM not set

I have searched and read few post but my problem is not the same as described. So here's the issue: using git clone into folder under external partition of the disk works fine but all git commands fai..

Transform only one axis to log10 scale with ggplot2

I have the following problem: I would like to visualize a discrete and a continuous variable on a boxplot in which the latter has a few extreme high values. This makes the boxplot meaningless (the poi..

Getting "cannot find Symbol" in Java project in Intellij

I make this call to a static singleton instance from the class GameManager.java. HUD.getInstance().update(timeDelta); HUD.java contains the HUD class as well as two other related classes, HUDTextEl..

Best practices for styling HTML emails

I'm designing an HTML template for an email newsletter. I've learned that many email clients ignore linked stylesheets, and many others (including Gmail) ignore CSS block declarations altogether. Are ..

How to get time in milliseconds since the unix epoch in Javascript?

Possible Duplicate: How do you get a timestamp in JavaScript? Calculating milliseconds from epoch How can I get the current epoch time in Javascript? Basically the number of milliseconds..

Android "Only the original thread that created a view hierarchy can touch its views."

I've built a simple music player in Android. The view for each song contains a SeekBar, implemented like this: public class Song extends Activity implements OnClickListener,Runnable { private Se..

Adding background image to div using CSS

I have been trying to add background image to a div class using CSS, but I didn't have any success. HTML code: <header id="masthead" class="site-header" role="banner"&..

HTML5 Number Input - Always show 2 decimal places

Is there's any way to format an input[type='number'] value to always show 2 decimal places? Example: I want to see 0.00 instead of 0...

How to divide flask app into multiple py files?

My flask application currently consists of a single test.py file with multiple routes and the main() route defined. Is there some way I could create a test2.py file that contains routes that were not ..

composer laravel create project

I'm trying to use laravel, when I start a project and type composer create-project /Applications/MAMP/htdocs/test_laravel in terminal it shows [InvalidArgumentException] ..

3-dimensional array in numpy

New at Python and Numpy, trying to create 3-dimensional arrays. My problem is that the order of the dimensions are off compared to Matlab. In fact the order doesn't make sense at all. Creating a matr..

how to find my angular version in my project?

I have setup the angular code on my local machine. I need to know the version of the angular that I am using in the project. how can I easily find it in cmd prompt?..

How to set a Fragment tag by code?

I haven't found something like setTag(String tagName) method in the Fragment class. The only way to set a Fragment tag that I have found is by doing a FragmentTransaction and passing a tag name as par..

Remove leading and trailing spaces?

I'm having a hard time trying to use .strip with the following line of code. Thanks for the help. f.write(re.split("Tech ID:|Name:|Account #:",line)[-1]) ..

Get css top value as number not as string?

In jQuery you can get the top position relative to the parent as a number, but you can not get the css top value as a number if it was set in px. Say I have the following: #elem{ position:relative..

How to get rid of underline for Link component of React Router?

I have the following: How do I get rid of the blue underline? The code is below: <Link to="first"><MenuItem style={{paddingLeft: 13, textDecoration: 'none'}}> Team 1 </MenuItem&g..

Where should I put <script> tags in HTML markup?

When embedding JavaScript in an HTML document, where is the proper place to put the <script> tags and included JavaScript? I seem to recall that you are not supposed to place these in the <he..

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

I've a form which I'm submitting (through GET as it is required this way) to a crm (ViciDial). I can successfully submit the form however if I do that the processing file at crm will just echo a succe..

Converting two lists into a matrix

I'll try to be as clear as possible, and I'll start by explaining why I want to transform two arrays into a matrix. To plot the performance of a portfolio vs an market index I need a data structure l..

basic authorization command for curl

How do I set up the basic authorization using 64 encoded credentials ? I tried below the two commands but of no use , please suggest. curl -i -H 'Accept:application/json' Authorization:Basic <use..

How do I format a date in Jinja2?

Using Jinja2, how do I format a date field? I know in Python I can simply do this: print(car.date_of_manufacture.strftime('%Y-%m-%d')) But how do I format the date in Jinja2?..

Getting current device language in iOS?

I'd like to show the current language that the device UI is using. What code would I use? I want this as an NSString in fully spelled out format. (Not @"en_US") EDIT: For those driving on by, there..

Java random numbers using a seed

This is my code to generate random numbers using a seed as an argument: double randomGenerator(long seed) { Random generator = new Random(seed); double num = generator.nextDouble() * (0.5); ..

How do I change the background color of the ActionBar of an ActionBarActivity using XML?

Details: I'm extending ActionBarActivity. Eclipse and SDK fully patched as of 2011-11-06. <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14" /> Deployed to Samsung device ..

How to remove focus from single editText

In my application I have a single EditText together with some TextViews, button and a spinner. My EditText receives focus since it is the only focusable view in this activity, I believe. My EditText s..

Set value of textbox using JQuery

My Jade template - input#main_search.span2( style = 'height: 26px; width: 800px;' , type = 'text', readonly='true', name='searchBar', value='test' ) JS file - $('#searchBar')..

Chrome javascript debugger breakpoints don't do anything?

I can't seem to figure out the Chrome debugging tool. I have chrome version 21.0.1180.60 m. Steps I took: I pressed ctrl-shift-i to bring up the console. Clicked on Sources then select the relevan..

How to get numbers after decimal point?

How do I get the numbers after a decimal point? For example, if I have 5.55, how do i get .55?..

What are the main differences between JWT and OAuth authentication?

I have a new SPA with a stateless authentication model using JWT. I am often asked to refer OAuth for authentication flows like asking me to send 'Bearer tokens' for every request instead of a simple ..

Python Dictionary Comprehension

Is it possible to create a dictionary comprehension in Python (for the keys)? Without list comprehensions, you can use something like this: l = [] for n in range(1, 11): l.append(n) We can sho..

apache mod_rewrite is not working or not enabled

I have installed rewrite_module and modified php.ini on Apache. I create rewrite.php and .htaccess files, but it's not working. My filesystem folders like: /var/www/html /var/www/html/test /var/www..

Why am I getting this redefinition of class error?

Apologies for the code dump: gameObject.cpp: #include "gameObject.h" class gameObject { private: int x; int y; public: gameObject() { x = 0; y = 0; } gameObj..

Sending Multipart File as POST parameters with RestTemplate requests

I am working with Spring 3 and RestTemplate. I have basically, two applications and one of them have to post values to the other app. through rest template. When the values to post are Strings, it's..

Basic Ajax send/receive with node.js

So I'm trying to make a very basic node.js server that with take in a request for a string, randomly select one from an array and return the selected string. Unfortunately I'm running into a few prob..

Override element.style using CSS

I have an HTML page from page builder, and it injects style attribute directly to the element. I found it's considered as element.style. I want to override it using CSS. I can match the element, but ..

CGContextDrawImage draws image upside down when passed UIImage.CGImage

Does anyone know why CGContextDrawImage would be drawing my image upside down? I am loading an image in from my application: UIImage *image = [UIImage imageNamed:@"testImage.png"]; And then simply ..

How to set Highcharts chart maximum yAxis value

I've been trying for two days to find a way to set the maximum value of the yAxis on Highcharts. I got a percentage column graphic, but the highest value in the series is 60, so it adjusts the axis t..

Center a popup window on screen?

How can we center a popup window opened via javascript window.open function on the center of screen variable to the currently selected screen resolution ?..

Select Row number in postgres

How to select row number in postgres. I tried this: select row_number() over (ORDER BY cgcode_odc_mapping_id)as rownum, cgcode_odc_mapping_id from access_odc.access_odc_mapping_tb order by..

How to set text color to a text view programmatically

How can I set Text Color of a text view to #bdbdbd programatically?..

Android fade in and fade out with ImageView

I'm having some troubles with a slideshow I'm building. I've created 2 animations in xml for fade in and fade out: fadein.xml <?xml version="1.0" encoding="UTF-8"?> <set xmlns:a..

How can I change the current URL?

I have the following code that changes the pages from within JavaScript: var newUrl = [some code to build up URL string]; window.location.replace(newUrl); But it doesn't change the top URL, so when..

What is SaaS, PaaS and IaaS? With examples

What do the following terms mean? SaaS PaaS IaaS? There are various cloud services available today, such as Amazon's EC2 and AWS, Apache Hadoop, Microsoft Azure and many others. Which category do..

How do I get a TextBox to only accept numeric input in WPF?

I'm looking to accept digits and the decimal point, but no sign. I've looked at samples using the NumericUpDown control for Windows Forms, and this sample of a NumericUpDown custom control from Micro..

What is lazy loading in Hibernate?

What is lazy loading in Java? I don't understand the process. Can anybody help me to understand the process of lazy loading?..

error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’

Wrong form: int &z = 12; Correct form: int y; int &r = y; Question: Why is the first code wrong? What is the "meaning" of the error in the title?..

Avoid synchronized(this) in Java?

Whenever a question pops up on SO about Java synchronization, some people are very eager to point out that synchronized(this) should be avoided. Instead, they claim, a lock on a private reference is t..

Spring Data JPA find by embedded object property

I want to write a Spring Data JPA repository interface method signature that will let me find entities with a property of an embedded object in that entity. Does anyone know if this is possible, and i..

Add a Progress Bar in WebView

I am trying to add a progress/loading bar to my application that uses WebView. I am confused on how to implement a progress bar that appears every time a link is clicked. Current code: public class ..

Reading HTML content from a UIWebView

Is it possible to read the raw HTML content of a web page that has been loaded into a UIWebView? If not, is there another way to pull raw HTML content from a web page in the iPhone SDK (such as an eq..

How to remove application from app listings on Android Developer Console

Is there any way to unpublish and then permanently remove an application from the list of applications on Android Developer Console?..

Get the last inserted row ID (with SQL statement)

I want to get the new created ID when you insert a new record in table. I read this: http://msdn.microsoft.com/en-us/library/ms177564.aspx but it needs to create temporary table. I want to return th..

How to calculate DATE Difference in PostgreSQL?

Here I need to calculate the difference of the two dates in the PostgreSQL. In SQL Server: Like we do in SQL Server its much easier. DATEDIFF(Day, MIN(joindate), MAX(joindate)) AS DateDifference;..

Java String - See if a string contains only numbers and not letters

I have a string that I load throughout my application, and it changes from numbers to letters and such. I have a simple if statement to see if it contains letters or numbers but, something isn't quite..

Nested Recycler view height doesn't wrap its content

I have an application that manage collections of books (like playlists). I want to display a list of collection with a vertical RecyclerView and inside each row, a list of book in an horizontal Recyc..

How to check if spark dataframe is empty?

Right now, I have to use df.count > 0 to check if the DataFrame is empty or not. But it is kind of inefficient. Is there any better way to do that? Thanks. PS: I want to check if it's empty so th..

Initializing a two dimensional std::vector

So, I have the following: std::vector< std::vector <int> > fog; and I am initializing it very naively like: for(int i=0; i<A_NUMBER; i++) { std::vector <int&g..

Use of exit() function

I want to know how and when can I use the exit() function like the program in my book: #include<stdio.h> void main() { int goals; printf("enter number of goals scored"); scanf("%d"..

How do MySQL indexes work?

I am really interested in how MySQL indexes work, more specifically, how can they return the data requested without scanning the entire table? It's off-topic, I know, but if there is someone who coul..

Maximum and minimum values in a textbox

I have a textbox. Is there a way where the highest value the user can enter is 100 and the lowest is 0? So if the user types in a number more than 100 then it will automatically change the value to 1..

Generate a random double in a range

I have two doubles like the following double min = 100; double max = 101; and with a random generator, I need to create a double value between the range of min and max. Random r = new Random(); r...

Command Line Tools not working - OS X El Capitan, Sierra, High Sierra, Mojave

I just upgraded from Yosemite to El Capitan (and replicated the problem upgrading from El Capitan to Sierra), and when I try to type for example git status inside a terminal, I get the following error..

403 Forbidden vs 401 Unauthorized HTTP responses

For a web page that exists, but for which a user does not have sufficient privileges (they are not logged in or do not belong to the proper user group), what is the proper HTTP response to serve? 401..

Android - Set text to TextView

I'm currently learning some android for a school project and I can't figure out the way to set text dynamically to a TextView. Here is my code: protected void onCreate(Bundle savedInstanceState) { ..

Java using enum with switch statement

I've looked at various Q&As on SO similar to this question but haven't found a solution. What I have is an enum which represents different ways to view a TV Guide... In the NDroid Application cl..

SQL Transaction Error: The current transaction cannot be committed and cannot support operations that write to the log file

I'm having a similar issue to The current transaction cannot be committed and cannot support operations that write to the log file, but I have a follow-up question. The answer there references Using ..

How to create a user in Oracle 11g and grant permissions

Can someone advise me on how to create a user in Oracle 11g and only grant that user the ability only to execute one particular stored procedure and the tables in that procedure. I am not really sure..

How to get selected option using Selenium WebDriver with Java

I want to get the selected label or value of a drop down using Selenium WebDriver and then print it on the console. I am able to select any value from the drop down, but I am not able to retrieve the..

Code for printf function in C

Possible Duplicate: source code of c/c++ functions I was wondering where I can find the C code that's used so that when I write printf("Hello World!"); in my C programm to know that it has ..

Looping Over Result Sets in MySQL

I am trying to write a stored procedure in MySQL which will perform a somewhat simple select query, and then loop over the results in order to decide whether to perform additional queries, data transf..

Entity Framework code-first: migration fails with update-database, forces unneccessary(?) add-migration

I have a funny effect using migration (EF 5.0) and code-first: I created some models with GUID primary keys. (BTW: It is important for me, that SQL Server uses NEWSEQUENTIALID(), which seems to be th..

android button selector

This is a button selector such that when normal it appears red, when pressed it appears grey. I would like to ask how could the code be further directly modified such that when PRESSED the text size ..

TypeScript function overloading

Section 6.3 of the TypeScript language spec talks about function overloading and gives concrete examples on how to implement this. However if I try something like this: export class LayerFactory { ..

Changing button color programmatically

Is there a way to change the color of a button, or at least the color of the button label programmatically? I can change the label itself with document.getElementById("button").object.textElement.in..

Why does range(start, end) not include end?

>>> range(1,11) gives you [1,2,3,4,5,6,7,8,9,10] Why not 1-11? Did they just decide to do it like that at random or does it have some value I am not seeing?..

How can I fill a column with random numbers in SQL? I get the same value in every row

UPDATE CattleProds SET SheepTherapy=(ROUND((RAND()* 10000),0)) WHERE SheepTherapy IS NULL If I then do a SELECT I see that my random number is identical in every row. Any ideas how to generate uniqu..

How to redirect 404 errors to a page in ExpressJS?

I don't know a function for doing this, does anyone know of one?..

VERR_VMX_MSR_VMXON_DISABLED when starting an image from Oracle virtual box

I'm getting this error while loading a Puppet image from a Oracle virtual box. How can I fix it? Failed to open a session for the virtual machine learn-puppet-centos-6.4-pe-3.1.0. VT-x is disabled i..

How to change identity column values programmatically?

I have a MS SQL 2005 database with a table Test with column ID. ID is an identity column. I have rows in this table and all of them have their corresponding ID auto incremented value. Now I would l..

Making heatmap from pandas DataFrame

I have a dataframe generated from Python's Pandas package. How can I generate heatmap using DataFrame from pandas package. import numpy as np from pandas import * Index= ['aaa','bbb','ccc','ddd',..

What's the difference between "git reset" and "git checkout"?

I've always thought of git reset and git checkout as the same, in the sense that both bring the project back to a specific commit. However, I feel they can't be exactly the same, as that would be redu..

How to Set Focus on Input Field using JQuery

Given the following HTML structure: <div class="wrapper"> <div class="top"> <a href="http://example.com" class="link">click here</a> </div> <div c..

How do I get the function name inside a function in PHP?

Is it possible? function test() { echo "function name is test"; } ..

How to obtain image size using standard Python class (without using external library)?

I am using Python 2.5. And using the standard classes from Python, I want to determine the image size of a file. I've heard PIL (Python Image Library), but it requires installation to work. How migh..

How do I escape a percentage sign in T-SQL?

This question also has the answer, but it mentions DB2 specifically. How do I search for a string using LIKE that already has a percent % symbol in it? The LIKE operator uses % symbols to signify wil..

Should you commit .gitignore into the Git repos?

Do you think it is a good practice to commit .gitignore into a Git repo? Some people don't like it, but I think it is good as you can track the file's history. Isn't it?..

Using "like" wildcard in prepared statement

I am using prepared statements to execute mysql database queries. And I want to implement a search functionality based on a keyword of sorts. For that I need to use LIKE keyword, that much I know. A..

ngOnInit not being called when Injectable class is Instantiated

Why isn't ngOnInit() called when an Injectable class is resolved? Code import {Injectable, OnInit} from 'angular2/core'; import { RestApiService, RestRequest } from './rest-api.service'; @Injectabl..

Creating folders inside a GitHub repository without using Git

I want to add a new folder to my newly created GitHub repository without installing the Git setup for (Mac, Linux, and Windows). Is it possible to do so? I can't have Git all the time with me when I ..

How to output to the console in C++/Windows

When using iostream in C++ on Linux, it displays the program output in the terminal, but in Windows, it just saves the output to a stdout.txt file. How can I, in Windows, make the output appear in the..

Cordova - Error code 1 for command | Command failed for

I'm new on cordova, so if my question is not relevant, forgive me. i have a cordova project in my Windows 7 x64 machine. Yesterday i was build my cordova app via cordova build android --release. But i..

Cannot send a content-body with this verb-type

I just got this exception (ProtocolViolationException) in my .NET 2.0 app (running on windows mobile 6 standard emulator). What confuses me is that as far as i know, I have not added any content body..

Is there a way to check which CSS styles are being used or not used on a web page?

Want to know which CSS styles are currently being used on a web page...

Javascript Uncaught TypeError: Cannot read property '0' of undefined

I know there's plenty of questions related to this error and I've checked most of them and none help me solve my issue. (Which seems so easy to debug...) I have an array (which is empty aat first): ..

Why is it bad practice to call System.gc()?

After answering a question about how to force-free objects in Java (the guy was clearing a 1.5GB HashMap) with System.gc(), I was told it's bad practice to call System.gc() manually, but the comments ..

XML Schema (XSD) validation tool?

At the office we are currently writing an application that will generate XML files against a schema that we were given. We have the schema in an .XSD file. Are there tool or libraries that we can us..

Check if an object belongs to a class in Java

Is there an easy way to verify that an object belongs to a given class? For example, I could do if(a.getClass() = (new MyClass()).getClass()) { //do something } but this requires instantiating ..

Python error: TypeError: 'module' object is not callable for HeadFirst Python code

I'm following the tutorial from the HeadFirst Python book. In chapter 7, I get an error message when trying to run the next code: Athlete class: class AthleteList(list): def __init__(self, a_nam..

Jump to function definition in vim

How can I jump to to a function definition using vim? For example with Visual Assist, I can type Alt+g under a function and it opens a context menu listing the files with definitions. How can I do so..

AppSettings get value from .config file

I'm not able to access values in configuration file. Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var clientsFilePath = config.AppSettings.Settings["..

Accessing inventory host variable in Ansible playbook

I am using Ansible 2.1. I have the following inventory host file and a role being called by a play that needs access to the host file variable. Any thoughts on how to access it (currently getting an..

Assign command output to variable in batch file

I'm trying to assign the output of a command to a variable - as in, I'm trying to set the current flash version to a variable. I know this is wrong, but this is what I've tried: set var=reg query hkl..

How to exclude records with certain values in sql select

How do I only select the stores that don't have client 5? StoreId ClientId ------- --------- 1 4 1 5 2 5 2 6 2 7 3 ..

Error: JAVA_HOME is not defined correctly executing maven

I installed java and set path to environment and when I execute echo $JAVA_HOME I get the following output: /usr/lib/jvm/java-7-oracle/jre/bin/java I Also installed apache-maven and changed environ..

How to host material icons offline?

My apologies if this is a very simple question, but how do you use google material icons without a <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> ? ..

React Native Border Radius with background color

In React Native, borderRadius is working but the background color given to the button stays a square. What is going on here? JS <TouchableHighlight style={styles.submit} onPress={() => thi..

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

I am using Authlogic-Connect for third party logins. After running appropriate migrations, Twitter/Google/yahoo logins seem to work fine but the facebook login throws exception: SSL_connect returned=..

Resolving IP Address from hostname with PowerShell

I am trying to get the ipaddress from a hostname using Powershell, but I really can't figure out how. Any help?..

docker cannot start on windows

Executing docker version command on Windows returns the following results: C:\Projects> docker version Client: Version: 1.13.0-dev API version: 1.25 Go version: go1.7.3 Git commit: d8..

What causes a Python segmentation fault?

I am implementing Kosaraju's Strong Connected Component(SCC) graph search algorithm in Python. The program runs great on small data set, but when I run it on a super-large graph (more than 800,000 no..

How to pass the password to su/sudo/ssh without overriding the TTY?

I'm writing a C Shell program that will be doing su or sudo or ssh. They all want their passwords in console input (the TTY) rather than stdin or the command line. Does anybody know a solution? Sett..

Amazon Interview Question: Design an OO parking lot

Design an OO parking lot. What classes and functions will it have. It should say, full, empty and also be able to find spot for Valet parking. The lot has 3 different types of parking: regular, handic..

'IF' in 'SELECT' statement - choose output value based on column values

SELECT id, amount FROM report I need amount to be amount if report.type='P' and -amount if report.type='N'. How do I add this to the above query?..

PHP: How to handle <![CDATA[ with SimpleXMLElement?

I noticed that when using SimpleXMLElement on a document that contains those CDATA tags, the content is always NULL. How do I fix this? Also, sorry for spamming about XML here. I have been trying to ..

Is there a way to avoid null check before the for-each loop iteration starts?

Every time I have to iterate over a collection I end up checking for null, just before the iteration of the for-each loop starts. Like this: if( list1 != null ){ for(Object obj : list1){ } }..

Getting "TypeError: failed to fetch" when the request hasn't actually failed

I'm using fetch API within my React app. The application was deployed on a server and was working perfectly. I tested it multiple times. But, suddenly the application stopped working and I've no clue ..