Examples On Programing Languages

How to get the date from the DatePicker widget in Android?

I use a DatePicker widget in Android for the user to set a date, and want to get the date value when a confirm button is clicked, how can I do that?...

Meaning of "487 Request Terminated"

Please tell me when a SIP call return 487 Request Terminated? Is it a termination issue?...

Add space between cells (td) using css

I am trying to add a table with space between cell as the background colour of the cell is white and the background color of the table is blue, you can easily see that padding and margin are not working (I am applying it to the td), it will only add ...

Show and hide a View with a slide up/down animation

I have a LinearLayout that I want to show or hide with an Animation that pushes the layout upwards or downwards whenever I change its visibility. I've seen a few samples out there but none of them suit my needs. I have created two xml files for the...

MomentJS getting JavaScript Date in UTC

I am not able to get the JavaScript Date string for MongoDB record via the following. It keeps using my local time. var utc = moment.utc().valueOf(); console.log(moment.utc(utc).toDate()); Output: Tue Nov 11 2014 14:42:51 GMT-0500 (EST) I need ...

Check whether a request is GET or POST

Possible Duplicate: PHP detecting request type (GET, POST, PUT or DELETE) This should be an easy one. I have a script, and in the script I want to determine whether the request arrive via GET or POST method. What is the correct way to d...

Make Font Awesome icons in a circle?

I am using font awesome on some project but I have some things that I want to do with font awesome icons, I can easily call an icon like this: <i class="fa fa-lock"></i> Is it possible to all icon always be in round circle with...

How do I reference to another (open or closed) workbook, and pull values back, in VBA? - Excel 2007

Basically I need to gather a fair few figures from another workbook (Which is found and can be opened by a UserForm, therefore the location and names are variable). I need to use VBA for this as I also need to populate a chart with this data. I would...

SELECT only rows that contain only alphanumeric characters in MySQL

I'm trying to select all rows that contain only alphanumeric characters in MySQL using: SELECT * FROM table WHERE column REGEXP '[A-Za-z0-9]'; However, it's returning all rows, regardless of the fact that they contain non-alphanumeric characters....

How to INNER JOIN 3 tables using CodeIgniter

Can someone Tell me how to join 3 table with php? Example SELECT FROM table1, table2,table on INNERJOIN ------------------- let I have 3 table.(question table ,answer table and category table) Here is example form my webpage. Time remaining 30 mi...

How to find which version of Oracle is installed on a Linux server (In terminal)

I am in terminal in Redhat 5.5 and I need to find out which version of Oracle is installed. I am pretty new at Linux, but I have searched Google for a while and I can't find what I need. I have to locate which version is installed via terminal. I fou...

TSQL CASE with if comparison in SELECT statement

I would like to use CASE statement in SELECT. I select from user table, and (as one attribute) I also use nested SQL: SELECT registrationDate, (SELECT COUNT(*) FROM Articles WHERE userId = Users.userId) as articleNumber, hobbies, ... FR...

Footnotes for tables in LaTeX

When I do \footnote{} for a value in a table, the footnote doesn't show up. How do I get it to show up? Also, is it possible to get it to show up at the bottom of the table rather than the bottom of the page?...

How to use a WSDL

I need to consume a Web Service. They sent me the WSDL file. What should I do to add it to my website and start using it as the proxy. ( If I put it on a Virtual Directory it can be discovered, but does it grant me the connection with the real web s...

TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable

I am trying to map from a service call but getting an error. Looked at subscribe is not defined in angular 2? and it said that in order to subscribe we need to return from inside the operators. I have return statements as well. Here's my code: chec...

How to reverse apply a stash?

I have a small patch saved away in my git stash. I've applied it to my working copy using git stash apply. Now, I'd like to back out those changes by reverse applying the patch (kind of like what git revert would do but against the stash). Does an...

How to resolve cURL Error (7): couldn't connect to host?

I send an item code to a web service in xml format using cUrl(php). I get the correct response in localhost, but when do it server it shows cURL Error (7): couldn't connect to host And here's my code: function xml_post($post_xml, $url) { ...

How to get first N number of elements from an array

I am working with Javascript(ES6) /FaceBook react and trying to get the first 3 elements of an array that varies in size. I would like do the equivalent of Linq take(n). In my Jsx file I have the following: var items = list.map(i => { return ...

Bad operand type for unary +: 'str'

I cannot figure out a problem I am having with code written in Python 2.7. I am converting the references to ints, but I keep getting a type exception bad operand type for unary +: 'str'. Can anyone assist? import urllib2 import time import datetime...

How to create a XML object from String in Java?

I am trying to write a code that helps me to create a XML object. For example, I will give a string as input to a function and it will return me a XMLObject. XMLObject convertToXML(String s) {} When I was searching on the net, generally I saw exam...

node.js shell command execution

I am still trying to grasp the finer points of how I can run a linux or windows shell command and capture output within node.js; ultimately, I want to do something like this... //pseudocode output = run_command(cmd, args) The important piece is th...

What's the best way to loop through a set of elements in JavaScript?

In the past and with most my current projects I tend to use a for loop like this: var elements = document.getElementsByTagName('div'); for (var i=0; i<elements.length; i++) { doSomething(elements[i]); } I've heard that using a "reverse whil...

Unlimited Bash History

I want my .bash_history file to be unlimited. e.g. So I can always go back and see how I built/configured something, or what that nifty command was, or how some command broke something weeks ago. How do I change this setting?...

Authentication failed because remote party has closed the transport stream

I am developing a TCP client to connect OpenSSL server with the certificate authentication. I have using .crt and .key files shared by server team. These certificates are generated by OpenSSL commands. I am using SslStream object to authenticate the...

Sequelize OR condition object

By creating object like this var condition= { where: { LastName:"Doe", FirstName:["John","Jane"], Age:{ gt:18 } } } and pass it in Student.findAll(condition) .success(function(students){ }) It could beautif...

PHP page redirect

Can PHP make a redirect call after executing a function? I am creating a function on the completion of which I want it to redirect to a file located in the same root folder. Can it be done? if (...) { // I am using echo here. } else if ($_SESS...

How to set up Automapper in ASP.NET Core

I'm relatively new at .NET, and I decided to tackle .NET Core instead of learning the "old ways". I found a detailed article about setting up AutoMapper for .NET Core here, but is there a more simple walkthrough for a newbie?...

Throughput and bandwidth difference?

The throughput of a channel is a measure of amount of data actually moves through the channel. Why is it substantially less than the bandwidth of the channel?...

SASS :not selector

I have a :not css selector in SASS mixin but it doesn't do anything: Code Snippet: @mixin dropdown-pos($pos:right) { &:not(.notip) { @if $comp-tip == true{ @if $pos == right { top:$dropdown-width * -0.6; @include tip...

Ajax request returns 200 OK, but an error event is fired instead of success

I have implemented an Ajax request on my website, and I am calling the endpoint from a webpage. It always returns 200 OK, but jQuery executes the error event. I tried a lot of things, but I could not figure out the problem. I am adding my code below:...

Json.NET serialize object with root name

In my web app I'm using Newtonsoft.Json and I have following object [Newtonsoft.Json.JsonObject(Title = "MyCar")] public class Car { [Newtonsoft.Json.JsonProperty(PropertyName = "name")] public string Name{get;set;} [Newtonsoft.Json.Jso...

Sample random rows in dataframe

I am struggling to find the appropriate function that would return a specified number of rows picked up randomly without replacement from a data frame in R language? Can anyone help me out?...

Bootstrap Modal sitting behind backdrop

So I'm having nearly the exact same problem as @Jamescoo was but I think that my issue is coming from the fact that I have already positioned a couple of DIVs to create a sliding nav panel. Here's my exact setup replicated: http://jsfiddle.net/ZBQ8...

Collections sort(List<T>,Comparator<? super T>) method example

Possible Duplicate: Sorting Java objects using multiple keys I can't find any example of using this method, all examples give the second parameter "null". I heard that this method used for sorting classes according to more than one criteri...

How do I append to a table in Lua

I'm trying to figure out the equivalent of: foo = [] foo << "bar" foo << "baz" I don't want to have to come up with an incrementing index. Is there an easy way to do this?...

RegExp matching string not starting with my

For PMD I'd like to have a rule which warns me of those ugly variables which start with my. This means I have to accept all variables which do NOT start with my. So, I need a RegEx (re) which behaves as follows: re.match('myVar') == false re.ma...

Add Header and Footer for PDF using iTextsharp

How can I add header and footer for each page in the pdf. Headed will contain just a text Footer will contain a text and pagination for pdf (Page : 1 of 4) How is this possible ? I tried to add the below line, but header does not show up in pdf. d...

Excel VBA - Sum up a column

I'm trying to sum up a column in Excel VBA , however because there are blank spaces, I'm getting 0 as the sum. Dim rExternalTotal As Range , dExternalTotal as Double Set rExternalTotal = Range(rReportData.Offset(0, 0), rReportData.Offset(261, 0).End...

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

I'm newly at server development and have been started from easy tutorial by Lars Vogel. Servlet and JSP development with Eclipse WTP . Step by step accord this tutorial: installed Eclipse Java EE Kepler; installed tomcat 7 on Ubuntu 12.04 - htt...

Microsoft Excel ActiveX Controls Disabled?

I have some Excel worksheets that use ActiveX checkboxes to control certain activity. They worked recently but today started to give errors. I was alerted to this by a colleague, but it was still working on my computer. I checked his version of Ex...

How can I undo git reset --hard HEAD~1?

Is it possible to undo the changes caused by the following command? If so, how? git reset --hard HEAD~1 ...

Excel VBA App stops spontaneously with message "Code execution has been halted"

From what I can see on the web, this is a fairly common complaint, but answers seem to be rarer. The problem is this: We have a number of Excel VBA apps which work perfectly on a number of users' machines. However on one machine they stop on certain...

Twig ternary operator, Shorthand if-then-else

Does Twig support ternary (shorthand if-else) operator? I need some conditional logic like: {%if ability.id in company_abilities %} <tr class="selected"> {%else%} <tr> {%endif%} but using shorthand in Twig....

How to concatenate two IEnumerable<T> into a new IEnumerable<T>?

I have two instances of IEnumerable<T> (with the same T). I want a new instance of IEnumerable<T> which is the concatenation of both. Is there a build-in method in .Net to do that or do I have to write it myself?...

How do I set the maximum line length in PyCharm?

I am using PyCharm on Windows and want to change the settings to limit the maximum line length to 79 characters, as opposed to the default limit of 120 characters. Where can I change the maximum amount of characters per line in PyCharm?...

How to run a single RSpec test?

I have the following file: /spec/controllers/groups_controller_spec.rb What command in terminal do I use to run just that spec and in what directory do I run the command? My gem file: # Test ENVIRONMENT GEMS group :development, :test do gem ...

Determine path of the executing script

I have a script called foo.R that includes another script other.R, which is in the same directory: #!/usr/bin/env Rscript message("Hello") source("other.R") But I want R to find that other.R no matter what the current working directory. In other...

Make Bootstrap's Carousel both center AND responsive?

I want my carousel images to be at the center (horizontally), which is not by default. I follow the solution at this topic. However, using this solution, when the carousel is resized and smaller than the image, the image is cropped instead of scalin...

Sql server - log is full due to ACTIVE_TRANSACTION

I have a very large database (50+ GB). In order to free space in my hard drive, I tried deleting old records from one of the tables . I ran the command: delete from Table1 where TheDate<'2004-01-01'; However, SQL Server 2012 said: Msg 9002, Le...

Change bootstrap datepicker date format on select

I'm using bootstrap datepicker on a textbox. The default format of the date when you select a date is mm/dd/yyyy. Now I want to change it to dd/mm/yyyy. How can I accomplish this. Right now I'm just initializing it just like this. $('.datepicker')....

Replace all double quotes within String

I am retrieving data from a database, where the field contains a String with HTML data. I want to replace all of the double quotes such that it can be used for parseJSON of jQuery. Using Java, I am trying to replace the quotes using.. details.repla...

iOS Safari – How to disable overscroll but allow scrollable divs to scroll normally?

I'm working on an iPad-based web app, and need to prevent overscrolling so that it seems less like a web page. I'm currently using this to freeze the viewport and disable overscroll: document.body.addEventListener('touchmove',function(e){ e.pr...

How do I change a single value in a data.frame?

Could anyone explain how to change a single cell in a data.frame to something else. Basically I just want to rename that one cell, not all cells which matches it. I can´t use the edit() command because it will screw up my script since im using the d...

How to display line numbers in 'less' (GNU)

What is the command to make less display line numbers in the left column?...

How to read a Parquet file into Pandas DataFrame?

How to read a modestly sized Parquet data-set into an in-memory Pandas DataFrame without setting up a cluster computing infrastructure such as Hadoop or Spark? This is only a moderate amount of data that I would like to read in-memory with a simple P...

How to get the current directory of the cmdlet being executed

This should be a simple task, but I have seen several attempts on how to get the path to the directory where the executed cmdlet is located with mixed success. For instance, when I execute C:\temp\myscripts\mycmdlet.ps1 which has a settings file at C...

How can I solve equations in Python?

Let's say I have an equation: 2x + 6 = 12 With algebra we can see that x = 3. How can I make a program in Python that can solve for x? I'm new to programming, and I looked at eval() and exec() but I can't figure out how to make them do what I want....

Is there a way to rollback my last push to Git?

Possible Duplicates: Undoing a 'git push' I have pushed some bad code, and I am the only user of the repository. How can I rollback my last commit?...

Create Table from View

I have a view that I want to create a table from in SQL Enterprise Manager, but I always get an error when I run this query: CREATE TABLE A AS (SELECT top 10 FROM dbo.myView) So far the error is: "syntax error at 'as'" View is too large. Is it ...

PostgreSQL: ERROR: operator does not exist: integer = character varying

Here i am trying to create view as shown below in example: Example: create view view1 as select table1.col1,table2.col1,table3.col3 from table1 inner join table2 inner join table3 on table1.col4 = table2.col5 /* Here col4 of tabl...

How to 'grep' a continuous stream?

Is that possible to use grep on a continuous stream? What I mean is sort of a tail -f <file> command, but with grep on the output in order to keep only the lines that interest me. I've tried tail -f <file> | grep pattern but it seems th...

stop all instances of node.js server

This is my first time working with Node.js and I ran into this problem: I have started a Node server through the plugin of an IDE. Unfortunately, I cannot use the IDE's terminal. So I tried to run the script from the command line. This is the probl...

Trigger validation of all fields in Angular Form submit

I'm using this method: http://plnkr.co/edit/A6gvyoXbBd2kfToPmiiA?p=preview to only validate fields on blur. This works fine, but I would also like to validate them (and thus show the errors for those fields if any) when the user clicks the 'submit' b...

Errors in pom.xml with dependencies (Missing artifact...)

A friend has passed me a Maven project that I'm trying to run locally in my computer. All that I have done in Eclipse, I selected: File -> Import -> Existing Maven Projects After that, the project showed me 4 errors in my pom.xml (Missing artif...

How to get multiple counts with one SQL query?

I am wondering how to write this query. I know this actual syntax is bogus, but it will help you understand what I am wanting. I need it in this format, because it is part of a much bigger query. SELECT distributor_id, COUNT(*) AS TOTAL, COUNT(*)...

CSS - Make divs align horizontally

I have a container div with a fixed width and height, with overflow: hidden. I want a horizontal row of float: left divs within this container. Divs which are floated left will naturally push onto the 'line' below after they read the right bound of ...

Tkinter: How to use threads to preventing main event loop from "freezing"

I have a small GUI test with a "Start" button and a Progress bar. The desired behavior is: Click Start Progressbar oscillates for 5 seconds Progressbar stops The observed behavior is the "Start" button freezes for 5 seconds, then a Progressbar is...

How can I get a list of locally installed Python modules?

I would like to get a list of Python modules, which are in my Python installation (UNIX server). How can you get a list of Python modules installed in your computer?...

Error checking for NULL in VBScript

I have the following VBScript in a Classic ASP page: function getMagicLink(fromWhere, provider) dim url url = "magic.asp?fromwhere=" & fromWhere If Not provider is Nothing Then ' Error occurs here url = url & "&provi...

ActionController::InvalidAuthenticityToken

Below is an error, caused by a form in my Rails application: Processing UsersController#update (for **ip** at 2010-07-29 10:52:27) [PUT] Parameters: {"commit"=>"Update", "action"=>"update", "_method"=>"put", "authenticity_token"=>"ysiD...

Command to close an application of console?

I need to close the console when the user selects a menu option. I tried using close() but it did not work.. how can I do this?...

Android screen size HDPI, LDPI, MDPI

I have a background that I need fit in all screen sizes. I have three folders, hdpi, ldpi and mdpi for drawables, but in the emulator there isn't any referense to what resolution hdpi is and what mdpi and ldpi are....

How do you attach and detach from Docker's process?

I can attach to a docker process but Ctrl+c doesn't work to detach from it. exit basically halts the process. What's the recommended workflow to have the process running, occasionally attaching to it to make some changes, and then detaching?...

What is the most efficient way to store tags in a database?

I am implementing a tagging system on my website similar to one stackoverflow uses, my question is - what is the most effective way to store tags so that they may be searched and filtered? My idea is this: Table: Items Columns: Item_ID, Title, Cont...

Spring 3 MVC accessing HttpRequest from controller

I would like to handle request and session attributes myself rather then leave it to spring @SessionAttributes, for login of cookies handling for example. I just cant figure out how could I access the HttpRequest from within a controller, I need a ...

scrollbars in JTextArea

How do I add scrollbars to a JTextArea?...

Node.js: How to read a stream into a buffer?

I wrote a pretty simple function that downloads an image from a given URL, resize it and upload to S3 (using 'gm' and 'knox'), I have no idea if I'm doing the reading of a stream to a buffer correctly. (everything is working, but is it the correct wa...

How to show git log history (i.e., all the related commits) for a sub directory of a git repo?

Lets say that I have a git repo that looks like this. foo/ .git/ A/ ... big tree here B/ ... big tree here Is there a way to ask git log to show only the log messages for a specific directory. For example I want to see what commits tou...

System.BadImageFormatException An attempt was made to load a program with an incorrect format

I'm writing a plug-in for another program that is based on a public .NET API. Typically these plugins are made by creating a class library DLL that references the API assembly. Then a command class is created by inheriting from a base command class i...

Get full path without filename from path that includes filename

Is there anything built into System.IO.Path that gives me just the filepath? For example, if I have a string @"c:\webserver\public\myCompany\configs\promo.xml", is there any BCL method that will give me "c:\webserver\public\myCompany\con...

Python logging: use milliseconds in time format

By default logging.Formatter('%(asctime)s') prints with the following format: 2011-06-09 10:54:40,638 where 638 is the millisecond. I need to change the comma to a dot: 2011-06-09 10:54:40.638 To format the time I can use: logging.Formatter(fm...

Could not load file or assembly 'System.Data.SQLite'

I've installed ELMAH 1.1 .Net 3.5 x64 in my ASP.NET project and now I'm getting this error (whenever I try to see any page): Could not load file or assembly 'System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44f...

Difference between CLOCK_REALTIME and CLOCK_MONOTONIC?

Could you explain the difference between CLOCK_REALTIME and CLOCK_MONOTONIC clocks returned by clock_gettime() on Linux? Which is a better choice if I need to compute elapsed time between timestamps produced by an external source and the current tim...

SQL Server: the maximum number of rows in table

I develop software that stores a lot of data in one of its database tables (SQL Server version 8, 9 or 10). Let's say, about 100,000 records are inserted into that table per day. This is about 36 million records per year. For fear that I would lose o...

Wrapping a react-router Link in an html button

Using suggested method: This is the result: A link in the button, Code in between comment lines I was wondering if there is a way to wrap a Link element from 'react-router' in an HTML button tag using react. I currently have Link components to navi...

Renew Provisioning Profile

Just got a notice that the provisioning profile for one of my apps is about to expire. Is there some way I can renew the existing one or must I recreate a new one?...

403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied

I have my website. First time I can succesfully login. Default address: www.abc.com I typed this on browser and I redirected to my login page: www.abc.com/pages/landingpage.aspx I entered my login credential and log into the site. After some ti...

DateTime.TryParse issue with dates of yyyy-dd-MM format

I have the following date in string format "2011-29-01 12:00 am" . Now I am trying to convert that to datetime format with the following code: DateTime.TryParse(dateTime, out dt); But I am alwayws getting dt as {1/1/0001 12:00:00 AM} , Can you p...

How to check if std::map contains a key without doing insert?

The only way I have found to check for duplicates is by inserting and checking the std::pair.second for false, but the problem is that this still inserts something if the key is unused, whereas what I want is a map.contains(key); function....

Angular: How to update queryParams without changing route

I am trying to update (add, remove) queryParams from a component. In angularJS, it used to be possible thanks to : $location.search('f', 'filters[]'); // setter $location.search()['filters[]']; // getter I have an app with a list that the user ...

How to comment/uncomment in HTML code

Often while coding view templates in html, my habit of adding some helpful comments causes lots of time-consuming effort while testing. Consider this code... <!-- Here starts the sidebar --> <div id="sidebar"> .... </div> <!--...

how to redirect to home page

How can I redirect a user to home page? Example: mywebsite.com/ddfdf/fdfdsf and I want to redirect to mywebsite.com However I want to do it without typing the static name. How can I do this?...

How to change target build on Android project?

I currently have an Android project in Eclipse. I created it with a target build of 1.5 (sdk 3). Now I want to change it so that it has a minSdk of 3 and targetSdk of 8. To do this I see that I must build against the newest SDK (2.2) To do this i...

How do SETLOCAL and ENABLEDELAYEDEXPANSION work?

I notice in most scripts, the two are usually in the same line as so: SETLOCAL ENABLEDELAYEDEXPANSION Are the two in fact separate commands and can be written on separate lines? Will setting ENABLEDELAYEDEXPANSION have an adverse effect on a scri...

lambda expression for exists within list

If I want to filter a list of objects against a specific id, I can do this: list.Where(r => r.Id == idToCompare); What if, instead of a single idToCompare, I have a list of Ids to compare against? What is the syntax for comparing against a ...

Redraw datatables after using ajax to refresh the table content?

I am using Datatables and have a button on the page that refreshes the table using AJAX. To be clear the table isn't using an ajax source of data, we are just using ajax to refresh it only when needed. Ajax is refreshing the div which the table is wr...

PowerShell: Run command from script's directory

I have a PowerShell script that does some stuff using the script’s current directory. So when inside that directory, running .\script.ps1 works correctly. Now I want to call that script from a different directory without changing the referencing d...

How to delete all files older than 3 days when "Argument list too long"?

I've got a log file directory that has 82000 files and directories in it (about half and half). I need to delete all the file and directories which are older than 3 days. In a directory that has 37000 files in it, I was able to do this with: find ...

How to get folder directory from HTML input type "file" or any other way?

So I have a basic form input with the type "file" however I want the user to be able to select a folder location and not a file. How can I get this input to select a folder and not a file, or is there another way to do it?...

Printing the correct number of decimal points with cout

I have a list of float values and I want to print them with cout with 2 decimal places. For example: 10.900 should be printed as 10.90 1.000 should be printed as 1.00 122.345 should be printed as 122.34 How can I do this? ( setprecision doesn'...

Use python requests to download CSV

Here is my code: import csv import requests with requests.Session() as s: s.post(url, data=payload) download = s.get('url that directly download a csv report') This gives me the access to the csv file. I tried different method to deal wit...

copy db file with adb pull results in 'permission denied' error

I just rooted my Nexus 5 using this method: http://www.phonearena.com/news/How-to-root-Google-Nexus-5_id49014 I also enabled USB debugging in the developer options. Then I tried to pull a database file from my device using this command: adb pull...

enable/disable zoom in Android WebView

There are some methods in WebSettings related to zoom: WebSettings.setSupportZoom WebSettings.setBuiltInZoomControls I noticed they work differently on some devices. For example, on my Galaxy S pinch to zoom is enabled by default, but on LG P500 ...

Reset auto increment counter in postgres

I would like to force the auto increment field of a table to some value, I tried with this: ALTER TABLE product AUTO_INCREMENT = 1453 AND ALTER SEQUENCE product RESTART WITH 1453; ERROR: relation "your_sequence_name" does not exist I'm new t...

Textarea Auto height

I want to make height of textarea equal to height of the text within it (And remove the scroll bar) HTML <textarea id="note">SOME TEXT</textarea> CSS textarea#note { width:100%; direction:rtl; display:block; max-width...

How can I initialize base class member variables in derived class constructor?

Why can't I do this? class A { public: int a, b; }; class B : public A { B() : A(), a(0), b(0) { } }; ...

Merging dataframes on index with pandas

I have two dataframes and each one has two index columns. I would like to merge them. For example, the first dataframe is the following: V1 A 1/1/2012 12 2/1/2012 14 B 1/1/2012 15 2/1/2012 8 C ...

Access Google's Traffic Data through a Web Service

Is there a way I can access traffic data that Google provides through a web service? There seems to be a GTrafficOverlay that puts traffic on top of a route on an embedded google map, but no direct web service that I can consume to, say, give the so...

Floating Point Exception C++ Why and what is it?

I'm building a program for the Euler projects question 3, and while that might not really matter as a result I'm current trying to make this code take a number and test if it is prime or not. Now then before I get to troubleshoot the function it give...

How to delete a cookie?

Is my function of creating a cookie correct? How do I delete the cookie at the beginning of my program? is there a simple coding? function createCookie(name,value,days) function setCookie(c_name,value,1) { document.cookie = c_name + "=" +escap...

C Programming: How to read the whole file contents into a buffer

I want to write the full contents of a file into a buffer. The file actually only contains a string which i need to compare with a string. What would be the most efficient option which is portable even on linux. ENV: Windows...

Fastest way to get the first n elements of a List into an Array

What is the fastest way to get the first n elements of a list stored in an array? Considering this as the scenario: int n = 10; ArrayList<String> in = new ArrayList<>(); for(int i = 0; i < (n+10); i++) in.add("foobar"); Option 1:...

Call a function after previous function is complete

I have the following JavaScript code: $('a.button').click(function(){ if (condition == 'true'){ function1(someVariable); function2(someOtherVariable); } else { doThis(someVariable); } }); How can I ensure th...

How to install bcmath module?

How do I install the bcmath module on a server? I tried yum update php-bcmath but it said it found nothing....

How to implement a ViewPager with different Fragments / Layouts

When I start an activity which implements viewpager, the viewpager created various fragments. I want to use different layouts for each fragment, but the problem is that viewpager shows only two layouts at the max (second layout on all of the remainin...

What does $(function() {} ); do?

Sometimes I make a function and call the function later. Example: function example { alert('example'); } example(); // <-- Then call it later Somehow, some functions cannot be called. I have to call those functions inside: $(function() { }); ...

What is the JUnit XML format specification that Hudson supports?

I have Hudson as continuous integration server and I want to use option 'Publish JUnit test result report'. But I don't use xUnit tools for testing, instead of that i have shell scripts which run tests and return results in simple format. I am thinki...

The ALTER TABLE statement conflicted with the FOREIGN KEY constraint

I have a problem when trying to add a foreign key to my tblDomare table; what am I doing wrong here? CREATE TABLE tblDomare (PersNR VARCHAR (15) NOT NULL, fNamn VARCHAR (15) NOT NULL, eNamn VARCHAR (20) NOT NULL, Erfarenhet VARCHAR (5), PRIMARY KEY ...

Python+OpenCV: cv2.imwrite

I'm trying to detect a face and write down area with the face in a separate file. How can I do it? I think that i must use "faces" (you can see this var in code). But how? from ffnet import mlgraph, ffnet, tmlgraph, imlgraph import pylab import sys ...

Are there best practices for (Java) package organization?

A little while ago, I saw a question answered here regarding the fine-grained organization of java packages. For example, my.project.util, my.project.factory, my.project.service, etc. I can't find it now, so I may as well ask the question. Are the...

How to rotate the background image in the container?

I want to rotate the image which is placed in the button of scrollbar in Chrome. Now I have a CSS with this content: ::-webkit-scrollbar-button:vertical:decrement { background-image:url(images/arrowup.png) ; -webkit-transform:rotate(120deg);...

How to run the sftp command with a password from Bash script?

I need to transfer a log file to a remote host using sftp from a Linux host. I have been provided credentials for the same from my operations group. However, since I don't have control over other host, I cannot generate and share RSA keys with the ot...

Convert Unicode to ASCII without errors in Python

My code just scrapes a web page, then converts it to Unicode. html = urllib.urlopen(link).read() html.encode("utf8","ignore") self.response.out.write(html) But I get a UnicodeDecodeError: Traceback (most recent call last): File "/Applications...

Redirect parent window from an iframe action

What JavaScript do I need to use to redirect a parent window from an iframe? I want them to click a hyperlink which, using JavaScript or any other method, would redirect the parent window to a new URL....

ssh "permissions are too open" error

I had a problem with my mac where I couldn't save any kind of file on the disk anymore. I had to reboot OSX lion and reset the permissions on files and acls. But now when I want to commit a repository I get the following error from ssh: Permissions...

Object of custom type as dictionary key

What must I do to use my objects of a custom type as keys in a Python dictionary (where I don't want the "object id" to act as the key) , e.g. class MyThing: def __init__(self,name,location,length): self.name = name self...

Is gcc's __attribute__((packed)) / #pragma pack unsafe?

In C, the compiler will lay out members of a struct in the order in which they're declared, with possible padding bytes inserted between members, or after the last member, to ensure that each member is aligned properly. gcc provides a language exten...

Importing JSON into an Eclipse project

I'm an aspiring Java programmer looking to use JSON in a project. I was following a programming tutorial (from a book) which asked me to import JSON into my project by using the following line: import com.google.appengine.repackaged.org.json.JSONArr...

Location of sqlite database on the device

I've created a sqlite database programmatically with the default way of extending SQLiteOpenHelper and overriding onCreate(). This way the db gets created on the fly when needed. I'd like to check the contents of the db file on my OS X machine with ...

What does '&' do in a C++ declaration?

I am a C guy and I'm trying to understand some C++ code. I have the following function declaration: int foo(const string &myname) { cout << "called foo for: " << myname << endl; return 0; } How does the function signature...

how to kill hadoop jobs

I want to kill all my hadoop jobs automatically when my code encounters an unhandled exception. I am wondering what is the best practice to do it? Thanks...

How to handle the `onKeyPress` event in ReactJS?

How can I make the onKeyPress event work in ReactJS? It should alert when enter (keyCode=13) is pressed. var Test = React.createClass({ add: function(event){ if(event.keyCode == 13){ alert('Adding....'); } }, ...

Unzip files (7-zip) via cmd command

I try to unzip a file via CMD. So I install WinZip (and its plugin to cmd), WinRAR, and 7-zip. But when I try to execute a command via the CMD: 7z e myzip.zip It gives the next error: 7z is not recognized as an internal or external command In...

How to use the ProGuard in Android Studio?

This is my first project in Android Studio, and the code of my apps are not obfuscated. Im using this configuration in build.gradle file: I'm using the Build > Generate Signed APK... with the Run Proguard checked. And, when I have tested using the ...

How can I use the python HTMLParser library to extract data from a specific div tag?

I am trying to get a value out of a HTML page using the python HTMLParser library. The value I want to get hold of is within this html element: ... <div id="remository">20</div> ... This is my HTMLParser class so far: class LinksParse...

Get current date/time in seconds

How do I get the current date/time in seconds in Javascript?...

Work with a time span in Javascript

Using Date.js already, but can also use another library if necessary. Not sure what is the best way to work with time deltas. Specifically, I want to display the time that has elapsed between now and a past date-time. So I need to do something like...

How can I initialize a String array with length 0 in Java?

The Java Docs for the method String[] java.io.File.list(FilenameFilter filter) includes this in the returns description: The array will be empty if the directory is empty or if no names were accepted by the filter. How do I do a similar thing a...

What is the relative performance difference of if/else versus switch statement in Java?

Worrying about my web application's performances, I am wondering which of "if/else" or switch statement is better regarding performance?...

How can I edit a view using phpMyAdmin 3.2.4?

I need to simply edit a very complicated view in phpMyAdmin 3.2.4 but I cannot figure how to do that. Any suggestions? Thanks!...

What is the Difference Between Mercurial and Git?

I've been using git for some time now on Windows (with msysGit) and I like the idea of distributed source control. Just recently I've been looking at Mercurial (hg) and it looks interesting. However, I can't wrap my head around the differences betwee...

Trying to use Spring Boot REST to Read JSON String from POST

Am using the latest version of Spring Boot to read in a sample JSON via Restful Web Service... Here's my pom.xml: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation=...

How to merge two arrays of objects by ID using lodash?

I have two array with one common field member. how can I merge theme easily? For example: var arr1 = [{ "member" : ObjectId("57989cbe54cf5d2ce83ff9d6"), "bank" : ObjectId("575b052ca6f66a5732749ecc"), "country" : ObjectId("575b0523a6f66a573274...

How do I get cURL to not show the progress bar?

I'm trying to use cURL in a script and get it to not show the progress bar. I've tried the -s, -silent, -S, and -quiet options, but none of them work. Here's a typical command I've tried: curl -s http://google.com > temp.html I only get the ...

How do you convert a byte array to a hexadecimal string in C?

I have: uint8 buf[] = {0, 1, 10, 11}; I want to convert the byte array to a string such that I can print the string using printf: printf("%s\n", str); and get (the colons aren't necessary): "00:01:0A:0B" Any help would be greatly appreciated...

Update my gradle dependencies in eclipse

I have a simple gradle project in my eclipse. I update the build.gradle to include a few apache http jars... dependencies { compile group: 'commons-collections', name: 'commons-collections', version: '3.2' compile 'org.apache.httpcomponents:...

What is the difference between HTML tags and elements?

I notice that most people use the words HTML tags and HTML elements interchangeably. But what is the difference between them? The way I see it is that tags are in the source code and elements are processed tags (by the browser) in the DOM. Am I w...

Angular no provider for NameService

I've got a problem loading a class into an Angular component. I've been trying to solve it for a long time; I've even tried joining it all in a single file. What I have is: Application.ts /// <reference path="../typings/angular2/angular2.d.ts" /...

AngularJS - Animate ng-view transitions

I have 2 html pages, welcome.html and login.html both of which are "inserted" into index.html dependending on the URL via an ngview attribute and router provider, as part of my AngularJS app. An example of this can be found on the AngularJS home pag...

Integer.valueOf() vs. Integer.parseInt()

Aside from Integer.parseInt() handling the minus sign (as documented), are there any other differences between Integer.valueOf() and Integer.parseInt()? And since neither can parse , as a decimal thousands separator (produces NumberFormatException),...

Trying to check if username already exists in MySQL database using PHP

I've looked at the many other posts that were similar to my issue and implemented their solutions (as far as I can tell) as exactly as I could. However, every time I execute this script, the code in the else block is executed (even when the username ...

SELECT query with CASE condition and SUM()

I'm currently using these sql statements. My table has the field CPaymentType which contains "Cash" or "Check". I can sum up the amount of payments by executing 2 SQL statements as shown below. In this case, the user won't even notice the speed diffe...

What is external linkage and internal linkage?

I want to understand the external linkage and internal linkage and their difference. I also want to know the meaning of const variables internally link by default unless otherwise declared as extern. ...

ArrayList - How to modify a member of an object?

I have a number of Customer objects stored in an ArrayList. My Customer class has 2 data members: Name and Email. Now I want to modify just the Email for Customer "Doe". Now if "Doe" is located at index 3 in the list, I know I can write this line: ...

Console output in a Qt GUI app?

I have a Qt GUI application running on Windows that allows command-line options to be passed and under some circumstances I want to output a message to the console and then quit, for example: int main(int argc, char *argv[]) { QApplication a(argc,...

Setting the classpath in java using Eclipse IDE

I have an Eclipse project with an external folder containing a lot of JAR files (legacy libraries) . instead of adding all the jars in Eclipse ("add external Jar"), I would prefer to add a ref to this external folder. In the "configure build bath", I...

Build Maven Project Without Running Unit Tests

How do you build a Maven project without running unit tests? Currently restructuring some code I have for a Servlet and would like to try it out in my web browser (which means running mvn install to get the .war to upload to Tomcat). I'm fully aware...

Writing data to a local text file with javascript

I have created a procedure to write content to a text file in my local machine. <form id="addnew"> <input type="text" class="id"> <input type="text" class="content"> <input type="submit" value="Add"> </form>...

What programming languages can one use to develop iPhone, iPod Touch and iPad (iOS) applications?

What programming languages can one use to develop iPhone, iPod Touch and iPad (iOS) applications? Also are there plans in the future to expand the amount of programming languages that iOS will support?...

How to install pip for Python 3.6 on Ubuntu 16.10?

I'd like to start by pointing out that this question may seem like a duplicate, but it isn't. All the questions I saw here were regarding pip for Python 3 and I'm talking about Python 3.6. The steps used back then don't work for Python 3.6. I got a...

How do I POST a x-www-form-urlencoded request using Fetch?

I have some parameters that I want to POST form-encoded to my server: { 'userName': '[email protected]', 'password': 'Password!', 'grant_type': 'password' } I'm sending my request (currently without parameters) like this var obj = { me...

Set margins in a LinearLayout programmatically

I'm trying to use Java (not XML) to create a LinearLayout with buttons that fill the screen, and have margins. Here is code that works without margins: LinearLayout buttonsView = new LinearLayout(this); buttonsView.setOrientation(LinearLayout.VERTIC...

How to get element by innerText

How to get tag in html page, if I know what text tag contains. E.g.: <a ...>SearchingText</a> ...

Python re.sub replace with matched content

Trying to get to grips with regular expressions in Python, I'm trying to output some HTML highlighted in part of a URL. My input is images/:id/size my output should be images/<span>:id</span>/size If I do this in Javascript method ...

How can I rename a project folder from within Visual Studio?

My current solution for renaming the project folder is: Remove the project from the solution. Rename the folder outside Visual Studio. Re-add the project to the solution. Is there a better way?...

Allowed memory size of X bytes exhausted

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 13965430 bytes) PHPInfo shows that I have a memory_limit of 128M, so I'm confused as to why the error says I only have 64M. Is it possible for phpinfo to report inco...

Crop image to specified size and picture location

I have an image that is being taken using AVCaptureSession and being returned to my view controller. Here is a screen shot of the camera interface: The AVCaptureSession takes the FULL SCREEN photo, and now I want to crop it down to the size of t...

Merge two (or more) lists into one, in C# .NET

Is it possible to convert two or more lists into one single list, in .NET using C#? For example, public static List<Product> GetAllProducts(int categoryId){ .... } . . . var productCollection1 = GetAllProducts(CategoryId1); var productCollec...

How to check for null in Twig?

What construct should I use to check whether a value is NULL in a Twig template?...

How do I get this javascript to run every second?

How do I get this javascript to run every second? source code: <script type="text/javascript"> $(function() { //More Button $('.more').live("click",function() { var ID = $(this).attr("id"); ...

Disable click outside of angular material dialog area to close the dialog (With Angular Version 4.0+)

I am currently working on password reset page of an Angular 4 project. We are using Angular Material to create the dialog, however, when the client clicks out of the dialog, it will close automatically. Is there a way to avoid the dialog close until ...

What is the correct way to declare a boolean variable in Java?

I have just started learning Java. In the online course I am following, I am asked to try the following code: String email1 = "[email protected]"; String email2 = "[email protected]"; Boolean isMatch = false; isMatch = email1.equals (email2); if (isMatch == t...

Using Java with Microsoft Visual Studio 2012

I started as a C++ programmer, and Visual studio has worked splendedly for me. However, I recently have wanted to branch out to C# and Java. Visual studio supports C# and I now have some experience with it, but it does not support Java. Does anyone h...

Find which commit is currently checked out in Git

I'm in the middle of a git bisect session. What's the command to find out which commit (SHA1 hash) I am currently on? git status does not provide this. Edit: I guess calling git log and looking at first entry works? ...

Joining Spark dataframes on the key

I have constructed two dataframes. How can we join multiple Spark dataframes ? For Example : PersonDf, ProfileDf with a common column as personId as (key). Now how can we have one Dataframe combining PersonDf and ProfileDf? ...

String replacement in java, similar to a velocity template

Is there any String replacement mechanism in Java, where I can pass objects with a text, and it replaces the string as it occurs. For example, the text is : Hello ${user.name}, Welcome to ${site.name}. The objects I have are "user" and "site"...

FirstOrDefault returns NullReferenceException if no match is found

Here is my code: string displayName = Dictionary.FirstOrDefault(x => x.Value.ID == long.Parse(options.ID)).Value.DisplayName; The code works fine if x.Value.ID matches options.ID. However, I get a NullReferenceException if it doesn't....

MySQL server has gone away - in exactly 60 seconds

I recently discovered that a sql query that was running fine earlier is now timing out after 60 seconds and throwing an error. The query is slow but runs as part of a nightly job so that's not a problem in itself (so please don't suggest I optimize i...

Matplotlib make tick labels font size smaller

In a matplotlib figure, how can I make the font size for the tick labels using ax1.set_xticklabels() smaller? Further, how can one rotate it from horizontal to vertical?...

Simple mediaplayer play mp3 from file path?

I have a very simple mediaplayer that play background. It calls file from the apk, but I want it to play from any directory like as music or sdcard. Here are my codes: private MediaPlayer mpintro; . . mpintro = MediaPlayer.create(this, R.raw.intr...

KeyListener, keyPressed versus keyTyped

I have a JFrame (well, a class which extends JFrame) and I want to do an action when I press the F5 key. So, I made the class implement KeyListener. And with that, came three methods, keyPressed, keyReleased, and keyTyped. Which of these methods sho...

Referring to the null object in Python

How do I refer to the null object in Python?...

JTable - Selected Row click event

I have a Jtable that is populated with a linkedlist through an AbstractTableModel. What I want to do is when I click (left-mouse click) on a row in the JTable, the linkedlist is search (in this case it contains movie titles) and displays the values ...

"Uncaught TypeError: undefined is not a function" - Beginner Backbone.js Application

I'm setting up a pretty simple app with backbone, and I'm getting an error. Uncaught TypeError: undefined is not a function example_app.js:7 ExampleApp.initialize example_app.js:7 (anonymous function) This is where the error is showing up in Chrom...

Why use the INCLUDE clause when creating an index?

While studying for the 70-433 exam I noticed you can create a covering index in one of the following two ways. CREATE INDEX idx1 ON MyTable (Col1, Col2, Col3) -- OR -- CREATE INDEX idx1 ON MyTable (Col1) INCLUDE (Col2, Col3) The INCLUDE clause ...

How can I add to a List's first position?

I just have a List<> and I would like to add an item to this list but at the first position. List.add() add the item at the last.. How can I do that?.. Thanks for help!...

Use different Python version with virtualenv

I have a Debian system currently running with python 2.5.4. I got virtualenv properly installed, everything is working fine. Is there a possibility that I can use a virtualenv with a different version of Python? I compiled Python 2.6.2 and would lik...

Checking if output of a command contains a certain string in a shell script

I'm writing a shell script, and I'm trying to check if the output of a command contains a certain string. I'm thinking I probably have to use grep, but I'm not sure how. Does anyone know?...

What is hashCode used for? Is it unique?

I notice there is a getHashCode() method in every controls, items, in WP7, which return a sequence of number. Can I use this hashcode to identify an item? For example I want to identify a picture or a song in the device, and check it whereabout. This...

Ruby: How to iterate over a range, but in set increments?

So I'm iterating over a range like so: (1..100).each do |n| # n = 1 # n = 2 # n = 3 # n = 4 # n = 5 end But what I'd like to do is iterate by 10's. So in stead of increasing n by 1, the next n would actually be 10, then 20, 30...

Get text from pressed button

How can I get the text from a pressed button? (Android) I can get the text from a button: String buttonText = button.getText(); I can get the id from a pressed button: int buttinID = view.getId(); What I can't find out at this moment is how to...

Change first commit of project with Git?

I want to change something in the first commit of my project with out losing all subsequent commits. Is there any way to do this? I accidentally listed my raw email in a comment within the source code, and I'd like to change it as I'm getting spamme...

How to align form at the center of the page in html/css

I am new to html/css. i am trying to build up my own form and i am trying to align it in the center. I used the align property in css but its not working. Html code: <!DOCTYPE HTML> <head> <title>Web Page Having A Form</tit...

Can I pass column name as input parameter in SQL stored Procedure

create procedure sp_First @columnname varchar AS begin select @columnname from Table_1 end exec sp_First 'sname' My requirement is to pass column names as input parameters. I tried like that but it gave wrong output. So Help me...

How to print to console using swift playground?

I have been following the Apple Guide for their new language swift, but I don't understand why the bar on the right is only showing "Hello, playground" and not "Hello, world". Can someone explain why the println isn't being printed on the right? // ...

Casting variables in Java

I wonder if anyone could tell me how casting works? I understand when I should do it, but not really how it works. On primitive data types I understand partially but when it comes to casting objects I don't understand how it works. How can a object ...

Cannot use mkdir in home directory: permission denied (Linux Lubuntu)

I am trying to create a directory in my home directory on Linux using the mkdir command, but am getting a 'permission denied' error. I have recently installed Lubuntu on my laptop, and have the only user profile on the computer. Here's what happene...

JQuery datepicker not working

Good day! I am trying to use jquery for the first time. And i cannot make it work. My code is as follows: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://ww...

Node.js: Gzip compression?

Am I wrong in finding that Node.js does no gzip compression and there are no modules out there to perform gzip compression? How can anyone use a web server that has no compression? What am I missing here? Should I try to—gasp—port the alg...

How should I unit test multithreaded code?

I have thus far avoided the nightmare that is testing multi-threaded code since it just seems like too much of a minefield. I'd like to ask how people have gone about testing code that relies on threads for successful execution, or just how people h...

Type or namespace name does not exist

I have a WCF Data Service project built with Visual Studio 2010, which was working fine. All of a sudden, it didn't compile anymore. It was giving me messages like: Error 7 The type or namespace name 'Services' does not exist in the namespace 'Sys...

Pretty-Printing JSON with PHP

I'm building a PHP script that feeds JSON data to another script. My script builds data into a large associative array, and then outputs the data using json_encode. Here is an example script: $data = array('a' => 'apple', 'b' => 'banana', 'c' ...

Error type 3 Error: Activity class {} does not exist

I have an IntelliJ Android project, that I successfully imported to Android Studio 0.4.0. It works perfectly if I don't change anything in manifest. However, when I want to change the launcher activity and run, it fails with this error: Launching ap...

Which is the preferred way to concatenate a string in Python?

Since Python's string can't be changed, I was wondering how to concatenate a string more efficiently? I can write like it: s += stringfromelsewhere or like this: s = [] s.append(somestring) later s = ''.join(s) While writing this question, I...

Find a file with a certain extension in folder

Given a folder path (like C:\Random Folder), how can I find a file in it that holds a certain extension, like txt? I assume I'll have to do a search for *.txt in the directory, but I'm not sure how I'm supposed to start this search in the first place...

Injecting $scope into an angular service function()

I have a Service: angular.module('cfd') .service('StudentService', [ '$http', function ($http) { // get some data via the $http var path = 'data/people/students.json'; var students = $http.get(path).then(function (resp) { ret...

LINQ's Distinct() on a particular property

I am playing with LINQ to learn about it, but I can't figure out how to use Distinct when I do not have a simple list (a simple list of integers is pretty easy to do, this is not the question). What I if want to use Distinct on a list of an Object on...

How to make my font bold using css?

I'm very new to HTML and CSS and I was just wondering how I could make my font bold using CSS. I have a plain HTML page that imports a CSS file, and I can change the font in the CSS. But I don't know how to make the font bold, can anyone help me?...

IntelliJ, can't start simple web application: Unable to ping server at localhost:1099

I'm trying to make a simple web app in IntelliJ by following this tutorial: http://wiki.jetbrains.net/intellij/Creating_a_simple_Web_application_for_Tomcat_in_IntelliJ_IDEA_12 I believe my Tomcat is installed correctly since I see the tomcat picture...

Converting List<String> to String[] in Java

How do I convert a list of String into an array? The following code returns an error. public static void main(String[] args) { List<String> strlist = new ArrayList<String>(); strlist.add("sdfs1"); strlist.add("sdfs2"); St...

How to get current memory usage in android?

I have used /proc/meminfo and parsed command response.however it result shows that : MemTotal: 94348 kB MemFree: 5784 kB means. it shows there is only 5MB free memory. Is it possible with android mobile? There is only 5-6 applicati...

How to remove white space characters from a string in SQL Server

I'm trying to remove white spaces from a string in SQL but LTRIM and RTRIM functions don't seem to work? Column: [ProductAlternateKey] [nvarchar](25) COLLATE Latin1_General_CS_AS NULL Query: select REPLACE(ProductAlternateKey, ' ', '@'), ...

Auto select file in Solution Explorer from its open tab

Normally, many files in Visual Studio 2010 are opened in many tabs, while massively working on a project. Many times, I find myself right-clicking on a tab title and searching for Show/Select/Scroll-to this file in Solution Explorer, and I ...

Sending SMS from PHP

How to send an SMS from a web server written in PHP?...

Example JavaScript code to parse CSV data

Where could I find some JavaScript code to parse CSV data?...

405 method not allowed Web API

This error is very common, and I tried all of the solutions and non of them worked. I have disabled WebDAV publishing in control panel and added this to my web config file: <handlers> <remove name="WebDAV"/> </handlers> <...

excel plot against a date time x series

Why does Excel ignore the time component of datetime values in a chart. For example, the following data : 10/10/2010 9:30 1 10/10/2010 9:40 2 10/10/2010 9:50 3 10/10/2010 10:00 4 10/10/2010 10:10 5 10/10/2010 10:20 6 excel plots it all ...

PHP mailer multiple address

Possible Duplicate: PHPMailer AddAddress() Here is my code. require('class.phpmailer.php'); $mail = new PHPMailer(); $email = '[email protected], [email protected], [email protected]'; $sendmail = "$email"; $mail->AddAddress($sendma...

JAX-WS client : what's the correct path to access the local WSDL?

The problem is I need to build a web service client from a file I'm been provided. I've stored this file on the local file system and, while I keep the WSDL file in the correct file system folder, everything is fine. When I deploy it to a server or r...

Insecure content in iframe on secure page

I'm in the in the process of developing an application for a client, which will have an SSL certificate and be served under https. However, to integrate with their existing site they want to provide their navigation inside an iframe. I can see this ...

What is JAVA_HOME? How does the JVM find the javac path stored in JAVA_HOME?

I would like to know what is JAVA_HOME. Where do I set the path of javac.exe and java.exe. It is in environment variables. When I compile a Java program from command prompt, how does the JVM find javac.exe?...

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". error

Regarding Eclipse IDE (Indigo, Juno and Kepler (32 and 64 bit versions)) Platforms: Windows, Ubuntu, Mac m2e version: 1.1.0.20120530-0009, 1.2.0.20120903-1050, 1.3.0.20130129-0926, 1.4.0.20130601-0317 General info The above error came after up...

How to SELECT the last 10 rows of an SQL table which has no ID field?

I have an MySQL table with 25000 rows. This is an imported CSV file so I want to look at the last ten rows to make sure it imported everything. However, since there is no ID column, I can't say: SELECT * FROM big_table ORDER BY id DESC What SQL ...

How to generate a random string of 20 characters

Possible Duplicate: How to generate a random String in Java I am wanting to generate a random string of 20 characters without using apache classes. I don't really care about whether is alphanumeric or not. Also, I am going to convert it to...

Common elements comparison between 2 lists

def common_elements(list1, list2): """ Return a list containing the elements which are in both list1 and list2 >>> common_elements([1,2,3,4,5,6], [3,5,7,9]) [3, 5] >>> common_elements(['this','this','n','that'],...

how to check if a datareader is null or empty

I have a datareader that return a lsit of records from a sql server database. I have a field in the database called "Additional". This field is 50% of the time empty or null. I am trying to write code that checks if this field isnull. The l...

What is the difference between ManualResetEvent and AutoResetEvent in .NET?

I have read the documentation on this and I think I understand. An AutoResetEvent resets when the code passes through event.WaitOne(), but a ManualResetEvent does not. Is this correct?...

Neither BindingResult nor plain target object for bean name available as request attr

Hi Experts, I have this controller code which is throwing the above mentioned error. It was working fine till yesterday, I have no clue what colleague did to this code and today I am seeing the error: Neither BindingResult nor plain target object ...

Create a CSS rule / class with jQuery at runtime

Usually I have a CSS file which has the following rule: #my-window { position: fixed; z-index: 102; display:none; top:50%; left:50%; } How can I avoid creating such a static CSS file by adding the CSS information during runtime...

Issue with adding common code as git submodule: "already exists in the index"

I'm new to git and would appreciate help with adding submodules. I've received two projects sharing some common code. The shared code was just copied into the two projects. I created a separate git repo for the common code and removed it from the pro...

Deleting DataFrame row in Pandas based on column value

I have the following DataFrame: daysago line_race rating rw wrating line_date 2007-03-31 62 11 56 1.000000 56.000000 2007-03-10 83 11 6...

How to add/update an attribute to an HTML element using JavaScript?

I'm trying to find a way that will add / update attribute using JavaScript. I know I can do it with setAttribute() function but that doesn't work in IE....

How do I use a PriorityQueue?

How do I get a PriorityQueue to sort on what I want it to sort on? Also, is there a difference between the offer and add methods?...

How to convert List<Integer> to int[] in Java?

This is similar to this question: How to convert int[] to Integer[] in Java? I'm new to Java. How can i convert a List<Integer> to int[] in Java? I'm confused because List.toArray() actually returns an Object[], which can be cast to nether Int...

Insert content into iFrame

I am trying to insert some content into a 'blank' iFrame, however nothing is being inserted. HTML: <iframe id="iframe"></iframe> JS: $("#iframe").ready(function() { var $doc = $("#iframe").contentWindow.document; var $body = ...

How can I see the entire HTTP request that's being sent by my Python application?

In my case, I'm using the requests library to call PayPal's API over HTTPS. Unfortunately, I'm getting an error from PayPal, and PayPal support cannot figure out what the error is or what's causing it. They want me to "Please provide the entire reque...

How can you search Google Programmatically Java API

Does anyone know if and how it is possible to search Google programmatically - especially if there is a Java API for it?...

Assert an object is a specific type

Is it possible in JUnit to assert an object is an instance of a class? For various reasons I have an object in my test that I want to check the type of. Is it a type of Object1 or a type of Object2? Currently I have: assertTrue(myObject instanceof ...

Check if value exists in Postgres array

Using Postgres 9.0, I need a way to test if a value exists in a given array. So far I came up with something like this: select '{1,2,3}'::int[] @> (ARRAY[]::int[] || value_variable::int) But I keep thinking there should be a simpler way to this...

Listview Scroll to the end of the list after updating the list

I would like to make sure that the list is scrolled all the way to the bottom, after I have updated the listview by using listAdapter, so that it displays the last element entered in the list. How can I do this ? I tried this but no luck: lv.setTr...

Regular vs Context Free Grammars

I'm studying for my computing languages test, and there's one idea I'm having problems wrapping my head around. I understood that regular grammars are simpler and cannot contain ambiguity, but can't do a lot of tasks that are required for programm...

Why is enum class preferred over plain enum?

I heard a few people recommending to use enum classes in C++ because of their type safety. But what does that really mean?...

Autowiring two beans implementing same interface - how to set default bean to autowire?

Background: I have a Spring 2.5/Java/Tomcat application. There is the following bean, which is used throughout the application in many places public class HibernateDeviceDao implements DeviceDao and the following bean which is new: public class ...

How do I open the "front camera" on the Android platform?

More generally, if a device has more than one embedded camera, is there a way to initialize one of them in particular? I didn't find it in Android reference documentation: https://developer.android.com/reference/android/hardware/Camera.html https:...

How to convert a byte array to its numeric value (Java)?

I have an 8 byte array and I want to convert it to its corresponding numeric value. e.g. byte[] by = new byte[8]; // the byte array is stored in 'by' // CONVERSION OPERATION // return the numeric value I want a method that will perform the abov...

SELECT list is not in GROUP BY clause and contains nonaggregated column .... incompatible with sql_mode=only_full_group_by

AM using MySQL 5.7.13 on my windows PC with WAMP Server Here my Problem is While executing this query SELECT * FROM `tbl_customer_pod_uploads` WHERE `load_id` = '78' AND `status` = 'Active' GROUP BY `proof_type` Am getting always error like...

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 way to do it....

Rotating a Div Element in jQuery

Trying to rotate a div element...This might be DOM blasphemy, could it work possibly with a canvas element? I'm not sure - if anybody has any ideas of how this could work or why it doesn't, I'd love to know. Thanks....

Exponentiation in Python - should I prefer ** operator instead of math.pow and math.sqrt?

In my field it's very common to square some numbers, operate them together, and take the square root of the result. This is done in pythagorean theorem, and the RMS calculation, for example. In numpy, I have done the following: result = numpy.sqrt(...

Bootstrap DatePicker, how to set the start date for tomorrow?

How can I set the startDate for tomorrow? I don't see an option in the documentation for Date.today so I can add one more day. Is there a way to accomplish this? $(function() { $("#appointment_adate").datepicker({ format: 'yyyy-mm-d', ...

How can I get my webapp's base URL in ASP.NET MVC?

How can I quickly determine what the root URL is for my ASP.NET MVC application? I.e., if IIS is set to serve my application at http://example.com/foo/bar, then I'd like to be able to get that URL in a reliable way that doesn't involve getting the c...

Error in if/while (condition) {: missing Value where TRUE/FALSE needed

I received this error message: Error in if (condition) { : missing value where TRUE/FALSE needed or Error in while (condition) { : missing value where TRUE/FALSE needed What does it mean, and how do I prevent it?...

Convert comma separated string to array in PL/SQL

How do I convert a comma separated string to a array? I have the input '1,2,3' , and I need to convert it into an array....

Delete data with foreign key in SQL Server table

I'm going to delete data in an SQL Server table (parent) which has a relationship with another table (child). I tried the basic Delete query. But it isn't working (and I know it won't). DELETE FROM table WHERE ... It returned following error T...

How to check if bootstrap modal is open, so I can use jquery validate?

I need to make a validation only if a modal is open, because if I open it, and then I close it, and the I press the button that opens the modal it doesn't work because it is making the jquery validation, but not showing because the modal was dismisse...

Problems with a PHP shell script: "Could not open input file"

Ok, I am trying to create an email logger, that uses a PHP shell script. I have set up CPanel to pipe emails to my script. I am sure this is all configured properly. However I am having problems with the script, well any script for that matter when r...

Including external jar-files in a new jar-file build with Ant

I have just 'inherited' a Java-project and not coming from a Java-background I am a little lost at times. Eclipse is used to debug and run the application during development. I have through Eclipse succeeded in creating a .jar-file that 'includes' al...

Add colorbar to existing axis

I'm making some interactive plots and I would like to add a colorbar legend. I don't want the colorbar to be in its own axes, so I want to add it to the existing axes. I'm having difficulties doing this, as most of the example code I have found creat...

Error while sending QUERY packet

i was trying to insert some data into the database but i got this error "Error while sending QUERY packet" $insertDeta = $conPat->prepare("insert into table1(data) VALUES(:data)"); $insertDeta->bindParam(':data',$data); $conPat->beginTran...

Java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException

I have updated my dependecies like you said in your comment and i have this now : org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServ...

How do I get Maven to use the correct repositories?

I have just checked out some projects and need to build them, however I installed Maven quite some time ago (6 months maybe?) and really haven't used it since - the pom.xml for the project I have doesn't have this "http://repo1.maven.org/myurlhere" a...

How to change date format from DD/MM/YYYY or MM/DD/YYYY to YYYY-MM-DD?

i need to change the format of my date string using C# from : "06/16/2010"or "16/06/2010" to : "2010-06-16" can you please help me achieve this thanks...

Java: Casting Object to Array type

I am using a web service that returns a plain object of the type "Object". Debug shows clearly that there is some sort of Array in this object so I was wondering how I can cast this "Object" to an Array (or similar)? I tried the following: Collecti...

The client and server cannot communicate, because they do not possess a common algorithm - ASP.NET C# IIS TLS 1.0 / 1.1 / 1.2 - Win32Exception

I have an issue with a C# PayTrace Gateway. The below code was working fine until yesterday when I believe they turned off SSL3 due to the Poodle Exploit. When running the code below we got the following message. The remote server has forcefully clos...

Git keeps asking me for my ssh key passphrase

I created keys as instructed in the github tutorial, registered them with github, and tried using ssh-agent explicitly — yet git continues to ask me for my passphrase every time I try to do a pull or a push. What could be the cause?...

combining two data frames of different lengths

I have two data frames. The first is of only one column and 10 rows. The second is of 3 columns and 50 rows. When I try to combine this by using cbind, it gives this error: Error in data.frame(..., check.names = FALSE) : Can anyone suggest ano...

Why does DEBUG=False setting make my django Static Files Access fail?

Am building an app using Django as my workhorse. All has been well so far - specified db settings, configured static directories, urls, views etc. But trouble started sneaking in the moment I wanted to render my own beautiful and custom 404.html and ...

Get an array of list element contents in jQuery

I have a structure like this: <ul> <li>text1</li> <li>text2</li> <li>text3</li> </ul> How do I use javascript or jQuery to get the text as an array? ['text1', 'text2', 'text3'] My plan after...

How do you dynamically add elements to a ListView on Android?

Can anyone explain or suggest a tutorial to dynamically create a ListView in android? Here are my requirements: I should be able to dynamically add new elements by pressing a button. Should be simple enough to understand (possibly without any perfor...

Should ol/ul be inside <p> or outside?

Which is standard compliant between these two? <p>Text text text ... <ol> <li>First element</li> </ol> </p> <p> Other text text ... </p> OR <p> Text text text ... </...

Set HTML dropdown selected option using JSTL

In the same context i have another query <select multiple="multiple" name="prodSKUs"> <c:forEach items="${productSubCategoryList}" var="productSubCategoryList"> <option value="${productSubCategoryList}"${product...

How do I center content in a div using CSS?

How do I center content in a div both horizontally and vertically?...

jQuery find and replace string

I have somewhere on website a specific text, let's say "lollypops", and I want to replace all the occurrences of this string with "marshmellows". The problem is that I don't know where exactly the text is. I know I could do something like: $(body).h...

Convert decimal to binary in python

Is there any module or function in python I can use to convert a decimal number to its binary equivalent? I am able to convert binary to decimal using int('[binary_value]',2), so any way to do the reverse without writing the code to do it myself?...

Can comments be used in JSON?

Can I use comments inside a JSON file? If so, how?...

How to get data from database in javascript based on the value passed to the function

In my web application, I want to retrieve data from database based on the value that is passed to the function. I wrote the query as follows. <script> //Functions to open database and to create, insert data into tables getSelectedRow = fun...

Jquery select change not firing

I need to capture when a select box changes, should be simple! $('#multiid').change(function(){ alert('Change Happened'); }); But it does not work, I suspected the problem is that the select box does not exist on document ready it is creat...

Adding an image to a PDF using iTextSharp and scale it properly

here's my code. It correctly adds the pictures I want and everything works except that the images are using their native resolution, so if the image is big it's being cropped to fit the page. Is there some way to have the picture use like a Zoom fea...

How to show PIL images on the screen?

I am doing some image editing with the PIL libary. The point is, that I don't want to save the image each time on my HDD to view it in Explorer. Is there a small module that simply enables me to set up a window and display the image?...

How to convert an array to a string in PHP?

For an array like the one below; what would be the best way to get the array values and store them as a comma-separated string? Array ( [0] => 33160, [1] => 33280, [2] => 33180, [3] => 33163, [4] => 331...

How to update record using Entity Framework 6?

I am trying to update record using EF6. First finding the record, if exists, update it. Here is my code:- var book = new Model.Book { BookNumber = _book.BookNumber, BookName = _book.BookName, BookTitle = _book.BookTitle, }; using (var ...

Save bitmap to file function

I'm trying to save a bitmap to file and a specific directly using a function I've created. It's not working. It crashes after bitmap.compress part (before here3). File dir = new File(filepath); if(!dir.exists())dir.mkdirs(); File file ...

Git command to show which specific files are ignored by .gitignore

I am getting my feet wet with Git and have the following issue: My project source tree: / | +--src/ +----refs/ +----... | +--vendor/ +----... I have code (currently MEF) in my vendor branch that I will compile there and then move the references i...

How to check a string for a special character?

I can only use a string in my program if it contains no special characters except underscore _. How can I check this? I tried using unicodedata library. But the special characters just got replaced by standard characters....

React ignores 'for' attribute of the label element

In React (Facebook's framework), I need to render a label element bound to a text input using the standard for attribute. e.g. the following JSX is used: <label for="test">Test</label> <input type="text" id="test" /> However, th...

Pass table as parameter into sql server UDF

I'd like to pass a table as a parameter into a scaler UDF. I'd also prefer to restrict the parameter to tables with only one column. (optional) Is this possible? EDIT I don't want to pass a table name, I'd like to pass the table of data (as a re...

How do I share variables between different .c files?

beginner question about C declaration: In a .c file, how to use variables defined in another .c file?...

Angular2 module has no exported member

For a website with authentication in Angular2, I want to use a component of the authentication submodule in the main app component. However, I keep getting the following error: app/app.component.ts(3,10): error TS2305: Module '"<dir>/app/auth...

Javascript change font color

I need to change the font color. I have the following: var clr="green"; <font color=clr>' + onlineff + ' </font> The font color does not change to green. Just wondering how this could be fixed....

Sound effects in JavaScript / HTML5

I'm using HTML5 to program games; the obstacle I've run into now is how to play sound effects. The specific requirements are few in number: Play and mix multiple sounds, Play the same sample multiple times, possibly overlapping playbacks, Interrup...

comparing two strings in ruby

I've just started to learn ruby and this is probably very easy to solve. How do I compare two strings in Ruby? I've tried the following : puts var1 == var2 //false, should be true (I think) puts var1.eql?(var2) //false, should be true (I think) W...

How to commit changes to a new branch

I just made changes to a branch. How can I commit the changes to the other branch? I am trying to use: git checkout "the commmit to the changed branch" -b "the other branch" However, I don't think this is the right thing to do, because in this ca...

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-offset-1 col-md-12 col-sm-12 "> <div class...

How to simulate a mouse click using JavaScript?

I know about the document.form.button.click() method. However, I'd like to know how to simulate the onclick event. I found this code somewhere here on Stack Overflow, but I don't know how to use it :( function contextMenuClick() { var elem...

SELECT with a Replace()

I have a table of names and addresses, which includes a postcode column. I want to strip the spaces from the postcodes and select any that match a particular pattern. I'm trying this (simplified a bit) in T-SQL on SQL Server 2005: SELECT Replace(Pos...

How to set a class attribute to a Symfony2 form input

How can I set the HTML class attribute to a form <input> using the FormBuilder in Symfony2 ? Something like this: ->add('birthdate', 'date',array( 'input' => 'datetime', 'widget' => 'single_text', 'attr' => array...

Submit a form in a popup, and then close the popup

This seemed so trivial when I started off with it! My objective is this: When user clicks on a button, open up a form in a new window. Once the form is submitted, close the popup and return to the original page. The reverse order is fine too - i.e...

How do I center text horizontally and vertically in a TextView?

How do I center the text horizontally and vertically in a TextView, so that it appears exactly in the middle of the TextView in Android?...

subquery in codeigniter active record

SELECT * FROM certs WHERE id NOT IN (SELECT id_cer FROM revokace); How do I write the above select statement in CodeIgniter active record?...

Query-string encoding of a Javascript Object

Do you know a fast and simple way to encode a Javascript Object into a string that I can pass via a GET Request? No jQuery, no other frameworks - just plain Javascript :)...

Conversion failed when converting from a character string to uniqueidentifier

Created a stored procedure in SQL 9 (2005) and have since upgraded to SQL 10 (2008). Since then, the following stored procedure has stopped working and thrown up the above error: ALTER PROCEDURE [dbo].[GetModifiedPages] @vPortalUID nvar...

javaw.exe cannot find path

Possible Duplicate: Eclipse will not open due to environment variables I'm using eclipse IDE and I tried to run a project, but I'm getting error. It says the javaw.exe cannot be run. I reinstalled Java, now I have JRE 7 and also I install...

How to exit a function in bash

How would you exit out of a function if a condition is true without killing the whole script, just return back to before you called the function. Example # Start script Do scripty stuff here Ok now lets call FUNCT FUNCT Here is A to come back to f...

How to set the text/value/content of an `Entry` widget using a button in tkinter

I am trying to set the text of an Entry widget using a button in a GUI using the tkinter module. This GUI is to help me classify thousands of words into five categories. Each of the categories has a button. I was hoping that using a button would sig...

Checking if a textbox is empty in Javascript

This is my code which was supposed to raise an alert message if the textbox is left empty: function a(id) { var n=document.getElementById(id).value; if (n.length < 1) { window.alert("Field is blank"); return false; ...

How to know function return type and argument types?

While I am aware of the duck-typing concept of Python, I sometimes struggle with the type of arguments of functions, or the type of the return value of the function. Now, if I wrote the function myself, I DO know the types. But what if somebody want...

What does it mean if a Python object is "subscriptable" or not?

Which types of objects fall into the domain of "subscriptable"?...

How can I convert String[] to ArrayList<String>

Possible Duplicate: Assigning an array to an ArrayList in Java I need to convert a String[] to an ArrayList<String> and I don't know how File dir = new File(Environment.getExternalStorageDirectory() + "/dir/"); String[] filesOrig = ...

Store images in a MongoDB database

How can I store images in a MongoDB database rather than just text? Can I create an array of images in a MongoDB database? Will it be possible to do the same for videos?...

Get index of array element faster than O(n)

Given I have a HUGE array, and a value from it. I want to get index of the value in array. Is there any other way, rather then call Array#index to get it? The problem comes from the need of keeping really huge array and calling Array#index enormous a...

HTML/CSS--Creating a banner/header

I've got a horizontal image as a GIF and JPG. It is something I made with Paint--a text logo with an image on a solid background. I am having a lot of trouble trying to get it to display as a banner/header. So far, I am only able to get the solid b...

PHP foreach change original array values

I am very new in multi dimensional arrays, and this is bugging me big time. My array is as following: $fields = array( "names" => array( "type" => "text", "class" => "name", "name" =>...

What's the default password of mariadb on fedora?

I installed mysql through yum just now and the OS fedora installed mariadb for me. I know mariadb is a new branch of mysql, but I can't understand why it does not ask me for setting the password. I have tried for 123456 and so on, but I failed. My f...

How to capture the "virtual keyboard show/hide" event in Android?

I would like to alter the layout based on whether the virtual keyboard is shown or not. I've searched the API and various blogs but can't seem to find anything useful. Is it possible? Thanks!...

Is there a good Valgrind substitute for Windows?

I was looking into Valgrind to help improve my C coding/debugging when I discovered it is only for Linux - I have no other need or interest in moving my OS to Linux so I was wondering if there is a equally good program for Windows....

ExecuteNonQuery doesn't return results

This is my (rough) code (DAL): int i; // Some other declarations SqlCommand myCmdObject = new SqlCommand("some query"); conn.open(); i = myCmdObject.ExecuteNonQuery(); conn.close(); The problem is: Even though there is a record present on my SEL...

MySQL WHERE: how to write "!=" or "not equals"?

I need to do this DELETE FROM konta WHERE taken != '' But != doesn't exist in mysql. Anyone know how to do this?...

How do we check if a pointer is NULL pointer?

I always think simply if(p != NULL){..} will do the job. But after reading this Stack Overflow question, it seems not. So what's the canonical way to check for NULL pointers after absorbing all discussion in that question which says NULL pointers ca...

Shrink to fit content in flexbox, or flex-basis: content workaround?

I have a webapp with which I'm using flexbox for layout. I'm trying to both fill the screen (it's an app, not a document), and as far as possible to not specify any fixed widths or heights as the content could be all sorts of things (Full fluid layo...

how to change the default positioning of modal in bootstrap?

<div class="modal"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> ...

CSS Input Type Selectors - Possible to have an "or" or "not" syntax?

If they exist in programming), If I have an HTML form with the following inputs: <input type="text" /> <input type="password" /> <input type="checkbox" /> I want to apply a style to all inputs that are either type="text" or type...

To find first N prime numbers in python

I am new to the programming world. I was just writing this code in python to generate N prime numbers. User should input the value for N which is the total number of prime numbers to print out. I have written this code but it doesn't throw the desire...

How to create composite primary key in SQL Server 2008

I want to create tables in SQL Server 2008, but I don't know how to create composite primary key. How can I achieve this?...

How to loop through a HashMap in JSP?

How can I loop through a HashMap in JSP? <% HashMap<String, String> countries = MainUtils.getCountries(l); %> <select name="country"> <% // Here I need to loop through countries. %> </select> ...

Get a substring of a char*

For example, I have this char *buff = "this is a test string"; and want to get "test". How can I do that?...

How to create image slideshow in html?

I wanna make image slideshow on my web, here's my code <head> <script type="text/javascript"> var image1 = new Image() image1.src = "images/pentagg.jpg" var image2 = new Image() image2.src = "images/promo.jpg" </script...

Accessing JPEG EXIF rotation data in JavaScript on the client side

I'd like to rotate photos based on their original rotation, as set by the camera in JPEG EXIF image data. The trick is that all this should happen in the browser, using JavaScript and <canvas>. How could JavaScript access JPEG, a local file AP...

How do I add a simple jQuery script to WordPress?

I read the Codex and a few blog posts about using jQuery in WordPress, and its very frustrating. I've got as far as loading jQuery in functions.php file, but all of the guides out there are crappy because they assume you already have a ton of WordPre...

c++ boost split string

I'm using the boost::split method to split a string as this: I first make sure to include the correct header to have access to boost::split: #include <boost/algorithm/string.hpp> then: vector<string> strs; boost::split(strs,line,boos...

ld.exe: cannot open output file ... : Permission denied

I recently installed CodeBlocks with mingw32 on Windows 7 Ultimate 32bit in order to dust off my c skills, but this problem has me somewhat stumped. I decided to fire off a short Fibonacci generator to make sure my setup was working, but I ran into ...

Getting binary (base64) data from HTML5 Canvas (readAsBinaryString)

Is there any way of reading the contents of a HTML Canvas as binary data? At the moment I've got the following HTML to show an input file and the canvas below it: <p><button id="myButton" type="button">Get Image Content</button>&l...

Best Practices for securing a REST API / web service

When designing a REST API or service are there any established best practices for dealing with security (Authentication, Authorization, Identity Management) ? When building a SOAP API you have WS-Security as a guide and much literature exists on the...

How to window.scrollTo() with a smooth effect

I can scroll to 200px using the following btn.addEventListener("click", function(){ window.scrollTo(0,200); }) But I want a smooth scroll effect. How do I do this?...

How do I use regular expressions in bash scripts?

I want to check if a variable has a valid year using a regular expression. Reading the bash manual I understand I could use the operator =~ Looking at the example below, I would expect to see "not OK" but I see "OK". What am I doing wrong? i="test"...

CSS hide scroll bar if not needed

I am trying to figure out how I can hide the overflow-y:scroll; if not needed. What I mean is that I am building a website and I have a main area which posts will be displayed and I want to hide the scroll bar if content does not exceed the current w...

Disabling SSL Certificate Validation in Spring RestTemplate

I am having two Spring based web apps A and B, on two different machines. I want to make a https call from web app A to web app B, however I am using a self-signed certificate in Machine B. So my HTTPS request fails. How can I disable https certifi...

ORDER BY using Criteria API

When I write a HQL query Query q = session.createQuery("SELECT cat from Cat as cat ORDER BY cat.mother.kind.value"); return q.list(); Everything is fine. However, when I write a Criteria Criteria c = session.createCriteria(Cat.class); c.addOrder(...

Master Page Weirdness - "Content controls have to be top-level controls in a content page or a nested master page that references a master page."

This is weird. I added a brand new Web Application project to my solution in Visual Studio 2008. Created a master page. Made zero modifications. Created a new webform. Set its master page to the MP I just created. Still, no modifications. No m...

How to override and extend basic Django admin templates?

How do I override an admin template (e.g. admin/index.html) while at the same time extending it (see https://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-vs-replacing-an-admin-template)? First - I know that this question has been aske...

When do Java generics require <? extends T> instead of <T> and is there any downside of switching?

Given the following example (using JUnit with Hamcrest matchers): Map<String, Class<? extends Serializable>> expected = null; Map<String, Class<java.util.Date>> result = null; assertThat(result, is(expected)); This does n...

Variables within app.config/web.config

Is it is possible to do something like the following in the app.config or web.config files? <appSettings> <add key="MyBaseDir" value="C:\MyBase" /> <add key="Dir1" value="[MyBaseDir]\Dir1"/> <add key="Dir2" value="[MyBaseDir]...

Does Notepad++ show all hidden characters?

In Notepad++ I have set "replace tab with 2 spaces". When coding in Python I copy-pasted some code from the web and it appeared indented correctly. But running the code resulted in indentation errors, which I solved in the end by removing all "visib...

How to find length of a string array?

I am having a problem with the following lines where car is a String array which has not been initialized/has no elements. String car []; System.out.println(car.length); What is a possible solution?...

Android: making a fullscreen application

What is the simplest change that I can make to a new Blank Activity, as created by the latest version of Android Studio, to get the app to appear fullscreen? I want to create a fullscreen Android application. I'm working with Android Studio. This po...

Maven error in eclipse (pom.xml) : Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4

I wanna make web project using the Maven to import automatically all libraries that I need, so I chose "maven-archetype-webpp" after that I got this error on pom.xml file : Description Resource Path Location Type Failure to transfer org.apache.mav...

ArrayList or List declaration in Java

What is the difference between these two declarations? Declaration 1: ArrayList<String> arrayList = new ArrayList<String>(); Declaration 2: List<String> arrayList = new ArrayList<String>(); ...

How do I jump out of a foreach loop in C#?

How do I break out of a foreach loop in C# if one of the elements meets the requirement? For example: foreach(string s in sList){ if(s.equals("ok")){ //jump foreach loop and return true } //no item equals to "ok" then return ...

Calling one Bash script from another Script passing it arguments with quotes and spaces

I made two test bash scripts on Linux to make the problem clear. TestScript1 looks like: echo "TestScript1 Arguments:" echo "$1" echo "$2" echo "$#" ./testscript2 $1 $2 TestScript2 looks like: echo "TestScript2 Arguments ...

Java Scanner String input

I'm writing a program that uses an Event class, which has in it an instance of a calendar, and a description of type String. The method to create an event uses a Scanner to take in a month, day, year, hour, minute, and a description. The problem I'...

How to check string length with JavaScript

I want to get the string length when a key is pressed like StackOverflow does. I have tried to do this with onblur, but it's not working. How do I do this?...

SQL Server query to find all current database names

I need a SQL query to find the names of existing databases....

How to add local .jar file dependency to build.gradle file?

So I have tried to add my local .jar file dependency to my build.gradle file: apply plugin: 'java' sourceSets { main { java { srcDir 'src/model' } } } dependencies { runtime files('libs/mnist-tools.jar', 'li...

Removing the title text of an iOS UIBarButtonItem

What I wanted to do is to remove the text from the 'Back' button of a UIBarButtonItem, leaving only the blue chevron on the navigation bar. Keep in mind that I'm developing for iOS 7. I've tried several methods, including, but not limited to: This i...

SQL DATEPART(dw,date) need monday = 1 and sunday = 7

I have a Query where I get the WeekDay of a date but by default: Sunday = 1 Moday = 2 etc. The function is: DATEPART(dw,ads.date) as weekday I need the result so: Sunday = 7 Monday = 1 etc. Is there any shortcut to do this? Or I will have...

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

What is AndroidX?

I am reading about a room library of Android. I see they changed package android to androidx. I did not understand that. Can someone explain, please? implementation "androidx.room:room-runtime:$room_version" annotationProcessor "androidx.room:room-c...

Git commit in terminal opens VIM, but can't get back to terminal

Trying to learn GitHub at the moment and doing this Git essentials tutorial over at nettuts. I'm on the lesson about making commits. The teacher types git commit and it opens VIM as his editor (I'd also like to know how to make it open up in Sublime...

How to change the button color when it is active using bootstrap?

I am using bootstrap 3. I want to change button color when I click on button.I mean button should be in different color when it is selected. How can I do this using css? My codes are : <div class="col-sm-12" id=""> <button type="submit...

How to have a a razor action link open in a new tab?

I trying to get my link to open in a new tab (it must be in razor format): <a href="@Url.Action("RunReport", "Performance", new { reportView = Model.ReportView.ToString() }, new { target = "_blank" })" type="submit" id="runReport" class="butt...

UICollectionView spacing margins

I have a UICollectionView which shows photos. I have created the collectionview using UICollectionViewFlowLayout. It works good but I would like to have spacing on margins. Is it possible to do that using UICollectionViewFlowLayout or must I implemen...

What is meaning of negative dbm in signal strength?

When we try to get nearby cells and their LAC, MNC, signal (and while using other android apps) we are getting signal as negative value (like -85dbm). How should I take this? Should I ignore -ve sign and take absolute value or -85 is smaller strengt...

Ansible: filter a list by its attributes

I have variable named "network" registered in Ansible: { "addresses": { "private_ext": [ { "type": "fixed", "addr": "172.16.2.100" } ], "private_man": [ ...

Why doesn't margin:auto center an image?

<html> <head> <title>Test</title> </head> <body> <div> <img src="queuedError.jpg" style="margin:auto; width:200px;" /> </div> </body> </html> The div expands to 100% ...

Oracle PL/SQL - Are NO_DATA_FOUND Exceptions bad for stored procedure performance?

I'm writing a stored procedure that needs to have a lot of conditioning in it. With the general knowledge from C#.NET coding that exceptions can hurt performance, I've always avoided using them in PL/SQL as well. My conditioning in this stored proc...

How to add header row to a pandas DataFrame

I am reading a csv file into pandas. This csv file constists of four columns and some rows, but does not have a header row, which I want to add. I have been trying the following: Cov = pd.read_csv("path/to/file.txt", sep='\t') Frame=pd.DataFrame([C...

Converting Go struct to JSON

I am trying to convert a Go struct to JSON using the json package but all I get is {}. I am certain it is something totally obvious but I don't see it. package main import ( "fmt" "encoding/json" ) type User struct { name string } fun...

How to find all occurrences of an element in a list

index() will give the first occurrence of an item in a list. Is there a neat trick which returns all indices in a list for an element?...

number_format() with MySQL

hey i need a way to get a formated number from my column decimal(23,2) NOT NULL DEFAULT '0.00' in php i could use this function number_format('1111.00', 2, ',', '.'); it would return 1.111,00 (in Germany we use , to define decimal numbers) how woul...

VS Code - Search for text in all files in a directory

Is there a way to search for text in all files in a directory using VS Code? I.e., if I type "find this" in my search, it will search through all the files in the current directory and return the files that matched. Basically like if I did a grep. M...

Pass Multiple Parameters to jQuery ajax call

I have the following jquery code to call a webmethod in an aspx page $.ajax({ type: "POST", url: "popup.aspx/GetJewellerAssets", contentType: "application/json; charset=utf-8", data: '{"jewellerId":' + filter + '}', dataType: "js...

Calculate Pandas DataFrame Time Difference Between Two Columns in Hours and Minutes

I have two columns, fromdate and todate, in a dataframe. import pandas as pd data = {'todate': [pd.Timestamp('2014-01-24 13:03:12.050000'), pd.Timestamp('2014-01-27 11:57:18.240000'), pd.Timestamp('2014-01-23 10:07:47.660000')], 'fromdate': ...

Generics in C#, using type of a variable as parameter

I have a generic method bool DoesEntityExist<T>(Guid guid, ITransaction transaction) where T : IGloballyIdentifiable; How do I use the method in the following way: Type t = entity.GetType(); DoesEntityExist<t>(entityGuid, transaction...

How do I assert my exception message with JUnit Test annotation?

I have written a few JUnit tests with @Test annotation. If my test method throws a checked exception and if I want to assert the message along with the exception, is there a way to do so with JUnit @Test annotation? AFAIK, JUnit 4.7 doesn't provide t...

Determining if Swift dictionary contains key and obtaining any of its values

I am currently using the following (clumsy) pieces of code for determining if a (non-empty) Swift dictionary contains a given key and for obtaining one (any) value from the same dictionary. How can one put this more elegantly in Swift? // excerpt f...

Why do we not have a virtual constructor in C++?

Why does C++ not have a virtual constructor?...

Nested ng-repeat

I have some dummy XML file: <Week number="2013-W45"> <Day dow="1" templateDay="Monday"> <Job name="wake up" > <Job name="get dressed" > <Job name="prepare breakfast" > ...

How do I determine if a checkbox is checked?

For some reason, my form does not want to get the value of a checkbox... I am not sure if it is my coding or not, but when I try and alert() the value, I get undefined as a result. What do I have wrong? <head> <script> var lfckv = ...

How to prevent Browser cache on Angular 2 site?

We're currently working on a new project with regular updates that's being used daily by one of our clients. This project is being developed using angular 2 and we're facing cache issues, that is our clients are not seeing the latest changes on their...

What are the First and Second Level caches in (N)Hibernate?

Can anyone explain in simple words what First and Second Level caching in Hibernate/NHibernate are?...

How do I search for files in Visual Studio Code?

I am used to Resharper where I can search for files, not the content, but the filename, which makes it quick to open new files. Is this feature implemented in Visual Studio Code and is there a shortcut for it?...

How do I filter an array with TypeScript in Angular 2?

ng-2 parent-child data inheritance has been a difficulty for me. What seems that could be a fine working practical solution is filtering my total array of data to an array consisting of only child data referenced by a single parent id. In other wor...

String comparison - Android

I'm unable to compare two strings using the following code: I have a string named "gender" which will have "Male" or "Female" as its value. if(gender == "Male") salutation ="Mr."; if(gender == "Female") salutation ="Ms."; This didn't work, ...

Imply bit with constant 1 or 0 in SQL Server

Is it possible to express 1 or 0 as a bit when used as a field value in a select statement? e.g. In this case statement (which is part of a select statement) ICourseBased is of type int. case when FC.CourseId is not null then 1 else 0 end as IsCo...

What is unexpected T_VARIABLE in PHP?

I get this PHP error: Parse error: syntax error, unexpected T_VARIABLE From this line: $list[$i][$docinfo['attrs']['@groupby']] = $docinfo['attrs']['@count']; Is there anything wrong with this line?...

Make a nav bar stick

Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stic...

last day of month calculation

I am having issues with the calculation of when the next Last Day of the Month is for a notification which is scheduled to be sent. Here is my code: RecurrenceFrequency recurrenceFrequency = notification.getRecurrenceFrequency(); Calendar nextNotif...

How do you stylize a font in Swift?

I'm trying out developing for Swift, it's going pretty well. One of the issues I'm having is finding out how to stylize fonts programmatically in the language. For example in this label I wrote the code below for, how can I make it Helvetica Neue U...

PHP form - on submit stay on same page

I have a PHP form that is located on file contact.html. The form is processed from file processForm.php. When a user fills out the form and clicks on submit, processForm.php sends the email and direct the user to - processForm.php with a message o...

What is a lambda expression in C++11?

What is a lambda expression in C++11? When would I use one? What class of problem do they solve that wasn't possible prior to their introduction? A few examples, and use cases would be useful. ...

Is there a way to select sibling nodes?

For some performance reasons, I am trying to find a way to select only sibling nodes of the selected node. For example, <div id="outer"> <div id="inner1"></div> <div id="inner2"></div> ...

What is the minimum I have to do to create an RPM file?

I just want to create an RPM file to distribute my Linux binary "foobar", with only a couple of dependencies. It has a config file, /etc/foobar.conf and should be installed in /usr/bin/foobar. Unfortunately the documentation for RPM is 27 chapters ...

NodeJS - Error installing with NPM

Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:\Windows\system32>npm install caress-server npm http GET https://registry.npmjs.org/caress-server npm http 304 https://registry.npmjs.org/caress-server np...

Adding Table rows Dynamically in Android

I am trying to create a layout where I need to add table rows dynamically. Below is the table layout xml <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="ma...

to call onChange event after pressing Enter key

I am new to Bootstrap and stuck with this problem. I have an input field and as soon as I enter just one digit, the function from onChange is called, but I want it to be called when I push 'Enter when the whole number has been entered. The same probl...

html table cell width for different rows

Possible Duplicate: table cell width issue I have a table set up as <html> <body bgcolor="#14B3D9"> <table width="100%" border="1" bgcolor="#ffffff"> <tr> <td width="25%">25</td> &l...

C++ inheritance - inaccessible base?

I seem to be unable to use a base class as a function parameter, have I messed up my inheritance? I have the following in my main: int some_ftn(Foo *f) { /* some code */ }; Bar b; some_ftn(&b); And the class Bar inheriting from Foo in such a...

Nexus 7 (2013) and Win 7 64 - cannot install USB driver despite checking many forums and online resources

I'm trying to set up my Nexus 7 (2013) for debugging, but I am getting stuck at the step where you install the USB driver. Here's what I've tried so far: Steps taken: Turned on debugging mode on Nexus 7 (2013) Connected device to PC Downloaded Go...

Send XML data to webservice using php curl

I'm working on Flight API of arzoo. The server must receive the posted data in simple POST Request. To achieve this i'm using PHP cURL. In the API Document it is clearly mention that the data should be sent in the following format: <AvailRequest&...

Gradle - Could not find or load main class

I'm trying to run a very simple project using Gradle and running into the following error when using the gradlew run command: could not find or load main class 'hello.HelloWorld' Here is my file structure: SpringTest -src -hello ...

Converting from a string to boolean in Python?

Does anyone know how to do convert from a string to a boolean in Python? I found this link. But it doesn't look like a proper way to do it. I.e. using built-in functionality, etc. The reason I'm asking this is because I learned about int("string") ...

redistributable offline .NET Framework 3.5 installer for Windows 8

Our company was testing our product (compiled for .NET Framework 3.5) on Windows 8. We have discovered that there is no .NET Framework 3.5 on Windows 8 and there are two possibilities to resolve this issue: online installation install from Windows ...

glob exclude pattern

I have a directory with a bunch of files inside: eee2314, asd3442 ... and eph. I want to exclude all files that start with eph with the glob function. How can I do it?...

CSS position:fixed inside a positioned element

I have a positioned div whose content can be too long so scrollbars appear (overflow:auto set). It functions as a dialog box in an ajax app. I want to fix a close button on it's right top corner so when the user scrolls the div it won't scroll away. ...

How to return a list of keys from a Hash Map?

I'm currently trying to make a program that conjugates verbs into Spanish. I've created a Hash Table that contains a key and an instantiation of the object Verb. The key is a string that has the infinitive form of the verb (for example, "hablar"). ...

Change color and appearance of drop down arrow

I want to change the default appearance of the arrow of a dropdown list so that looks the same across browsers. Is there a way to override the default look and feel of the drop down arrow using CSS or otherwise ?...

How do I find the duplicates in a list and create another list with them?

How can I find the duplicates in a Python list and create another list of the duplicates? The list only contains integers....

How to debug Spring Boot application with Eclipse?

My Spring Boot webapp is running just fine, and I'd like to debug it through Eclipse. So when launching my Remote Java Application debugger, which port should I listen to? And is there a setting on my webapp I have to set to enable debugging?...

How to see the proxy settings on windows?

Our work laptops are configured to use proxy to access external sites and I don't have access to see the proxy information. All our applications like IDEs are configured to use system proxy. Is there a way I can check the proxy settings; For example,...

SQL Server equivalent to Oracle's CREATE OR REPLACE VIEW

In Oracle, I can re-create a view with a single statement, as shown here: CREATE OR REPLACE VIEW MY_VIEW AS SELECT SOME_FIELD FROM SOME_TABLE WHERE SOME_CONDITIONS As the syntax implies, this will drop the old view and re-create it with whatever d...

Javascript Thousand Separator / string format

Is there any function in Javascript for formatting number and strings ? I am looking for a way for thousand separator for string or numbers... (Like String.Format In c#)...

Django upgrading to 1.9 error "AppRegistryNotReady: Apps aren't loaded yet."

When upgraded to django 1.9 from 1.8 I got this error. I checked answers for similar questions, but I didn't think this is an issue with any 3rd party packages or apps. Traceback (most recent call last): File "manage.py", line 10, in <module> ...

How to pass variable as a parameter in Execute SQL Task SSIS?

I have ssis package in that I'm taking values from flat file and insert it into table. I have taken one Execute SQL Task in that creating one temptable CREATE TABLE [tempdb].dbo.##temptable ( date datetime, companyname nvarchar(50), price decimal...

How to change package name of an Android Application

My keystore is corrupt, therefore the Android Market is requiring me to rename the app and resubmit it. However, whenever I go to edit the package names in Manifest and throughout the files, it gives me tons of errors. What's the proper way to chang...

How to change the background color of the options menu?

I'm trying to change the default color for the options menu which is white: I want a black background for every item on the options menu. I've tried some shoots like android:itemBackground="#000000" on the item element within the menu element but it...

Call a function with argument list in python

I'm trying to call a function inside another function in python, but can't find the right syntax. What I want to do is something like this: def wrapper(func, args): func(args) def func1(x): print(x) def func2(x, y, z): return x+y+z wr...

CSS: styled a checkbox to look like a button, is there a hover?

I've created a small looking button to display instead of a checkbox. I was wondering if there was a way to also have a :hover look somehow? thanks http://jsfiddle.net/zAFND/2/...

How do I change the default library path for R packages

I have attempted to install R and R studio on the local drive on my work computer as opposed to the organization network folder because anything that runs through the network is really slow. When installing, the destination path shows that it's my lo...

How to move screen without moving cursor in Vim?

I recently discovered Ctrl+E and Ctrl+Y shortcuts for Vim that respectively move the screen up and down with a one line step, without moving the cursor. Do you know any command that leaves the cursor where it is but moves the screen so that the line...

How to apply an XSLT Stylesheet in C#

I want to apply an XSLT Stylesheet to an XML Document using C# and write the output to a File....

What difference is there between WebClient and HTTPWebRequest classes in .NET?

What difference is there between the WebClient and the HttpWebRequest classes in .NET? They both do very similar things. In fact, why weren't they merged into one class (too many methods/variables etc may be one reason but there are other classes in ...

What is the equivalent of Java's final in C#?

What is the equivalent of Java's final in C#?...

What are these ^M's that keep showing up in my files in emacs?

So I think it may have to do with textmate, but we work in a small team and are having some issues with full-file conflicts of nearly identical files in git because each line of one branch has a ^M appended to it. What is this mysterious ^M characte...

nginx- duplicate default server error

In my error log i get [emerg] 10619#0: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/mysite.com:4 on Line 4 I have: server_name mysite.com www.mysite.com; Any suggestions?...

Difference between "module.exports" and "exports" in the CommonJs Module System

On this page (http://docs.nodejitsu.com/articles/getting-started/what-is-require), it states that "If you want to set the exports object to a function or a new object, you have to use the module.exports object." My question is why. // right...

Python class input argument

I am new to OOP. My idea was to implement the following class: class name(object, name): def __init__(self, name): print name Then the idea was to create two instances of that class: person1 = name("jean") person2 = name("dean") I k...

Assign width to half available screen width declaratively

Is it possible to assign a widget width to half the available screen width, and do it using declarative xml?...

UIImageView aspect fit and center

I have an image view, declared programmatically, and I am setting its image, also programmatically. However, I find myself unable to set the image to both fit the aspect and align centre to the image view. In other words, I want the image to: Sca...

How to access the first property of a Javascript object?

Is there an elegant way to access the first property of an object... where you don't know the name of your properties without using a loop like for .. in or jQuery's $.each For example, I need to access foo1 object without knowing the name of foo...

What's the proper way to "go get" a private repository?

I'm searching for the way to get $ go get work with private repository, after many google try. The first try: $ go get -v gitlab.com/secmask/awserver-go Fetching https://gitlab.com/secmask/awserver-go?go-get=1 https fetch failed. Fetching http://...

Get push notification while App in foreground iOS

I am using push notification service in my app. When app is in background I am able to see notification on notification screen(screen shown when we swipe down from top of iOS device). But if application is in foreground the delegate method - (void)...

How to break out of nested loops?

If I use a break statement, it will only break inner loop and I need to use some flag to break the outer loop. But if there are many nested loops, the code will not look good. Is there any other way to break all of the loops? (Please don't use goto ...

How to download Google Play Services in an Android emulator?

I want to use Google Play Services API in my application, but when I open the emulator to test my application it sends me a message that says "Google Play Services must be downloaded". I know that occurs because I coded this test in my MainActivity i...

What is in your .vimrc?

Vi and Vim allow for really awesome customization, typically stored inside a .vimrc file. Typical features for a programmer would be syntax highlighting, smart indenting and so on. What other tricks for productive programming have you got, hidden in...

How to get Database Name from Connection String using SqlConnectionStringBuilder

I never want to split connection string using string manipulation and get server,database,uid and password. I read the following link and read the accepted answer , I found that is the best way to get userid and password out from connection string, ...

Apache POI error loading XSSFWorkbook class

I'm trying to write a program that works with Excel docs, but the HSSF format is too small for my requirements. I'm attempting to move to XSSF, but I keep getting errors when trying to use it. I managed to solve the first two by adding xmlbeans-2.3....

php exec() is not executing the command

I have tried to use exec() with 'whoami' to check if it works and I got the result of nt authority\system Now I need to run a .exe file with parameters from php via exec() function. I tried this in command prompt and it actually runs the progra...

How to retrieve unique count of a field using Kibana + Elastic Search

Is it possible to query for a distinct/unique count of a field using Kibana? I am using elastic search as my backend to Kibana. If so, what is the syntax of the query? Heres a link to the Kibana interface I would like to make my query: http://demo....

Check if a file is executable

I am wondering what's the easiest way to check if a program is executable with bash, without executing it ? It should at least check whether the file has execute rights, and is of the same architecture (for example, not a windows executable or anoth...

How to embed a PDF?

I am trying to embed a PDF in an HTML document, but this seems to work only with Chrome. Other browsers appear to either require plugins or require a user to click a link which is not what I want. Here is what I have tried: <object data="pdfFiles...

Change status bar color with AppCompat ActionBarActivity

In one of my Activities, I changed the Toolbar color using Palette. But on 5.0 devices using ActionBarActivity the status bar color is the color of my colorPrimaryDark in my activity theme so I have 2 very different colors and it does not look good....

Where does MySQL store database files on Windows and what are the names of the files?

So I accidentally formatted my hard drive and re-installed Windows and forgot to backup an important database I had in my MySQL server. I'm trying to salvage files now using some software, but I don't know what to look for. What is the path that the...

How can one see the structure of a table in SQLite?

How can I see the structure of table in SQLite as desc was in Oracle?...

What is the best (idiomatic) way to check the type of a Python variable?

I need to know if a variable in Python is a string or a dict. Is there anything wrong with the following code? if type(x) == type(str()): do_something_with_a_string(x) elif type(x) == type(dict()): do_somethting_with_a_dict(x) else: rai...

How do I replicate a \t tab space in HTML?

How can I use the common \t escape character in html ? Is it possible? I need a code that has the same function as the /t escape character...

Undefined symbols for architecture arm64

I am getting a Apple Mach-O Linker Error everytime I import a file from CocoaPods. Undefined symbols for architecture arm64: "_OBJC_CLASS_$_FBSession", referenced from: someFile ld: symbol(s) not found for architecture arm64 I get about 12 of th...

Python pandas insert list into a cell

I have a list 'abc' and a dataframe 'df': abc = ['foo', 'bar'] df = A B 0 12 NaN 1 23 NaN I want to insert the list into cell 1B, so I want this result: A B 0 12 NaN 1 23 ['foo', 'bar'] Ho can I do that? 1) If I use this: df...

How to initialize a struct in accordance with C programming language standards

I want to initialize a struct element, split in declaration and initialization. This is what I have: typedef struct MY_TYPE { bool flag; short int value; double stuff; } MY_TYPE; void function(void) { MY_TYPE a; ... a = { true, 15, 0.12...

C++ IDE for Macs

I teach a C++ course using Visual Studio. One of my students has a Mac and was looking for an IDE to use on his machine. What would be good to recommend?...

What is the difference between 127.0.0.1 and localhost

Assuming the following is defined in .../hosts: 127.0.0.1 localhost What, if any, are the actual differences between using 127.0.0.1 and localhost as the server name, especially when hitting processes running locally that are listening for connect...

jQuery.ajax returns 400 Bad Request

This works fine: jQuery('#my_get_related_keywords').click(function() { if (jQuery('#my_keyword').val() == '') return false; jQuery.getJSON("http://boss.yahooapis.com/ysearch/web/v1/" +jQuery('#my_keyword').val()+"?" +"app...

Switch statement fall-through...should it be allowed?

For as long as I can remember I have avoided using switch statement fall-through. Actually, I can't remember it ever entering my consciousness as a possible way to do things as it was drilled into my head early on that it was nothing more than a bug ...

Create a day-of-week column in a Pandas dataframe using Python

Create a day-of-week column in a Pandas dataframe using Python I’d like to read a csv file into a pandas dataframe, parse a column of dates from string format to a date object, and then generate a new column that indicates the day of the week. Th...

SQL Server 2012 Install or add Full-text search

I am working in SQL Server 2012, and would like to use the CONTAINS() function only it seems I need to have full-text search enabled for to be able to use it. How do I enable/install this feature to an existing SQL Server 2012 install? What I need ar...

How to iterate over each string in a list of strings and operate on it's elements

Im new to python and i need some help with this. TASK : given a list --> words = ['aba', 'xyz', 'xgx', 'dssd', 'sdjh'] i need to compare the first and the last element of each string in the list, if the first and the last element in the string i...

How do I print out the contents of a vector?

How do I print out the contents of a std::vector to the screen? A solution that implements the following operator<< would be nice as well: template<container C, class T, String delim = ", ", String open = "[", String clo...

CSS Cell Margin

In my HTML document, I have a table with two columns and multiple rows. How can I increase the space in between the first and second column with css? I've tried applying "margin-right: 10px;" to each of the cells on the left hand side, but to no effe...

Excel - find cell with same value in another worksheet and enter the value to the left of it

I have a report that is generated in Excel which contains an employee's number, but not his/her name. Not every employee will be on this worksheet on any given day. In a 2nd worksheet I have a list of all employees' numbers and names. I want a fo...

How do I run a shell script without using "sh" or "bash" commands?

I have a shell script which I want to run without using the "sh" or "bash" commands. For example: Instead of: sh script.sh I want to use: script.sh How can I do this? P.S. (i) I don't use shell script much and I tried reading about aliases, but I...

How to access share folder in virtualbox. Host Win7, Guest Fedora 16?

I'm a newbie in linux. I installed Fedora 16 OS as guest in virtualbox on Window 7. Now, I want to access share folder from Fedora. Here is something I did: Install guest addtion [OK] Make share folder link to virtualbox [OK]. Share folder path in ...

How to get the last characters in a String in Java, regardless of String size

I'm looking for a way to pull the last characters from a String, regardless of size. Lets take these strings into example: "abcd: efg: 1006746" "bhddy: nshhf36: 1006754" "hfquv: nd: 5894254" As you can see, completely random strings, but they have...

Remove duplicates from dataframe, based on two columns A,B, keeping row with max value in another column C

I have a pandas dataframe which contains duplicates values according to two columns (A and B): A B C 1 2 1 1 2 4 2 7 1 3 4 0 3 4 8 I want to remove duplicates keeping the row with max value in column C. This would lead to: A B C 1 2 4 2 7 1 3 4 ...

Best way to check if MySQL results returned in PHP?

I'm looking for the best way to check and see if any results were returned in a query. I feel like I write this part of code a lot and sometimes I get errors, and sometimes I don't. For example, I run this query to check if a username exists before ...

Check if something is (not) in a list in Python

I have a list of tuples in Python, and I have a conditional where I want to take the branch ONLY if the tuple is not in the list (if it is in the list, then I don't want to take the if branch) if curr_x -1 > 0 and (curr_x-1 , curr_y) not in myLis...

Best practice for localization and globalization of strings and labels

I'm a member of a team with more than 20 developers. Each developer works on a separate module (something near 10 modules). In each module we might have at least 50 CRUD forms, which means that we currently have near 500 add buttons, save buttons, ed...

Rollback transaction after @Test

First of all, I've found a lot of threads on StackOverflow about this, but none of them really helped me, so sorry to ask possibly duplicate question. I'm running JUnit tests using spring-test, my code looks like this @RunWith(SpringJUnit4ClassRunn...

Binary Data in JSON String. Something better than Base64

The JSON format natively doesn't support binary data. The binary data has to be escaped so that it can be placed into a string element (i.e. zero or more Unicode chars in double quotes using backslash escapes) in JSON. An obvious method to escape bi...

How to use NULL or empty string in SQL

I would like to know how to use NULL and an empty string at the same time in a WHERE clause in SQL Server. I need to find records that have either null values or an empty string. Thanks....

How to format DateTime in Flutter , How to get current time in flutter?

I am trying to display the current DateTime in a Text widget after tapping on a button. The following works, but I'd like to change the format. Current approach DateTime now = DateTime.now(); currentTime = new DateTime(now.year, now.month, now.day,...

CSS image resize percentage of itself?

I am trying to resize an img with a percentage of itself. For example, I just want to shrink the image by half by resizing it to 50%. But applying width: 50%; will resize the image to be 50% of the container element (the parent element which maybe th...

What does the 'Z' mean in Unix timestamp '120314170138Z'?

I have an X.509 certificate which has the following 2 timestamps: ['validFrom'] = String(13) "120314165227Z" ['validTo'] = String(13) "130314165227Z" What does the postfix character 'Z' mean. Does it specify the timezone?...

Switching to landscape mode in Android Emulator

This is probably a pretty easy to answer question, but I can't find the solution myself after a couple hours of searching the documentation and Google. I set the orientation of my Android app to landscape in the AndroidManifest.xml file: android:scr...

How to define constants in ReactJS

I have a function that maps text to letters: sizeToLetterMap: function() { return { small_square: 's', large_square: 'q', thumbnail: 't', small_240: 'm', small_320...

How to enter a multi-line command

Is it possible to split a PowerShell command line over multiple lines? In Visual Basic I can use the underscore (_) to continue the command in the next line....

git ahead/behind info between master and branch?

I have created a branch for testing in my local repo (test-branch) which I pushed to Github. If I go to my Github account and select this test-branch it shows the info: This branch is 1 commit ahead and 2 commits behind master My questions are: ...

Difference between except: and except Exception as e: in Python

Both the following snippets of code do the same thing. They catch every exception and execute the code in the except: block Snippet 1 - try: #some code that may throw an exception except: #exception handling code Snippet 2 - try: #...

Stop handler.postDelayed()

I call multiple Handlers by new Handler().postDelayed(new Runnable()..... How can I stop it when I click on back? public class MyActivity extends AppCompatActivity implements OnClickListener { private Button btn; private Handler handler; ...

Add borders to cells in POI generated Excel File

I am using POI to generate an Excel File. I need to add borders to specific cells in the worksheet. How can I accomplish this?...

What does EntityManager.flush do and why do I need to use it?

I have an EJB where I am saving an object to the database. In an example I have seen, once this data is saved (EntityManager.persist) there is a call to EntityManager.flush(); Why do I need to do this? The object I am saving is not attached and no...

How can you create multiple cursors in Visual Studio Code

What are the keyboard shortcuts for creating multiple cursors in VS Code?...

What is it exactly a BLOB in a DBMS context

What is it a BLOB? How can I use it? What are the differences between DBMS's BLOBs. I would like to save data using BLOBs into any DBMS and then read that BLOB with a library. ...

Python variables as keys to dict

Is there an easier way to do this in Python (2.7)?: Note: This isn't anything fancy, like putting all local variables into a dictionary. Just the ones I specify in a list. apple = 1 banana = 'f' carrot = 3 fruitdict = {} # I want to set the key equ...

How do I get the n-th level parent of an element in jQuery?

When I want to get, for example, the 3rd level parent of the element I must write $('#element').parent().parent().parent() Is there a more optimal method for this?...

How do I analyze a program's core dump file with GDB when it has command-line parameters?

My program operates like this: exe -p param1 -i param2 -o param3 It crashed and generated a core dump file, core.pid. I want to analyze the core dump file by gdb ./exe -p param1 -i param2 -o param3 core.pid But GDB recognizes the parameters of...

Java generics: multiple generic parameters?

I was wondering if it's possible to write a function that accepts multiple generic types as follows: public int void myfunction(Set<T> a, Set<T> b) { return 5; } Set<Integer> setA = new HashSet<Integer>(); Set<String&...

How do I list / export private keys from a keystore?

How do I list and export a private key from a keystore?...

Initial bytes incorrect after Java AES/CBC decryption

What's wrong with the following example? The problem is that the first part of the decrypted string is nonsense. However, the rest is fine, I get... Result: `£eB6O?geS??i are you? Have a nice day. @Test public void testEncrypt() { try { ...

What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__?

What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__, and where are they documented? How do I decide which one to use?...

How to copy a string of std::string type in C++?

I used the strcpy() function and it only works if I use C-string arrays like: char a[6] = "text"; char b[6] = "image"; strcpy(a,b); but whenever I use string a = "text"; string b = "image"; strcpy(a,b); I get...

Is it possible to create a temporary table in a View and drop it after select?

I need to alter one view and I want to introduce 2 temporary table before the SELECT. Is this possible? And how can I do it? ALTER VIEW myView AS SELECT * INTO #temporary1 SELECT * INTO #temporary2 SELECT * FROM #temporary1 UNION ALL SELECT * ...

How to open Atom editor from command line in OS X?

I have the Atom editor and was wondering how you can open a file or folder from the terminal in Atom. I am using a Mac. I am looking for a way to do this: atom . (opens folder) atom file.js (opens file) atom (opens editor) Is this possible and h...

Count items in a folder with PowerShell

I'm trying to write a very simple PowerShell script to give me the total number of items (both files and folders) in a given folder (c:\MyFolder). Here's what I've done: Write-Host ( Get-ChildItem c:\MyFolder ).Count; The problem is, that if I ha...

How to run a Command Prompt command with Visual Basic code?

I'm trying to code something in Visual Basic, more specifically Visual Studio 2010. I want, with a button click, my program to execute a command. Is that possible? ...

Finding first and last index of some value in a list in Python

Is there any built-in methods that are part of lists that would give me the first and last index of some value, like: verts.IndexOf(12.345) verts.LastIndexOf(12.345) ...

SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable

I recently tried to import sample Android games I downloaded from Google's developer website. After importing them into Android Studio, I'm getting the following error: Error: SDK location not found. Define location with sdk.dir in the local.prop...

Change the Blank Cells to "NA"

Here's the link of my data. My target is to assign "NA" to all blank cells irrespective of categorical or numerical values. I am using na.strings="". But it's not assigning NA to all blank cells. ## reading the data dat <- read.csv("data2.csv")...

How to return HTTP 500 from ASP.NET Core RC2 Web Api?

Back in RC1, I would do this: [HttpPost] public IActionResult Post([FromBody]string something) { try{ // ... } catch(Exception e) { return new HttpStatusCodeResult((int)HttpStatusCode.InternalServerError); } ...

getActivity() returns null in Fragment function

I have a fragment (F1) with a public method like this public void asd() { if (getActivity() == null) { Log.d("yes","it is null"); } } and yes when I call it (from the Activity), it is null... FragmentTransaction t...

error : expected unqualified-id before return in c++

when I want to compile I get : Probléme : expected unqualified-id before "return" return 0; about last line : erreur:expexted declaration before { token I left the code unchanged just the middle part I changed... whats the problem??? here is my cod...

How do I call an Angular.js filter with multiple arguments?

As from the documentation, we can call a filter such as date like this: {{ myDateInScope | date: 'yyyy-MM-dd' }} Here date is a filter that takes one argument. What is the syntax to call filters with more parameters both from templates and from J...

Eclipse keyboard shortcut to indent source code to the left?

I've looked in the keyboard shortcuts list in Eclipse but can't find keyboard shortcut to indent source code to the left. Surely there is one?...