Examples On Programing Languages

Host binding and Host listening

How to use the host listener and host binding in angular 2? I tried like the below for host listener, but it's always showing a Declaration expected error. app.component.ts: import {Component, EventEmitter, HostListener, Directive} from 'angular2/co...

Installing Bootstrap 3 on Rails App

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

How do I create a Linked List Data Structure in Java?

What's the best way to make a linked list in Java?...

Why is it bad style to `rescue Exception => e` in Ruby?

Ryan Davis’s Ruby QuickRef says (without explanation): Don’t rescue Exception. EVER. or I will stab you. Why not? What’s the right thing to do?...

get size of json object

i have a json object that gets returned by an AJAX request and I am having some trouble with the .length because it keeps returning undefined. Just wondering if I'm using it right: console.log(data.length); console.log(data.phones.length); They bo...

How do you detect Credit card type based on number?

I'm trying to figure out how to detect the type of credit card based purely on its number. Does anyone know of a definitive, reliable way to find this?...

How to unzip gz file using Python

I need to extract a gz file that I have downloaded from an FTP site to a local Windows file server. I have the variables set for the local path of the file, and I know it can be used by GZIP muddle. How can I do this? The file inside the GZ file is...

Add error bars to show standard deviation on a plot in R

For each X-value I calculated the average Y-value and the standard deviation (sd) of each Y-value x = 1:5 y = c(1.1, 1.5, 2.9, 3.8, 5.2) sd = c(0.1, 0.3, 0.2, 0.2, 0.4) plot (x, y) How can I use the standard deviation to add error bars to each ...

Golang read request body

I am writing my own logginMiddleware. Basically, I need to log body of the request and the response. The problem that I faced is that when I read body, it becomes empty and I cannot read it twice. I understand that it happens because it is of type R...

Is Secure.ANDROID_ID unique for each device?

I am using this call: Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID); To get a UID for the device. I think I am getting the same ID from multiple devices though. Should this be possible? The ID in question is: ...

Everytime I run gulp anything, I get a assertion error. - Task function must be specified

I'm trying to run the command below but unfortunately I run into errors. $ gulp build In my terminal and I get this assertion error. I've uninstalled node and NPM and reinstalled again using brew - How do I completely uninstall Node.js, and reins...

When should I use Async Controllers in ASP.NET MVC?

I have some concerns using async actions in ASP.NET MVC. When does it improve performance of my apps, and when does it not? Is it good to use async action everywhere in ASP.NET MVC? Regarding awaitable methods: shall I use async/await keywords when...

Converting strings to floats in a DataFrame

How to covert a DataFrame column containing strings and NaN values to floats. And there is another column whose values are strings and floats; how to convert this entire column to floats. ...

Can't connect to Postgresql on port 5432

I have PostgreSQL 9.3 installed on a server running Ubuntu Server 14.04. If I ssh into the server via terminal, I'm able to connect with psql. But when I try to configure pgAdmin III to do the remote connection, I get: Server doesn't listen The ...

What is difference between monolithic and micro kernel?

Could anyone please explain with examples difference between monolithic and micro kernel? Also other classifications of the kernel?...

How to access /storage/emulated/0/

I have written a code to record audio and save it to below file location. private String getFilename() { String filepath = Environment.getExternalStorageDirectory().getPath(); File file = new File(filepath, AUDIO_RECORDER_FOLDER); if (!f...

Searching word in vim?

I can search word in vim with /word. How can I search only for word, excluding searches for word1 and word2?...

Kill a Process by Looking up the Port being used by it from a .BAT

In Windows what can look for port 8080 and try to kill the process it is using through a .BAT file?...

How to create many labels and textboxes dynamically depending on the value of an integer variable?

Is there any way to dynamically create and display 'n' Labels with 'n' corresponding Textboxs when we know value of 'n' after for example, clicking "Display" button. Let me know if anything make you don't understand my question. Thank you! I am wor...

convert pfx format to p12

I need to export a .pfx format certificate (from windows mmc) to .p12 to use in another application. I cant find a way to do this. Can anyone suggest a method?...

What are the complexity guarantees of the standard containers?

Apparently ;-) the standard containers provide some form of guarantees. What type of guarantees and what exactly are the differences between the different types of container? Working from the SGI page (about STL) I have come up with this: Containe...

Java abstract interface

Consider an example (which compiles in java) public abstract interface Interface { public void interfacing(); public abstract boolean interfacing(boolean really); } Why is it necessary for an interface to be "declared" abstract? Is there o...

How do I redirect a user when a button is clicked?

I have a view with a button. When the user clicks the button I want them redirected to a data entry view. How do I accomplish this? I should mention the views are created, tested, and functioning. I can get to them by typing the url. I looked for st...

How to destroy a DOM element with jQuery?

Suppose the jQuery object is $target....

UTC Date/Time String to Timezone

How do I convert a date/time string (e.g. 2011-01-01 15:00:00) that is UTC to any given timezone php supports, such as America/New_York, or Europe/San_Marino....

Python | change text color in shell

I was wondering if anyone knows how to set the color of the text that shows up in the shell. I noticed the 'ls' uses a couple different colors when printing out information to the screen (on my Linux box), was wondering if I could take advantage of t...

Alter user defined type in SQL Server

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

Visual Studio debugger error: Unable to start program Specified file cannot be found

I have a solution in C:\full path here\VS2010\blender.sln This solution contains many projects(around 100). When I compile them, they all work fine. I can run them without any problem, and (quite) everything works (there are some bugs). One of the p...

CSS I want a div to be on top of everything

How do I make an html div tag to be on top of everything? ...

Get Unix timestamp with C++

How do I get a uint unix timestamp in C++? I've googled a bit and it seems that most methods are looking for more convoluted ways to represent time. Can't I just get it as a uint?...

Add A Year To Today's Date

I am trying to add a year to todays date. I am working in a system that does not allow you to use standard JavaScript. For instance, to get todays date I have to use: javascript:now(); I have tried: javascript:now(+1); I have never seen this ...

Apache POI error loading XSSFWorkbook class

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

Download file using libcurl in C/C++

I am building an application (on windows using Dev-C++) and I want it to download a file. I am doing this using libcurl (I have already installed the source code using packman). I found a working example (http://siddhantahuja.wordpress.com/2009/04/12...

How Can I Remove “public/index.php” in the URL Generated Laravel?

I need to remove index.php or public/index.php from the generated URL in Laravel; commonly path is localhost/public/index.php/someWordForRoute, It should be something like localhost/someWordForRoute. .htaccess <IfModule mod_rewrite.c> <If...

Error:java: invalid source release: 8 in Intellij. What does it mean?

Im trying to compile some code in I'm using Intellij Ultimate 13.1.4, but I get the following error and I have no idea what it means: Information:Using javac 1.7.0_55 to compile java sources Information:java: Errors occurred while compiling module '...

c# - approach for saving user settings in a WPF application?

What approach do you recommend for persisting user settings in a WPF windows (desktop) application? Note that the idea is that the user can change their settings at run time, and then can close down the application, then when starting up the applic...

Unsupported operation :not writeable python

Email validation #Email validator import re def is_email(): email=input("Enter your email") pattern = '[\.\w]{1,}[@]\w+[.]\w+' file = open('ValidEmails.txt','r') if re.match(pattern, email): file.write(email) I am wonderi...

How does lock work exactly?

I see that for using objects which are not thread safe we wrap the code with a lock like this: private static readonly Object obj = new Object(); lock (obj) { // thread unsafe code } So what happens when multiple threads access the same code ...

Diff files present in two different directories

I have two directories with the same list of files. I need to compare all the files present in both the directories using the diff command. Is there a simple command line option to do it, or do I have to write a shell script to get the file listing a...

Ternary operator in AngularJS templates

How do you do a ternary with AngularJS (in the templates)? It would be nice to use some in html attributes (classes and style) instead of creating and calling a function of the controller....

org.xml.sax.SAXParseException: Premature end of file for *VALID* XML

I am getting very strange "Premature end of file." exception for last few days on one of our servers. The same configuration XML works fine on another server. We are using Tomcat 5.0.28 on both these servers. This code has been working for ages (7+ y...

How do you clone a Git repository into a specific folder?

Executing the command git clone [email protected]:whatever creates a directory in my current folder named whatever, and drops the contents of the Git repository into that folder: /httpdocs/whatever/public My problem is that I need the contents of the...

C# loop - break vs. continue

In a C# (feel free to answer for other languages) loop, what's the difference between break and continue as a means to leave the structure of the loop, and go to the next iteration? Example: foreach (DataRow row in myTable.Rows) { if (someCondi...

How to write a simple Html.DropDownListFor()?

In ASP.NET MVC 2, I'd like to write a very simple dropdown list which gives static options. For example I'd like to provide choices between "Red", "Blue", and "Green"....

Array to Hash Ruby

Okay so here's the deal, I've been googling for ages to find a solution to this and while there are many out there, they don't seem to do the job I'm looking for. Basically I have an array structured like this ["item 1", "item 2", "item 3", "item ...

Can't start Tomcat as Windows Service

I am using Tomcat6 on Windows 8. I am able to start Tomcat via startup.bat without error. I've copied Tomcat6.exe, Tomcat6w.exe and service.bat under tomcat/bin directory and set the .exe files to run as administrator. I open command line with admi...

Difference Between Select and SelectMany

I've been searching the difference between Select and SelectMany but I haven't been able to find a suitable answer. I need to learn the difference when using LINQ To SQL but all I've found are standard array examples. Can someone provide a LINQ To ...

cannot call member function without object

This program has the user input name/age pairs and then outputs them, using a class. Here is the code. #include "std_lib_facilities.h" class Name_pairs { public: bool test(); void read_names(); void read_ages(); void pri...

Spring get current ApplicationContext

I am using Spring MVC for my web application. My beans are written in "spring-servlet.xml" file Now I have a class MyClass and i want to access this class using spring bean In the spring-servlet.xml i have written following <bean id="myClass" c...

In CSS how do you change font size of h1 and h2

In a word press twenty eleven theme. I want to change the size of headings When I wrap my headings around h1 and h2 tags as follows <h1>My h1 heading </h1> <h2> My h2 heading </h2> The font size of heading in the theme I ...

Is it better to use C void arguments "void foo(void)" or not "void foo()"?

What is better: void foo() or void foo(void)? With void it looks ugly and inconsistent, but I've been told that it is good. Is this true? Edit: I know some old compilers do weird things, but if I'm using just GCC, is void foo() Ok? Will foo(bar); th...

Remove duplicates from a list of objects based on property in Java 8

I am trying to remove duplicates from a List of objects based on some property. can we do it in a simple way using java 8 List<Employee> employee Can we remove duplicates from it based on id property of employee. I have seen posts removing ...

How do I create a crontab through a script

I need to add a cron job thru a script I run to set up a server. I am currently using Ubuntu. I can use crontab -e but that will open an editor to edit the current crontab. I want to do this programmatically. Is it possible to do so?...

Disable eslint rules for folder

Is there a way to disable specific rules for a folder? For example, I don't want to have required JSDoc comments for all my test files in the test folder. Is there a way to do this?...

Use Toast inside Fragment

I'm trying to show a Toast Message when user click on a Button inside a Fragment. The problem is I cannot access the activity to show the Toast on it. Here's the source of Fragment: public class FrgTimes extends Fragment { ScrollVie...

PHP preg replace only allow numbers

How can I modify this existing preg_replace to only allow numbers? function __cleanData($c) { return preg_replace("/[^A-Za-z0-9]/", "",$c); } ...

Randomize a List<T>

What is the best way to randomize the order of a generic list in C#? I've got a finite set of 75 numbers in a list I would like to assign a random order to, in order to draw them for a lottery type application....

How to receive JSON as an MVC 5 action method parameter

I have been trying the whole afternoon crawling through the web trying to receive a JSON object in the action controller. What is the correct and or easier way to go about doing it? I have tried the following: 1: //Post/ Roles/AddUser [HttpPost] p...

How can I compare two lists in python and return matches

I want to take two lists and find the values that appear in both. a = [1, 2, 3, 4, 5] b = [9, 8, 7, 6, 5] returnMatches(a, b) would return [5], for instance....

Saving awk output to variable

Can anyone help me out with this problem? I'm trying to save the awk output into a variable. variable = `ps -ef | grep "port 10 -" | grep -v "grep port 10 -"| awk '{printf "%s", $12}'` printf "$variable" EDIT: $12 corresponds to a parameter runni...

How to set JAVA_HOME in Linux for all users

I am new to Linux system and there seem to be too many Java folders. java -version gives me: java version "1.7.0_55" OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13) OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode) When I a...

Does Django scale?

I'm building a web application with Django. The reasons I chose Django were: I wanted to work with free/open-source tools. I like Python and feel it's a long-term language, whereas regarding Ruby I wasn't sure, and PHP seemed like a huge hassle to ...

Cannot push to GitHub - keeps saying need merge

I'm new to GitHub. Today I met some issue when I was trying to push my code to GitHub. Pushing to [email protected]:519ebayproject/519ebayproject.git To [email protected]:519ebayproject/519ebayproject.git ! [rejected] master -> master (non-fast...

JQUERY: Uncaught Error: Syntax error, unrecognized expression

console.log($('"#'+d+'"')); in html i have <div id="2013-10-23"> <h1>5</h1> <p>eeeeeeeeeeee</p> </div> It throws error: Uncaught Error: Syntax error, unrecognized expression: "#2013-10-23" In a...

AWS S3 copy files and folders between two buckets

I have been on the lookout for a tool to help me copy content of an AWS S3 bucket into a second AWS S3 bucket without downloading the content first to the local file system. I have tried to use the AWS S3 console copy option but that resulted in som...

Setting query string using Fetch GET request

I'm trying to use the new Fetch API: I am making a GET request like this: var request = new Request({ url: 'http://myapi.com/orders', method: 'GET' }); fetch(request); However, I'm unsure how to add a query string to the GET request. Ideally...

How can I replace every occurrence of a String in a file with PowerShell?

Using PowerShell, I want to replace all exact occurrences of [MYID] in a given file with MyValue. What is the easiest way to do so?...

Search for "does-not-contain" on a DataFrame in pandas

I've done some searching and can't figure out how to filter a dataframe by df["col"].str.contains(word), however I'm wondering if there is a way to do the reverse: filter a dataframe by that set's compliment. eg: to the effect of !(df["col"].str.cont...

Failed to open/create the internal network Vagrant on Windows10

I upgraded my Windows 10 to the last update yesterday and now, when I launch vagrant up command, I get this error : ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... The guest machine entered ...

Spring data jpa- No bean named 'entityManagerFactory' is defined; Injection of autowired dependencies failed

I'm developing application using spring data jpa,hibernate,mysql,tomcat7,maven and it's create error.I'm trying to figure it out but i failed. error are Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; N...

Generating random whole numbers in JavaScript in a specific range?

How can I generate random whole numbers between two specified variables in JavaScript, e.g. x = 4 and y = 8 would output any of 4, 5, 6, 7, 8?...

Reading a string with scanf

I'm a little bit confused about something. I was under the impression that the correct way of reading a C string with scanf() went along the lines of (never mind the possible buffer overflow, it's just a simple example) char string[256]; scanf( "%s...

Select first occurring element after another element

I've got the following HTML code on a page: <h4>Some text</h4> <p> Some more text! </p> In my .css I've got the following selector to style the h4 element. The HTML code above is just a small part of the entire code; there ...

Angular expression if array contains

I'm trying to add a class to an element if a jobSet has not been selected for approval using expressions. <li class="approvalUnit" ng-repeat="jobSet in dashboard.currentWork" ng-class="{-1:'approved'}[selectedForApproval.indexOf(jobSet)]"> T...

Truncate (not round) decimal places in SQL Server

I'm trying to determine the best way to truncate or drop extra decimal places in SQL without rounding. For example: declare @value decimal(18,2) set @value = 123.456 This will automatically round @value to be 123.46, which is good in most cases....

How to resolve TypeError: can only concatenate str (not "int") to str

I decided to make some kind of secret code for testing purposes with Unicode. I've done that by adding numbers to Unicode so it would be kind of secret. I've been getting this error, but I don't know how to solve it. Is there any solution? Orig...

How to use the priority queue STL for objects?

class Person { public: int age; }; I want to store objects of the class Person in a priority queue. priority_queue< Person, vector<Person>, ??? > I think I need to define a class for the comparison thing, but I am not sure about ...

Why do python lists have pop() but not push()

Does anyone know why Python's list.append function is not called list.push given that there's already a list.pop that removes and returns the last element (that indexed at -1) and list.append semantic is consistent with that use?...

Get a list of dates between two dates

Using standard mysql functions is there a way to write a query that will return a list of days between two dates. eg given 2009-01-01 and 2009-01-13 it would return a one column table with the values: 2009-01-01 2009-01-02 2009-01-03 2009-01-...

How to Configure SSL for Amazon S3 bucket

I am using an Amazon S3 bucket for uploading and downloading of data using my .NET application. Now my question is: I want to access my S3 bucket using SSL. Is it possible to implement SSL for an Amazon s3 bucket?...

switch() statement usage

I am a little confused about the switch statement in R. Simply googling the function I get an example as follows: A common use of switch is to branch according to the character value of one of the arguments to a function. > centre <- functi...

UIWebView open links in Safari

I have a very simple UIWebView with content from my application bundle. I would like any links in the web view to open in Safari instead of in the web view. Is this possible?...

Permanently hide Navigation Bar in an activity

Is it possible to permanently remove the Navigation Bar on an activity? I want to remove the bar with the buttons that appear at the button of the screen on a tablet, not the Action Bar. Here. I know it is not recommended to do that, I did not make ...

How to check in Javascript if one element is contained within another

How can I check if one DOM element is a child of another DOM element? Are there any built in methods for this? For example, something like: if (element1.hasDescendant(element2)) or if (element2.hasParent(element1)) If not then any ideas how t...

Java Ordered Map

In Java, Is there an object that acts like a Map for storing and accessing key/value pairs, but can return an ordered list of keys and an ordered list of values, such that the key and value lists are in the same order? So as explanation-by-code, I'm...

Oracle SQL - REGEXP_LIKE contains characters other than a-z or A-Z

I would like to create a query where I select all records which contain characters that are not a-z or A-Z so something like this SELECT * FROM mytable WHERE REGEXP_LIKE(column_1, '![A-Z] [a-z]')...

CSS vertically align floating divs

I have a div (#wrapper) containing 2 divs standing side by side. I would like the right-div to be vertically aligned. I tried vertical-align:middle on my main wrapper but it is not working. It is driving me crazy! Hope someone can help. http://...

Capturing multiple line output into a Bash variable

I've got a script 'myscript' that outputs the following: abc def ghi in another script, I call: declare RESULT=$(./myscript) and $RESULT gets the value abc def ghi Is there a way to store the result either with the newlines, or with '\n' cha...

What is the simplest way to SSH using Python?

How can I simply SSH to a remote server from a local Python (3.0) script, supply a login/password, execute a command and print the output to the Python console? I would rather not use any large external library or install anything on the remote serv...

Running PowerShell as another user, and launching a script

I won't get into all the details of why I need this, but users must be able to launch PowerShell as a service account and when PowerShell loads it needs to run a script. I already can launch PowerShell with the stored credentials (stored as a secure ...

Using iFrames In ASP.NET

I have an asp.net website with a master-page, can I use the iframe so my .aspx pages will load inside the iframes. (Meaning it wont load the master-page) Kinda like my iframe will be the contentplaceholder or maybe the contentplaceholder will be ins...

PHP: date function to get month of the current date

I want to be able to figure out the month of the current date variable. I'm ex vb.net and the way to do it there is just date.Month. How do I do this in PHP? Thanks, Jonesy I used date_format($date, "m"); //01, 02..12 This is what I wanted, quest...

Using Java 8's Optional with Stream::flatMap

The new Java 8 stream framework and friends make for some very concise java code, but I have come across a seemingly-simple situation that is tricky to do concisely. Consider a List<Thing> things and method Optional<Other> resolve(Thing ...

how to remove the bold from a headline?

I have a headline: <h1>THIS IS A HEADLINE</h1> How do i make the phrase "THIS IS..." not to be bold and the rest without a change? couldn't find any relevent tag in text-decoration....

Convert JSON array to an HTML table in jQuery

Is there a really easy way I can take an array of JSON objects and turn it into an HTML table, excluding a few fields? Or am I going to have to do this manually?...

Running Facebook application on localhost

I am planning to connect to Facebook chat from my localhost. I will need to get the session key from Facebook. When I give the site URL as localhost:8080 or ip-address:8080 it does not work. I read about setting up two apps with 2 different API key...

I keep getting "Uncaught SyntaxError: Unexpected token o"

I'm trying to learn some html/css/javascript, so I'm writing myself a teaching project. The idea was to have some vocabulary contained in a json file which would then be loaded into a table. I managed to load the file in and print out one of its val...

How to resize array in C++?

I need to do the equivalent of the following C# code in C++ Array.Resize(ref A, A.Length - 1); How to achieve this in C++?...

Wavy shape with css

I'm trying to recreate this image with CSS: I would not need it to repeat. This is what I started but it just has a straight line: _x000D_ _x000D_ #wave {_x000D_ position: absolute;_x000D_ height: 70px;_x000D_ width: 600px;_x000D_ backgro...

Count work days between two dates

How can I calculate the number of work days between two dates in SQL Server? Monday to Friday and it must be T-SQL....

Spring - @Transactional - What happens in background?

I want to know what actually happens when you annotate a method with @Transactional? Of course, I know that Spring will wrap that method in a Transaction. But, I have the following doubts: I heard that Spring creates a proxy class? Can someone exp...

How can I exclude $(this) from a jQuery selector?

I have something like this: <div class="content"> <a href="#">A</a> </div> <div class="content"> <a href="#">B</a> </div> <div class="content"> <a href="#">C</a> </div&...

What is the most compatible way to install python modules on a Mac?

I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble. On the Mac, I'm used to ...

Storing image in database directly or as base64 data?

The common method to store images in a database is to convert the image to base64 data before storing the data. This process will increase the size by 33%. Alternatively it is possible to directly store the image as a BLOB; for example: $image = new...

How to track down a "double free or corruption" error

When I run my (C++) program it crashes with this error. * glibc detected * ./load: double free or corruption (!prev): 0x0000000000c6ed50 *** How can I track down the error? I tried using print (std::cout) statements, without success. Could g...

Java 8 Stream and operation on arrays

I have just discovered the new Java 8 stream capabilities. Coming from Python, I was wondering if there was now a neat way to do operations on arrays like summing, multiplying two arrays in a "one line pythonic" way ? Thanks...

Is there an easy way to reload css without reloading the page?

I'm trying to make a live, in-page css editor with a preview function that would reload the stylesheet and apply it without needing to reload the page. What would be the best way to go about this?...

What strategies and tools are useful for finding memory leaks in .NET?

I wrote C++ for 10 years. I encountered memory problems, but they could be fixed with a reasonable amount of effort. For the last couple of years I've been writing C#. I find I still get lots of memory problems. They're difficult to diagnose and fix...

Create a button with rounded border

How would you make a FlatButton into a button with a rounded border? I have the rounded border shape using RoundedRectangleBorder but somehow need to color the border. new FlatButton( child: new Text("Button text), onPressed: null, shape: new ...

postgreSQL - psql \i : how to execute script in a given path

I'm new to postgreSQL and I have a simple question: I'm trying to create a simple script that creates a DB so I can later call it like this: psql -f createDB.sql I want the script to call other scripts (separate ones for creating tables, adding c...

How do I fix the npm UNMET PEER DEPENDENCY warning?

I'm on Windows 10, with Node 5.6.0 and npm 3.6.0. I'm trying to install angular-material and mdi into my working folder. npm install angular-material mdi errors with: +-- [email protected] +-- UNMET PEER DEPENDENCY angular-animate@^1.5.0 +-- UNMET PEE...

Textarea to resize based on content length

I need a textarea where I type my text in the box, it grows in length as needed to avoid having to deal with scroll bars and it need to shrink after delete text! I didn’t want to go down the mootools or jquery route because I have a lightweight for...

Couldn't connect to server 127.0.0.1:27017

I'm getting the following error: alex@alex-K43U:/$ mongo MongoDB shell version: 2.2.0 connecting to: test Thu Oct 11 11:46:53 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91 exception: connect failed alex@alex-K43U:/$ ...

Saving image from PHP URL

I need to save an image from a PHP URL to my PC. Let's say I have a page, http://example.com/image.php, holding a single "flower" image, nothing else. How can I save this image from the URL with a new name (using PHP)?...

using lodash .groupBy. how to add your own keys for grouped output?

I have this sample data returned from an API. I'm using Lodash's _.groupBy to convert the data into an object I can use better. The raw data returned is this: [ { "name": "jim", "color": "blue", "age": "22" }, { ...

How to bring back "Browser mode" in IE11?

UPDATE: The old question applies only to IE11 preview; browser mode had returned in final release of IE11. But there is a catch: it is next to useless, because it does not emulate conditional comments. For example, if you use them to enable HTML5 sup...

Can I have a video with transparent background using HTML5 video tag?

We filmed a spokesperson on a green screen and have the video files ready in multiple formats. With Flash we could use the wmode transparent within the param and embed tags, but is there something similar to this with the video and source tags in H...

Can't subtract offset-naive and offset-aware datetimes

I have a timezone aware timestamptz field in PostgreSQL. When I pull data from the table, I then want to subtract the time right now so I can get it's age. The problem I'm having is that both datetime.datetime.now() and datetime.datetime.utcnow() se...

The opposite of Intersect()

Intersect can be used to find matches between two collections, like so: // Assign two arrays. int[] array1 = { 1, 2, 3 }; int[] array2 = { 2, 3, 4 }; // Call Intersect extension method. var intersect = array1.Intersect(array2); // Write intersection...

Ignore case in Python strings

What is the easiest way to compare strings in Python, ignoring case? Of course one can do (str1.lower() <= str2.lower()), etc., but this created two additional temporary strings (with the obvious alloc/g-c overheads). I guess I'm looking for an ...

how to get request path with express req object

I'm using express + node.js and I have a req object, the request in the browser is /account but when I log req.path I get '/' --- not '/account'. //auth required or redirect app.use('/account', function(req, res, next) { console.log(req.path...

A Simple, 2d cross-platform graphics library for c or c++?

As in title, i need a 2d graphics library that is cross-platform, and provides simple functions, like in Basic; essentially, i only need to paint a pixel a certain color-I do not need hardware acceleration, or any kind of 3d support. I've found a cou...

Install pip in docker

I'm not able to install pip in Docker. Here's my Dockerfile: FROM ubuntu:14.04 # Install dependencies RUN apt-get update -y RUN apt-get install -y git curl apache2 php5 libapache2-mod-php5 php5-mcrypt php5-mysql python3.4 python-pip When buildin...

how to access downloads folder in android?

I am new android, i'm making an app in which one can download files to downloads folder (using Download Manager). I can see pictures if i go to downloads folder in emulator. So if i want to show a slideshow of downloaded files how can i get the acces...

An exception of type 'System.NullReferenceException' occurred in myproject.DLL but was not handled in user code

What does this error mean?, I keep getting this error, it use to work fine and it just started throwing this error.... any help? img1.ImageUrl = ConfigurationManager.AppSettings.Get("Url").Replace("###", randomString) + Server.UrlEncode(((System.W...

Javascript : array.length returns undefined

I have a set of data that is being passed on by the PHP's json_encode function. I'm using the jQuery getJSON function to decode it: $.getJSON("url", function (data) { console.log(data); }); The output looks like this in the console: Object {...

What is the correct way to write HTML using Javascript?

It seems that experienced web developers frown upon using document.write() in JavaScript when writing dynamic HTML. Why is this? and what is the correct way?...

:last-child not working as expected?

The issue lies within this CSS and HTML. Here is a link to jsFiddle with the sample code. HTML <ul> <li class"complete">1</li> <li class"complete">2</li> <li>3</li> <li>4</li> &l...

Accessing the logged-in user in a template

I'm using FOSuserbundle to get started with User registration https://github.com/FriendsOfSymfony/FOSUserBundle I've got it registering / logging in and out. What I want to do now is grab the logged in users data and present it on every page of my s...

How to remove \xa0 from string in Python?

I am currently using Beautiful Soup to parse an HTML file and calling get_text(), but it seems like I'm being left with a lot of \xa0 Unicode representing spaces. Is there an efficient way to remove all of them in Python 2.7, and change them into spa...

ALTER TABLE on dependent column

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

How to draw in JPanel? (Swing/graphics Java)

I'm working on a project in which I am trying to make a paint program. So far I've used Netbeans to create a GUI and set up the program. As of right now I am able to call all the coordinated necessary to draw inside it but I am very confused with ho...

How to get the element clicked (for the whole document)?

I would like to get the current element (whatever element that is) in an HTML document that I clicked. I am using: $(document).click(function () { alert($(this).text()); }); But very strangely, I get the text of the whole(!) document, not the cl...

Controlling Maven final name of jar artifact

I'm trying to define a property in our super pom which will be used by all child projects as the destination of the generated artifact. For this I was thinking about using project/build/finalName yet this does not seem work, even for simple poms: C...

Installation of VB6 on Windows 7 / 8 / 10

I have been having problems installing VB6 on Windows 7. I realize it is a legacy IDE and my research on the net hasn't been that much of help. Every time I attempt to install VB6 on Windows 7, besides the alert notifying me of compatibility issues, ...

How can I create an array with key value pairs?

How can I add key value pairs to an array? This won't work: public function getCategorieenAsArray(){ $catList = array(); $query = "SELECT DISTINCT datasource_id, title FROM table"; if ($rs=C_DB::fetchRecordset($query)) { while...

SQL Sum Multiple rows into one

I need some help with the SUM feature. I am trying to SUM the bill amounts for the same account into one grand total, but the results I am getting show my SUM column just multiples my first column by 3. Here is what I want as results for my mock da...

Define global variable with webpack

Is it possible to define a global variable with webpack to result something like this: var myvar = {}; All of the examples I saw were using external file require("imports?$=jquery!./file.js")...

Pivoting rows into columns dynamically in Oracle

I have the following Oracle 10g table called _kv: select * from _kv ID K V ---- ----- ----- 1 name Bob 1 age 30 1 gender male 2 name Susan 2 status married I'd like to turn my keys ...

Presto SQL - Converting a date string to date format

I'm on presto and have a date formatted as varchar that looks like - 7/14/2015 8:22:39 AM I've looked the presto docs and tried various things(cast, date_format, using split_part to parse and then cast) and am not getting this to convert to a dat...

How do I get an OAuth 2.0 authentication token in C#

I have these settings: Auth URL (which happens to be a "https://login.microsoftonline.com/...") if that helps. Access Token URL "https://service.endpoint.com/api/oauth2/token" ClientId "abc" Clientsecret "123" I then need to make a get call using...

Android - Back button in the title bar

In many apps (Calendar, Drive, Play Store) when you tap a button and enter a new activity, the icon in the title bar turns into a back button, but for the app I am making, it doesn't do that. How do I make that icon take you back to the previous scre...

Calculate difference between two datetimes in MySQL

I am storing the last login time in MySQL in, datetime-type filed. When users logs in, I want to get the difference between the last login time and the current time (which I get using NOW()). How can I calculate it?...

How can I disable a tab inside a TabControl?

Is there a way to disable a tab in a TabControl?...

How to scan multiple paths using the @ComponentScan annotation?

I'm using Spring 3.1 and bootstrapping an application using the @Configuration and @ComponentScan attributes. The actual start is done with new AnnotationConfigApplicationContext(MyRootConfigurationClass.class); This Configuration class is annota...

Kill tomcat service running on any port, Windows

Kill tomcat service running on any port, Windows using command promt like 8080/ 8005 ...

Advantage of switch over if-else statement

What's the best practice for using a switch statement vs using an if statement for 30 unsigned enumerations where about 10 have an expected action (that presently is the same action). Performance and space need to be considered but are not critical. ...

Catching multiple exception types in one catch block

I'd like a cleaner way to obtain the following functionality, to catch AError and BError in one block: try { /* something */ } catch( AError, BError $e ) { handler1( $e ) } catch( Exception $e ) { handler2( $e ) } Is there any way to d...

Lambda expression to convert array/List of String to array/List of Integers

Since Java 8 comes with powerful lambda expressions, I would like to write a function to convert a List/array of Strings to array/List of Integers, Floats, Doubles etc.. In normal Java, it would be as simple as for(String str : strList){ intLi...

Drop data frame columns by name

I have a number of columns that I would like to remove from a data frame. I know that we can delete them individually using something like: df$x <- NULL But I was hoping to do this with fewer commands. Also, I know that I could drop columns us...

How to convert a string from uppercase to lowercase in Bash?

I have been searching to find a way to convert a string value from upper case to lower case. All the search results show approaches of using tr command. The problem with the tr command is that I am able to get the result only when I use the command ...

Undefined symbols for architecture x86_64 on Xcode 6.1

All of a sudden Xcode threw me this error at compilation time: Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_Format", referenced from: objc-class-ref in WOExerciseListViewController.o ld: symbol(s) not found for architecture x86_64 cla...

How do I break a string in YAML over multiple lines?

In YAML, I have a string that's very long. I want to keep this within the 80-column (or so) view of my editor, so I'd like to break the string. What's the syntax for this? In other words, I have this: Key: 'this is my very very very very very very ...

PHP DateTime __construct() Failed to parse time string (xxxxxxxx) at position x

I had this construction error when trying to creating a new DateTime object using a timestamp: Exception: DateTime::_construct(): Failed to parse time string (1372622987) at position 8 (8): Unexpected character in DateTime->_construct() The obj...

Keeping session alive with Curl and PHP

I'm trying to connect to an API, authenticate a user and then view the user details. This is accomplished by first accessing the login endpoint at http://api.example.com/login/<username>/<password> to log in and then the following to v...

How to correctly catch change/focusOut event on text input in React.js?

I've got a form, in which I want to handle change event on text inputs, but React onChange triggering on key down (opposite to native JS, that triggers change event when an input field is out of focus). Is there a React way to do what I want?...

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

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

How do I generate a random number between two variables that I have stored?

Possible Duplicate: Generating random integer from a range I am trying to create a program where the computer guesses a number the user has in his/her mind. The only user input required is whether the guess was too high, too low, or correc...

Count number of rows by group using dplyr

I am using the mtcars dataset. I want to find the number of records for a particular combination of data. Something very similar to the count(*) group by clause in SQL. ddply() from plyr is working for me library(plyr) ddply(mtcars, .(cyl,gear),nro...

How to get the stream key for twitch.tv

I write an app for broadcasting to twitch.tv using C++. For that streaming I need to know the user stream key, usually an user gets that key from the page, http://www.twitch.tv/user_name/dashboard/streamkey But I would like get it via my app by us...

What port is used by Java RMI connection?

May I know what port is used by Java RMI connection? If I want to connect a Java client application to a Java server application using RMI connection, what port I need to open at the server machine so that the client application can connect to it? ...

Python error message io.UnsupportedOperation: not readable

I made a simple program but It shows the following error when I run it: line1 = [] line1.append("xyz ") line1.append("abc") line1.append("mno") file = open("File.txt","w") for i in range(3): file.write(line1[i]) file.write("\n") for line i...

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

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

Material Design not styling alert dialogs

I've added the appCompat material design to my app and it seems that the alert dialogs are not using my primary, primaryDark, or accent colors. Here is my base style: <style name="MaterialNavyTheme" parent="@style/Theme.AppCompat.Light.DarkActi...

Boolean vs tinyint(1) for boolean values in MySQL

What column type is best to use in a MySQL database for boolean values? I use boolean but my colleague uses tinyint(1)....

How to get the type of T from a member of a generic class or method?

Let say I have a generic member in a class or method, so: public class Foo<T> { public List<T> Bar { get; set; } public void Baz() { // get type of T } } When I instantiate the class, the T becomes MyTypeObj...

How do I correctly setup and teardown for my pytest class with tests?

I am using selenium for end to end testing and I can't get how to use setup_class and teardown_class methods. I need to set up browser in setup_class method, then perform a bunch of tests defined as class methods and finally quit browser in teardown_...

jQuery AutoComplete Trigger Change Event

How do you trigger jQuery UI's AutoComplete change event handler programmatically? Hookup $("#CompanyList").autocomplete({ source: context.companies, change: handleCompanyChanged }); Misc Attempts Thus Far $("#CompanyList").change(); ...

Get current cursor position

I want to get the current mouse position of the window, and assign it to 2 variables x and y (co-ordinates relative to the window, not to the screen as a whole). I'm using Win32 and C++. And a quick bonus question: how would you go about hiding the...

Sql select rows containing part of string

I want to write a comparation procedure (t-sql) for site seo. I have a table with field 'url' (nvarchar()) that contain a part of site url's. Ex: 'mysyte.com/?id=2'. Also this table for each url contains metadata, that i need to extract. The main p...

How do I disable text selection with CSS or JavaScript?

I am making a HTML/CSS/jQuery gallery, with several pages. I indeed have a "next" button, which is a simple link with a jQuery click listener. The problem is that if the user click the button several times, the text of the button is selected, and t...

__FILE__, __LINE__, and __FUNCTION__ usage in C++

Presuming that your C++ compiler supports them, is there any particular reason not to use __FILE__, __LINE__ and __FUNCTION__ for logging and debugging purposes? I'm primarily concerned with giving the user misleading data—for example, reporting t...

SQL subquery with COUNT help

I have an SQL statement that works SELECT * FROM eventsTable WHERE columnName='Business' I want to add this as a subquery... COUNT(Business) AS row_count How do I do this?...

Indent starting from the second line of a paragraph with CSS

How can I indent starting from the second line of a paragraph? I've tried p { text-indent: 200px; } p:first-line { text-indent: 0; } and p { margin-left: 200px; } p:first-line { margin-left: 0; } and (with position:relative;)...

jQuery: selecting each td in a tr

I need a way to interact with each td element in a tr. To elaborate, I would like to access the first table row, then the first column, then the second column, etc. Then move onto the second row and repeat the process. Something like this (pseudo-...

Why do I have to define LD_LIBRARY_PATH with an export every time I run my application?

I have some code that uses some shared libraries (c code on gcc). When compiling I have to explicitly define the include and library directories using -I and -L, since they aren't in the standard places. When I try to run the code, I get the followin...

What's the difference between passing by reference vs. passing by value?

What is the difference between a parameter passed by reference a parameter passed by value? Could you give me some examples, please?...

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 do I ignore files in Subversion?

How do I ignore files in Subversion? Also, how do I find files which are not under version control?...

Total memory used by Python process?

Is there a way for a Python program to determine how much memory it's currently using? I've seen discussions about memory usage for a single object, but what I need is total memory usage for the process, so that I can determine when it's necessary to...

jQuery: enabling/disabling datepicker

In my php-file, I want to use the jQuery Datepicker. When my file loads, I create the Datepicker disabled. Then, when a special field in my php-file (it is a form) is filled, I want to enable the Datepicker. So, initially my Datepicker looks like ...

How to set ANDROID_HOME path in ubuntu?

How to set ANDROID_HOME path in ubuntu? Please provide the steps....

Sublime Text 2 keyboard shortcut to open file in specified browser (e.g. Chrome)

I do web development and am trying out Sublime Text 2. Is there a keyboard shortcut to open the current file in specified browser (e.g. Chrome)? Any help to get setup in Sublime Text for web development is appreciated!...

Angular 2 - Setting selected value on dropdown list

I have run into an issue in pre-selecting values on a dropdown list in Angular 2. I set an array of colours in the component which I bind successfully to the dropdown list. The issue I'm experiencing is with pre-selecting a value on page init. ...

How to get element by innerText

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

How to store(bitmap image) and retrieve image from sqlite database in android?

In my project I need to store an image into a sqlite database and also need to retrieve it to show in my android emulator. When I show it directly after decoding the encoded string, which I got from Java class using sockets, the image displays there....

Firefox 'Cross-Origin Request Blocked' despite headers

I'm trying to make a simple cross-origin request, and Firefox is consistently blocking it with this error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at [url]. This can be fixed by moving the resou...

How to close TCP and UDP ports via windows command line

Does somebody knows how to close a TCP or UDP socket for a single connection via windows command line? Googling about this, I saw some people asking the same thing. But the answers looked like a manual page of netstat or netsh commands focusing on h...

Setting onClickListener for the Drawable right of an EditText

In my app I have a EditText with a search Icon on the right side. I used the code given below. <EditText android:id="@+id/search" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marg...

How to make certain text not selectable with CSS

The header for my page has some centered text, but I do not want the user to be able to select it. Is there a way to do this with CSS?...

Changing background colour of tr element on mouseover

I want to have my table rows highlighted on mouse over, but I have yet to find a way to do it that isn't using Javascript. Is this not possible in CSS? I've tried this: tr:hover { background: #000; } But that doesn't work. Using td:hover work...

What is PAGEIOLATCH_SH wait type in SQL Server?

I have a query that is taking a long time in the middle of a transaction. When I get the wait_type of the process it is PAGEIOLATCH_SH. What does this wait type mean and how can this be resolved?...

How to implement common bash idioms in Python?

I currently do my textfile manipulation through a bunch of badly remembered AWK, sed, Bash and a tiny bit of Perl. I've seen mentioned a few places that python is good for this kind of thing. How can I use Python to replace shell scripting, AWK, sed...

Can someone explain Microsoft Unity?

I've been reading the articles on MSDN about Unity (Dependency Injection, Inversion of Control), but I think I need it explained in simple terms (or simple examples). I'm familiar with the MVPC pattern (we use it here), but I just can't really grasp ...

When and why do I need to use cin.ignore() in C++?

I wrote a very basic program in C++ which asked the user to input a number and then a string. To my surprise, when running the program it never stopped to ask for the string. It just skipped over it. After doing some reading on StackOverflow, I found...

What's a quick way to comment/uncomment lines in Vim?

I have a Ruby code file open in vi, there are lines commented out with #: class Search < ActiveRecord::Migration def self.up # create_table :searches do |t| # t.integer :user_id # t.string :name # t.string :all_of # ...

Add JavaScript object to JavaScript object

I'd like to have JavaScript objects within another JavaScript object as such: Issues: - {"ID" : "1", "Name" : "Missing Documentation", "Notes" : "Issue1 Notes"} - {"ID" : "2", "Name" : "Software Bug", "Notes" : "Issue2 Notes, blah, blah"} - {...

WPF global exception handler

Sometimes, under not reproducible circumstances, my WPF application crashes without any message. The application simply close instantly. Where is the best place to implement the global Try/Catch block. At least I have to implement a messagebox with:...

What encoding/code page is cmd.exe using?

When I open cmd.exe in Windows, what encoding is it using? How can I check which encoding it is currently using? Does it depend on my regional setting or are there any environment variables to check? What happens when you type a file with a certain...

Replace a newline in TSQL

I would like to replace (or remove) a newline character in a TSQL-string. Any Ideas? The obvious REPLACE(@string, CHAR(13), '') just won't do it......

How to activate JMX on my JVM for access with jconsole?

How to activate JMX on a JVM for access with jconsole?...

How to change background color in the Notepad++ text editor?

Does anyone know how to change the background color, font size, and other appearance-based settings in Notepad++? The default is white but I am trying to change it into a dark gray or something else....

Python function as a function argument?

Can a Python function be an argument of another function? Say: def myfunc(anotherfunc, extraArgs): # run anotherfunc and also pass the values from extraArgs to it pass So this is basically two questions: Is it allowed at all? And if it ...

ASP.NET MVC 5 - Identity. How to get current ApplicationUser

I have an Article entity in my project which has the ApplicationUser property named Author. How can I get the full object of currently logged ApplicationUser? While creating a new article, I have to set the Author property in Article to the current A...

Append key/value pair to hash with << in Ruby

In Ruby, one can append values to existing arrays using <<: a = [] a << "foo" but, can you also append key/value pairs to an existing hash? h = {} h << :key "bar" I know you can do: h[:key] = "" h[:key] << "bar" but t...

What does iterator->second mean?

In C++, what is the type of a std::map<>::iterator? We know that an object it of type std::map<A,B>::iterator has an overloaded operator -> which returns a std::pair<A,B>*, and that the std::pair<> has a first and second m...

Which data type for latitude and longitude?

I am newbie to PostgreSQL and PostGIS. I want to store latitude and longitude values in PostgreSQL 9.1.1 database table. I will calculate distance between two points, find nearer points by using this location values. Which data type should I use fo...

How to fix: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found

So I'm now desperate in finding a fix for this. I'm compiling a shared library .so in Ubuntu 32 bit (Have tried doing it under Debian and Ubuntu 64 bit, but none worked either) I keep getting: /usr/lib/libstdc++.so.6: version ``GLIBCXX_3.4.15' not f...

Replace HTML Table with Divs

Alright, I'm trying to buy into the idea that html tables should not be used, and that divs should be. However, I often have code that resembles the following <table> <tr> <td>First Name:</td> <td colsp...

Sorting a tab delimited file

I have a data with the following format: foo<tab>1.00<space>1.33<space>2.00<tab>3 Now I tried to sort the file based on the last field decreasingly. I tried the following commands but it wasn't sorted as we expected. $ sor...

How to request Administrator access inside a batch file

I am trying to write a batch file for my users to run from their Vista machines with UAC. The file is re-writing their hosts file, so it needs to be run with Administrator permissions. I need to be able to send them an email with a link to the .bat...

Downloading jQuery UI CSS from Google's CDN

I am planning on using Google to download the jQuery lib for both UI and Core. My question is, do they allow me to download the CSS for it or should I have to host it myself? Also if I use Google to load how should I load other plugins? Can I compr...

Environment Variable with Maven

I've ported a project from Eclipse to Maven and I need to set an environment variable to make my project work. In Eclipse, I go to "Run -> Run configurations" and, under the tab "environment", I set "WSNSHELL_HOME" to the value "conf". How can I do...

How to update RecyclerView Adapter Data?

Trying to figure out what is the issue with updating RecyclerView's Adapter. After I get a new List of products, I tried to: Update the ArrayList from the fragment where recyclerView is created, set new data to adapter, then call adapter.notifyDa...

Hive cast string to date dd-MM-yyyy

How can I cast a string in the format 'dd-MM-yyyy' to a date type also in the format 'dd-MM-yyyy' in Hive? Something along the lines of: CAST('12-03-2010' as date 'dd-mm-yyyy') ...

Use jquery to set value of div tag

I have this html div tag defined: <div style="height:100px; width:100px" class="total-title"> first text </div> I have jquery code to change its value: $('div.total-title').html('test'); But this does not change the content of ...

Find if a String is present in an array

OK let's say I have an array filled with {"tube", "are", "fun"} and then I have a JTextField and if I type either one of those commands to do something and if NOT to get like a message saying "Command not found". I tried looking in Java docs but all...

Push eclipse project to GitHub with EGit

I am successfully pushing my project to GitHub using EGit. My repository is called HelloWorld. My project in eclipse is also called HelloWorld. My problem is when i push the project it is upload the project under the folder HelloWorld. So the result ...

Apache error: _default_ virtualhost overlap on port 443

I get this error when trying to start Apache. _default_ virtualhost overlap on port 443 I'm trying to set up SSL. Almost every solution online says add: NameVirtualHost *:443 to the conf file but Apache still fails to start and just says ...

Java - How to find the redirected url of a url?

I am accessing web pages through java as follows: URLConnection con = url.openConnection(); But in some cases, a url redirects to another url. So I want to know the url to which the previous url redirected. Below are the header fields that I got ...

Slack URL to open a channel from browser

This iTunes URL will open The Hitchhiker's Guide to the Galaxy in your iTunes: itmss://itunes.apple.com/us/audiobook/hitchhikers-guide-to-galaxy/id315596797 This Spotify URL will open ALL by the Descendents in Spotify: spotify:track:22feF2s...

Moment JS - check if a date is today or in the future

I am trying to use momentjs to check if a given date is today or in the future. This is what I have so far: <script type="text/javascript" src="http://momentjs.com/downloads/moment.min.js"></script> <script type="text/javascript">...

jQuery to loop through elements with the same class

I have a load of divs with the class testimonial and I want to use jquery to loop through them to check for each div if a specific condition is true. If it is true, it should perform an action. Does anyone know how I would do this?...

How to save RecyclerView's scroll position using RecyclerView.State?

I have a question about Android's RecyclerView.State. I am using a RecyclerView, how could I use and bind it with RecyclerView.State? My purpose is to save the RecyclerView's scroll position....

How to get an Instagram Access Token

I'm really struggling in how I'm meant to get my access token for Instagram, I've registered a new client and then I used this URL https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code ...

Checking if type == list in python

I may be having a brain fart here, but I really can't figure out what's wrong with my code: for key in tmpDict: print type(tmpDict[key]) time.sleep(1) if(type(tmpDict[key])==list): print 'this is never visible' break th...

How to convert a string Date to long millseconds

I have a date inside a string, something like "12-December-2012". How can I convert this into milliseconds (long)?...

AngularJS: factory $http.get JSON file

I am looking to develop locally with just a hardcoded JSON file. My JSON file is as follows (valid when put into JSON validator): { "contentItem": [ { "contentID" : "1", "contentVideo" : "file.mov", ...

How can I clone an SQL Server database on the same server in SQL Server 2008 Express?

I have an MS SQL Server 2008 Express system which contains a database that I would like to 'copy and rename' (for testing purposes) but I am unaware of a simple way to achieve this. I notice that in the R2 version of SQL Server there is a copy datab...

Execute SQL script from command line

I need to alter a database using a batch file, for a simple example, drop a table. I´m using local SQL Express (SQL Server 2008 R2) with user sa and its password. How would the bat file be? How can I specify in the script the password and that I ...

Java ElasticSearch None of the configured nodes are available

Just downloaded and installed elasticsearch 1.3.2 in past hour Opened IP tables to port 9200 and 9300:9400 Set my computer name and ip in /etc/hosts Head Module and Paramedic Installed and running smoothly curl on localhost works flawlessy copie...

to_string is not a member of std, says g++ (mingw)

I am making a small vocabulary remembering program where words would would be flashed at me randomly for meanings. I want to use standard C++ library as Bjarne Stroustroup tells us, but I have encountered a seemingly strange problem right out of the ...

How to determine whether a given Linux is 32 bit or 64 bit?

When I type uname -a, it gives the following output. Linux mars 2.6.9-67.0.15.ELsmp #1 SMP Tue Apr 22 13:50:33 EDT 2008 i686 i686 i386 GNU/Linux How can I know from this that the given OS is 32 or 64 bit? This is useful when writing configure scr...

In MySQL, can I copy one row to insert into the same table?

insert into table select * from table where primarykey=1 I just want to copy one row to insert into the same table (i.e., I want to duplicate an existing row in the table) but I want to do this without having to list all the columns after the "sele...

Split a vector into chunks

I have to split a vector into n chunks of equal size in R. I couldn't find any base function to do that. Also Google didn't get me anywhere. Here is what I came up with so far; x <- 1:10 n <- 3 chunk <- function(x,n) split(x, factor(sort(ran...

How to open a link in new tab using angular?

I have an angular 5 component that needs to open a link in new tab, I tried the following: <a href="www.example.com" target="_blank">page link</a> when I open the link, the application gets slow and opens a route like: localhost:4200/...

sorting a vector of structs

I have a vector<data> info where data is defined as: struct data{ string word; int number; }; I need to sort info by the length of the word strings. Is there a quick and simple way to do it?...

Android: How to programmatically access the device serial number shown in the AVD manager (API Version 8)

How do I programmatically access the value shown in the image below ? ...

Select folder dialog WPF

I develop a WPF4 application and in my app I need to let the user select a folder where the application will store something (files, generated reports etc.). My requirements: Ability to see the standard folder tree Ability to select a folder WPF l...

How to round down to nearest integer in MySQL?

How would I round down to the nearest integer in MySQL? Example: 12345.7344 rounds to 12345 mysql's round() function rounds up. I don't know how long the values nor the decimal places will be, could be 10 digits with 4 decimal places, could be 2 ...

How to get a time zone from a location using latitude and longitude coordinates?

Given the latitude and longitude of a location, how does one know what time zone is in effect in that location? In most cases, we are looking for an IANA/Olson time zone id, although some services may return just a UTC offset, or some other time zone...

Border Radius of Table is not working

I want to add a border radius around the entire table. But the following code is not working in both the latest versions of Firefox and Google Chrome. HTML <table class="bordered"> <thead> <tr> <th>&l...

SQL Server Insert Example

I switch between Oracle and SQL Server occasionally, and often forget how to do some of the most trivial tasks in SQL Server. I want to manually insert a row of data into a SQL Server database table using SQL. What is the easiest way to do that? Fo...

Find duplicate records in a table using SQL Server

I am validating a table which has a transaction level data of an eCommerce site and find the exact errors. I want your help to find duplicate records in a 50 column table on SQL Server. Suppose my data is: OrderNo shoppername amountpayed city Item...

How to set the initial zoom/width for a webview

I am trying to get the WebView to have similar behavior as the android browser. The browser opens all pages in a way that tries to fit their width to the screen. However, the default behavior of the WebView is to start at a 100% pixel scale so it s...

Convert char to int in C and C++

How do I convert a char to an int in C and C++?...

Can I make a <button> not submit a form?

I've got a form, with 2 buttons <a href="index.html"><button>Cancel changes</button></a> <button type="submit">Submit</button> I use jQuery UI's button on them too, simply like this $('button').button(); How...

Android Studio Rendering Problems : The following classes could not be found

I just update Android Studio, and when I restarted it, the preview window rendering failed, and I was told that The following classes could not be found: - android.support.v7.internal.widget.ActionBarOverlayLayout If someone can tell me wha...

No module named Image

Sorry for my grammar, I don't speak English. After I set filebrowser, tinymce, and grappelli, I get this error: No module named Image try: from PIL import Image except ImportError: import Image I set it to PIL but it didn't solve the probl...

PHP salt and hash SHA256 for login password

I've made encrypting of the password in my register script and they are stored in the database, and I have to use them to login, so I would want to use the unencrypted ones to login. I've read some of the threads in here but nothing is helping me. Ho...

View more than one project/solution in Visual Studio

I am new to visual studio and I am experimenting around with some Windows Services. I have created two solutions and I would like to view both of them at once. Without having to click file->recent projects to switch back and forth. Ideally this coul...

Rails 4: List of available datatypes

Where can I find a list of data types that can be used in Ruby on Rails 4? Such as text string integer float date I keep learning about new ones and I'd love to have a list I could easily refer to....

How to apply two CSS classes to a single element

Can i apply 2 classes to a single div or span or any html element? For example: <a class="c1" class="c2">aa</a> I tried and in my case c2 does not get applied. How can i apply both classes at once?...

jQuery append() vs appendChild()

Here's some sample code: function addTextNode(){ var newtext = document.createTextNode(" Some text added dynamically. "); var para = document.getElementById("p1"); para.appendChild(newtext); $("#p1").append("HI"); } <div style="...

gcc: undefined reference to

I would like to compile this. program.c #include <libavcodec/avcodec.h> int main(){ int i = avpicture_get_size(AV_PIX_FMT_RGB24,300,300); } Running this gcc -I$HOME/ffmpeg/include program.c gives error /tmp/ccxMLBme.o: In function...

Differences between Lodash and Underscore.js

Why would someone prefer either the Lodash or Underscore.js utility library over the other? Lodash seems to be a drop-in replacement for underscore, the latter having been around longer. I think both are brilliant, but I do not know enough about how ...

Java optional parameters

How do I use optional parameters in Java? What specification supports optional parameters?...

PHP class: Global variable as property in class

I have a global variable outside my class = $MyNumber; How do I declare this as a property in myClass? For every method in my class, this is what I do: class myClass() { private function foo() { $privateNumber = $GLOBALS['MyNumber'];...

How to combine class and ID in CSS selector?

If I have the following div: <div class="sectionA" id="content"> Lorem Ipsum... </div> Is there a way to define a style that expresses the idea "A div with id='content' AND class='myClass'"? Or do you have simply go one way or the...

Refer to a cell in another worksheet by referencing the current worksheet's name?

I plan to have a workbook with 24 sheets. The sheet names will be: Jan, Jan item, Feb, Feb item, etc. Basically it's for budgeting, with the month named sheet having summary info, and the ones with "item" in the name having more detailed info. Now...

How do I stop/start a scheduled task on a remote computer programmatically?

I want to write a script that will stop a scheduled task on a remote computer, do some stuff, and then start the schedule task back up. How can I do it?...

What characters do I need to escape in XML documents?

What characters must be escaped in XML documents, or where could I find such a list?...

How to switch to another domain and get-aduser

I am on a server under the DomainA. I can use Get-ADUser and it's working fine. Now there is a trust built between DomainA and DomainB. I would like to switch to DomainB and get all the users that's in OU=New Users, DC=DomainB, DC=com. I tried thes...

Postgresql column reference "id" is ambiguous

I tried the following select: SELECT (id,name) FROM v_groups vg inner join people2v_groups p2vg on vg.id = p2vg.v_group_id where p2vg.people_id =0; and I get the following error column reference id is ambiguous. Thing is if I try the same SELECT bu...

Try-catch speeding up my code?

I wrote some code for testing the impact of try-catch, but seeing some surprising results. static void Main(string[] args) { Thread.CurrentThread.Priority = ThreadPriority.Highest; Process.GetCurrentProcess().PriorityClass = ProcessPriorityC...

Reference to a non-shared member requires an object reference occurs when calling public sub

I have a Public Class "General" in which is a Public Sub "updateDynamics". When I attempt to reference it in the code-behind for a page like so: updateDynamics(get_prospect.dynamicsID) I get the following error: reference to a non-shared membe...

Set element focus in angular way

After looking for examples of how set focus elements with angular, I saw that most of them use some variable to watch for then set focus, and most of them use one different variable for each field they want to set focus. In a form, with a lot of fiel...

How to set background image of a view?

I am a beginner at Obj-C/Cocoa Touch/iPhone OS. I wish to have a background for my app with different images everytime the the view is called. Say I have 10 images. I 've used it like this: //random image generation NSString* imageName; int aRando...

How to add app icon within phonegap projects?

I created a new phonegap (v 3.0.0-0.14.0) project with default config.xml and then added iOS and Android platforms. The config contains all the paths to all platform icons. I have overwritten the default icons for iOS and Android so that path and n...

Get human readable version of file size?

A function to return human readable size from bytes size: >>> human_readable(2048) '2 kilobytes' >>> How to do this?...

How to access model hasMany Relation with where condition?

I created a model Game using a condition / constraint for a relation as follows: class Game extends Eloquent { // many more stuff here // relation without any constraints ...works fine public function videos() { return $this-...

Open button in new window?

How would I go about making the button open in a new window, emulating "a href, target = _blank"? I currently have: <button class="button" onClick="window.location.href='http://www.example.com';"> <span class="icon">Open</span&...

Set UILabel line spacing

How can I modify the gap between lines (line spacing) in a multiline UILabel?...

How do I alter the position of a column in a PostgreSQL database table?

I've tried the following, but I was unsuccessful: ALTER TABLE person ALTER COLUMN dob POSITION 37; ...

Optimistic vs. Pessimistic locking

I understand the differences between optimistic and pessimistic locking. Now could someone explain to me when I would use either one in general? And does the answer to this question change depending on whether or not I'm using a stored procedure to...

How to use \n new line in VB msgbox() ...?

What is the alternative to \n (for new line) in a VB.NET MsgBox()?...

How can I "reset" an Arduino board?

I've uploaded a sketch to an Arduino Uno whose loop is something like this: void loop(){ Serial.println("Hello, World!"); } So, now, I can't upload anything anymore, because the IDE says "port already in use". Is there a way to "reset" the Ar...

Why is Maven downloading the maven-metadata.xml every time?

Below is the error I usually get when my internet connection is flanky when trying to build a web application with maven. My question is that, why does maven always have to download every time when the same app has been built earlier. What could ...

isPrime Function for Python Language

So I was able to solve this problem with a little bit of help from the internet and this is what I got: def isPrime(n): for i in range(2,int(n**0.5)+1): if n%i==0: return False return True But my question really ...

How to implement Rate It feature in Android App

I am developing an Android App. In which everything is working right. My app is ready to launch. But there I need to implement one more feature. I need to display a popup that contains Rate It and Remind me later Here if any user rates the app in the...

implementing merge sort in C++

I have studied the theory of the merge sort but don't have any idea of how to implement it in C++. My question is, merge sort creates arrays in recursion. But when implementing, how do we create arrays in runtime? or what is the general approach for ...

Sorting data based on second column of a file

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

Pandas: Convert Timestamp to datetime.date

I have a pandas column of Timestamp data In [27]: train["Original_Quote_Date"][6] Out[27]: Timestamp('2013-12-25 00:00:00') How can check equivalence of these objects to datetime.date objects of the type datetime.date(2013, 12, 25) ...

ViewPager PagerAdapter not updating the View

I'm using the ViewPager from the compatibility library. I have succussfully got it displaying several views which I can page through. However, I'm having a hard time figuring out how to update the ViewPager with a new set of Views. I've tried all s...

Why do people use Heroku when AWS is present? What distinguishes Heroku from AWS?

I'm a beginner RoR programmer who's planning to deploy my app using Heroku. Word from my other advisor friends says that Heroku is really easy, good to use. The only problem is that I still have no idea what Heroku does... I've looked at their websi...

Passing string parameter in JavaScript function

I was trying to pass a string to a JavaScript function. As it's mentioned here - Pass a string parameter in an onclick function I'm using this simple code- <!DOCTYPE html> <html> <body> <script> name =...

ImportError: No module named tensorflow

Please help me with this error I have installed the tensorflow module on my server and below is it's information 15IT60R19@cpusrv-gpu-109:~$ pip show tensorflow Name: tensorflow Version: 1.0.0 Summary: TensorFlow helps the tensors flow Home-page: h...

jquery - fastest way to remove all rows from a very large table

I thought this might be a fast way to remove the contents of a very large table (3000 rows): $jq("tbody", myTable).remove(); But it's taking around five seconds to complete in firefox. Am I doing something dumb (aside from trying to load 3000 rows...

AngularJS error: 'argument 'FirstCtrl' is not a function, got undefined'

I noticed the same question was asked a few times here, I tried so solve it but nothing helps. I'm following this tutorial with the egghead videos. But when I get at the section of Controllers and Sharing data between controllers, I can't get it t...

how to get file path from sd card in android

hi all i have mp3 files in sd card. how to get file path of mp3 song from sd card. please assist me....

Is there an opposite of include? for Ruby Arrays?

I've got the following logic in my code: if [email protected]?(p.name) ... end @players is an array. Is there a method so I can avoid the !? Ideally, this snippet would be: if @players.does_not_include?(p.name) ... end ...

Rails Object to hash

I have the following object that has been created @post = Post.create(:name => 'test', :post_number => 20, :active => true) Once this is saved, I want to be able to get the object back to a hash, e.g. by doing somthing like: @object.to_h...

Apache SSL Configuration Error (SSL Connection Error)

I'm trying to configure Apache on my server to work with ssl, but everytime I visit my site, I get the following message in my browser: SSL connection error. Unable to make a secure connection to the server. This may be a problem with the server, or...

Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

I installed MySQL community server 5.7.10 using binary zip. I extracted the zip in c:\mysql and created the data folder in c:\mysql\data. I created the config file as my.ini and placed it in c:\mysql (root folder of extracted zip). Below is the conte...

Are PHP Variables passed by value or by reference?

Are PHP variables passed by value or by reference?...

What's the difference between StaticResource and DynamicResource in WPF?

When using resources such as brushes, templates and styles in WPF, they can be specified either as StaticResources <Rectangle Fill="{StaticResource MyBrush}" /> or as a DynamicResource <ItemsControl ItemTemplate="{DynamicResource MyItem...

Google.com and clients1.google.com/generate_204

I was looking into google.com's Net activity in firebug just because I was curious and noticed a request was returning "204 No Content." It turns out that a 204 No Content "is primarily intended to allow input for actions to take place without causi...

Python error: AttributeError: 'module' object has no attribute

I'm totally new to Python and I know this question was asked many times, but unfortunately it seems that my situation is a bit different... I have created a package (or so I think). The catalog tree is like this: mydir lib (__init__.py) ...

remove double quotes from Json return data using Jquery

I use JQuery to get Json data, but the data it display has double quotes. It there a function to remove it? $('div#ListingData').text(JSON.stringify(data.data.items[0].links[1].caption)) it returns: "House" How can I remove the double quote? C...

What does the "@" symbol do in SQL?

I was browsing through the questions and noticed this: SELECT prodid, issue FROM Sales WHERE custid = @custid AND datesold = SELECT MAX(datesold) FROM Sales s WHERE s.prodid = Sales.prodid AND s.issue ...

AssertionError: View function mapping is overwriting an existing endpoint function: main

Does anyone know why I can't overwrite an existing endpoint function if i have two url rules like this app.add_url_rule('/', view_func=Main.as_view('main'), methods=["GET"]) app.add_url_rule('/<page>/', ...

Access an arbitrary element in a dictionary in Python

If a mydict is not empty, I access an arbitrary element as: mydict[mydict.keys()[0]] Is there any better way to do this?...

What is the best way to add options to a select from a JavaScript object with jQuery?

What is the best method for adding options to a <select> from a JavaScript object using jQuery? I'm looking for something that I don't need a plugin to do, but I would also be interested in the plugins that are out there. This is what I did: ...

Error in file(file, "rt") : cannot open the connection

I'm new to R, and after researching this error extensively, I'm still not able to find a solution for it. Here's the code. I've checked my working directory, and made sure the files are in the right directory. Appreciate it. Thanks pollutantmean &l...

How to convert JTextField to String and String to JTextField?

How to convert JTextField to String and String to JTextField in Java?...

Python spacing and aligning strings

I am trying to add spacing to align text in between two strings vars without using " " to do so Trying to get the text to look like this, with the second column being aligned. Location: 10-10-10-10 Revision: 1 District: Tower ...

Where is database .bak file saved from SQL Server Management Studio?

I was trying to create a backup for my SQL Server Database using SQL Server Management Studio 2008 Express. I have created the backup but it is getting saved at some path which I am not able to find. I am saving it on my local HD and I checked in Pro...

how to find my angular version in my project?

I have setup the angular code on my local machine. I need to know the version of the angular that I am using in the project. how can I easily find it in cmd prompt?...

How do I iterate through the files in a directory in Java?

I need to get a list of all the files in a directory, including files in all the sub-directories. What is the standard way to accomplish directory iteration with Java?...

How to define the basic HTTP authentication using cURL correctly?

I'm learning Apigility (Apigility docu -> REST Service Tutorial) and trying to send a POST request with basic authentication via cURL: $ curl -X POST -i -H "Content-Type: application/hal+json" -H "Authorization: Basic YXBpdXNlcjphcGlwd2Q=" http://ap...

How can I plot a histogram such that the heights of the bars sum to 1 in matplotlib?

I'd like to plot a normalized histogram from a vector using matplotlib. I tried the following: plt.hist(myarray, normed=True) as well as: plt.hist(myarray, normed=1) but neither option produces a y-axis from [0, 1] such that the bar heights of...

How to hash a password

I'd like to store the hash of a password on the phone, but I'm not sure how to do it. I can only seem to find encryption methods. How should the password be hashed properly?...

How to print multiple lines of text with Python

If I wanted to print multiple lines of text in Python without typing print('') for every line, is there a way to do that? I'm using this for ASCII art. (Python 3.5.1)...

Netbeans installation doesn't find JDK

installing Netbeans 6.0.1 on my windows computer, I find this error: Even if I my enviroment variables seems to be ok, when executing: I rebooted my system, but the error persists. Does anybody know why?? Thans in advance...

Package opencv was not found in the pkg-config search path

I have installed OpenCV using the instructions in https://help.ubuntu.com/community/OpenCV $ sudo su $ sudo apt-get install build-essential $ sudo apt-get install libavformat-dev $ sudo apt-get install ffmpeg $ sudo apt-get install libcv2.3 libcvaux...

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

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

What is the difference between attribute and property?

These seem to mean the same thing. But what term is more appropriate in what context?...

"inconsistent use of tabs and spaces in indentation"

I'm trying to create an application in Python 3.2 and I use tabs all the time for indentation, but even the editor changes some of them into spaces and then print out "inconsistent use of tabs and spaces in indentation" when I try to run the program....

How to scroll to bottom in react?

I want to build a chat system and automatically scroll to the bottom when entering the window and when new messages come in. How do you automatically scroll to the bottom of a container in React?...

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

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

ReactJS - Does render get called any time "setState" is called?

Does React re-render all components and sub components every time setState() is called? If so, why? I thought the idea was that React only rendered as little as needed - when state changed. In the following simple example, both classes render again w...

Download file of any type in Asp.Net MVC using FileResult?

I've had it suggested to me that I should use FileResult to allow users to download files from my Asp.Net MVC application. But the only examples of this I can find always has to do with image files (specifying content type image/jpeg). But what if ...

Differences between strong and weak in Objective-C

I'm new to Obj-C, so my first question is: What are the differences between strong and weak in @property declarations of pointers to objects? Also, what does nonatomic mean?...

Removing an activity from the history stack

My app shows a signup activity the first time the user runs the app, looks like: ActivitySplashScreen (welcome to game, sign up for an account?) ActivitySplashScreenSignUp (great, fill in this info) ActivityGameMain (main game screen) so the acti...

Command prompt won't change directory to another drive

I'm trying to compile some java (learning java currently), and to do so I need to change command-prompt's directory (using javac). C:\...\Admin> cd D:\Docs\Java C:\...\Admin> cd C:\...\Admin It doesn't change the directory. I try again using...

Twitter-Bootstrap-2 logo image on top of navbar

Can someone suggest how I can place a logo image on the top of the navbar? My markup: <body> <a href="index.html"> <img src="images/57x57x300.jpg"></a> <div class="navbar navbar-fixed-top"> <div cla...

Replace only some groups with Regex

Let's suppose I have the following regex: -(\d+)- and I want to replace, using C#, the Group 1 (\d+) with AA, to obtain: -AA- Now I'm replacing it using: var text = "example-123-example"; var pattern = @"-(\d+)-"; var replaced = Regex.Replace(...

How to enable NSZombie in Xcode?

I have an app that is crashing with no error tracing. I can see part of what is going on if I debug, but can't figure out which object is "zombie-ing". Does anybody know how to enable NSZombie in Xcode 4?...

How can I align the columns of tables in Bash?

I'd like to output a table format text. What I tried to do was echo the elements of an array with '\t', but it was misaligned. My code for((i=0;i<array_size;i++)); do echo stringarray[$i] $'\t' numberarray[$i] $'\t' anotherfieldarray[$i] done...

Remove local git tags that are no longer on the remote repository

We use tags in git as part of our deployment process. From time to time, we want to clean up these tags by removing them from our remote repository. This is pretty straightforward. One user deletes the local tag and the remote tag in one set of co...

Text that shows an underline on hover

Can you underline a text on hover using css? (Like the behavior of a link but not an actual link.) you have the following text Hello work when you hover your mouse over the text it underlines it using css (the text is not a link)...

Log all queries in mysql

Is it possible for me to turn on audit logging on my mysql database? I basically want to monitor all queries for an hour, and dump the log to a file....

Setting up PostgreSQL ODBC on Windows

I have the latest 64 bit version of PostgreSQL. I am running Win 7 64 bit. I had installed the ODBC driver (via the initial installer) when I installed PG, and upgraded it to the latest version from http://www.postgresql.org/ftp/odbc/versions/msi/. ...

How do I make a fully statically linked .exe with Visual Studio Express 2005?

My current preferred C++ environment is the free and largely excellent Microsoft Visual Studio 2005 Express edition. From time to time I have sent release .exe files to other people with pleasing results. However recently I made the disturbing discov...

HTTP Headers for File Downloads

I've written a PHP script that handles file downloads, determining which file is being requested and setting the proper HTTP headers to trigger the browser to actually download the file (rather than displaying it in the browser). I now have a proble...

How to find row number of a value in R code

In the following set of values how can I find the row number of a particular value in column 4 ?? For example how can I find the row number of the value "1578" that's in column number 4 using the R code commands. > mydata_2 sex age height_sec...

How to search through all Git and Mercurial commits in the repository for a certain string?

I have a Git repository with few branches and dangling commits. I would like to search all such commits in repository for a specific string. I know how to get a log of all commits in history, but these don't include branches or dangling blobs, just ...

Check if file exists and whether it contains a specific string

I want to check if file2.sh exists and also if a specific word, poet is part of the file. I use grep to create the variable used_var. #!/bin/ksh file_name=/home/file2.sh used_var=`grep "poet" $file_name` How can I check if u...

How are Anonymous inner classes used in Java?

What is the use of anonymous classes in Java? Can we say that usage of anonymous class is one of the advantages of Java?...

Proper way to restrict text input values (e.g. only numbers)

Is it possible to implement an input that allows to type only numbers inside without manual handling of event.target.value? In React, it is possible to define value property and afterwards input change will be basically bound to the value (not possi...

How to validate IP address in Python?

What's the best way to validate that an IP entered by the user is valid? It comes in as a string....

How can I pad an integer with zeros on the left?

How do you left pad an int with zeros when converting to a String in java? I'm basically looking to pad out integers up to 9999 with leading zeros (e.g. 1 = 0001)....

I need to round a float to two decimal places in Java

Possible Duplicate: How to round a number to n decimal places in Java I am having difficulties rounding a float to two decimal places. I have tried a few methods I have seen on here including simply just using Math.round(), but no matter ...

Fork() function in C

Below is an example of the Fork function in action. Below is also the output. My main question has to to do with the a fork is called how values are changed. So pid1,2 and 3 start off at 0 and get changed as the forks happen. Is this because each tim...

DB2 Date format

I just want to format current date into yyyymmdd in DB2. I see the date formats available, but how can I use them? http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2z10.doc.intro%2Fsrc%2Ftpc%2Fdb2z_datetimetimesta...

Is there a simple way to remove unused dependencies from a maven pom.xml?

I have a large Maven project with many modules and many pom.xml files. The project has changed and I suspect the pom's contain some unnecessary dependencies. Is there is a command which removes any unused dependencies from a pom? ...

What is the difference between char array and char pointer in C?

I am trying to understand pointers in C but I am currently confused with the following: char *p = "hello" This is a char pointer pointing at the character array, starting at h. char p[] = "hello" This is an array that stores hello. What is th...

What's the purpose of the LEA instruction?

For me, it just seems like a funky MOV. What's its purpose and when should I use it?...

Allow anonymous authentication for a single folder in web.config?

So here is the scenario, I have an Asp.Net application that is using a custom authentication & membership provider but we need to allow completely anonymous access (i.e.) to a particular folder within the application. In IIS manager, you can set...

Loop through checkboxes and count each one checked or unchecked

I've run into a bit of an issue. Here's a brief explanation. I have 12 check boxes on a standard form. What I need to do is loop through each of them and learn which ones are checked and which ones are unchecked. Using this, I can then build a str...

How to delete all data from solr and hbase

How do I delete all data from solr by command? We are using solr with lily and hbase. How can I delete data from both hbase and solr? http://lucene.apache.org/solr/4_10_0/tutorial.html#Deleting+Data...

Use a list of values to select rows from a pandas dataframe

Lets say I have the following pandas dataframe: df = DataFrame({'A' : [5,6,3,4], 'B' : [1,2,3, 5]}) df A B 0 5 1 1 6 2 2 3 3 3 4 5 I can subset based on a specific value: x = df[df['A'] == 3] x A B 2 3 3 ...

How to compare different branches in Visual Studio Code

How do I compare different branches in Visual Studio Code 1.9? Is it possible?...

How to clear APC cache entries?

I need to clear all APC cache entries when I deploy a new version of the site. APC.php has a button for clearing all opcode caches, but I don't see buttons for clearing all User Entries, or all System Entries, or all Per-Directory Entries. Is it pos...

Before and After Suite execution hook in jUnit 4.x

I'm trying to preform setup and teardown for a set of integration tests, using jUnit 4.4 to execute the tests. The teardown needs to be run reliably. I'm having other problems with TestNG, so I'm looking to port back to jUnit. What hooks are availabl...

Moment JS start and end of given month

I need to calculate a JS date given year=2014 and month=9 (September 2014). I tried this: var moment = require('moment'); var startDate = moment( year+'-'+month+'-'+01 + ' 00:00:00' ); var endDate = startDate.endOf('month'); ...

How can I get a precise time, for example in milliseconds in Objective-C?

Is there an easy way to get a time very precisely? I need to calculate some delays between method calls. More specifically, I want to calculate the speed of scrolling in an UIScrollView....

Change value in a cell based on value in another cell

Searched for this but could not find a way to do it. I would like to be able to transform a value in one cell to another value in a different cell like this: When cells in Column A contain Y set same number cells in Column B to Male or when cells...

What is the syntax of the enhanced for loop in Java?

I have been asked to use the enhanced for loop in my coding. I have only been taught how to use traditional for loops, and as such don't know about the differences between it and the enhanced for loop. How does an enhanced for loop differ from a ...

Import regular CSS file in SCSS file?

Is there anyway to import a regular CSS file with Sass's @import command? While I'm not using all of the SCSS syntax from sass, I do still enjoy it's combining/compressing features, and would like to be able to use it without renaming all of my files...

.NET unique object identifier

Is there a way of getting a unique identifier of an instance? GetHashCode() is the same for the two references pointing to the same instance. However, two different instances can (quite easily) get the same hash code: Hashtable hashCodesSeen = new ...

Where can I find a list of escape characters required for my JSON ajax return type?

I have an ASP.NET MVC action that is returning a JSON object. The JSON: {status: "1", message:"", output:"<div class="c1"><div class="c2">User generated text, so can be anything</div></div>"} Currently my HTML is breaking ...

android - listview get item view by position

I have listview with custom adapter (base adapter). I want to get view from listview by position. I tried mListView.getChildAt(position) , but it is not working. How can i get item view by position?...

Getting unique values in Excel by using formulas only

Do you know a way in Excel to "calculate" by formula a list of unique values ? E.g: a vertical range contains values "red", "blue", "red", "green", "blue", "black" and I want to have as result "red, "blue", "green", "black" + eventually 2 other bla...

AngularJS ng-click stopPropagation

I have a click Event on a table row and in this row there is also a delete Button with a click Event. When i click the delete button the click Event on the row is also fired. Here is my code. <tbody> <tr ng-repeat="user in users" class=...

Find the directory part (minus the filename) of a full path in access 97

For various reasons, I'm stuck in Access 97 and need to get only the path part of a full pathname. For example, the name c:\whatever dir\another dir\stuff.mdb should become c:\whatever dir\another dir\ This site has some suggestions on how to ...

Biggest differences of Thrift vs Protocol Buffers?

What are the biggest pros and cons of Apache Thrift vs Google's Protocol Buffers?...

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

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

Unable to Build using MAVEN with ERROR - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile

I have been trying to build a code using maven. But I am stuck with an error. The code is available on this github repo. google-play-crawler My system configurations as shown by maven is followning: Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe...

Which JRE am I using?

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

How do I get a div to float to the bottom of its container?

I have floated images and inset boxes at the top of a container using float:right (or left) many times. Recently I hit a need to float a div at the bottom right corner of another div with the normal text wrap that you get with float (text wrapped abo...

How do I POST XML data to a webservice with Postman?

I want POST an XML request to a webservice using Postman. However, when I check the available request formats, I only see options for form-data, x-www-form-urlencoded, raw, and binary. How do I POST an XML request to a webservice with Postman?...

How do I avoid the "#DIV/0!" error in Google docs spreadsheet?

I have a column with average(K23:M23) that starts out with #DIV/0! when the K23 through M23 cells are empty. Preferably I'd like to only do the average of cells that contain non-zero, non-blank values. I think it's possible using the query command: ...

When should one use a spinlock instead of mutex?

I think both are doing the same job,how do you decide which one to use for synchronization?...

How to set div width using ng-style

I am trying to set the div width dynamically using ng-style but it is not applying the style. Here is the code: <div style="width: 100%;" id="container_fform" ng-controller="custController"> <div style="width: 250px;overflow: scroll;"&g...

COLLATION 'utf8_general_ci' is not valid for CHARACTER SET 'latin1'

I am trying to fix a character encoding issue - previously we had the collation set for this column utf8_general_ci which caused issues because it is accent insensitive.. I'm trying to find all the entries in the database that could have been affect...

How to add multiple columns to pandas dataframe in one assignment?

I'm new to pandas and trying to figure out how to add multiple columns to pandas simultaneously. Any help here is appreciated. Ideally I would like to do this in one step rather than multiple repeated steps... import pandas as pd df = {'col_1': [...

Bootstrap button drop-down inside responsive table not visible because of scroll

I have a problem with drop-down buttons inside tables when are responsive and scroll active because the drop-down is not visible because of overflow: auto; property. How can I fix that in order to show drop-down option of button when this is collapse...

How to remove all characters after a specific character in python?

I have a string. How do I remove all text after a certain character? (In this case ...) The text after will ... change so I that's why I want to remove all characters after a certain one....

Javascript "Not a Constructor" Exception while creating objects

I am defining an object like this: function Project(Attributes, ProjectWidth, ProjectHeight) { this.ProjectHeight = ProjectHeight; this.ProjectWidth = ProjectWidth; this.ProjectScale = this.GetProjectScale(); this.Attributes = Attrib...

libxml install error using pip

This is my error: (mysite)zjm1126@zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install lxml Downloading/unpacking lxml Running setup.py egg_info for package lxml Building lxml version 2.3. Building without Cython. ERROR: /bin/sh: xslt-confi...

jQuery scrollTop not working in Chrome but working in Firefox

I have used a scrollTop function in jQuery for navigating to top, but strangely 'the smooth animated scroll' stopped working in Safari and Chrome (scrolling without smooth animation) after I made some changes. But it is still working smoothly in Fi...

slideToggle JQuery right to left

i'm new in JQ i have this script i found on the internet and its do exactly what i need but i want the sliding will be from the right to the left how can i do it? please help this is the code <script src="http://ajax.googleapis.com/ajax/libs/jqu...

How can I detect the touch event of an UIImageView?

I have placed an image (UIImageView) on the navigation bar. Now I want to detect the touch event and want to handle the event. How can I do that?...

Read text file into string. C++ ifstream

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

How to normalize a signal to zero mean and unit variance?

I am new to MATLAB and I am trying to built a voice morphing system using MATLAB. So I would like to know how to normalize a signal to zero mean and unit variance using MATLAB?...

Cause of No suitable driver found for

I'm trying to unit test (JUnit) a DAO i've created. I'm using Spring as my framework, my DAO (JdbcPackageDAO) extends SimpleJdbcDaoSupport. The testing class (JdbcPackageDAOTest) extends AbstractTransactionalDataSourceSpringContextTests. I've over...

How to get the instance id from within an ec2 instance?

How can I find out the instance id of an ec2 instance from within the ec2 instance?...

How to run script as another user without password?

I have script.sh that must be run as user2. However, this script can only be run under user1 in my application. I would like the following command to run: su user2 -C script.sh but be able to run without password. I also want this to be very re...

filename and line number of Python script

How can I get the file name and line number in a Python script? Exactly the file information we get from an exception traceback. In this case without raising an exception....

How to change active class while click to another link in bootstrap use jquery?

I have a html as sidebar, and use Bootstrap. <ul class="nav nav-list"> <li class="active"><a href="/">Link 1</a></li> <li><a href="/link2">Link 2</a></li> <li><a href="/link3...

Python convert decimal to hex

I have a function here that converts decimal to hex but it prints it in reverse order. How would I fix it? def ChangeHex(n): if (n < 0): print(0) elif (n<=1): print(n) else: x =(n%16) if (x < 10):...

Where can I read the Console output in Visual Studio 2015

I am new to C# and downloaded the free version of Microsoft Visual Studio 2015. To write a first program, I created a Windows Forms Application. Now I use Console.Out.WriteLine() to print some test data. But where can I read the console?...

Using NOT operator in IF conditions

Is it really a good practice to avoid using NOT operator in IF conditions in order to make your code better readable? I heard the if (doSomething()) is better then if (!doSomething())....

ORACLE convert number to string

Need some help in converting numbers: select to_char(a, '99D99') , to_char(a, '90D99') from ( select 50 a from dual union select 50.57 from dual union select 5.57 from dual union select 0.35 from dual union select 0.4 from dual Will result ...

filedialog, tkinter and opening files

I'm working for the first time on coding a Browse button for a program in Python3. I've been searching the internet and this site, and even python standard library. I have found sample code and very superficial explanations of things, but I haven't ...

How to find the statistical mode?

In R, mean() and median() are standard functions which do what you'd expect. mode() tells you the internal storage mode of the object, not the value that occurs the most in its argument. But is there is a standard library function that implements th...

Deserialize JSON to Array or List with HTTPClient .ReadAsAsync using .NET 4.0 Task pattern

I'm trying to deserialize the JSON returned from http://api.usa.gov/jobs/search.json?query=nursing+jobs using the .NET 4.0 Task pattern. It returns this JSON ('Load JSON data' @ http://jsonviewer.stack.hu/). [ { "id": "usajobs:353400300", ...

ip address validation in python using regex

In the following ip address validation i want to see if it a valid ip address or not how can i do this using the below re >>> ip="241.1.1.112343434" >>> aa=re.match(r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}[^0-9]",ip) >>> aa.g...

Differences between hard real-time, soft real-time, and firm real-time?

I have read the definitions for the different notions of real-time, and the examples provided for hard and soft real-time systems make sense to me. But, there is no real explanation or example of a firm real-time system. According to the link above: ...

Vim: insert the same characters across multiple lines

Sometimes I want to edit a certain visual block of text across multiple lines. For example, I would take a text that looks like this: name comment phone email And make it look like this vendor_name vendor_comment vendor_phone vendor_email Curr...

Exception : AAPT2 error: check logs for details

Task :processDebugResources Failed to execute aapt com.android.ide.common.process.ProcessException: Failed to execute aapt at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796) at com.android.build.gradle.tasks....

How to get htaccess to work on MAMP

I am trying to get the .htaccess working in MAMP. The content of the .htaccess is a simple redirect line but it does not work. I am trying to manipulate URLs of a WordPress page, so I added the .htaccess file in my theme folder, but it is not workin...

Are multiple `.gitignore`s frowned on?

Unless a repo consisted of several independent projects, it seems it would be simplest to just have one .gitignore file at the root of the repo than various ones throughout. Is there a standard best practice on this or some analysis online of when o...

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

In Postgresql, force unique on combination of two columns

I would like to set up a table in PostgreSQL such that two columns together must be unique. There can be multiple values of either value, so long as there are not two that share both. For instance: CREATE TABLE someTable ( id int PRIMARY KEY A...

What is the purpose for using OPTION(MAXDOP 1) in SQL Server?

I have never clearly understood the usage of MAXDOP. I do know that it makes the query faster and that it is the last item that I can use for Query Optimization. However, my question is, when and where it is best suited to use in a query?...

Import Python Script Into Another?

I'm going through Zed Shaw's Learn Python The Hard Way and I'm on lesson 26. In this lesson we have to fix some code, and the code calls functions from another script. He says that we don't have to import them to pass the test, but I'm curious as to ...

Localhost : 404 not found

I am using XAMPP. and internal server of Django. When I browse to localhost or 127.0.0.1, It shows Not Found . HTTP Error 404. The requested resource is not found. It sometimes works fine and other times pops up the error. Moreover, when I browse ...

file_get_contents behind a proxy?

At work we have to use a proxy to basically access port 80 for example, we have our own custom logins for each user. My temporary workaround is using curl to basically login as myself through a proxy and access the external data I need. Is there so...

How to check if an item is selected from an HTML drop down list?

I have a drop drown list and I am having trouble checking whether or not a value has been selected from the drop down list Below is my HTML Code : <label class="paylabel" for="cardtype">Card Type:</label> <select id="cardtype" name="...

How do I escape a reserved word in Oracle?

In TSQL I could use something like Select [table] from tablename to select a column named "table". How do I do this for reserved words in oracle? Edit: I've tried square braces, double quotes, single quotes, and backquotes, they don't work... As ...

Omitting all xsi and xsd namespaces when serializing an object in .NET?

The code looks like this: StringBuilder builder = new StringBuilder(); XmlWriterSettings settings = new XmlWriterSettings(); settings.OmitXmlDeclaration = true; using (XmlWriter xmlWriter = XmlWriter.Create(builder, settings)) { XmlSerializer s...

Error retrieving parent for item: No resource found that matches the given name '@android:style/TextAppearance.Holo.Widget.ActionBar.Title'

I am implementing ActionBar to set the color for text using this style script in xml but getting error when I run my application time does anybody have idea what I have missing this is my style.xml file <!-- Start with the Holographic Light them...

Creating a constant Dictionary in C#

What is the most efficient way to create a constant (never changes at runtime) mapping of strings to ints? I've tried using a const Dictionary, but that didn't work out. I could implement a immutable wrapper with appropriate semantics, but that s...

How can I write to the console in PHP?

Is it possible write a string or log into the console? What I mean Just like in JSP, if we print something like system.out.println("some"), it will be there at the console, not at a page....

Uncaught TypeError: Cannot set property 'value' of null

I'm trying to pass the entered text to the controller using an ajax request. But i'm getting athe error "Uncaught TypeError: Cannot set property 'value' of null " when I tried to execute JS file.. Here is the HTMLcode: <form action=""> &...

Connection Strings for Entity Framework

I want to share same Database information across multiple entities in Silverlight.. but I want the connection string to be named xyz and have everyone access that connection string from machine.config... The meta data part of the entities will be ...

jQuery If value is NaN

I am having some trouble with an if statement. I want to set num to 0 of NaN: $('input').keyup(function() { var tal = $(this).val(); var num = $(this).data('boks'); if(isNaN(tal)) { var tal = 0; } }); ...

How to convert timestamps to dates in Bash?

I need a shell command or script that converts a Unix timestamp to a date. The input can come either from the first parameter or from stdin, allowing for the following usage patterns: ts2date 1267619929 and echo 1267619929 | ts2date Both comman...

How do I pass variables and data from PHP to JavaScript?

I have a variable in PHP, and I need its value in my JavaScript code. How can I get my variable from PHP to JavaScript? I have code that looks like this: <?php ... $val = $myService->getValue(); // Makes an API and database call ?&g...

Python - How to convert JSON File to Dataframe

How can I convert a JSON File as such into a dataframe to do some transformations. For Example if the JSON file reads: {"FirstName":"John", "LastName":"Mark", "MiddleName":"Lewis", "username":"johnlewis2", "password":"2910"} How can I conve...

How to download a folder from github?

I wished to download the mysite folder from this link: https://github.com/username/repository/master/...

How to convert Excel values into buckets?

I have a set of data in Excel and in one column is a estimate (number of weeks) I want an Excel formula to bucket it into Small Medium Large where if the value is 0 - 10 then put it Small. If the value is 10 - 20 put it in Medium, etc . . . if...

What does it mean when a PostgreSQL process is "idle in transaction"?

What does it mean when a PostgreSQL process is "idle in transaction"? On a server that I'm looking at, the output of "ps ax | grep postgres" I see 9 PostgreSQL processes that look like the following: postgres: user db 127.0.0.1(55658) idle in trans...

Entity Framework Query for inner join

What would be the query for: select s.* from Service s inner join ServiceAssignment sa on sa.ServiceId = s.Id where sa.LocationId = 1 in entity framework? This is what I wrote: var serv = (from s in db.Services join sl in Loca...

Failing to run jar file from command line: “no main manifest attribute”

I am trying to run a jar file from the console: java -jar ScrumTimeCaptureMaintenence.jar And am getting the error: Can't execute jar- file: “no main manifest attribute” As you can see I do in fact have a main file and it runs fine from ...

How can I change the version of npm using nvm?

I've been using NVM to install the latest versions of nodeJS for my node work. It works totally fine for installing separate versions and switching between them. It also installs the latest version of NPM within each local .../bin folder along with t...

adb connection over tcp not working now

I was trying to use adb over TCP/IP. I have followed these steps adb tcpip 5555 adb connect 194.68.0.100:5555 I have used my device for 2 days and now I am unable to connect to my IP address like when I do adb tcpip 5555 it doesn't respond any...

How to use JQuery with ReactJS

I'm new to ReactJS. Previously I've used jQuery to set any animation or feature that I needed. But now I'm trying to use ReactJS and minimize the use of jQuery. My Case is: I'm trying to build an accordion with ReactJS. <div class="accor"> ...

How do I query using fields inside the new PostgreSQL JSON datatype?

I am looking for some docs and/or examples for the new JSON functions in PostgreSQL 9.2. Specifically, given a series of JSON records: [ {name: "Toby", occupation: "Software Engineer"}, {name: "Zaphod", occupation: "Galactic President"} ] Ho...

SQL Statement with multiple SETs and WHEREs

I am wondering if this is a valid query: UPDATE table SET ID = 111111259 WHERE ID = 2555 AND SET ID = 111111261 WHERE ID = 2724 AND SET ID = 111111263 WHERE ID = 2021 AND SET ID = 111111264 WHERE ID = 2017 ...

Is it possible to CONTINUE a loop from an exception?

I have a fetch being executed inside of a loop. If this fetch fails (no data) I would like to CONTINUE the loop to the next record from within the EXCEPTION. Is this possible? I'm getting a ORA-06550 & PLS-00201 identifer CONTINUE must be decl...

I want to multiply two columns in a pandas DataFrame and add the result into a new column

I'm trying to multiply two existing columns in a pandas Dataframe (orders_df) - Prices (stock close price) and Amount (stock quantities) and add the calculation to a new column called 'Value'. For some reason when I run this code, all the rows under ...

Excel tab sheet names vs. Visual Basic sheet names

It seems that Visual Basic can not reference sheets according to user-modified sheet names. The worksheet tabs can have their names changed, but it seems that Visual Basic still thinks of the worksheet names as Sheet1, etc., despite the workbook tab ...

How to combine GROUP BY and ROW_NUMBER?

I hope following sample code is self-explanatory: declare @t1 table (ID int,Price money, Name varchar(10)) declare @t2 table (ID int,Orders int, Name varchar(10)) declare @relation table (t1ID int,t2ID int) insert into @t1 values(1, 200, 'AAA'); i...

Rendering HTML inside textarea

I need to be able to render some HTML tags inside a textarea (namely <strong>, <i>, <u>, <a>) but textareas only interpret their content as text. Is there an easy way of doing it without relying on external libraries/plugins (...

subsampling every nth entry in a numpy array

I am a beginner with numpy, and I am trying to extract some data from a long numpy array. What I need to do is start from a defined position in my array, and then subsample every nth data point from that position, until the end of my array. basical...

How to make external HTTP requests with Node.js

The question is fairly simple. I want to use a Node.js server as a proxy to log, authenticate, and forward HTTP queries to a backend HTTP server (PUT, GET, and DELETE requests). What library should I use for that purpose? I'm afraid I can't find one...

How to change a nullable column to not nullable in a Rails migration?

I created a date column in a previous migration and set it to be nullable. Now I want to change it to be not nullable. How do I go about doing this assuming there are null rows in that database? I'm ok with setting those columns to Time.now if they'r...

Using TortoiseSVN how do I merge changes from the trunk to a branch and vice versa?

I've been reading up on branching/merging with Subversion 1.5 using the excellent and free Version Control with Subversion book. I think that I understand how to use the Subversion command line client to perform the actions that I need most often, w...

Xcode error: Code signing is required for product type 'Application' in SDK 'iOS 10.0'

I have Xcode 8 installed on OS X El Capitan. I get this error: Signing for "target" requires a development team. Select a development team in the project editor. Code signing is required for product type 'Application' in SDK 'iOS 10.0' ...

Iterate through Nested JavaScript Objects

I'm trying to iterate through a nested object to retrieve a specific object identified by a string. In the sample object below, the identifier string is the "label" property. I can't wrap my head around how to iterate down through the tree to return ...

Mount current directory as a volume in Docker on Windows 10

Description I am using Docker version 1.12.5 on Windows 10 via Hyper-V and want to use container executables as commands in the current path. I built a Docker image that is running fine, but I have a problem to mount the current path. The idea is to...

Error in finding last used cell in Excel with VBA

When I want to find the last used cell value, I use: Dim LastRow As Long LastRow = Range("E4:E48").End(xlDown).Row Debug.Print LastRow I'm getting the wrong output when I put a single element into a cell. But when I put more than one val...

WCF Service , how to increase the timeout?

Might seem like a silly question, but everything in WCF seems a lot more complicated than in asmx, how can I increase the timeout of an svc service? Here is what I have so far: <bindings> <basicHttpBinding> <binding nam...

How to write specific CSS for mozilla, chrome and IE

What would be the CSS conditional statement you can use to include specific CSS for IE, Mozilla, Chrome. If IE #container { top: 5px; } If Mozilla #container { top: 7px; } If Chrome #container { top: 9px; } What would be the respect...

SASS and @font-face

I have the following CSS - how would I describe it in SASS? I've tried reverse compiling it with css2sass, and just keep getting errors.... is it my CSS (which works ;-) )? @font-face { font-family: 'bingo'; src: url("bingo.eot"); src: loc...

ORA-12505: TNS:listener does not currently know of SID given in connect descriptor (DBD ERROR: OCIServerAttach)

I created a Windows 2003 R2 Virtual Machine running on VirtualBox and I installed Oracle (10201_database_win32). I assigned a static IP on the Virtual Ethernet too. Everything worked great right after installation. I listed(lsnrctl services) the ...

"for line in..." results in UnicodeDecodeError: 'utf-8' codec can't decode byte

Here is my code, for line in open('u.item'): # Read each line Whenever I run this code it gives the following error: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 2892: invalid continuation byte I tried to solve this and add...

Angular ng-click with call to a controller function not working

I need to pass a variable to another controller. I have the following code which is related to the ListCtrl : <a href="#items" data-router="article" ng-click="changeListName('metro')"> The link is going to another controller, ItemCtrl. I wa...

How to join three table by laravel eloquent model

I have three table Articles table id title body categories_id user_id Categories table id category_name User table id user_name user_type I want to show articles with their category name instead of category_id and user_name inst...

Change language of Visual Studio 2017 RC

I have installed Visual Studio 2017 RC, and by default it set language to my system language (Polish) so I was trying to change it to EN but in Options > Environment > International Settings i have only Polish language. There is link to "download mor...

How can I get the height of an element using css only

We have a lot of options to get the height of an element using jQuery and JavaScript. But how can we get the height using CSS only? Suppose, I have a div with dynamic content - so it does not have a fixed height: _x000D_ _x000D_ .dynamic-height {_...

SQL Server using wildcard within IN

Since I believe this should be a basic question I know this question has probably been asked, but I am unable to find it. I'm probably about to earn my Peer Pressure badge, but I'll ask anyway: Is there a way in SQL Server that I am not aware of for...

Mismatched anonymous define() module

I'm getting this error when I browse my webapp for the first time (usually in a browser with disabled cache). Error: Mismatched anonymous define() module: function (require) { HTML: <html> . . . <script src="//ajax.googlea...

Get current batchfile directory

Firstly, I saw this topic but I couldn't understand that. Question : There is a batch file in D:\path\to\file.bat with following content : echo %cd% pause Output is : C:\ It must be D:\path\to What am I doing wrong?...

How do I link a JavaScript file to a HTML file?

How do you properly link a JavaScript file to a HTML document? Secondly, how do you use jQuery within a JavaScript file?...

5.7.57 SMTP - Client was not authenticated to send anonymous mail during MAIL FROM error

I have to send mails using my web application. Given the below code showing The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous ma...

Accessing Google Account Id /username via Android

How do you access the user's Google Account Id / username in code? I am building an application that will call a web service to store data and I want to identify the identity of the person submitting the data....

Maven project version inheritance - do I have to specify the parent version?

I have two projects: Parent project: A, Sub project: B A/pom.xml: <groupId>com.dummy.bla</groupId> <artifactId>parent</artifactId> <version>0.1-SNAPSHOT</version> <packaging>pom</packaging> And in B...

Send a base64 image in HTML email

Using a rich-text editor, our users can drag and drop a saved image from their desktop to the editor. The image appears and displays properly in the web page after they submit. Since the image is not uploaded anywhere, the editor saves the image as ...

JSON and XML comparison

I want to know which is faster: XML and JSON? When to use which one ?...

How do I install a module globally using npm?

I recently installed Node.js and npm module on OSX and have a problem with the settings I think: npm install [MODULE] is not installing the node.js module to the default path which is /usr/local/lib/node_modules. ...

scale Image in an UIButton to AspectFit?

I want to add an image to a UIButton, and also want to scale my image to fit with the UIButton (make image smaller). Please show me how to do it. This is what I have tried, but it does't work: Adding image to button and using setContentMode: [...

How to prevent form resubmission when page is refreshed (F5 / CTRL+R)

I have a simple form that submits text to my SQL table. The problem is that after the user submits the text, they can refresh the page and the data gets submitted again without filling the form again. I could redirect the user to another page after t...

Using Git with Visual Studio

As a long-time Visual SourceSafe user (and hater) I was discussing switching to SVN with a colleague; he suggested using Git instead. Since, apparently, it can be used as peer-to-peer without a central server (we are a 3-developer team). I have not...

Python: BeautifulSoup - get an attribute value based on the name attribute

I want to print an attribute value based on its name, take for example <META NAME="City" content="Austin"> I want to do something like this soup = BeautifulSoup(f) //f is some HTML containing the above meta tag for meta_tag in soup('meta'):...

Jupyter notebook not running code. Stuck on In [*]

My code was running fine before I did not change anything and I ran it again. Now it doesn't return anything not even an error. It is just stuck on "In [*]". ...

Set up git to pull and push all branches

I'd like to push and pull all the branches by default, including the newly created ones. Is there a setting that I can define for it? Otherwise, when I add a new branch, locally and I want to pull it from the server, what is the simplest way to do ...

Synchronously waiting for an async operation, and why does Wait() freeze the program here

Preface: I'm looking for an explanation, not just a solution. I already know the solution. Despite having spent several days studying MSDN articles about the Task-based Asynchronous Pattern (TAP), async and await, I'm still a bit confused about some...

Simulator or Emulator? What is the difference?

While I understand what simulation and emulation mean in general, I almost always get confused about them. Assume that I create a piece of software that mimics existing hardware/software, what should I call it? A simulator or an emulator? Could anyo...

angular 2 sort and filter

In Angularjs 1 it is possible to sort and filter the following way: <ul ng-repeat="friend in friends | filter:query | orderBy: 'name' "> <li>{{friend.name}}</li> </ul> But I could not find any examples of how to do this ...

Error C1083: Cannot open include file: 'stdafx.h'

When I compiled this program (from C++ Programming Language 4th edition): main.cpp #include <stdafx.h> #include <iostream> #include <cmath> #include "vector.h" using namespace std; double sqrt_sum(vector&); int _tmain(int ar...

How to install XNA game studio on Visual Studio 2012?

Is it possible to create XNA games using Visual Studio 2012?...

Try reinstalling `node-sass` on node 0.12?

I would like to use google web starter kit. I installed node.js v0.12.0, node-sass & gulp. And then ran: $ sudo npm install When I typed gulp serve then got this error: Using gulpfile ~/web-starter-kit/gulpfile.js Starting 'styles'... 'style...

What is the difference between children and childNodes in JavaScript?

I have found myself using JavaScript and I ran across childNodes and children properties. I am wondering what the difference between them is. Also is one preferred to the other?...

What is a callback URL in relation to an API?

I've been scouring the net, and can't seem to wrap my head around the idea of a callback URL. In my case I have a few callback URLs that I have to define myself. A popular one is a "default callback URL". What is this exactly? Can you give an example...

HTML5 Video not working in IE 11

I have a video archive that I have working in everything except IE 11. I get the error "Error: Unsupported video type or invalid file path" when loaded in IE 11. Below is the HTML I am using. <video id="movie" width="640" height="400" autobuffer ...

Git Bash is extremely slow on Windows 7 x64

I've been using Git on both Windows and Ubuntu during the development of a small project, frequently flipping back and forth between the two. The issue is that Git Bash consistently becomes slow. When I say slow, I mean that running cd takes anywher...

How can I quickly sum all numbers in a file?

I have a file which contains several thousand numbers, each on it's own line: 34 42 11 6 2 99 ... I'm looking to write a script which will print the sum of all numbers in the file. I've got a solution, but it's not very efficient. (It takes severa...

What does "for" attribute do in HTML <label> tag?

I wonder what is the difference between the following two code snippets: <label>Input here : </label> <input type='text' name='theinput' id='theinput'/> and <label for='theinput'>Input here : </label> <input type='te...

How to view the contents of an Android APK file?

Is there a way to extract and view the content of an .apk file?...

Response.Redirect with POST instead of Get?

We have the requirement to take a form submission and save some data, then redirect the user to a page offsite, but in redirecting, we need to "submit" a form with POST, not GET. I was hoping there was an easy way to accomplish this, but I'm startin...

Lombok added but getters and setters not recognized in Intellij IDEA

I am using IntelliJ IDEA on ubuntu. I added lombok.jar into my project and installed the Lombok plugin for IDEA. I have access to the annotations but the getters and setters aren't generated. I get the same errors I would get if I tried accessing a g...

Disable all gcc warnings

I'm working on a project that will read compiler error messages of a particular variety and do useful things with them. The sample codebase I'm testing this on (a random open-source application), and hence rebuilding frequently, contains a few bits t...

Automated way to convert XML files to SQL database?

We have a bunch of XML files, following a schema which is essentially a serialised database form: <table1> <column1>value</column1> <column2>value</column2> </table1> <table1> <column1>another...

What is the python keyword "with" used for?

What is the python keyword "with" used for? Example from: http://docs.python.org/tutorial/inputoutput.html >>> with open('/tmp/workfile', 'r') as f: ... read_data = f.read() >>> f.closed True ...

Round a double to 2 decimal places

If the value is 200.3456, it should be formatted to 200.34. If it is 200, then it should be 200.00....

Reading From A Text File - Batch

I have a text file, a.txt: Hello World Good Afternoon I have written a batch script to read contents of this file line by line: FOR /F "tokens=* delims=" %%x in (a.txt) DO echo %%x I am getting output as "Hello" "World" due to default beh...

Looping through all the properties of object php

How can I loop through all the properties of object?. Right now I have to write a new code line to print each property of object echo $obj->name; echo $obj->age; Can I loop through all the properties of an object using foreach loop or any lo...

Hibernate Error: a different object with the same identifier value was already associated with the session

I essentially have some objects in this configuration (the real data model is a bit more complex): A has a many-to-many relationship with B. (B has inverse="true") B has a many-to-one relationship with C. (I have cascade set to "save-update") C is ...

How to replace local branch with remote branch entirely in Git?

I have two branches: local branch (the one which I work with) remote branch (public, only well-tested commits go there) Recently I seriously messed up my local branch. How would I replace the local branch entirely with the remote one, so I can c...

get list of pandas dataframe columns based on data type

If I have a dataframe with the following columns: 1. NAME object 2. On_Time object 3. On_Budget object 4. %actual_hr ...

Change a branch name in a Git repo

How do I rename an existing branch in a Git repo? I want the current branch to have a new name....

How do I store the select column in a variable?

How do I store the select column in a variable? I tried this, but it throws me an error "Incorrect syntax": declare @EmpId int SELECT dbo.Employee.Id as @EmpId FROM dbo.Employee ...

Is it possible to iterate through JSONArray?

Possible Duplicates: JSON Array iteration in Android/Java JSONArray with Java Is it possible to iterate through JSONArray object using Iterator?...

Powershell folder size of folders without listing Subdirectories

I have found several resources that use the following script to get folder sizes $colItems = (Get-ChildItem $startFolder -recurse | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object) foreach ($i in $colItems) { $subFolderItems = (G...

How can I add an image file into json object?

I want to add an image file into json object . Is it possible to add image file into json object? I tried below code but its not working ? Because i want to send that json object to the server then server will read my image file and store into that ...