Examples On Programing Languages

How to end a session in ExpressJS

I feel like this has to be buried somewhere in the documentation, but I can't find it. How do you close or end or kill (whatever) a session in ExpressJS?...

PHP Excel Header

header("Content-Type: application/vnd.ms-excel; charset=utf-8"); header("Content-type: application/x-msexcel; charset=utf-8"); header("Content-Disposition: attachment; filename=abc.xsl"); header("Expires: 0"); header("Cache-Control: must-revalid...

ADB not responding. You can wait more,or kill "adb.exe" process manually and click 'Restart'

I have installed Android Studio. Then I have updated the Android SDK. Now when I start Android Studio, this message pops up: ADB not responding. You can wait more,or kill "adb.exe" process manually and click 'Restart' The dialog has 3 options: ...

problem with php mail 'From' header

I'm building a website that sends and email to a user when he registers. My code (the gist of it): <?php $to = "[email protected]"; $subject = "Test mail"; $message = "Hello! \nThis is a simple email message."; $headers = "From: munged@gmail...

C++ compiling on Windows and Linux: ifdef switch

I want to run some c++ code on Linux and Windows. There are some pieces of code that I want to include only for one operating system and not the other. Is there a standard #ifdef that once can use? Something like: #ifdef LINUX_KEY_WORD ... ...

How to print third column to last column?

I'm trying to remove the first two columns (of which I'm not interested in) from a DbgView log file. I can't seem to find an example that prints from column 3 onwards until the end of the line. Note that each line has variable number of columns. ...

Put text at bottom of div

I have 4 DIV's right next to each other, and they're all centered in the middle of the screen. I have 2 words in each div, but I don't want them at the top, I want them to appear in the bottom right hand corner of the div. How can I do this?...

How to replace unicode characters in string with something else python?

I have a string that I got from reading a HTML webpage with bullets that have a symbol like "•" because of the bulleted list. Note that the text is an HTML source from a webpage using Python 2.7's urllib2.read(webaddress). I know the unicode chara...

WordPress query single post by slug

For the moment when I want to show a single post without using a loop I use this: <?php $post_id = 54; $queried_post = get_post($post_id); echo $queried_post->post_title; ?> The problem is that when I move the site, the id's usually chang...

jQuery get the name of a select option

I have a dropdown list with several option, each option has a name attribute. When I select an option, a different list of checkboxes needs to appear - when another options is selected, that checkbox list should disappear and another one be displayed...

jQuery scrollTop() doesn't seem to work in Safari or Chrome (Windows)

I've got a simple setup to allow a "help"-style window to be loaded and scrolled to a particular point on the page. More or less the code looks like this: var target = /* code */; target.offsetParent().scrollTop(target.offset().top - fudgeValue); ...

Is there an Eclipse plugin to run system shell in the Console?

Do you know of any Eclipse plugin to run a system shell in the included console? It would be awesome. Dolphin, KDE's file navigator, has this feature, you can press F4 and a console shows located on the directory you are standing. It would be awesom...

How can I load storyboard programmatically from class?

My problem is that I was looking for way to use both storyboard and xib. But I can't find proper way to load and show storyboard programmatically. Project was started developing with xib, and now it's very hard to nest all xib files in storyboard. So...

How to write a stored procedure using phpmyadmin and how to use it through php?

I want to be able create stored procedures using phpMyAdmin and later on use it through php. But I dont know how to? From what I know, I found out that we cannot manage stored procedures through phpMyAdmin. What other tool can manage stored procedure...

How to get device make and model on iOS?

I was wondering if it's possible to determine what kind of iPhone (for example) the currentdevice is? I know it's possible to get the model through NSString *deviceType = [[UIDevice currentDevice] model]; which will just return whether I have an ...

Change One Cell's Data in mysql

How can I change the data in only one cell of a mysql table. I have problem with UPDATE because it makes all the parameters in a column change but I want only one changed. How?...

How to compile C programming in Windows 7?

I am looking for free tools to compile C programs on Windows 7. I've always compiled C code on Ubuntu using gcc in the past. So, how can I compile C code on Windows 7? Please teach me. :)...

android:drawableLeft margin and/or padding

Is it possible to set the margin or padding for the image which we added with the android:drawableLeft?...

Convert string to a variable name

I am using R to parse a list of strings in the form: original_string <- "variable_name=variable_value" First, I extract the variable name and value from the original string and convert the value to numeric class. parameter_value <- as.nume...

Invoke a second script with arguments from a script

I have a script that reads a configuration file that results in a set of name value pairs that I would like to pass as arguments to a function in a second PowerShell script. I do not know what parameters will be placed in this configuration file at d...

How to get memory available or used in C#

How can I get the available RAM or memory used by the application? ...

Getting a better understanding of callback functions in JavaScript

I understand passing in a function to another function as a callback and having it execute, but I'm not understanding the best implementation to do that. I'm looking for a very basic example, like this: var myCallBackExample = { myFirstFunction ...

php: Get html source code with cURL

How can I get the html source code of http://www.example-webpage.com/file.html without using file_get_contents()? I need to know this because on some webhosts allow_url_fopen is disabled so you can't use file_get_contents(). Is it possible to get th...

Error: free(): invalid next size (fast):

What is this strange error I'm getting? I'm compiling C++ using g++ on Ubuntu 10.10. It pops up randomly when I run the executable (maybe 2 times in 8 hours, with 10 compiles an hour). However, if I make clean and recompile it goes away most of the t...

Make a table fill the entire window

How can I make a HTML table fill the entire browser window horizontally and vertically? The page is simply a title and a score which should fill the entire window. (I realise the fixed font sizes are a separate issue.) <table style="width: 100%...

Adjust UILabel height depending on the text

Consider I have the following text in a UILabel (a long line of dynamic text): Since the alien army vastly outnumbers the team, players must use the post-apocalyptic world to their advantage, such as seeking cover behind dumpsters, pillars, cars,...

How to reload apache configuration for a site without restarting apache?

I have edited the variable AllowOverride for one of my websites in sites-enabled directory. How do I reload the new configuration without restarting apache? Is it possible?...

How can I use regex to get all the characters after a specific character, e.g. comma (",")

Need a Regex to get all characters after , (not including it) from a variable. This variable can contain for example 'SELECT___100E___7',24 'SELECT___100E___7',1 'SELECT___100E___7',286 'SELECT___100E___7',5147 Note: There can be any length of ch...

How do I Merge two Arrays in VBA?

Given Dim arr1 As Variant Dim arr2 As Variant Dim arr3 As Variant arr1 = Array("A", 1, "B", 2) arr2 = Array("C", 3, "D", 4) What kind of operations can I do on arr1 and arr2 and store result in arr3 such that: arr3 = ("A", "C", 1, 3, "B", "D"...

Counting no of rows returned by a select query

I need to count the no of rows which is returned by the following query. select m.Company_id from Monitor as m inner join Monitor_Request as mr on mr.Company_ID=m.Company_id group by m.Company_id having COUNT(m.Monitor_id)>=5 I have...

Connect to sqlplus in a shell script and run SQL scripts

I have a .sql file, which is a bunch of oracle pl/sql commands and I want to create a shell script to run these commands. Suppose that user/pass@server is my credentials. What will be the shell script to do such a task?...

What is the single most influential book every programmer should read?

If you could go back in time and tell yourself to read a specific book at the beginning of your career as a developer, which book would it be? I expect this list to be varied and to cover a wide range of things. To search: Use the search box in the...

JAVA_HOME and PATH are set but java -version still shows the old one

I am using Linux Mint Cinnamon 14. I have set the $JAVA_HOME and $PATH environment variables in ~/.profile as follows: export JAVA_HOME=/home/aqeel/development/jdk/jdk1.6.0_35 export PATH=/home/aqeel/development/jdk/jdk1.6.0_35/bin:$PATH I then di...

How to export a table dataframe in PySpark to csv?

I am using Spark 1.3.1 (PySpark) and I have generated a table using a SQL query. I now have an object that is a DataFrame. I want to export this DataFrame object (I have called it "table") to a csv file so I can manipulate it and plot the columns. Ho...

How to create a circular ImageView in Android?

How could I create a rounded ImageView in Android? I have tried the following code, but it's not working fine. Code: Bitmap circleBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); BitmapShader shader = ...

How to read integer value from the standard input in Java

What class can I use for reading an integer variable in Java?...

Can I write or modify data on an RFID tag?

maybe my question would be lost in the forum, but has somebody work with RFID tags? I know I can read them, but can I write or modify the inside data? Does anyone know where can I find more about this?...

JavaScript - Get minutes between two dates

If I have two dates, how can I use JavaScript to get the difference between the two dates in minutes?...

How to select a drop-down menu value with Selenium using Python?

I need to select an element from a drop-down menu. For example: <select id="fruits01" class="select" name="fruits"> <option value="0">Choose your fruits:</option> <option value="1">Banana</option> <option val...

How can I make all images of different height and width the same via CSS?

I am trying to create an image wall consisting of product photos. Unfortunately, all of them are of different height and width. How can I use css to make all images look the same size? preferably 100 x 100. I was thinking of doing a div that has...

Difference between Pragma and Cache-Control headers?

I read about Pragma header on Wikipedia which says: "The Pragma: no-cache header field is an HTTP/1.0 header intended for use in requests. It is a means for the browser to tell the server and any intermediate caches that it wants a fresh vers...

Big-oh vs big-theta

Possible Duplicate: What is the difference between T(n) and O(n)? It seems to me like when people talk about algorithm complexity informally, they talk about big-oh. But in formal situations, I often see big-theta with the occasional big-oh thrown...

How to get an Android WakeLock to work?

My WakeLock isn't keeping my device awake. In OnCreate() I've got: PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "My Tag"); mW...

Fatal error: "No Target Architecture" in Visual Studio

When I try to compile my c++ project using Visual Studio 2010 in either Win32 or x64 mode I get the following error: >C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(135): fatal error C1189: #error : "No Target Architecture" ...

Upgrade version of Pandas

I am running Python on a Windows machine at the following path: C:\WinPython-64bit-3.4.4.1 I am trying to upgrade to the latest version of pandas (currently running '0.17.1') but am having problems. I have looked at previous posts and have tried ...

How can I filter a date of a DateTimeField in Django?

I am trying to filter a DateTimeField comparing with a date. I mean: MyObject.objects.filter(datetime_attr=datetime.date(2009,8,22)) I get an empty queryset list as an answer because (I think) I am not considering time, but I want "any time". Is ...

QuotaExceededError: Dom exception 22: An attempt was made to add something to storage that exceeded the quota

Using LocalStorage on iPhone with iOS 7 throws this error. I've been looking around for a resolvant, but considering I'm not even browsing in private, nothing is relevant. I don't understand why localStorage would be disabled by default in iOS 7, bu...

Box shadow in IE7 and IE8

I want to implement box shadows in IE7 and IE8. I have tried everything without succeeding. Here is the css that I am using to apply colored shadow to a div: .bright{ position: absolute; z-index: 1; -moz-box-shadow: 0px -3px 55px 20px #...

What is difference between MVC, MVP & MVVM design pattern in terms of coding c#

If we search Google using the phrase "differences between MVC, MVP & MVVM design pattern" then we may get a few URL's which discuss the difference between MVC MVP & MVVM design pattern theoretically like: MVP Use in situations where...

Pass arguments into C program from command line

So I'm in Linux and I want to have a program accept arguments when you execute it from the command line. For example, ./myprogram 42 -b -s So then the program would store that number 42 as an int and execute certain parts of code depending on wha...

SQL Query - Concatenating Results into One String

I have a sql function that includes this code: DECLARE @CodeNameString varchar(100) SELECT CodeName FROM AccountCodes ORDER BY Sort I need to concatenate all results from the select query into CodeNameString. Obviously a FOREACH loop in C# code ...

Setting DEBUG = False causes 500 Error

Once I change the DEBUG = False, my site will generate 500 (using wsgi & manage.py runserver), and there is no error info in Apache error log and it will run normally when I change debug to True . I'm using Django 1.5 & Python 2.7.3 here is ...

Div with horizontal scrolling only

I have a fixed width DIV containing a table with many columns, and need to allow the user to scroll the table horizontally within the DIV. This needs to work on IE6 and IE7 only (internal client application). The following works in IE7: overflow-x...

Saving ssh key fails

i just started a Git tutorial and I get to a deadend: I try to generate a rsa key part and it fails. I did this, in git bash: ssh-keygen -t rsa -C "[email protected]" And i got this: Generating public/private rsa key pair. Enter file in which t...

How to remove all the null elements inside a generic list in one go?

Is there a default method defined in .Net for C# to remove all the elements within a list which are null? List<EmailParameterClass> parameterList = new List<EmailParameterClass>{param1, param2, param3...}; Let's say some of the paramet...

How to get Django and ReactJS to work together?

New to Django and even newer to ReactJS. I have been looking into AngularJS and ReactJS, but decided on ReactJS. It seemed like it was edging out AngularJS as far as popularity despite AngularJS having more of a market share, and ReactJS is said to b...

bundle install returns "Could not locate Gemfile"

I'm new to Rails and am currently working through a guide. The guide states: Use a text editor to update the Gemfile needed by Bundler with the contents of Listing 2.1. source 'https://rubygems.org' gem 'rails', '3.2.3' group :development d...

IOError: [Errno 32] Broken pipe: Python

I have a very simple Python 3 script: f1 = open('a.txt', 'r') print(f1.readlines()) f2 = open('b.txt', 'r') print(f2.readlines()) f3 = open('c.txt', 'r') print(f3.readlines()) f4 = open('d.txt', 'r') print(f4.readlines()) f1.close() f2.close() f3.cl...

How can I quickly and easily convert spreadsheet data to JSON?

I want to convert spreadsheet data (such as from Excel/*.xls files or Open Office, etc.) to JSON files. What is the easiest way to accomplish this?...

How to disable javax.swing.JButton in java?

I have created a swings application and there is a "Start" button on the GUI. I want that whenever I clicked on that "Start" button, the start button should be disabled and the "Stop" button be enabled. For that I have written the following code in ...

Facebook Graph API : get larger pictures in one request

I'm currently using the Graph API Explorer to make some tests. That's a good tool. I want to get the user's friend list, with friends' names, ids and pictures. So I type : https://graph.facebook.com/me/friends?fields=id,picture,name But picture i...

How to use SearchView in Toolbar Android

The code on which I am working, is using a Toolbar and inflating a menu. Here is the code private Toolbar mToolbar; mToolbar.inflateMenu(R.menu.chat_screen_menu); setupMenu (); private void setupMenu () { mMenu = mToolbar.getMenu(); if (mM...

What's the easiest way to install a missing Perl module?

I get this error: Can't locate Foo.pm in @INC Is there an easier way to install it than downloading, untarring, making, etc?...

SQL Error: ORA-00913: too many values

Two tables are identical in terms of table name, column names, datatype and size. These tables are located in separate databases, but I am use to current Log in in hr user. insert into abc.employees select * from employees where employee_id=100; ...

How can you find the height of text on an HTML canvas?

The spec has a context.measureText(text) function that will tell you how much width it would require to print that text, but I can't find a way to find out how tall it is. I know it's based on the font, but I don't know to convert a font string to a ...

Load HTML File Contents to Div [without the use of iframes]

I'm quite sure this a common question, but I'm pretty new to JS and am having some trouble with this. I would like to load x.html into a div with id "y" without using iframes. I've tried a few things, searched around, but I can't find a decent solut...

How can one change the timestamp of an old commit in Git?

The answers to How to modify existing, unpushed commits? describe a way to amend previous commit messages that haven't yet been pushed upstream. The new messages inherit the timestamps of the original commits. This seems logical, but is there a way...

Compare dates with javascript

I have two dates in javascript: var first = '2012-11-21'; var second = '2012-11-03'; i would like make: if(first > second){ //... } how is the best way for this, without external library?...

Regular expression to extract numbers from a string

Can somebody help me construct this regular expression please... Given the following strings... "April ( 123 widgets less 456 sprockets )" "May (789 widgets less 012 sprockets)" I need a regular expression that will extract the two numbers from ...

How do you round to 1 decimal place in Javascript?

Can you round a number in javascript to 1 character after the decimal point (properly rounded)? I tried the *10, round, /10 but it leaves two decimals at the end of the int....

What is stdClass in PHP?

Please define what stdClass is....

MVC web api: No 'Access-Control-Allow-Origin' header is present on the requested resource

I tried everything that is written in this article: http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api, but nothing works. I'm trying to get data from webAPI2 (MVC5) to use in another domain using angularJS. my co...

AWS S3 - How to fix 'The request signature we calculated does not match the signature' error?

I have searched on the web for over two days now, and probably have looked through most of the online documented scenarios and workarounds, but nothing worked for me so far. I am on AWS SDK for PHP V2.8.7 running on PHP 5.3. I am trying to connect ...

To the power of in C?

So in python, all I have to do is print(3**4) Which gives me 81 How do I do this in C? I searched a bit and say the exp() function, but have no clue how to use it, thanks in advance...

End-line characters from lines read from text file, using Python

When reading lines from a text file using python, the end-line character often needs to be truncated before processing the text, as in the following example: f = open("myFile.txt", "r") for line in f: line = line[:-1] # do something with lin...

Print string to text file

I'm using Python to open a text document: text_file = open("Output.txt", "w") text_file.write("Purchase Amount: " 'TotalAmount') text_file.close() I want to substitute the value of a string variable TotalAmount into the text document. Can someon...

Add property to an array of objects

I have an array of objects as shown below Object {Results:Array[2]} Results:Array[2] [0-1] 0:Object id=1 name: "Rick" 1:Object id=2 name:'david' I want to add one more property named Active to each elemen...

"installation of package 'FILE_PATH' had non-zero exit status" in R

By installing the package in R using the following command: install.packages('FILE_PATH', repos=NULL, type = "source") I got the following error: Installing package into ‘/home/p/R/x86_64-pc-linux-gnu-library/3.0’ (as ‘lib’ is un...

Can CSS3 transition font size?

How can one make the font size grow bigger on mouse over? Color transitions work fine over time, but the font size switches immediately for some reason. Sample code: body p { font-size: 12px; color: #0F9; transition:font-size 12s...

Problems with local variable scope. How to solve it?

I'm getting the following error when trying to execute statemet.executeUpdate() in my code: Local variable statement defined in an enclosing scope must be final or effectively final. This is my code so far: import java.sql.Connection; import java...

How can I determine whether a specific file is open in Windows?

One of my favourite tools for linux is lsof - a real swiss army knife! Today I found myself wondering which programs on a WinXP system had a specific file open. Is there any equivalent utility to lsof? Additionally, the file in question was over a n...

MVC 4 - Return error message from Controller - Show in View

I am doing a C# project using Razor in VS2010 (MVC 4). I need to return an error message from Controller to View and show it to the user. What I have tried: CONTROLLER: [HttpPost] public ActionResult form_edit(FormModels model) { m...

Declare a const array

Is it possible to write something similar to the following? public const string[] Titles = { "German", "Spanish", "Corrects", "Wrongs" }; ...

Regular Expression to find a string included between two characters while EXCLUDING the delimiters

I need to extract from a string a set of characters which are included between two delimiters, without returning the delimiters themselves. A simple example should be helpful: Target: extract the substring between square brackets, without returning...

iOS 8 removed "minimal-ui" viewport property, are there other "soft fullscreen" solutions?

(This is a multi-part question, I will try my best to summarise the scenario.) We are currently building a responsive web app (news reader) that allow users to swipe between tabbed content, as well as scroll vertically inside each tabbed content. A...

Copying a rsa public key to clipboard

I am trying to copy a public key to the clipboard on macOS, but I keep getting "no such file or directory." The command I am using is pasted below pbcopy < ~/.ssh/id_rsa.pub ...

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

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

Is the 'as' keyword required in Oracle to define an alias?

Is the 'AS' keyword required in Oracle to define an alias name for a column in a SELECT statement? I noticed that SELECT column_name AS "alias" is the same as SELECT column_name "alias" I am wondering what the consequences are of defining a ...

Hash String via SHA-256 in Java

By looking around here as well as the internet in general, I have found Bouncy Castle. I want to use Bouncy Castle (or some other freely available utility) to generate a SHA-256 Hash of a String in Java. Looking at their documentation I can't seem to...

Passing Variable through JavaScript from one html page to another page

I have two pages - "page 1" and "page 2". On page 1 there's an text-box with a value of e.g. 100 and a button at the end. By pressing the button I want javascript to save the value of the textbox in a global (?) variable and jump to page 2. With "wi...

Facebook Like-Button - hide count?

In the setup dialog for the Like-Button, there are only two options for layout: Alternative 1 Alternative 2 Unfortunately, the numbers for the website of my employer is nowhere near 22'000, so the powers that be have decided that we should not sh...

Possible to iterate backwards through a foreach?

I know I could use a for statement and achieve the same effect, but can I loop backwards through a foreach loop in C#?...

Displaying a vector of strings in C++

I'm sorry if this is a repeat question but I already tried to search for an answer and came up empty handed. So basically I just want to add strings (single words) to the back of a vector and then display the stored strings as a single string. I am ...

Understanding passport serialize deserialize

How would you explain the workflow of Passport's serialize and deserialize methods to a layman. Where does user.id go after passport.serializeUser has been called? We are calling passport.deserializeUser right after it where does it fit in the work...

How to hide Bootstrap modal with javascript?

I've read the posts here, the Bootstrap site, and Googled like mad - but can't find what I'm sure is an easy answer... I have a Bootstrap modal that I open from a link_to helper like this: <%= link_to "New Contact", new_contact_path, {remote: tr...

MVC Form not able to post List of objects

so I have an MVC Asp.net app that is having issues. Essentially, I have a View that contains a form, and its contents are bound to a list of objects. Within this loop, it loads PartialView's with the items being looped over. Now everything works up t...

A good Sorted List for Java

I'm looking for a good sorted list for java. Googling around give me some hints about using TreeSet/TreeMap. But these components is lack of one thing: random access to an element in the set. For example, I want to access nth element in the sorted se...

How to do INSERT into a table records extracted from another table

I'm trying to write a query that extracts and transforms data from a table and then insert those data into another table. Yes, this is a data warehousing query and I'm doing it in MS Access. So basically I want some query like this: INSERT INTO Tabl...

How to generate javadoc comments in Android Studio

Can I use shortcut keys in Android studio to generate javadoc comments? If not, what is the easiest way to generate javadoc comments?...

JQuery: How to get selected radio button value?

How do I default the value of a non-selected radio button to 0? I have the following HTML: <input type="radio" name="myradiobutton" value="1" />1 <input type="radio" name="myradiobutton" value="2" />2 <input type="radio" name="myradi...

mean() warning: argument is not numeric or logical: returning NA

I have a data frame with two columns. When I try to calculate mean, I get this message: [1] NA Warning message: In mean.default(results) : argument is not numeric or logical: returning NA` where 'results' is my data set. Any advice on getting aro...

Responsive table handling in Twitter Bootstrap

When a table's width exceed the span's width, like this page: http://jsfiddle.net/rcHdC/ You will see the table's content is outside of the span. What would be the best method to cater this case? ...

Bloomberg Open API

Bloomberg Open API announced recently - is it just the Bloomberg SDK which had been (limitedly) exposed to public for quite a while? My understanding is that Bloomberg SDK is possible to use only on the machine with a Bloomberg Terminal installed, b...

When should you use a class vs a struct in C++?

In what scenarios is it better to use a struct vs a class in C++?...

ImportError: cannot import name

I have two files app.py and mod_login.py app.py from flask import Flask from mod_login import mod_login app = Flask(__name__) app.config.update( USERNAME='admin', PASSWORD='default' ) mod_login.py # coding: utf8 from flask import Bluep...

What is the difference between a function expression vs declaration in JavaScript?

What is the difference between the following lines of code? //Function declaration function foo() { return 5; } //Anonymous function expression var foo = function() { return 5; } //Named function expression var foo = function foo() { return 5; } ...

"X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE"

<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE" /> Actually what is the meaning of this statement ? Some of the examples use , to separate versions of IE, while some use ;; which is correct? The order IE=9; IE=8; IE=7;...

Hive load CSV with commas in quoted fields

I am trying to load a CSV file into a Hive table like so: CREATE TABLE mytable ( num1 INT, text1 STRING, num2 INT, text2 STRING ) ROW FORMAT DELIMITED FIELDS TERMINATED BY ","; LOAD DATA LOCAL INPATH '/data.csv' OVERWRITE INTO TABLE mytable; ...

How to display the current time and date in C#

How do you display the current date and time in a label in c#...

Eclipse memory settings when getting "Java Heap Space" and "Out of Memory"

When trying to launch and run a flex/java project in eclipse I kept getting a "Out of Memory Exception" and "Java Heap Space" using Eclipse, Tomcat and a JRE. While researching trying to adjust the memory settings I found three places to adjust thes...

Can I call an overloaded constructor from another constructor of the same class in C#?

Can I call an overloaded constructor from another constructor of the same class in C#?...

printf %f with only 2 numbers after the decimal point?

In my printf, I need to use %f but I'm not sure how to truncate to 2 decimal places: Example: getting 3.14159 to print as: 3.14...

What is the difference between mocking and spying when using Mockito?

What would be a use case for a use of a Mockito spy? It seems to me that every spy use case can be handled with a mock, using callRealMethod. One difference I can see is if you want most method calls to be real, it saves some lines of code to use ...

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

How do I select an entire row which has the largest ID in the table?

How would I do something like this? SQL SELECT row FROM table WHERE id=max(id) ...

Modify table: How to change 'Allow Nulls' attribute from not null to allow null

How to change one attribute in a table using T-SQL to allow nulls (not null --> null)? Alter table maybe?...

Convert array values from string to int?

The following code: $string = "1,2,3" $ids = explode(',', $string); var_dump($ids); Returns the array: array(3) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(1) "3" } I need for ...

Explaining Apache ZooKeeper

I am trying to understand ZooKeeper, how it works and what it does. Is there any application which is comparable to ZooKeeper? If you know, then how would you describe ZooKeeper to a layman? I have tried apache wiki, zookeeper sourceforge...but I ...

How to list the files inside a JAR file?

I have this code which reads all the files from a directory. File textFolder = new File("text_directory"); File [] texFiles = textFolder.listFiles( new FileFilter() { public boolean accept( File file ) { return fil...

commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated

Sometimes, when using <h:commandLink>, <h:commandButton> or <f:ajax>, the action, actionListener or listener method associated with the tag are simply not being invoked. Or, the bean properties are not updated with submitted UIInput...

How do I import global modules in Node? I get "Error: Cannot find module <module>"?

I am trying to setup Node on Mac OSX Lion. It all seems to work ok, but I can't seem to import anything modules from my global modules folder. I get the error, Error: Cannot find module <module> If I run this: node -e require.paths, the resp...

Docker Repository Does Not Have a Release File on Running apt-get update on Ubuntu

I am using Ubuntu 16.10 and recently installed Docker (v1.12.4) using the Xenial build by following the instructions found here. I haven't encountered any problems creating containers, ensuring they restart automatically, etc. However, now every tim...

How to pass password automatically for rsync SSH command?

I need to do rsync by ssh and want to do it automatically without the need of passing password for ssh manually....

How to show the Project Explorer window in Eclipse

Suddenly my project explorer window has disappeared from Eclipse. I try selecting Windows > Show View > Project Explorer, but nothing happens. What can I do?...

req.body empty on posts

All of a sudden this has been happening to all my projects. Whenever I make a post in nodejs using express and body-parser req.body is an empty object. var express = require('express') var bodyParser = require('body-parser') var app = express()...

Change cursor to hand when mouse goes over a row in table

How do I change the cursor pointer to hand when my mouse goes over a <tr> in a <table> <table class="sortable" border-style:> <tr> <th class="tname">Name</th><th class="tage">Age</th> </tr&g...

java.sql.SQLException: Missing IN or OUT parameter at index:: 1

I made some Java 1.6-Oracle11g-JDBC (using OJDBC 6) code (below). I am getting an exception - java.sql.SQLException: Missing IN or OUT parameter at index:: 1 Why is this happening and how do I fix it ? My output is- create CREATE TABLE employee(emp...

Exit a Script On Error

I'm building a Shell Script that has a if function like this one: if jarsigner -verbose -keystore $keyst -keystore $pass $jar_file $kalias then echo $jar_file signed sucessfully else echo ERROR: Failed to sign $jar_file. Please recheck the v...

Simple PHP calculator

I'm creating a basic PHP calculator that lets you enter two values and chose your operator then displays the answer. Everything is working fine except it's not outputting the answer to the browser. Here are the codes for my html and PHP files: ...

Android : Fill Spinner From Java Code Programmatically

How do you fill a spinner from java code programmatically? I have a spinner in the layout like this: <Spinner android:id="@+id/consultation_deseases" android:layout_width="@dimen/bigSpinnerWidth" android:layout_height="@dimen/big...

How can getContentResolver() be called in Android?

I want to know the context in which getContentResolver() is called? I have a scenario like this: I have an activity A that calls a method myFunc() of class B which is not an activity. So, in class B I have to use getContentResolver(). I directly cal...

How to create a global variable?

I have a global variable that needs to be shared among my ViewControllers. In Objective-C, I can define a static variable, but I can't find a way to define a global variable in Swift. Do you know of a way to do it?...

How do I serialize an object and save it to a file in Android?

Say I have some simple class and once it's instantiated as an object I want to be able to serialize its contents to a file, and retrieve it by loading that file at some later time... I'm not sure where to start here, what do I need to do to serialize...

java.net.SocketTimeoutException: Read timed out under Tomcat

I have a Tomcat based web application. I am intermittently getting the following exception, Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read...

IntelliJ IDEA JDK configuration on Mac OS

I am using IntelliJ IDEA 10. Every time when I create a new project, it is asking me to choose JDK for this project. Anyone know how I can configure it and make it easy to use?...

Microsoft .NET 3.5 Full download

Although not a question directly associated with programming. One does sometimes need certain frameworks in your projects. I'm looking into downloading the .NET 3.5 framework here but you end up downloading some 2MB installer that once you run it do...

What Java FTP client library should I use?

Since I received no positives answers to my last question. I will try to write a Java FTP upload applet myself. My question is: "Can you recommend a Java FTP client library for me to use?" I want it to be: stable able to handle passive and active...

How to find tags with only certain attributes - BeautifulSoup

How would I, using BeautifulSoup, search for tags containing ONLY the attributes I search for? For example, I want to find all <td valign="top"> tags. The following code: raw_card_data = soup.fetch('td', {'valign':re.compile('top')}) gets ...

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 go to each directory and execute a command?

How do I write a bash script that goes through each directory inside a parent_directory and executes a command in each directory. The directory structure is as follows: parent_directory (name could be anything - doesnt follow a pattern) 001 (direct...

MySQL - SELECT * INTO OUTFILE LOCAL ?

MySQL is awesome! I am currently involved in a major server migration and previously, our small database used to be hosted on the same server as the client. So we used to do this : SELECT * INTO OUTFILE .... LOAD DATA INFILE .... Now, we moved the d...

Using 24 hour time in bootstrap timepicker

Hi im using http://eonasdan.github.io/bootstrap-datetimepicker/ on bootstrap, specifically example number 4. I added this property to take away the PM thing and be able to use 24 system on the widget itself: format: 'hh:mm', But lets say I pic...

Setting java locale settings

When I use the default java locale on my linux machine it comes out with the US locale settings, where do I change this so that it comes out with the correct locale?...

Generating UML from C++ code?

Is there a tool that can parse C++ files within a project and generate UML from it?...

How do I remove an item from a stl vector with a certain value?

I was looking at the API documentation for stl vector, and noticed there was no method on the vector class that allowed the removal of an element with a certain value. This seems like a common operation, and it seems odd that there's no built in way ...

jquery live hover

I'm using the following jquery code to show a contextual delete button only for table rows we are hovering with our mouse. This works but not for rows that have been added with js/ajax on the fly... Is there a way to make this work with live events?...

No increment operator (++) in Ruby?

Possible Duplicate: Why doesn't Ruby support i++ or i— for fixnum? Why is there no increment operator in Ruby? e.g. i++ ++i Is the ++ operator used for something else? Is there a real reason for this?...

Read lines from a text file but skip the first two lines

I've got this macro code in Microsoft Office Word 2003 which reads the lines of a text file. The lines each represent a string value that I need to use later in the code. However, the first two lines of the text file contains some stuff that I don't...

Declare and initialize a Dictionary in Typescript

Given the following code interface IPerson { firstName: string; lastName: string; } var persons: { [id: string]: IPerson; } = { "p1": { firstName: "F1", lastName: "L1" }, "p2": { firstName: "F2" } }; Why isn't the initialization rejec...

How to use wait and notify in Java without IllegalMonitorStateException?

I have 2 matrices and I need to multiply them and then print the results of each cell. As soon as one cell is ready I need to print it, but for example I need to print the [0][0] cell before cell [2][0] even if the result of [2][0] is ready first. So...

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

"make clean" results in "No rule to make target `clean'"

I am running Ubuntu 10.04. Whenever I run make clean, I get this: make: *** No rule to make target `clean'. Stop. Here is my makefile: CC = gcc CFLAGS = -g -pedantic -O0 -std=gnu99 -m32 -Wall PROGRAMS = digitreversal all : $(PROGRAMS) digitr...

CSS text-decoration underline color

Possible Duplicate: Changing Underline color It's possible to change only line color which is under text? I would like to see something like red letters with a blue line below it, but I can't find out how to get this done....

C# send a simple SSH command

I'm a young a student and received my homework for this week. It's pretty difficult for me because I have to create a program, that is able to connect to an SSH server and send the command "etc/init.d/networking restart". I should program this appli...

How can I get a process handle by its name in C++?

I'm trying to get the process handle of, say example.exe, so I can call TerminateProcess on it. How can I do this? Notice, it doesn't have a window so FindWindow won't work....

typeof operator in C

Is typeof in C, really an operator? I'm thinking because there is no polymorphism in C, that there is nothing to do at run-time. That is, the answer to typeof is known at compile-time. (I can't think of a use of typeof that would not be known at co...

How to completely remove node.js from Windows

I uninstalled my previous version of node.js (0.8.11) and downloaded the latest, 0.10.24 from the node.js website and installed it. However, after running node --version, it still indicates that I'm running v0.8.11. Obviously, some stuff was left beh...

In Django, how do I check if a user is in a certain group?

I created a custom group in Django's admin site. In my code, I want to check if a user is in this group. How do I do that?...

Include PHP file into HTML file

I'm working on a project that may have to change the same content on all html pages. So I figured I would create a php file and only have to change that so it changes on all pages over the web. The files are saved as: index.html number.php EXAMPL...

How to Read and Write from the Serial Port

I just start to learn how to send and receive data from my hardware through the C# GUI. Can anyone please write a detail how to read data from the serial port?...

Change div width live with jQuery

Is it possible to change a div's width live with jQuery? And if it is, how? What I want is to change its width depending on the browser's window width in real time, so if/when the user changes the browser window, the div's dimensions are changed as ...

Android center view in FrameLayout doesn't work

I have a FrameLayout in which I have 2 controls: - a custom view which draws a image and some text on it - a textview with a text I want to center both in the FrameLayout but I can't manage to do it. The Texview is centered just fine, my cusom view...

Read Excel File in Python

I've an Excel File Arm_id DSPName DSPCode HubCode PinCode PPTL 1 JaVAS 01 AGR 282001 1,2 2 JaVAS 01 AGR 282002 3,4 3...

How do I resolve this "ORA-01109: database not open" error?

I'm trying to create my own database using SQLPlus. So first I log into it as admin: sqlplus sys/sys_password as sysdba And then I try to create a new user, called sqlzoo : CREATE USER sqlzoo IDENTIFIED BY sqlzoo DEFAULT TABLESPACE tbs_perm_01sq...

Responsive web design is working on desktop but not on mobile device

I have a website which must be responsive for mobile phones. I've created it using my desktop. When I adjust browser windows it's working perfectly for mobile phone but when I check it on my real mobile phone: Samsung Galaxy S2 it's not responsive to...

How to fix "unable to open stdio.h in Turbo C" error?

Whenever I compile my program, I get the error above. ...

Refused to apply inline style because it violates the following Content Security Policy directive

So, in about 1 hour my extensions failed hard. I was doing my extension and it was doing what I pretended. I made some changes, and as I didnt liked I deleted them, and now my extension is throwing error: Refused to apply inline style because it...

how to open a url in python

import urllib fun open(): return urllib.urlopen('http://example.com') But when example.com opens it does not render css or js. How can I open the webpage in a web browser? @error(404) def error404(error): return webbrowser.open('http://ex...

How to refresh a Page using react-route Link

I am trying to refresh a page using react-route Link. But the way I have implemented it goes to the URL one step back.(as an example if the URL was ../client/home/register and when I press the reload is goes to ../client/home) below is my code con...

JavaScript string and number conversion

How can I do the following in JavaScript? Concatenate "1", "2", "3" into "123" Convert "123" into 123 Add 123 + 100 = 223 Covert 223 into "223" ...

How to create module-wide variables in Python?

Is there a way to set up a global variable inside of a module? When I tried to do it the most obvious way as appears below, the Python interpreter said the variable __DBNAME__ did not exist. ... __DBNAME__ = None def initDB(name): if not __DBNA...

How to get the primary IP address of the local machine on Linux and OS X?

I am looking for a command line solution that would return me the primary (first) IP address of the localhost, other than 127.0.0.1 The solution should work at least for Linux (Debian and RedHat) and OS X 10.7+ I am aware that ifconfig is available...

No String-argument constructor/factory method to deserialize from String value ('')

I'm running into a json parsing issue when using the ObjectMapper class from the com.fasterxml.jackson.databind package, and the error that I'm getting is: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.grayba...

check the null terminating character in char*

I was just trying to see how to check for the null terminating character in the char * array but I failed. I can find the length using the for loop procedure where you keep on checking each element, but I wanted to just use the while loop and find th...

Counting in a FOR loop using Windows Batch script

Can anyone explain this? I am able to count in a loop using the Windows command prompt, using this method: SET /A XCOUNT=0 :loop SET /A XCOUNT+=1 echo %XCOUNT% IF "%XCOUNT%" == "4" ( GOTO end ) ELSE ( GOTO loop ) :end But this method does not...

How to access JSON Object name/value?

function (data) { //add values based on activity type //data = JSON.parse(data); //alert(abc.Phone1); alert(data.myName) alert(data.toString()); if (activityType == "Phone") { } return; }, As you can see this call...

Python integer division yields float

Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 2/2 1.0 Is this intended? I strongly remember earlier versions returning int/int=...

Return a 2d array from a function

Hi I am a newbie to C++ I am trying to return a 2d array from a function. It is something like this int **MakeGridOfCounts(int Grid[][6]) { int cGrid[6][6] = {{0, }, {0, }, {0, }, {0, }, {0, }, {0, }}; return cGrid; } ...

Rename a dictionary key

Is there a way to rename a dictionary key, without reassigning its value to a new name and removing the old name key; and without iterating through dict key/value? In case of OrderedDict, do the same, while keeping that key's position....

How to search for a string in cell array in MATLAB?

Let's say I have the cell array strs = {'HA' 'KU' 'LA' 'MA' 'TATA'} What should I do if I want to find the index of 'KU'?...

How to make Java work with SQL Server?

I know this is a basic question, but I can't seem to find an answer and I apologize, if this question is way too stupid, but here we go: I am supposed to work with SQL Server (no problem so far) and with Java (love java, so no problem here either), ...

How to add a column in TSQL after a specific column?

I have a table: MyTable ID FieldA FieldB I want to alter the table and add a column so it looks like: MyTable ID NewField FieldA FieldB In MySQL I would so a: ALTER TABLE MyTable ADD COLUMN NewField int NULL AFTER I...

How to vertically center a "div" element for all browsers using CSS?

I want to center a div vertically with CSS. I don't want tables or JavaScript, but only pure CSS. I found some solutions, but all of them are missing Internet Explorer 6 support. <body> <div>Div to be aligned vertically</div> &...

Ripple effect on Android Lollipop CardView

I'm trying to get a CardView to display the ripple effect when touched by setting the android:backgound attribute in the activity XML file as described here on the Android Developers page, but it isn't working. No animation at all, but the method in ...

Count number of tables in Oracle

Like MySQL has "SHOW TABLES" , how do you count tables in Oracle DB. Little bit of research gave me this query: select owner, count(*) from dba_tables So like MySQL has a standard command, does Oracle have one?...

How long is the SHA256 hash?

I'm going to run SHA256 on a password + salt, but I don't know how long to make my VARCHAR when setting up the MySQL database. What is a good length?...

How to use parameters with HttpPost

I am using a RESTfull webservice with this methode: @POST @Consumes({"application/json"}) @Path("create/") public void create(String str1, String str2){ System.out.println("value 1 = " + str1); System.out.println("value 2 = " + str2); } In my Andr...

How can I read a text file from the SD card in Android?

I am new to Android development. I need to read a text file from the SD card and display that text file. Is there any way to view a text file directly in Android or else how can I read and display the contents of a text file?...

Does --disable-web-security Work In Chrome Anymore?

I'm trying to do a simple test without changing any server-side code involving a cross-domain AJAX call, and I was wondering if it's possible to use --disable-web-security anymore. It seems to not work on Chrome 28. I haven't used it since Chrome ve...

How to send email to multiple recipients using python smtplib?

After much searching I couldn't find out how to use smtplib.sendmail to send to multiple recipients. The problem was every time the mail would be sent the mail headers would appear to contain multiple addresses, but in fact only the first recipient ...

Making HTTP Requests using Chrome Developer tools

Is there a way to make an HTTP request using the Chrome Developer tools without using a plugin like POSTER?...

How to save an activity state using save instance state?

I've been working on the Android SDK platform, and it is a little unclear how to save an application's state. So given this minor re-tooling of the 'Hello, Android' example: package com.android.hello; import android.app.Activity; import android.os....

How to disable Excel's automatic cell reference change after copy/paste?

I've got a massive Excel 2003 spreadsheet I'm working on. There are a lot of very large formulas with a lot of cell references. Here's a simple example. ='Sheet'!AC69+'Sheet'!AC52+'Sheet'!AC53)*$D$3+'Sheet'!AC49 Most of them are more complicated t...

Make button width fit to the text

While I was fiddling with this 'Fancy 3D Button' example, I found that the width seemed to be hard-coded to fit the text's width. Here is the HTML / CSS: _x000D_ _x000D_ body {_x000D_ background-image: url(http://subtlepatterns.com/patterns/rice...

Running Python code in Vim

I am writing Python code using Vim, and every time I want to run my code, I type this inside Vim: :w !python This gets frustrating, so I was looking for a quicker method to run Python code inside Vim. Executing Python scripts from a terminal maybe...

How to see what privileges are granted to schema of another user

Consider the case : In a database , I have two users A and B and their corresponding schema. I want to know , How can I get the information : what permissions are there for USER A in Schema B . Consider the case : We have two users and their associ...

How to find a text inside SQL Server procedures / triggers?

I have a linkedserver that will change. Some procedures call the linked server like this: [10.10.100.50].dbo.SPROCEDURE_EXAMPLE. We have triggers also doing this kind of work. We need to find all places that uses [10.10.100.50] to change it. In SQL ...

How to download source in ZIP format from GitHub?

I see something strange like: http://github.com/zoul/Finch.git Now I'm not that CVS, SVN, etc. dude. When I open that in the browser it tells me that I did something wrong. So I bet I need some hacker-style tool? Some client? (I mean... why not j...

How to put a delay on AngularJS instant search?

I have a performance issue that I can't seem to address. I have an instant search but it's somewhat laggy, since it starts searching on each keyup(). JS: var App = angular.module('App', []); App.controller('DisplayController', function($scope, $ht...

How to convert date into this 'yyyy-MM-dd' format in angular 2

I want to convert current data into 'yyyy-MM-dd' format in .ts file. i template it can easily be done by using data pipe. how to do that in typescript. In template: {{date | date:'yyyy-MM-dd'}} How to convert in this format 'yyyy-MM-dd' in types...

How do I use Access-Control-Allow-Origin? Does it just go in between the html head tags?

I've been reading about Access-Control-Allow-Origin because it seems effective at allowing cross domain requests since I have access to the external site. My question ism how do I use Access-Control-Allow-Origin to allow cross domain requests. I tr...

How to create an installer for a .net Windows Service using Visual Studio

How do I create an installer for a Windows Service that I have created using Visual Studio?...

How to Create Multiple Where Clause Query Using Laravel Eloquent?

I'm using the Laravel Eloquent query builder and I have a query where I want a WHERE clause on multiple conditions. It works, but it's not elegant. Example: $results = User::where('this', '=', 1) ->where('that', '=', 1) ->where('this...

Search all tables, all columns for a specific value SQL Server

I have a specific value, let's say string 'comments'. I need to find all instances of this in the database as I need to do an update on the format to change it to (*) Comments. How can I do this? The database is in SQL Server 2000 format....

Difference between long and int data types

Considering that the following statements return 4, what is the difference between the int and long types in C++? sizeof(int) sizeof(long) ...

target="_blank" vs. target="_new"

What's the difference between <a target="_new"> and <a target="_blank"> and which should I use if I just want to open a link in a new tab/window?...

How do I escape spaces in path for scp copy in Linux?

I'm new to linux, I want to copy a file from remote to local system... now I'm using scp command in linux system.. I have some folders or files names are with spaces, when I try to copy that file, it shows the error message: "No such file or director...

UIView Infinite 360 degree rotation animation?

I'm trying to rotate a UIImageView 360 degrees, and have looked at several tutorials online. I could get none of them working, without the UIView either stopping, or jumping to a new position. How can I achieve this? The latest thing I've tried i...

How to fix: "HAX is not working and emulator runs in emulation mode"

Question is I get "HAX is not working and emulator runs in emulation mode", is this related to Intel x86 Emulator Accelerator (HAXM) installation and running avd with cpu set to CPU Intel Atom (x86)? And even though it feels like AVD runs faster aft...

Change windows hostname from command line

Is it possible to change the hostname in Windows 2003 from the command line with out-of-the-box tools?...

Spring MVC - HttpMediaTypeNotAcceptableException

I keep getting this HttpMediaTypeNotAcceptableException error for AJAX requests when using with Spring MVC and JSON.. full stack trace of the error is.. org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable represe...

htaccess redirect all pages to single page

I want to redirect all of my old domain request to my new domain using htaccess file. Below is what I am using but it does not work if the page is not on the new site. For example google index about.htm on the old site but on the new site it does not...

how to increase java heap memory permanently?

I have one problem with java heap memory. I developed one client server application in java which is run as a windows service it requires more than 512MB of memory. I have 2GB of RAM but when I run my application it throws an exception Out of mem...

What's the difference between SCSS and Sass?

From what I've been reading, Sass is a language that makes CSS more powerful with variable and math support. What's the difference with SCSS? Is it supposed to be the same language? Similar? Different?...

Convert Pandas column containing NaNs to dtype `int`

I read data from a .csv file to a Pandas dataframe as below. For one of the columns, namely id, I want to specify the column type as int. The problem is the id series has missing/empty values. When I try to cast the id column to integer while readin...

SQL Server: Difference between PARTITION BY and GROUP BY

I've been using GROUP BY for all types of aggregate queries over the years. Recently, I've been reverse-engineering some code that uses PARTITION BY to perform aggregations. In reading through all the documentation I can find about PARTITION BY, it...

Excel - extracting data based on another list

I have an Excel worksheet with two columns (name/ID) and then another list that is a subset of the names only from the larger aforementioned list. I want to go through the subset list and then pull the data from the larger list (name/ID) and put it s...

mysql.h file can't be found

i'm trying to install connection between c++ and mysql in ubuntu 12.04. i've installed mysql-client, mysql-server, libmysqlclient15-dev, libmysql++-dev. but when i try to compile the code i got the error: mysql.h there is no such file. i looked in th...

Error:Execution failed for task ':ProjectName:mergeDebugResources'. > Crunching Cruncher *some file* failed, see logs

I have this error when trying to make a module of a project apply plugin: 'com.android.library' android { compileSdkVersion 17 buildToolsVersion "19.1.0" defaultConfig { minSdkVersion 8 targetSdkVersion 8 } bui...

Change all files and folders permissions of a directory to 644/755

How would I change all files to 644 and all folders to 755 using chmod from the linux command prompt? (Terminal)...

VERR_VMX_MSR_VMXON_DISABLED when starting an image from Oracle virtual box

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

Printing a java map Map<String, Object> - How?

How to I print information from a map that has the object as the value? I have created the following map: Map<String, Object> objectSet = new HashMap<>(); The object has its own class with its own instance variables I have already po...

SQL Order By Count

If I have a table and data like this: ID | Name | Group 1 Apple A 2 Boy A 3 Cat B 4 Dog C 5 Elep C 6 Fish C and I wish to order it according to the total of Group from smallest to l...

Vertical Align Center in Bootstrap 4

I am trying to center my Container in the middle of the page using Bootstrap 4. I have been unsuccessful thus far. Any help would be appreciated. I have built it at Codepen.io so you guys can play with it and let me know what works as I am about out...

How do I make a placeholder for a 'select' box?

I'm using placeholders for text inputs which is working out just fine. But I'd like to use a placeholder for my selectboxes as well. Of course I can just use this code: <select> <option value="">Select your option</option> ...

Format of the initialization string does not conform to specification starting at index 0

I have an ASP.NET application which runs fine on my local development machine. When I run this application online, it shows the following error: Format of the initialization string does not conform to specification starting at index 0 Why is this a...

JTable - Selected Row click event

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

How can I check if string contains characters & whitespace, not just whitespace?

What is the best way to check if a string contains only whitespace? The string is allowed to contain characters combined with whitespace, but not just whitespace....

VT-x is disabled in the BIOS for both all CPU modes (VERR_VMX_MSR_ALL_VMX_DISABLED)

Downloaded Xamarin Android Player and with >>next>> progress installed Virtual Box. When I tried to start an emulator I got Failed to initialized device (name Of the emulator) VboxManager Commendt Failed and the detail of the error in Oracle Vm ...

Creating Scheduled Tasks

I am working on a C# WPF project. I need to allow the user to create and add a scheduled task to the Windows Task Scheduler. How could I go about doing this and what using directives and references do I need as I am not finding much when searching ...

In which conda environment is Jupyter executing?

I have jupyter/anaconda/python3.5. How can I know which conda environment is my jupyter notebook running on? How can I launch jupyter from a new conda environment? ...

Can we install Android OS on any Windows Phone and vice versa, and same with iPhone and vice versa?

I have 3 smartphones with me , one running Windows Mobile OS , another one running Android OS , and 3rd one running iOS. I am wondering if i can load/install Android OS on any Windows Phone and vice versa, and same with iPhone and vice versa ? To cl...

Remove an item from a dictionary when its key is unknown

What is the best way to remove an item from a dictionary by value, i.e. when the item's key is unknown? Here's a simple approach: for key, item in some_dict.items(): if item is item_to_remove: del some_dict[key] Are there better ways?...

Checking for the correct number of arguments

How do i check for the correct number of arguments (one argument). If somebody tries to invoke the script without passing in the correct number of arguments, and checking to make sure the command line argument actually exists and is a directory....

Exchange Powershell - How to invoke Exchange 2010 module from inside script?

I'm writing a script that does a number of things with AD and Exchange and just got to the part of the GUI where I need to start working with Exchange but don't see where I can manually specify to include the Exchange module. The normal process I'm ...

is the + operator less performant than StringBuffer.append()

On my team, we usually do string concatentation like this: var url = // some dynamically generated URL var sb = new StringBuffer(); sb.append("<a href='").append(url).append("'>click here</a>"); Obviously the following is much more rea...

Python strftime - date without leading 0?

When using Python strftime, is there a way to remove the first 0 of the date if it's before the 10th, ie. so 01 is 1? Can't find a %thingy for that? Thanks!...

How do I install g++ on MacOS X?

I want to compile C++ code on MacOS X, using the g++ compiler. How do I install it?...

How can I do a line break (line continuation) in Python?

I have a long line of code that I want to break up among multiple lines. What do I use and what is the syntax? For example, adding a bunch of strings, e = 'a' + 'b' + 'c' + 'd' and have it in two lines like this: e = 'a' + 'b' + 'c' + 'd' ...

How to run a task when variable is undefined in ansible?

I am looking for a way to perform a task when ansible variable is not registers /undefined e.g -- name: some task command: sed -n '5p' "{{app.dirs.includes}}/BUILD.info" | awk '{print $2}' when: (! deployed_revision) AND ( !deployed_revisio...

How to create a numpy array of all True or all False?

In Python, how do I create a numpy array of arbitrary shape filled with all True or all False?...

How can I let a user download multiple files when a button is clicked?

So I have a httpd server running which has links to a bunch of files. Lets say the user selects three files from a file list to download and they're located at: mysite.com/file1 mysite.com/file2 mysite.com/file3 When they click the download butt...

Convert Mongoose docs to json

I returned mongoose docs as json in this way: UserModel.find({}, function (err, users) { return res.end(JSON.stringify(users)); } However, user.__proto__ was also returned. How can I return without it? I tried this but not worked: UserModel.f...

Datetime equal or greater than today in MySQL

What's the best way to do following: SELECT * FROM users WHERE created >= today; Note: created is a datetime field....

XPath - Difference between node() and text()

I'm having trouble understanding the difference between text() and node(). From what I understand, text() would be whatever is in between the tags <item>apple</item> which is apple in this case. Node would be whatever that node actually i...

Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0

I want using external logins so I installed Oauth by package manager: PM> Install-Package Microsoft.AspNet.WebPages.OAuth Then I got this error after installed it then I install razor: PM> Install-Package Microsoft.AspNet.Razor But I sti...

Closing Twitter Bootstrap Modal From Angular Controller

I have a modal window that I use to present a form to users. They enter the information and then press a button the has an ng-click. The server processes the request and sends back a response. When the response is success I want to close the modal...

Load resources from relative path using local html in uiwebview

I have a very simple iOS app with a uiwebview loading a very simple test page (test.html): <html> <body> <img src="img/myimage.png" /> </body> </html> I load this test.html file into my web view: NSURL *url = [[NSBun...

Unzip a file with php

I want to unzip a file and this works fine system('unzip File.zip'); But I need to pass in the file name through the URL and can not get it to work, this is what I have. $master = $_GET["master"]; system('unzip $master.zip'); What am I missin...

Adding Google Translate to a web site

Looking here Google Translate I get the following code. <meta name="google-translate-customization" content="9f841e7780177523-3214ceb76f765f38-gc38c6fe6f9d06436-c"></meta> <div id="google_translate_element&quo...

Access-Control-Allow-Origin Multiple Origin Domains?

Is there a way to allow multiple cross-domains using the Access-Control-Allow-Origin header? I'm aware of the *, but it is too open. I really want to allow just a couple domains. As an example, something like this: Access-Control-Allow-Origin: htt...

how to run or install a *.jar file in windows?

I have downloaded jbpm-installer-3.2.7.jar but I don't know how to install or run the file. If I double click on it, it opens in winrar. I tried installing through command prompt, but I got the following errors: C:\Documents and Settings\ccuser\Des...

Installing SetupTools on 64-bit Windows

I'm running Python 2.7 on Windows 7 64-bit, and when I run the installer for setuptools it tells me that Python 2.7 is not installed. The specific error message is: `Python Version 2.7 required which was not found in the registry` My installed ve...

Differences between Oracle JDK and OpenJDK

NOTE: This question is from 2014. As of Java 11 OpenJDK and Oracle JDK are converging. Are there any crucial differences between Oracle and OpenJDK? For example, are the garbage collection and other JVM parameters the same? Does GC work di...

Why is it string.join(list) instead of list.join(string)?

This has always confused me. It seems like this would be nicer: my_list = ["Hello", "world"] print(my_list.join("-")) # Produce: "Hello-world" Than this: my_list = ["Hello", "world"] print("-".join(my_list)) # Produce: "Hello-world" Is there a ...

How do I make a dictionary with multiple keys to one value?

I have a question about a dictionary I want to make. My goal is to have multiple keys to a single value, like below: dictionary = {('a', 'b'): 1, ('c', 'd'): 2} assert dictionary['a'] == 1 assert dictionary['b'] == 1 Any ideas?...

Cassandra cqlsh - connection refused

I've just started working with Cassandra (datastax), version 2.1.3 and cqlsh version 5.0.1. Cassandra starts up fine and the cluster is operational instantly. Cqlsh is not working (on any of the nodes) and emits the following error: Connection ...

Proxy with urllib2

I open urls with: site = urllib2.urlopen('http://google.com') And what I want to do is connect the same way with a proxy I got somewhere telling me: site = urllib2.urlopen('http://google.com', proxies={'http':'127.0.0.1'}) but that didn't work ei...

You cannot call a method on a null-valued expression

I am simply trying to create a powershell script which calculates the md5 sum of an executable (a file). My .ps1 script: $answer = Read-Host "File name and extension (ie; file.exe)" $someFilePath = "C:\Users\xxx\Downloads\$answer" If (Test-Path $s...

How Many Seconds Between Two Dates?

So I have two dates YYYY-MM-DD and ZZZZ-NN-EE How can I find out how many seconds there are between them?...

In Matplotlib, what does the argument mean in fig.add_subplot(111)?

Sometimes I come across code such as this: import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5] y = [1, 4, 9, 16, 25] fig = plt.figure() fig.add_subplot(111) plt.scatter(x, y) plt.show() Which produces: I've been reading the documentation like c...

"Primary Filegroup is Full" in SQL Server 2008 Standard for no apparent reason

Our database is currently at 64 Gb and one of our apps started to fail with the following error: System.Data.SqlClient.SqlException: Could not allocate space for object 'cnv.LoggedUnpreparedSpos'.'PK_LoggedUnpreparedSpos' in database 'travelgatew...

How to copy a row and insert in same table with a autoincrement field in MySQL?

In MySQL I am trying to copy a row with an autoincrement column ID=1 and insert the data into same table as a new row with column ID=2. How can I do this in a single query?...

TypeError: $(...).modal is not a function with bootstrap Modal

I have a bootstrap 2.32 modal which I am trying to dynamically insert into the HTML of another view. I'm working with Codeigniter 2.1. Following Dynamically inserting a bootstrap modal partial view into a view, I have: <div id="modal_target">&...

Creating an array from a text file in Bash

A script takes a URL, parses it for the required fields, and redirects its output to be saved in a file, file.txt. The output is saved on a new line each time a field has been found. file.txt A Cat A Dog A Mouse etc... I want to take file.txt ...

Android failed to load JS bundle

I'm trying to run AwesomeProject on my Nexus5 (android 5.1.1). I'm able to build the project and install it on the device. But when I run it, I got a red screen saying Unable to download JS bundle. Did you forget to start the development server or c...

How can I change Mac OS's default Java VM returned from /usr/libexec/java_home

(Wasn't sure if this should go on SU... migration is certainly an option, but more programmers read questions here, so here goes). I am running Mac OS X 10.8.4, and I have Apple's JDK 1.6.0_51 installed as well as Oracle's JDK 1.7.0_25. I recently i...

How to send an email using PHP?

I am using PHP on a website and I want to add emailing functionality. I have WAMPSERVER installed. How do I send an email using PHP?...

Prolog "or" operator, query

I'm working on some prolog that I'm new to. I'm looking for an "or" operator registered(X, Y), Y=ct101, Y=ct102, Y=ct103. Here's my query. What I want to write is code that will: "return X, given that Y is equal to value Z OR value Q OR value P"...

How to make several plots on a single page using matplotlib?

I have written code that opens 16 figures at once. Currently they all open as separate graphs. I'd like them to open all on the same page. Not the same graph. I want 16 separate graphs on a single page/window. Also for some reason the format of t...

Cast to generic type in C#

I have a Dictionary to map a certain type to a certain generic object for that type. For example: typeof(LoginMessage) maps to MessageProcessor<LoginMessage> Now the problem is to retrieve this generic object at runtime from the Dictionary. ...

Can HTTP POST be limitless?

I heard that HTTP POST has no specification limit in data size it can be sent by. Is that true or is there just some really high limit?...

Protractor : How to wait for page complete after click a button?

In a test spec, I need to click a button on a web page, and wait for the new page completely loaded. emailEl.sendKeys('jack'); passwordEl.sendKeys('123pwd'); btnLoginEl.click(); // ...Here need to wait for page complete... How? ptor.waitForAngula...

Java generics - ArrayList initialization

It is known that arraylist init. should be like this ArrayList<A> a = new ArrayList<A>(); ArrayList<Integer> a = new ArrayList<Number>(); // compile-time error so, why does java allow these ? 1. ArrayList<? extends...

How to connect to a docker container from outside the host (same network) [Windows]

I've created my first docker container, it's running a server using Go but I can't access it from outside the host computer. I've just started with docker so I'm a little lost here. So I have a very simple Go code that starts a server, I have built ...

Error message: (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)

I am trying to deploy my website on windows server 2003. Am i missing something or what is wrong from the following error message, how can I correct it? Thank I am having the error message: A connection was successfully established with the ser...

Pause Console in C++ program

Which is best way to pause the console in C++ programs? using cin.get() or using system("pause") or using C functions like getch() or getchar()? Is it true that use of system("pause") leads to non portable code and can't work in UNIX? Is cin.get...

Lombok annotations do not compile under Intellij idea

I've installed the plugin for intellij idea(lombok-plugin-0.8.6-13). Added lombok.jar into classpath I can find getters and setters in the window of structure. And Intellij shows no error. Setting - Lombok plugin - Verified Intellij configuration fo...

Default value of 'boolean' and 'Boolean' in Java

What are the default values of boolean (primitive) and Boolean (primitive wrapper) in Java?...

Viewing all `git diffs` with vimdiff

I setup git diff to wrap into vimdiff, using "Git Diff with Vimdiff" as a guide, and it's working as expected unless there are many files with changes. When there are multiple files with changes and I run git diff, it opens the first file and, afte...

How do I run PHP code when a user clicks on a link?

I want to have a page run some PHP code when a user clicks on a link, without redirecting them. Is this possible with <a href=""></a> or with the javascript onclick event?...

Curl : connection refused

I got the following error while running curl: curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused. It seems that it is easy to debug, but, I didnt find how to solve it. The adress 127.0.0.1 is mentioned in the file etc/host...

What is a word boundary in regex, does \b match hyphen '-'?

I'm trying to use regexes to match space-separated numbers. I can't find a precise definition of \b ("word boundary"). I had assumed that -12 would be an "integer word" (matched by \b\-?\d+\b) but it appears that this does not wo...

what is the multicast doing on 224.0.0.251?

On my debian server (squeeze) I get this message every few seconds: Sep 18 21:28:14 myhost kernel: [7903784.720091] AIF:UNPRIV connect attempt: IN=eth0 OUT= MAC= SRC=my_serverip_eth0 DST=224.0.0.251 LEN=72 TOS=0x00 PREC=0x00 TTL=255 ID=0 DF P...

Timeout jQuery effects

I am trying to have an element fade in, then in 5000 ms fade back out again. I know I can do something like: setTimeout(function () { $(".notice").fadeOut(); }, 5000); But that will only control the fade out, would I add the above on the callback?...

Debug vs Release in CMake

In a GCC compiled project, How do I run CMake for each target type (debug/release)? How do I specify debug and release C/C++ flags using CMake? How do I express that the main executable will be compiled with g++ and one nested library with gcc? ...

Differences between Microsoft .NET 4.0 full Framework and Client Profile

The Microsoft .NET Framework 4.0 full installer (32- and 64-bit) is 48.1 MB and the Client Profile installer is 41.0 MB. The extracted installation files are 237 MB and 194 MB respectively, and once installed, they are 537 MB...

Getting a File's MD5 Checksum in Java

I am looking to use Java to get the MD5 checksum of a file. I was really surprised but I haven't been able to find anything that shows how to get the MD5 checksum of a file. How is it done?...

How to get HttpContext.Current in ASP.NET Core?

We are currently rewriting/converting our ASP.NET WebForms application using ASP.NET Core. Trying to avoid re-engineering as much as possible. There is a section where we use HttpContext in a class library to check the current state. How can I acces...

Convert dd-mm-yyyy string to date

i am trying to convert a string in the format dd-mm-yyyy into a date object in JavaScript using the following: var from = $("#datepicker").val(); var to = $("#datepickertwo").val(); var f = new Date(from); var t = new Date(to); ("#datepicker")...

@Directive vs @Component in Angular

What is the difference between @Component and @Directive in Angular? Both of them seem to do the same task and have the same attributes. What are the use cases and when to prefer one over another?...

Android Studio Stuck at Gradle Download on create new project

I have installed the new Android Studio. Everything was working fine but when I try to create a new project it gets stuck at downloading Gradle. Is there any way to install the Gradle required by Android Studio manually? Or any other method to solve...

True/False vs 0/1 in MySQL

Which is faster in a MySQL database? Booleans, or using zero and one to represent boolean values? My frontend just has a yes/no radio button....

How to replace plain URLs with links?

I am using the function below to match URLs inside a given text and replace them for HTML links. The regular expression is working great, but currently I am only replacing the first match. How I can replace all the URL? I guess I should be using the...

How to remove only 0 (Zero) values from column in excel 2010

I want to remove the values from entire column where cells value is 0. The resultant Cells should be blank. How can I write a formula for this? Any suggestions? TELEPHONE NUMBERS ---------- 49 5235102027 <-- Cell has 0 value but shouldn't r...

Converting a pointer into an integer

I am trying to adapt an existing code to a 64 bit machine. The main problem is that in one function, the previous coder uses a void* argument that is converted into suitable type in the function itself. A short example: void function(MESSAGE_ID id, ...

Amazon S3 direct file upload from client browser - private key disclosure

I'm implementing a direct file upload from client machine to Amazon S3 via REST API using only JavaScript, without any server-side code. All works fine but one thing is worrying me... When I send a request to Amazon S3 REST API, I need to sign the r...

Convert nested Python dict to object?

I'm searching for an elegant way to get data using attribute access on a dict with some nested dicts and lists (i.e. javascript-style object syntax). For example: >>> d = {'a': 1, 'b': {'c': 2}, 'd': ["hi", {'foo': "bar"}]} Should be acc...

Getting the folder name from a path

string path = "C:/folder1/folder2/file.txt"; What objects or methods could I use that would give me a result of folder2?...

window.open target _self v window.location.href?

I need to redirect the user using JavaScript. Which is the preferred method? window.open("webpage.htm", "_self"); or window.location.href = "webpage.htm"; ...

How to define custom exception class in Java, the easiest way?

I'm trying to define my own exception class the easiest way, and this is what I'm getting: public class MyException extends Exception {} public class Foo { public bar() throws MyException { throw new MyException("try again please"); } } T...

Getting all documents from one collection in Firestore

Hi I'm starting with javascript and react-native and I'm trying to figure out this problem for hours now. Can someone explain me how to get all the documents from firestore collection ? I have been trying this: async getMarkers() { const events ...

Javascript change date into format of (dd/mm/yyyy)

How can I convert the following date format below (Mon Nov 19 13:29:40 2012) into: dd/mm/yyyy <html> <head> <script type="text/javascript"> function test(){ var d = Date() alert(d) } <...

Splitting String and put it on int array

I have to input a string with numbers ex: 1,2,3,4,5. That's a sample of the input, then I have to put that in an array of INT so I can sort it but is not working the way it should work. package array; import java.util.Scanner; public class Array {...

What is the JUnit XML format specification that Hudson supports?

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

Setting up a cron job in Windows

I have to download a file from an SFTP server everyday. I have the program which retrieves the file from the server but I was thinking of setting up a cron job (or anything similar) to automate that. We are a Windows shop and need to set up the cron ...

Why must wait() always be in synchronized block

We all know that in order to invoke Object.wait(), this call must be placed in synchronized block, otherwise an IllegalMonitorStateException is thrown. But what's the reason for making this restriction? I know that wait() releases the monitor, but wh...

How to check if a std::thread is still running?

How can I check if a std::thread is still running (in a platform independent way)? It lacks a timed_join() method and joinable() is not meant for that. I thought of locking a mutex with a std::lock_guard in the thread and using the try_lock() method...

How to set the range of y-axis for a seaborn boxplot?

From the official seaborn documentation, I learned that you can create a boxplot as below: import seaborn as sns sns.set_style("whitegrid") tips = sns.load_dataset("tips") ax = sns.boxplot(x="day", y="total_bill", data=tips) My question is: how ...

How to create virtual column using MySQL SELECT?

If I do SELECT a AS b and b is not a column in the table, would query create the "virtual" column? in fact, I need to incorporate some virtual column into the query and process some information into the query so I can use it with each item later on....

XSLT string replace

I don't really know XSL but I need to fix this code, I have reduced it to make it simpler. I am getting this error Invalid XSLT/XPath function on this line <xsl:variable name="text" select="replace($text,'a','b')"/> This is the XSL &...

Getting the current Fragment instance in the viewpager

Below is my code which has 3 Fragment classes each embedded with each of the 3 tabs on ViewPager. I have a menu option. As shown in the onOptionsItemSelected(), by selecting an option, I need to update the fragment that is currently visible. To updat...

Correct way to load a Nib for a UIView subclass

I am aware this question has been asked before but the answers are contradicting and I am confused, so please don't flame me. I want to have a reusable UIView subclass throughout my app. I want to describe the interface using a nib file. Now let's ...

Could not create work tree dir 'example.com'.: Permission denied

I have got a virtual private server with nginx Virtual Hosts setup (Server Blocks). I've installed Git and got my ssh keys authenticated with GitHub. I have my website running in ~/var/www/example.com/public_html/ I tried to run: git clone git...

Showing the stack trace from a running Python application

I have this Python application that gets stuck from time to time and I can't find out where. Is there any way to signal Python interpreter to show you the exact code that's running? Some kind of on-the-fly stacktrace? Related questions: Print c...

Angular 2: How to write a for loop, not a foreach loop

Using Angular 2, I want to duplicate a line in a template multiple times. Iterating over an object is easy, *ngFor="let object of objects". However, I want to run a simple for loop, not a foreach loop. Something like (pseudo-code): {for i =...

Singleton: How should it be used

Edit: From another question I provided an answer that has links to a lot of questions/answers about singletons: More info about singletons here: So I have read the thread Singletons: good design or a crutch? And the argument still rages. I see S...

jQuery .ready in a dynamically inserted iframe

We are using jQuery thickbox to dynamically display an iframe when someone clicks on a picture. In this iframe, we are using galleria a javascript library to display multiple pictures. The problem seems to be that $(document).ready in the iframe se...

Create directory if it does not exist

I am writing a PowerShell script to create several directories if they do not exist. The filesystem looks similar to this D:\ D:\TopDirec\SubDirec\Project1\Revision1\Reports\ D:\TopDirec\SubDirec\Project2\Revision1\ D:\TopDirec\SubDirec\Project3\Re...

Get child node index

In straight up javascript (i.e., no extensions such as jQuery, etc.), is there a way to determine a child node's index inside of its parent node without iterating over and comparing all children nodes? E.g., var child = document.getElementById('my_...

How to implement DrawerArrowToggle from Android appcompat v7 21 library

So now that Android 5.0 was released i was wondering how to implement the animated actionbar icons. This library here implements it fine for me but since the appcompat v7 library has it how can it be implemented? The library references it in themes...

How do I measure time elapsed in Java?

I want to have something like this: public class Stream { public startTime; public endTime; public getDuration() { return startTime - endTime; } } Also it is important that for example if the startTime it's 23:00 and e...

Pandas/Python: Set value of one column based on value in another column

I need to set the value of one column based on the value of another in a Pandas dataframe. This is the logic: if df['c1'] == 'Value': df['c2'] = 10 else: df['c2'] = df['c3'] I am unable to get this to do what I want, which is to simply cre...

How to upload & Save Files with Desired name

i am using this code to upload files(images to a folder) <form action='' method='POST' enctype='multipart/form-data'> <input type='file' name='userFile'><br> <input type='submit' name='upload_btn' value='upload'> </form>...

Get and Set Screen Resolution

How can I collect and change screen resolution using Visual C#?...

Extract filename and extension in Bash

I want to get the filename (without extension) and the extension separately. The best solution I found so far is: NAME=`echo "$FILE" | cut -d'.' -f1` EXTENSION=`echo "$FILE" | cut -d'.' -f2` This is wrong because it doesn't work if the file name ...

Print the data in ResultSet along with column names

I am retrieving columns names from a SQL database through Java. I know I can retrieve columns names from ResultSet too. So I have this sql query select column_name from information_schema.columns where table_name='suppliers' The problem is I don...

How to cast the size_t to double or int C++

My question is that I have a size_t data, but now I want to convert it to double or int. If I do something like size_t data = 99999999; int convertdata = data; the compiler will report warning. because it maybe overflow. Do you have some met...

Serializing a list to JSON

I have an object model that looks like this: public MyObjectInJson { public long ObjectID {get;set;} public string ObjectInJson {get;set;} } The property ObjectInJson is an already serialized version an object that contains nested lists. For t...

Measuring Query Performance : "Execution Plan Query Cost" vs "Time Taken"

I'm trying to determine the relative performance of two different queries and have two ways of measuring this available to me: 1. Run both and time each query 2. Run both and get "Query Cost" from the actual execution plan Here is the code I run to ...

Can't import org.apache.http.HttpResponse in Android Studio

I want to use these libraries in Android Studio: import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; I am following a v...

How do I change the root directory of an Apache server?

How can I change the document root of the Apache server? I basically want localhost to come from /users/spencer/projects directory instead of /var/www. I ended up figuring it out. Some suggested I change the httpd.conf file, but I ended up finding a...

OpenCV - Apply mask to a color image

How can I apply mask to a color image in latest python binding (cv2)? In previous python binding the simplest way was to use cv.Copy e.g. cv.Copy(dst, src, mask) But this function is not available in cv2 binding. Is there any workaround without usi...

A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations

What is wrong with this statement? ALTER Function [InvestmentReturn].[getSecurityMinLowForPeriod](@securityid int, @start datetime, @end datetime) returns xml begin declare @results varchar(500) declare @low int declare @adjustedLow int dec...

How to set image in imageview in android?

I want to show an image in imageview so I made a folder - drawable in res and put my image there. Something like apple.png. Then I use this code: ImageView iv= (ImageView)findViewById(R.id.img_selected_image); String path = getApplication().getFiles...

Open links in new window using AngularJS

Is there a way to tell AngularJS that I want links to be opened in new windows when the user clicks on them? With jQuery I would do this: jQuery("a.openInNewWindow").click( function() { window.open(this.href); return false; }) Is there an...

How to set null value to int in c#?

int value=0; if (value == 0) { value = null; } How can I set value to null above? Any help will be appreciated....

The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication

The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state. What is this error all about, and how would I go about solving it?...

CSS media query to target iPad and iPad only?

Hi I am working with multiple tablet devices, iPad, Galaxy Tab, Acer Iconia, LG 3D Pad and so on. iPad - 1024 x 768 LG Pad - 1280 x 768 Galaxy Tab - 1280 x 800 I want to target iPad only using CSS3 media query. Since, device width of LG and iPad ...

If/else else if in Jquery for a condition

I am having a set of text fields where i am doing validation Say I am Having a field called "seats" this can accept value less than "99999".Meaning I should not able to enter the "99999" any thing less than that is ok. For that I wrote below if a...

"Eliminate render-blocking CSS in above-the-fold content"

I've been using Google PageSpeed insights to try and improve my site's performance, and so far it's proven extremely successful. Things like deferring scripts worked beautifully, since I already had an in-house version of jQuery's .ready() to defer s...

How to modify WooCommerce cart, checkout pages (main theme portion)

I have been researching and tweaking away at my custom Wordpress theme and overridden WooCommerce templates with now WooCommerce installed to rectify a bunch of small formatting issues that occur on the WooCommerce pages. I'm down to now the cart and...

How can I resolve the error: "The command [...] exited with code 1"?

I've read around many questions but I've not been able to find the right answer for me. As I try to compile a project in VS2012 I have this result: The command "....\tools\bin\nuget pack Packages\Lib.Html.nuspec - OutputDirectory ....\bin\Zip\Pa...

How to redirect back to form with input - Laravel 5

How do I redirect back to my form page, with the given POST params, if my form action throws an exception?...

Create a txt file using batch file in a specific folder

I am trying to create a batch file which will create a text file in a specific folder. I am able to create a text file on my desktop, but I need to create a file in a specific file path. For example in D:/Testing folder I wants to create a user def...

SET NOCOUNT ON usage

Inspired by this question where there are differing views on SET NOCOUNT... Should we use SET NOCOUNT ON for SQL Server? If not, why not? What it does Edit 6, on 22 Jul 2011 It suppresses the "xx rows affected" message after any DML. This is a...

UITableView with fixed section headers

Greets, I'm reading that the default behaviour of UITableView is to pin section header rows to the top of the table as you scroll through the sections until the next section pushes the previos section row out of view. I have a UITableView inside a U...

Having services in React application

I'm coming from the angular world where I could extract logic to a service/factory and consume them in my controllers. I'm trying to understand how can I achieve the same in a React application. Let's say that I have a component that validates user...

What is the purpose of mvnw and mvnw.cmd files?

When I created a Spring Boot application I could see mvnw and mvnw.cmd files in the root of the project. What is the purpose of these two files?...

How can I switch to another branch in git?

Which one of these lines is correct? git checkout 'another_branch' Or git checkout origin 'another_branch' Or git checkout origin/'another_branch' And what is the difference between them? ...

jQuery - Click event on <tr> elements with in a table and getting <td> element values

I have the following HTML in a JSP file: <div class="custList"> <table class="dataGrid"> <c:forEach var="cust" items="${custList}"> <tr> <td>${cust.number}</td> <td>...

Git Clone - Repository not found

git clone <url> gives the message fatal: repository 'url' not found I tried the options in the link, but it didn't work. ...

java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;

I have a problem with egovframework of Korea when I have deployed file war to Tomcat after I restarted Tomcat, it showed the error like below : 2011-12-23 09:16:01,101 ERROR [org.springframework.web.servlet.DispatcherServlet] Context initialization ...

Get Return Value from Stored procedure in asp.net

i have a stored procedure ALTER PROC TESTLOGIN @UserName varchar(50), @password varchar(50) As Begin declare @return int; set @return = (SELECT COUNT(*) FROM CPUser WHERE UserName = @UserN...

Delete a row in DataGridView Control in VB.NET

I am working on DataGridView control in vb.net. I need help you that i want to delete a row in datagrid and only that row deleted who selected. Mean first i select the row then row deleted. So please provide me code that how i select and delete row f...

Copy Files from Windows to the Ubuntu Subsystem

I have enabled developer mode and installed Bash on Ubuntu on Windows. My home directory can be found under %localappdata%\Lxss\home\<ubuntu.username>\, i have created a sub-directory called Pictures such that the full path should be on windo...

Bootstrap button - remove outline on Chrome OS X

I am looking to achieve this: http://getbootstrap.com/javascript/#popovers-examples - scroll to the "live Demo" and hit the red popover button, in Chrome on OS X.... It's perfect beautiful Now go here (the problem child): http://yoyo.io/javascript/#...

How to show SVG file on React Native?

I want to show svg files (I have bunch of svg images) but the thing I couldn't find the way to show. I tried to use Image and Use components of react-native-svg but they don't work with that. And I tried to do that with native way but it's really har...

Change UITableView height dynamically

I want to change the height of my tableview from another viewcontroller based on the sum of its cells' heights, as they are dynamic. Is it at all possible? Thanks Add-on: What I basically have is a UserProfileViewController that has a containerview...

Change selected value of kendo ui dropdownlist

I have a kendo ui dropdownlist in my view: $("#Instrument").kendoDropDownList({ dataTextField: "symbol", dataValueField: "symbol", dataSource: data, index: 0 }); How can I change the selected value of it using jQuery? I tried: $("...

Where to place the 'assets' folder in Android Studio?

I am confused about the assets folder. It doesn't come auto-created in Android Studio, and almost all the forums in which this is discussed talk about Eclipse. How can the Assets directory be configured in Android Studio?...

Java says FileNotFoundException but file exists

I have an assignment for my CS class where it says to read a file with several test scores and asks me to sum and average them. While summing and averaging is easy, I am having problems with the file reading. The instructor said to use this syntax Sc...

Difference between jQuery’s .hide() and setting CSS to display: none

Which am I better off doing? .hide() is quicker than writing out .css("display", "none"), but what’s the difference and what are both of them actually doing to the HTML element?...

Import MySQL database into a MS SQL Server

I have a .sql file from a MySQL dump containing tables, definitions and data to be inserted in these tables. How can I convert this database represented in the dump file to a MS SQL Server database?...

How to round the double value to 2 decimal points?

Possible Duplicate: round double to two decimal places in java I want to round up the double value upto 2 decimal points. for example: I have double d=2; and the result should be result =2.00...

Why am I seeing an "origin is not allowed by Access-Control-Allow-Origin" error here?

I am seeing the following error: Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin with this code: var http = new getXMLHttpRequestObject(); var url = "http://gdata.youtube.com/action/GetUploadToken"; var sendXML = '<?...

How to check if BigDecimal variable == 0 in java?

I have the following code in Java; BigDecimal price; // assigned elsewhere if (price.compareTo(new BigDecimal("0.00")) == 0) { return true; } What is the best way to write the if condition?...

Upgrading PHP in XAMPP for Windows?

I would like to know how you upgrade PHP in Xampp for Windows? I tried to download the latest PHP version from the main PHP site but when I check (phpinfo) I still get that the previous version is still in use....

How can I check out a GitHub pull request with git?

I'd like to check out a previously created pull request (created via GitHub web interface). I searched and found different places where a refs/pull or refs/pull/pr But when I add fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to the git config f...

Is there any way to show a countdown on the lockscreen of iphone?

The integral countdown has a limit of 24 hours, but I want a countdown which could count for a few years. It could show the time like XXXXDays XXHours XXminutes XXseconds with large characters on the lock screen. If it could also show on the wallpap...

TypeError: $ is not a function when calling jQuery function

I have a simple jQuery script in a WordPress plugin that is using a jQuery wrapper like this: $(document).ready(function(){ // jQuery code is in here }); I am calling this script from within the WordPress Dashboard and am loading it AFTER th...

Javascript Thousand Separator / string format

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

How to move table from one tablespace to another in oracle 11g

I run oracle 11g and need to move table (tbl1) from one tablespace (tblspc1) to another (tblspc2). What is the easiest way to do that? ...

How do I delete an entity from symfony2

My first symfony2 project is a list of guests (invited in an event) stored in a database. I have created the entity class Guest with all variables for them (id, name, address, phone number etc.) created the schema in the mysql db created a route ...

Select all contents of textbox when it receives focus (Vanilla JS or jQuery)

What is a Vanilla JS or jQuery solution that will select all of the contents of a textbox when the textbox receives focus?...

Media Queries: How to target desktop, tablet, and mobile?

I have been doing some research on media queries and I still don't quite understand how to target devices of certain sizes. I want to be able to target desktop, tablet and mobile. I know that there will be some discrepancies but it would be nice to...

here-document gives 'unexpected end of file' error

I need my script to send an email from terminal. Based on what I've seen here and many other places online, I formatted it like this: /var/mail -s "$SUBJECT" "$EMAIL" << EOF Here's a line of my message! And here's another line! Last line of th...

Objects are not valid as a React child. If you meant to render a collection of children, use an array instead

I am setting up a React app with a Rails backend. I am getting the error "Objects are not valid as a React child (found: object with keys {id, name, info, created_at, updated_at}). If you meant to render a collection of children, use an array instead...

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

Placing/Overlapping(z-index) a view above another view in android

I have a linear layout which consists of imageview and textview , one below another in a linear layout. <LinearLayout android:orientation="horizontal" ... > <ImageView android:id="@+id/thumbnail" android:layout_weight="0.8" ...

File Upload using AngularJS

Here is my HTML form: <form name="myForm" ng-submit=""> <input ng-model='file' type="file"/> <input type="submit" value='Submit'/> </form> I want to upload an image from local machine and want to read the content of...

Parse an URL in JavaScript

How do I parse an URL with JavaScript (also with jQuery)? For instance I have this in my string, url = "http://example.com/form_image_edit.php?img_id=33" I want to get the value of img_id I know I can do this easily with PHP with parse_url(), bu...

Load RSA public key from file

I've generated a private key with: openssl genrsa [-out file] –des3 After this I've generated a public key with: openssl rsa –pubout -in private.key [-out file] I want to sign some messages with my private key, and verify some other message...

SQL Query Where Date = Today Minus 7 Days

I have a SQL table of hits to my website called ExternalHits. I track the URL as URLx and the date the page was accessed as Datex. I run this query every week to get the count of total hits from the week before, and every week I have to manually chan...

How to embed fonts in HTML?

I'm trying to figure out a decent solution (especially from the SEO side) for embedding fonts in web pages. So far I have seen the W3C solution, which doesn't even work on Firefox, and this pretty cool solution. The second solution is for titles only...

How to throw a C++ exception

I have a very poor understanding of exception handling(i.e., how to customize throw, try, catch statements for my own purposes). For example, I have defined a function as follows: int compare(int a, int b){...} I'd like the function to throw an exc...

Retrieve WordPress root directory path?

How can I retrieve the path to the root directory in WordPress CMS?...

What is the opposite of :hover (on mouse leave)?

Is there any way to do the opposite of :hover using only CSS? As in: if :hover is on Mouse Enter, is there a CSS equivalent to on Mouse Leave? Example: I have a HTML menu using list items. When I hover one of the items, there is a CSS color animati...

ORA-00932: inconsistent datatypes: expected - got CLOB

Considering that TEST_SCRIPT is a CLOB why when I run this simple query from SQL*PLUS on Oracle, I get the error: ORA-00932: inconsistent datatypes: expected - got CLOB I have been reading a lot of questions about the same error but none of thos...

Read properties file outside JAR file

I have a JAR file where all my code is archived for running. I have to access a properties file which need to be changed/edited before each run. I want to keep the properties file in the same directory where the JAR file is. Is there anyway to tell J...

How do I print a double value without scientific notation using Java?

I want to print a double value in Java without exponential form. double dexp = 12345678; System.out.println("dexp: "+dexp); It shows this E notation: 1.2345678E7. I want it to print it like this: 12345678 What is the best way to prevent this?...

c++ string array initialization

I know I can do this in C++: string s[] = {"hi", "there"}; But is there anyway to delcare an array this way without delcaring string s[]? e.g. void foo(string[] strArray){ // some code } string s[] = {"hi", "there"}; // Works foo(s); // Works...

Call javascript from MVC controller action

Can I call javascript function from MVC controller action (not from view page) and get return value? How? I need to make request to server from code (.cs) using javascript like here (but this is aspx page) function getInitData() { var code; code...

Failed to import new Gradle project: failed to find Build Tools revision *.0.0

When I boot up Android Studio and select "New Project..." and go through creating a new project, I get this popup error: Failed to import new Gradle project: failed to find Build Tools revision 17.0.0 Consult IDE log for more details (Help...

How to check compiler log in sql developer?

I get this error: Errors: check compiler log How can I see compiler log in Oracle SQL Developer?...

How to redirect to previous page in Ruby On Rails?

I have a page that lists all of the projects that has sortable headers and pagination. path: /projects?order=asc&page=3&sort=code I choose to edit one of the projects path: projects/436/edit When I click save on that page, it calls the ...

How do you use Intent.FLAG_ACTIVITY_CLEAR_TOP to clear the Activity Stack?

I've read through several posts about using this, but must be missing something as it's not working for me. My activity A has launchmode="singleTop" in the manifest. It starts activity B, with launchmode="singleInstance". Activity B opens a browser a...

How to loop over files in directory and change path and add suffix to filename

I need to write a script that starts my program with different arguments, but I'm new to Bash. I start my program with: ./MyProgram.exe Data/data1.txt [Logs/data1_Log.txt]. Here is the pseudocode for what I want to do: for each filename in /Data d...

Calculating Time Difference

at the start and end of my program, I have from time import strftime print int(strftime("%Y-%m-%d %H:%M:%S") Y1=int(strftime("%Y")) m1=int(strftime("%m")) d1=int(strftime("%d")) H1=int(strftime("%H")) M1=int(strftime("%M")) S1=int(strftime("%S")...

Difference between matches() and find() in Java Regex

I am trying to understand the difference between matches() and find(). According to the Javadoc, (from what I understand), matches() will search the entire string even if it finds what it is looking for, and find() will stop when it finds what it is...

How to change package name in android studio?

I have made an app and it is my very first app so when I started coding, I left the package name as com.example.stuff and now when I try to upload to the play store it wont let me due to the package name. I have tried refactor-> rename the package na...

How do I remove the file suffix and path portion from a path string in Bash?

Given a string file path such as /foo/fizzbuzz.bar, how would I use bash to extract just the fizzbuzz portion of said string?...

jquery: $(window).scrollTop() but no $(window).scrollBottom()

I want to place an element to the bottom of the page whenever the user scrolls the page. It's like "fixed position" but I can't use "position: fixed" css as many of my clients' browser can't support that. I noticed jquery can get current viewport's ...

Microsoft.Office.Core Reference Missing

Using the example provided in codeproject I am struggling to work out where I can find the reference to the library Microsoft.Office.Core. I am getting the error "The referenced component 'Microsoft.Office.Core' could not be found." I only have of...

How to install SQL Server Management Studio 2008 component only

Below is a list of the SQL components that I installed in the Visual Studio 2010 Professional setup. Sadly, while trying to work I could not find SQL Server Management Studio 2008. Is there a way to download SQL Server Management Studio 2008 separa...

oracle SQL how to remove time from date

I have a column named StartDate containing a date in this format: 03-03-2012 15:22 What I need is to convert it to date. It should be looking like this: DD/MM/YYYY What I have tried without success is: select p1.PA_VALUE as StartDate, p2.PA_VALUE...

Running npm command within Visual Studio Code

Is there anyway of executing the npm command within Visual Studio Code (using f1 into >) on Windows(10) to install packages to my folder I'm working in? I have npm installed and I keep having to install npm packages from cmd...

How to find and replace string?

If s is a std::string, then is there a function like the following? s.replace("text to replace", "new text"); ...

getting a checkbox array value from POST

i am posting an array of checkboxes. and i cant get it to work. i didnt include the proper syntax in the foreach loop to keep it simple. but it is working. i tested in by trying to do the same thing with a text field instead of a checkbox and it work...

Given a DateTime object, how do I get an ISO 8601 date in string format?

Given: DateTime.UtcNow How do I get a string which represents the same value in an ISO 8601-compliant format? Note that ISO 8601 defines a number of similar formats. The specific format I am looking for is: yyyy-MM-ddTHH:mm:ssZ ...

Get input type="file" value when it has multiple files selected

Possible Duplicate: Retrieving file names out of a multi-file upload control with javascript From HTML5 input type="file" allows users to choose multiple files by adding the multiple="multiple" : <input type="file" multiple="multiple" ...

test if event handler is bound to an element in jQuery

Is it possible to determine whether an element has a click handler, or a change handler, or any kind of event handler bound to it using jQuery? Furthermore, is it possible to determine how many click handlers (or whatever kind of event handlers) it ...

How to get full path of a file?

Is there an easy way I can print the full path of file.txt ? file.txt = /nfs/an/disks/jj/home/dir/file.txt The <command> dir> <command> file.txt should print /nfs/an/disks/jj/home/dir/file.txt ...

HTML text-overflow ellipsis detection

I have a collection of block elements on a page. They all have the CSS rules white-space, overflow, text-overflow set so that overflowing text is trimmed and an ellipsis is used. However, not all the elements overflow. Is there anyway I can use jav...

Iterate through string array in Java

I have String array with some components, this array has 5 components and it vary some times. What I would like to do is to iterate through that array and get the first component and the component next to that one. So the first time I would get the c...

Creating new database from a backup of another Database on the same server?

I am trying to create a new database from an old backup of database on the same server. When using SQL server management studio and trying to restore to the new DB from the backup I get this error System.Data.SqlClient.SqlError: The backup set holds...

HTML <input type='file'> File Selection Event

Let's say we have this code: <form action='' method='POST' enctype='multipart/form-data'> <input type='file' name='userFile'><br> <input type='submit' name='upload_btn' value='upload'> </form> which results in...

How do I make entire div a link?

I have a div like this <div class="xyz"></div> and all the content in that div is in the css. How do I make that div into a link? I tried wrapping the a tag around it, but that didn't seem to work. Thanks!!...

How to Make Laravel Eloquent "IN" Query?

I want to make query in Laravel Eloquent like here its raw MySQL query SELECT * from exampleTbl where id in(1,2,3,4) I have tried this in Laravel Eloquent but it's not working DB::where("id IN(23,25)")->get() ...

.htaccess File Options -Indexes on Subdirectories

I have the following .htaccess line, simple no indexes on root. Options -Indexes What do we add so it propagates to any sub directory instead of having to create one file for each? One .htaccess on root only....

Failure during conversion to COFF: file invalid or corrupt

When I try building just a simple program into VS2010, compiling succeeds yet when I try to build the solution it gives me this error: LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt What am I doing wrong?...

How to break nested loops in JavaScript?

I tried this: for(i = 0; i < 5; i++){ for(j = i + 1; j < 5; j++){ break(2); } alert(1); } only to get: SyntaxError: missing ; before statement So, how would I break a nested loop in JavaScript?...

HTTP response header content disposition for attachments

Background Write an XML document to a browser's response stream and cause the browser to display a "Save As" dialog. Problem Consider the following download() method: HttpServletResponse response = getResponse(); BufferedWriter bw = new Buff...

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

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

How to force remounting on React components?

Lets say I have a view component that has a conditional render: render(){ if (this.state.employed) { return ( <div> <MyInput ref="job-title" name="job-title" /> </div> ); ...

Prevent overwriting a file using cmd if exist

I am currently writing a .bat batch file that executes an installation file. Before it runs the installation file I check to see if the directory exists to avoid re-installing the application. I do this by using a If Not Exist filename statement. If...

Find first element by predicate

I've just started playing with Java 8 lambdas and I'm trying to implement some of the things that I'm used to in functional languages. For example, most functional languages have some kind of find function that operates on sequences, or lists that r...

How can a LEFT OUTER JOIN return more records than exist in the left table?

I have a very basic LEFT OUTER JOIN to return all results from the left table and some additional information from a much bigger table. The left table contains 4935 records yet when I LEFT OUTER JOIN it to an additional table the record count is sign...

Error 80040154 (Class not registered exception) when initializing VCProjectEngineObject (Microsoft.VisualStudio.VCProjectEngine.dll)

I'm trying to run this tool in order to convert a Visual C++ project to makefile. The project I'm trying to convert project is written in VS2008, so I'm using a reference to Microsoft.VisualStudio.VCProjectEngine.dll from version 9. It fails in this...

html5 <input type="file" accept="image/*" capture="camera"> display as image rather than "choose file" button

I've been looking into using html 5 <input type="file" accept="image/*" capture="camera"> to take a picture from my webapp and upload the image to the database using php - this is now working correctly. However, the only way I can seem to find...

How to use multiprocessing pool.map with multiple arguments?

In the Python multiprocessing library, is there a variant of pool.map which supports multiple arguments? text = "test" def harvester(text, case): X = case[0] text+ str(X) if __name__ == '__main__': pool = multiprocessing.Pool(p...

How to find the last day of the month from date?

How can I get the last day of the month in PHP? Given: $a_date = "2009-11-23" I want 2009-11-30; and given $a_date = "2009-12-23" I want 2009-12-31....

Bootstrap 3: Offset isn't working?

I have this code: <div class="row"> <div class="col-sm-3 col-sm-offset-6 col-md-12 col-md-offset-0"></div> <div class="col-sm-3 col-md-12"></div> </div> What I want for small (sm) screens is to have two div...

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

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

Get content of a DIV using JavaScript

I have two DIV's called DIV1 and DIV2 and DIV1 consists of dynamic content and DIV2 is empty. I need content of DIV1 to be displayed in DIV2. How can I do it. I coded in below manner which is not working. Anybody please correct it. <script type=...

java.lang.OutOfMemoryError: bitmap size exceeds VM budget - Android

I developed an application that uses lots of images on Android. The app runs once, fills the information on the screen (Layouts, Listviews, Textviews, ImageViews, etc) and user reads the information. There is no animation, no special effects or any...

Is it possible to capture the stdout from the sh DSL command in the pipeline

For example: var output=sh "echo foo"; echo "output=$output"; I will get: output=0 So, apparently I get the exit code rather than the stdout. Is it possible to capture the stdout into a pipeline variable, such that I could get: output=foo as my...

How to convert NSData to byte array in iPhone?

I want to convert NSData to a byte array, so I write the following code: NSData *data = [NSData dataWithContentsOfFile:filePath]; int len = [data length]; Byte byteData[len]; byteData = [data bytes]; But the last line of code pops up an error sayi...

How do I check if string contains substring?

I have a shopping cart that displays product options in a dropdown menu and if they select "yes", I want to make some other fields on the page visible. The problem is that the shopping cart also includes the price modifier in the text, which can be...

Groovy built-in REST/HTTP client?

I heard that Groovy has a built-in REST/HTTP client. The only library I can find is HttpBuilder, is this it? Basically I'm looking for a way to do HTTP GETs from inside Groovy code without having to import any libraries (if at all possible). But sin...

Get item in the list in Scala?

How in the world do you get just an element at index i from the List in scala? I tried get(i), and [i] - nothing works. Googling only returns how to "find" an element in the list. But I already know the index of the element! Here is the co...

Run function in script from command line (Node JS)

I'm writing a web app in Node. If I've got some JS file db.js with a function init in it how could I call that function from the command line?...

How can I get enum possible values in a MySQL database?

I want to populate my dropdowns with enum possible values from a DB automatically. Is this possible in MySQL?...

TimePicker Dialog from clicking EditText

I've already got a DatePicker which pops up when the user clicks on the EditText field eReminderDate.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated m...

Getting "A potentially dangerous Request.Path value was detected from the client (&)"

I've got a legacy code issue that requires that I support random urls as if they were requests for the home page. Some of the URLs have characters in them that generate the error "A potentially dangerous Request.Path value was detected from the clien...

CSS :not(:last-child):after selector

I have a list of elements, which are styled like this: _x000D_ _x000D_ ul {_x000D_ list-style-type: none;_x000D_ text-align: center;_x000D_ }_x000D_ _x000D_ li {_x000D_ display: inline;_x000D_ }_x000D_ _x000D_ li:not(:last-child):after {...

In python, how do I cast a class object to a dict

Let's say I've got a simple class in python class Wharrgarbl(object): def __init__(self, a, b, c, sum, version='old'): self.a = a self.b = b self.c = c self.sum = 6 self.version = version def __int__(...

Android custom dropdown/popup menu

How do I do a custom dropdown/popup menu anchored to a button? I need it to work like the popup menu (anchored to a view), and do something when I click an item from the menu. How do I add items to the menu by code, keeping menu's height and make ...

Add new element to an existing object

I was looking for a way to add new elements to an an existing object like what push does with arrays I have tried this and it didn't work : var myFunction = { Author: 'my name ', date: '15-12-2012', doSomething: function(){ ale...

Bootstrap 4 Dropdown Menu not working?

I copied the official Bootstrap 4 example for dropdown menus but it is not working, that is nothing is dropped down. <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="dropdown01" data-toggle="dropdown" aria...

How to stop asynctask thread in android?

I want to stop a AsyncTask thread from another AsyncTask thread. I have tried like new AsyncTask.cancel(true) to stop the background process but it didn't stop. Could any one help me on this?...

How to create a String with carriage returns?

For a JUnit test I need a String which consists of multiple lines. But all I get is a single lined String. I tried the following: String str = ";;;;;;\n" + "Name, number, address;;;;;;\n" + "01.01.12-16.02.12;;...

Vim: How to insert in visual block mode?

How can you insert when you are in visual block mode (by pressing ctrl-V) in Vim?...

Random number c++ in some range

Possible Duplicate: Generate Random numbers uniformly over entire range I want to generate the random number in c++ with in some range let say i want to have number between 25 and 63. How can i have that. Thanks...

how does unix handle full path name with space and arguments?

How does unix handle full path name with space and arguments ? In windows we quote the path and add the command-line arguments after, how is it in unix? "c:\foo folder with space\foo.exe" -help update: I meant how do I recognize a path from the ...

What is the main difference between Inheritance and Polymorphism?

I was presented with this question in an end of module open book exam today and found myself lost. I was reading Head first Javaand both definitions seemed to be exactly the same. I was just wondering what the MAIN difference was for my own piece of ...

'dispatch' is not a function when argument to mapToDispatchToProps() in Redux

I am a javascript/redux/react beginner building an small application with redux, react-redux, & react. For some reason when using mapDispatchToProps function in tandem with connect (react-redux binding) I receive a TypeError indicating that dispa...

MySQL does not start when upgrading OSX to Yosemite or El Capitan

I know similar questions exist, such as MySQL with MAMP does not work with OSX Yosemite 10.10. However, I do have MAMP, nor XAMPP installed on my computer. When I try to start mySQL from the PrefPane, nothing happens. When I try to start mqSQL from...

Self-reference for cell, column and row in worksheet functions

In a worksheet function in Excel, how do you self-reference the cell, column or row you're in?...

Changing background color of selected item in recyclerview

How to change the background color of only selected view in my recycle view example?only the background color of clicked itemview needs to be changed. Only one selected item must be displayed with background color change at a time and the rest needs ...

Turn off constraints temporarily (MS SQL)

I'm looking for a way to temporarily turn off all DB's constraints (eg table relationships). I need to copy (using INSERTs) one DB's tables to another DB. I know I can achieve that by executing commands in proper order (to not break relationships). ...

About the Full Screen And No Titlebar from manifest

I want to set my application to full screen view. I got the idea to set it in an individual activity using FullScreen and NoTitlebar, but i want to set it in my Manifest XML file for the whole application not for each activity... Is this possible? H...

How to check if cursor exists (open status)

How do I check if a cursor is open or not? Because many times I am encountering the error 'Cursor already exists'. Please let me know how can I check whether a cursor is already in open status. In fact I have closed as well as Deallocated it at the ...

How to POST JSON Data With PHP cURL?

Here is my code, $url = 'url_to_post'; $data = array( "first_name" => "First name", "last_name" => "last name", "email"=>"[email protected]", "addresses" => array ( "address1" => "some address", "city" =&...

How to change the Push and Pop animations in a navigation based app

I have a navigation based application and I want to change the animation of the push and pop animations. How would I do that? Edit 2018 There have been many answers to this question and it's been quite awhile now, I have re-chosen the answer to wha...

How to remove the first Item from a list?

I have the list [0, 1, 2, 3, 4] I'd like to make it into [1, 2, 3, 4]. How do I go about this? ...

Search and replace a line in a file in Python

I want to loop over the contents of a text file and do a search and replace on some lines and write the result back to the file. I could first load the whole file in memory and then write it back, but that probably is not the best way to do it. What...

How to prevent a browser from storing passwords

I need to stop browsers from storing the username & password values, because I'm working on a web application which contains more secure data. My client asked me to do this. I tried the autocomplete="off" attribute in the HTML form and password ...

Is there a way to programmatically minimize a window

What I'm doing is I have a full-screen form, with no title bar, and consequently lacks the minimize/maximize/close buttons found in the upper-right hand corner. I'm wanting to replace that functionality with a keyboard short-cut and a context menu it...

How to use sed to replace only the first occurrence in a file?

I would like to update a large number of C++ source files with an extra include directive before any existing #includes. For this sort of task, I normally use a small bash script with sed to re-write the file. How do I get sed to replace just the f...

how to load url into div tag

I have a <div id="content"> want to load url: http://vnexpress.net content into my code: <html> <head> <script type="text/javascript"> $(document).ready(function(){ $("#content").attr(...

Possible to change where Android Virtual Devices are saved?

I've set up the Android SDK and Eclipse on my machine running Windows XP and AVDs (Android Virtual Devices) are saved to "Documents and Settings\user\.android" by default. Is there any way to change this behavior? I have all of the other components...

Toad for Oracle..How to execute multiple statements?

I have some 800-1200 INSERT statements generated from an excel sheet. I want to run these in TOAD - Oracle db. If I press F9, it runs only one line and F5 gives me syntax issue and do not seem to work? What am I missing here?...

nodemon command is not recognized in terminal for node js server

I am doing node.js server setup from https://scotch.io/tutorials/authenticate-a-node-js-api-with-json-web-tokens. I am new in node.js. I am installing npm install nodemon --save. But when I am run the server with this nodemon server.js. In the termi...

Rotate an image in image source in html

Is there a way I could add in the source of my image codes that could rotate my image? Something like this: <img id="image_canv" src="/image.png" rotate="90"> I'm making my images dynamic, so I was wondering if I could append some extra cod...

WordPress asking for my FTP credentials to install plugins

I installed a WordPress blog in my local system. But when I try to add plugins from admin it asks for FTP access. What do I need to configure for WordPress to be able to upload without FTP?...

How do I reload a page without a POSTDATA warning in Javascript?

I want to reload a page using: window.location.reload(true); But I receive the POSTDATA warning because the refresh function want to resend previous POST form data. How can I refresh my page without this warning? UPDATED: I have no control of th...

Byte Array to Hex String

I have data stored in a byte array. How can I convert this data into a hex string? Example of my byte array: array_alpha = [ 133, 53, 234, 241 ] ...

In oracle, how do I change my session to display UTF8?

I can't figure out Oracle's encryptic syntax for the life of me. This is Oracle 10g My session's NLS_LANGUAGE is currently defaulting to AMERICAN. I need to be able to display UTF8 characters. Below are some of my attempts, all incorrect: ALTER S...

write newline into a file

considering the following function private static void GetText(String nodeValue) throws IOException { if(!file3.exists()) { file3.createNewFile(); } FileOutputStream fop=new FileOutputStream(file3,true); if(nodeValue!=null) ...

How to dynamically change the color of the selected menu item of a web page?

I am new to developing web pages. I am looking to create menus similar to the ones in stackoverflow.com (like Questions, Tags, Users shown above). How do I change the color of the selected menu (for example, the background color of the Question chang...

How can you flush a write using a file descriptor?

It turns out this whole misunderstanding of the open() versus fopen() stems from a buggy I2C driver in the Linux 2.6.14 kernel on an ARM. Backporting a working bit bashed driver solved the root cause of the problem I was trying to address here. ...

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

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

TS1086: An accessor cannot be declared in ambient context

I have a thousands of this error after initial implementation nad typing in terminal ng serve my-app of and i can't resolve it. This is first time for me when i have problem like this inside angular with typescript Errors looks like this: ERROR i...

How to parse a JSON string into JsonNode in Jackson?

It should be so simple, but I just cannot find it after being trying for an hour. I need to get a JSON string, for example, {"k1":v1,"k2":v2}, parsed as a JsonNode. JsonFactory factory = new JsonFactory(); JsonParser jp = factory....

How do you uninstall all dependencies listed in package.json (NPM)?

If I have a package.json file defined in my application root and run npm install -g it will install all the dependencies defined in package.json, globablly. However, this doesn't seem to work in reverse. If I do npm uninstall -g in my application r...

Margin between items in recycler view Android

Hi I am Following this tutorial: http://www.journaldev.com/10024/android-recyclerview-and-cardview-example-tutorial Now I am facing a weird issue the margin between each CardView item inside RecyclerView is way too much. ISSUE How to red...

PowerShell Connect to FTP server and get files

$ftpServer = "ftp.example.com" $username ="validUser" $password ="myPassword" $localToFTPPath = "C:\ToFTP" $localFromFTPPath = "C:\FromFTP" $remotePickupDir = "/Inbox" $remoteDropDir = "/Outbox" $SSLMode = [AlexPilotti.FTPS.Client.ESSLSupportMode]::C...

Test if something is not undefined in JavaScript

I'm checking if(response[0].title !== undefined), but I get the error: Uncaught TypeError: Cannot read property 'title' of undefined. ...

In jQuery, what's the best way of formatting a number to 2 decimal places?

This is what I have right now: $("#number").val(parseFloat($("#number").val()).toFixed(2)); It looks messy to me. I don't think I'm chaining the functions correctly. Do I have to call it for each textbox, or can I create a separate function?...

difference between width auto and width 100 percent

Previously my assumption about width: auto was that the width is set to that of the contents. Now I see that it takes the full width of the parent. Can anyone please describe the differences between these?...

Compare one String with multiple values in one expression

I have one String variable, str with possible values, val1, val2 and val3. I want to compare (with equal case) str to all of these values using an if statement, for example: if("val1".equalsIgnoreCase(str)||"val2".equalsIgnoreCase(str)||"val3.equal...

Difference between ${} and $() in Bash

I have two questions and could use some help understanding them. What is the difference between ${} and $()? I understand that () means running command in separate shell and placing $ means passing the value to variable. Can someone help me in unde...

Java Byte Array to String to Byte Array

I'm trying to understand a byte[] to string, string representation of byte[] to byte[] conversion... I convert my byte[] to a string to send, I then expect my web service (written in python) to echo the data straight back to the client. When I send ...

How to convert integer to string in C?

I tried this example: /* itoa example */ #include <stdio.h> #include <stdlib.h> int main () { int i; char buffer [33]; printf ("Enter a number: "); scanf ("%d",&i); itoa (i,buffer,10); printf ("decimal: %s\n"...

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

Laravel 5: Display HTML with Blade

I have a string returned to one of my views, like this: $text = '<p><strong>Lorem</strong> ipsum dolor <img src="images/test.jpg"></p>' I'm trying to display it with Blade: {{$text}} However, the output is a raw st...

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

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

Laravel-5 how to populate select box from database with id value and name value

I want to create a select box like the one below using illuminate\html : <select> <option value="$item->id">$item->name</option> <option value="$item->id">$item->name</option> </select> In my...

Cannot declare instance members in a static class in C#

I have a public static class and I am trying to access appSettings from my app.config file in C# and I get the error described in the title. public static class employee { NameValueCollection appSetting = ConfigurationManager.AppSettings; } ...