Examples On Programing Languages

How do I add an element to a list in Groovy?

Let's say I've got a list, like this... def myList = ["first", 2, "third", 4.0]; How do I add (push) an element to the end of it? I come from a PHP background, and there I would just do something like $myList[] = "fifth";. What's the equivalent of...

C++ queue - simple example

I can't find simple example how to use queues in C++ for pointers to some myclass objects. I have code like this: class myclass{ string s; }; myclass *p = new myclass(); my_queue.push(p); //something.... p = my_queue.front(); my_queue.pop(); ...

SQL count rows in a table

I need to send a SQL query to a database that tells me how many rows there are in a table. I could get all the rows in the table with a SELECT and then count them, but I don't like to do it this way. Is there some other way to ask the number of the r...

Meaning of delta or epsilon argument of assertEquals for double values

I have a question about JUnit assertEquals to test double values. Reading the API doc I can see: @Deprecated public static void assertEquals(double expected, double actual) Deprecated. Use assertEquals(double expected, double actual, double delta) ...

Convert DateTime to TimeSpan

I want to convert a DateTime instance into a TimeSpan instance, is it possible? I've looked around but I couldn't find what I want, I only find time difference. More specifically, I want to convert a DateTime instance into milliseconds, to then sav...

Rearrange columns using cut

I am having a file in the following format Column1 Column2 str1 1 str2 2 str3 3 I want the columns to be rearranged. I tried below command cut -f2,1 file.txt The command doesn't reorder the columns. Any idea why its not...

How to remove unique key from mysql table

I need to remove a unique key from my mysql table. How can remove that using mysql query. I tried this but it is not working alter table tbl_quiz_attempt_master drop unique key; Please help me Thanks...

Turn Pandas Multi-Index into column

I have a dataframe with 2 index levels: value Trial measurement 1 0 13 1 3 2 4 2 0 NaN 1 12 ...

save a pandas.Series histogram plot to file

In ipython Notebook, first create a pandas Series object, then by calling the instance method .hist(), the browser displays the figure. I am wondering how to save this figure to a file (I mean not by right click and save as, but the commands needed...

Spring Bean Scopes

Can someone explain what the scopes are in Spring beans I've always just used 'prototype' but are there other parameters I can put in place of that? Example of what I'm talking about <bean id="customerInfoController" class="com.action.Controller...

How to close a Java Swing application from the code

What is the proper way to terminate a Swing application from the code, and what are the pitfalls? I'd tried to close my application automatically after a timer fires. But just calling dispose() on the JFrame didn't do the trick - the window vanished...

Android: How to overlay a bitmap and draw over a bitmap?

I have three questions actually: Is it better to draw an image on a bitmap or create a bitmap as resource and then draw it over a bitmap? Performance wise, which one is better? If I want to draw something transparent over a bitmap, how would I go a...

Boto3 to download all files from a S3 Bucket

I'm using boto3 to get files from s3 bucket. I need a similar functionality like aws s3 sync My current code is #!/usr/bin/python import boto3 s3=boto3.client('s3') list=s3.list_objects(Bucket='my_bucket_name')['Contents'] for key in list: s3.d...

How do I prevent a Gateway Timeout with FastCGI on Nginx

I am running Django, FastCGI, and Nginx. I am creating an api of sorts that where someone can send some data via XML which I will process and then return some status codes for each node that was sent over. The problem is that Nginx will throw a 504...

How to open SharePoint files in Chrome/Firefox

In Internet Explorer, I can open Sharepoint files directly from their links so the file in Sharepoint is automatically updated when I save it. But in Chrome, it asks to download the file instead of just opening it. In Firefox, it can open the file bu...

pandas: find percentile stats of a given column

I have a pandas data frame my_df, where I can find the mean(), median(), mode() of a given column: my_df['field_A'].mean() my_df['field_A'].median() my_df['field_A'].mode() I am wondering is it possible to find more detailed stats such as 90 perce...

How to import and export components using React + ES6 + webpack?

I'm playing around with React and ES6 using babel and webpack. I want to build several components in different files, import in a single file and bundle them up with webpack Let's say I have a few components like this: my-navbar.jsx import React f...

Java Date vs Calendar

Could someone please advise the current "best practice" around Date and Calendar types. When writing new code, is it best to always favour Calendar over Date, or are there circumstances where Date is the more appropriate datatype?...

Java JTable getting the data of the selected row

Are there any methods that are used to get the data of the selected row? I just want to simply click a specific row with data on it and click a button that will print the data in the Console. ...

AngularJS : Initialize service with asynchronous data

I have an AngularJS service that I want to initialize with some asynchronous data. Something like this: myModule.service('MyService', function($http) { var myData = null; $http.get('data.json').success(function (data) { myData = dat...

CSS pseudo elements in React

I'm building React components. I have added CSS inline in the components as suggested in this brilliant presentation by one of the guys behind React. I've been trying all night to find a way to add CSS pseudo classes inline, like on the slide titled ...

Why are my PowerShell scripts not running?

I wrote a simple batch file as a PowerShell script, and I am getting errors when they run. It's in a scripts directory in my path. This is the error I get: Cannot be loaded because the execution of scripts is disabled on this system. Please ...

How to "set a breakpoint in malloc_error_break to debug"

I'm getting lots of console outputs like this without my application crashing: malloc: * error for object 0xc6a3970: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug How can I find out which object or...

Split string into array of characters?

How is it possible to split a VBA string into an array of characters? I tried Split(my_string, "") but this didn't work....

How many concurrent requests does a single Flask process receive?

I'm building an app with Flask, but I don't know much about WSGI and it's HTTP base, Werkzeug. When I start serving a Flask application with gunicorn and 4 worker processes, does this mean that I can handle 4 concurrent requests? I do mean concurren...

Configure WAMP server to send email

Is there a way that I can configure the WAMP server for PHP to enable the mail() function?...

How does jQuery work when there are multiple elements with the same ID value?

I fetch data from Google's AdWords website which has multiple elements with the same id. Could you please explain why the following 3 queries doesn't result with the same answer (2)? Live Demo HTML: <div> <span id="a">1</span&g...

How can I split a delimited string into an array in PHP?

I need to split my string input into an array at the commas. How can I go about accomplishing this? Input: 9,[email protected],8 ...

How to obtain values of request variables using Python and Flask

I'm wondering how to go about obtaining the value of a POST/GET request variable using Python with Flask. With Ruby, I'd do something like this: variable_name = params["FormFieldValue"] How would I do this with Flask?...

Tomcat Servlet: Error 404 - The requested resource is not available

I am completely new to writing a Java Servlet, and am struggling to get a simple HelloWorld example to work properly. The HelloWorld.java class is: package crunch; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public clas...

Python: converting a list of dictionaries to json

I have a list of dictionaries, looking some thing like this: list = [{'id': 123, 'data': 'qwerty', 'indices': [1,10]}, {'id': 345, 'data': 'mnbvc', 'indices': [2,11]}] and so on. There may be more documents in the list. I need to convert these to ...

Read entire file in Scala?

What's a simple and canonical way to read an entire file into memory in Scala? (Ideally, with control over character encoding.) The best I can come up with is: scala.io.Source.fromPath("file.txt").getLines.reduceLeft(_+_) or am I supposed to use...

Spring Test & Security: How to mock authentication?

I was trying to figure out how to unit test if my the URLs of my controllers are properly secured. Just in case someone changes things around and accidentally removes security settings. My controller method looks like this: @RequestMapping("/api/v...

How to copy from CSV file to PostgreSQL table with headers in CSV file?

I want to copy a CSV file to a Postgres table. There are about 100 columns in this table, so I do not want to rewrite them if I don't have to. I am using the \copy table from 'table.csv' delimiter ',' csv; command but without a table created I get E...

Error System.Data.OracleClient requires Oracle client software version 8.1.7 or greater when installs setup

I have made a desktop app Setup that connects with remote Oracle 10g Database. When I install Setup on remote machine and run my application then I get following error: system.data.oracleclient requires oracle client software version 8.1.7 or greate...

CSS media queries for screen sizes

I am currently trying to design a layout which will be compatible for multiple screen sizes. The screen sizes I am designing for are listed below: Screen Sizes: 640x480 800x600 1024x768 1280x1024 (and larger) The thing that I'm having trouble w...

Android Recyclerview GridLayoutManager column spacing

How do you set the column spacing with a RecyclerView using a GridLayoutManager? Setting the margin/padding inside my layout has no effect....

XMLHttpRequest cannot load XXX No 'Access-Control-Allow-Origin' header

tl;dr; About the Same Origin Policy I have a Grunt process which initiates an instance of express.js server. This was working absolutely fine up until just now when it started serving a blank page with the following appearing in the error log in the...

Why is Git better than Subversion?

I've been using Subversion for a few years and after using SourceSafe, I just love Subversion. Combined with TortoiseSVN, I can't really imagine how it could be any better. Yet there's a growing number of developers claiming that Subversion has p...

Redirect to specified URL on PHP script completion?

How can I get a PHP function go to a specific website when it is done running? For example: <?php //SOMETHING DONE GOTO(http://example.com/thankyou.php); ?> I would really like the following... <?php //SOMETHING DONE GOTO($url);...

Getting java.net.SocketTimeoutException: Connection timed out in android

I'm relatively new to android development. I'm developing an android application where I'm sending requests to the web server and parsing JSON objects. Frequently I'm getting java.net.SocketTimeoutException: Connection timed out exception while commu...

Adding background image to div using CSS

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

How to add a new column to an existing sheet and name it?

Suppose I have the worksheet below: Empid EmpName Sal 1 david 100 2 jhon 200 3 steve 300 How can I insert a new column named "Loc"? Empid EmpName Loc Sal 1 david uk 100 2 jhon us 200 3 ...

repository element was not specified in the POM inside distributionManagement element or in -DaltDep loymentRepository=id::layout::url parameter

I'm having a problem while deploying and here is the error message I get: [INFO] [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ core --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILU...

Saving a text file on server using JavaScript

Is it possible to save text to a new text file using JavaScript/jQuery without using PHP? The text I'm trying to save may contain HTML entities, JS, HTML, CSS and PHP scripts that I don't want to escape or use urlencode! If it's only can be achieved...

Aligning a button to the center

I have a simple submit button. I am wanting to align it to the center. Here is my code: <input type="submit" name="btnSubmit" value="Submit" onClick="Submit" align="center"> However, it does not work. What is the best/easiest way to do this?...

How do you determine a processing time in Python?

I'm new to Python, and confused by the date/time documentation. I want to compute the time that it takes to perform a computation. In java, I would write: long timeBefore = System.currentTimeMillis(); doStuff(); long timeAfter = System.currentTime...

Change grid interval and specify tick labels in Matplotlib

I am trying to plot counts in gridded plots, but I am not being able to figure out how I go about it. I want to: Have dotted grids at an interval of 5 Have major tick labels only every 20 I want the ticks to be outside the plot. Have "counts...

Should I use Vagrant or Docker for creating an isolated environment?

I use Ubuntu for development and deployment and have a need for creating an isolated environment. I am considering either Vagrant or Docker for this purpose. What are the pros and cons, or how do these solutions compare?...

How to use KeyListener

I am currently trying to implement a keylistener in my program so that it does an action when I pressed an arrow key, the object in my program either moves left or right. Here is the moving method in my program public void moveDirection(KeyEvent e)...

Find what 2 numbers add to something and multiply to something

Hey so I'm making a factoring program and I'm wondering if anyone can give me any ideas on an efficient way to find what two numbers multiple to a specified number, and also add to a specified number. for example I may have (a)(b) = 6 a + b = 5 S...

SVN Commit failed, access forbidden

Recently I am facing problem of commit to SVN. The SVN server I am using is VisualSVN Server 2.5.9 and the client is TortoiseSVN 1.7.12. At first, one user is having problem to commit files to SVN. But that user still can access to the repository an...

How to make layout with View fill the remaining space?

I'm designing my application UI. I need a layout looks like this: (< and > are Buttons). The problem is, I don't know how to make sure the TextView will fill the remaining space, with two buttons have fixed size. If I use fill_parent for Text ...

Any way to return PHP `json_encode` with encode UTF-8 and not Unicode?

Any way to return PHP json_encode with encode UTF-8 and not Unicode? $arr=array('a'=>'รก'); echo json_encode($arr); mb_internal_encoding('UTF-8');and $arr=array_map('utf8_encode',$arr); does not fix it. Result: {"a":"\u00e1"} Expected result:...

Bootstrap: Use .pull-right without having to hardcode a negative margin-top

This is my code (please see fiddle here): <div class='container'> <div class='hero-unit'> <h2>Welcome</h2> <p>Please log in</p> <div id='login-box' class='pull-right control-group'&...

Detect if range is empty

I want to check if a range in Excel is empty. How do I write in VBA code: If Range("A38":"P38") is empty ...

Seeking useful Eclipse Java code templates

You can create various Java code templates in Eclipse via Window > Preferences > Java > Editor > Templates e.g. sysout is expanded to: System.out.println(${word_selection}${});${cursor} You can activate this by typing sysout followed by CTRL+SP...

Pointer to 2D arrays in C

I know there is several questions about that which gives good (and working) solutions, but none IMHO which says clearly what is the best way to achieve this. So, suppose we have some 2D array : int tab1[100][280]; We want to make a pointer that po...

How do I get the current location of an iframe?

I have built a basic data entry application allowing users to browse external content in iframe and enter data quickly from the same page. One of the data variables is the URL. Ideally I would like to be able to load the iframes current url into a te...

Submit form with Enter key without submit button?

Possible Duplicate: HTML: Submitting a form by pressing enter without a submit button How can I submit a form with just the Enter key on a text input field, without having to add a submit button? I remember this worked in the past, but I ...

How to convert file to base64 in JavaScript?

UPD TypeScript version is also available in answers Now I'm getting File object by this line: file = document.querySelector('#files > input[type="file"]').files[0] I need to send this file via json in base 64. What should I do to conver...

How can I use grep to find a word inside a folder?

In Windows, I would have done a search for finding a word inside a folder. Similarly, I want to know if a specific word occurs inside a directory containing many sub-directories and files. My searches for grep syntax shows I must specify the filename...

Do I need a content-type header for HTTP GET requests?

As far as I understood there are two places where to set the content type: The client sets a content type for the body he is sending to the server (e.g. for post) The server sets a content type for the response. Does this mean I don't have to or ...

No module named setuptools

I want to install setup file of twilio. When I install it through given command it is given me an error: No module named setuptools. Could you please let me know what should I do? I am using python 2.7 Microsoft Windows [Version 6.1.7601] C...

Passing an array by reference in C?

How can I pass an array of structs by reference in C? As an example: struct Coordinate { int X; int Y; }; SomeMethod(Coordinate *Coordinates[]){ //Do Something with the array } int main(){ Coordinate Coordinates[10]; SomeMethod(&...

Why does Math.Round(2.5) return 2 instead of 3?

In C#, the result of Math.Round(2.5) is 2. It is supposed to be 3, isn't it? Why is it 2 instead in C#?...

Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.

I have used xuggle library in my project to trans code the video from mp4 to flv. I have used slf4j libraries also to support logging end. import com.xuggle.mediatool.IMediaReader; import com.xuggle.mediatool.IMediaViewer; import com.xuggle.mediatoo...

Change NULL values in Datetime format to empty string

I have a table which contains 'NULL' values which are of type 'Datetime'. Now i have to convert those into empty string but when when i use convert function ISNULL( [Accrued Out of Default] ,'' ) here accrued into default is of datetime type, what...

MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]

I'm new in nodeJS, started learning by following a trailer on youtube, everything goes well until I added the connect function if mongodb, mongo.connect("mongodb://localhost:27017/mydb") when I run my code on cmd (node start-app), get the followin...

@RequestParam in Spring MVC handling optional parameters

Is it possible for a Spring controller to handle both kind of requests? 1) http://localhost:8080/submit/id/ID123432?logout=true 2) http://localhost:8080/submit/id/ID123432?name=sam&password=543432 If I define a single controller of the kind: ...

Strict Standards: Only variables should be assigned by reference PHP 5.4

I upgraded my PHP version to 5.4 (XAMPP 1.7.3 to 1.8.0). Now I see Strict Standards error, for myDBconnection: Strict Standards: Only variables should be assigned by reference in C:\xampp\htdocs\alous\include\dbconn.php on line 4 dbconn.php: <?p...

Spark RDD to DataFrame python

I am trying to convert the Spark RDD to a DataFrame. I have seen the documentation and example where the scheme is passed to sqlContext.CreateDataFrame(rdd,schema) function. But I have 38 columns or fields and this will increase further. If I manu...

'module' object is not callable - calling method in another file

I have a fair background in java, trying to learn python. I'm running into a problem understanding how to access methods from other classes when they're in different files. I keep getting module object is not callable. I made a simple function to ...

Which JRE am I using?

There are two varieties of JRE available. Java VM: IBM vs. Sun. Is there a way to know which JRE I am using through JavaScript or some Java issued command....

Create an empty object in JavaScript with {} or new Object()?

There are two different ways to create an empty object in JavaScript: var objectA = {} var objectB = new Object() Is there any difference in how the script engine handles them? Is there any reason to use one over the other? Similarly it is also p...

Does Java have a complete enum for HTTP response codes?

I'm wondering if there is an enum type in some standard Java class library that defines symbolic constants for all of the valid HTTP response codes. It should support conversion to/from the corresponding integer values. I'm debugging some Java code ...

Change background of LinearLayout in Android

I am working on an Android application. I want to change the background of a LinearLayout element. What attribute can I set in order to change its background?...

What are the best PHP input sanitizing functions?

I am trying to come up with a function that I can pass all my strings through to sanitize. So that the string that comes out of it will be safe for database insertion. But there are so many filtering functions out there I am not sure which ones I sho...

Grouping functions (tapply, by, aggregate) and the *apply family

Whenever I want to do something "map"py in R, I usually try to use a function in the apply family. However, I've never quite understood the differences between them -- how {sapply, lapply, etc.} apply the function to the input/grouped input, what t...

VirtualBox: mount.vboxsf: mounting failed with the error: No such device

I'm using VirtualBox with OS X as host and CentOS on the guest VM. In OS X I created folder myfolder, added it as shared folder to the VM, turned on the VM, in CentOS created folder /home/user/myfolder and typing: sudo mount -t vboxsf myfolder /hom...

Difference between OpenJDK and Adoptium/AdoptOpenJDK

Due to recent Oracle Java SE Support Roadmap policy update (end of $free release updates from Oracle after March 2019 in particular), I've been searching for alternatives to Oracle Java. I've found that OpenJDK is an open-source alternative. And I've...

Pass a JavaScript function as parameter

How do I pass a function as a parameter without the function executing in the "parent" function or using eval()? (Since I've read that it's insecure.) I have this: addContact(entityId, refreshContactList()); It works, but the problem is that refr...

Finding the length of an integer in C

I would like to know how I can find the length of an integer in C. For instance: 1 => 1 25 => 2 12512 => 5 0 => 1 and so on. How can I do this in C?...

How to convert an ASCII character into an int in C

How can I convert an ASCII character into an int in C?...

Boolean.parseBoolean("1") = false...?

sorry to be a pain... I have: HashMap<String, String> o o.get('uses_votes'); // "1" Yet... Boolean.parseBoolean(o.get('uses_votes')); // "false" I'm guessing that ....parseBoolean doesn't accept the standard 0 = false 1 = true? Am I doin...

Java SecurityException: signer information does not match

I recompiled my classes as usual, and suddenly got the following error message. Why? How can I fix it? java.lang.SecurityException: class "Chinese_English_Dictionary"'s signer information does not match signer information of other classes in the sam...

download file using an ajax request

I want to send an "ajax download request" when I click on a button, so I tried in this way: javascript: var xhr = new XMLHttpRequest(); xhr.open("GET", "download.php"); xhr.send(); download.php: <? header("Cache-Control: public"); header("Co...

How to check whether a string contains a substring in Ruby

I have a string variable with content: varMessage = "hi/thsid/sdfhsjdf/dfjsd/sdjfsdn\n" "/my/name/is/balaji.so\n" "call::myFunction(int const&)\n" "void::secondFunction(char const&)\n" ...

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

Permutation of array

For example I have this array: int a[] = new int[]{3,4,6,2,1}; I need list of all permutations such that if one is like this, {3,2,1,4,6}, others must not be the same. I know that if the length of the array is n then there are n! possible combina...

CSS Box Shadow - Top and Bottom Only

I cannot find any examples of how to do this, but how can I add a box shadow only to the top and bottom of an element?...

Message 'src refspec master does not match any' when pushing commits in Git

I clone my repository with: git clone ssh://xxxxx/xx.git But after I change some files and add and commit them, I want to push them to the server: git add xxx.php git commit -m "TEST" git push origin master But the error I get back is: error:...

EPPlus - Read Excel Table

Using EPPlus, I want to read an excel table, then store all the contents from each column into its corresponding List. I want it to recognize the table's heading and categorize the contents based on that. For example, if my excel table is as below: ...

Horizontal ListView in Android?

Is it possible to make the ListView horizontally? I have done this using a gallery view, but the selected item comes to the center of the screen automatically. I don't want the selected item at the same spot I clicked. How can I rectify this problem?...

'profile name is not valid' error when executing the sp_send_dbmail command

I have a windows account with users group and trying to exec sp_send_dbmail but getting an error: profile name is not valid. However, when I logged in as administrator and execute the sp_send_dbmail, it managed to send the email so obviously the pr...

How to change the default collation of a table?

create table check2(f1 varchar(20),f2 varchar(20)); creates a table with the default collation latin1_general_ci; alter table check2 collate latin1_general_cs; show full columns from check2; shows the individual collation of the columns as 'lati...

A JNI error has occurred, please check your installation and try again in Eclipse x86 Windows 8.1

public class LoginCumReg implements ActionListener,KeyListener { private JFrame form; private JTextField txtunm; private JTextField txtnm; private JTextField txteml; private JButton cmdcreate; priva...

Parsing JSON array into java.util.List with Gson

I have a JsonObject named "mapping" with the following content: { "client": "127.0.0.1", "servers": [ "8.8.8.8", "8.8.4.4", "156.154.70.1", "156.154.71.1" ] } I know I can get the array "servers" with: ...

How to set-up a favicon?

I am trying to do a very simple preliminary exercise to setting up a website which is creating a favicon. This is the code I am using: <!DOCTYPE html > <html lang="en-US"> <head profile="http://www.w3.org/2005/10/profile"> <li...

What's the fastest way to do a bulk insert into Postgres?

I need to programmatically insert 10's of millions of records into a postgres database. Presently I am executing 1000's of insert statements in a single "query". Is there a better way to do this, some bulk insert statement I dont know about?...

Find and copy files

Why does the following does not copy the files to the destination folder? # find /home/shantanu/processed/ -name '*2011*.xml' -exec cp /home/shantanu/tosend {} \; cp: omitting directory `/home/shantanu/tosend' cp: omitting directory `/home/shantanu...

What is the difference between compare() and compareTo()?

What is the difference between Java's compare() and compareTo() methods? Do those methods give same answer?...

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:\Program Files\Automated QA\TestExecute 8\Bin\Tes...

What is the T-SQL To grant read and write access to tables in a database in SQL Server?

What is the exact SQL to assign db_datareader and db_datawriter roles to a user in SQL Server? The user name is MYUSER and the database is MYDB....

Box-Shadow on the left side of the element only

I have been having trouble setting a box shadow on the left side of an element only. I tried this: box-shadow: -10px 0px 3px 0px #aaa; However, the box shadow looks more like a grey line and lacks the regular shadow-effect that I am used to when ...

How to check cordova android version of a cordova/phonegap project?

I have received a Security Alert from Google this week that tells me to upgrade my android version of cordova app. The email from google is as below - This is a notification that your --apps ids--, is built on a version of Apache Cordova that contai...

Open new popup window without address bars in firefox & IE

hope someone can help. just cannot get a new window to open in Firefox without address bars. IE works fine with below code window.open('/pageaddress.html', 'winname', directories=0,titlebar=0,toolbar=0,location=0,status=0, menubar=0,s...

Installing Bootstrap 3 on Rails App

I'm trying to install Bootstrap 3.0 on my Rails app. I recently finished Michael Hartl's tutorial and am now trying to build my own system using this new version of Bootstrap, but I have a few questions that I'm not sure about. My system specs: OS...

How to get the current URL within a Django template?

I was wondering how to get the current URL within a template. Say my current URL is: .../user/profile/ How do I return this to the template?...

add an element to int [] array in java

Want to add or append elements to existing array int[] series = {4,2}; now i want to update the series dynamically with new values i send.. like if i send 3 update series as int[] series = {4,2,3}; again if i send 4 update series as int[] seri...

Java 8 Streams: multiple filters vs. complex condition

Sometimes you want to filter a Stream with more than one condition: myList.stream().filter(x -> x.size() > 10).filter(x -> x.isCool()) ... or you could do the same with a complex condition and a single filter: myList.stream().filter(x -&...

Are there any HTTP/HTTPS interception tools like Fiddler for mac OS X?

I would like to know if there are any applications like fiddler but for mac OS X, as I need to debug some requests from web applications in Mac OS X. I used to do it with fiddler on Windows and would love to have this tool available on Mac as well. ...

Compare two Lists for differences

I would like some feedback on how we can best write a generic function that will enable two Lists to be compared. The Lists contain class objects and we would like to iterate through one list, looking for the same item in a second List and report any...

Sum values in a column based on date

I have written this function that will give me a monthly sum for two columns: one has the date of each order, one has the cost of each order. =SUMIF($C$1:$C$1000,">="&DATE(2010,6,1),$D$1:$D$1000)-SUMIF($C$1:$C$1000,">="&DATE(2010,7,1),...

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

gdb: "No symbol table is loaded"

I keep getting this error mesage when trying to add a breakpoint in gdb. I've used these commands to compile: gcc -g main.c utmpib2.c -o main.o and: cc -g main.c utmpib2.c -o main.o and also: g++ -g main.c utmpib2.c -o main.o I also tried "-ggdb"...

Android map v2 zoom to show all the markers

I have 10 markers in the GoogleMap. I want to zoom in as much as possible and keep all markers in view? In the earlier version this can be achieved from zoomToSpan() but in v2 I have no idea how about doing that. Further, I know the radius of the cir...

how can I see what ports mongo is listening on from mongo shell?

If I have a mongo instance running, how can I check what port numbers it is listening on from the shell? I thought that db.serverStatus() would do it but I don't see it. I see this "connections" : { "current" : 3, "available" : 816 Which i...

Check if any type of files exist in a directory using BATCH script

Hello I'm looking to write a batch file to check to see if there are any files of any type inside a given folder. So far I've tried the following if EXIST FOLDERNAME\\*.* ( echo Files Exist ) ELSE ( echo "Empty" ) I can get it to work if I know ...

Set HTTP header for one request

I have one particular request in my app that requires Basic authentication, so I need to set the Authorization header for that request. I read about setting HTTP request headers, but from what I can tell, it will set that header for all requests of t...

Importing PNG files into Numpy?

I have about 200 grayscale PNG images stored within a directory like this. 1.png 2.png 3.png ... ... 200.png I want to import all the PNG images as NumPy arrays. How can I do this?...

Adding a view controller as a subview in another view controller

I have found few posts for this problem but none of them solved my issue. Say like I've.. ViewControllerA ViewControllerB I tried to add ViewControllerB as a subview in ViewControllerA but, it's throwing an error like "fatal error: unexpectedly ...

Replace forward slash "/ " character in JavaScript string?

I have this string: var someString = "23/03/2012"; and want to replace all the "/" with "-". I tried to do this: someString.replace(///g, "-"); But it seems you cant have a forward slash / in there....

grep exclude multiple strings

I am trying to see a log file using tail -f and want to exclude all lines containing the following strings: "Nopaging the limit is"` and `"keyword to remove is" I am able to exclude one string like this: tail -f admin.log|grep -v "Nopaging the l...

Remove all elements contained in another array

I am looking for an efficient way to remove all elements from a javascript array if they are present in another array. // If I have this array: var myArray = ['a', 'b', 'c', 'd', 'e', 'f', 'g']; // and this one: var toRemove = ['b', 'c', 'g']; I ...

Can a table row expand and close?

Is it possible to make a table row expand and collapse? Can anyone refer me to a script or an example? I prefer jQuery if possible. I have a drawing concept I would like to achieve: ...

How to copy directories with spaces in the name

I am trying to use robocopy but am unable to make it work because of spaces in the directory names. I am trying to copy 3 directories: My Documents, My Music and My Pictures to 'C:\test-backup' but want the end result to be 'C:\test-backup\My Documen...

go to character in vim

I'm getting an error message from a python script at position 21490. How can I go to this position in Vim?...

How to get the exact local time of client?

What is the best method to get the clients local time irrespective of the time zone of clients system? I am creating an application and i need to first of all get the exact time and date of the place from where the client is accessing. Even detecting...

How to insert a new line in strings in Android

This may seem like a stupid question, but I've been searching and can't find an answer. I'm creating an android application and within it there is a button that will send some information in an email, and I don't want to have everything all in one p...

Convert an integer to a byte array

I have a function which receives a []byte but I what I have is an int, what is the best way to go about this conversion? err = a.Write([]byte(myInt)) I guess I could go the long way and get it into a string and put that into bytes, but it sounds u...

Getting all types that implement an interface

Using reflection, how can I get all types that implement an interface with C# 3.0/.NET 3.5 with the least code, and minimizing iterations? This is what I want to re-write: foreach (Type t in this.GetType().Assembly.GetTypes()) if (t is IMyInter...

PowerMockito mock single static method and return object

I want to mock a static method m1 from a class which contains 2 static methods, m1 and m2. And I want the method m1 to return an object. I tried the following 1) PowerMockito.mockStatic(Static.class, new Answer<Long>() { @Override...

How to align flexbox columns left and right?

With typical CSS I could float one of two columns left and another right with some gutter space in-between. How would I do that with flexbox? http://jsfiddle.net/1sp9jd32/ _x000D_ _x000D_ #container {_x000D_ width: 500px;_x000D_ border: solid 1...

use of entityManager.createNativeQuery(query,foo.class)

I would like to return a List of Integers from a javax.persistence.EntityManager.createNativeQuery call Why is the following incorrect? entityManager.createNativeQuery("Select P.AppID From P", Integer.class); specifically why do I get "...Unkno...

How to install SimpleJson Package for Python

http://pypi.python.org/pypi/simplejson I am just diving into the Python world and want to make a simple twitter application which requires the installation of simplejson but not sure how I can set it up and get it working.. I am on a Windows System...

How to import .py file from another directory?

I have this structure of files (directory and after arrow files): model -> py_file.py report -> other_py_file.py main __init__.py: import model import report model directory: import py_file report directory: import other_py_file no...

How can I safely create a nested directory?

What is the most elegant way to check if the directory a file is going to be written to exists, and if not, create the directory using Python? Here is what I tried: import os file_path = "/my/directory/filename.txt" directory = os.path.dirname(file...

Count rows with not empty value

In a Google Spreadsheet: How can I count the rows of a given area that have a value? All hints about this I found up to now lead to formulas that do count the rows which have a not empty content (including formula), but a cell with =IF(1=2;"";"") ...

The default XML namespace of the project must be the MSBuild XML namespace

I cloned the ASP.NET Core SignalR Repo locally, and try opening the solution from within the following environment. IDE Microsoft Visual Studio Enterprise 2015 Version 14.0.25431.01 Update 3 Microsoft .NET Framework Version 4.6.01055 DOT NET CLI ...

Navigation drawer: How do I set the selected item at startup?

My code works perfectly: every time an item in Navigation Drawer is clicked the item is selected. Of course I want to start the app with a default fragment (home), but Navigation Drawer doesn't have the item selected. How can I select that item prog...

Write-back vs Write-Through caching?

My understanding is that the main difference between the two methods is that in "write-through" method data is written to the main memory through the cache immediately, while in "write-back" data is written in a "latter time". We still need to wait ...

Compress files while reading data from STDIN

Is it possible to compress (create a compressed archive) data while reading from stdin on Linux?...

Permutations between two lists of unequal length

Iโ€™m having trouble wrapping my head around a algorithm Iโ€™m try to implement. I have two lists and want to take particular combinations from the two lists. Hereโ€™s an example. names = ['a', 'b'] numbers = [1, 2] the output in this case would be:...

Instantiating a generic type

I'm trying to convert an existing class to use generics, and am getting stumped while converting the constructors. The original class was a POJO that contained logic for moving from one room to another in a text-based console game. Literally, it was...

Binding Combobox Using Dictionary as the Datasource

I'm using .NET 2.0 and I'm trying to bind a combobox's Datasource to a sorted dictionary. So the error I'm getting is "DataMember property 'Key' cannot be found on the Datasource". SortedDictionary<string, int> userCache = UserCache.g...

Run PHP Task Asynchronously

I work on a somewhat large web application, and the backend is mostly in PHP. There are several places in the code where I need to complete some task, but I don't want to make the user wait for the result. For example, when creating a new account, I ...

Disable a Button

I want to disable a button (UIButton) on iOS after it is clicked. I am new to developing for iOS but I think the equivalent code on objective - C is this: button.enabled = NO; But I couldn't do that on swift....

Disabled form fields not submitting data

Is there any way (with a attribute flag or something like that) to enable form fields that are disabled to submit data? Or, if that's not possible, is there any way to block fields from editing with css or any other attribute than disabled without h...

How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?

How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code? I tried this, but it doesn't work: <!--[if IE 10]> <html class="no-js ie10" lang="en">...

JavaScript or jQuery browser back button click detector

Could someone please share experience / code how we can detect the browser back button click (for any type of browsers)? We need to cater all browser that doesn't support HTML5...

Create a <ul> and fill it based on a passed array

I've managed to generate a series of list-items based on one specified array within a matrix (i.e. an array within an array). I would like to be able to pass a variable (representing an array) to a function so that it can spit out an unordered list ...

What's wrong with overridable method calls in constructors?

I have a Wicket page class that sets the page title depending on the result of an abstract method. public abstract class BasicPage extends WebPage { public BasicPage() { add(new Label("title", getTitle())); } protected abstract...

How to enable local network users to access my WAMP sites?

First of all, I read at least 20 articles about this topic, and not one of them can match up the scenario and I screwed up the process numerous times. So I turn help by offering my specific scenario if any help will be appreciated. Laptops or other ...

how to change class name of an element by jquery

<div class="bestAnswerControl"> <div id="ct100_contentplaceholder_lvanswer_control_divbestanswer" class="IsBestAnswer"></div> </div> I want to add: .bestanswer { // some attribute } I want to replace c...

โ€˜ld: warning: directory not found for optionโ€™

When I'm building my Xcode 4 apps I'm getting this warning: ld: warning: directory not found for option '-L/Users/frenck/Downloads/apz/../../../Downloads/Google Analytics SDK/Library' ld: warning: directory not found for option '-L/Users/frenck/Dow...

import httplib ImportError: No module named httplib

I got this error when run test.py C:\Python32>python.exe test.py Traceback (most recent call last): File "test.py", line 5, in <module> import httplib ImportError: No module named httplib How to correct it? Code block for test.py: ...

How to execute a Windows command on a remote PC?

Is it possible to execute a Windows shell command on a remote PC when I know its login name and password? Is it possible to do it using client PC's Windows shell?...

how to configure apache server to talk to HTTPS backend server?

I configured apache server as a reverse proxy and it works fine if I point a backend server as HTTP. That is: I configured virtual host 443 like: ProxyPass /primary/store http://localhost:9763/store/ ProxyPassReverse /primary/store http://localhost...

How do I finish the merge after resolving my merge conflicts?

I've read the Basic Branching and Merging section of the Git Community Book. So I follow it and create one branch: experimental. Then I: switch to experimental branch (git checkout experimental) make a bunch of changes commit it (git commit -a) s...

Is there are way to make a child DIV's width wider than the parent DIV using CSS?

Is there a way to have a child DIV within a parent container DIV that is wider than it's parent. The child DIV needs to be the same width of the browser viewport. See example below: The child DIV must stay as a child of the parent div. I know I ca...

Clearfix with twitter bootstrap

I have an issue with twitter bootstrap that looks a little bit strange to me. I have a sidebar with fixed with at the left side and a main area. <div> <div id="sidebar"> <ul> <li>A</li> <li>A<...

How to programmatically get iOS status bar height

I know that currently the status bar (with the time, battery, and network connection) at the top of the iPhone/iPad is 20 pixels for non-retina screens and 40 pixels for retina screens, but to future proof my app I would like to be able to determine ...

What is cardinality in Databases?

I have been searching all over the internet but I couldn't seem to find an answer that I can understand. So kindly, if somebody could explain to me with the help of examples what is cardinality in databases? Thank you....

There has been an error processing your request, Error log record number

I installed Magento, logged in admin panel. But if I press on any link to open let say CMS pages or users configuration, I get error like this: There has been an error processing your request Exception printing is disabled by default for se...

Search and replace a particular string in a file using Perl

Possible Duplicate: How to replace a string in an existing file in Perl? I need to create a subroutine that does a search and replace in file. Here's the contents of myfiletemplate.txt: CATEGORY1=youknow_<PREF> CATEGORY2=your...

Set up a scheduled job?

I've been working on a web app using Django, and I'm curious if there is a way to schedule a job to run periodically. Basically I just want to run through the database and make some calculations/updates on an automatic, regular basis, but I can't s...

How to create a custom navigation drawer in android

Hi I'm trying to create a navigation drawer similar to gmail app navigation drawer. I follow the developer site but it only specify about basic implementation. But I need to customize the navigation according to my specifications. I need to add a...

NPM stuck giving the same error EISDIR: Illegal operation on a directory, read at error (native)

I am stuck with this error no matter what directory I am in, and what I type after "npm" in cmd.exe. Here is the npm-debug.log: 0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe', 1 verbose cli 'C:\\Program ...

How to load CSS Asynchronously

I'm trying to eliminate 2 CSS files that are render blocking on my site - they appear on Google Page Speed Insights. I have followed different methods, none of which were a success. But, recently, I found a post about Thinking Async and when I applie...

Choosing the best concurrency list in Java

My thread pool has a fixed number of threads. These threads need to write and read from a shared list frequently. So, which data structure (it better be a List, must be monitor-free) in java.util.concurrent package is best in this case?...

error: command 'gcc' failed with exit status 1 on CentOS

I'm trying to install lxml package on CentOS using sudo pip install lxml and its throwing this error right at the end: error: error: command 'gcc' failed with exit status 1 --------------------------------------- Command /usr/bin/python -c "impor...

Get operating system info

I recently started wondering about sites like http://thismachine.info/ that get the user's operating system info. I have not been able to find out how to do that with PHP, and wanted to try to figure it out. I noticed that they list the user-agent, ...

Change bullets color of an HTML list without using span

I was wondering if there is a way to change the color on the bullets in a list. I have a list like this: <ul> <li>House</li> <li>Car</li> <li>Garden</li> </ul> It is not possible for me to...

How to use the TextWatcher class in Android?

Can anyone tell me how to mask the substring in EditText or how to change EditText substring input to password type or replace by another character like this 123xxxxxxxxx3455 String contents = et1.getText().toString(); et1.setText(contents.replace...

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 can VBA connect to MySQL database in Excel?

Dim oConn As ADODB.Connection Private Sub ConnectDB() Set oConn = New ADODB.Connection Dim str As String str = "DRIVER={MySQL ODBC 5.2.2 Driver};" & _ "SERVER=sql100.xtreemhost.com;" & _ ...

jQuery serialize does not register checkboxes

I'm using jQuery.serialize to retrieve all data fields in a form. My problem is that it does not retriev checkboxes that is not checked. It includes this: <input type="checkbox" id="event_allDay" name="event_allDay" class="checkbox" checked="ch...

Do I need to explicitly call the base virtual destructor?

When overriding a class in C++ (with a virtual destructor) I am implementing the destructor again as virtual on the inheriting class, but do I need to call the base destructor? If so I imagine it's something like this... MyChildClass::~MyChildClass...

Mapping two integers to one, in a unique and deterministic way

Imagine two positive integers A and B. I want to combine these two into a single integer C. There can be no other integers D and E which combine to C. So combining them with the addition operator doesn't work. Eg 30 + 10 = 40 = 40 + 0 = 39 + 1 Neit...

SQL Error: ORA-00936: missing expression

Qns: Item Description and the treatment date of all treatments for any patients named Jessie Stange (ie GivenName is Jessie & FamilyName is Stange) What I wrote: SELECT DISTINCT Description, Date as treatmentDate WHERE doothey.Patient P, dooth...

How can I check if PostgreSQL is installed or not via Linux script?

I want to check in a script if PostgreSQL is installed or not on Linux and print the result. Any suggestions on how to do the check? ...

Handling ExecuteScalar() when no results are returned

I am using the following SQL query and the ExecuteScalar() method to fetch data from an Oracle database: sql = "select username from usermst where userid=2" string getusername = command.ExecuteScalar(); It is showing me this error message: Sys...

How to insert a string which contains an "&"

How can I write an insert statement which includes the & character? For example, if I wanted to insert "J&J Construction" into a column in the database. I'm not sure if it makes a difference, but I'm using Oracle 9i....

Measuring elapsed time with the Time module

With the Time module in python is it possible to measure elapsed time? If so, how do I do that? I need to do this so that if the cursor has been in a widget for a certain duration an event happens. ...

Replace specific characters within strings

I would like to remove specific characters from strings within a vector, similar to the Find and Replace feature in Excel. Here are the data I start with: group <- data.frame(c("12357e", "12575e", "197e18", "e18947") I start with just the fir...

How to check if a file exists from a url

I need to check if a particular file exists on a remote server. Using is_file() and file_exists() doesn't work. Any ideas how to do this quickly and easily?...

How to check if a date is greater than another in Java?

I am working on a Java application which generates a report for a duration entered by a user in the command line. The user needs to enter the dates in the following format: dd-MM-yyyy > java report startDate endDate Example: java report 01-01-2...

How to calculate the difference between two dates using PHP?

I have two dates of the form: Start Date: 2007-03-24 End Date: 2009-06-26 Now I need to find the difference between these two in the following form: 2 years, 3 months and 2 days How can I do this in PHP?...

Open existing file, append a single line

I want to open a text file, append a single line to it, then close it....

Alter user defined type in SQL Server

I created few user defined types in my database as below CREATE TYPE [dbo].[StringID] FROM [nvarchar](20) NOT NULL and assigned them to various tables. The tables in my database are in various schemas (not only dbo) But I realized I need bigger fiel...

PHP Curl And Cookies

I have some problem with PHP Curl and cookies authentication. I have a file Connector.php which authenticates users on another server and returns the cookie of the current user. The Problem is that I want to authenticate thousands of users with cur...

hasOwnProperty in JavaScript

Consider: function Shape() { this.name = "Generic"; this.draw = function() { return "Drawing " + this.name + " Shape"; }; } function welcomeMessage() { var shape1 = new Shape(); //alert(shape...

Correct use of transactions in SQL Server

I have 2 commands and need both of them executed correctly or none of them executed. So I think I need a transaction, but I don't know how to use it correctly. What's the problem with the following script? BEGIN TRANSACTION [Tran1] INSERT INTO [Te...

Change color of PNG image via CSS?

Given a transparent PNG displaying a simple shape in white, is it possible to somehow change the color of this through CSS? Some kind of overlay or what not?...

Save string to the NSUserDefaults?

How to save a string into the NSUserDefaults?...

Transport endpoint is not connected

FUSE is constantly(every 2 - 3 days) giving me this Transport endpoint is not connected error on my mount point and the only thing that seems to fix it is rebooting. I currently have my mount points setup like this, I'm not sure what other details ...


mysql query order by multiple items

is is possible to order by multiple rows? I want my users to be sorted by last_activity, but at the same time, i want the users with pictures to appear before the ones without Something like this: SELECT some_cols FROM `prefix_users` WHERE (some ...

Cannot install packages using node package manager in Ubuntu

NodeJS interpreter name(node) on Ubuntu has been renamed to nodejs because of a name conflict with another package. Here's what the readme. Debian says: The upstream name for the Node.js interpreter command is "node". In Debian the interprete...

How do I check if I'm running on Windows in Python?

I found the platform module but it says it returns 'Windows' and it's returning 'Microsoft' on my machine. I notice in another thread here on stackoverflow it returns 'Vista' sometimes. So, the question is, how do implemement? if isWindows(): ......

How to reload a page using Angularjs?

I have a link. When user will click in this link, then the page will be reloaded. I did it by the following way...... Html <div data-ng-hide="backHide" class="offset6 pull-right"> <a href="" data-ng-click="backLinkClick()"><<...

When to use Spring Security`s antMatcher()?

When do we use antMatcher() vs antMatchers()? For example: http .antMatcher("/high_level_url_A/**") .authorizeRequests() .antMatchers("/high_level_url_A/sub_level_1").hasRole('USER') .antMatchers("/high_level_url_A/sub_level_2").h...

How to find the sum of an array of numbers

Given an array [1, 2, 3, 4], how can I find the sum of its elements? (In this case, the sum would be 10.) I thought $.each might be useful, but I'm not sure how to implement it....

What is the purpose of Android's <merge> tag in XML layouts?

I've read Romain Guy's post on the <merge /> tag, but I still don't understand how it's useful. Is it a sort-of replacement of the <Frame /> tag, or is it used like so: <merge xmlns:android="...."> <LinearLayout ...> . ...

HTML-encoding lost when attribute read from input field

Iโ€™m using JavaScript to pull a value out from a hidden field and display it in a textbox. The value in the hidden field is encoded. For example, <input id='hiddenId' type='hidden' value='chalk &amp; cheese' /> gets pulled into <in...

Reverse Singly Linked List Java

Can someone tell me why my code dosent work? I want to reverse a single linked list in java: This is the method (that doesnt work correctly) public void reverseList(){ Node before = null; Node tmp = head; Node next = tmp.next; while(...

presentViewController and displaying navigation bar

I have a view controller hierarchy and the top-most controller is displayed as a modal and would like to know how to display the navigation bar when using 'UIViewController:presentViewController:viewControllerToPresent:animated:completion' The do...

Modify the legend of pandas bar plot

I am always bothered when I make a bar plot with pandas and I want to change the names of the labels in the legend. Consider for instance the output of this code: import pandas as pd from matplotlib.pyplot import * df = pd.DataFrame({'A':26, 'B':20...

What is the difference between "long", "long long", "long int", and "long long int" in C++?

I am transitioning from Java to C++ and have some questions about the long data type. In Java, to hold an integer greater than 232, you would simply write long x;. However, in C++, it seems that long is both a data type and a modifier. There seems ...

Getting cursor position in Python

Is it possible to get the overall cursor position in Windows using the standard Python libraries?...

How to add minutes to current time in swift

I am new to Swift and am trying a scheduler. I have the start time selected and I need to add 5 minutes (or multiples of it) to the start time and display it in an UILabel? @IBAction func timePickerClicked(sender: UIDatePicker) { var dateFormatte...

Return True, False and None in Python

I have function a call function b (returns True or False to a), afterwards function a can return the result to be printed. class C: ... def a(self, data): p = self.head return self.b( p,data) def b(self, p, data): ...

How do I view an older version of an SVN file?

I have an SVN file which is now missing some logic and so I need to go back about 40 revisions to the time when it had the logic I need. Other than trying to view a diff of the file in the command line (very hard to read), is there any way I could ge...

What is the best workaround for the WCF client `using` block issue?

I like instantiating my WCF service clients within a using block as it's pretty much the standard way to use resources that implement IDisposable: using (var client = new SomeWCFServiceClient()) { //Do something with the client } But, as noted...

How to assign string to bytes array

I want to assign string to bytes array: var arr [20]byte str := "abc" for k, v := range []byte(str) { arr[k] = byte(v) } Have another method?...

vue.js 2 how to watch store values from vuex

I am using vuex and vuejs 2 together. I am new to vuex, I want to watch a store variable change. I want to add the watch function in my vue component This is what I have so far: import Vue from 'vue'; import { MY_STATE, } from './../../mutation...

How to call multiple functions with @click in vue?

Question: How to call multiple functions in a single @click? (aka v-on:click)? I tried Split functions with a semicolon: <div @click="fn1('foo');fn2('bar')"> </div>; Use several @click: <div @click="fn1('foo')" @click="fn2('bar')"...

Filter by Dates in SQL

I have a column in my table for dates (DateTime) and I am trying to create a WHERE clause that says, WHERE dates BETWEEN 12-11-2012 and 12-13-2012 A sample value of dates column = 2012-05-24 00:38:40.260 I want to say WHERE dates BETWEEN MM-DD-YYYY...

What are C++ functors and their uses?

I keep hearing a lot about functors in C++. Can someone give me an overview as to what they are and in what cases they would be useful?...

JsonParseException: Unrecognized token 'http': was expecting ('true', 'false' or 'null')

We have the following string which is a valid JSON written to a file on HDFS. { "id":"tag:search.twitter.com,2005:564407444843950080", "objectType":"activity", "actor":{ "objectType":"person", "id":"id:twitter.com:2302910022", ...

Android WebView not loading an HTTPS URL

public void onCreate(Bundle savedInstance) { super.onCreate(savedInstance); setContentView(R.layout.show_voucher); webView=(WebView)findViewById(R.id.webview); webView.getSettings().setJavaScriptEnabled(true); webView.getSe...

How to enable zoom controls and pinch zoom in a WebView?

The default Browser app for Android shows zoom controls when you're scrolling and also allows for pinch zooming. How can I enable this feature for my own Webview? I've tried: webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(tru...

Dynamically create an array of strings with malloc

I am trying to create an array of strings in C using malloc. The number of strings that the array will hold can change at run time, but the length of the strings will always be consistent. I've attempted this (see below), but am having trouble, any ...

How to dynamically add and remove form fields in Angular 2

I'm trying to add input fields dynamically while the user clicks the add button and for each form field there must be a remove button, when the user clicks that the form fields must be removed, I need to achieve this using Angular 2, as I'm new to An...

Microsoft Azure: How to create sub directory in a blob container

How to create a sub directory in a blob container for example, in my blob container http://veda.blob.core.windows.net/document/ If I store some files it will be http://veda.blob.core.windows.net/document/1.txt http://veda.blob.core.windows.net/docum...

Query to select data between two dates with the format m/d/yyyy

I am facing problem when i'm trying to select records from a table between two dates. m using the following query select * from xxx where dates between '10/10/2012' and '10/12/2012' this query works for me but when the dates are in format like 1/...

Scrolling to an Anchor using Transition/CSS3

I have a series of links which are using an anchor mechanism: <div class="header"> <p class="menu"><a href="#S1">Section1</a></p> <p class="menu"><a href="#S2">Section2</a></p> ... &l...

Version vs build in Xcode

I have an app that I developed with Xcode 3 and recently started editing with Xcode 4. In the target summary I have the iOS application target form with fields: identifier, version, build, devices, and deployment target. The version field is blank an...

Is there anything like .NET's NotImplementedException in Java?

Is there anything like .NET's NotImplementedException in Java?...

How to set the width of a RaisedButton in Flutter?

I have seen that I can't set the width of a RaisedButton in Flutter. If I have well understood, I should put the RaisedButton into a SizedBox. I will then be able to set the width or height of the box. Is it correct? Is there another way to do it? T...

Selecting between two dates within a DateTime field - SQL Server

How to select records between a date to another date given a DateTime field in a table....

Setting action for back button in navigation controller

I'm trying to overwrite the default action of the back button in a navigation controller. I've provided a target an action on the custom button. The odd thing is when assigning it though the backbutton attribute it doesn't pay attention to them and ...

Why am I getting "undefined reference to sqrt" error even though I include math.h header?

I'm very new to C and I have this code: #include <stdio.h> #include <math.h> int main(void) { double x = 0.5; double result = sqrt(x); printf("The square root of %lf is %lf\n", x, result); return 0; } But when I compile this w...

python exception message capturing

import ftplib import urllib2 import os import logging logger = logging.getLogger('ftpuploader') hdlr = logging.FileHandler('ftplog.log') formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) logger.addHan...

Why can I not push_back a unique_ptr into a vector?

What is wrong with this program? #include <memory> #include <vector> int main() { std::vector<std::unique_ptr<int>> vec; int x(1); std::unique_ptr<int> ptr2x(&x); vec.push_back(ptr2x); //This tiny ...

How to update-alternatives to Python 3 without breaking apt?

The other day I decided that I wanted the command python to default to firing up python3 instead of python2. So I did this: $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2 $ sudo update-alternatives --install /usr/...

Extreme wait-time when taking a SQL Server database offline

I'm trying to perform some offline maintenance (dev database restore from live backup) on my dev database, but the 'Take Offline' command via SQL Server Management Studio is performing extremely slowly - on the order of 30 minutes plus now. I am just...

How to convert number to words in java

We currently have a crude mechanism to convert numbers to words (e.g. using a few static arrays) and based on the size of the number translating that into an english text. But we are running into issues for numbers which are huge. 10183 = Ten thousa...

How to use an output parameter in Java?

Could someone please give me some sample code that uses an output parameter in function? I've tried to Google it but just found it just in functions. I'd like to use this output value in another function. The code I am developing intended to be run ...

Laravel Eloquent update just if changes have been made

Is there any way to update a record in Laravel using eloquent models just if a change has been made to that record? I don't want any user requesting the database for no good reason over and over, just hitting the button to save changes. I have a java...

Python list sort in descending order

How can I sort this list in descending order? timestamps = [ "2010-04-20 10:07:30", "2010-04-20 10:07:38", "2010-04-20 10:07:52", "2010-04-20 10:08:22", "2010-04-20 10:08:22", ...

Global Git ignore

I want to set up Git to globally ignore certain files. I have added a .gitignore file to my home directory (/Users/me/) and I have added the following line to it: *.tmproj But it is not ignoring this type of files, any idea what I am doing wrong?...

"Active Directory Users and Computers" MMC snap-in for Windows 7?

Is there an equivalent tool available for use in Windows 7? I just need to browse the membership of some small Active Directory groups that are deep within a huge hierarchy, so I can eventually write code to work with those groups. The Windows Serv...

C# Syntax - Example of a Lambda Expression - ForEach() over Generic List

First, I know there are methods off of the generic List<> class already in the framework do iterate over the List<>. But as an example, what is the correct syntax to write a ForEach method to iterate over each object of a List<>, a...

Create a sample login page using servlet and JSP?

I developed a sample login page for validating username and password. If the user gives correct credentials the page will navigate to some other page, else return a message from the servlet to the same login page. I have enclosed the sample code here...

Python - Create list with numbers between 2 values?

How would I create a list with values between two values I put in? For example, the following list is generated for values from 11 to 16: list = [11, 12, 13, 14, 15, 16] ...

What is the best Java email address validation method?

What are the good email address validation libraries for Java? Are there any alternatives to commons validator?...

Navigation Controller Push View Controller

Question How to navigate from one view controller to another simply using a button's touch up inside event? More Info What I tried in a sample project, in steps, was: Create the sample single view application. Add a new file -> Objective-C Class...

When to use setAttribute vs .attribute= in JavaScript?

Has a best-practice around using setAttribute instead of the dot (.) attribute notation been developed? E.g.: myObj.setAttribute("className", "nameOfClass"); myObj.setAttribute("id", "someID"); or myObj.className = "nameOfClass"; myObj.id = "som...

asterisk : Unable to connect to remote asterisk (does /var/run/asterisk.ctl exist?)

I am learning asterisk. After I installed asterisk, I tried to connect with it using asterisk -rvvvvc. But it gave me the following error message: Unable to connect to remote asterisk (does /var/run/asterisk.ctl exist?) How can I solve thi...

Getting new Twitter API consumer and secret keys

I am working on a Twitter project where I want to use OAuth but I don't know where to get the consumer and secret keys. How can I get these?...

Python: read all text file lines in loop

I want to read huge text file line by line (and stop if a line with "str" found). How to check, if file-end is reached? fn = 't.log' f = open(fn, 'r') while not _is_eof(f): ## how to check that end is reached? s = f.readline() print s if...

Can you use CSS to mirror/flip text?

Is it possible to use CSS/CSS3 to mirror text? Specifically, I have this scissors char โ€œ✂โ€ (&#9986;) that I'd like to display pointing left and not right....

How to get the current taxonomy term ID (not the slug) in WordPress?

I've created a taxonomy.php page in my WordPress theme folder. I would like to get the current term id for a function. How can I get this? get_query_var('taxonomy') only returns the term slug, I want the ID...

How do I make the first letter of a string uppercase in JavaScript?

How do I make the first letter of a string uppercase, but not change the case of any of the other letters? For example: "this is a test" -> "This is a test" "the Eiffel Tower" -> "The Eiffel Tower" "/index.html" -> "/index.html" ...

How do you implement a Stack and a Queue in JavaScript?

What is the best way to implement a Stack and a Queue in JavaScript? I'm looking to do the shunting-yard algorithm and I'm going to need these data-structures....

JPA Hibernate Persistence exception [PersistenceUnit: default] Unable to build Hibernate SessionFactory

I've been trying to sort out a connection to my DB with JPA Hibernate and mysql, but for some reason, no matter what i try, when launching the tomcat server i get the same exception: org.springframework.beans.factory.BeanCreationException: Error cr...

Creating a timer in python

import time def timer(): now = time.localtime(time.time()) return now[5] run = raw_input("Start? > ") while run == "start": minutes = 0 current_sec = timer() #print current_sec if current_sec == 59: mins = minutes + 1 ...

Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved

I have install maven in my machine. I have properly set the class-path and maven home folder. Every time I execute mvn clean install, it gives me exception. I have also tried to delete the .m2 folder but the same result. mvn -version output Apache...

Can you "compile" PHP code and upload a binary-ish file, which will just be run by the byte code interpreter?

I know that PHP is compiled to byte code before it is run on the server, and then that byte code can be cached so that the whole script doesn't have to be re-interpreted with every web access. But can you "compile" PHP code and upload a binary-ish f...

Copy file from source directory to binary directory using CMake

I'm trying to create a simple project on CLion. It uses CMake (I'm new here) to generate Makefiles to build project (or some sort of it) All I need to is transfer some non-project file (some sort of resource file) to binary directory each time when ...

Timer Interval 1000 != 1 second?

I have a label which should show the seconds of my timer (or in other word I have a variable to which is added 1 every interval of the timer). The interval of my timer is set to 1000, so the label should update itself every second (and should also sh...

How to split data into training/testing sets using sample function

I've just started using R and I'm not sure how to incorporate my dataset with the following sample code: sample(x, size, replace = FALSE, prob = NULL) I have a dataset that I need to put into a training (75%) and testing (25%) set. I'm not sure w...

Get User's Current Location / Coordinates

How can I store the user's current location and also show the location on a map? I am able to show pre-defined coordinates on a map, I just don't know how to receive information from the device. Also I know I have to add some items into a Plist. Ho...

How to create a multiline UITextfield?

I am developing an application where user has to write some information. For this purpose I need a UITextField which is multi-line (in general UITextField is a single line). As I'm Googling I find a answer of using UITextView instead of UITextfield ...

Can I set the cookies to be used by a WKWebView?

I'm trying to switch an existing app from UIWebView to WKWebView. The current app manages the users login / session outside of the webview and sets the cookies required for authentication into the the NSHTTPCookieStore. Unfortunately new WKWebView do...

Convert factor to integer

I am manipulating a data frame using the reshape package. When using the melt function, it factorizes my value column, which is a problem because a subset of those values are integers that I want to be able to perform operations on. Does anyone know...

asp.net: Invalid postback or callback argument

I am getting this error: Server Error in '/' Application. Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a ...

How to build splash screen in windows forms application?

I need to show splash screen on my application start for few seconds. Does anybody know how to implement this? Will be much appreciate for the help....

How to play a notification sound on websites?

When a certain event occurs, I want my website to play a short notification sound to the user. The sound should not auto-start (instantly) when the website is opened. Instead, it should be played on demand via JavaScript (when that certain event occ...

Get timezone from DateTime

Does the .Net DateTime contain information about time zone where it was created? I have a library parsing DateTime from a format that has "+zz" at the end, and while it parses correctly and adjusts a local time, I need to get what the specific time...

How to run a program in Atom Editor?

I found Atom editor as good free alternative to Sublime text editor. Not able to find a straightforward way to run a program in Atom editor. In my case, I am trying to run a java program. Please let me know if it's possible? If yes, please describe t...

Sending data from HTML form to a Python script in Flask

I have the code below in my Python script: def cmd_wui(argv, path_to_tx): """Run a web UI.""" from flask import Flask, flash, jsonify, render_template, request import webbrowser app = Flask(__name__) @app.route('/tx/index/') ...

Javascript Iframe innerHTML

Does anyone know how to get the HTML out of an IFRAME I have tried several different ways: document.getElementById('iframe01').contentDocument.body.innerHTML document.frames['iframe01'].document.body.innerHTML document.getElementById('iframe01').con...

How to include (source) R script in other scripts

I've created a utility R script, util.R, which I want to use from other scripts in my project. What is the proper way to ensure that the function this script defines are available to function in my other scripts? I'm looking for something similar to...

Can a for loop increment/decrement by more than one?

Are there other ways to increment a for loop in Javascript besides i++ and ++i? For example, I want to increment by 3 instead of one. for (var i = 0; i < myVar.length; i+3) { //every three } ...

Using import fs from 'fs'

I want to use import fs from 'fs' in JavaScript. Here is a sample: import fs from 'fs' var output = fs.readFileSync('someData.txt') console.log(output) The error I get when I run my file using node main.js is: (function (exports, require, module, ...

Converting a generic list to a CSV string

I have a list of integer values (List) and would like to generate a string of comma delimited values. That is all items in the list output to a single comma delimted list. My thoughts... 1. pass the list to a method. 2. Use stringbuilder to iterate ...

'adb' is not recognized as an internal or external command, operable program or batch file

I am trying to run google map v2 on emulator, I am following this tutorial. When I was trying to install required apk file on emulator, I am getting below error. I tried to solve this using this tutorial.Followed all steps, added the path to paltfor...

Error:attempt to apply non-function

I'm trying to run the following code in R, but I'm getting an error. I'm not sure what part of the formula is incorrect. Any help would be greatly appreciated. > censusdata_20$AGB93 = WD * exp(-1.239 + 1.980 * log (DIAM93) + 0.207 (log(DIAM93))^...

How to declare an array of objects in C#

I have a very beginning C# question. Suppose I have a class called GameObject, and I want to create an array of GameObject entities. I could think of writing code like: GameObject[] houses = new GameObject[200]; The compiler complains (assuming beca...

Bootstrap Modal before form Submit

I'm new to Modals, I have a Form and when the user clicks submit, It will show a Modal confirming if the user wants to submit, the modal also contains the user input from the form fields. I searched all over the internet but can't find the right one ...

How to use Angular2 templates with *ngFor to create a table out of nested arrays?

Given the following array in component property groups: [ { "name": "pencils", "items": ["red pencil","blue pencil","yellow pencil"] }, { "name": "rubbers", "items": ["big rubber","small rubber"] }, ] How to create ...

Bootstrap 3 only for mobile

I have a site 1600px wide and I want to make that fit nicely on mobile only. How can I do with Bootstrap 3. I tried to use col-sm-*. but also effects on larges screens because existing site is not coded as per Bootstrap grid. Is there any way I can u...

Passing data from controller to view in Laravel

I am new to laravel and I have been trying to store all records of table 'student' to a variable and then pass that variable to a view so that I can display them. I have a controller - ProfileController and inside that a function: public funct...

Can I use git diff on untracked files?

Is it possible to ask git diff to include untracked files in its diff output, or is my best bet to use git add on the newly created files and the existing files I have edited, then use: git diff --cached ?...

Practical uses for AtomicInteger

I sort of understand that AtomicInteger and other Atomic variables allow concurrent accesses. In what cases is this class typically used though?...

CORS header 'Access-Control-Allow-Origin' missing

I'm calling this function from my asp.net form and getting following error on firebug console while calling ajax. Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://anotherdomain/test.json. (Reaso...

Return Result from Select Query in stored procedure to a List

I'm writing a stored procedure that currently contains only a SELECT query. It will be expanded to do a number of other things, which is why it has to be a stored procedure, but for now, it is a simple query. Something like this: SELECT name, occu...

Highcharts - how to have a chart with dynamic height?

I want to have a chart that resizes with the browser window, but the problem is that the height is fixed to 400px. This JSFiddle example has the same problem. How can I do that? I tried using the chart.events.redraw event handler to resize the chart...

Uncaught TypeError: Object #<Object> has no method 'movingBoxes'

Im trying to use the movingBoxes plugin with my asp.net mvc site and it is not working (obviously). I have the movingboxes.js imported in my head tag in the site.master like so <script src="<%: Url.Content("~/Scripts/jquery.movingboxes.js...

What size do you use for varchar(MAX) in your parameter declaration?

I normally set my column size when creating a parameter in ADO.NET But what size do I use if the column is VARCHAR(MAX)? cmd.Parameters.Add("@blah", SqlDbType.VarChar, ?????).Value = blah; ...

How to create a .NET DateTime from ISO 8601 format

I've found how to turn a DateTime into an ISO 8601 format, but nothing on how to do the reverse in C#. I have 2010-08-20T15:00:00Z, and I want to turn it into a DateTime object. I could separate the parts of the string myself, but that seems like a...

Spring Data: "delete by" is supported?

I am using Spring JPA for database access. I am able to find examples such as findByName and countByName, for which I dont have to write any method implementation. I am hoping to find examples for delete a group of records based on some condition. D...

What is the "right" way to iterate through an array in Ruby?

PHP, for all its warts, is pretty good on this count. There's no difference between an array and a hash (maybe I'm naive, but this seems obviously right to me), and to iterate through either you just do foreach (array/hash as $key => $value) In...

Skipping Incompatible Libraries at compile

When I try to compile a copy of my project on my local machine, I get an error stating that it 's skipping over incompatible libraries. This isn't the case when I'm messing around with the live version hosted on the server at work [it makes perfectl...

How can I replace newline or \r\n with <br/>?

I am trying to simply replace some new lines and have tried three different ways, but I don't get any change: $description = preg_replace('/\r?\n|\r/', '<br/>', $description); $description = str_replace(array("\r\n", "\r", &...

How can I have two fixed width columns with one flexible column in the center?

I'm trying to set up a flexbox layout with three columns where the left and right columns have a fixed width, and the center column flexes to fill the available space. Despite setting up dimensions for the columns, they still seem to shrink as the ...

Int to Char in C#

What is the best way to convert an Int value to the corresponding Char in Utf16, given that the Int is in the range of valid values?...

Understanding the order() function

I'm trying to understand how the order() function works. I was under the impression that it returned a permutation of indices, which when sorted, would sort the original vector. For instance, > a <- c(45,50,10,96) > order(a) [1] 3 1 2 4 ...

Laravel Check If Related Model Exists

I have an Eloquent model which has a related model: public function option() { return $this->hasOne('RepairOption', 'repair_item_id'); } public function setOptionArrayAttribute($values) { $this->option->update($values); } When I ...

Output to the same line overwriting previous output?

I am writing an FTP downloader. Part of to the code is something like this: ftp.retrbinary("RETR " + file_name, process) I am calling function process to handle the callback: def process(data): print os.path.getsize(file_name)/1024, 'KB / ', ...

How to generate and manually insert a uniqueidentifier in sql server?

I'm trying to manually create a new user in my table but impossible to generate a "UniqueIdentifier" type without threw an exception ... Here is my example: DECLARE @id uniqueidentifier SET @id = NEWID() INSERT INTO [dbo].[aspnet_Users] ...

jQuery vs. javascript?

I recently stumbled upon some javascript forums (sadly, link is lost somewhere in the universe), where you could feel real hate against jQuery for not being... any good? Most arguments seem to make sense actually. Now, I really like jQuery, mostly fo...

What's the best free C++ profiler for Windows?

I'm looking for a profiler in order to find the bottleneck in my C++ code. I'd like to find a free, non-intrusive, and good profiling tool. I'm a game developer, and I use PIX for Xbox 360 and found it very good, but it's not free. I know the In...

Date Conversion from String to sql Date in Java giving different output?

I have a string form of Date. I have to change it to Sql Date. so for that i have used the following code. String startDate="01-02-2013"; SimpleDateFormat sdf1 = new SimpleDateFormat("dd-mm-yyyy"); java.util.Date date = sdf1.parse(startDate); java....

how to remove pagination in datatable

I am new in jQuery. I have used Datatables in grid but need not pagination. There is a list of orders in one page and I show them in a Datatable grid but in bottom I do not want to show pagination. Is there any way to remove or hide pagination fro...

Could not load file or assembly ... The parameter is incorrect

Recently I met the following exception at C# solution: Error 2 Could not load file or assembly 'Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b9a188c8922137c6' or one of its dependencies. The parameter is incorrect. (Exc...

How to check the installed version of React-Native

I'm going to upgrade react-native but before I do, I need to know which version I'm upgrading from to see if there are any special notes about upgrading from my version. How do I find the version of react-native I have installed on my Mac?...

How do I declare and use variables in PL/SQL like I do in T-SQL?

In Sql Server, often times when I'm testing the body of a stored procedure, I copy the body into SSMS, DECLARE the variables at the top of the page, set them to some sample values, and execute the body as-is. For Example, if my proc is CREATE PROC ...

What's the fastest way to delete a large folder in Windows?

I want to delete a folder that contains thousands of files and folders. If I use Windows Explorer to delete the folder it can take 10-15 minutes (not always, but often). Is there a faster way in Windows to delete folders? Other details: I don't c...

Add (insert) a column between two columns in a data.frame

I have a data frame that has columns a, b, and c. I'd like to add a new column d between b and c. I know I could just add d at the end by using cbind but how can I insert it in between two columns? ...

How to force a line break in a long word in a DIV?

Okay, this is really confusing me. I have some content inside of a div like so: <div style="background-color: green; width: 200px; height: 300px;"> Thisisatest.Thisisatest.Thisisatest.Thisisatest.Thisisatest.Thisisatest. </div> Howev...

String to decimal conversion: dot separation instead of comma

I have a string read from a textbox. It contains a comma for decimal separation. I have NumberFormatInfo.CurrencyDecimalSeparator set to , (comma) but when I convert the string to decimal Convert.ToDecimal(mystring); I obtain a dot separate value fo...

How do I convert special UTF-8 chars to their iso-8859-1 equivalent using javascript?

I'm making a javascript app which retrieves .json files with jquery and injects data into the webpage it is embedded in. The .json files are encoded with UTF-8 and contains accented chars like รฉ, รถ and รฅ. The problem is that I don't control the ...

Merge (Concat) Multiple JSONObjects in Java

I am consuming some JSON from two different sources, I end up with two JSONObjects and I'd like to combine them into one. Data: "Object1": { "Stringkey":"StringVal", "ArrayKey": [Data0, Data1] } "Object2": { "Stringkey":"StringVal", ...

How to use performSelector:withObject:afterDelay: with primitive types in Cocoa?

The NSObject method performSelector:withObject:afterDelay: allows me to invoke a method on the object with an object argument after a certain time. It cannot be used for methods with a non-object argument (e.g. ints, floats, structs, non-object point...

'No JUnit tests found' in Eclipse

So I'm new to JUnit, and we have to use it for a homework assignment. Our professor gave us a project that has one test class, BallTest.java. When I right click > Run as > JUnit Test, I get a popup error that says 'No JUnit tests found'. I know the q...

What are projection and selection?

What is the difference between projection and selection? Is it: Projection --> for selecting the columns of table; and Selection ---> to select the rows of table? So are projection and selection vertical and horizontal slicing respectively?...

How to disable RecyclerView scrolling?

I cannot disable scrolling in the RecyclerView. I tried calling rv.setEnabled(false) but I can still scroll. How can I disable scrolling?...

String.format() to format double in java

How can I use String.format(format String,X) to format a double like follows??? 2354548.235 -> 2,354,548.23 Thanks!...

How to remove a file from the index in git?

How to remove a file from the index ( = staging area = cache) without removing it from the file system?...

Difference between frontend, backend, and middleware in web development

I was wondering if anyone can compare/contrast the differences between frontend, backend, and middleware ("middle-end"?) succinctly. Are there cases where they overlap? Are there cases where they MUST overlap, and frontend/backend cannot be separate...

setting textColor in TextView in layout/main.xml main layout file not referencing colors.xml file. (It wants a #RRGGBB instead of @color/text_color)

I'm trying to set some general colors for a program I'm writing. I created a colors.xml file and am trying to directly reference the colors from the layout.xml file. I believe I'm am doing this correctly however it's giving me the following error: C...

How to get response as String using retrofit without using GSON or any other library in android

I am trying to get response from the following Api : https://api.github.com/users/username But I don't know how to get response as String so that I can use the String to parse and get the JSONObject. Retrofit version used: retrofit:2.0.0-beta1...

Get combobox value in Java swing

I need to get the integer value of the combobox in Swing. I have set an integer value as id for the combobox.I tried combobox.getSelectedItem() and combobox.getSelectedIndex() but it cant get the int value. Below is my code: CommonBean commonBean[...

PHP - Failed to open stream : No such file or directory

In PHP scripts, whether calling include(), require(), fopen(), or their derivatives such as include_once, require_once, or even, move_uploaded_file(), one often runs into an error or warning: Failed to open stream : No such file or directory. ...

tomcat - CATALINA_BASE and CATALINA_HOME variables

I have multiple instances of tomcat 6 running on the same server (Linux) and it works as expected. I am trying to find out what the standard practice is with regards to setting the CATALINA_HOME and CATALINA_BASE variables. In my tomcat installation...

Sanitizing strings to make them URL and filename safe?

I am trying to come up with a function that does a good job of sanitizing certain strings so that they are safe to use in the URL (like a post slug) and also safe to use as file names. For example, when someone uploads a file I want to make sure that...

Custom alert and confirm box in jquery

Is there any alert and confirm dialog available in jquery with custom title and custom content in it. I have searched many sites but cannot find appropriate. Any site link or any content are appreciable....

Flutter Circle Design

I want to make this kind of design with these white circles as a raised button....

Keep overflow div scrolled to bottom unless user scrolls up

I have a div that is only 300 pixels big and I want it to when the page loads scroll to the bottom of the content. This div has content dynamically added to it and needs to stay scrolled all the way down. Now if the user decides to scroll up I don't ...

How to get the browser viewport dimensions?

I want to provide my visitors the ability to see images in high quality, is there any way I can detect the window size? Or better yet, the viewport size of the browser with JavaScript? See green area here: ...

Call web service in excel

In a VBA module in excel 2007, is it possible to call a web service? If so, any code snippets? How would I add the web reference?...

How can I generate a 6 digit unique number?

How can I generate a 6 digit unique number? I have verification mechanisms in place to check for duplicate entries....

How do I call a SQL Server stored procedure from PowerShell?

I have a large CSV file and I want to execute a stored procedure for each line. What is the best way to execute a stored procedure from PowerShell?...

How to create a inner border for a box in html?

How to Create a inner border for a box in html? See this picture: ...

How to count the NaN values in a column in pandas DataFrame

I want to find the number of NaN in each column of my data so that I can drop a column if it has fewer NaN than some threshold. I looked but wasn't able to find any function for this. value_counts is too slow for me because most of the values are di...

AngularJS : ng-click not working

I am new in AngularJs, ng-click is not working as expected. I searched on the internet , Follow the tutorial , (that was working) - but this is not working!!! My Code: <div class="row" ng:repeat="follower in myform.all_followers | partition:2"&...

Regex any ASCII character

What is the regex to match xxx[any ASCII character here, spaces included]+xxx? I am trying xxx[(\w)(\W)(\s)]+xxx, but it doesn't seem to work....

jquery simple image slideshow tutorial

Where can I find a simple jquery image slideshow tutorial for beginners from scratch (without plugins) without left and right navigation button? thank you....

How to get first element in a list of tuples?

I have a list like below where the first element is the id and the other is a string: [(1, u'abc'), (2, u'def')] I want to create a list of ids only from this list of tuples as below: [1,2] I'll use this list in __in so it needs to be a list of...

How to split a string in shell and get the last field

Suppose I have the string 1:2:3:4:5 and I want to get its last field (5 in this case). How do I do that using Bash? I tried cut, but I don't know how to specify the last field with -f....

How to hide UINavigationBar 1px bottom line

I have an app that sometimes needs its navigation bar to blend in with the content. Does anyone know how to get rid of or to change color of this annoying little bar? On the image below situation i have - i'm talking about this 1px height line be...

How to truncate the time on a DateTime object in Python?

What is a classy way to way truncate a python datetime object? In this particular case, to the day. So basically setting hour, minute, seconds, and microseconds to 0. I would like the output to also be a datetime object, not a string....

How to format numbers?

I want to format numbers using JavaScript. For example: 10 => 10.00 100 => 100.00 1000 => 1,000.00 10000 => 10,000.00 100000 => 100,000.00 ...

How to create new div dynamically, change it, move it, modify it in every way possible, in JavaScript?

I want to create new divs as the page loads. These divs will appear as an ordered group which changes depending upon external data from a JSON file. I will need to do this with a for loop because there are over 100 divs needed. So, I need to be able...

How to measure time in milliseconds using ANSI C?

Using only ANSI C, is there any way to measure time with milliseconds precision or more? I was browsing time.h but I only found second precision functions....

How can I mock requests and the response?

I am trying to use Pythons mock package to mock Pythons requests module. What are the basic calls to get me working in below scenario? In my views.py, I have a function that makes variety of requests.get() calls with different response each time de...

How to add a jar in External Libraries in android studio

I am new to Android Studio. What I need to do is add a few jar files in the External Libraries below the < JDK > folder. If anyone has knowledge of how to do this, please help me....

Change mysql user password using command line

I'm trying to update the password for a database user using the command line, and it's not working for me. This is the code I'm using: mysql> UPDATE user SET password=PASSWORD($w0rdf1sh) WHERE user='tate256'; Could someone tell me what's wrong ...

javascript, is there an isObject function like isArray?

Possible Duplicate: Check that value is object literal? I am working with an output that can be either null, 0, or a json object. And with that I need to come up with a means of determining if that output is indeed a real object. But I can...

Using LINQ to concatenate strings

What is the most efficient way to write the old-school: StringBuilder sb = new StringBuilder(); if (strings.Count > 0) { foreach (string s in strings) { sb.Append(s + ", "); } sb.Remove(sb.Length - 2, 2); } return sb.ToStr...

How to turn off gcc compiler optimization to enable buffer overflow

I'm working on a homework problem that requires disabling compiler optimization protection for it to work. I'm using gcc 4.4.1 on ubuntu linux, but can't figure out which flags are are the right ones. I realize it's architecture dependant - my machin...

How do I read configuration settings from Symfony2 config.yml?

I have added a setting to my config.yml file as such: app.config: contact_email: [email protected] ... For the life of me, I can't figure out how to read it into a variable. I tried something like this in one of my controllers: $recipien...

MySQL delete multiple rows in one query conditions unique to each row

So I know in MySQL it's possible to insert multiple rows in one query like so: INSERT INTO table (col1,col2) VALUES (1,2),(3,4),(5,6) I would like to delete multiple rows in a similar way. I know it's possible to delete multiple rows based on the ...

how to download file in react js

I receive file url as response from api. when user clicks on download button, the file should be downloaded without opening file preview in a new tab. How to achieve this in react js? ...

Error executing command 'ant' on Mac OS X 10.9 Mavericks when building for Android with PhoneGap/Cordova

Today I tried PhoneGap/Cordova with Mac OS X Mavericks. Building for iOS went just fine, but building for Android wasn't without some guesswork. I installed Android 4.2.2 via the Android SDK Manager (I had to use the older API v17 since it wasn't co...

How to shutdown my Jenkins safely?

I run Jenkins in its own container. I use the command "nohup java -jar jenkins.war --httpsPort=8443". How do I shut it down safely? Right now, I use the kill command to kill the process....

Android getResources().getDrawable() deprecated API 22

With new android API 22 getResources().getDrawable() is now deprecated. Now the best approach is to use only getDrawable(). What changed? ...

What's the difference between JPA and Hibernate?

I understand that JPA 2 is a specification and Hibernate is a tool for ORM. Also, I understand that Hibernate has more features than JPA 2. But from a practical point of view, what really is the difference? I have experience using iBatis and now I'...

Python IndentationError: unexpected indent

Here is my code ... I am getting indentation error but i don't know why it occurs. -> # loop while d <= end_date: # print d.strftime("%Y%m%d") fecha = d.strftime("%Y%m%d") # set url url = 'http://www.wpemergencia.omie.es//datosP...

Display image as grayscale using matplotlib

I'm trying to display a grayscale image using matplotlib.pyplot.imshow(). My problem is that the grayscale image is displayed as a colormap. I need the grayscale because I want to draw on top of the image with color. I read in the image and conver...

MySQL Delete all rows from table and reset ID to zero

I need to delete all rows from a table but when I add a new row, I want the primary key ID, which has an auto increment, to start again from 0 respectively from 1....

How do I get textual contents from BLOB in Oracle SQL

I am trying to see from an SQL console what is inside an Oracle BLOB. I know it contains a somewhat large body of text and I want to just see the text, but the following query only indicates that there is a BLOB in that field: select BLOB_FIELD fro...

jQuery issue in Internet Explorer 8

I am trying to get my jQuery functions to work on IE8. I am loading the library from Google's servers (http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js). The $(function(){}) is never called. Instead, I get an error Object expected. I op...

iPad Multitasking support requires these orientations

I'm trying to submit my universal iOS 9 apps to Apple (built with Xcode 7 GM) but I receive this error message for the bundle in iTunes Connect, just when I select Submit for Review: Invalid Bundle. iPad Multitasking support requires these orientati...

Create Pandas DataFrame from a string

In order to test some functionality I would like to create a DataFrame from a string. Let's say my test data looks like: TESTDATA="""col1;col2;col3 1;4.4;99 2;4.5;200 3;4.7;65 4;3.2;140 """ What is the simplest way to read that data into a Pandas ...

How to write log file in c#?

How would I write a log file in c#? Currently i have a timer with this statement which ticks every 20 secs: File.WriteAllText(filePath+"log.txt", log); For everything that i want logged i do this: log += "stringToBeLogged"; As you can assume ...

How to display a jpg file in Python?

def show(): file = raw_input("What is the name of the image file? ") picture = Image(file) width, height = picture.size() pix = picture.getPixels() I am trying to write a code to display this image but this code does not provide...

Rename multiple files in cmd

If I have multiple files in a directory and want to append something to their filenames, but not to the extension, how would I do this? I have tried the following, with test files file1.txt and file2.txt: ren *.txt *1.1.txt This renames the files...

Adb install failure: INSTALL_CANCELED_BY_USER

I try to install app via adb and get a error: $ ./adb -d install /Users/dimon/Projects/one-place/myprogram/platforms/android/build/outputs/apk/android-debug.apk -r -g 3704 KB/s (4595985 bytes in 1.211s) pkg: /data/local/tmp/android-debug.apk Fai...

Maven command to determine which settings.xml file Maven is using

How do I use maven command line to determine which settings.xml file Maven is picking up?...

JavaScript, getting value of a td with id name

Originally I was using input with an id and grabbing it's value with getElementById. Currently, I'm playing with <td>s. How can I grab the values of the <td>? Originally I used: <input id="hello"> document.getElementById("hello")....

No mapping found for HTTP request with URI Spring MVC

Here's my Web.xml <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <init-param> <param-...

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

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

How to automatically generate getters and setters in Android Studio

Is there a shortcut in Android Studio for automatically generating the getters and setters in a given class?...

How to add data to DataGridView

I'm having a Structure like X={ID="1", Name="XX", ID="2", Name="YY" }; How to dump this data to a DataGridView of two columns The gridView is like ID | Name Can we use LINQ to do this. I'm new to DataGridView Pleaese help me to do thi...

Convert JSON string to Javascript array

I have an array of arrays which I have planted in the DOM, so that I can reuse it at a later stage to transfer to the server: [["1","aaaaaa","1"],["2","bbbbbbb","2"],["3","ccc...

How to use router.navigateByUrl and router.navigate in Angular

https://angular.io/api/router/RouterLink gives a good overview of how to create links that will take the user to a different route in Angular4, however I can't find how to do the same thing programmatically rather needing the user to click a link...

Show default value in Spinner in android

I want to show a dropdown for gender selection. I passed a string array as String arr[]=new String[]{"male","female"}; but the problem is that is shows default selection with the value of "male" and I want to show "Gender" as default value. If I p...

What do all of Scala's symbolic operators mean?

Scala syntax has a lot of symbols. Since these kinds of names are difficult to find using search engines, a comprehensive list of them would be helpful. What are all of the symbols in Scala, and what does each of them do? In particular, I'd like to...

JQuery Validate input file type

I have a form that can have 0-hundreds of <input type="file"> elements. I have named them sequentially depending on how many are dynamically added to the page. For example: <input type="file" required="" name="fileupload1" id="fileupload1...

IIS7: Setup Integrated Windows Authentication like in IIS6

This is for IIS 7 on a Windows Server 2008 that is not part of an AD domain. I would like to password protect a website, where people have to enter a username/password (a windows account for example) to view the website. The website would then use ...

What does InitializeComponent() do, and how does it work in WPF?

What does InitializeComponent() do, and how does it work in WPF? In general first, but I would especially be interested to know the gory details of order of construction, and what happens when there are Attached Properties....

How to convert "0" and "1" to false and true

I have a method which is connecting to a database via Odbc. The stored procedure which I'm calling has a return value which from the database side is a 'Char'. Right now I'm grabbing that return value as a string and using it in a simple if statemen...

Difference between decimal, float and double in .NET?

What is the difference between decimal, float and double in .NET? When would someone use one of these?...

How to get base64 encoded data from html image

I have a registration form where users can choose an avatar. They have 2 possibilities: Choose a default avatar Upload their own avatar In my HTML page I have this. <img id="preview" src="img/default_1.png"> It displays the chosen avatar...

Disable browsers vertical and horizontal scrollbars

Is it possible to disable the browsers vertical and horizontal scrollbars using jQuery or javascript?...

Convert date to another timezone in JavaScript

I am looking for a function to convert date in one timezone to another. It need two parameters, date (in format "2012/04/10 10:10:30 +0000") timezone string ("Asia/Jakarta") The timezone string is described in http://en.wikipedia.org/wiki/Zon...

PHP & localStorage;

I've searched around for use of localStorage in PHP, as I need to get localStorage data as a $var, in PHP and do stuff in PHP with it. Is this possible? P.S. If anybody knows any good HTML5 resources, other than what can be easily found on Google, p...

How to write character & in android strings.xml

I wrote the following in the strings.xml file: <string name="game_settings_dragNDropMove_checkBox">Move by Drag&Drop</string> I got the following error: The reference to entity "Drop" must end with the ';' delimiter. How can I w...

Integer to hex string in C++

How do I convert an integer to a hex string in C++? I can find some ways to do it, but they mostly seem targeted towards C. It doesn't seem there's a native way to do it in C++. It is a pretty simple problem though; I've got an int which I'd like to...

Reading images in python

I am trying to read a png image in python. The imread function in scipy is being deprecated and they recommend using imageio library. However, I am would rather restrict my usage of external libraries to scipy, numpy and matplotlib libraries. Thus,...

Uninstall Django completely

I uninstalled django on my machine using pip uninstall Django. It says successfully uninstalled whereas when I see django version in python shell, it still gives the older version I installed. To remove it from python path, I deleted the django fold...

Why should we NOT use sys.setdefaultencoding("utf-8") in a py script?

I have seen few py scripts which use this at the top of the script. In what cases one should use it? import sys reload(sys) sys.setdefaultencoding("utf-8") ...

Finding element's position relative to the document

What's the easiest way to determine an elements position relative to the document/body/browser window? Right now I'm using .offsetLeft/offsetTop, but this method only gives you the position relative to the parent element, so you need to determine h...

source command not found in sh shell

I have a script that uses sh shell. I get an error in the line that uses the source command. It seems source is not included in my sh shell. If I explicitly try to run source from shell I get: sh: 1: source: not found Should I somehow install "s...

Adding text to a cell in Excel using VBA

I've been working with SQL and Excel Macros, but I don't know how to add text to a cell. I wish to add the text "01/01/13 00:00" to cell A1. I can't just write it in the cell because the macro clears the contents of the sheet first and adds the info...

Difference between iCalendar (.ics) and the vCalendar (.vcs)

I want to send booking information through mail in an attachment to add in MS Outlook. Which format is better? Especially for MS Outlook 2003?...

How to call a SOAP web service on Android

I am having a lot of trouble finding good information on how to call a standard SOAP/WSDL web service with Android. All I've been able to find are either very convoluted documents and references to "kSoap2" and then some bit about parsing it all manu...

How to allow user to pick the image with Swift?

I am writing my first iOS application (iPhone only) with Swift. The main application view should allow user to choose the image from the photo gallery. I've found the following sample code of ViewController.swift: class ViewController: UIImagePick...

Setting a PHP $_SESSION['var'] using jQuery

I need to set a PHP $_SESSION variable using the jQuery. IF the user clicks on an image I want to save a piece of information associated with that image as a session variable in php. I think I can do this by calling a php page or function and appen...

automating telnet session using bash scripts

I am working on automating some telnet related tasks, using Bash scripts. Once automated there will be no interaction of the user with telnet. (that is it will be totally automated) the scripts looks something like this: # execute some commands on th...

Command to list all files in a folder as well as sub-folders in windows

I tried searching for a command that could list all the file in a directory as well as subfolders using a command prompt command. I have read the help for "dir" command but coudn't find what I was looking for. Please help me what command could get th...

How to add a JAR in NetBeans

Let's say you create a new project, and want it to make use of some 3rd party library, say, widget.jar. Where do you add this JAR: File >> Project Properties >> Libraries >> Compile-Time Libraries; or File >> Project Properties >> Libraries >> Run-...

Laravel orderBy on a relationship

I am looping over all comments posted by the Author of a particular post. foreach($post->user->comments as $comment) { echo "<li>" . $comment->title . " (" . $comment->post->id . ")</li>"; } This gives me...

Using an index to get an item, Python

I have a tuple in python ('A','B','C','D','E'), how do I get which item is under a particular index number? Example: Say it was given 0, it would return A. Given 2, it would return C. Given 4, it would return E....

Best data type for storing currency values in a MySQL database

What is the best SQL data type for currency values? I'm using MySQL but would prefer a database independent type....

Is a new line = \n OR \r\n?

I've seen many developers use different methods to split a string by new lines, but i'm confused which is the correct: \r\n OR \n only?...

The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception

I'm working with EF5 in a MVC 4 aspnet website. Locally, everything works just fine, but when I publish it to the IIS and try to enter, I get the error "The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception." Det...

Oracle 'Partition By' and 'Row_Number' keyword

I have a SQL query written by someone else and I'm trying to figure out what it does. Can someone please explain what the Partition By and Row_Number keywords does here and give a simple example of it in action, as well as why one would want to use i...

How can I initialise a static Map?

How would you initialise a static Map in Java? Method one: static initialiser Method two: instance initialiser (anonymous subclass) or some other method? What are the pros and cons of each? Here is an example illustrating the two methods: import...

Can I export a variable to the environment from a bash script without sourcing it?

Suppose that I have this script export.bash: #! /usr/bin/env bash export VAR="HELLO, VARIABLE" When I execute the script and try to access to the $VAR, I get no value! echo $VAR Is there any way to access to the $VAR by just executing export.b...

How to implement debounce in Vue2?

I have a simple input box in a Vue template and I would like to use debounce more or less like this: <input type="text" v-model="filterKey" debounce="500"> However the debounce property has been deprecated in Vue 2. The recommendation only s...

What are alternatives to ExtJS?

So what I'm looking for is a javascript framework I can use that has several UI controls. I have taken a look at jQuery but those controls are very basic compared to ExtJS. Are there any other competitive alternatives? This question exists becaus...

Oracle: How to find out if there is a transaction pending?

I'm looking for a way to find out if there are uncommited INSERT, UPDATE or DELETE statements in the current session. One way would be to check v$lock with the current sid, but that requires read access to v$lock, which is a problem if the DBA doesn'...

How to show full height background image?

I have a photo type (not landscape) background image with 979px width by 1200px height. I would like to set it to float left and show 100% full image height fixed, without the need to scroll up/down (regardless of content length). This is my CSS cod...

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 7: ordinal not in range(128)

I have this code: printinfo = title + "\t" + old_vendor_id + "\t" + apple_id + '\n' # Write file f.write (printinfo + '\n') But I get this error when running it: f.write(printinfo + '\n') UnicodeEncodeError: 'ascii' codec can't en...

convert a JavaScript string variable to decimal/money

How can we convert a JavaScript string variable to decimal? Is there a function such as: parseInt(document.getElementById(amtid4).innerHTML) ...

Setting equal heights for div's with jQuery

I want to set equal height for divs with jQuery. All the divs may have different amount of content and different default height. Here is a sample of my html layout: <div class="container"> <div class="column">This is<br />the ...

How Do I Insert a Byte[] Into an SQL Server VARBINARY Column

I have a byte array highlighted below, how do I insert it into a SQL Server database Varbinary column? byte[] arraytoinsert = new byte[10]{0,1,2,3,4,5,6,7,8,9}; string sql = string.format ( "INSERT INTO mssqltable (varbinarycolumn) VAL...

What is the difference between sscanf or atoi to convert a string to an integer?

gcc 4.4.4 c89 What is better to convert a string to an integer value. I have tried 2 different methods atoi and sscanf. Both work as expected. char digits[3] = "34"; int device_num = 0; if(sscanf(digits, "%d", &device_num) == EOF) { fprin...

Access Session attribute on jstl

I am trying to access a session attribute from a jsp page which is set and dispatched by a servlet, but I am getting the error message "jsp:attribute must be the subelement of a standard or custom action". What could be wrong, am I accessing it incor...

Page redirect after certain time PHP

There is a certain PHP function for redirecting after some time. I saw it somewhere but can't remember. It's like the gmail redirection after logging in. Please, could anyone remind me?...

Vertically align text within a div

The code below (also available as a demo on JS Fiddle) does not position the text in the middle, as I ideally would like it to. I cannot find any way to vertically centre text in a div, even using the margin-top attribute. How can I do this? <div...

Firebase FCM force onTokenRefresh() to be called

I am migrating my app from GCM to FCM. When a new user installs my app, the onTokenRefresh() is automatically being called. The problem is that the user is not logged in yet (No user id). How can I trigger the onTokenRefresh() after the user is log...

How to sort an array of ints using a custom comparator?

I need to sort an array of ints using a custom comparator, but Java's library doesn't provide a sort function for ints with comparators (comparators can be used only with objects). Is there any easy way to do this?...

Create table using Javascript

I have a JavaScript function which creates a table with 3 rows 2 cells. Could anybody tell me how I can create the table below using my function (I need to do this for my situation)? Here is my javascript and html code given below: _x000D_ _x000D_...

Python - Passing a function into another function

I am solving a puzzle using python and depending on which puzzle I am solving I will have to use a special set of rules. How can I pass a function into another function in Python? Example def Game(listA, listB, rules): if rules == True: do...

How to enter ssh password using bash?

Everyday I am connecting to a server through ssh. I go through this routine: IC001:Desktop user$ ssh [email protected] [email protected]'s password: Last login: Tue Jun 4 10:09:01 2013 from 0.0.0.0 $ I would like to automate this process and ...

How to put a component inside another component in Angular2?

I'm new at Angular and I'm still trying to understand it. I've followed the course on the Microsoft Virtual Academy and it was great, but I found a little discrepancy between what they said and how my code behave! Specifically, I've tried to "put a c...

CSS - display: none; not working

I'm trying to develop a mobile stylesheet and in this stylesheet I want to remove a particular div. In the HTML code of the div, I place an id called "tfl", as shown below: <div id="tfl" style="display: block; width: 187px; height: 260px; font-...

not-null property references a null or transient value

Facing trouble in saving parent/child object with hibernate. Any idea would be highly appreciated. org.hibernate.PropertyValueException: not-null property references a null or transient value: example.forms.InvoiceItem.invoice at org.hibernate.e...

Twitter bootstrap scrollable modal

I'm using twitter bootstrap for a project I am working on. I have a modal window that has a somewhat longer form in it and I didn't like that when the window got too small the modal didn't scroll (if just disappeared off my page which isn't scrolla...

Why can't I do <img src="C:/localfile.jpg">?

It works if the html file is local (on my C drive), but not if the html file is on a server and the image file is local. Why is that? Any possible workarounds?...

read.csv warning 'EOF within quoted string' prevents complete reading of file

I have a CSV file (24.1 MB) that I cannot fully read into my R session. When I open the file in a spreadsheet program I can see 112,544 rows. When I read it into R with read.csv I only get 56,952 rows and this warning: cit <- read.csv("citations....

List all kafka topics

I'm using kafka 0.10 without zookeeper. I want to get kafka topics list. This command is not working since we're not using zookeeper: bin/kafka-topics.sh --list --zookeeper localhost:2181. How can I get the same output without zookeeper?...

Why can't I define my workbook as an object?

Why can't I define a workbook either of these ways? (I have the range bit in there just for a quick test.) How do I fix it? This produces a "Compile Error: Type Mismatch" Sub Setwbk() Dim wbk As Workbook Set wbk = "F:\Quarterly Reports\...

How to convert Blob to String and String to Blob in java

I'm trying to get string from BLOB datatype by using Blob blob = rs.getBlob(cloumnName[i]); byte[] bdata = blob.getBytes(1, (int) blob.length()); String s = new String(bdata); It is working fine but when I'm going to convert String to Blob and tr...

Oracle DB : java.sql.SQLException: Closed Connection

Reasons for java.sql.SQLException: Closed Connection from Oracle?? java.sql.SQLException: Closed Connection at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlExce...

How do I disable Git Credential Manager for Windows?

I notice that in the latest version of Git, the default is now to popup a "Git Credential Manager for Windows" dialog instead of prompting me for me password at the Bash prompt every time. I really hate this behaviour. How can I just disable it and ...

How can I set the default value for an HTML <select> element?

I thought that adding a "value" attribute set on the <select> element below would cause the <option> containing my provided "value" to be selected by default: _x000D_ _x000D_ <select name="hall" id="hall" value="3">_x000D_ <op...

How to stop an unstoppable zombie job on Jenkins without restarting the server?

Our Jenkins server has a job that has been running for three days, but is not doing anything. Clicking the little X in the corner does nothing, and the console output log doesn't show anything either. I've checked on our build servers and the job doe...

Run Excel Macro from Outside Excel Using VBScript From Command Line

I'm trying to run an Excel macro from outside of the Excel file. I'm currently using a ".vbs" file run from the command line, but it keeps telling me the macro can't be found. Here is the script I'm trying to use Set objExcel = CreateObject("Excel.A...

How to read .pem file to get private and public key

I am writing a small piece of code which reads public and private key stored in .pem file. I am using the following commands to generate the keys. Below command to generate pair of key. $openssl genrsa -out mykey.pem 2048 This command to g...

Is there any way to install Composer globally on Windows?

I've read the global installation documentation for Composer, but it's for *nix systems only: curl -s https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer I would be such happy doing the same on Windows, that's t...

css selector to match an element without attribute x

I'm working on a CSS file and find the need to style text input boxes, however, I'm running into problems. I need a simple declaration that matches all these elements: <input /> <input type='text' /> <input type='password' /> ......

Github Windows 'Failed to sync this branch'

I am using Github Windows 1.0.38.1 and when I click the 'Sync' button after committing, I get the error How do I debug this problem? If in the shell, what should I do? The sync works fine if i do a git push or git pull, but the next time I want ...

Excel VBA Automation Error: The object invoked has disconnected from its clients

I know I've seen references to this issue before, but I have tried several of the suggestions and I am still getting the error. I have a workbook that assembles data from another book and generates a report. I then want to make a new workbook, copy...

jQuery - replace all instances of a character in a string

This does not work and I need it badly $('some+multi+word+string').replace('+', ' ' ); always gets some multi+word+string it's always replacing for the first instance only, but I need it to work for all + symbols....

How can I change or remove HTML5 form validation default error messages?

For example I have a textfield. The field is mandatory, only numbers are required and length of value must be 10. When I try to submit form with value which length is 5, the default error message appears: Please match the requested format <in...

Can scrapy be used to scrape dynamic content from websites that are using AJAX?

I have recently been learning Python and am dipping my hand into building a web-scraper. It's nothing fancy at all; its only purpose is to get the data off of a betting website and have this data put into Excel. Most of the issues are solvable and ...

How do I update pip itself from inside my virtual environment?

I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version. What's the command for that? Do I need to use distr...

How to Customize a Progress Bar In Android

I am working on an app in which I want to show a ProgressBar, but I want to replace the default Android ProgressBar. So how can I customize the ProgressBar? Do I need some graphics and animation for that? I read the following post but could not ge...

How to match hyphens with Regular Expression?

How to rewrite the [a-zA-Z0-9!$* \t\r\n] pattern to match hyphen along with the existing characters ?...

Running Java gives "Error: could not open `C:\Program Files\Java\jre6\lib\amd64\jvm.cfg'"

After years of working OK, I'm suddenly getting this message when trying to start the JVM: Error: could not open `C:\Program Files\Java\jre6\lib\amd64\jvm.cfg' I tried uninstalling, and got a message saying a DLL was missing (unspecified) Tried re...

iOS: Convert UTC NSDate to local Timezone

How do I convert a UTC NSDate to local timezone NSDate in Objective C or/and Swift?...

Difference between object and class in Scala

I'm just going over some Scala tutorials on the Internet and have noticed in some examples an object is declared at the start of the example. What is the difference between class and object in Scala?...

How should I do integer division in Perl?

What is a good way to always do integer division in Perl? For example, I want: real / int = int int / real = int int / int = int ...

Array Index Out of Bounds Exception (Java)

Here is my code: public class countChar { public static void main(String[] args) { int i; String userInput = new String(); userInput = Input.getString("Please enter a sentence"); int[] total = totalChars(userIn...

Increasing Heap Size on Linux Machines

I work on Ubuntu desktop machine and I'd like to increase heap size for Java. The RAM is 16GB and the current Max Heap Size is 3GB I checked this post post Increasing Tomcat Heap Size Not much found about Ubuntu, so I tried this command: java -Xmx...

How to solve error message: "Failed to map the path '/'."

I've searched and searched on Google, and I can't find anything that even seems applicable to my situation, let alone solves the problem. It doesn't matter which address in my website I try to navigate to (even addresses that don't exist give this er...

Angular exception: Can't bind to 'ngForIn' since it isn't a known native property

What am I doing wrong? import {bootstrap, Component} from 'angular2/angular2' @Component({ selector: 'conf-talks', template: `<div *ngFor="let talk in talks"> {{talk.title}} by {{talk.speaker}} <p>{{talk.description}} &...

Passing additional variables from command line to make

Can I pass variables to a GNU Makefile as command line arguments? In other words, I want to pass some arguments which will eventually become variables in the Makefile....

How to install a Mac application using Terminal

Apple suggests that prior to submitting to the Mac application store, the installation process for Macs be tested using the command sudo installer -store -pkg path-to-package -target / I saved the application package to the desktop and then in the...

C: convert double to float, preserving decimal point precision

i wanted to convert double to float in C, but wanted to preserve the decimal point exactly as possible without any changes... for example, let's say i have double d = 0.1108; double dd = 639728.170000; double ddd = 345.2345678 now correc...

Finding the path of the program that will execute from the command line in Windows

Say I have a program X.EXE installed in folder c:\abcd\happy\ on the system. The folder is on the system path. Now suppose there is another program on the system that's also called X.EXE but is installed in folder c:\windows\. Is it possible to quic...

Difference between JE/JNE and JZ/JNZ

In x86 assembly code, are JE and JNE exactly the same as JZ and JNZ?...

Makefiles with source files in different directories

I have a project where the directory structure is like this: $projectroot | +---------------+----------------+ | | | part1/ ...

Double value to round up in Java

I have a double value = 1.068879335 i want to round it up with only two decimal values like 1.07. I tried like this DecimalFormat df=new DecimalFormat("0.00"); String formate = df.format(value); double finalValue = Double.parseDouble(formate) ; t...

html div onclick event

I have one html div on my jsp page, on that i have put one anchor tag, please find code below for that, <div class="expandable-panel-heading"> <h2> <a id="ancherComplaint" href="#addComplaint" ...

Unit testing void methods?

What is the best way to unit test a method that doesn't return anything? Specifically in c#. What I am really trying to test is a method that takes a log file and parses it for specific strings. The strings are then inserted into a database. Nothing...

What does "Fatal error: Unexpectedly found nil while unwrapping an Optional value" mean?

My Swift program is crashing with EXC_BAD_INSTRUCTION and one of the following similar errors. What does this error mean, and how do I fix it? Fatal error: Unexpectedly found nil while unwrapping an Optional value or Fatal error: Unexpect...

std::cin input with spaces?

#include <string> std::string input; std::cin >> input; The user wants to enter "Hello World". But cin fails at the space between the two words. How can I make cin take in the whole of Hello World? I'm actually doing this with structs...

Remove Fragment Page from ViewPager in Android

I'm trying to dynamically add and remove Fragments from a ViewPager, adding works without any problems, but removing doesn't work as expected. Everytime I want to remove the current item, the last one gets removed. I also tried to use an FragmentSt...

How to restart Activity in Android

How do I restart an Android Activity? I tried the following, but the Activity simply quits. public static void restartActivity(Activity act){ Intent intent=new Intent(); intent.setClass(act, act.getClass()); act.startActivi...

What is the difference between atan and atan2 in C++?

What is the difference between atan and atan2 in C++?...

Eclipse EGit Checkout conflict with files: - EGit doesn't want to continue

I've started Eclipse EGit. In some scenarios it is really not comprehensive. I have local file e.g. pom.xml changed. On git server this file was changed. I do pull, EGIt says: Checkout conflict with files: i.e. pulling stops (fetch is done,...

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 <omp.h> #include "mpi.h" using namespace std; ...

How to change an application icon programmatically in Android?

Is it possible to change an application icon directly from the program? I mean, change icon.png in the res\drawable folder. I would like to let users to change application's icon from the program so next time they would see the previously selected ic...

How can I show/hide component with JSF?

How can I show/hide component with JSF? I am currently trying so do the same with the help of javascript but not successfull. I cannot use any third party libraries. Thanks| Abhi...

Best practice to look up Java Enum

We have a REST API where clients can supply parameters representing values defined on the server in Java Enums. So we can provide a descriptive error, we add this lookup method to each Enum. Seems like we're just copying code (bad). Is there a bet...

How to export html table to excel using javascript

My table is in format <table id="mytable"> <thead> <tr> <th>name</th> <th>place</th> </tr> </thead> <tbody> <tr> <td>adfas</td> <td>asdfasf</td...

Find location of a removable SD card

Is there an universal way to find the location of an external SD card? Please, do not be confused with External Storage. Environment.getExternalStorageState() returns the path to the internal SD mount point, like "/mnt/sdcard". But the question is ...

How to remove carriage return and newline from a variable in shell script

I am new to shell script. I am sourcing a file, which is created in Windows and has carriage returns, using the source command. After I source when I append some characters to it, it always comes to the start of the line. test.dat (which has carriag...

Spring Boot application as a Service

How to configure nicely Spring Boot application packaged as executable jar as a Service in the Linux system? Is this recommended approach, or should I convert this app to war and install it into Tomcat? Currently, I can run Spring boot application fr...

Simple dictionary in C++

Moving some code from Python to C++. BASEPAIRS = { "T": "A", "A": "T", "G": "C", "C": "G" } Thinking maps might be overkill? What would you use?...

Sorting std::map using value

I need to sort an std::map by value rather than by key. Is there an easy way to do it? I got one solution from the follwing thread: std::map sort by data? Is there a better solution? map<long, double> testMap; // some code to generate the v...

How do I read all classes from a Java package in the classpath?

I need to read classes contained in a Java package. Those classes are in classpath. I need to do this task from a Java program directly. Do you know a simple way to do? List<Class> classes = readClassesFrom("my.package") ...

How to get Toolbar from fragment?

I have ActionBarActivity with NavigationDrawer and use support_v7 Toolbar as ActionBar. In one of my fragments toolbar has custom view. In other fragments Toolbar should show title. How get Toolbar instance for customizing from fragments? I can get ...

Python Requests throwing SSLError

I'm working on a simple script that involves CAS, jspring security check, redirection, etc. I would like to use Kenneth Reitz's python requests because it's a great piece of work! However, CAS requires getting validated via SSL so I have to get pas...

What is the Windows equivalent of the diff command?

I know that there is a post similar to this : here. I tried using the comp command like it mentioned, but if I have two files, one with data like "abcd" and the other with data "abcde", it just says the files are of different sizes. I wanted to know ...

How do I implement a progress bar in C#?

How do I implement a progress bar and backgroundworker for database calls in C#? I do have some methods that deal with large amounts of data. They are relatively long running operations, so I want to implement a progress bar to let the user know tha...

Play infinitely looping video on-load in HTML5

I'm looking to place a video in an HTML5 page that will begin playing on page-load, and once completed, loop back to the beginning without a break. The video should also NOT have any controls associated with it, and either be compatible with all 'mod...

isset in jQuery?

Possible Duplicate: Finding whether the element exists in whole html page i would like make somethings: HTML: <span id="one">one</span> <span id="two">two</span> <span id="three">three</span> JavaScr...

CRON command to run URL address every 5 minutes

I'm newbie in cron commands and I need help. I have a script on http://example.com/check/. Whats is command for cron to run this URL every 5 minutes? I tried */5 * * * * /home/test/check.php But I want to run URL not relative script addres...

center MessageBox in parent form

Is there a easy way to center MessageBox in parent form in .net 2.0...

No connection could be made because the target machine actively refused it?

Sometimes I get the following error while I was doing HttpWebRequest to a WebService. I copied my code below too. System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made...