Questions Tagged with #Optional variables

python numpy vector math

What is the numpy equivalent to euclid's 2d vector classes / operations ? ( like: euclid.Vector2 ) So far I have this. Create two vectors import numpy as np loc = np.array([100., 100.]) vel = np.a..

Viewing full output of PS command

when I run ps -aux command on my linux server, to which I connected using putty, few processes are too long to fit in my current window width. Is there an alternative? -- Update -- I am sorry for do..

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided does not match the recipient window's origin ('null')

I have a game in heroku, now I'm trying to make it work in Facebook canvas, but, while it works in Firefox, in Chrome and IE doesn't. IE shows a warning with a button, when clicking the button, it sh..

How to sort the files according to the time stamp in unix?

How to sort the files according to the time stamp in unix? I need to sort the files and also based on time they created...

Error while installing json gem 'mkmf.rb can't find header files for ruby'

For context, it on a remote server which has a firewall. I'm setting up my environment through a proxy. I have ruby 1.8.7. When I try to gem install.. sudo gem install --http-proxy <host address&g..

Insert Data Into Tables Linked by Foreign Key

I am using PostgreSQL. Customer ================== Customer_ID | Name Order ============================== Order_ID | Customer_ID | Price To insert an order, here is what I need to do usually, Fo..

How can I use custom fonts on a website?

In order for my website to look good I need to use a custom font, specifically, Thonburi-Bold. The problem is - the font does not get displayed unless the user has installed it. It also isn't displaye..

How to include a child object's child object in Entity Framework 5

I am using Entity Framework 5 code first and ASP.NET MVC 3. I am struggling to get a child object's child object to populate. Below are my classes.. Application class; public class Application { ..

Use VBA to Clear Immediate Window?

Does anyone know how to clear the immediate window using VBA? While I can always clear it myself manually, I am curious if there is a way to do this programmatically...

How to set MouseOver event/trigger for border in XAML?

I want the border to turn green when the mouse is over it and then to return to blue when the mouse is no longer over the border. I attempted this without any luck: <Border Name="ClearButto..

How to set only time part of a DateTime variable in C#

I have a DateTime variable: DateTime date = DateTime.Now; I want to change the time part of a DateTime variable. But when I tried to access time part (hh:mm:ss) these fields are readonly. Can't I ..

MySQL JOIN with LIMIT 1 on joined table

I want to join two tables, but only get 1 record of table2 per record on table1 For example: SELECT, c.title, AS product_id, p.title FROM categories AS c JOIN products AS p ON =

Detecting arrow key presses in JavaScript

How do I detect when one of the arrow keys are pressed? I used this to find out: function checkKey(e) { var event = window.event ? window.event : e; console.log(event.keyCode) } Though it w..

Changing Font Size For UITableView Section Headers

Can someone please instruct me on the easiest way to change the font size for the text in a UITableView section header? I have the section titles implemented using the following method: - (NSString ..

Play an audio file using jQuery when a button is clicked

I am trying to play an audio file when I click the button, but it's not working, my html code is: <html> <body> <div id="container"> <button id="play"..

Can I add jars to maven 2 build classpath without installing them?

Maven2 is driving me crazy during the experimentation / quick and dirty mock-up phase of development. I have a pom.xml file that defines the dependencies for the web-app framework I want to use, an..

Jackson JSON: get node name from json-tree

How can I receive the node names from a JSON tree using Jackson? The JSON-File looks something like this: { node1:"value1", node2:"value2", node3:{ node3.1:"value3.1", ..

Element count of an array in C++

Let's say I have an array arr. When would the following not give the number of elements of the array: sizeof(arr) / sizeof(arr[0])? I can thing of only one case: the array contains elements that are ..

How to get GET (query string) variables in Express.js on Node.js?

Can we get the variables in the query string in Node.js just like we get them in $_GET in PHP? I know that in Node.js we can get the URL in the request. Is there a method to get the query string para..

Regex replace uppercase with lowercase letters

I'm trying to replace uppercase letters with corresponding lowercase letters using regex. So that EarTH: 1, MerCury: 0.2408467, venuS: 0.61519726, becomes earth: 1, mercury: 0.2408467, venus..

MassAssignmentException in Laravel

I am a Laravel newbie. I want to seed my database. When I run the seed command I get an exception [Illuminate\Database\Eloquent\MassAssignmentException] username db:seed [--class[="..."]] [--d..

Find records from one table which don't exist in another

I've got the following two tables (in MySQL): Phone_book +----+------+--------------+ | id | name | phone_number | +----+------+--------------+ | 1 | John | 111111111111 | +----+------+--------------..

How to subscribe to an event on a service in Angular2?

I know how to raise an event with the EventEmitter. I can also attach a method to be called if I have a component like this: <component-with-event (myevent)="mymethod($event)" /> When I have ..

$(...).datepicker is not a function - JQuery - Bootstrap

I'm trying to include the datepicker for Bootstrap but am getting the following error: Uncaught TypeError: $(...).datepicker is not a function I don't see why it's there. I've looked at other cases ..

Converting UTF-8 to ISO-8859-1 in Java - how to keep it as single byte

I am trying to convert a string encoded in java in UTF-8 to ISO-8859-1. Say for example, in the string 'âabcd' 'â' is represented in ISO-8859-1 as E2. In UTF-8 it is represented as two bytes. C3 A2..

Can JavaScript connect with MySQL?

Can JavaScript connect with MySQL? If so, how?..

How do I add FTP support to Eclipse?

I'm using Eclipse PHP Development Tools. What would be the easiest way to access a file or maybe create a remote project trough FTP and maybe SSH and SFTP?...

How to resolve Error : Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation

I am working on project. In my System when I run the project it is running nicely, but after uploading it to my domain when I check, then it displays the error like: "Showing a modal dialog box or fo..

Simulating a click in jQuery/JavaScript on a link

I want to simulate a click on any link on a page using JavaScript. If that link has some function binded to its 'onclick' event (by any other JS I don't have any control over), then that function must..

Add string in a certain position in Python

Is there any function in Python that I can use to insert a value in a certain position of a string? Something like this: "3655879ACB6" then in position 4 add "-" to become "3655-879ACB6"..

Free c# QR-Code generator

I'm looking for a free to use c# library/code to create barcodes. Secifically I need to be able to create QR-Code type barcodes. I'm looking for free to use (Open Source or just Free, etc.) not pay to..

How to use classes from .jar files?

I read the Java tutorials on Sun for JAR files, but I still can't find a solution for my problem. I need to use a class from a jar file called jtwitter.jar, I downloaded the file, and tried executing ..

Interface type check with Typescript

This question is the direct analogon to Class type check with TypeScript I need to find out at runtime if a variable of type any implements an interface. Here's my code: interface A{ member:stri..

SQL Left Join first match only

I have a query against a large number of big tables (rows and columns) with a number of joins, however one of tables has some duplicate rows of data causing issues for my query. Since this is a read o..

NPM vs. Bower vs. Browserify vs. Gulp vs. Grunt vs. Webpack

I'm trying to summarize my knowledge about the most popular JavaScript package managers, bundlers, and task runners. Please correct me if I'm wrong: npm & bower are package managers. They just d..

How to capture the screenshot of a specific element rather than entire page using Selenium Webdriver?

Currently I'm trying to capture a screenshot using the Selenium WebDriver. But I can only obtain the whole page screen shot. However, what I wanted is just to capture a part of the page or perhaps jus..

Read text file into string. C++ ifstream

void docDB(){ int sdb = 0; ifstream dacb("kitudacbiet.txt"); if(!dacb.is_open()) cout<<"Deo doc dc file"<<endl; else{ while(!dacb.eof()){ ..

jQuery Validation plugin: validate check box

I am using jQuery Validation plugin to validate check box since it does not have default option, One should be selected and max two check boxes can be selected, these is the criteria. I am not getting..

Bootstrap 3 - jumbotron background image effect

Hi I'm trying to build a site with a jumbotron with a background image, which in itself is not hard: HTML: <div class="jumbotron"> ... </div> CSS: (which lies in my custom css file and..

Better way to find control in ASP.NET

I have a complex form,having even 50 to 60 fields in one form like there is Multiview, inside MultiView I have a GridView, and inside GridView I have several CheckBoxes. Currently I am using ..

Why is SQL Server 2008 Management Studio Intellisense not working?

I'm being driven to insanity trying to figure out why Intellisense just fails to work at all. The server I'm using is local and is 2008, the database is set to 2008 compatibility, Intellisense is on i..

Removing all line breaks and adding them after certain text

I have text file in which I have to remove all line breaks, and later add new ones after each text </row>. how could I do that using replace tool?..

How to write a large buffer into a binary file in C++, fast?

I'm trying to write huge amounts of data onto my SSD(solid state drive). And by huge amounts I mean 80GB. I browsed the web for solutions, but the best I came up with was this: #include <fstream&..

Do you need to dispose of objects and set them to null?

Do you need to dispose of objects and set them to null, or will the garbage collector clean them up when they go out of scope?..

Applying an ellipsis to multiline text

Is there a solution to add ellipsis on last line inside a div with a fluid height (20%)? I found the -webkit-line-clamp function in CSS, but in my case the line number will be depending on window siz..

How to make CSS width to fill parent?

I am sure this problem has been asked before but I cannot seem to find the answer. I have the following markup: <div id="foo"> <div id="bar"> here be dragons </div>..

Simulate a specific CURL in PostMan

I am using Postman to test some Curl requests to an API server. The API developers gave us the curl command, but I can't send it from the Postman. How to make such a request from the Postman? curl -X..

Splitting a string into chunks of a certain size

Suppose I had a string: string str = "1111222233334444"; How can I break this string into chunks of some size? e.g., breaking this into sizes of 4 would return strings: "1111" "2222" "3333" "44..

How can I escape double quotes in XML attributes values?

From the following trials <tag attr="\""> <tag attr="<![CDATA["]]>"> <tag attr='"'> Only the last one works for an XML parser that I'm using here. Is there an alternative?..

Pass form data to another page with php

I have a form on my homepage and when it is submitted, it takes users to another page on my site. I want to pass the form data entered to the next page, with something like: <?php echo $email; ?&g..

How to put a new line into a wpf TextBlock control?

I'm fetching text from an XML file, and I'd like to insert some new lines that are interpreted by the textblock render as new lines. I've tried: <data>Foo bar baz \n baz bar</data> But..

How to detect a loop in a linked list?

Say you have a linked list structure in Java. It's made up of Nodes: class Node { Node next; // some user data } and each Node points to the next node, except for the last Node, which has ..

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

Classpath including JAR within a JAR

Is it possible to specify a Java classpath that includes a JAR file contained within another JAR file?..

Delete the first three rows of a dataframe in pandas

I need to delete the first three rows of a dataframe in pandas. I know df.ix[:-1] would remove the last row, but I can't figure out how to remove first n rows...

How do I find an element position in std::vector?

I need to find an element position in an std::vector to use it for referencing an element in another vector: int find( const vector<type>& where, int searchParameter ) { for( int i = 0;..

How to select multiple rows filled with constants?

Selecting constants without referring to a table is perfectly legal in an SQL statement: SELECT 1, 2, 3 The result set that the latter returns is a single row containing the values. I was wondering..

jquery loop on Json data using $.each

I have the following JSON returned in a variable called data. THIS IS THE JSON THAT GETS RETURNED... [ {"Id": 10004, "PageName": "club"}, {"Id": 10040, "PageName": "qaz"}, {"Id": 10059, "PageName..

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 : $'f', 'filters[]'); // setter $['filters[]']; //..

Configure hibernate to connect to database via JNDI Datasource

Hi all I'm using Hibernate+Struts2+Tomcat6+Mysql as my J2EE framework. I've been using hibernate's built-in connection pooling mechanism but it turned out to be problematic where mysql closes it's con..

OS X cp command in Terminal - No such file or directory

this might be one of those days my brain just does not work, or i'm incredibly dumb. i've been trying to copy files (which are actually directories .app, .bundle, etc.) but consistently get an error '..

C# - How to get Program Files (x86) on Windows 64 bit

I'm using: FileInfo( System.Environment.GetFolderPath( System.Environment.SpecialFolder.ProgramFiles) + @"\MyInstalledApp" In order to determine if a program is detected on a users..

Displaying files (e.g. images) stored in Google Drive on a website

I was wondering if its possible to access/display files like images which are stored in Google Drive on a public website...

How to convert XML to JSON in Python?

Possible Duplicate: Converting XML to JSON using Python? I'm doing some work on App Engine and I need to convert an XML document being retrieved from a remote server into an equivalent JSON..

Find duplicate records in MongoDB

How would I find duplicate fields in a mongo collection. I'd like to check if any of the "name" fields are duplicates. { "name" : "ksqn291", "__v" : 0, "_id" : ObjectId("540f346c3e7fc105..

What is the best way to concatenate two vectors?

I'm using multitreading and want to merge the results. For example: std::vector<int> A; std::vector<int> B; std::vector<int> AB; I want AB to have to contents of A and the content..

How to retrieve raw post data from HttpServletRequest in java

I'm trying to get the post data in Java. Seems like it should be one of the simplest things to do right? I mean, HttpServletRequest.getParameter has to do it right? So how can you get the raw post dat..

Execute jQuery function after another function completes

I want to execute a custom jQuery function after another custom function completes The first function is used for creating a "typewriting" effect function Typer() { var srcText = 'EXAMPLE '; ..

Vuex - Computed property "name" was assigned to but it has no setter

I have a component with some form validation. It is a multi step checkout form. The code below is for the first step. I'd like to validate that the user entered some text, store their name in the glob..

Elasticsearch difference between MUST and SHOULD bool query

What is the difference between MUST and SHOULD bool query in ES? If I ONLY want results that contain my terms should I then use must ? I have a query that should only contain certain values, and als..

Why doesn't Python have a sign function?

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

How do I get the path of the Python script I am running in?

Duplicate: In Python, how do I get the path and name of the file that is currently executing? How do I get the path of a the Python script I am running in? I was doing dirname(sys.argv[0]), h..

Docker container not starting (docker start)

I created the container with the following command: docker run -d -p 52022:22 basickarl/docker-git-test Here are the commands: root@basickarl:~# docker ps CONTAINER ID IMAGE C..

Calling a function when ng-repeat has finished

What I am trying to implement is basically a "on ng repeat finished rendering" handler. I am able to detect when it is done but I can't figure out how to trigger a function from it. Check the fiddle:..

Launch Failed. Binary not found. CDT on Eclipse Helios

I'm using Eclipse Helios on Ubuntu 10.04, and I'm trying to install CDT plugin on it. I download it from here here. And then I go to Install New Software and select the zip file (I don't extract it,..

Ajax LARAVEL 419 POST error

I would really appreciate some help on this. I tried tons of solutions as posted in this forum, but I cannot get it to work. My ajax call is something like $(document).ready(function() { $("#co..

How to use vertical align in bootstrap

Simple problem: How do I vertically align a col within a col using bootstrap? Example here (I want to vertically align child1a and child1b): HTML <div class="col-lg-12"..

How to drop all tables from a database with one SQL query?

I don't want to type all tables' name to drop all of them. Is it possible with one query?..

Android replace the current fragment with another fragment

I just started with fragment design for HoneyComb. I created two fragments. When i click a button in the left side fragment, a new fragment is created in right side. Meanwhile when i click a button i..

What is

Why does exist? Why does each XML Webservice require its own namespace, unique from any other on the web?..

Java character array initializer

I tried to make a program that separates characters. The question is: "Create a char array and use an array initializer to initialize the array with the characters in the string 'Hi there'. Display..

Check if string has space in between (or anywhere)

Is there a way to determine if a string has a space(s) in it? sossjjs sskkk should return true, and sskskjsk should return false. "sssss".Trim().Length does not seem to work...


I've found a few "would be" solutions for the classic "How do I insert a new record or update one if it already exists" but I cannot get any of them to work in SQLite. I have a table defined as follo..

How to make external HTTP requests with Node.js

The question is fairly simple. I want to use a Node.js server as a proxy to log, authenticate, and forward HTTP queries to a backend HTTP server (PUT, GET, and DELETE requests). What library should I..

Add new attribute (element) to JSON object using JavaScript

How do I add new attribute (element) to JSON object using JavaScript?..

Changing the tmp folder of mysql

Our Mysql queries use temporary tables which creates temporary files in the process. Currently the files are written to /tmp. How exactly can the path of the temp folder to which mysql writes to be ch..

Load Image from javascript

On my album slide show page, i have code like <span style="display:none;"> <img id="id1" src="~$imageUrl`" onload="javascript:showImage();"> </span> <span> // show loa..

How can I add a space in between two outputs?

This is the code I am working with. public void displayCustomerInfo() { System.out.println(Name + Income); } I use a separate main method with this code to call the method above: first.displa..

How do I set a cookie on HttpClient's HttpRequestMessage

I am trying to use the web api's HttpClient to do a post to an endpoint that requires login in the form of an HTTP cookie that identifies an account (this is only something that is #ifdef'ed out of th..

Reverse a string in Java

I have "Hello World" kept in a String variable named hi. I need to print it, but reversed. How can I do this? I understand there is some kind of a function already built-in into Java that does that...

How to get current date in jquery?

I want to know how to use the Date() function in jQuery to get the current date in a yyyy/mm/dd format...

What's the simplest way to print a Java array?

In Java, arrays don't override toString(), so if you try to print one directly, you get the className + '@' + the hex of the hashCode of the array, as defined by Object.toString(): int[] intArray = n..

Strip HTML from strings in Python

from mechanize import Browser br = Browser()'http://somewebpage') html = br.response().readlines() for line in html: print line When printing a line in an HTML file, I'm trying to find a ..

HTML img tag: title attribute vs. alt attribute?

I was browsing Amazon and I noticed that when searching "1TB" if you hover the mouse cursor over the stars rating image, you only see the score if using IE. If you are using another browser then the..

Copy Notepad++ text with formatting?

I'm using Notepad++ to write code. How do I copy code in Notepad++ along with its formatting to paste into Microsoft Word? (i.e. syntax highlights, etc)..

OpenMP set_num_threads() is not working

I am writing a parallel program using OpenMP in C++. I want to control the number of threads in the program using omp_set_num_threads(), but it does not work. #include <iostream> #include <..

Correct way to set Bearer token with CURL

I get my bearer token from an API end point and set the following: $authorization = "Bearer 080042cad6356ad5dc0a720c18b53b8e53d4c274" Next I want to use CURL to access the secure endpoint however I..

How to add custom Http Header for C# Web Service Client consuming Axis 1.4 Web service

I'm trying to write a web service client in c# which the webservice is Java Axis 1.4. Axis service requires the Authorization: Basic Base64EncodedToken header value in the HTTP Headers. I can't find ..

How to store a dataframe using Pandas

Right now I'm importing a fairly large CSV as a dataframe every time I run the script. Is there a good solution for keeping that dataframe constantly available in between runs so I don't have to spend..

Callback to a Fragment from a DialogFragment

Question: How does one create a callback from a DialogFragment to another Fragment. In my case, the Activity involved should be completely unaware of the DialogFragment. Consider I have public clas..

Parsing JSON using

I'm trying to parse some JSON using the JSon.Net library. The documentation seems a little sparse and I'm confused as to how to accomplish what I need. Here is the format for the JSON I need to pars..

Explanation of BASE terminology

The BASE acronym is used to describe the properties of certain databases, usually NoSQL databases. It's often referred to as the opposite of ACID. There are only few articles that touch upon the deta..

Draw an X in CSS

I've got a div that looks like a orange square I'd like to draw a white X in this div somehow so that it looks more like Anyway to do this in CSS or is it going to be easier to just draw this in..

Spring Security exclude url patterns in security annotation configurartion

I have spring web application with Spring security configured using java config approach. I want to exclude some URL patterns from authentication(eg: static resources etc..). I have done this earlier ..

Command to change the default home directory of a user

I would like to know whether there is any simple shell command to change the user home directory in Linux/Unix (one similar to chsh which changes the default login shell of an existing valid user) wit..

How can I selectively merge or pick changes from another branch in Git?

I'm using Git on a new project that has two parallel -- but currently experimental -- development branches: master: import of existing codebase plus a few modifications that I'm generally sure of exp..

Angular 2: Get Values of Multiple Checked Checkboxes

My problem is really simple: I have a list of checkboxes like this: <div class="form-group"> <label for="options">Options :</label> <label *ngFor="#option of options" cla..

How to find Current open Cursors in Oracle

What is the query to find the no. of current open cursors in an Oracle Instance? Also, what is the accuracy/update frequency of this data? I am using Oracle 10gR2..

How to get the mysql table columns data type?

I want to get the column data type of a mysql table. Thought I could use MYSQLFIELD structure but it was enumerated field types. Then I tried with mysql_real_query() The error which i am getting is..

Check if SQL Connection is Open or Closed

How do you check if it is open or closed I was using if (SQLOperator.SQLCONNECTION.State.Equals("Open")) however, even the State is 'Open' it fails on this check...

C# get string from textbox

I am just a noob in C#, and I've got this question to ask you. I have here a form that asks for login details. It has two textfields: Username Password What I want is to get the strings entered ..

How to get the server path to the web directory in Symfony2 from inside the controller?

The question is as follows: How can I get the server path to the web directory in Symfony2 from inside the controller (or from anywhere else for that reason) What I've already found (also, by search..

Django -- Template tag in {% if %} block

I have the following dictionary passed to a render function, with sources being a list of strings and title being a string potentially equal to one of the strings in sources: {'title':title, 'sources..

How do I import a Swift file from another Swift file?

I simply want to include my Swift class from another file, like its test PrimeNumberModel.swift import Foundation class PrimeNumberModel { } PrimeNumberModelTests.swift import XCTest import Prim..

Correct use of flush() in JPA/Hibernate

I was gathering information about the flush() method, but I'm not quite clear when to use it and how to use it correctly. From what I read, my understanding is that the contents of the persistence con..

Angular 2 router.navigate

I'm trying to navigate to a route in Angular 2 with a mix of route and query parameters. Here is an example route where the route is the last part of the path: { path: ':foo/:bar/:baz/page', compon..

Converting a Pandas GroupBy output from Series to DataFrame

I'm starting with input data like this df1 = pandas.DataFrame( { "Name" : ["Alice", "Bob", "Mallory", "Mallory", "Bob" , "Mallory"] , "City" : ["Seattle", "Seattle", "Portland", "Seattle", ..

Shortcut for creating single item list in C#

In C#, is there an inline shortcut to instantiate a List<T> with only one item. I'm currently doing: new List<string>( new string[] { "title" } )) Having this code everywhere reduces r..

How do you get the "object reference" of an object in java when toString() and hashCode() have been overridden?

I would like to print the "object reference" of an object in Java for debugging purposes. I.e. to make sure that the object is the same (or different) depending on the situation. The problem is that ..

AngularJS access parent scope from child controller

I've set up my controllers using data-ng-controller="xyzController as vm" I have a scenario with parent / child nested controllers. I have no problem accessing parent properties in the nested html by..

HTML5 <video> element on Android

According to: Android 2.0 should support the HTML5 video element. I haven't been able to get this to work using a Motorola Droid, and hav..

Scheduling recurring task in Android

I'm designing an app that has a recurring task of sending presence to a dedicated server as long as the app is in foreground. In my searches across the web I saw a few different approaches and wanted..

error: pathspec 'test-branch' did not match any file(s) known to git

I am a new user of Git. I have forked a repository called Spoon-Knife (available for practicing forking with Git). Then, I cloned it locally by running git clone

Limit the output of the TOP command to a specific process name

If you call the top command, you get all the running processes. But how can I limit the output only to a certain process name like "java"? I've tried this top -l 2 | grep java but in this way you g..

Angularjs autocomplete from $http

I'm trying to write an autocomplete directive that fetches data from the server using an $http request (without using any external plugins or scripts). Currently it works only with static data. Now, I..

What is the difference between typeof and instanceof and when should one be used vs. the other?

In my particular case: callback instanceof Function or typeof callback == "function" does it even matter, what's the difference? Additional Resource: JavaScript-Garden typeof vs instanceof..

How do I find which rpm package supplies a file I'm looking for?

As an example, I am looking for a file which presumably would come with the php-devel package. I guessed that yum would install the file with the php-devel x86_64 5.1.6-23.2...

How to retrieve the dimensions of a view?

I have a view made up of TableLayout, TableRow and TextView. I want it to look like a grid. I need to get the height and width of this grid. The methods getHeight() and getWidth() always return 0. ..

Getting request payload from POST request in Java servlet

I have a javascript library that is sending a POST request to my Java servlet, but in the doPost method, I can't seem to get the contents of the request payload. In chrome Developer Tools, all the con..

How to send and retrieve parameters using $state.go toParams and $stateParams?

I am using AngularJS v1.2.0-rc.2 with ui-router v0.2.0. I want to pass the referrer state to another state so I use the toParams of $state.go like so: $state.go('toState', {referer: $

get string value from HashMap depending on key name

I have a HashMap with various keys and values, how can I get one value out? I have a key in the map called my_code, it should contain a string, how can I just get that without having to iterate throu..

MySQL command line client for Windows

Is there any nice command line MySQL client for windows? I mean a single exe that allows connecting and running a sample query. I've googled and only could find big graphical environments like toad or..

how to create inline style with :before and :after

I generated a bubble chat thingy from In my page I put a number inside of it .bubble { position: relative; width: 20px; height: 15px; padding: 0; ..

How to check if element is visible after scrolling?

I'm loading elements via AJAX. Some of them are only visible if you scroll down the page. Is there any way I can know if an element is now in the visible part of the page?..

How can I reset eclipse to default settings?

One of the top reasons I use an IDE editor is to get context information about the classes I am working on. Right now I have lost the java method context information, and have no idea where to reset ..

when I run mockito test occurs WrongTypeOfReturnValue Exception

Error detail: org.mockito.exceptions.misusing.WrongTypeOfReturnValue: Boolean cannot be returned by updateItemAttributesByJuId() updateItemAttributesByJuId() should return ResultRich This exception ..

Batch file to perform start, run, %TEMP% and delete all

looking for a way to perform the following: Start > Run > "%TEMP% > Delete everything (skipping any conflicts). so Far I have @echo off start %TEMP% DEL *.* I suppose I could use CD to get to the..

Python urllib2 Basic Auth Problem

Update: based on Lee's comment I decided to condense my code to a really simple script and run it from the command line: import urllib2 import sys username = sys.argv[1] password = sys.argv[2] url =..

Getting assembly name

C#'s exception class has a source property which is set to the name of the assembly by default. Is there another way to get this exact string (without parsing a different string)? I have tried the ..

Why is my power operator (^) not working?

#include <stdio.h> void main(void) { int a; int result; int sum = 0; printf("Enter a number: "); scanf("%d", &a); for( int i = 1; i <= 4; i++ ) { resu..

Configuring angularjs with eclipse IDE

I want to start using AngularJs and Java Spring for development purpose.I am using Eclipse as IDE . I want to configure my Eclipse to have these frameworks working seamlessly. I know I may be asking ..

Returning a value from thread?

How do I return a value from a thread?..

How do I expire a PHP session after 30 minutes?

I need to keep a session alive for 30 minutes and then destroy it. ..

read subprocess stdout line by line

My python script uses subprocess to call a linux utility that is very noisy. I want to store all of the output to a log file and show some of it to the user. I thought the following would work, but ..

angularjs to output plain text instead of html

I have some text like this: <span>My text</span> I want to display without tags: My text I also don't want to apply the tags, I want to strip them. What's an easy way to do that? An..

Deserialize a JSON array in C#

I'm stuck with a tricky problem. I've a JSON string of this format: [{ "record": { "Name": "Komal", "Age": 24, "Location": "Siliguri" } ..

Why do I get "warning longer object length is not a multiple of shorter object length"?

I have dataframe dih_y2. These two lines give me a warning: > memb = dih_y2$MemberID[1:10] > dih_col = which(dih_y2$MemberID == memb) Warning message: In dih_y2$MemberID == memb : longer obje..

Difference between database and schema

What's the difference between a Database and a Schema in SQL Server? Both are the containers of tables and data. If a Schema is deleted, then are all the tables contained in that schema also deleted ..

SQL query for getting data for last 3 months

How can you get today's date and convert it to 01/mm /yyyy format and get data from the table with delivery month 3 months ago? Table already contains delivery month as 01/mm/yyyy...

Android Volley - BasicNetwork.performRequest: Unexpected response code 400

Problem statement: I am trying to access an REST API that will return a JSON object for various HTTP status codes (400, 403, 200 etc) using Volley. For any HTTP status other than 200, it seems the '..

mcrypt is deprecated, what is the alternative?

The mcrypt-extension is deprecated will be removed in PHP 7.2 according to the comment posted here. So I am looking for an alternative way to encrypt passwords. Right now I am using something like m..

How do I allow HTTPS for Apache on localhost?

I was asked to set up HTTPS with a self-signed cert on Apache on localhost, but how do I actually do that? I have no idea at all...

How to write std::string to file?

I want to write a std::string variable I am accepting from the user to a file. I tried using the write() method and it writes to the file. But when I open the file I see boxes instead of the string. ..

How to change the pop-up position of the jQuery DatePicker control

Any idea how to get the DatePicker to appear at the end of the associated text box instead of directly below it? What tends to happen is that the text box is towards the bottom of the page and the Dat..

How to determine if a decimal/double is an integer?

How do I tell if a decimal or double value is an integer? For example: decimal d = 5.0; // Would be true decimal f = 5.5; // Would be false or double d = 5.0; // Would be true double f = 5.5; //..

is vs typeof

Which of these pieces of code is faster? if (obj is ClassA) {} if (obj.GetType() == typeof(ClassA)) {} Edit: I'm aware that they don't do the same thing...

Accuracy Score ValueError: Can't Handle mix of binary and continuous target

I'm using linear_model.LinearRegression from scikit-learn as a predictive model. It works and it's perfect. I have a problem to evaluate the predicted results using the accuracy_score metric. This is ..

Python send UDP packet

I am trying to write a program to send UDP packets, as in The code appears to be in Python 2: import socket UDP_IP = "" UDP_PORT = 5005 MESSAG..

Codeigniter displays a blank page instead of error messages

I'm using Codeigniter, and instead of error messages I'm just getting a blank page. Is there any way to show PHP error messages instead? It's very hard to debug when I get no feedback. My environment..

Location of ini/config files in linux/unix?

Two questions, really: Is there a standard/convention regarding the placement on configuration files? For system or quasi-system programs they seem to usually be somewhere in /etc. It seems less..

getSupportActionBar() The method getSupportActionBar() is undefined for the type TaskActivity. Why?

I was recommended to extend my Activity class from ActionBarActivity Here is the previous code: import; import; public cl..

Foreign Key to non-primary key

I have a table which holds data, and one of those rows needs to exist in another table. So, I want a foreign key to maintain referential integrity. CREATE TABLE table1 ( ID INT NOT NULL IDENTITY(1..

DbEntityValidationException - How can I easily tell what caused the error?

I have a project that uses Entity Framework. While calling SaveChanges on my DbContext, I get the following exception: System.Data.Entity.Validation.DbEntityValidationException: Validation faile..

How do you performance test JavaScript code?

CPU Cycles, Memory Usage, Execution Time, etc.? Added: Is there a quantitative way of testing performance in JavaScript besides just perception of how fast the code runs?..

How to split page into 4 equal parts?

I want to divide my page into four equal parts, each of same height and width (50-50%). I don't want to use JavaScript. I want blocks (<div>s) to be resized automatically (and relatively) if th..

List all virtualenv

In virtualenvwrapper, is there a simple way to list all virtualenv on my machine? (like what yolk -l does to list all python packages in the current virtual environment?) CLARIFICATION: "ls -la" in..

Sorting data based on second column of a file

I have a file of two columns and n number of rows. column 1 contains names and column2 age. I want to sort the content of this file in ascending order based on the age (in second column). The resul..

Hide keyboard in react-native

If I tap onto a textinput, I want to be able to tap somewhere else in order to dismiss the keyboard again (not the return key though). I haven't found the slightest piece of information concerning thi..

How can I change IIS Express port for a site

I want to change the port number on which my website runs while debugging from Visual Studio. I am using Visual Studio 2012, and I am using ASP.NET MVC 4 for my projects I want to change the port. Ran..

Unicode (UTF-8) reading and writing to files in Python

I'm having some brain failure in understanding reading and writing text to a file (Python 2.4). # The string, which has an a-acute in it. ss = u'Capit\xe1n' ss8 = ss.encode('utf8') repr(ss), repr(ss8..

ssh_exchange_identification: Connection closed by remote host under Git bash

I work at win7 and set up git server with sshd. I git --bare init myapp.git, and clone ssh://git@localhost/home/git/myapp.git in Cywgin correctly. But I need config git of Cygwin again, I want to git ..

How to cast ArrayList<> from List<>

Can somebody please explain me why I can't cast List<> to ArrayList<> with first approach and I do with second one? Thank you. First approach: ArrayList<Task> tmp = ((ArrayList<..

Add/remove class with jquery based on vertical scroll?

So basically I'd like to remove the class from 'header' after the user scrolls down a little and add another class to change it's look. Trying to figure out the simplest way of doing this but I can't..

R memory management / cannot allocate vector of size n Mb

I am running into issues trying to use large objects in R. For example: > memory.limit(4000) > a = matrix(NA, 1500000, 60) > a = matrix(NA, 2500000, 60) > a = matrix(NA, 3500000, 60) Erro..

How to log PostgreSQL queries?

How to enable logging of all SQL executed by PostgreSQL 8.3? Edited (more info) I changed these lines : log_directory = 'pg_log' log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' l..

How do I use PHP namespaces with autoload?

I get this error when I try to use autoload and namespaces: Fatal error: Class 'Class1' not found in /usr/local/www/apache22/data/public/php5.3/test.php on line 10 Can anyone tell me what I am d..

Maximum length of HTTP GET request

What's the maximum length of an HTTP GET request? Is there a response error defined that the server can/should return if it receives a GET request that exceeds this length? This is in the context of..

Is there a way I can retrieve sa password in sql server 2005

I just forgot the password. Can anyone help me how to get back the password...

How do you determine the ideal buffer size when using FileInputStream?

I have a method that creates a MessageDigest (a hash) from a file, and I need to do this to a lot of files (>= 100,000). How big should I make the buffer used to read from the files to maximize perfor..

Android TextView Text not getting wrapped

Can anyone tell me what's going wrong with the text? Text longer than one line doesn't wrap to the next line but goes beyond the screen. Following is the code: <LinearLayout xmlns:android="http:/..

Executing an EXE file using a PowerShell script

I'm trying to execute an EXE file using a PowerShell script. If I use the command line it works without a problem (first I supply the name of the executable and series of parameters to invoke it): "C..

Why do we assign a parent reference to the child object in Java?

I am asking a quite simple question, but I am bit confused in this. Suppose I have a class Parent: public class Parent { int name; } And have another class Child: public class Child extends Pare..

How to set breakpoints in inline Javascript in Google Chrome?

When I open Developer Tools in Google Chrome, I see all kinds of features like Profiles, Timelines, and Audits, but basic functionality like being able to set breakpoints both in js files and within h..

Eclipse - no Java (JRE) / (JDK) ... no virtual machine

I am trying to get Eclipse v3.5 (Galileo) to re-run on my computer - I have run it before with no problems, but now I keep getting this error: A Java Runtime Environment (JRE) or Java Develop..

AngularJS: ng-show / ng-hide not working with `{{ }}` interpolation

I am trying to show / hide some HTML using the ng-show and ng-hide functions provided by AngularJS. According to the documentation, the respective usage for these functions are as follows: ngHide..

Service vs IntentService in the Android platform

I am seeking an example of something that can be done with an IntentService that cannot be done with a Service (and vice-versa)? I also believe that an IntentService runs in a different thread and a ..

Function passed as template argument

I'm looking for the rules involving passing C++ templates functions as arguments. This is supported by C++ as shown by an example here: #include <iostream> void add1(int &v) { v+=1; } ..

How can I return the current action in an ASP.NET MVC view?

I wanted to set a CSS class in my master page, which depends on the current controller and action. I can get to the current controller via ViewContext.Controller.GetType().Name, but how do I get the c..

How to undo a git pull?

I would like to undo my git pull on account of unwanted commits on the remote origin, but I don't know to which revision I have to reset back to. How can I just go back to the state before I did the ..


Does anyone know how I can do an inner joins and alias values within so they won't overwrite each other? It might look more clear if you see my code: SELECT home, away,, g.date_start ..

Could not find or load main class org.gradle.wrapper.GradleWrapperMain

I cleaned the whole project by deleting local directories like ~/.gradle, ~/.m2 ~./android and ~/workspace/project/.gradle and chosing File -> Invalidate Caches / Restart... in Android Studio. Now ..

How to grey out a button?

I have a button defined as shown below. When I want to disable it I use my_btn.setEnabled(false), but I would also like to grey it out. How can I do that? Thanks <Button android:id="@+id/buy_btn"..

.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

I have this error when trying to browse php files locally [Fri Apr 13 19:16:40 2012] [alert] [client] C:/AppServ/www/hr-website/.htaccess: Invalid command 'RewriteEngine', perhaps misspelle..

Error: Node Sass does not yet support your current environment: Windows 64-bit with false

E:\A Prem World\Team_Work_Tasks\Anjali\Anjali_20160524\QuizApp_20160524_01_Anj>ionic serve -l (node:4772) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs ..

Android sqlite how to check if a record exists

I would like to check whether a record exists or not. Here is what I've tried: MainActivity.class public void onTextChanged(CharSequence s, int start, int before, int count) { System...

How to add shortcut keys for java code in eclipse

Say I type "sout", the intellisense should expand it to "System.out.println()". Is there a way to adding such templates?..

How can I plot with 2 different y-axes?

I would like superimpose two scatter plots in R so that each set of points has its own (different) y-axis (i.e., in positions 2 and 4 on the figure) but the points appear superimposed on the same figu..

SSH library for Java

Does anyone have an example of an SSH library connection using Java...

How to change maximum number of POST variable in PHP?

I'm using WAMP in my local machine, when a FORM(method="POST") with 2000 input fields is submitted I'm able to read only 1001 _POST variable. i.e With Netbeans debugger I can clearly see _PO..

How to get access to raw resources that I put in res folder?

In J2ME, I've do this like that: getClass().getResourceAsStream("/raw_resources.dat"); But in android, I always get null on this, why?..