Questions Tagged with #Code analysis

Code Analysis is the process of analyzing the code of the application to discover, review, validate or verify certain properties of the application. This is useful during the process of development and for testing the application before it is put in production mode, especially for checking the security related aspects.

What static analysis tools are available for C#?

What tools are there available for static analysis against C# code? I know about FxCop and StyleCop. Are there others? I've run across NStatic before but it's been in development for what seems like f..

How can I perform static code analysis in PHP?

Is there a static analysis tool for PHP source files? The binary itself can check for syntax errors, but I'm looking for something that does more, like: unused variable assignments arrays that are as..

C# compiler error: "not all code paths return a value"

I'm trying to write code that returns whether or not a given integer is divisible evenly by 1 to 20, but I keep receiving the following error: error CS0161: 'ProblemFive.isTwenty(int)': not all c..

How do I fix PyDev "Undefined variable from import" errors?

I've got a Python project using PyDev in Eclipse, and PyDev keeps generating false errors for my code. I have a module settings that defines a settings object. I import that in module b and assign a..

How does an SSL certificate chain bundle work?

I've created a chain hierarchy like this. root-ca ==> signing-ca ==> subordinate-ca ==> server It is mentioned to create chain bundle, the lowest should go first. $ cat server.crt subordi..

Asp.Net MVC with Drop Down List, and SelectListItem Assistance

I am trying to build a Dropdownlist, but battling with the Html.DropDownList rendering. I have a class: public class AccountTransactionView { public IEnumerable<SelectListItem> Accounts { ..

What is a 'multi-part identifier' and why can't it be bound?

I continually get these errors when I try to update tables based on another table. I end up rewriting the query, change the order of joins, change some groupings and then it eventually works, but I ju..

Add new field to every document in a MongoDB collection

How can I add a new field to every document in an existent collection? I know how to update an existing document's field but not how to add a new field to every document in a collection. How can I do..

Where is PHP.ini in Mac OS X Lion? Thought it was in /usr/local/php5/lib

I wanted to run some PHP right on my Mac, uncommented httpd.conf, activated web sharing, installed MySQL etc. I can't seem to find my PHP files, most importantly, PHP.ini. On my old machine it was lo..

How can I compare two ordered lists in python?

If I have one long list: myList = [0,2,1,0,2,1] that I split into two lists: a = [0,2,1] b = [0,2,1] how can I compare these two lists to see if they are both equal/identical, with the constraint t..

Unit testing with Spring Security

My company has been evaluating Spring MVC to determine if we should use it in one of our next projects. So far I love what I've seen, and right now I'm taking a look at the Spring Security module to d..

Dynamic constant assignment

class MyClass def mymethod MYCONSTANT = "blah" end end gives me the error: SyntaxError: dynamic constant assignment error Why is this considered a dynamic constant? I'm just assigning ..

jQuery checkbox check/uncheck

What would be a proper way to check/uncheck checkbox that's placed inside the element that triggers my function? Here's my code: <table id="news_list"> <tr> <td><input type=..

CSS: How to change colour of active navigation page menu

I'm trying to change the colour of the active or current page navigation link which is selected by the user on my website. What am I doing wrong? Thanks. So far the CSS looks like this: div.menuBar ..

Registry Key '...' has value '1.7', but '1.6' is required. Java 1.7 is Installed and the Registry is Pointing to it

My development team recently was forced over to a remote development environment where we do not have full access to the servers. Before the change over we had a JAR that was running fine on Java 1.7..

Converting a JS object to an array using jQuery

My application creates a JavaScript object, like the following: myObj= {1:[Array-Data], 2:[Array-Data]} But I need this object as an array. array[1]:[Array-Data] array[2]:[Array-Data] So I trie..

Join two data frames, select all columns from one and some columns from the other

Let's say I have a spark data frame df1, with several columns (among which the column id) and data frame df2 with two columns, id and other. Is there a way to replicate the following command sqlContex..

To check if string contains particular word

So how do you check if a string has a particular word in it? So this is my code: a.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { ..

Using Pip to install packages to Anaconda Environment

conda 4.2.13 MacOSX 10.12.1 I am trying to install packages from pip to a fresh environment (virtual) created using anaconda. In the Anaconda docs it says this is perfectly fine. It is done the sam..

Alert handling in Selenium WebDriver (selenium 2) with Java

I want to detect whether an alert is popped up or not. Currently I am using the following code: try { Alert alert = webDriver.switchTo().alert(); // check if alert exists ..

What is the difference between the remap, noremap, nnoremap and vnoremap mapping commands in Vim?

What is the difference between the remap, noremap, nnoremap and vnoremap mapping commands in Vim?..

Convert Go map to json

I tried to convert my Go map to a json string with encoding/json Marshal, but it resulted in a empty string. Here's my code : package main import ( "encoding/json" "fmt" ) type Foo struct ..

len() of a numpy array in python

If I use len(np.array([[2,3,1,0], [2,3,1,0], [3,2,1,1]])), I get back 3. Why is there no argument for len() about which axis I want the length of in multidimensional arrays? This is alarming. Is t..

jQuery - Detecting if a file has been selected in the file input

Possible Duplicate: jQuery: get the file name selected from <input type=“file” /> I have a standard file input box <input type="file" name="imafile"> I also have ..

Testing socket connection in Python

This question will expand on: Best way to open a socket in Python When opening a socket how can I test to see if it has been established, and that it did not timeout, or generally fail. Edit: I tried..

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..

LINQ Using Max() to select a single row

I'm using LINQ on an IQueryable returned from NHibernate and I need to select the row with the maximum value(s) in a couple of fields. I've simplified the bit that I'm sticking on. I need to select ..

How to round up integer division and have int result in Java?

I just wrote a tiny method to count the number of pages for cell phone SMS. I didn't have the option to round up using Math.ceil, and honestly it seems to be very ugly. Here is my code: public class..

Float vs Decimal in ActiveRecord

Sometimes, Activerecord data types confuse me. Err, often. One of my eternal questions is, for a given case, Should I use :decimal or :float? I've often come across this link, ActiveRecord: :dec..

What is the difference between declarative and imperative paradigm in programming?

I have been searching the web looking for a definition for declarative and imperative programming that would shed some light for me. However, the language used at some of the resources that I have fou..

Passing command line arguments to R CMD BATCH

I have been using R CMD BATCH my_script.R from a terminal to execute an R script. I am now at the point where I would like to pass an argument to the command, but am having some issues getting it wor..

Why does Date.parse give incorrect results?

Case One: new Date(Date.parse("Jul 8, 2005")); Output: Fri Jul 08 2005 00:00:00 GMT-0700 (PST) Case Two: new Date(Date.parse("2005-07-08")); Output: Thu Jul 07 2005 17:00:00 GMT-0700 (PST) ..

onchange event on input type=range is not triggering in firefox while dragging

When I played with <input type="range">, Firefox triggers an onchange event only if we drop the slider to a new position where Chrome and others triggers onchange events while the slider is drag..

Having links relative to root?

Is there a way to have all links on a page be relative to the root directory? For example, on I could have a link saying: <a href="fruits/index.html">B..

How can I create a simple message box in Python?

I'm looking for the same effect as alert() in JavaScript. I wrote a simple web-based interpreter this afternoon using Twisted.web. You basically submit a block of Python code through a form, and the ..

How do I change the UUID of a virtual disk?

I am trying to create a new virtual machine with Oracle VirtualBox, using an already-existing hard disk. When I try to select the existing hard disk file, a .vhd file, it displays an error saying the ..

How to search for a file in the CentOS command line

I am using CentOS minimal version and I am trying to locate a file, but I have no idea how to search all of the server for the file. I am sure there is a command out there to do it, can anyone help me..

"SMTP Error: Could not authenticate" in PHPMailer

I'm using PHPMailer in a Simple Script For Send Email's Through Gmail, and I'm getting an "Unknown Error" (At least for me!): SMTP Error: Could not authenticate. Error: SMTP Error: Could not a..

Background position, margin-top?

I currently have my background set to top right as: #thedivstatus { background-image: url("imagestatus.gif"); background-position: right top; background-repeat: no-repeat; } BUT! I need..

Difference between return 1, return 0, return -1 and exit?

For example consider following code: int main(int argc,char *argv[]) { int *p,*q; p = (int *)malloc(sizeof(int)*10); q = (int *)malloc(sizeof(int)*10); if (p == 0) { printf("ERROR: Ou..

Setting multiple attributes for an element at once with JavaScript

How can I set multiple attributes at once with JavaScript? Unfortunately, I'm not able to use a framework like jQuery on this project. Here is what I have now: var elem = document.createElement("img"..

How can I check if a jQuery plugin is loaded?

Is there any way to check if a particular plugin is available? Imagine that you are developing a plugin that depends on another plugin being loaded. For example I want the jQuery Validation plugin t..

How would I check a string for a certain letter in Python?

How would I tell Python to check the below for the letter x and then print "Yes"? The below is what I have so far... dog = "xdasds" if "x" is in dog: print "Yes!" ..

APR based Apache Tomcat Native library was not found on the java.library.path?

When trying to run my app with eclipse/linux on tomcat I got the following info message: INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments w..

Calling remove in foreach loop in Java

In Java, is it legal to call remove on a collection when iterating through the collection using a foreach loop? For instance: List<String> names = .... for (String name : names) { // Do som..

Date validation with ASP.NET validator

I'm trying to use an ASP.NET RangeValidator to validate a date on a textbox. The format of the date entered on the textbox is dd MMMM yyyy. How can I use the range validator to validate a valid date?..

gdb: how to print the current line or find the current line number?

list commands prints a set of lines, but I need one single line, where I am and where an error has probably occurred...

How to crop(cut) text files based on starting and ending line-numbers in cygwin?

I have few log files around 100MBs each. Personally I find it cumbersome to deal with such big files. I know that log lines that are interesting to me are only between 200 to 400 lines or so. What w..

Min/Max of dates in an array?

How can I find out the min and the max date from an array of dates? Currently, I am creating an array like this: var dates = []; dates.push(new Date("2011/06/25")) dates.push(new Date("2011/06/26")) ..

Maven Install on Mac OS X

I'm trying to install maven through the terminal by following these instructions. So far I got this export M2_HOME=/user/apple/apache-maven-3.0.3 export M2=$M2_HOME/bin export PATH=$M2:$PATH export ..

Math functions in AngularJS bindings

Is there a way to use math functions in AngularJS bindings? e.g. <p>The percentage is {{Math.round(100*count/total)}}%</p> This fiddle shows the problem

How to style HTML5 range input to have different color before and after slider?

I want the left side to be green and the right side to be gray. As pictured above would be PERFECT. Preferably a pure CSS solution (only need to worry about WebKit). Is such a thing possible?..

Find files containing a given text

In bash I want to return file name (and the path to the file) for every file of type .php|.html|.js containing the case-insensitive string "document.cookie" | "setcookie" How would I do that?..

Convert MySql DateTime stamp into JavaScript's Date format

Does anyone know how I can take a MySQL datetime data type value, such as YYYY-MM-DD HH:MM:SS and either parse it or convert it to work in JavaScript's Date() function, for example:- Date('YYYY, MM, D..

Cannot read configuration file due to insufficient permissions

I've recently encountered an error trying to host my site with IIS. I have found a solution that many swear by. Solution: Add IIS_IUSRS with Read permission on files in the folder Change II..

Matrix Transpose in Python

I am trying to create a matrix transpose function for python but I can't seem to make it work. Say I have theArray = [['a','b','c'],['d','e','f'],['g','h','i']] and I want my function to come up w..

Where is Developer Command Prompt for VS2013?

I need to run web.exe file from my developer command prompt in Visual Studio 2013. By default, the command prompt is not installed in Visual Studio 2013. Previously, I was using Visual Studio 2012. I..

What does <value optimized out> mean in gdb?

(gdb) n 134 a = b = c = 0xdeadbeef + ((uint32_t)length) + initval; (gdb) n (gdb) p a $30 = <value optimized out> (gdb) p b $31 = <value optimized out> (gdb) p c $32 = 3735928563 How ca..

Get class name of object as string in Swift

Getting the classname of an object as String using: object_getClassName(myViewController) returns something like this: _TtC5AppName22CalendarViewController I am looking for the pure version: "Ca..

How to generate random colors in matplotlib?

What's the trivial example of how to generate random colors for passing to plotting functions? I'm calling scatter inside a loop and want each plot a different color. for X,Y in data: scatter(X, ..

Dynamically create an array of strings with malloc

I am trying to create an array of strings in C using malloc. The number of strings that the array will hold can change at run time, but the length of the strings will always be consistent. I've attem..

Strip all non-numeric characters from string in JavaScript

Consider a non-DOM scenario where you'd want to remove all non-numeric characters from a string using JavaScript/ECMAScript. Any characters that are in range 0 - 9 should be kept. var myString = 'abc..

If else embedding inside html

What is the correct way of embedding if else and elseif conditions inside html?..

"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..

AttributeError: 'module' object has no attribute 'urlretrieve'

I am trying to write a program that will download mp3's off of a website then join them together but whenever I try to download the files I get this error: Traceback (most recent call last): File "/h..

How to use a different version of python during NPM install?

I have terminal access to a VPS running centos 5.9 and default python 2.4.3 installed. I also installed python 2.7.3 via these commands: (I used make altinstall instead of make install) wget http://w..

Increase days to php current Date()

How do I add a certain number of days to the current date in PHP? I already got the current date with: $today = date('y:m:d'); Just need to add x number of days to it..

ALTER TABLE on dependent column

I am trying to alter column datatype of a primary key to tinyint from int.This column is a foreign key in other tables.So,I get the following error: Msg 5074, Level 16, State 1, Line 1 The objec..

Remove 'standalone="yes"' from generated XML

Do you know of a JAXB setting to prevent standalone="yes" from being generated in the resulting XML? <?xml version="1.0" encoding="UTF-8" standalone="yes"?> ..

Uncaught ReferenceError: $ is not defined error in jQuery

I have this code in jQuery: (the file name is javascript.js ...I was using JavaScript before...) $(document).ready(function() { $("#readFile").click(function() { $.get('test.txt', function(data)..

How to do a SOAP Web Service call from Java class?

I'm relative new to the webservices world and my research seems to have confused me more than enlighten me, my problem is that I was given a library(jar) which I have to extend with some webservice fu..

How can I check if a var is a string in JavaScript?

How can I check if a var is a string in JavaScript? I've tried this and it doesn't work... var a_string = "Hello, I'm a string."; if (a_string typeof 'string') { // this is a string } ..

Are (non-void) self-closing tags valid in HTML5?

The W3C validator doesn't like self-closing tags (those that end with "/>") on non-void elements. (Void elements are those that may not ever contain any content.) Are they still valid in HTML5? So..

Java GUI frameworks. What to choose? Swing, SWT, AWT, SwingX, JGoodies, JavaFX, Apache Pivot?

There is quite a lot of gui frameworks out there for java, but what is recognized as today's framework of choice? The following is my understanding of the different frameworks, please correct me if i..

Using getResources() in non-activity class

I am trying to use getResources method in a non-activity class. How do I get the reference to the "resources" object so that I can access the xml file stored under resources folder? Example: XmlPull..

Detect when input has a 'readonly' attribute

I want to throw an alert when an input has a 'readonly' attribute. I have tried this: if($('input').attr('readonly') == 'readonly'){ alert("foo"); } I think that 'if' is not even the best ..

JS search in object values

I have an array of homogeneous objects like so; [ { "foo" : "bar", "bar" : "sit" }, { "foo" : "lorem", "bar" : "ipsum" }, { "foo" : "dolor", "bar" : "amet" } ] I..

Use SELECT inside an UPDATE query

How can I UPDATE a field of a table with the result of a SELECT query in Microsoft Access 2007. Here's the Select Query: SELECT Min(TAX.Tax_Code) AS MinOfTax_Code FROM TAX, FUNCTIONS WHERE (((FUNCT..

Lock screen orientation (Android)

I'm writing an android application that uses tabs with different contents (activities). In one of these activities, I would like to lock the screen orientation to "Landscape"-mode, but in the other ac..

JavaScript: changing the value of onclick with or without jQuery

I'd like to change the value of the onclick attribute on an anchor. I want to set it to a new string that contains JavaScript. (That string is provided to the client-side JavaScript code by the server..

Step out of current function with GDB

Those who use Visual Studio will be familiar with the Shift + F11 hotkey, which steps out of a function, meaning it continues execution of the current function until it returns to its caller, at which..

Where is Java's Array indexOf?

I must be missing something very obvious, but I've searched all over and can't find this method...

Critical t values in R

I need to determine the critical t values for one-sided tails of 75% and 99%, for 40 degrees of freedom. The following is code for a two-sided 99% critical t values: qt(0.01, 40) but how can I det..

Cast Double to Integer in Java

Any way to cast java.lang.Double to java.lang.Integer? It throws an exception "java.lang.ClassCastException: java.lang.Double incompatible with java.lang.Integer" ..

Closing Excel Application Process in C# after Data Access

I'm writing an application in C# that opens an Excel template file for read/write operations. I want to when user closes the application, excel application process has been closed, without saving exce..

C++ pointer to objects

In C++ do you always have initialize a pointer to an object with the new keyword? Or can you just have this too: MyClass *myclass; myclass->DoSomething(); I thought this was a pointer allocate..

Laravel Mail::send() sending to multiple to or bcc addresses

I can't seem to successfully send to multiple addresses when using Laravel's Mail::send() callback, the code does however work when I only specify one recipient. I've tried chaining: // for example ..

ImportError: No module named Image

I have also tried from PIL import Image but it gives me ImportError: No module named PIL. I have installed PIL successfully using pip install pil and I've also installed xcode command line too..

How do I get into a non-password protected Java keystore or change the password?

I'm trying to import a trusted certificated into the Java cacerts keystore, but I have a problem. I tried to list existing trusted certificates and it seems that the keystore isn't password protected...

How to increase the vertical split window size in Vim

:vsplit (short form: :vs) split the Vim viewport vertically. :30vs splits the viewport, making the new window 30 characters wide. Once this 30 char window is created, how would one change it's size to..

Assign keyboard shortcut to run procedure

When I press F5 in the VBA editor I would always like to run my "Sub Skynet()" procedure. Is there any way to assign a keyboard shortcut to this procedure...

postgres: upgrade a user to be a superuser?

In postgres, how do I change an existing user to be a superuser? I don't want to delete the existing user, for various reasons. # alter user myuser ...? ..

Managing jQuery plugin dependency in webpack

I'm using Webpack in my application, in which I create two entry points - bundle.js for all my JavaScript files/codes, and vendors.js for all libraries like jQuery and React. What do I do in order to ..

what happens when you type in a URL in browser

Can somebody tell me what all happens behind the scenes from the time I type in a URL in the browser to the time when I get to see the page on the browser? A detailed account of the process would be o..

CodeIgniter Select Query

I have a simple CodeIgniter Active record query to select an ID: $q = $this -> db -> select('id') -> where('email', $email) -> limit(1) -> g..

Change application's starting activity

I have created the meat and guts of my application but I want to add a different activity that will be the starting point (sort of a log-in screen). Couple questions: 1 I have a fairly decent handl..

How to show a dialog to confirm that the user wishes to exit an Android Activity?

I've been trying to show a "Do you want to exit?" type of dialog when the user attempts to exit an Activity. However I can't find the appropriate API hooks. Activity.onUserLeaveHint() initially lo..

How to set -source 1.7 in Android Studio and Gradle

I'm getting following error when trying to compile my project in Android Studio: Gradle: error: diamond operator is not supported in -source 1.6 I have 1.7 set as target in all project preferences ..

Java: Finding the highest value in an array

For some reason this code is printing three values for the highest value in the array when I'm trying to print just one (which is 11.3). Can someone please explain to me why it is doing this? Thanks...

How do I set ANDROID_SDK_HOME environment variable?

I'm working with Eclipse on Windows 7, x64. I'm getting an error when running ADT bundle of android development: Error: Error parsing the AVDs Unable to get the Android SDK home directory. Make sure ..

Centering the image in Bootstrap

I m using bootstrap 3.0 to creating a website. I am new to bootstrap. what i want, i want image in center of div when browser size is extra small i have this code. <div class="col-lg-10 ccol-lg-of..

What is JavaScript garbage collection?

What is JavaScript garbage collection? What's important for a web programmer to understand about JavaScript garbage collection, in order to write better code?..

How do I create a message box with "Yes", "No" choices and a DialogResult?

I want to make simple Yes/No choiced MessageBox, but I think it is nonsense to design a form for that. I thought I could use MessageBox, add buttons, etc. to accomplish this. It is simple, but since t..

What is difference between INNER join and OUTER join

Difference between inner and outer join. i am using two table and want to fetch data from both table so which type join we should use owning of that we can solve our problem ..

Combining two expressions (Expression<Func<T, bool>>)

I have two expressions of type Expression<Func<T, bool>> and I want to take to OR, AND or NOT of these and get a new expression of the same type Expression<Func<T, bool>> expr..

Can Android do peer-to-peer ad-hoc networking?

Is it possible to set up Android in ad-hoc peer-to-peer wifi mode? For example, I would like to have one phone broadcast a message, and have all peers in the network receive the broadcast, without ha..

How to generate a random string of a fixed length in Go?

I want a random string of characters only (uppercase or lowercase), no numbers, in Go. What is the fastest and simplest way to do this?..

regular expression to validate datetime format (MM/DD/YYYY)

I am trying to validate datetime format MM/DD/YYYY. Here is the code I am trying please help. function ValidateDate(testdate) { var Status var reg = /^(((0[1-9]|[12]\d|3[01])\/(0[135..

Python extending with - using super() Python 3 vs Python 2

Originally I wanted to ask this question, but then I found it was already thought of before... Googling around I found this example of extending configparser. The following works with Python 3: $ pyth..

How do I remove duplicates from a C# array?

I have been working with a string[] array in C# that gets returned from a function call. I could possibly cast to a Generic collection, but I was wondering if there was a better way to do it, possibly..

Angular2 QuickStart npm start is not working correctly

I know Angular2 beta has just been released but I can't reproduce the steps from their official site tutorial ( ). Maybe someone has had similar issues and knows ..

difference between throw and throw new Exception()

what is the difference between try { ... } catch{ throw } and try{ ... } catch(Exception e) {throw new Exception(e.message) } Regardless that the second shows a message ?..

Accessing UI (Main) Thread safely in WPF

I have an application which updates my datagrid each time a log file that I'm watching gets updated (Appended with new text) in the following manner: private void DGAddRow(string name, FunctionType f.. Read timed out under Tomcat

I have a Tomcat based web application. I am intermittently getting the following exception, Caused by: Read timed out at

How can I delete (not disable) ActiveX add-ons in Internet Explorer (7 and 8 Beta 2)?

I'm developing a solution which uses an ActiveX control (a commercial one which we bought and that I did not develop). I need to develop the proper installation pages to simulate what happens when a u..

How can I remove time from date with Moment.js?

formatCalendarDate = function (dateTime) { return moment.utc(dateTime).format('LLL'); }; It displays: "28 februari 2013 09:24" But I would like to remove the time at the end. How can I do that?..

What's the main difference between int.Parse() and Convert.ToInt32

What is the main difference between int.Parse() and Convert.ToInt32()? Which one is to be preferred ..

Convert Unix timestamp to a date string

Is there a quick, one-liner way to convert a Unix timestamp to a date from the Unix command line? date might work, except it's rather awkward to specify each element (month, day, year, hour, etc.), an..

How to resize an image to a specific size in OpenCV?

IplImage* img = cvLoadImage("something.jpg"); IplImage* src = cvLoadImage("src.jpg"); cvSub(src, img, img); But the size of the source image is different from img. Is there any opencv function to r..

How can I install a CPAN module into a local directory?

I'm using a hosted Linux machine so I don't have permissions to write into the /usr/lib directory. When I try to install a CPAN module by doing the usual: perl Makefile.PL make test make install T..

Django Reverse with arguments '()' and keyword arguments '{}' not found

Hi I have an infuriating problem. I have a url pattern like this: # mproject/ url(r'^project/(?P<project_id>\d+)/$','user_profile.views.EditProject',name='edit_project'), it wo..

Completely remove MariaDB or MySQL from CentOS 7 or RHEL 7

I installed MariaDB on CentOS 7 but I had some problems with some configuration, now it is completely misconfigured. Thus, I wanted to remove the MariaDB with “yum remove mariadb mariadb-server”..

Add new column with foreign key constraint in one command

I am trying to add a new column that will be a foreign key. I have been able to add the column and the foreign key constraint using two separate ALTER TABLE commands: ALTER TABLE one ADD two_id integ..

Better way to sort array in descending order

I have a array of int which I have to sort by descending. Since I did not find any method to sort the array in descending order.Currently I am sorting the array in descending order as below int[] a..

Error TF30063: You are not authorized to access ... \DefaultCollection

I'm using TFS Preview (Team Foundation Service) with one of my projects with Visual Studio 2012. I'm also using an on-premises TFS server with most of my projects. When I use my on-premises TFS after ..

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

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

Reverse / invert a dictionary mapping

Given a dictionary like so: my_map = {'a': 1, 'b': 2} How can one invert this map to get: inv_map = {1: 'a', 2: 'b'} ..

How to vertically align text inside a flexbox?

I would like to use flexbox to vertically align some content inside an <li> but not having great success. I've checked online and many of the tutorials actually use a wrapper div which gets the..

Size of Matrix OpenCV

I know this might be very rudimentary, but I am new to OpenCV. Could you please tell me how to obtain the size of a matrix in OpenCV?. I googled and I am still searching, but if any of you know the an..

Chosen Jquery Plugin - getting selected values

How can i get the selected values from the chosen Multi-select Box?..


I am trying to update a LARGE MyISAM table (25 million records) using a CLI script. The table is not being locked/used by anything else. I figured instead of doing single UPDATE queries for each reco..

What is the final version of the ADT Bundle?

What is the final version of the ADT Bundle that was released by Google? Since "Android Studio" was announced as official IDE for the development of Android apps, the ADT Bundle (Eclipse with ADT Pl..

What operator is <> in VBA

I was studying some vba code and came across this: If DblBalance <> 0 Then I can't figure out what operator this is, any help would be appreciated...

How do I download and save a file locally on iOS using objective C?

I'm new to Objective-C and I want to download a file from the web (if it was changed on the webserver) and save it locally so it can be used by my application. Mainly I want to implement what wget --..

Authentication failed for

I am trying to use git to push my repository to a visual studio team services project, but I get the error: fatal: Authentication failed for (url of team project) I am using the commands: git remote ..

Qt 5.1.1: Application failed to start because platform plugin "windows" is missing

Edit: Some people started to mark my question as a duplicate. Do not forget that many similar questions existed when I asked this one (see e.g. the list below). However, none of these answers solved..

Create File If File Does Not Exist

I need to get my code to read if file doesnt exist create else append. Right now it is reading if it does exist create and append. Here is the code: if (File.Exists(path)) { using (StreamWriter s..

How to send control+c from a bash script?

I'm starting a number of screens in a bash script, then running django's runserver command in each of them. I'd like to be able to programmatically stop them all as well, which requires me to send Con..

Why doesn't Python have a sign function?

I can't understand why Python doesn't have a sign function. It has an abs builtin (which I consider sign's sister), but no sign. In python 2.6 there is even a copysign function (in math), but no sign..

Function pointer as a member of a C struct

I have a struct as follows, with a pointer to a function called "length" that will return the length of the chars member. typedef struct pstring_t { char * chars; int (* length)(); } PString;..

HTML image bottom alignment inside DIV container

I have a div tag with a fixed height. Most of the images have the same height and width. I want to align the images at the bottom of the div so that they are nicely arranged. Here is what I have so..

Automatically create an Enum based on values in a database lookup table?

How do I automatically create an enum and subsequently use its values in C# based on values in a database lookup table (using enterprise library data layer)? For example, If I add a new lookup value ..

Is this very likely to create a memory leak in Tomcat?

I configured tomcat to work with a different external open source. However, after the tomcat is running for a few minutes I get: SEVERE: The web application [/MyProject] created a ThreadLocal wit..

mvn command is not recognized as an internal or external command

I am getting the mvn command not recognized as an internal or external command. I have setup the M2_HOME, JAVA_HOME and added %M2_HOME%/bin to the path variable. All are system variables. Still getti..

SQL SERVER: Get total days between two dates

I'm trying to get the total number of days between two days: 1/1/2011 3/1/2011 RETURN 62 Is it possible to do in SQL Server?..

How to center and crop an image to always appear in square shape with CSS?

I need to always crop a random-sized image to a square 160x160 using only CSS. The images should stay centered when cropped. My markup should be: <a href="#" class="cropper"> <img src="i..

How do you create a toggle button?

I want to create a toggle button in html using css. I want it so that when you click on it , it stays pushed in and than when you click it on it again it pops out. If theres no way of doing it just..

How to amend older Git commit?

I have made 3 git commits, but have not been pushed. How can I amend the older one (ddc6859af44) and (47175e84c) which is not the most recent one? $git log commit f4074f289b8a49250b15a4f25ca4b4601745..

Bash script to run php script

I have a php script that I want to be run using a bash script, so I can use Cron to run the php script every minute or so. As far as I'm aware I need to create the bash script to handle the php scrip..

Regex - Does not contain certain Characters

I need a regex to match if anywhere in a sentence there is NOT either < or >. If either < or > are in the string then it must return false. I had a partial success with this but only if my <..

How to use onResume()?

Can anyone give me an example that uses onResume() in Android? Also, if I want to restart the activity at the end of the execution of another, which method is executed—onCreate() or onResume()? An..

SOAP-ERROR: Parsing WSDL: Couldn't load from <URL>

In PHP: I am getting an error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://xxx.xxxx.asmx?WSDL' : failed to load external entity "http://xxx.xxxx.asmx?WSDL" My code is: <?php ..

How can I format a decimal to always show 2 decimal places?

I want to display: 49 as 49.00 and: 54.9 as 54.90 Regardless of the length of the decimal or whether there are are any decimal places, I would like to display a Decimal with 2 decimal places, and ..

PHP checkbox set to check based on database value

I have a system where people fill in their information and later can go back and edit certain parts, basically the enter personal info and check whether they want to know extra info, these bits of ext..


I have to list all "shift" data to be assigned to an "employee" but shift data must not be included if it is already existing in employee's data. Let's see the image sample. This query solves the..

Pycharm: run only part of my Python file

Is it possible to run only a part of a program in PyCharm? In other editors there is something like a cell which I can run, but I can't find such an option in PyCharm? If this function doesn't exist..

How can I iterate JSONObject to get individual items

This is my below code from which I need to parse the JSONObject to get individual items. This is the first time I am working with JSON. So not sure how to parse JSONObject to get the individual items ..

How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?

I have a simple key/value list in JSON being sent back to ASP.NET via POST. Example: { "key1": "value1", "key2": "value2"} I AM NOT TRYING TO DESERIALIZE INTO STRONGLY-TYPED .NET OBJECTS I simply ..

What is two way binding?

I have read lots that Backbone doesn't do two way binding but I don't exactly understand this concept. Could somebody give me an example of how two way binding works in an MVC codebase and how it doe..

add allow_url_fopen to my php.ini using .htaccess

I want to allow allow_url_fopen on my server . I have asked my host and they said it can be done with a .htaccess file. Can anyone tell me how to go about this ?..

Best way to check for "empty or null value"

What is best way to check if value is null or empty string in Postgres sql statements? Value can be long expression so it is preferable that it is written only once in check. Currently I'm using: c..

ValueError: invalid literal for int () with base 10

I wrote a program to solve y = a^x and then project it on a graph. The problem is that whenever a < 1 I get the error: ValueError: invalid literal for int () with base 10. Any suggestions? ..

Python pip install fails: invalid command egg_info

I find that recently often when I try to install a Python package using pip, I get the error(s) below. I found a reference online that one has to use "python2 install" from the download dire..

Bootstrap how to get text to vertical align in a div container

What is the best/proper way to vertically align the text in the middle of its column? The image height is statically set in the CSS. I have tried setting an outer div to display: table and an inner d..

Facebook login message: "URL Blocked: This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings."

Important notice: If you register for testing, go to your profile settings and to your interests add delete profile. Trying to login with Facebook to my website: I get the following error: URL..

React Native Error: ENOSPC: System limit for number of file watchers reached

I have setup a new blank react native app. After installing few node modules I got this error. Running application on PGN518. internal/fs/watchers.js:173 throw error; ^ Error: ENOSPC: System l..

Unable to run Java GUI programs with Ubuntu

I am learning GUI in Java, and for that I have created a demo program: import java.awt.*; public class FrameDemo extends Frame { public FrameDemo(){ super("Frame Demo"); setSize..

How do I pass an object to HttpClient.PostAsync and serialize as a JSON body?

I'm using System.Net.Http, I found several examples on the web. I managed to create this code for make a POST request: public static string POST(string resource, string token) { using (var client..

Force SSL/https using .htaccess and mod_rewrite

How can I force to SSL/https using .htaccess and mod_rewrite page specific in PHP...

What is PostgreSQL equivalent of SYSDATE from Oracle?

I want to perform a query using sysdate like: select up_time from exam where up_time like sysdate which is possible in Oracle. However, it seems that PostgreSQL doesn't support sysdate. I couldn't..

How to check for valid email address?

Is there a good way to check a form input using regex to make sure it is a proper style email address? Been searching since last night and everybody that has answered peoples questions regarding this ..

pycharm convert tabs to spaces automatically

I am using pycharm IDE for python development it works perfectly fine for django code so suspected that converting tabs to spaces is default behaviour, however in python IDE is giving errors everywher..

Error handling in getJSON calls

How can you handle errors in a getJSON call? Im trying to reference a cross-domain script service using jsonp, how do you register an error method? ..

Very simple log4j2 XML configuration file using Console and File appender

I'd like a very simple XML configuration file with a console and a file appender using log4j2. (The Apache Website is killing me with much Information.)..

Set Text property of asp:label in Javascript PROPER way

I have a series of textboxes on a form. When the user inserts numbers into these textboxes, calculations are made and <asp:Label> controls are updated via JavaScript to reflect these calculatio..

Recover unsaved SQL query scripts

How to recover the unsaved scripts if the SSMS crashes / unsaved tab gets accidentally closed?..

How do I generate sourcemaps when using babel and webpack?

I'm new to webpack, and I need a hand in setting up to generate sourcemaps. I'm running webpack serve from the command line, which compiles successfully. But I really need sourcemaps. This is my webpa..

How to convert View Model into JSON object in ASP.NET MVC?

I am a Java developer, new to .NET. I am working on a .NET MVC2 project where I want to have a partial view to wrap a widget. Each JavaScript widget object has a JSON data object that would be populat..

How can I make PHP display the error instead of giving me 500 Internal Server Error

This has never happened before. Usually it displays the error, but now it just gives me a 500 internal server error. Of course before, when it displayed the error, it was different servers. Now I'm on..

Autowiring fails: Not an managed Type

I have a big problem in my diploma project and would be very glad if you guys could help me! I made a Maven Multi Module Project and have 3 "Core-projects" NaviClean: (Parent) NaviCleanDomain: conta..

Maintain the aspect ratio of a div with CSS

I want to create a div that can change its width/height as the window's width changes. Are there any CSS3 rules that would allow the height to change according to the width, while maintaining its asp..

SQL : BETWEEN vs <= and >=

In SQL Server 2000 and 2005: what is the difference between these two WHERE clauses? which one I should use on which scenarios? Query 1: SELECT EventId, EventName FROM EventMaster WHERE EventDate..

How to base64 encode image in linux bash / shell

I'm trying to base64 encode an image in a shell script and put it into variable: test="$(printf DSC_0251.JPG | base64)" echo $test RFNDXzAyNTEuSlBH I've also tried something like this: test=\`echo..

Get list from pandas DataFrame column headers

I want to get a list of the column headers from a pandas DataFrame. The DataFrame will come from user input so I won't know how many columns there will be or what they will be called. For example, if..

Use and meaning of "in" in an if statement?

In an example from Zed Shaw's Learn Python the Hard Way, one of the exercises displays the following code: next = raw_input("> ") if "0" in next or "1" in next: how_much = int(next) I'm havi..

Check if DataRow exists by column name in c#?

I want to do something like this: private User PopulateUsersList(DataRow row) { Users user = new Users(); user.Id = int.Parse(row["US_ID"].ToString()); ..

What is Haskell used for in the real world?

There is a lot of hype around Haskell, however, it is hard to get information on how it is used in the real world applications. What are the most popular projects / usages of Haskell and why it excels..

How to autowire RestTemplate using annotations

When I try to autowire Spring RestTemplate, I am getting following error: nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springfr..

Rolling back local and remote git repository by 1 commit

I've read the similar posts on this topic, and can't for the life of me figure out how to do this properly. I checked in about 1000 files that I don't want, and I'd rather not have to go through 1by1..

How to convert the background to transparent?

I have no experience with any image processing/editing tools. I am doing a project which requires me to convert the images(small icon) with background colour(red/blue/white) to transparent for the web..

Plotting multiple time series on the same plot using ggplot()

I am fairly new to R and am attempting to plot two time series lines simultaneously (using different colors, of course) making use of ggplot2. I have 2 data frames. the first one has 'Percent change..

SQL How to correctly set a date variable value and use it?

I have the following query which uses a date variable, which is generated inside the stored procedure: DECLARE @sp_Date DATETIME SET @sp_Date = DateAdd(m, -6, GETDATE()) SELECT DISTINCT pat.Publicati..

Bower: ENOGIT Git is not installed or not in the PATH

Git is installed and is in the path. Platform: Red Hat Enterprise Linux 5.8. >which git /usr/local/bin/git Yet bower can't find it: bower angular#1.0.6 ENOGIT git is not installed or not in t..

Is the buildSessionFactory() Configuration method deprecated in Hibernate

When I updated the Hibernate version from 3.6.8 to 4.0.0, I got a warning about deprecated method buildSessionFactory() in this line: private static final SessionFactory sessionFactory = new..

How to get Node.JS Express to listen only on localhost?

I have an application that I have behind a reverse proxy, I would like for it to only listen to localhost/ I expected this to work: app.listen(3001, 'localhost'); or app.listen(3001, '12..

Elegant way to read file into byte[] array in Java

Possible Duplicate: File to byte[] in Java I want to read data from file and unmarshal it to Parcel. In documentation it is not clear, that FileInputStream has method to read all its conten..

Set a cookie to never expire

Looking at the php documentation on setting a cookie I see that I can set an expiration date for the cookie. You can set the cookie to expire at the end of the browser session or at some time in the ..

How to lock orientation of one view controller to portrait mode only in Swift

Since my app got support for all orientation. I would like to lock only portrait mode to specific UIViewController. e.g. assume it was Tabbed Application and when SignIn View appear modally, I only w..

Use Fieldset Legend with bootstrap

I'm using Bootstrap for my JSP page. I want to use <fieldset> and <legend> for my form. This is my code. <fieldset class="scheduler-border"> <legend class="scheduler-border"..

Java 8 Filter Array Using Lambda

I have a double[] and I want to filter out (create a new array without) negative values in one line without adding for loops. Is this possible using Java 8 lambda expressions? In python it would be t..

Android ImageView setImageResource in code

I have an imageView that I want to display a little icon of the country that you are currently in. I can get the country code, but problem is I can't dynamically change the imageView resource. My imag..

Java: How to Indent XML Generated by Transformer

I'm using Java's built in XML transformer to take a DOM document and print out the resulting XML. The problem is that it isn't indenting the text at all despite having set the parameter "indent" expli..

How to remove a key from Hash and get the remaining hash in Ruby/Rails?

To add a new pair to Hash I do: {:a => 1, :b => 2}.merge!({:c => 3}) #=> {:a => 1, :b => 2, :c => 3} Is there a similar way to delete a key from Hash ? This works: {:a =>..

OperationalError, no such column. Django

I am very new to django and was able to finish the tutorial on without any errors. I am now going through the Django REST framework tutorial found at http://www.django-rest-framework..