Examples On Programing Languages

How do I detach objects in Entity Framework Code First?

There is no Detach(object entity) on the DbContext. Do I have the ability to detach objects on EF code first?...

Downcasting in Java

Upcasting is allowed in Java, however downcasting gives a compile error. The compile error can be removed by adding a cast but would anyway break at the runtime. In this case why Java allows downcasting if it cannot be executed at the runtime? Is...

How to escape special characters in building a JSON string?

Here is my string { 'user': { 'name': 'abc', 'fx': { 'message': { 'color': 'red' }, 'user': { 'color': 'blue' } } }, 'timestamp': '2...

Get attribute name value of <input>

How to get the attribute name value of a input tag using jQuery. Please help. <input name='xxxxx' value=1> ...

How can I force Python's file.write() to use the same newline format in Windows as in Linux ("\r\n" vs. "\n")?

I have the simple code: f = open('out.txt','w') f.write('line1\n') f.write('line2') f.close() Code runs on windows and gives file size 12 bytes, and linux gives 11 bytes The reason is new line In linux it's \n and for win it is \r\n But in my co...

The content type application/xml;charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8)

I trying to consume a WCF web service using stand alone application. I am able to view this service using Internet Explorer also able to view in Visual studio service references. This is the error I am getting The content type text/html; charset=U...

Best XML Parser for PHP

I have used the XML Parser before, and even though it worked OK, I wasn't happy with it in general, it felt like I was using workarounds for things that should be basic functionality. I recently saw SimpleXML but I haven't tried it yet. Is it any si...

"webxml attribute is required" error in Maven

I am getting the following error: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) I have got web.xml in right place which is projectname\src\main\webapp\WEB-INF\web.xml What cou...

Found conflicts between different versions of the same dependent assembly that could not be resolved

When I clean and then build my solution that has several projects, the output window reports that the build succeeded. However, when I view the Error List Window, it shows me this warning: Found conflicts between different versions of the same de...

How to add option to select list in jQuery

My select list is called dropListBuilding. The following code does not seem to work: for (var i = 0; i < buildings.length; i++) { var val = buildings[i]; var text = buildings[i]; alert("value of builing at: " + i.toString() + " is...

How to Run the Procedure?

Here the Package.. CREATE OR REPLACE PACKAGE G_PKG_REFCUR AS TYPE rcDataCursor IS REF CURSOR; END; Let's consider the PROC.. Create procedure gokul_proc( pId in number, pName in varchar2, OutCur OUT G_PKG_REFCUR.rcDataCursor ) is ...

How to read all of Inputstream in Server Socket JAVA

I am using Java.net at one of my project. and I wrote a App Server that gets inputStream from a client. But some times my (buffered)InputStream can not get all of OutputStream that client sent to my server. How can I write a wait or some thing like t...

How to delete all rows from all tables in a SQL Server database?

How to delete all rows from all tables in a SQL Server database?...

How do I format a String in an email so Outlook will print the line breaks?

I'm trying to send an email in Java but when I read the body of the email in Outlook, it's gotten rid of all my linebreaks. I'm putting \n at the ends of the lines but is there something special I need to do other than that? The receivers are always ...

Insert Data Into Temp Table with Query

I have an existing query that outputs current data, and I would like to insert it into a Temp table, but am having some issues doing so. Would anybody have some insight on how to do this? Here is an example SELECT * FROM (SELECT Received, ...

SQlite - Android - Foreign key syntax

I've been trying to get foreign keys working within my Android SQLite database. I have tried the following syntax but it gives me a force close: private static final String TASK_TABLE_CREATE = "create table " + TASK_TABLE + " (" + TASK_I...

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

"UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure." when plotting figure with pyplot on Pycharm

I am trying to plot a simple graph using pyplot, e.g.: import matplotlib.pyplot as plt plt.plot([1,2,3],[5,7,4]) plt.show() but the figure does not appear and I get the following message: UserWarning: Matplotlib is currently using agg, which is a...

Best way to randomize an array with .NET

What is the best way to randomize an array of strings with .NET? My array contains about 500 strings and I'd like to create a new Array with the same strings but in a random order. Please include a C# example in your answer....

jQuery AJAX cross domain

Here are two pages, test.php and testserver.php. test.php <script src="scripts/jq.js" type="text/javascript"></script> <script> $(function() { $.ajax({url:"testserver.php", success:function() { ...

Access to build environment variables from a groovy script in a Jenkins build step (Windows)

I'm using Scriptler plugin, so I can run a groovy script as a build step. My Jenkins slaves are running on windows in service mode. With scriptler, I don't need to use windows batch scripts. But I have trouble to get the environment variables in a b...

Check if a file exists locally using JavaScript only

I want to check if a file exists locally, where the HTML file is located. It has to be JavaScript. JavaScript will never be disabled. jQuery is not good but can do. By the way, I am making a titanium app for Mac so I am looking for a way of protecti...

install apt-get on linux Red Hat server

I'm setting up a Linux Red Hat web server. apt-get isn't installed, but yum is. However, yum cannot find the apt package. When I run apt-get, I get a message from the shell saying that the command apt-get couldn't be found. When I try yum install ap...

Truncate a string straight JavaScript

I'd like to truncate a dynamically loaded string using straight JavaScript. It's a url, so there are no spaces, and I obviously don't care about word boundaries, just characters. Here's what I got: var pathname = document.referrer; //wont work i...

Facebook api: (#4) Application request limit reached

Since late November we are hitting the application limit on the Facebook API. We are fetching user's photos, and selected 25 friends photos ? this is done when a user signatures in (we are building albums for the users). The above action is limited,...

Delete all rows with timestamp older than x days

I want to delete all the rows with timestamp older than 180 days from a specific table in my database. I've tried the this: DELETE FROM on_search WHERE search_date < DATE_SUB(NOW(), INTERVAL 180 DAY); But that deleted all the rows and not only...

How to stop java process gracefully?

How do I stop a Java process gracefully in Linux and Windows? When does Runtime.getRuntime().addShutdownHook get called, and when does it not? What about finalizers, do they help here? Can I send some sort of signal to a Java process from a shell?...

Why does LayoutInflater ignore the layout_width and layout_height layout parameters I've specified?

I've had severe trouble getting LayoutInflater to work as expected, and so did other people: How to use layoutinflator to add views at runtime?. Why does LayoutInflater ignore the layout parameters I've specified? E.g. why are the layout_width and l...

How to write a file or data to an S3 object using boto3

In boto 2, you can write to an S3 object using these methods: Key.set_contents_from_string() Key.set_contents_from_file() Key.set_contents_from_filename() Key.set_contents_from_stream() Is there a boto 3 equivalent? What is the boto3 method for s...

ALTER COLUMN in sqlite

How do I alter column in sqlite? This is in Postgresql ALTER TABLE books_book ALTER COLUMN publication_date DROP NOT NULL; I believe there is no ALTER COLUMN in sqlite at all, only ALTER TABLE is supported. Any idea? Thanks!...

Application not picking up .css file (flask/python)

I am rendering a template, that I am attempting to style with an external style sheet. File structure is as follows. /app - app_runner.py /services - app.py /templates - mainpage.html /styles - mainpage.css ...

C++ Boost: undefined reference to boost::system::generic_category()

I am trying to include Boost libraries in my project and have been facing issues in the same. I am on Ubuntu 12.10 with Codeblocks IDE and tried installing the libraries manually reading instructions from the site, but was getting error's with header...

React.js: onChange event for contentEditable

How do I listen to change event for contentEditable-based control? var Number = React.createClass({ render: function() { return <div> <span contentEditable={true} onChange={this.onChange}> {this.st...

ERROR 1049 (42000): Unknown database

I can't seem to login to my tutorial database development environment: Ayman$ mysql -u blog -p blog_development Enter password: ERROR 1049 (42000): Unknown database 'blog_development' I can login to the database fine without the blog_development...

How to force delete a file?

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. How can i force Windows XP to d...

List all environment variables from the command line

Is it possible to list all environment variables from a Windows' command prompt? Something equivalent to PowerShell's gci env: (or ls env: or dir env:)....

Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6

When trying to run the Example CorDapp (GitHub CorDapp) via IntelliJ, I receive the following error: Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 How can I modify the IntelliJ settings so th...

What static analysis tools are available for C#?

What tools are there available for static analysis against C# code? I know about FxCop and StyleCop. Are there others? I've run across NStatic before but it's been in development for what seems like forever - it's looking pretty slick from what littl...

jQuery keypress() event not firing?

I am trying to fire an event on the right and left arrow key presses with jQuery. Using the following code, I can fire events on any of the alphanumeric keys, but the cursor keys (up, down, left, right) fire nothing. I am developing the site primaril...

How to pass a PHP variable using the URL

I want to pass some PHP variables using the URL. I tried the following code: link.php <html> <body> <?php $a='Link1'; $b='Link2'; echo '<a href="pass.php?link=$a">Link 1</a>'; echo '<br/>'; echo '<a href="pass....

Get all dates between two dates in SQL Server

How to get all the dates between two dates? I have a variable @MAXDATE which is storing the maximum date from the table. Now I want to get the all dates between @Maxdate and GETDATE() and want to store these dates in a cursor. So far I have done as f...

How to get history on react-router v4?

I having some little issue migrating from React-Router v3 to v4. in v3 I was able to do this anywhere: import { browserHistory } from 'react-router'; browserHistory.push('/some/path'); How do I achieve this in v4. I know that I could use, the hoc...

Amazon Linux: apt-get: command not found

I'm trying to install an apache server on my AWS instance, however, it seems that it doesn't have the apt package installed. I googled and all I found was some broken links to this package. I am using Putty on a windows machine if that information h...

Proper usage of .net MVC Html.CheckBoxFor

All I want to know is the proper syntax for the Html.CheckBoxFor HTML helper in ASP.NET MVC. What I'm trying to accomplish is for the check-box to be initially checked with an ID value so I can reference it in the Controller to see if it's still che...

CSS/HTML: Create a glowing border around an Input Field

I want to create some decent inputs for my form, and I would really like to know how TWITTER does their glowing border around their inputs. Example/Picture of the Twitter border: I also don't quite know how to create the rounded corners....

jQuery Ajax simple call

I'm trying a basic ajax call. So I'm hosting the following test php on a test server: http://voicebunny.comeze.com/index.php?numberOfWords=10 This web page is my own test that is already integrated to the VoiceBunny API http://voicebunny.com/deve...

How to use both onclick and target="_blank"

Code is as following: <p class="downloadBoks" onclick="location.href='Prosjektplan.pdf'">Prosjektbeskrivelse</p> Works fine like this, but it opens the file in the same window. I want to apply the target="_blank". But after some go...

How to set time to a date object in java

I created a Date object in Java. When I do so, it shows something like: date=Tue Aug 09 00:00:00 IST 2011. As a result, it appears that my Excel file is lesser by one day (27 feb becomes 26 feb and so on) I think it must be because of time. How can I...

Laravel - check if Ajax request

I have been trying to find a way to determine ajax call in Laravel but i don't find any document regarding it. I have a index() function which i want to handle situation differently based on the nature of request. Basically this is a resource contro...

JavaScript error (Uncaught SyntaxError: Unexpected end of input)

I have some JavaScript code that works in FireFox but not in Chrome or IE. In the Chrome JS Console I get the follow error: "Uncaught SyntaxError: Unexpected end of input". The JavaScript code I am using is: <script> $(function() { ...

How can I tell what edition of SQL Server runs on the machine?

I am running SQL Server 2005 but I am unsure which edition this is. How can I decide what edition (Express, Standard, Enterprise etc) is running on the machine? ...

Calling the base class constructor from the derived class constructor

I have a question: Say I have originally these classes which I can't change (let's say because they're taken from a library which I'm using): class Animal_ { public: Animal_(); int getIdA() { return idA; }; string getNameA...

Error 1022 - Can't write; duplicate key in table

I'm getting a 1022 error regarding duplicate keys on create table command. Having looked at the query, I can't understand where the duplication is taking place. Can anyone else see it? SQL query: -- ------------------------------------------------...

How to update TypeScript to latest version with npm?

Currently I have TypeScript 1.0.3.0 version installed on my machine. I want to update it to latest one i.e. 2.0. How to do this with npm?...

jQuery Validation plugin: validate check box

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

Get the key corresponding to the minimum value within a dictionary

If I have a Python dictionary, how do I get the key to the entry which contains the minimum value? I was thinking about something to do with the min() function... Given the input: {320:1, 321:0, 322:3} It would return 321....

asp.net mvc3 return raw html to view

Are there other ways I can return raw html from controller? As opposed to just using viewbag. like below: public class HomeController : Controller { public ActionResult Index() { ViewBag.HtmlOutput = "<HTML></HTML>"; ...

how to pass data in an hidden field from one jsp page to another?

I have some data in an hidden field on a jsp page <input type=hidden id="thisField" name="inputName"> how to access or pass this field onsubmit to another page?...

How do I get bit-by-bit data from an integer value in C?

I want to extract bits of a decimal number. For example, 7 is binary 0111, and I want to get 0 1 1 1 all bits stored in bool. How can I do so? OK, a loop is not a good option, can I do something else for this?...

Get value from text area

How to get value from the textarea field when it's not equal "". I tried this code, but when I enter text into textarea the alert() isn't works. How to fix it? <textarea name="textarea" placeholder="Enter the text..."></textarea> $(doc...

How do I pass the this context to a function?

I thought this would be something I could easily google, but maybe I'm not asking the right question... How do I set whatever "this" refers to in a given javascript function? for example, like with most of jQuery's functions such as: $(selector)...

add allow_url_fopen to my php.ini using .htaccess

I want to allow allow_url_fopen on my server . I have asked my host and they said it can be done with a .htaccess file. Can anyone tell me how to go about this ?...

How to make spring inject value into a static field

I know this may looks like a previously asked question but I'm facing a different problem here. I have a utility class that has only static methods. I don't and I won't take an instance from it. public class Utils{ private static Properties dat...

redirect to current page in ASP.Net

How can I perform a redirect with Server.Transfer() to the same page that is currently shown? I want to have A cleared form after submit. What other/better methods can I use to achieve the same?...

How can I turn a JSONArray into a JSONObject?

Basically I have: JSONArray j = new JSONArray(); j.add(new JSONObject()); //JSONObject has a bunch of data in it j.add(new JSONArray()); //JSONArray has a bunch of data in it And now I would like to turn that JSONArray into a JSONObject with the ...

Changing image on hover with CSS/HTML

I have this problem where I have set an image to display another image when the mouse hovers over, however the first image still appears and the new one doesn't change height and width and overlaps the other one. I'm still pretty new to HTML/CSS so I...

How can I check for NaN values?

float('nan') results in Nan (not a number). But how do I check for it? Should be very easy, but I cannot find it....

Set variable in jinja

I would like to know how can I set a variable with another variable in jinja. I will explain, I have got a submenu and I would like show which link is active. I tried this: {% set active_link = {{recordtype}} -%} where recordtype is a variable giv...

how to include glyphicons in bootstrap 3

I've not used any of the bootstrap frameworks before. I want to include some of the glyphicons in bootstrap 3 on my page. From what I understand they should be included in a bootstrap.css file which I've added to my page. When I've looked in the boot...

Display a loading bar before the entire page is loaded

I would like to display a loading bar before the entire page is loaded. For now, I'm just using a small delay: $(document).ready(function(){ $('#page').fadeIn(2000); }); The page already uses jQuery. Note: I have tried this, but it didn't work f...

How to restore a SQL Server 2012 database to SQL Server 2008 R2?

I am trying to restore the backup taken from a SQL Server 2012 to SQL Server 2008 R2, and it giving an error Specified cast is not valid. (SqlManagerUI) If you have any solution to this please give comment thanks. ...

Git checkout - switching back to HEAD

I've been doing my project while at some point I discovered that one thing stopped working. I needed to look up the state of my code when it was working correctly, so I've decided to use git checkout (because I wanted to check-something-out). And so ...

OpenCV error: the function is not implemented

I'm trying to get OpenCV working with Python on my Ubuntu machine. I've downloaded and installed OpenCV, but when I attempt to run the following python code (which should capture images from a webcam and push them to the screen) import cv cv.Named...

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

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

need to test if sql query was successful

I have this query and if it returns successful, I want another function to process, if not, do not process that function. Here is the code for running the query global $DB; $DB->query("UPDATE exp_members SET group_id = '$group_id' WHERE member_i...

Pipe to/from the clipboard in Bash script

Is it possible to pipe to/from the clipboard in Bash? Whether it is piping to/from a device handle or using an auxiliary application, I can't find anything. For example, if /dev/clip was a device linking to the clipboard we could do: cat /dev/clip...

How to change the colors of a PNG image easily?

I have PNG images that represent playing-cards. They are the standard colours with Clubs and Spades being blank and Diamonds and Hearts being red. I want to create a 4-colour deck by converting the the Clubs to green and the Diamonds to blue. I don...

Creating new table with SELECT INTO in SQL

Possible Duplicate: SELECT INTO using Oracle I have came across SQL SELECT INTO statement for creating new table and also dumping old table records into new table in single SQL statement as SELECT * INTO NEW_TABLE FROM OLD_TABLE; But ...

Convert String to System.IO.Stream

I need to convert a String to System.IO.Stream type to pass to another method. I tried this unsuccessfully. Stream stream = new StringReader(contents); ...

How do I perform an IF...THEN in an SQL SELECT?

How do I perform an IF...THEN in an SQL SELECT statement? For example: SELECT IF(Obsolete = 'N' OR InStock = 'Y' ? 1 : 0) AS Saleable, * FROM Product ...

What is the best way to paginate results in SQL Server

What is the best way (performance wise) to paginate results in SQL Server 2000, 2005, 2008, 2012 if you also want to get the total number of results (before paginating)?...

How to increase heap size for jBoss server

I have an upload files scenario in my project. When I'm trying to upload the large files it's giving me an OutOfMemory error. That error is related to Java heap size. How can you increase the heap size in Java and which file do I need to alter for...

How to View Oracle Stored Procedure using SQLPlus?

How can I view the code of a stored procedure using sqlplus for Oracle 10g? When I type in: desc daily_update; it shows me the parameter, but when I try to do the following: select * from all_source where name = 'daily_update'; I get no ...

What Language is Used To Develop Using Unity

What language does one need to use when programming with Unity? Or is it an API for many languages? I read through the docs and I guess I missed the point on the language used. It says it has iOS deployment, would this still allow the programmer to...

How to get the browser to navigate to URL in JavaScript

What is the best (correct, modern, cross-browser, safe) way to get a web browser to navigate to a URL of your choice using JavaScript?...

Converting map to struct

I am trying to create a generic method in Go that will fill a struct using data from a map[string]interface{}. For example, the method signature and usage might look like: func FillStruct(data map[string]interface{}, result interface{}) { ... } ...

CSS - Syntax to select a class within an id

What is the selector syntax to select a tag within an id via the class name? For example, what do I need to select below in order to make the inner "li" turn red? <html> <head> <style type="text/css"> #navigation li ...

Has been blocked by CORS policy: Response to preflight request doesn’t pass access control check

I have created trip server. It works fine and we are able to make POST request by Insomnia but when we make POST request by axios on our front-end, it sends an error: has been blocked by CORS policy: Response to preflight request doesn’t pass acce...

MySQL Error 1153 - Got a packet bigger than 'max_allowed_packet' bytes

I'm importing a MySQL dump and getting the following error. $ mysql foo < foo.sql ERROR 1153 (08S01) at line 96: Got a packet bigger than 'max_allowed_packet' bytes Apparently there are attachments in the database, which makes for very large i...

How to replace � in a string

I have a string that contains a character � I haven't been able to replace it correctly. String.replace("�", ""); doesn't work, does anyone know how to remove/replace the � in the string?...

Get first element of Series without knowing the index

Is that any way that I can get first element of Seires without have information on index. For example,We have a Series import pandas as pd key='MCS096' SUBJECTS=pd.DataFrame({'ID':Series([146],index=[145]),\ 'study':S...

load Js file in HTML

My first PhoneGap application includes 2 HTML files. The first one is named index.html which uses index.js. This file will display a list item. When I click an item in that list, it brings me to detail.html file by this: $.mobile.changePage("de...

#1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation

Hello, I am currently having an issue with MySQL! What's going wrong here? I am a cPanel user, and yes I have searched this and found no definitive answers. It appears this is more specific than other people with the same error codes issues. Please ...

VB.Net Properties - Public Get, Private Set

I figured I would ask... but is there a way to have the Get part of a property available as public, but keep the set as private? Otherwise I am thinking I need two properties or a property and a method, just figured this would be cleaner....

How to add parameters into a WebRequest?

I need to call a method from a webservice, so I've written this code: private string urlPath = "http://xxx.xxx.xxx/manager/"; string request = urlPath + "index.php/org/get_org_form"; WebRequest webRequest = WebRequest.Create(request); webRequest...

Threading Example in Android

I want some simple example on thread creation and invoking of threads in android. ...

Why an interface can not implement another interface?

What I mean is: interface B {...} interface A extends B {...} // allowed interface A implements B {...} // not allowed I googled it and I found this: implements denotes defining an implementation for the methods of an interface. However in...

iPhone - Get Position of UIView within entire UIWindow

The position of a UIView can obviously be determined by view.center or view.frame etc. but this only returns the position of the UIView in relation to it's immediate superview. I need to determine the position of the UIView in the entire 320x480 co-...

SmtpException: Unable to read data from the transport connection: net_io_connectionclosed

I am using the SmtpClient library to send emails using the following: SmtpClient client = new SmtpClient(); client.Host = "hostname"; client.Port = 465; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client...

How to create a JavaScript callback for knowing when an image is loaded?

I want to know when an image has finished loading. Is there a way to do it with a callback? If not, is there a way to do it at all?...

How to merge two files line by line in Bash

I have two text files, each of them contains an information by line such like that file1.txt file2.txt ---------- --------- linef11 linef21 linef12 linef22 linef13 linef23 . ...

How to programmatically modify WCF app.config endpoint address setting?

I'd like to programmatically modify my app.config file to set which service file endpoint should be used. What is the best way to do this at runtime? For reference: <endpoint address="http://mydomain/MyService.svc" binding="wsHttpBinding" b...

Angular: Cannot Get /

I am trying to open, build and run someone else's Angular 4 project but I am not able to view the project when I run it my way. I don't see what is going wrong or what I should do now. I already had everything in place to use NPM and NodeJS The step...

Generating Unique Random Numbers in Java

I'm trying to get random numbers between 0 and 100. But I want them to be unique, not repeated in a sequence. For example if I got 5 numbers, they should be 82,12,53,64,32 and not 82,12,53,12,32 I used this, but it generates same numbers in a sequenc...

How to solve time out in phpmyadmin?

I want import huge (at least 300 mb) sql scripts via phpMyAdmin. I've tried: post_max_size = 750M upload_max_filesize = 750M max_execution_time = 300 max_input_time = 540 memory_limit = 1000M in my php.ini file, but I'm still getting timeout erro...

VS2010 command prompt gives error: Cannot determine the location of the VS Common Tools folder

I have installed VS2010. The installation creates the shortcut for VS2010 command prompt but when I open up the command prompt I get the error: Cannot determine the location of the VS Common Tools folder. I checked the environment variable VS10...

How to use the divide function in the query?

I want to show the percentage for the Overshipment column. My sample query select (SPGI09_EARLY_OVER_T – (SPGI09_OVER_WK_EARLY_ADJUST_T) / (SPGI09_EARLY_OVER_T + SPGR99_LATE_CM_T + SPGR99_ON_TIME_Q)) from CSPGI09_OVERSHIPMENT Table Name - CS...

Wrap text in <td> tag

I want to wrap some text that is added to a <td> element. I have tried with style="word-wrap: break-word;" width="15%". But it is not wrapping the text. Is it mandatory to give it 100% width? I have other controls to display so only 15% width i...

Java double.MAX_VALUE?

For my assignment I have to create a Gas Meter System for a Gas company to allow employees to create new costumer accounts and amend data such as name and unit costs along with taking(depositing) money from their account. I have created my construct...

Can I use a :before or :after pseudo-element on an input field?

I am trying to use the :after CSS pseudo-element on an input field, but it does not work. If I use it with a span, it works OK. <style type="text/css"> .mystyle:after {content:url(smiley.gif);} .mystyle {color:red;} </style> This work...

How do you say not equal to in Ruby?

This is a much simpler example to what I'm trying to do in my program but is the similar idea. In an if statement how do I say say not equal to? Is != correct? def test vara = 1 varb = 2 if vara == 1 && varb != 3 puts "correct" ...

JavaScript property access: dot notation vs. brackets?

Other than the obvious fact that the first form could use a variable and not just a string literal, is there any reason to use one over the other, and if so under which cases? In code: // Given: var foo = {'bar': 'baz'}; // Then var x = foo['bar']...

Double quotes within php script echo

I have a line of php code that looks like this: echo "<script>$('#edit_errors').html('<h3><em>Please Correct Errors Before Proceeding</em></h3>')</script>"; I would like to know how to add a font color to the te...

PL/SQL ORA-01422: exact fetch returns more than requested number of rows

I get keep getting this error I can't figure out what is wrong. DECLARE * ERROR at line 1: ORA-01422: exact fetch returns more than requested number of rows ORA-06512: at line 11 Here is my code. DECLARE rec_ENAME EMPLOYEE.ENAME%TY...

Pass multiple values with onClick in HTML link

Hi Im trying to pass multiple values with the HTML onclick function. Im using Javascript to create the Table var user = element.UserName; var valuationId = element.ValuationId; $('#ValuationAssignedTable').append('<tr> <td><a href=# o...

Purpose of #!/usr/bin/python3 shebang

I have noticed this in a couple of scripting languages, but in this example, I am using python. In many tutorials, they would start with #!/usr/bin/python3 on the first line. I don't understand why we have this. Shouldn't the operating system know ...

Pandas: Creating DataFrame from Series

My current code is shown below - I'm importing a MAT file and trying to create a DataFrame from variables within it: mat = loadmat(file_path) # load mat-file Variables = mat.keys() # identify variable names df = pd.DataFrame # Initialis...

jQuery fade out then fade in

There's a bunch on this topic, but I havn't found an instance that applies well to my situation. Fade a picture out and then fade another picture in. Instead, I'm running into an issue where the first fades out and immediately (before the animation ...

How to find largest objects in a SQL Server database?

How would I go about finding the largest objects in a SQL Server database? First, by determining which tables (and related indices) are the largest and then determining which rows in a particular table are largest (we're storing binary data in BLOBs...

How to get current url in view in asp.net core 1.0

In previous versions of asp.net, we could use @Request.Url.AbsoluteUri But it seems it's changed. How can we do that in asp.net core 1.0?...

How to resolve Unable to load authentication plugin 'caching_sha2_password' issue

In eclipse when i started my application i got this - Could not discover the dialect to use. java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'. at java.sql.SQLException: Unable to load authentication plugin 'ca...

What's the fastest way in Python to calculate cosine similarity given sparse matrix data?

Given a sparse matrix listing, what's the best way to calculate the cosine similarity between each of the columns (or rows) in the matrix? I would rather not iterate n-choose-two times. Say the input matrix is: A= [0 1 0 0 1 0 0 1 1 1 1 1 0 1 0]...

Export DataBase with MySQL Workbench with INSERT statements

I am trying to export the DataBase i have at MySQL Workbench but I am having troubles to generate the INSERT statements on the .sql file. I order to export the data, I do the reverse engineering for the database i want to export. Then, i go to ...

When is TCP option SO_LINGER (0) required?

I think I understand the formal meaning of the option. In some legacy code I'm handling now, the option is used. The customer complains about RST as response to FIN from its side on connection close from its side. I am not sure I can remove it safel...

How do you specifically order ggplot2 x axis instead of alphabetical order?

I'm trying to make a heatmap using ggplot2 using the geom_tiles function here is my code below: p<-ggplot(data,aes(Treatment,organisms))+geom_tile(aes(fill=S))+ scale_fill_gradient(low = "black",high = "red") + scale_x_discrete(expand = c(0,...

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'db'

I want to begin writing queries in MySQL. show grants shows: +--------------------------------------+ | Grants for @localhost | +--------------------------------------+ | GRANT USAGE ON *.* TO ''@'localhost' | +----------------------...

PHP - print all properties of an object

I have an unknown object in php page. How can I print/echo it, so I can see what properties/values do it have? What about functions? Is there any way to know what functions an object have?...

UDP vs TCP, how much faster is it?

For general protocol message exchange, which can tolerate some packet loss. How much more efficient is UDP over TCP?...

npm - EPERM: operation not permitted on Windows

I ran npm config set prefix /usr/local After running that command, When trying to run any npm commands on Windows OS I keep getting the below. Error: EPERM: operation not permitted, mkdir 'C:\Program Files (x86)\Git\local' at Error (native) H...

jQuery UI - Draggable is not a function?

I've trying to use the draggable effect on some divs on a page, but whenever I load the page, I get the error message: Error: $(".draggable").draggable is not a function I've had a look around it seemed other people were having this problem as the...

How do I check if a string contains another string in Swift?

In Objective-C the code to check for a substring in an NSString is: NSString *string = @"hello Swift"; NSRange textRange =[string rangeOfString:@"Swift"]; if(textRange.location != NSNotFound) { NSLog(@"exists"); } But how do I do this in Swif...

Move UIView up when the keyboard appears in iOS

I have a UIView, it is not inside UIScrollView. I would like to move up my View when the keyboard appears. Before I tried to use this solution: How can I make a UITextField move up when the keyboard is present?. It was working fine. But after insert...

Input Type image submit form value?

I am using this code to try and submit a value via form but it doesn't seem to submit anything... I would normally use a checkbox or Radio buttons for multiple options but I want to use an image to do this. Is this code wrong? <input id="test1"...

Tensorflow: Using Adam optimizer

I am experimenting with some simple models in tensorflow, including one that looks very similar to the first MNIST for ML Beginners example, but with a somewhat larger dimensionality. I am able to use the gradient descent optimizer with no problems, ...

Cannot create SSPI context

I am working on a .NET application where I am trying to build the database scripts. While building the project, I am getting an error "Cannot create SSPI context.". This error is shown in the output window (inside VS2008 screen) and the building proc...

How to use Selenium with Python?

How do I set up Selenium to work with Python? I just want to write/export scripts in Python, and then run them. Are there any resources for that? I tried googling, but the stuff I found was either referring to an outdated version of Selenium (RC), or...

What exactly does a jar file contain?

As an intern, I use company code in my projects and they usually send me a jar file to work with. I add it to the build path in Eclipse and usually all is fine and dandy. However, I got curious to know, what each class contained and when I try to op...

Rails - Could not find a JavaScript runtime?

I created a new Rails project using rails 3.1.0.rc4 on my local machine but when I try to start the server I get: Could not find a JavaScript runtime. See here for a list of available runtimes. (ExecJS::RuntimeUnavailable) Note: This is not about He...

How to work offline with TFS

Our TFS server has some temporary connectivity issues right now, and as such VS has gone unresponsive, leaving 50+ developers unable to work! Is it possible to switch TFS into an offline mode in the event of such an issue?...

Google Maps API OVER QUERY LIMIT per second limit

I am using Google Maps API to display about 50 locations on the map. I am using client side geocoding. I am using window.setTimeout to control the number of geocode requests that the application sends per second. If I send more than 1 request per sec...

How often should you use git-gc?

How often should you use git-gc? The manual page simply says: Users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance. Are there some commands to ...

Mapping US zip code to time zone

When users register with our app, we are able to infer their zip code when we validate them against a national database. What would be the best way to determine a good potential guess of their time zone from this zip code? We are trying to minimize...

Best way to access a control on another form in Windows Forms?

First off, this is a question about a desktop application using Windows Forms, not an ASP.NET question. I need to interact with controls on other forms. I am trying to access the controls by using, for example, the following... otherForm.Controls["...

Using Pandas to pd.read_excel() for multiple worksheets of the same workbook

I have a large spreadsheet file (.xlsx) that I'm processing using python pandas. It happens that I need data from two tabs in that large file. One of the tabs has a ton of data and the other is just a few square cells. When I use pd.read_excel() on ...

Android dex gives a BufferOverflowException when building

When compiling a specific Android project, and only on my Windows machine, I get a java.nio.BufferOverflowException during from dex. The problem occurs both when using Eclipse and when using Ant. The output when using Ant is: ... [dex] Pre-Dexing...

Get current category ID of the active page

Looking to pull the category ID of a specific page in WordPress that is listing all posts using that specific category. Tried the below but not working. I am able to get the category name using single_term_title. $category = single_term_title("", ...

Color picker utility (color pipette) in Ubuntu

I'am looking for a color picker utility on Ubuntu/Debian. Anything simple and easy to use....

Go: panic: runtime error: invalid memory address or nil pointer dereference

When running my Go program, it panics and returns the following: panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x38 pc=0x26df] goroutine 1 [running]: main.getBody(0x1cdcd4, 0xf800000004, 0x1f2b44,...

Command to get time in milliseconds

Is there a shell command in Linux to get the time in milliseconds?...

How to do one-liner if else statement?

Can I write a simple if-else statement with variable assignment in go (golang) as I would do in php? For example: $var = ( $a > $b )? $a: $b; Currently I have to use the following: var c int if a > b { c = a } else { c = b } Sorry I c...

What exactly does an #if 0 ..... #endif block do?

In C/C++ What happens to code placed between an #if 0/#endif block? #if 0 //Code goes here #endif Does the code simply get skipped and therefore does not get executed?...

How to set NODE_ENV to production/development in OS X

For use in express.js environments. Any suggestions?...

Why Response.Redirect causes System.Threading.ThreadAbortException?

When I use Response.Redirect(...) to redirect my form to a new page I get the error: A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll An exception of type 'System.Threading.ThreadAbortExcepti...

Jenkins: Is there any way to cleanup Jenkins workspace?

How can I cleanup the workspace in Jenkins? I am using AccuRev as version control tool. I created freestyle projects in Jenkins....

How to install the current version of Go in Ubuntu Precise

Running sudo apt-get install golang-stable, I get Go version go1.0.3. Is there any way to install go1.1.1?...

How can I remove file extension from a website address?

I am designing a website. I want my website address to look like the following image: I don't want my website to look like http://something.com/profile.php. I want the .php extension to be removed in the address bar when someone opens my website. ...

Modifying Objects within stream in Java8 while iterating

In Java8 streams, am I allowed to modify/update objects within? For eg. List<User> users: users.stream().forEach(u -> u.setProperty("value")) ...

How to run a script file remotely using SSH

I want to run a script remotely. But the system doesn't recognize the path. It complains that "no such file or directory". Am I using it right? ssh kev@server1 `./test/foo.sh` ...

How to fix Terminal not loading ~/.bashrc on OS X Lion

Whenever I open a new tab in Terminal using Cmd + T, it opens bash in the same directory, as the previous tab. This works fine when I'm in the ~ directory, but if I'm anywhere else, I get an error loading .bashrc Last login: Sat Oct 15 21:10:00 on t...

Delete last N characters from field in a SQL Server database

I have table of over 4 million rows and accidentally in one column there is more data than needed. For example instead of ABC there is ABC DEFG. How can I remove that N symbols using TSQL? Please note that I want to delete this characters from da...

Filling a List with all enum values in Java

I would like to fill a list with all possible values of an enum Since I recently fell in love with EnumSet, I leveraged allOf() EnumSet<Something> all = EnumSet.allOf( Something.class); List<Something> list = new ArrayList<>( all.s...

How can one develop iPhone apps in Java?

I was wondering if is it possible to develop iPhone applications using Java plus XMLV, which claims to cross-compile Java-based Android applications to native iPhone applications. Is XMLV a viable way to develop iPhone applications using Java? Here a...

Can you run GUI applications in a Docker container?

How can you run GUI applications in a Docker container? Are there any images that set up vncserver or something so that you can - for example - add an extra speedbump sandbox around say Firefox?...

Windows Task Scheduler doesn't start batch file task

I have a batch file with the code below to stop and start the SQL Report service: net stop "SQL Server Reporting Services (MSSQLSERVER)" timeout /t 10 net start "SQL Server Reporting Services (MSSQLSERVER)" I have set up the scheduled task to r...

Difference between request.getSession() and request.getSession(true)

I understand the difference between request.getSession(true) and request.getSession(false). But request.getSession() & request.getSession(true) look very similar! Both "return the current session associated with this request", but differ in: re...

Whether a variable is undefined

How do I find if a variable is undefined? I currently have: var page_name = $("#pageToEdit :selected").text(); var table_name = $("#pageToEdit :selected").val(); var optionResult = $("#pageToEditOptions :selected").val(); var string = "?z=z"; if (...

Can you target <br /> with css?

Is it possible to target the line-break <br/> tag with CSS? I would like to have a 1px dashed line every time there is a line-break. I am customising a site with my own CSS and cannot change the set HTML, otherwise I would use some other way....

Creating a mock HttpServletRequest out of a url string?

I have a service that does some work on an HttpServletRequest object, specifically using the request.getParameterMap and request.getParameter to construct an object. I was wondering if there is a straightforward way to take a provided url, in the fo...

adding multiple entries to a HashMap at once in one statement

I need to initialize a constant HashMap and would like to do it in one line statement. Avoiding sth like this: hashMap.put("One", new Integer(1)); // adding value into HashMap hashMap.put("Two", new Integer(2)); hashMap.put("Three", new ...

Maximum and minimum values in a textbox

I have a textbox. Is there a way where the highest value the user can enter is 100 and the lowest is 0? So if the user types in a number more than 100 then it will automatically change the value to 100 using a keyup() function and if user types in a...

Rewrite left outer join involving multiple tables from Informix to Oracle

How do I write an Oracle query which is equivalent to the following Informix query? select tab1.a,tab2.b,tab3.c,tab4.d from table1 tab1, table2 tab2 OUTER (table3 tab3,table4 tab4,table5 tab5) where tab3.xya = tab4.xya AND tab4.ss = ...

How to put attributes via XElement

I have this code: XElement EcnAdminConf = new XElement("Type", new XElement("Connections", new XElement("Conn"), // Conn.SetAttributeValue("Server", comboBox1.Text); // Conn.SetAttributeValue("DataBase", comboBox2.Text))), new XE...

jQuery - Getting form values for ajax POST

I am trying to post form values via AJAX to a php file. How do I collect my form values to send inside of the "data" parameter? $.ajax({ type: "POST", data: "submit=1&username="+username+"&email="+email+"&password="+pass...

Angular JS: What is the need of the directive’s link function when we already had directive’s controller with scope?

I need to perform some operations on scope and the template. It seems that I can do that in either the link function or the controller function (since both have access to the scope). When is it the case when I have to use link function and not the c...

How to set app icon for Electron / Atom Shell App

How do you set the app icon for your Electron app? I am trying BrowserWindow({icon:'path/to/image.png'}); but it does not work. Do I need to pack the app to see the effect?...

Angular ng-repeat add bootstrap row every 3 or 4 cols

I'm looking for the right pattern to inject a bootstrap row class every each 3 columns. I need this because cols doesn't have a fixed hight (and I don't want to fix one), so it breaks my design ! Here is my code : <div ng-repeat="product in pro...

How can I shuffle the lines of a text file on the Unix command line or in a shell script?

I want to shuffle the lines of a text file randomly and create a new file. The file may have several thousands of lines. How can I do that with cat, awk, cut, etc?...

How to sort an object array by date property?

Say I have an array of a few objects: var array = [{id: 1, date: Mar 12 2012 10:00:00 AM}, {id: 2, date: Mar 8 2012 08:00:00 AM}]; How can I sort this array by the date element in order from the date closest to the current date and time down? Keep i...

Numpy array dimensions

I'm currently trying to learn Numpy and Python. Given the following array: import numpy as np a = np.array([[1,2],[1,2]]) Is there a function that returns the dimensions of a (e.g.a is a 2 by 2 array)? size() returns 4 and that doesn't help very ...

How do you push a tag to a remote repository using Git?

I have cloned a remote Git repository to my laptop, then I wanted to add a tag so I ran git tag mytag master When I run git tag on my laptop the tag mytag is shown. I then want to push this to the remote repository so I have this tag on all my cli...

How do I get the HTTP status code with jQuery?

I want to check if a page returns the status code 401. Is this possible? Here is my try, but it only returns 0. $.ajax({ url: "http://my-ip/test/test.php", data: {}, complete: function(xhr, statusText){ alert(xhr.status); ...

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

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

How to scp in Python?

What's the most pythonic way to scp a file in Python? The only route I'm aware of is os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) which is a hack, and which doesn't work outside Linux-like systems, and which needs help fr...

Check if image exists on server using JavaScript?

Using javascript is there a way to tell if a resource is available on the server? For instance I have images 1.jpg - 5.jpg loaded into the html page. I'd like to call a JavaScript function every minute or so that would roughly do the following scratc...

How to move an element into another element?

I would like to move one DIV element inside another. For example, I want to move this (including all children): <div id="source"> ... </div> into this: <div id="destination"> ... </div> so that I have this: <div id="...

Inserting the same value multiple times when formatting a string

I have a string of this form s='arbit' string='%s hello world %s hello world %s' %(s,s,s) All the %s in string have the same value (i.e. s). Is there a better way of writing this? (Rather than listing out s three times)...

How to read appSettings section in the web.config file?

My XML looks like this and the filename is web.config <?xml version="1.0"?> <configuration> <appSettings> <add key="configFile" value="IIS.config"/> <add key="RialtoDomain" value="ASNC_AUDITORS"/> <...

SDK Location not found Android Studio + Gradle

I have seen this same thing posted quite a few times, but whenever I try to import my project to my new work laptop I keep getting this error. I have pulled the project from git (which his btw running fine on my old laptop). Then I went to the sdk ...

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

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

Event handler not working on dynamic content

I have a tag A in which when clicked on, it appends another tag B to perform an action B on click. So when I click on tag B, action B is performed. However, the .on method does not seems to be working on the dynamically created tag B. My html and ...

SELECT data from another schema in oracle

I want to execute a query that selects data from a different schema than the one specified in the DB connection (same Oracle server, same database, different schema) I have an python app talking to an Oracle server. It opens a connection to database...

How to get Rails.logger printing to the console/stdout when running rspec?

Same as title: How to get Rails.logger printing to the console/stdout when running rspec? Eg. Rails.logger.info "I WANT this to go to console/stdout when rspec is running" puts "Like how the puts function works" I still want Rails.logger to go to ...

Get list of Excel files in a folder using VBA

I need to get the names of all the Excel files in a folder and then make changes to each file. I've gotten the "make changes" part sorted out. Is there a way to get a list of the .xlsx files in one folder, say D:\Personal and store it in a String Arr...

Linking a qtDesigner .ui file to python/pyqt?

So if I go into QtDesigner and build a UI, it'll be saved as a .ui file. How can I make this as a python file or use this in python?...

TypeError: worker() takes 0 positional arguments but 1 was given

I'm trying to implement a subclass and it throws the error: TypeError: worker() takes 0 positional arguments but 1 was given class KeyStatisticCollection(DataDownloadUtilities.DataDownloadCollection): def GenerateAddressStrings(self): ...

jquery function setInterval

$(document).ready(function(){ setInterval(swapImages(),1000); function swapImages(){ var active = $('.active'); var next = ($('.active').next().length > 0) ? $('.active').next() : $('#siteNewsHead img:first'); ...

Disable time in bootstrap date time picker

I am using bootstrap date time picker in my web application, made in PHP/HTML5 and JavaScript. I am currently using one from here: http://tarruda.github.io/bootstrap-datetimepicker/ When I am using the control without time, it doesn't work. It just ...

How to crop(cut) text files based on starting and ending line-numbers in cygwin?

I have few log files around 100MBs each. Personally I find it cumbersome to deal with such big files. I know that log lines that are interesting to me are only between 200 to 400 lines or so. What would be a good way to extract relavant log lines f...

org.hibernate.MappingException: Unknown entity

I'm trying to work through Beginning Hibernate 2nd edition, and I'm stuck trying to put together the simple working example with HSQLDB. When I run ant populateMessages, I get [java] org.hibernate.MappingException: Unknown entity: sample.entity.Mes...

nginx: [emerg] "server" directive is not allowed here

I have reconfigured nginx but i can't get it to restart using the following config: conf: server { listen 80; server_name www.example.com; return 301 $scheme://example.com$request_uri; } server { listen 80; server_name example.com; access_log /v...

How do I restore a dump file from mysqldump?

I was given a MySQL database file that I need to restore as a database on my Windows Server 2008 machine. I tried using MySQL Administrator, but I got the following error: The selected file was generated by mysqldump and cannot be restored by ...

Bash script to calculate time elapsed

I am writing a script in bash to calculate the time elapsed for the execution of my commands, consider: STARTTIME=$(date +%s) #command block that takes time to complete... #........ ENDTIME=$(date +%s) echo "It takes $($ENDTIME - $STARTTIME) seconds...

What does <T> denote in C#

I'm new to C# and directly diving into modifying some code for a project I received. However, I keep seeing code like this : class SampleCollection<T> and I cannot make sense of what the <T> means nor what it is called. If anyon...

How can I present a file for download from an MVC controller?

In WebForms, I would normally have code like this to let the browser present a "Download File" popup with an arbitrary file type, like a PDF, and a filename: Response.Clear() Response.ClearHeaders() ''# Send the file to the output stream Response.Bu...

Can I embed a .png image into an html page?

How can I embed a .png file into a blank "file.html" so that when you open that file in any browser you see that image? In this scenario the image file is not linked to from the HTML but rather the image data is embedded in the HTML itself....

How to add and get Header values in WebApi

I need to create a POST method in WebApi so I can send data from application to WebApi method. I'm not able to get header value. Here I have added header values in the application: using (var client = new WebClient()) { // Set ...

How do I query between two dates using MySQL?

The following query: SELECT * FROM `objects` WHERE (date_field BETWEEN '2010-09-29 10:15:55' AND '2010-01-30 14:15:55') returns nothing. I should have more than enough data to for the query to work though. What am I doing wrong?...

check if a number already exist in a list in python

I am writing a python program where I will be appending numbers into a list, but I don't want the numbers in the list to repeat. So how do I check if a number is already in the list before I do list.append()?...

'node' is not recognized as an internal or an external command, operable program or batch file while using phonegap/cordova

I am using phonegap/cordova. Everthing is installed propelry i.e cordova, phonegap, ant,sdk,jdk. But now it says "node is not recogzed as an internal or external command"...

Launch iOS simulator from Xcode and getting a black screen, followed by Xcode hanging and unable to stop tasks

I'm having trouble running my basic iPhone application (while going through the Stanford iTunes CS193p lectures) in the iOS simulator. I've been searching for a while (both Google and SO), but unable to find a solution so far. There are many similar...

Can CSS3 transition font size?

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

How to add number of days to today's date?

I need to be able to add 1, 2 , 5 or 10 days to today's date using jQuery....

Find and replace string values in list

I got this list: words = ['how', 'much', 'is[br]', 'the', 'fish[br]', 'no', 'really'] What I would like is to replace [br] with some fantastic value similar to &lt;br /&gt; and thus getting a new list: words = ['how', 'much', 'is<br /&...

android start activity from service

Android: public class LocationService extends Service { @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); startActivity(new Intent(this, activity.class)); } } I launched this servi...

Check if string doesn't contain another string

In T-SQL, how would you check if a string doesn't contain another string? I have an nvarchar which could be "Oranges Apples". I would like to do an update where, for instance, a columm doesn't contain "Apples". How can this be done?...

How to fix 'android.os.NetworkOnMainThreadException'?

I got an error while running my Android project for RssReader. Code: URL url = new URL(urlToRssFeed); SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); XMLReader xmlreader = parser.getXMLReader()...

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

Search an Oracle database for tables with specific column names?

We have a large Oracle database with many tables. Is there a way I can query or search to find if there are any tables with certain column names? IE show me all tables that have the columns: id, fname, lname, address Detail I forgot to add: I need...

How do I read a specified line in a text file?

Given a text file, how would I go about reading an arbitrary line and nothing else in the file? Say, I have a file test.txt. How would I go about reading line number 15 in the file? All I've seen is stuff involving storing the entire text file as ...

Make a table fill the entire window

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

Converting Stream to String and back...what are we missing?

I want to serialize objects to strings, and back. We use protobuf-net to turn an object into a Stream and back, successfully. However, Stream to string and back... not so successful. After going through StreamToString and StringToStream, the new St...

How do I remove a MySQL database?

You may notice from my last question that a problem caused some more problems, Reading MySQL manuals in MySQL monitor? My database is now unusable partly due to my interest to break things and my inability to look at error messages. I know that I sh...

Reading a resource file from within jar

I would like to read a resource from within my jar like so: File file; file = new File(getClass().getResource("/file.txt").toURI()); BufferedReader reader = new BufferedReader(new FileReader(file)); //Read the file and it works fine when ...

How can I get a Unicode character's code?

Let's say I have this: char registered = '®'; or an umlaut, or whatever unicode character. How could I get its code?...

Simplest way to set image as JPanel background

How would I add the backgroung image to my JPanel without creating a new class or method, but simply by inserting it along with the rest of the JPanel's attributes? I am trying to set a JPanel's background using an image, however, every example I f...

How do I rewrite URLs in a proxy response in NGINX

I'm used to using Apache with mod_proxy_html, and am trying to achieve something similar with NGINX. The specific use case is that I have an admin UI running in Tomcat on port 8080 on a server at the root context: http://localhost:8080/ I need to...

How to run SUDO command in WinSCP to transfer files from Windows to linux

I am trying to use WinSCP to transfer files over to a Linux Instance from Windows. Im using private key for my instance to login to Amazon instance using ec2-user. However ec2-user does not have access to write to the Linux instance How do i sudo...

How to convert string into float in JavaScript?

I am trying to parse two values from a datagrid. The fields are numeric, and when they have a comma (ex. 554,20), I can't get the numbers after the comma. I've tried parseInt and parseFloat. How can I do this?...

What's the difference between SCSS and Sass?

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

JS: iterating over result of getElementsByClassName using Array.forEach

I want to iterate over some DOM elements, I'm doing this: document.getElementsByClassName( "myclass" ).forEach( function(element, index, array) { //do stuff }); but I get an error: document.getElementsByClassName("myclass").forEach is not a ...

How to prepare a Unity project for git?

What are the steps necessary to prepare a Unity project for committing to a git repository eg. github? I don't want to store unnecessary files (specially temp files and avoid binary formats as much as possible). ...

How to do a FULL OUTER JOIN in MySQL?

I want to do a Full Outer Join in MySQL. Is this possible? Is a Full Outer Join supported by MySQL?...

error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' -- Missing /var/run/mysqld/mysqld.sock

My problem started off with me not being able to log in as root any more on my mysql install. I was attempting to run mysql without passwords turned on... but whenever I ran the command # mysqld_safe --skip-grant-tables & I would never get the ...

java.lang.NoClassDefFoundError: javax/mail/Authenticator, whats wrong?

Send to Email.java package helper; //Mail.java - smtp sending starttls (ssl) authentication enabled //1.Open a new Java class in netbeans (default package of the project) and name it as "Mail.java" //2.Copy paste the entire code below and save it. ...

How to find memory leak in a C++ code/project?

I am a C++ programmer on the Windows platform. I am using Visual Studio 2008. I usually end up in the code with memory leaks. Normally I find the memory leak by inspecting the code, but it is cumbersome and is not always a good approach. Since ...

If...Then...Else with multiple statements after Then

a very easy question: considering an If...Then...Else instruction in VBA, how can I separate multiple instructions after Then? In other words, should I write something like If condition [ Then ] [ statement1 ] & [statement2] Else [Else s...

How to pass arguments to a Button command in Tkinter?

Suppose I have the following Button made with Tkinter in Python: import Tkinter as Tk win = Tk.Toplevel() frame = Tk.Frame(master=win).grid(row=1, column=1) button = Tk.Button(master=frame, text='press', command=action) The method action is called...

How do I check if a column is empty or null in MySQL?

I have a column in a table which might contain null or empty values. How do I check if a column is empty or null in the rows present in a table? (e.g. null or '' or ' ' or ' ' and ...) ...

How do I remove an array item in TypeScript?

I have an array that I've created in TypeScript and it has a property that I use as a key. If I have that key, how can I remove an item from it?...

Cannot GET / Nodejs Error

I'm using the tutorial found here: http://addyosmani.github.io/backbone-fundamentals/#create-a-simple-web-server and added the following code. // Module dependencies. var application_root = __dirname, express = require( 'express' ), //Web framework ...

How to add text to a WPF Label in code?

I feel stupid but cannot find out how to add a text to a WPF Label control in code. Like following for a TextBlock: DesrTextBlock.Text = "some text"; What is equivalent property in Label for doing it? DesrLabel.??? = "some text"; //something like...

How to convert an integer (time) to HH:MM:SS::00 in SQL Server 2008?

Here I have a table with a time column (datatype is integer), now I need to convert the integer value to time format HH:MM:SS:00 in SQL Server 2008. Also need clarification in the above time format, whether 00 represents milliseconds? Please help...

invalid_grant trying to get oAuth token from google

I keep getting an invalid_grant error on trying to get an oAuth token from Google to connect to their contacts api. All the information is correct and I have tripple checked this so kind of stumped. Does anyone know what may be causing this issue? I...

How to Set Selected value in Multi-Value Select in Jquery-Select2.?

hi all i am binding my dropdown with Jquery-Select2. Its working fine but now i need to Bind my Multi-Value selectBox by using Jquery-Select2. My DropDwon <div class="divright"> <select ...

Number of days between two dates in Joda-Time

How do I find the difference in Days between two Joda-Time DateTime instances? With ‘difference in days’ I mean if start is on Monday and end is on Tuesday I expect a return value of 1 regardless of the hour/minute/seconds of the start and end da...

How to identify and switch to the frame in selenium webdriver when frame does not have id

Can anyone tell me how I can identify and switch to the iframe which has only a title? <iframe frameborder="0" style="border: 0px none; width: 100%; height: 356px; min-width: 0px; min-height: 0px; overflow: auto;" dojoattachpoint="frame" title="F...

How to ssh from within a bash script?

I am trying to create an ssh connection and do some things on the remote server from within the script. However the terminal prompts me for a password, then opens the connection in the terminal window instead of the script. The commands don't get ex...

Why compile Python code?

Why would you compile a Python script? You can run them directly from the .py file and it works fine, so is there a performance advantage or something? I also notice that some files in my application get compiled into .pyc while others do not, why ...

Docker for Windows error: "Hardware assisted virtualization and data execution protection must be enabled in the BIOS"

I've installed Docker and I'm getting this error when I run the GUI: Hardware assisted virtualization and data execution protection must be enabled in the BIOS Seems like a bug since Docker works like a charm from the command line, but I'm wo...

Remove the first character of a string

I would like to remove the first character of a string. For example, my string starts with a : and I want to remove that only. There are several occurrences of : in the string that shouldn't be removed. I am writing my code in Python....

How can you remove all documents from a collection with Mongoose?

I know how to... Remove a single document. Remove the collection itself. Remove all documents from the collection with Mongo. But I don't know how to remove all documents from the collection with Mongoose. I want to do this when the user clicks a...

Replacing &nbsp; from javascript dom text node

I am processing xhtml using javascript. I am getting the text content for a div node by concatenating the nodeValue of all child nodes where nodeType == Node.TEXT_NODE. The resulting string sometimes contains a non-breaking space entity. How do I re...

Bootstrap dropdown sub menu missing

Bootstrap 3 is still at RC, but I was just trying to implement it. I couldn't figure out how to put a sub menu class. Even there is no class in css and even the new docs don't say anything about it It was there in 2.x with class name as dropdown-sub...

SQL Server: Difference between PARTITION BY and GROUP BY

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

I want to align the text in a <td> to the top

I have the following code <table style="height: 275px; width: 188px"> <tr> <td style="width: 259px;"> main page </td> </tr> </table> The main page appears in the center of the...

VB.NET Empty String Array

How can I create an empty one-dimensional string array?...

How do I check if a Key is pressed on C++

How could I possibly check if a Key is pressed on Windows?...

How to show an empty view with a RecyclerView?

I am used to put an special view inside the layout file as described in the ListActivity documentation to be displayed when there is no data. This view has the id "android:id/empty". <TextView android:id="@android:id/empty" android:layout...

Android: how to refresh ListView contents?

My ListView is using an extension of BaseAdapter, I can not get it to refresh properly. When I refresh, it appears that the old data draws on top of the new data, until a scroll event happens. The old rows draw on top of the new rows, but the old r...

Locating child nodes of WebElements in selenium

I am using selenium to test my web application and I can successfully find tags using By.xpath. However now and then I need to find child nodes within that node. Example: <div id="a"> <div> <span /> <input /...

How do you write to a folder on an SD card in Android?

I am using the following code to download a file from my server then write it to the root directory of the SD card, it all works fine: package com.downloader; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import j...

Adding an image to a project in Visual Studio

I added a folder to my project by right clicking on the project and adding a new folder. Now I added the image to the folder (using copy paste in Windows File Explorer), but the solution explorer is not showing my added image. I did refresh the solut...

Starting of Tomcat failed from Netbeans

I have problem with starting Apache Tomcat 6 from Netbeans IDE 7.4 (on 7.3 version I had the same troubles. Other people mentioned that this problem exist also in other versions, like 8.0 etc). What did I do: remove installed Tomcat 7 (without r...

Format the date using Ruby on Rails

The flickr api provides a posted date as unix timestamp one: "The posted date is always passed around as a unix timestamp, which is an unsigned integer specifying the number of seconds since Jan 1st 1970 GMT." For example, here is the date '11008974...

jQuery find and replace string

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

VB.NET Inputbox - How to identify when the Cancel Button is pressed?

I have a simple windows application that pops up an input box for users to enter in a date to do searches. How do I identify if the user clicked on the Cancel button, or merely pressed OK without entering any data as both appear to return the same...

Python handling socket.error: [Errno 104] Connection reset by peer

When using Python 2.7 with urllib2 to retrieve data from an API, I get the error [Errno 104] Connection reset by peer. Whats causing the error, and how should the error be handled so that the script does not crash? ticker.py def urlopen(url): r...

How to make a Java thread wait for another thread's output?

I'm making a Java application with an application-logic-thread and a database-access-thread. Both of them persist for the entire lifetime of the application and both need to be running at the same time (one talks to the server, one talks to the user;...

How to pass a value from Vue data to href?

I'm trying to do something like this: <div v-for="r in rentals"> <a bind-href="'/job/'r.id"> {{ r.job_title }} </a> </div> I can't figure out how to add the value of r.id to the end of the href attribute so that I can m...

Changing CSS style from ASP.NET code

Possible Duplicate: Change CSS Dynamically I need to change the height of a div container(CSS Property Height) from ASP.NET code (VB). How can I do that?...

How to Find App Pool Recycles in Event Log

I have configured an app pool in IIS 7.5 to recycle when the memory usage goes above a certain level. I have also configured it to log this information. Where in the event log should I look for this? I have tried filtering based on the source being...

Is it possible to set an object to null?

Further in my code, I check to see check if an object is null/empty. Is there a way to set an object to null?...

The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'Negotiate,NTLM'

I've looked through a ton of SO articles, and even other sites, but can't seem to get this service working. I have a SOAP service I'm trying to hit and it's configured like this: <system.serviceModel> <bindings> <basicHttp...

Visual Studio SignTool.exe Not Found

I have completed an application I have made in Visual Studio 14.0, but when I tried to publish the program, I get an error as Visual Studio cannot find 'SignTool.exe'. I have searched my Hard drive a few times for this but it is nowhere on my PC. Ca...

python: sys is not defined

I have a piece of code which is working in Linux, and I am now trying to run it in windows, I import sys but when I use sys.exit(). I get an error, sys is not defined. Here is the begining part of my code try: import numpy as np import pyfit...

javascript windows alert with redirect function

.guys I have the following code: echo ("<SCRIPT LANGUAGE='JavaScript'> window.alert('Succesfully Updated') </SCRIPT>"); what i want to do is that when i click ok on the windows.alert the page will be redirected to a my ...

Phone validation regex

I'm using this pattern to check the validation of a phone number ^[0-9\-\+]{9,15}$ It's works for 0771234567 and +0771234567, but I want it to works for 077-1234567 and +077-1234567 and +077-1-23-45-67 and +077-123-45-6-7 What should I change in...

CMake does not find Visual C++ compiler

After installing Visual Studio 2015 and running CMake on a previous project, CMake errors stating that it could not find the C compiler. The C compiler identification is unknown The CXX compiler identification is unknown CMake Error at CMakeLists.tx...

Double precision floating values in Python?

Are there data types with better precision than float?...

JavaScript require() on client side

Is it possible to use require() (or something similar) on client side? Example var myClass = require('./js/myclass.js'); ...

This Activity already has an action bar supplied by the window decor

Trying to move over my stuff to use Toolbar instead of action bar but I keep getting an error saying java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tyczj.weddingalbum/com.xxx.xxx.MainActivity}: java.lang.IllegalStateException...

Difference between OpenJDK and Adoptium/AdoptOpenJDK

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

Javascript wait() function

I want to create a JavaScript wait() function. What should I edit? function wait(waitsecs) { setTimeout(donothing(), 'waitsecs'); } function donothing() { // } ...

Using print statements only to debug

I have been coding a lot in Python of late. And I have been working with data that I haven't worked with before, using formulae never seen before and dealing with huge files. All this made me write a lot of print statements to verify if it's all goi...

How to get the client IP address in PHP

How can I get the client IP address using PHP? I want to keep record of the user who logged into my website through his/her IP address....

How to create a MySQL hierarchical recursive query?

I have a MySQL table which is as follows: id name parent_id 19 category1 0 20 category2 19 21 category3 20 22 category4 21 ... ... ... Now, I want to have a single MySQL query to which I simply supply the id [for instance say id=1...

How do I properly force a Git push?

I've set up a remote non-bare "main" repo and cloned it to my computer. I made some local changes, updated my local repository, and pushed the changes back to my remote repo. Things were fine up to that point. Now, I had to change something in the r...

Why aren't Xcode breakpoints functioning?

I have breakpoints set but Xcode appears to ignore them....

Rebase array keys after unsetting elements

I have an array: $array = array(1,2,3,4,5); If I were to dump the contents of the array they would look like this: array(5) { [0] => int(1) [1] => int(2) [2] => int(3) [3] => int(4) [4] => int(5) } When I loop through a...

Bootstrap 3 Flush footer to bottom. not fixed

I am using Bootstrap 3 for a site I am designing. I want to have a footer like this sample. Sample Please note that I don't want it FIXED so bootstrap navbar-fixed-bottom does not solve my problem. I just want it to be always at the bottom of the c...

Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click

I used explicit waits and I have the warning: org.openqa.selenium.WebDriverException: Element is not clickable at point (36, 72). Other element would receive the click: ... Command duration or timeout: 393 milliseconds If I use Thread.s...

Linux command to check if a shell script is running or not

What is the linux command to find if a process say aa.sh is running or not. ps command does not seem to work and it does not show the shell script names. Please advise....

How do I find and replace all occurrences (in all files) in Visual Studio Code?

I can't figure out how to find and replace all occurrences of a word in different files using Visual Studio Code version 1.0. I get the impression this should be possible since doing Ctrl + Shift + F allows me to simply search a folder, but i am clu...

How to send value attribute from radio button in PHP

I am struggling with sending the value of a radiobutton to an email. I have coded 2 radiobuttons, where I have set the first on to be default checked. The form and values work, however the radio button value is not submitted. Any wise words?...

Using any() and all() to check if a list contains one set of values or another

My code is for a Tic Tac Toe game and checking for a draw state but I think this question could be more useful in a general sense. I have a list that represents the board, it looks like this: board = [1,2,3,4,5,6,7,8,9] When a player makes a move...

How to add jQuery in JS file

I have some code specific to sorting tables. Since the code is common in most pages I want to make a JS file which will have the code and all the pages using it can reference it from there. Problem is: How do I add jQuery, and table sorter plugin ...

Stream file using ASP.NET MVC FileContentResult in a browser with a name?

Is there a way to stream a file using ASP.NET MVC FileContentResult within the browser with a specific name? I have noticed that you can either have a FileDialog (Open/Save) or you can stream the file in a browser window, but then it will use the Ac...

What is the fastest way to create a checksum for large files in C#

I have to sync large files across some machines. The files can be up to 6GB in size. The sync will be done manually every few weeks. I cant take the filename into consideration because they can change anytime. My plan is to create checksums on the ...

Putting a simple if-then-else statement on one line

I'm just getting into Python and I really like the terseness of the syntax. However, is there an easier way of writing an if-then-else statement so it fits on one line? For example: if count == N: count = 0 else: count = N + 1 Is there a ...

Find out if string ends with another string in C++

How can I find out if a string ends with another string in C++?...

Multiple conditions in ngClass - Angular 4

How to use multiple conditions for ngClass? Example: <section [ngClass]="[menu1 ? 'class1' : '' || menu2 ? 'class1' : '' || (something && (menu1 || menu2)) ? 'class2' : '']"> something like this. I got same class for 2 menus, and I...

window.open with headers

Can I control the HTTP headers sent by window.open (cross browser)? If not, can I somehow window.open a page that then issues my request with custom headers inside its popped-up window? I need some cunning hacks....

phpMyAdmin on MySQL 8.0

UPDATE Newer versions of phpMyAdmin solved this issue. I've successfully tested with phpMyAdmin 5.0.1 I have installed the MySQL 8.0 server and phpMyAdmin, but when I try to access it from the browser the following errors occur: #2054 - The serve...

Byte array to image conversion

I want to convert a byte array to an image. This is my database code from where I get the byte array: public void Get_Finger_print() { try { using (SqlConnection thisConnection = new SqlConnection(@"Data Source=" + System.Environmen...

Where does this come from: -*- coding: utf-8 -*-

Python recognizes the following as instruction which defines file's encoding: # -*- coding: utf-8 -*- I definitely saw this kind of instructions before (-*- var: value -*-). Where does it come from? What is the full specification, e.g. can the val...

Why doesn't TFS get latest get the latest?

Why Why WHY doesn't TFS's get latest work consistently? You would have thought that feature would have been tested thoroughly. What I have to do is, get specific version, then check both overwrite writetable files + overwrite all files. Is my loca...

Not able to start Genymotion device

I am getting an error when I try to start Genymotion. It says The Genymotion Virtual device could not obtain an IP address.For an unknown reason, VirtualBox DHCP has not assigned an IP address to virtual device. Run the VirtualBox software t...

Find all controls in WPF Window by type

I'm looking for a way to find all controls on Window by their type, for example: find all TextBoxes, find all controls implementing specific interface etc....

jQuery duplicate DIV into another DIV

Need some jquery help copying a DIV into another DIV and hoping that this is possible. I have the following HTML: <div class="container"> <div class="button"></div> </div> And then I have another DIV in another locati...

Downloading and unzipping a .zip file without writing to disk

I have managed to get my first python script to work which downloads a list of .ZIP files from a URL and then proceeds to extract the ZIP files and writes them to disk. I am now at a loss to achieve the next step. My primary goal is to download an...

How can I set selected option selected in vue.js 2?

My component vue is like this : <template> <select class="form-control" v-model="selected" :required @change="changeLocation"> <option :selected>Choose Province</option> <option v-for="option in options...

Vlookup referring to table data in a different sheet

I would like to use a VLOOKUP function referring to a data table placed in a different sheet from the one where the VLOOKUP function in written. Example: in Sheet 1, cell AA3 I would like to insert the VLOOKUP function. I want the function to check...

PHPExcel - set cell type before writing a value in it

Do you know how can I set the cell type before writing a value in it? I would like to be able to set types like "General", "Text" and "Number". Thank you....

How do I escape a single quote in SQL Server?

I'm trying to insert some text data into a table in SQL Server 9. The text includes a single quote('). How do I escape that? I tried using two single quotes, but it threw me some errors. eg. insert into my_table values('hi, my name''s tim.');...

Eclipse interface icons very small on high resolution screen in Windows 8.1

The various icons and buttons in the Eclipse (Kepler) interface are very, very small on a laptop with a 3200x1800px screen. The red error decoration that appears to indicate errors on files is difficult to see unless my nose a few cm from the screen...

How can I get the assembly file version

In AssemblyInfo there are two assembly versions: AssemblyVersion: Specify the version of the assembly being attributed. AssemblyFileVersion: Instructs a compiler to use a specific version number for the Win32 file version resource. The Win32 file v...

What are the most common naming conventions in C?

What are the naming conventions commonly use in C? I know there are at least two: GNU / linux / K&R with lower_case_functions ? name ? with UpperCaseFoo functions I am talking about C only here. Most of our projects are small embedded systems...

Loading .sql files from within PHP

I'm creating an installation script for an application that I'm developing and need to create databases dynamically from within PHP. I've got it to create the database but now I need to load in several .sql files. I had planned to open the file and m...

How to cin Space in c++?

Say we have a code: int main() { char a[10]; for(int i = 0; i < 10; i++) { cin>>a[i]; if(a[i] == ' ') cout<<"It is a space!!!"<<endl; } return 0; } How to cin a Space symbol from standard...

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

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

How can I use an http proxy with node.js http.Client?

I want to make an outgoing HTTP call from node.js, using the standard http.Client. But I cannot reach the remote server directly from my network and need to go through a proxy. How do I tell node.js to use the proxy?...

Android fade in and fade out with ImageView

I'm having some troubles with a slideshow I'm building. I've created 2 animations in xml for fade in and fade out: fadein.xml <?xml version="1.0" encoding="UTF-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android...

How can I parse / create a date time stamp formatted with fractional seconds UTC timezone (ISO 8601, RFC 3339) in Swift?

How to generate a date time stamp, using the format standards for ISO 8601 and RFC 3339? The goal is a string that looks like this: "2015-01-01T00:00:00.000Z" Format: year, month, day, as "XXXX-XX-XX" the letter "T" as a separator hour, minute,...

How to read json file into java with simple JSON library

I want to read this JSON file with java using json simple library. My JSON file looks like this: [ { "name":"John", "city":"Berlin", "cars":[ "audi", "bmw" ], "job":"Teacher...

Encode URL in JavaScript?

How do you safely encode a URL using JavaScript such that it can be put into a GET string? var myUrl = "http://example.com/index.html?param=1&anotherParam=2"; var myOtherUrl = "http://example.com/index.html?url=" + myUrl; I assume that you nee...

An error occurred while updating the entries. See the inner exception for details

When i delete an item in a listbox, i get the error in the question as shown in the screenshot below: I do not know where the inner exception is, but i tried try, catch but i got the same error in the question. Here is all of the code : namespace...

javascript - replace dash (hyphen) with a space

I have been looking for this for a while, and while I have found many responses for changing a space into a dash (hyphen), I haven't found any that go the other direction. Initially I have: var str = "This-is-a-news-item-"; I try to replace it wi...

How can I run specific migration in laravel

I create on address table migration but one migration is already in the database it gives following error : Base table or view already exists: 1050 Table 'notification' already exists So, Can I run specific migration? How can I run in Laravel?...

What's the difference between a mock & stub?

I've read various articles about mocking vs stubbing in testing, including Martin Fowler's Mocks Aren't Stubs, but still don't understand the difference....

python: how to get information about a function?

When information about a type is needed you can use: my_list = [] dir(my_list) gets: ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getite...

How to import a SQL Server .bak file into MySQL?

The title is self explanatory. Is there a way of directly doing such kind of importing?...

React component not re-rendering on state change

I have a React Class that's going to an API to get content. I've confirmed the data is coming back, but it's not re-rendering: var DealsList = React.createClass({ getInitialState: function() { return { deals: [] }; }, componentDidMou...

getting a checkbox array value from POST

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

How to check if an user is logged in Symfony2 inside a controller?

I read here how to check the login status of an user by inside a twig template for a Symfony2-based website. However, I need to know how to check if the user is logged in from inside a controller. I was quite sure the the following code was right: $...

Apache POI Excel - how to configure columns to be expanded?

I am using Apache POI API to generate excel spreadsheet to output some data. The problem I am facing is when the spreadsheet is created and opened, columns are not expanded so that some long text like Date formatted text is not showing up on first g...

Export to csv/excel from kibana

I am building a proof of concept using Elasticsearch Logstash and Kibana for one of my projects. I have the dashboard with the graphs working without any issue. One of the requirements for my project is the ability to download the file(csv/excel). I...

Login credentials not working with Gmail SMTP

I am attempting to send an email in Python, through Gmail. Here is my code: import smtplib fromaddr = '......................' toaddrs = '......................' msg = 'Spam email Test' username = '.......' password = '.......' server =...

Flutter - The method was called on null

I'm programming an app that displays two media streams in the same view via one horizontal listView and one vertical listView. I'm currently working on implementing information into the bottom listView using some nice looking boilerplate that can be ...

Datanode process not running in Hadoop

I set up and configured a multi-node Hadoop cluster using this tutorial. When I type in the start-all.sh command, it shows all the processes initializing properly as follows: starting namenode, logging to /usr/local/hadoop/libexec/../logs/hadoop-ro...

Printing result of mysql query from variable

So I wrote this earlier (in php), but everytime I try echo $test", I just get back resource id 5. Does anyone know how to actually print out the mysql query from the variable? $dave= mysql_query("SELECT order_date, no_of_items, shipping_charge, SUM(...

How can I check if the current date/time is past a set date/time?

I'm trying to write a script that will check if the current date/time is past the 05/15/2010 at 4PM How can I use PHP's date() function to perform this check? ...

"’" showing on page instead of " ' "

’ is showing on my page instead of '. I have the Content-Type set to UTF-8 in both my <head> tag and my HTTP headers: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> In addition, my browser is set to Uni...

Swift: Testing optionals for nil

I'm using Xcode 6 Beta 4. I have this weird situation where I cannot figure out how to appropriately test for optionals. If I have an optional xyz, is the correct way to test: if (xyz) // Do something or if (xyz != nil) // Do something The doc...

ssh-copy-id no identities found error

I have few client systems where I need to push the ssh key and login from my server without authentication prompts. First, on the server, I created ssh key as below which was successful ]# ssh-keygen -t rsa -N "" -f my.key Second, tried copying ...

How to get am pm from the date time string using moment js

I have a string as Mon 03-Jul-2017, 11:00 AM/PM and I have to convert this into a string like 11:00 AM/PM using moment js. The problem here is that I am unable to get AM or PM from the date time string. I am doing this: moment(Mon 03-Jul-2017, 11:...

How to extract base URL from a string in JavaScript?

I'm trying to find a relatively easy and reliable method to extract the base URL from a string variable using JavaScript (or jQuery). For example, given something like: http://www.sitename.com/article/2009/09/14/this-is-an-article/ I'd like to get...

How do I convert a list of ascii values to a string in python?

I've got a list in a Python program that contains a series of numbers, which are themselves ASCII values. How do I convert this into a "regular" string that I can echo to the screen?...

How to close IPython Notebook properly?

How to close IPython Notebook properly? Currently, I just close the browser tabs and then use Ctrl+C in the terminal. Unfortunately, neither exit() nor ticking Kill kernel upon exit does help (they do kill the kernel they but don't exit the iPython)...

How to use environment variables in docker compose

I would like to be able to use env variables inside docker-compose.yml, with values passed in at the time of docker-compose up. This is the example. I am doing this today with basic docker run command, which is wrapped around my own script. Is there ...

Squash the first two commits in Git?

With git rebase --interactive <commit> you can squash any number of commits together into a single one. That's all great unless you want to squash commits into the initial commit. That seems impossible to do. Are there any ways to achieve it?...

How do I trim leading/trailing whitespace in a standard way?

Is there a clean, preferably standard method of trimming leading and trailing whitespace from a string in C? I'd roll my own, but I would think this is a common problem with an equally common solution....

How to connect to my http://localhost web server from Android Emulator

What can I do in the Android emulator to connect it to my localhost web server page at http://localhost or http://127.0.0.1? I've tried it, but the emulator still takes my request like a Google search for localhost or worse it says that it didn't fo...

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

I'm using: FileInfo( System.Environment.GetFolderPath( System.Environment.SpecialFolder.ProgramFiles) + @"\MyInstalledApp" In order to determine if a program is detected on a users machine (it's not ideal, but the program I'm look...

SQL INSERT INTO from multiple tables

this is my table 1: NAME AGE SEX CITY ID Clara 22 f New York 1 Bob 33 m Washington 2 Sam 25 m Boston 3 this is my table ...

JavaScript - Use variable in string match

I found several similar questions, but it did not help me. So I have this problem: var xxx = "victoria"; var yyy = "i"; alert(xxx.match(yyy/g).length); I don't know how to pass variable in match command. Please help. Thank you....

How to make google spreadsheet refresh itself every 1 minute?

My google spreadsheet is using GOOGLEFINANCE('symbol','price) function to retrieve stock prices of my portfolio. Unfortunately, I have to refresh manually now. How can I make the spreadsheet refresh itself every 1 minute? Thank you for your help....

Why does GitHub recommend HTTPS over SSH?

On the GitHub site there is a link... https://help.github.com/articles/generating-ssh-keys ... and it states... If you have decided not to use the recommended HTTPS method, we can use SSH keys to establish a secure connection between your com...

How to fetch FetchType.LAZY associations with JPA and Hibernate in a Spring Controller

I have a Person class: @Entity public class Person { @Id @GeneratedValue private Long id; @ManyToMany(fetch = FetchType.LAZY) private List<Role> roles; // etc } With a many-to-many relation that is lazy. In my cont...

TypeError: Cannot read property "0" from undefined

I'm getting a very weird undefined error: function login(name,pass) { var blob = Utilities.newBlob(pass); var passwordencode = Utilities.base64Encode(blob.getBytes()); var ss = SpreadsheetApp.openById(""); var sheet = ss.getActiveSheet(); ...

Simulating Button click in javascript

So what i want to do is when i click on a button, it will pass this click event to another element in webpage, or you can say it will create a new click event in another element. Below is my code, it does not work, please let me know what is wrong wi...

How can I find which tables reference a given table in Oracle SQL Developer?

In Oracle SQL Developer, if I'm viewing the information on a table, I can view the constraints, which let me see the foreign keys (and thus which tables are referenced by this table), and I can view the dependencies to see what packages and such refe...

How do I wrap text in a pre tag?

pre tags are super-useful for code blocks in HTML and for debugging output while writing scripts, but how do I make the text word-wrap instead of printing out one long line?...

Meaning of "n:m" and "1:n" in database design

In database design what do n:m and 1:n mean? Does it have anything to do with keys or relationships?...

Remove not alphanumeric characters from string

I want to convert the following string to the provided output. Input: "\\test\red\bob\fred\new" Output: "testredbobfrednew" I've not found any solution that will handle special characters like \r, \n, \b, etc. Basically I just want to get rid o...

Converting year and month ("yyyy-mm" format) to a date?

I have a dataset that looks like this: Month count 2009-01 12 2009-02 310 2009-03 2379 2009-04 234 2009-05 14 2009-08 1 2009-09 34 2009-10 2386 I want to plot the data (months as x values and counts as y values). Since there are gaps in...

How to get margin value of a div in plain JavaScript?

I can get height in jQuery with $(item).outerHeight(true); but how do I with JS? I can get the height of the li with document.getElementById(item).offsetHeight but i will always get "" when I try margin-top: document.getElementById(item).st...

How to print variable addresses in C?

When i run this code. #include <stdio.h> void moo(int a, int *b); int main() { int x; int *y; x = 1; y = &x; printf("Address of x = %d, value of x = %d\n", &x, x); printf("Address of y = &d, value of y ...

C# Connecting Through Proxy

I work in a office which requires all connections to be made through a specific http proxy. I need to write a simple application to query some values from a webserver - it's easy if there were no proxy. How can I make the C# application proxy-aware? ...

What does "export" do in shell programming?

As far as I can tell, variable assignment is the same whether it is or is not preceded by "export". What's it for?...

How do I deal with special characters like \^$.?*|+()[{ in my regex?

I want to match a regular expression special character, \^$.?*|+()[{. I tried: x <- "a[b" grepl("[", x) ## Error: invalid regular expression '[', reason 'Missing ']'' (Equivalently stringr::str_detect(x, "[") or stringi::stri_detect_regex(x, "...

Copy/Paste from Excel to a web page

Is there a standard way or library to copy and paste from a spreasheet to a web form? When I select more than one cell from Excel I (obviously) lose the delimiter and all is pasted into one cell of the web form. Does it have to be done in VB? or coul...

How to print values separated by spaces instead of new lines in Python 2.7

I am using Python 2.7.3 and I am writing a script which prints the hex byte values of any user-defined file. It is working properly with one problem: each of the values is being printed on a new line. Is it possible to print the values with spaces in...

Unable to connect to SQL Server instance remotely

I’m trying to access the SQL Server instance on my VPS from SQL Server Management Studio on my local machine. It’s not working (the error I’m getting is: A network-related or instance-specific error occurred while establishing a connectio...

How to split a string between letters and digits (or between digits and letters)?

I'm trying to work out a way of splitting up a string in java that follows a pattern like so: String a = "123abc345def"; The results from this should be the following: x[0] = "123"; x[1] = "abc"; x[2] = "345"; x[3] = "def"; However I'm complete...

The thread has exited with code 0 (0x0) with no unhandled exception

While debugging my C# application I have noticed a large amount occurrences of the following sentence: The thread -- has exited with code 0 (0x0). The application continues to work and no exception is catched/unhanded. The application is runni...

Image change every 30 seconds - loop

I would like to make an image change after 30 seconds. The javascript I'm using looks like this: var images = new Array(); images[0] = "image1.jpg"; images[1] = "image2.jpg"; images[2] = "image3.jpg"; setTimeout("ch...

Nested rows with bootstrap grid system?

I want 1 larger image with 4 smaller images in a 2x2 format like this: My initial thought was to house everything in one row. Then create two columns, and, in the second column, create two rows and two columns to create the 1x1 and 2x2 effect. ...

Writing a pandas DataFrame to CSV file

I have a dataframe in pandas which I would like to write to a CSV file. I am doing this using: df.to_csv('out.csv') And getting the error: UnicodeEncodeError: 'ascii' codec can't encode character u'\u03b1' in position 20: ordinal not in range(128...

How to manually trigger click event in ReactJS?

How can I manually trigger a click event in ReactJS? When a user clicks on element1, I want to automatically trigger a click on the input tag. <div className="div-margins logoContainer"> <div id="element1" className="content" onClick={thi...

Data access object (DAO) in Java

I was going through a document and I came across a term called DAO. I found out that it is a Data Access Object. Can someone please explain me what this actually is? I know that it is some kind of an interface for accessing data from different type...

trace a particular IP and port

I have an app running on port 9100 on a remote server serving http pages. After I ssh into the server I can curl localhost 9100 and I receive the response. However I am unable to access the same app from the browser using http://ip:9100 I am also u...

Assignment inside lambda expression in Python

I have a list of objects and I want to remove all objects that are empty except for one, using filter and a lambda expression. For example if the input is: [Object(name=""), Object(name="fake_name"), Object(name="")] ...then the output should b...

Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function but got: object

I am getting this error: Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. This is my code: var React = require('react...

Undoing accidental git stash pop

I stashed some local changes before doing a complicated merge, did the merge, then stupidly forgot to commit before running git stash pop. The pop created some problems (bad method calls in a big codebase) that are proving hard to track down. I ran...

'list' object has no attribute 'shape'

how to create an array to numpy array? def test(X, N): [n,T] = X.shape print "n : ", n print "T : ", T if __name__=="__main__": X = [[[-9.035250067710876], [7.453250169754028], [33.34074878692627]], [[-6.63700008392334], [5.13299...

How do I change the string representation of a Python class?

In Java, I can override the toString() method of my class. Then Java's print function prints the string representation of the object defined by its toString(). Is there a Python equivalent to Java's toString()? For example, I have a PlayCard class. ...

Resize command prompt through commands

I want to resize the command prompt window in a batch file, is it possible to set a height and width through something I can just add in the batch file?...

SQL exclude a column using SELECT * [except columnA] FROM tableA?

We all know that to select all columns from a table, we can use SELECT * FROM tableA Is there a way to exclude column(s) from a table without specifying all the columns? SELECT * [except columnA] FROM tableA The only way that I know is to manua...

Can I add a custom attribute to an HTML tag?

Can I add a custom attribute to an HTML tag like the following? <tag myAttri="myVal" /> ...

How to check the installed version of React-Native

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

How do I check CPU and Memory Usage in Java?

I need to check CPU and memory usage for the server in java, anyone know how it could be done?...

Sequelize.js delete query?

Is there a way to write a delete/deleteAll query like findAll? For example I want to do something like this (assuming MyModel is a Sequelize model...): MyModel.deleteAll({ where: ['some_field != ?', something] }) .on('success', function() { /* ...

Entity Framework Core: DbContextOptionsBuilder does not contain a definition for 'usesqlserver' and no extension method 'usesqlserver'

I am new to EF core and I'm trying to get it to work with my ASP.NET Core project. I get the above error in my startup.cs when trying configure the DbContext to use a connection string from config. I am following this tutorial. The problematic code i...

Circular (or cyclic) imports in Python

What will happen if two modules import each other? To generalize the problem, what about the cyclic imports in Python?...

How to count string occurrence in string?

How can I count the number of times a particular string occurs in another string. For example, this is what I am trying to do in Javascript: var temp = "This is a string."; alert(temp.count("is")); //should output '2' ...

Comparing the contents of two files in Sublime Text

I have two cloned repositories of two very similar open-source projects, which I have been working on in different instances in Sublime Text 2 to arrive at my desired result. Code from both of these projects was used. I have been using Git as version...

Difference between @Mock and @InjectMocks

What is the difference between @Mock and @InjectMocks in Mockito framework?...

What's the difference between "app.render" and "res.render" in express.js?

Docs for app.render: Render a view with a callback responding with the rendered string. This is the app-level variant of res.render(), and otherwise behaves the same way. Docs for res.render: Render a view with a callback responding with th...

How to initialize a JavaScript Date to a particular time zone

I have date time in a particular timezone as a string and I want to convert this to the local time. But, I don't know how to set the timezone in the Date object. For example, I have Feb 28 2013 7:00 PM ET, then I can var mydate = new Date(); mydat...

Detect when an image fails to load in Javascript

Is there a way to determine if a image path leads to an actual image, Ie, detect when an image fails to load in Javascript. For a web app, I am parsing a xml file and dynamically creating HTML images from a list of image paths. Some image paths may ...

Add click event on div tag using javascript

I have a div tag in my form without id property. I need to set an on-click event on this div tag. My HTML code: <div class="drill_cursor" > .... </div> I don't want to add an id property to my div tag. How can I add an on-click event...

How to redirect a page using onclick event in php?

I tried with this code but it's not working, <input type="button" value="Home" class="homebutton" id="btnHome" onClick="<?php header("Location: /index.php"); ?>" /> ...

Make Frequency Histogram for Factor Variables

I am very new to R, so I apologize for such a basic question. I spent an hour googling this issue, but couldn't find a solution. Say I have some categorical data in my data set about common pet types. I input it as a character vector in R that conta...

How to produce an csv output file from stored procedure in SQL Server

Is it possible to generate a csv file from a stored procedure in SQL Server? I created my stored procedure and I want to stored some result as csv, does someone know how to achieve this?...

Consider marking event handler as 'passive' to make the page more responsive

I am using hammer for dragging and it is getting choppy when loading other stuff, as this warning message is telling me. Handling of 'touchstart' input event was delayed for X ms due to main thread being busy. Consider marking event handler as ...

ALTER TABLE to add a composite primary key

I have a table called provider. I have three columns called person, place, thing. There can be duplicate persons, duplicate places, and duplicate things, but there can never be a dupicate person-place-thing combination. How would I ALTER TABLE to ad...

How to call a method in another class of the same package?

How to call a method, which is in another class of same package in Java? What I know is, using an object we can call a method from a different class. Is there any other way to call a method of different class?...

How do I tidy up an HTML file's indentation in VI?

How do I fix the indentation of his huge html files which was all messed up? I tried the usual "gg=G command, which is what I use to fix the indentation of code files. However, it didn't seem to work right on HTML files. It simply removed all the ...

How do I best silence a warning about unused variables?

I have a cross platform application and in a few of my functions not all the values passed to functions are utilised. Hence I get a warning from GCC telling me that there are unused variables. What would be the best way of coding around the warning...

How do I clone a specific Git branch?

Git clone will behave copying remote current working branch into local. Is there any way to clone a specific branch by myself without switching branches on the remote repository?...

Convert CString to const char*

How do I convert from CString to const char* in my Unicode MFC application?...

How can I change column types in Spark SQL's DataFrame?

Suppose I'm doing something like: val df = sqlContext.load("com.databricks.spark.csv", Map("path" -> "cars.csv", "header" -> "true")) df.printSchema() root |-- year: string (nullable = true) |-- make: string (nullable = true) |-- model: st...

Increment counter with loop

This question is related to my previous question : Jsp iterate trough object list I want to insert counter that starts from 0 in my for loop, I've tried several combinations so far : 1. <c:forEach var="tableEntity" items='${requestScope.tables...

Android webview slow

My android webviews are slow. This is on everything from phones to 3.0+ tablets with more than adequate specs I know that webviews are supposed to be "limited" but I see web apps done with phone gap that must be using all sorts of CSS3 and JQuery so...

installing python packages without internet and using source code as .tar.gz and .whl

we are trying to install couple of python packages without internet. For ex : python-keystoneclient For that we have the packages downloaded from https://pypi.python.org/pypi/python-keystoneclient/1.7.1 and kept it in server. However, while insta...

How to make a great R reproducible example

When discussing performance with colleagues, teaching, sending a bug report or searching for guidance on mailing lists and here on Stack Overflow, a reproducible example is often asked and always helpful. What are your tips for creating an exce...

How do I set a JLabel's background color?

In my JPanel, I set the background of a JLabel to a different color. I can see the word "Test" and it's blue, but the background doesn't change at all. How can I get it to show? this.setBackground(Color.white); JLabel label = new JLabel("Test"); lab...

Boxplot show the value of mean

In this boxplot we can see the mean but how can we have also the number value on the plot for every mean of every box plot? ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot() + stat_summary(fun.y=mean, colour="darkre...

Python requests library how to pass Authorization header with single token

I have a request URI and a token. If I use: curl -s "<MY_URI>" -H "Authorization: TOK:<MY_TOKEN>" etc., I get a 200 and view the corresponding JSON data. So, I installed requests and when I attempt to access this resource I get a 403 p...

Loop through files in a folder using VBA?

I would like to loop through the files of a directory using vba in Excel 2010. In the loop, I will need: the filename, and the date at which the file was formatted. I have coded the following which works fine if the folder has no more then 50 ...

Why is this rsync connection unexpectedly closed on Windows?

I'm trying to use rsync on Windows 7. I installed cwRsync and tried to connect to Ubuntu 9.04. $ rsync -azC --force --more-options ./ user@server:/my/path/ rsync: connection unexpectedly closed (0 bytes received so far) [receiver] rsync error: erro...

Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported for @RequestBody MultiValueMap

Based on the answer for problem with x-www-form-urlencoded with Spring @Controller I have written the below @Controller method @RequestMapping(value = "/{email}/authenticate", method = RequestMethod.POST , produces = {"application/json...

Vertical Menu in Bootstrap

Is there a way to create a vertical menu (not dropdown, entirely separate vertical menu on sidebar) by using any bootstrap class? I can create one using my css, but just want to know if there is any builtin class for this in bootstrap, or can it be d...

Can you change what a symlink points to after it is created?

Does any operating system provide a mechanism (system call — not command line program) to change the pathname referenced by a symbolic link (symlink) — other than by unlinking the old one and creating a new one? The POSIX standard does not. Sol...

How to remove undefined and null values from an object using lodash?

I have a Javascript object like: var my_object = { a:undefined, b:2, c:4, d:undefined }; How to remove all the undefined properties? False attributes should stay....

Visual Studio move project to a different folder

How do I move a project to a different folder in Visual Studio? I am used to this structure in my projects. -- app ---- Project.Something ---- Project.SomethingElse I want to rename the whole namespace SomethingElse to SomethingNew, what's the bes...

Convert factor to integer

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

Opencv - Grayscale mode Vs gray color conversion

I am working in opencv(2.4.11) python(2.7) and was playing around with gray images. I found an unusual behavior when loading image in gray scale mode and converting image from BGR to GRAY. Following is my experimental code: import cv2 path = 'some/...

How to get JQuery.trigger('click'); to initiate a mouse click

I'm having a hard time understand how to simulate a mouse click using JQuery. Can someone please inform me as to what i'm doing wrong. HTML: <a id="bar" href="http://stackoverflow.com" target="_blank">Don't click me!</a> <span id="fo...

Bootstrap carousel resizing image

Hi I am trying to make a carousel on my wordpress website with bootstrap. I would like to put four block links next to it. I have the blocks there and the images are scrolling fine, However I believe the carousel is changing the height of the image. ...

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

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

Angular 2 execute script after template render

So I have this slider component that use materializecss javascript. So after it's rendered, I need to execute $(document).ready(function(){ $('body').on('Slider-Loaded',function(){ console.log('EVENT SLIDER LOADED'); $('.slider')...

Using 'starts with' selector on individual class names

If I have the following: <div class="apple-monkey"></div> <div class="apple-horse"></div> <div class="cow-apple-brick"></div> I can use the following selector to find the first two DIVs: $("div[class^='apple-']...

How to remove files from git staging area?

I made changes to some of my files in my local repo, and then I did git add -A which I think added too many files to the staging area. How can I delete all the files from the staging area? After I do that, I'll just manually do git add "filename"....

How can I change the remote/target repository URL on Windows?

I created a local GIT repository on Windows. Let's call it AAA. I staged, committed, and pushed the contents to GitHub. [email protected]:username/AAA.git I realized I made a mistake with the name. On GitHub, I renamed it to [email protected]:username/B...

How to update Ruby Version 2.0.0 to the latest version in Mac OSX Yosemite?

I need to update my ruby version from 2.0.0 to the latest version, I can not use some gems because my version is not updated. I had used Homebrew to install Ruby some time ago, How can i update my Ruby version?...

How does System.out.print() work?

I have worked with Java for a quite a long time, and I was wondering how the function System.out.print() works. Here is my doubt: Being a function, it has a declaration somewhere in the io package. But how did Java developers do that, since this fu...

Conditional Replace Pandas

I have a DataFrame, and I want to replace the values in a particular column that exceed a value with zero. I had thought this was a way of achieving this: df[df.my_channel > 20000].my_channel = 0 If I copy the channel into a new data frame it's s...

Failed to find target with hash string 'android-25'

I have Android Studio 2.2. I am trying to open a project, but I get the error "Failed to find target with hash string 'android-25'". Below the error message I see a link "Install missing platform(s) and sync project". If I click t...

How to call another components function in angular2

I have two components as follows and I want to call a function from another component. Both components are included in the third parent component using directive. Component 1: @component( selector:'com1' ) export class com1{ function1(){....

How to rotate x-axis tick labels in Pandas barplot

With the following code: import matplotlib matplotlib.style.use('ggplot') import matplotlib.pyplot as plt import pandas as pd df = pd.DataFrame({ 'celltype':["foo","bar","qux","woz"], 's1':[5,9,1,7], 's2':[12,90,13,87]}) df = df[["celltype","s1","s...

How to resolve "Server Error in '/' Application" error?

I am trying to deploy an asp.net application in our server while I am receiving the following error. Server Error in '/' Application. ________________________________________ Configuration Error Description: An error occurred during the processing...

Is there a way to run Python on Android?

We are working on an S60 version and this platform has a nice Python API.. However, there is nothing official about Python on Android, but since Jython exists, is there a way to let the snake and the robot work together??...

How does one convert a HashMap to a List in Java?

In Java, how does one get the values of a HashMap returned as a List?...

System.BadImageFormatException: Could not load file or assembly

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe C:\_PRODUKCIJA\D ebug\DynamicHtmlTool.exe Microsoft (R) .NET Framework Installation utility Version 4.0.30319.1 Copyright (c) Microsoft Corporation. All rights reserved. Exception o...

Excel VBA Run Time Error '424' object required

I am totally new in VBA and coding in general, am trying to get data from cells from the same workbook (get framework path ...) and then to start application (QTP) and run tests. I am getting this error when trying to get values entered in excel cel...

Does "\d" in regex mean a digit?

I found that in 123, \d matches 1 and 3 but not 2. I was wondering if \d matches a digit satisfying what kind of requirement? I am talking about Python style regex. Regular expression plugin in Gedit is using Python style regex. I created a text fi...

How stable is the git plugin for eclipse?

I was intending to have a play with git, and was wondering if anyone had used the git plugin for eclipse I see it's at version 0.3.1, and was wondering if anyone knew how stable it was / any gotchas? Update: If you are using a recent version of ...

Psql list all tables

I would like to list all tables in the liferay database in my PostgreSQL install. How do I do that? I would like to execute SELECT * FROM applications; in the liferay database. applications is a table in my liferay db. How is this done? Here's a ...

BasicHttpBinding vs WsHttpBinding vs WebHttpBinding

In WCF there are several different types of HTTP based bindings: BasicHttpBinding WsHttpBinding WebHttpBinding What are the differences among these 3? In particular what are the differences in terms of features / performance and compatability?...

Java LinkedHashMap get first or last entry

I have used LinkedHashMap because it is important the order in which keys entered in the map. But now I want to get the value of key in the first place (the first entered entry) or the last. Should there be a method like first() and last() or somet...

How to return value from Action()?

In regards to the answer for this question Passing DataContext into Action(), how do I return a value from action(db)? SimpleUsing.DoUsing(db => { // do whatever with db }); Should be more like: MyType myType = SimpleUsing.DoUsing<MyType...

How to bind Dataset to DataGridView in windows application

I have created Windows Application. In this, I have multiple tables in dataset, now I want to bind that to a single DataGridView. Can anybody help me?...

How can I inspect the file system of a failed `docker build`?

I'm trying to build a new Docker image for our development process, using cpanm to install a bunch of Perl modules as a base image for various projects. While developing the Dockerfile, cpanm returns a failure code because some of the modules did no...

How can I count all the lines of code in a directory recursively?

We've got a PHP application and want to count all the lines of code under a specific directory and its subdirectories. We don't need to ignore comments, as we're just trying to get a rough idea. wc -l *.php That command works great within a given d...

What is the best way to delete a value from an array in Perl?

The array has lots of data and I need to delete two elements. Below is the code snippet I am using, my @array = (1,2,3,4,5,5,6,5,4,9); my $element_omitted = 5; @array = grep { $_ != $element_omitted } @array; ...

Getting msbuild.exe without installing Visual Studio

How do you get msbuild.exe without installing those crazy Visual Studio programs? I need it for an npm install to finish working. I'm on Windows 7 and can't get on older version of Visual Studio 2013 Express online....

Compile to stand alone exe for C# app in Visual Studio 2010

Similar to this question Compile to a stand-alone executable (.exe) in Visual Studio But nothing there works for me. I've written an app that is very simple in C#. I want this to compile to a stand alone exe file, but I can't seem to find the prop...

jQuery add text to span within a div

<div id="tagscloud"> <span></span> </div> How would I do to add some text within the span like code below ? <span>**tag cloud**</span> Edit: actually the span has an id <div id="tagscloud"> <sp...

How to send redirect to JSP page in Servlet

When I'm done processing in a servlet, and the result is valid, then I need to redirect the response to another JSP page, say welcome.jsp in web content folder. How can I do it? For example: protected void doPost(HttpServletRequest request, HttpSer...

What algorithms compute directions from point A to point B on a map?

How do map providers (such as Google or Yahoo! Maps) suggest directions? I mean, they probably have real-world data in some form, certainly including distances but also perhaps things like driving speeds, presence of sidewalks, train schedules, etc....

How To Create Table with Identity Column

I have an existing table that I am about to blow away because I did not create it with the ID column set to be the table's Identity column. Using SQL Server Management Studio, I scripted a "Create To..." of the existing table and got this: CREATE T...

How to get PID by process name?

Is there any way I can get the PID by process name in Python? PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3110 meysam 20 0 971m ...

Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine

I created a windows application developed in .NET 3.5 in a 32 bit Windows 2008 server. When deployed the application in a 64 bit server it shows the error "Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine ". So as a solution ...

Linq to Entities - SQL "IN" clause

In T-SQL you could have a query like: SELECT * FROM Users WHERE User_Rights IN ("Admin", "User", "Limited") How would you replicate that in a LINQ to Entities query? Is it even possible?...

How do I make the text box bigger in HTML/CSS?

I am not sure where you edit the code for my question so I put both (sorry if that confuses anyone) In the top right hand corner there are two text boxes, but I'm not sure how to make them bigger in height. Please could you help me? Here is the lin...

Efficiently counting the number of lines of a text file. (200mb+)

I have just found out that my script gives me a fatal error: Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 440 bytes) in C:\process_txt.php on line 109 That line is this: $lines = count(file($path)) - 1; So I ...

SET versus SELECT when assigning variables?

What are the differences between the SET and SELECT statements when assigning variables in T-SQL?...

Git On Custom SSH Port

My VPS provider recommends that I leave my SSH port to the custom port number they assign it by default (not 22). The thing is the while I know I can give the port number when create a remote config, it seems like I can't do the same when doing a gi...

comma separated string of selected values in mysql

I want to convert selected values into a comma separated string in MySQL. My initial code is as follows: SELECT id FROM table_level where parent_id=4; Which produced: '5' '6' '9' '10' '12' '14' '15' '17' '18' '779' My desired output would look ...

Fastest way to add an Item to an Array

What is the fastest way to add a new item to an existing array? Dim arr As Integer() = {1, 2, 3} Dim newItem As Integer = 4 (I already know that when working with dynamic list of items you should rather use a List, ArrayList or similar IEnumerable...

Count character occurrences in a string in C++

How can I count the number of "_" in a string like "bla_bla_blabla_bla"?...

Fatal error: "No Target Architecture" in Visual Studio

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

How get the base URL via context path in JSF?

I have this structure: WebContent resources components top.xhtml company about_us.xhtml index.xhtml top.xhtml is a component, that is used in index.xthml and about_us.xhtml too. top.xhtml <ul> ...

How to create/make rounded corner buttons in WPF?

I need to create a rounded corner glossy button in WPF. Can anyone please explain me what steps are needed?...

How do I create a new line in Javascript?

var i; for(i=10; i>=0; i= i-1){ var s; for(s=0; s<i; s = s+1){ document.write("*"); } //i want this to print a new line /document.write(?); } I am printing a pyramid of stars, I can't get the new line to print....

Error: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'

I recently upgraded/updated Entity Framework in an old project from version 4 or 5 to version 6. Now I get this exception: An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code ...

How to show/hide an element on checkbox checked/unchecked states using jQuery?

I have this code: <fieldset class="question"> <label for="coupon_question">Do you have a coupon?</label> <input class="coupon_question" type="checkbox" name="coupon_question" value="1" /> <span c...

Download large file in python with requests

Requests is a really nice library. I'd like to use it for downloading big files (>1GB). The problem is it's not possible to keep whole file in memory; I need to read it in chunks. And this is a problem with the following code: import requests def...

What is the easiest way to ignore a JPA field during persistence?

I'm essentially looking for a "@Ignore" type annotation with which I can stop a particular field from being persisted. How can this be achieved?...

Set default option in mat-select

I have a simple select option form field in my Angular material project: component.html <mat-form-field> <mat-select [(value)]="modeSelect" placeholder="Mode"> <mat-option value="domain">Domain</mat-option> ...

How to check if div element is empty

Possible Duplicate: Checking if an html element is empty with jQuery I have an empty div like this: <div id="cartContent"></div> I need to check if it's empty. If it's empty it needs to return true and then some elements a...

Reading all files in a directory, store them in objects, and send the object

I do not know if this is possible, but here goes. And working with callbacks makes it even more difficult. I have a directory with html files that I want to send back to the client in Object chunks with node.js and socket.io. All my files are in /t...

How to display image from URL on Android

I want to display image on screen. Image should come from URL, and not drawable. Code is here: <ImageView android:id="@+id/ImageView01" android:src = "http://l.yimg.com/a/i/us/we/52/21.gif" android:layout_width="wrap_content" android:layout_...

Maximum size of a varchar(max) variable

At any time in the past, if someone had asked me the maximum size for a varchar(max), I'd have said 2GB, or looked up a more exact figure (2^31-1, or 2147483647). However, in some recent testing, I discovered that varchar(max) variables can apparent...

How to convert a byte to its binary string representation

For example, the bits in a byte B are 10000010, how can I assign the bits to the string str literally, that is, str = "10000010". Edit I read the byte from a binary file, and stored in the byte array B. I use System.out.println(Integer.toBi...

How to specify maven's distributionManagement organisation wide?

I'm trying to figure out how to organize many (around 50+) maven2 projects, so that they can deploy into a central nexus repository. When using the mvn deploy goal, one does need to specify the target in the distributionManagement tag like this: <...

Android Studio with Google Play Services

I'm trying to test Google Play Services with the new Android Studio. I have a project with a dependency to the google_play_services.jar. But when I try to Rebuild the project I get the following errors: Information:[TstGP3-TstGP3] Crunching PNG File...

How to cut first n and last n columns?

How can I cut off the first n and the last n columns from a tab delimited file? I tried this to cut first n column. But I have no idea to combine first and last n column cut -f 1-10 -d "<CTR>v <TAB>" filename ...

JavaScript get element by name

Consider this function: function validate() { var acc = document.getElementsByName('acc').value; var pass = document.getElementsByName('pass').value; alert (acc); } And this HTML part: <table border="0" cellpadding="2" cellspacing="0" v...

how to get files from <input type='file' .../> (Indirect) with javascript

I have problem with "input tag" in non IE browsers <input type="file" ... I'm trying to write my uploader , just using javascript and asp.net. I have no problem uploading files. My problem occured When I wanted to get my files in non IE brows...

Check if a Class Object is subclass of another Class Object in Java

I'm playing around with Java's reflection API and trying to handle some fields. Now I'm stuck with identifying the type of my fields. Strings are easy, just do myField.getType().equals(String.class). The same applies for other non-derived classes. Bu...

Command to close an application of console?

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

Angularjs $http.get().then and binding to a list

I have a list that looks like this: <li ng-repeat="document in DisplayDocuments()" ng-class="IsFiltered(document.Filtered)"> <span><input type="checkbox" name="docChecked" id="doc_{{document.Id}}" ng-model="document.Filtered" /&g...

How can I run a function from a script in command line?

I have a script that has some functions. Can I run one of the function directly from command line? Something like this? myScript.sh func() ...

How to convert a date String to a Date or Calendar object?

I have a String representation of a date that I need to create a Date or Calendar object from. I've looked through Date and Calendar APIs but haven't found anything that can do this other than creating my own ugly parse method. I know there must be a...

fatal: does not appear to be a git repository

Why am I getting this error when my git repository url is correct? jitendra@JITENDRA-PC /c/mySite (master) $ git push beanstalk master fatal: '[email protected]/gittest.git' does not appear to be a git repository fatal: The remote end hung ...

Bootstrap datepicker disabling past dates without current date

I wanted to disable all past date before current date, not with current date. I am trying by bootstrap datepicker library "bootstrap-datepicker" and using following code: $('#date').datepicker({ startDate: new Date() }); It works fine. But i...

Unique on a dataframe with only selected columns

I have a dataframe with >100 columns, and I would to find the unique rows, by comparing only two of the columns. I'm hoping this is an easy one, but I can't get it working with unique or duplicated myself. In the below, I would like to unique only u...

Returning null in a method whose signature says return int?

public int pollDecrementHigherKey(int x) { int savedKey, savedValue; if (this.higherKey(x) == null) { return null; // COMPILE-TIME ERROR } else if (this.get(this.higherKey(x)) > 1) {...