Examples On Programing Languages

Spring @ContextConfiguration how to put the right location for the xml

In our project we are writting a test to check if the controller returns the right modelview @Test public void controllerReturnsModelToOverzichtpage() { ModelAndView modelView = new ModelAndView(); KlasoverzichtController con...

sql query to return differences between two tables

I am trying to compare two tables, SQL Server, to verify some data. I want to return all the rows from both tables where data is either in one or the other. In essence, I want to show all the discrepancies. I need to check three pieces of data in doi...

Maven "build path specifies execution environment J2SE-1.5", even though I changed it to 1.7

In Eclipse Juno, I installed the latest m2e plugin (1.2.20120903-1050). In preferences, I have added jdk1.7.0_11 in Java -> Installed JREs -> Add, and then specified the location (C:\Program Files\Java\jdk1.7.0_11). When I create a new Maven projec...

Why can't I use Docker CMD multiple times to run multiple services?

I have built a base image from Dockerfile named centos+ssh. In centos+ssh's Dockerfile, I use CMD to run ssh service. Then I want to build a image run other service named rabbitmq,the Dockerfile: FROM centos+ssh EXPOSE 22 EXPOSE 4149 CMD /opt/mq/sb...

How do I fix "The expression of type List needs unchecked conversion...'?

In the Java snippet: SyndFeedInput fr = new SyndFeedInput(); SyndFeed sf = fr.build(new XmlReader(myInputStream)); List<SyndEntry> entries = sf.getEntries(); the last line generates the warning "The expression of type List needs unchecked ...

javax.mail.AuthenticationFailedException: failed to connect, no password specified?

This program attempts to send e-mail but throws a run time exception: javax.mail.AuthenticationFailedException: failed to connect, no password specified? Why am I getting this exception when I have supplied the correct username and password for au...

How to load all the images from one of my folder into my web page, using Jquery/Javascript

I have a folder named "images" in the same directory as my .js file. I want to load all the images from "images" folder into my html page using Jquery/Javascript. Since, names of images are not some successive integers, how am I supposed to load the...

Property getters and setters

With this simple class I am getting the compiler warning Attempting to modify/access x within its own setter/getter and when I use it like this: var p: point = Point() p.x = 12 I get an EXC_BAD_ACCESS. How can I do this without explicit bac...

Bringing a subview to be in front of all other views

I am working on integrating an ad provider into my app currently. I wish to place a fading message in front of the ad when the ad displays but have been completely unsuccessful. I made a function which adds a subview to my current view and tries to ...

Difference between $(document.body) and $('body')

I am a jQuery beginner and while going through some code examples I found: $(document.body) and $('body') Is there any difference between these two?...

ASP.net Getting the error "Access to the path is denied." while trying to upload files to my Windows Server 2008 R2 Web server

I have an asp.net webapplication that uploads files to a specific folder on the Web server. locally everything works fine, but when I deploy the application to the Webserver, I begin getting the error "Access to the path "D:\Attachments\myfile.doc" i...

MySQL - Trigger for updating same table after insert

Here's what I'm trying to do: When there's a new INSERT into the table ACCOUNTS, I need to update the row in ACCOUNTS where pk = NEW.edit_on by setting status='E' to denote that the particular (old) account has been edited. DELIMITER $$ DROP TRIGG...

Merge or combine by rownames

In the example below I have two datasets (Z and A). I want to merge or combine these sets by the ILMN numbers. If there is no match, fill in NA. z <- matrix(c(0,0,1,1,0,0,1,1,0,0,0,0,1,0,1,1,0,1,1,1,1,0,0,0,"RND1","WDR", "PLAC8","TYBSA","GRA","T...

Bootstrap: Position of dropdown menu relative to navbar item

I have the following dropdown <label class="dropdown-toggle" role="button" data-toggle="dropdown" data-target="#"> Action <b class="caret"></b></label> <ul class="dropdown-menu" role="menu" aria-labelledby="lang-select...

How to get the groups of a user in Active Directory? (c#, asp.net)

I use this code to get the groups of the current user. But I want to manually give the user and then get his groups. How can I do this? using System.Security.Principal; public ArrayList Groups() { ArrayList groups = new ArrayList(); foreac...

Can't find bundle for base name

I'm using a library that has a dependency on jfreechart (v 1.0.9). When I try to run the .jar, I get: java.util.MissingResourceException: Can't find bundle for base name org.jfree.chart.LocalizationBundle, locale en_US at java.util.Reso...

Automatic creation date for Django model form objects?

What's the best way to set a creation date for an object automatically, and also a field that will record when the object was last updated? models.py: created_at = models.DateTimeField(False, True, editable=False) updated_at = models.DateTimeField(...

How to create a circular ImageView in Android?

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

typesafe select onChange event using reactjs and typescript

I have figured out how to tie up an event handler on a SELECT element using an ugly cast of the event to any. Is it possible to retrieve the value in a type-safe manner without casting to any? import React = require('react'); interface ITestState ...

What is the difference between the operating system and the kernel?

I do not understand the difference between operating system and kernel. Can someone please explain it?...

How to create a readonly textbox in ASP.NET MVC3 Razor

How do I create a readonly textbox in ASP.NET MVC3 with the Razor view engine? Is there an HTMLHelper method available to do that? Something like the following? @Html.ReadOnlyTextBoxFor(m => m.userCode) ...

getting " (1) no such column: _id10 " error

I'm trying to retrieve the data of a particulate row in a sqlite database . and trying to display it to on a EditText but I'm getting this error , Kindly help me in solving the error ! Thanks in advance :) here is the logcat data showing error ...

How to get value by class name in JavaScript or jquery?

i wan to retrive all the value of this code using class name ..is it possible in jquery . i want to retrive only the text within a div or number of div may be change the next form <span class="HOEnZb adL"> <font color="#888888"> ...

Find ALL tweets from a user (not just the first 3,200)

With https://dev.twitter.com/docs/api/1/get/statuses/user_timeline I can get 3,200 most recent tweets. However, certain sites like http://www.mytweet16.com/ seems to bypass the limit, and my browse through the API documentation could not find anythin...

jquery json to string?

Instead of going from a json string and using $.parseJSON, I need to take my object and store it in a variable as string representing json. (A library I'm dealing with expects a malformed json type so I need to mess around with it to get it to work....

What is the function of the push / pop instructions used on registers in x86 assembly?

When reading about assembler I often come across people writing that they push a certain register of the processor and pop it again later to restore it's previous state. How can you push a register? Where is it pushed on? Why is this needed? Does t...

Where to install Android SDK on Mac OS X?

Where should the Android SDK be installed on Mac OS X?...

how to use Blob datatype in Postgres

I am using a Postgresql database in my rails application. To store large file or data in database I have used blob data type in MySql. For Postgres which data type I have to use instead of blob in MySql?...

Is it possible to select the last n items with nth-child?

Using a standard list, I'm trying to select the last 2 list items. I've various permutations of An+B but nothing seems to select the last 2: li:nth-child(n+2) {} /* selects from the second onwards */ li:nth-child(n-2) {} /* selects everything */ li:...

How can I replace text with CSS?

How can I replace text with CSS using a method like this: .pvw-title img[src*="IKON.img"] { visibility:hidden; } Instead of ( img[src*="IKON.img"] ), I need to use something that can replace text instead. I have to use [ ] to get it to work. ...

how to output every line in a file python

if data.find('!masters') != -1: f = open('masters.txt') lines = f.readline() for line in lines: print lines sck.send('PRIVMSG ' + chan + " " + str(lines) + '\r\n') f.close()...

How do I remove a single file from the staging area (undo git add)?

Situation: I have a Git repository with files already in the index. I make changes to several files, open Git and add these files to my staging area with "git add ." Question: How do I remove one of those files from the staging area but not remove ...

What are the differences between a pointer variable and a reference variable in C++?

I know references are syntactic sugar, so code is easier to read and write. But what are the differences?...

Can I have an IF block in DOS batch file?

In a DOS batch file we can only have 1 line if statement body? I think I found somewhere that I could use () for an if block just like the {} used in C-like programming languages, but it is not executing the statements when I try this. No error messa...

libstdc++.so.6: cannot open shared object file: No such file or directory

I want to run Cilkscreen command with a cilk++ program but I'v got this error /usr/local/cilk/bin/../lib32/pinbin: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory Can you help...

Iterating through a golang map

I have a map of type: map[string]interface{} And finally, I get to create something like (after deserializing from a yml file using goyaml) mymap = map[foo:map[first: 1] boo: map[second: 2]] How can I iterate through this map? I tried the followi...

Real life example, when to use OUTER / CROSS APPLY in SQL

I have been looking at CROSS / OUTER APPLY with a colleague and we're struggling to find real life examples of where to use them. I've spent quite a lot of time looking at When should I use Cross Apply over Inner Join? and googling but the main (onl...

Convert string with comma to integer

Is there any neat method to convert "1,112" to integer 1112, instead of 1? I've got one, but not neat: "1,112".split(',').join.to_i #=> 1112 ...

MySQL stored procedure vs function, which would I use when?

I'm looking at MySQL stored procedures and function. What is the real difference? They seem to be similar, but a function has more limitations. I'm likely wrong, but it seems a stored procedure can do everything and more a stored function can. Why...

What is PAGEIOLATCH_SH wait type in SQL Server?

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

How to delete an SVN project from SVN repository

Can anyone please suggest me how to delete complete SVN project from SVN repository (svn repository is in linux). I found "svn delete", but don't think it does the same. It only helps in removing files or sub-folders but not the entire project....

Restoring Nuget References?

I have solution & project in Visual Studio 2012. The project has a file packages.config in the root of the project. For the purposes of this question, lets assume I accidentally removed these libraries from the References section of my project...

Put icon inside input element in a form

How do I put an icon inside a form's input element? Live version at: Tidal Force theme...

How to extract the year from a Python datetime object?

I would like to extract the year from the current date using Python. In C#, this looks like: DateTime a = DateTime.Now() a.Year What is required in Python?...

C function that counts lines in file

When I try to run my program, I get the wrong number of lines printed. LINES: 0 This is the output although I have five lines in my .txt file Here is my program: #include<stdio.h> #include<stdlib.h> int countlines(char *filename); ...

Getting current device language in iOS?

I'd like to show the current language that the device UI is using. What code would I use? I want this as an NSString in fully spelled out format. (Not @"en_US") EDIT: For those driving on by, there are a ton of useful comments here, as the answer ...

How to fluently build JSON in Java?

I'm thinking of something like: String json = new JsonBuilder() .add("key1", "value1") .add("key2", "value2") .add("key3", new JsonBuilder() .add("innerKey1", "value3")) .toJson(); Which Java JSON library is best for this kind of fluen...

Proxies with Python 'Requests' module

Just a short, simple one about the excellent Requests module for Python. I can't seem to find in the documentation what the variable 'proxies' should contain. When I send it a dict with a standard "IP:PORT" value it rejected it asking for 2 values. ...

How to compare arrays in JavaScript?

I'd like to compare two arrays... ideally, efficiently. Nothing fancy, just true if they are identical, and false if not. Not surprisingly, the comparison operator doesn't seem to work. var a1 = [1,2,3]; var a2 = [1,2,3]; console.log(a1==a2); // ...

How can I run an external command asynchronously from Python?

I need to run a shell command asynchronously from a Python script. By this I mean that I want my Python script to continue running while the external command goes off and does whatever it needs to do. I read this post: Calling an external comma...

Fixed sidebar navigation in fluid twitter bootstrap 2.0

Is it possible to make sidebar navigation stay always fixed on scroll in fluid layout?...

What is the difference between background, backgroundTint, backgroundTintMode attributes in android layout xml?

While working with the android layout xml I came across backgroundTint attribute . I don't understand what is for. Also what is backgroundTintMode ??...

How can I reference a commit in an issue comment on GitHub?

I find a lot of answers on how to reference a GitHub issue in a git commit (using the #xxx notation). I'd like to reference a commit in my comment, generating a link to the commit details page?...

How do I add my bot to a channel?

I'm using my bot to tell important news, but when I using sendMessage to the channel I'm receiving the following error: {"ok":false,"error_code":403,"description":"Error: Forbidden: bot is not a participant of the channel"} In the Change Log they ...

How can I completely uninstall nodejs, npm and node in Ubuntu

The Question is similar to How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X) but for Ubuntu, and just for uninstalling. Installation was done by: sudo apt-get install node How do I completely remove npm along with all lib...

Evenly distributing n points on a sphere

I need an algorithm that can give me positions around a sphere for N points (less than 20, probably) that vaguely spreads them out. There's no need for "perfection", but I just need it so none of them are bunched together. This question provided go...

What is a reasonable length limit on person "Name" fields?

I have a simple webform that will allow unauthenticated users to input their information, including name. I gave the name field a limit of 50 characters to coincide with my database table where the field is varchar(50), but then I started to wonder. ...

Rails 3 migrations: Adding reference column?

If I create a new rails 3 migration with (for example) rails g migration tester title:tester user:references , everything works fine...however if I add a column with something along the lines of: rails g migration add_user_to_tester user:referenc...

How to obtain image size using standard Python class (without using external library)?

I am using Python 2.5. And using the standard classes from Python, I want to determine the image size of a file. I've heard PIL (Python Image Library), but it requires installation to work. How might I obtain an image's size without using any exter...

hide div tag on mobile view only?

I'm creating a fluid layout for a site. I'm trying to hide the contents of a <div> or the whole <div> itself in the mobile view, but not the tablet and desktop view. Here's what I've got so far... #title_message { clear: both; f...

Reference member variables as class members

In my place of work I see this style used extensively:- #include <iostream> using namespace std; class A { public: A(int& thing) : m_thing(thing) {} void printit() { cout << m_thing << endl; } protected: const int&a...

How to sort by column in descending order in Spark SQL?

I tried df.orderBy("col1").show(10) but it sorted in ascending order. df.sort("col1").show(10) also sorts in descending order. I looked on stackoverflow and the answers I found were all outdated or referred to RDDs. I'd like to use the native datafra...

Pandas: convert dtype 'object' to int

I've read an SQL query into Pandas and the values are coming in as dtype 'object', although they are strings, dates and integers. I am able to convert the date 'object' to a Pandas datetime dtype, but I'm getting an error when trying to convert the s...

How to initialise memory with new operator in C++?

I'm just beginning to get into C++ and I want to pick up some good habits. If I have just allocated an array of type int with the new operator, how can I initialise them all to 0 without looping through them all myself? Should I just use memset? Is t...

How to start Spyder IDE on Windows

I downloaded spyder using the pip install spyder in my windows 10 32-bit operating system, but i dont see any desktop icons or exe files to start running the IDE. I downloaded spyder 3, any my python is 3.6. I even tried creating a shortcut of spy...

App not setup: This app is still in development mode

I have followed the instructions here: The developers of this app have not set up this app properly for Facebook Login? Made my app public and the circle is green so the app is public. But when I try to login, I go to the Facebook app, it asks me...

Find Java classes implementing an interface

Some time ago, I came across a piece of code, that used some piece of standard Java functionality to locate the classes that implemented a given interface. I know the functions were hidden in some non-logical place, but they could be used for other c...

Failed to execute 'atob' on 'Window'

I'm trying to save my HTML file in Chrome when the user presses ctrl + s keys but Chrome is crashed. (I want to download just the source code of my HTML file) I read that it happens because my file is bigger than 1.99M.. In the first attempt (befo...

How to get all elements inside "div" that starts with a known text

I have a div element in an HTML document. I would like to extract all elements inside this div with id attributes starting with a known string (e.g. "q17_"). How can I achieve this using JavaScript ? If needed, for simplicity, I can assume that al...

CKEditor automatically strips classes from div

I am using CKEditor as a back end editor on my website. It is driving me round the bend though as it seems to want to change the code to how it sees fit whenever I press the source button. For example if I hit source and create a <div>... <...

Batch file to split .csv file

I have a very large .csv file (>500mb) and I wish to break this up into into smaller .csv files in command prompt. (Basically trying to find a linux "split" function in Windows". This has to be a batch script as my machine only has windows installed...

CHECK constraint in MySQL is not working

First I created a table like CREATE TABLE Customer ( SD integer CHECK (SD > 0), Last_Name varchar (30), First_Name varchar(30) ); and then inserted values in that table INSERT INTO Customer values ('-2','abc','zz'); MySQL doesn't show ...

C# Base64 String to JPEG Image

I am trying to convert a Base64String to an image which needs to be saved locally. At the moment, my code is able to save the image but when I open the saved image, it says "Invalid Image". Code: try { using (var imageFile = new StreamWriter...

If list index exists, do X

In my program, user inputs number n, and then inputs n number of strings, which get stored in a list. I need to code such that if a certain list index exists, then run a function. This is made more complicated by the fact that I have nested if stat...

replace special characters in a string python

I am using urllib to get a string of html from a website and need to put each word in the html document into a list. Here is the code I have so far. I keep getting an error. I have also copied the error below. import urllib.request url = input("Pl...

while-else-loop

Of course this is an impossible statement in java (to-date), however ideally I would like to implement it as it is at the heart of many iterations. For example the first multiple times it is called I'm doing it 650,000+ times when it is creating the ...

jQuery - passing value from one input to another

I have a form, with several input fields that are title, name, address etc What I want to do, is to get these values and 'put them' into values of other input fields. For example <label for="first_name">First Name</label> <input type...

RegEx to exclude a specific string constant

Can regular expression be utilized to match any string except a specific string constant let us say "ABC" ? Is this possible to exclude just one specific string constant? Thanks your help in advance....

Running an Excel macro via Python?

I'm trying to run a macro via python but I'm not sure how to get it working... I've got the following code so far, but it's not working. import win32com.client xl=win32com.client.Dispatch("Excel.Application") xl.Workbooks.Open(Filename="C:\test.xls...

How to check if a windows form is already open, and close it if it is?

I have a form "fm" that is a simple info window that opens every 10 mins (fm.Show();). How I can make that every 10 mins it will check if the form "fm" is open and if it is open it closes it and open it again! Now the form fm is always created with...

CSS to prevent child element from inheriting parent styles

Possible Duplicate: How do I prevent CSS inheritance? Is there a way to declare the CSS property of an element such that it will not affect any of its children or is there a way to declare CSS of an element to implement just the style specified an...

Excel - Combine multiple columns into one column

I have multiple lists that are in separate columns in excel. What I need to do is combine these columns of data into one big column. I do not care if there are duplicate entries, however I want it to skip row 1 of each column. Also what about if R...

How do I get the output of a shell command executed using into a variable from Jenkinsfile (groovy)?

I have something like this on a Jenkinsfile (Groovy) and I want to record the stdout and the exit code in a variable in order to use the information later. sh "ls -l" How can I do this, especially as it seems that you cannot really run any kind o...

How can I turn a List of Lists into a List in Java 8?

If I have a List<List<Object>>, how can I turn that into a List<Object> that contains all the objects in the same iteration order by using the features of Java 8?...

How do I get the full path to a Perl script that is executing?

I have Perl script and need to determine the full path and filename of the script during execution. I discovered that depending on how you call the script $0 varies and sometimes contains the fullpath+filename and sometimes just filename. Because the...

How to close a Java Swing application from the code

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

How to get the screen width and height in iOS?

How can one get the dimensions of the screen in iOS? Currently, I use: lCurrentWidth = self.view.frame.size.width; lCurrentHeight = self.view.frame.size.height; in viewWillAppear: and willAnimateRotationToInterfaceOrientation:duration: The first...

ValueError: cannot reshape array of size 30470400 into shape (50,1104,104)

I am trying to run threw this Tutorial http://emmanuelle.github.io/segmentation-of-3-d-tomography-images-with-python-and-scikit-image.html where I want to do a Segmentation of 3-D tomography images with Python. I'm struggling directly in the beg...

JQuery show/hide when hover

I have three links, Cat, Dog, Snakes. When I hover over each, the content relating to each link should change. So if i hover over cat, then cat content will appear, if i hover over dog the cat content will smoothly disappear and the dog content wil...

DISTINCT clause with WHERE

How can I use the DISTINCT clause with WHERE? For example: SELECT * FROM table WHERE DISTINCT email; -- email is a column name I want to select all columns from a table with distinct email addresses....

Parse String date in (yyyy-MM-dd) format

I have a string in the form "2013-09-18". I want to convert it into a java.util.Date. I am doing this SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date convertedCurrentDate = sdf.parse(currentDateText); The convertedCurrentDate is c...

How to create Drawable from resource

I have an image res/drawable/test.png (R.drawable.test). I want to pass this image to a function which accepts Drawable, e.g. mButton.setCompoundDrawables(). So how can I convert an image resource to a Drawable?...

Printing tuple with string formatting in Python

So, i have this problem. I got tuple (1,2,3) which i should print with string formatting. eg. tup = (1,2,3) print "this is a tuple %something" % (tup) and this should print tuple representation with brackets, like This is a tuple (1,2,3) But...

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

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

Using BeautifulSoup to search HTML for string

I am using BeautifulSoup to look for user-entered strings on a specific page. For example, I want to see if the string 'Python' is located on the page: http://python.org When I used: find_string = soup.body.findAll(text='Python'), find_string returne...

What is the difference between <html lang="en"> and <html lang="en-US">?

What is the difference between <html lang="en"> and <html lang="en-US">? What other values can follow the dash? According to w3.org "Any two-letter subcode is understood to be a [ISO3166] country code." so does that mean any value listed...

git am error: "patch does not apply"

I am trying to move several commits from one project to the second, similar one, using git. So I created a patch, containing 5 commits: git format-patch 4af51 --stdout > changes.patch Then move the patch to second project's folder and wants ...

Single Result from Database by using mySQLi

I am trying to use mySQLi for the first time. I have done it in case of loop. Loop results are showing but i am stuck when i try to show single record. Here is loop code that is working. <?php // Connect To DB $hostname="localhost"; $database="my...

Show/Hide Multiple Divs with Jquery

I want to use some buttons to show/hide multiple divs using jquery. The page will initially show all divs. The idea then is that there will be a button to reset (show all) and then separate buttons to show a particular div while hiding the rest. An...

How to show an alert box in PHP?

I want to display an alert box showing a message with PHP. Here is my PHP code: <?php header("Location:form.php"); echo '<script language="javascript">'; echo 'alert(message successfully sent)'; //not showing an alert box. echo...

How to pass arguments from command line to gradle

I'm trying to pass an argument from command line to a java class. I followed this post: http://gradle.1045684.n5.nabble.com/Gradle-application-plugin-question-td5539555.html but the code does not work for me (perhaps it is not meant for JavaExec?). ...

How to flatten only some dimensions of a numpy array

Is there a quick way to "sub-flatten" or flatten only some of the first dimensions in a numpy array? For example, given a numpy array of dimensions (50,100,25), the resultant dimensions would be (5000,25)...

Putting -moz-available and -webkit-fill-available in one width (css property)

I want to make the width of the footer browser-independent. For Mozilla I want to use the value of -moz-available, and when a user uses Opera, then CSS should get the values from -webkit-fill-available. How to do this in CSS3? I tried to do some...

"detached entity passed to persist error" with JPA/EJB code

I am trying to run this basic JPA/EJB code: public static void main(String[] args){ UserBean user = new UserBean(); user.setId(1); user.setUserName("name1"); user.setPassword("passwd1"); em.persist(user);...

SQL Server 2008 Windows Auth Login Error: The login is from an untrusted domain

When attempting to connect to a SQL Server 2008 Instance using Management Studio, I get the following error: Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. (Microsoft SQL Server, Error: 1...

Sort arrays of primitive types in descending order

I've got a large array of primitive types (double). How do I sort the elements in descending order? Unfortunately the Java API doesn't support sorting of primitive types with a Comparator. The first approach that probably comes to mind is to conver...

Change Schema Name Of Table In SQL

I want to change schema name of table Employees in Database. In the current table Employees database schema name is dbo I want to change it to exe. How can I do it ? Example: FROM dbo.Employees TO exe.Employees I tried with this query: ALT...

How to access form methods and controls from a class in C#?

I'm working on a C# program, and right now I have one Form and a couple of classes. I would like to be able to access some of the Form controls (such as a TextBox) from my class. When I try to change the text in the TextBox from my class I get the fo...

How to correctly dismiss a DialogFragment?

The docs say this for the dismiss() method from the Dialog class: Dismiss this dialog, removing it from the screen. This method can be invoked safely from any thread. Note that you should not override this method to do cleanup when ...

Regular expression: zero or more occurrences of optional character /

What is the regular expression pattern to say: zero or more occurrences of the character / ?...

Initializing a two dimensional std::vector

So, I have the following: std::vector< std::vector <int> > fog; and I am initializing it very naively like: for(int i=0; i<A_NUMBER; i++) { std::vector <int> fogRow; for(int j=0; j<OTHER_NUM...

How to pass command line argument to gnuplot?

I want to use gnuplot to draw figure from data file, say foo.data. Currently, I hardcoded the data file name in the command file, say foo.plt, and run command gnuplot foo.plg to plot data. However, I want to pass the data file name as a command argum...

Visual Studio 2015 is very slow

I just finished the installation and the whole IDE is super slow. It seems like it's making some kind of heavy CPU calls in the background where the whole IDE literally freezes and becomes unresponsive for about 2-3 seconds. I was not having this is...

Black transparent overlay on image hover with only CSS?

I'm trying to add a transparent black overlay to an image whenever the mouse is hovering over the image with only CSS. Is this possible? I tried this: http://jsfiddle.net/Zf5am/565/ But I can't get the div to show up. <div class="image">...

How to create a string with format?

I need to create a string with format which can convert int, long, double etc. types into string. Using Obj-C, I can do it via below way. NSString *str = [NSString stringWithFormat:@"%d , %f, %ld, %@", INT_VALUE, FLOAT_VALUE, DOUBLE_VALUE, STRING_VA...

How can I copy data from one column to another in the same table?

Is it possible to copy data from column A to column B for all records in a table in SQL?...

How long do browsers cache HTTP 301s?

I am debugging a problem with a HTTP 301 Permanent Redirect. After a quick test, it seems that Safari clears its cache of 301s when it is restarted, but Firefox does not. When do IE, Chrome, Firefox and Safari clear their cache of 301s? UPDATE: For...

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

How to check if one of the following items is in a list?

I'm trying to find a short way to see if any of the following items is in a list, but my first attempt does not work. Besides writing a function to accomplish this, is the any short way to check if one of multiple items is in a list. >>> a ...

Custom CSS for <audio> tag?

I'm building a music player web application which implements the HTML5 audio tag, however would like it to look consistent across browsers - is it possible to define my own custom CSS? And how? cheers Fela...

List of All Folders and Sub-folders

In Linux, I want to find out all Folder/Sub-folder name and redirect to text file I tried ls -alR > list.txt, but it gives all files+folders...

Calculating frames per second in a game

What's a good algorithm for calculating frames per second in a game? I want to show it as a number in the corner of the screen. If I just look at how long it took to render the last frame the number changes too fast. Bonus points if your answer upda...

Set focus on TextBox in WPF from view model

I have a TextBox and a Button in my view. Now I am checking a condition upon button click and if the condition turns out to be false, displaying the message to the user, and then I have to set the cursor to the TextBox control. if (companyref == nu...

How to export all collections in MongoDB?

I want to export all collections in MongoDB by the command: mongoexport -d dbname -o Mongo.json The result is: No collection specified! The manual says, if you don't specify a collection, all collections will be exported. However, why doesn't...

Where can I find a NuGet package for upgrading to System.Web.Http v5.0.0.0?

Just upgraded an ASP.NET MVC4 project to use Unity.WebApi version 5.0.0.0 and it requires System.Web.Http v 5.0.0.0 as per the following error: Assembly 'Unity.WebApi, Version=5.1.0.0, Culture=neutral, PublicKeyToken=43da31bc42a85347' uses 'System.We...

sublime text2 python error message /usr/bin/python: can't find '__main__' module in ''

I installed sublime text 2 to OSX 10.8.2. In my Mac, python 2.7.3 is installed. In sublime text2, I just type print 'Hello' but error occurred like below. /usr/bin/python: can't find '__main__' module in '' [Finished in 0.2s with exit code 1] ...

Converting json results to a date

Possible Duplicate: How to format a JSON date? I have the following result from a $getJSON call from JavaScript. How do I convert the start property to a proper date in JavaScript? [ {"id":1,"start":"/Date(1238540400000)/"}, {"id"...

What is Node.js?

I don't fully get what Node.js is all about. Maybe it's because I am mainly a web based business application developer. What is it and what is the use of it? My understanding so far is that: The programming model is event driven, especially the wa...

SQL Query to add a new column after an existing column in SQL Server 2005

I need a SQL query which add a new column after an existing column, so the column will be added in a specific order. Please suggest me if any ALTER query which do that....

Copy and paste content from one file to another file in vi

I am working with two files, and I need to copy a few lines from one file and paste into another file. I know how to copy (yy) and paste (p) in the same file. But that doesn't work for different files. How is this done? Also, is there a way to cut-p...

How to resize superview to fit all subviews with autolayout?

My understanding of autolayout is that it takes the size of superview and base on constrains and intrinsic sizes it calculates positions of subviews. Is there a way to reverse this process? I want to resize superview on the base of constrains and in...

Index Error: list index out of range (Python)

I am a beginner programmer and im not sure what this means... Index Error: list index out of range...

What is a good game engine that uses Lua?

I know Love2D and Corona SDK (for mobile devices). Is there any other game engines that use Lua you recommend?...

How to flush output of print function?

How do I force Python's print function to output to the screen? This is not a duplicate of Disable output buffering - the linked question is attempting unbuffered output, while this is more general. The top answers in that question are too powerful ...

How can I solve the error LNK2019: unresolved external symbol - function?

I get this error, but I don't know how to fix it. I'm using Visual Studio 2013. I made the solution name MyProjectTest This is the structure of my test solution: -function.h #ifndef MY_FUNCTION_H #define MY_FUNCTION_H int multiple(int x, int y); #e...

How to create a connection string in asp.net c#

I am working on asp.net c# project, for connection I used: SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\19-02\ABCC\App_Data\abcc.mdf;Integrated Security=True;User Instance=True"); but I want to get this conn...

git: How to ignore all present untracked files?

Is there a handy way to ignore all untracked files and folders in a git repository? (I know about the .gitignore.) So git status would provide a clean result again....

Setting default value for TypeScript object passed as argument

function sayName(params: {firstName: string; lastName?: string}) { params.lastName = params.lastName || 'smith'; // <<-- any better alternative to this? var name = params.firstName + params.lastName alert(name); } sayName({firstNa...

Hive ParseException - cannot recognize input near 'end' 'string'

I am getting the following error when trying to create a Hive table from an existing DynamoDB table: NoViableAltException(88@[]) at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.identifier(HiveParser_IdentifiersParser.java:9123) at or...

Maven: Non-resolvable parent POM

I have my maven project setup as 1 shell projects and 4 children modules. When I try to build the shell. I get: [INFO] Scanning for projects... [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project module1:1.0_A0 (...

Difference between final and effectively final

I'm playing with lambdas in Java 8 and I came across warning local variables referenced from a lambda expression must be final or effectively final. I know that when I use variables inside anonymous class they must be final in outer class, but still ...

Qt: How do I handle the event of the user pressing the 'X' (close) button?

I am developing an application using Qt. I don't know which slot corresponds to the event of "the user clicking the 'X'(close) button of the window frame" i.e. this button: If there isn't a slot for this, can anyone suggest me some other method by...

HTML5 Canvas Resize (Downscale) Image High Quality?

I use html5 canvas elements to resize images im my browser. It turns out that the quality is very low. I found this: Disable Interpolation when Scaling a <canvas> but it does not help to increase the quality. Below is my css and js code as wel...

Postman - How to see request with headers and body data with variables substituted

I am using the Postman Chrome plugin to invoke HTTP requests for software testing. I use the Environments feature with Environment and Global Variables to substitute variables in my requests headers and body. The variable substitution is working cor...

How to select all textareas and textboxes using jQuery?

How can I select all textboxes and textareas, e.g: <input type='text' /> and <textarea></textarea> on a page and have the property style.width="90%"; applied to them?...

PIG how to count a number of rows in alias

I did something like this to count the number of rows in an alias in PIG: logs = LOAD 'log' logs_w_one = foreach logs generate 1 as one; logs_group = group logs_w_one all; logs_count = foreach logs_group generate SUM(logs_w_one.one); dump logs_count...

CROSS JOIN vs INNER JOIN in SQL

What is the difference between CROSS JOIN and INNER JOIN? CROSS JOIN: SELECT Movies.CustomerID, Movies.Movie, Customers.Age, Customers.Gender, Customers.[Education Level], Customers.[Internet Connection], Customers.[Marital Status], ...

What is the difference between max-device-width and max-width for mobile web?

I need to develop some html pages for iphone/android phones, but what is the difference between max-device-width and max-width? I need to use different css for different screen size. @media all and (max-device-width: 400px) @media all and (max-widt...

How can I use MS Visual Studio for Android Development?

Can you use Visual Studio for Android Development? If so how would you set the android SDK instead of .NET framework and are there any special settings or configuration?...

Equal height rows in a flex container

As you can see, the list-items in the first row have same height. But items in the second row have different heights. I want all items to have a uniform height. Is there any way to achieve this without giving fixed-height and only using flexbox? ...

Python's equivalent of && (logical-and) in an if-statement

Here's my code: def front_back(a, b): # +++your code here+++ if len(a) % 2 == 0 && len(b) % 2 == 0: return a[:(len(a)/2)] + b[:(len(b)/2)] + a[(len(a)/2):] + b[(len(b)/2):] else: #todo! Not yet done. :P return I'm getting ...

what does "dead beef" mean?

What does the word "dead beef" mean? I read it from a interview question. It has something to do with ipv6. I figured it could be a random hex number used for examples, like "The quick brown fox jumps over the lazy dog". Is my understanding correct?...

Setting the height of a SELECT in IE

IE seems to ignore the height set in CSS when rendering a HTML SELECT. Are there any work around's for this or do we have to just accept IE will not look as good as other browsers?...

Qt - reading from a text file

I have a table view with three columns; I have just passed to write into text file using this code QFile file("/home/hamad/lesson11.txt"); if(!file.open(QIODevice::WriteOnly)) { QMessageBox::information(0,"error",file.errorString()); } QString d...

How can I install a package with go get?

I want to install packages from github to my gopath, I have tried this: go get github.com:capotej/groupcache-db-experiment.git the repository is here....

Error: Module not specified (IntelliJ IDEA)

I was trying to execute a simple program in IntelliJ IDEA as a static web project. I'm newbie and I'm learning web development with Node.js. I took help from the official website of IntelliJ IDEA, but the error was same. Though, I configured the sett...

How to create a Restful web service with input parameters?

I am creating restful web service and i wanted to know how do we create a service with input parameters and also how to invoke it from a web browser. For example @Path("/todo") public class TodoResource { // This method is called if XMLis reque...

How can I stage and commit all files, including newly added files, using a single command?

How can I stage and commit all files, including newly added files, using a single command?...

How do I use disk caching in Picasso?

I am using Picasso to display image in my android app: /** * load image.This is within a activity so this context is activity */ public void loadImage (){ Picasso picasso = Picasso.with(this); picasso.setDebugging(true); picasso.load(qu...

jQuery toggle CSS?

I want to toggle between CSS so when a user clicks the button (#user_button) it shows the menu (#user_options) and changes the CSS, and when the user clicks it again it goes back to normal. So far this is all I have: $('#user_button').click( functio...

How to convert string to double with proper cultureinfo

I have two nvarchar fields in a database to store the DataType and DefaultValue, and I have a DataType Double and value as 65.89875 in English format. Now I want the user to see the value as per the selected browser language format (65.89875 in Engl...

Spring Boot: Is it possible to use external application.properties files in arbitrary directories with a fat jar?

Is it possible to have multiple application.properties file? (EDIT: note that this question evolved to the one on the title.) I tried to have 2 files. The first one is on the root folder in the application Jar. The second one is on the directory w...

What is “2's Complement”?

I'm in a computer systems course and have been struggling, in part, with Two's Complement. I want to understand it but everything I've read hasn't brought the picture together for me. I've read the wikipedia article and various other articles, includ...

Total size of the contents of all the files in a directory

When I use ls or du, I get the amount of disk space each file is occupying. I need the sum total of all the data in files and subdirectories I would get if I opened each file and counted the bytes. Bonus points if I can get this without opening eac...

Array of char* should end at '\0' or "\0"?

Lets say we have an array of char pointers char* array[] = { "abc", "def" }; Now what should be put in the end ? char* array[] = { "abc", "def", '\0' }; or char* array[] = { "abc", "def", "\0" }; Though, both works. We only have to put the c...

Why has it failed to load main-class manifest attribute from a JAR file?

I have created a JAR file in this way jar cf jar-file input-files. Now, I'm trying to run it. Running it does not work (jre command is not found): jre -cp app.jar MainClass This does not work either: java -jar main.jar (Failed to load Main-Clas...

How to stretch div height to fill parent div - CSS

I have a page with divs like below <div id="container"> <div id="A"></div> <div id="B"> <div id="B1"></div> <div id="B2">B2</div>...

Unzip files (7-zip) via cmd command

I try to unzip a file via CMD. So I install WinZip (and its plugin to cmd), WinRAR, and 7-zip. But when I try to execute a command via the CMD: 7z e myzip.zip It gives the next error: 7z is not recognized as an internal or external command In...

what is difference between success and .done() method of $.ajax

Can anyone help me? I am not able to understand the difference between success and .done() of $.ajax. If possible please give examples....

In c, in bool, true == 1 and false == 0?

Just to clarify I found similar answer but for C++, I'm kinda new to coding so I'm not sure whether it applies to C as well....

Convert bytes to bits in python

I am working with Python3.2. I need to take a hex stream as an input and parse it at bit-level. So I used bytes.fromhex(input_str) to convert the string to actual bytes. Now how do I convert these bytes to bits?...

PHP order array by date?

Possible Duplicate: PHP Sort a multidimensional array by element containing date I have some data from XML or JSON in a PHP array that looks like this: [0]= array(2) { ["title"]= string(38) "Another title" ["date"]= string(31) "Fr...

How to retrieve the current value of an oracle sequence without increment it?

Is there an SQL instruction to retrieve the value of a sequence that does not increment it. Thanks. EDIT AND CONCLUSION As stated by Justin Cave It's not useful to try to "save" sequence number so select a_seq.nextval from dual; is good enough...

CURL ERROR: Recv failure: Connection reset by peer - PHP Curl

I'm having this strange error, CURL ERROR: Recv failure: Connection reset by peer This is how it happens, if I did not connect to the server and all of a sudden trying to connect to the server via CURL in PHP I get the error. When I run the CURL scr...

jQuery: what is the best way to restrict "number"-only input for textboxes? (allow decimal points)

What is the best way to restrict "number"-only input for textboxes? I am looking for something that allows decimal points. I see a lot of examples. But have yet to decide which one to use. Update from Praveen Jeganathan No more plugins, jQuery ha...

Using psql to connect to PostgreSQL in SSL mode

I am trying to configure ssl certificate for PostgreSQL server. I have created a certificate file (server.crt) and key (server.key) in data directory and update the parameter SSL to "on" to enable secure connection. I just want only the ser...

MVC 3: How to render a view without its layout page when loaded via ajax?

I am learning about Progressive Enhancement and I have a question about AJAXifying views. In my MVC 3 project I have a layout page, a viewstart page, and two plain views. The viewstart page is in the root of the Views folder and thus applies to all ...

How to fill in form field, and submit, using javascript?

If I have an html document whose rough structure is <html> <head> </head> <body class="bodyclass" id="bodyid"> <div class="headerstuff">..stuff...</div> <div class = "body"> <form action="http://example.c...

React setState not updating state

So I have this: let total = newDealersDeckTotal.reduce(function(a, b) { return a + b; }, 0); console.log(total, 'tittal'); //outputs correct total setTimeout(() => { this.setState({dealersOverallTotal: total}); }, 10); console.log(this.stat...

How to install a certificate in Xcode (preparing for app store submission)

I wan't to select my distribution profile in Code Signing Identity in the build tab of targets. But all my certificates (developer, ad hoc, ...) are grayed out. So it seems that the new profile XXX.mobileprovision is not installed. The guidelines say...

How can I split a shell command over multiple lines when using an IF statement?

How can I split a command over multiple lines in the shell, when the command is part of an if statement? This works: if ! fab --fabfile=.deploy/fabfile.py --forward-agent --disable-known-hosts deploy:$target; then rc=1 ...

How do I use Assert.Throws to assert the type of the exception?

How do I use Assert.Throws to assert the type of the exception and the actual message wording? Something like this: Assert.Throws<Exception>( ()=>user.MakeUserActive()).WithMessage("Actual exception message") The method I am t...

How to clear all data in a listBox?

I am after a statement that will clear all strings / data that is currently in a listBox, I have tried: private void cleanlistbox(object sender, EventArgs e) { listBox1.ResetText(); } ...

Changing tab bar item image and text color iOS

Here is my tab bar: The following image shows the program being run and the "NEWS" item selected: It is clear the bar tint color is working fine as I want ! But the tintColor only affects the image and not the text. Also, when the an item is ...

Get Root Directory Path of a PHP project

I have this folder structure in my PHP project. (this is as shown in eclips) -MySystem +Code +Data_Access -Public_HTML +css +js +Templates -resources When I try this code echo $_SERVER['DOCUMENT_ROOT'] o...

What does <? php echo ("<pre>"); ..... echo("</pre>"); ?> mean?

The question is the tag <pre> </pre> I've seen one script I am working on, uses it: echo ("<pre>"); .... .... echo ("</pre>"); What exactly does it do ? Is it an Html tag or a PHP ? I've searched on Google but nothing ...

ant build.xml file doesn't exist

After the installation of my ant in my windows 7 . In cmd i typed ant -v it's given the ant version but it says the following also. Buildfile: build.xml does not exist! Build failed What's the problem in the system. How i can rectify this issue? ...

Alternative to mysql_real_escape_string without connecting to DB

I'd like to have a function behaving as mysql_real_escape_string without connecting to database as at times I need to do dry testing without DB connection. mysql_escape_string is deprecated and therefore is undesirable. Some of my findings: http://w...

How to implement Rate It feature in Android App

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

onchange event for html.dropdownlist

I am trying to trigger an action method for onchange event for dropdownlist, how can I do this without using jquery onchange. @Html.DropDownList("Sortby", new SelectListItem[] { new Sel...

How do I resize a Google Map with JavaScript after it has loaded?

I have a 'mapwrap' div set to 400px x 400px and inside that I have a Google 'map' set to 100% x 100%. So the map loads at 400 x 400px, then with JavaScript I resize the 'mapwrap' to 100% x 100% of the screen - the google map resizes to the whole scre...

resize2fs: Bad magic number in super-block while trying to open

I am trying to resize a logical volume on CentOS7 but am running into the following error: resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root Couldn't find valid filesystem superblo...

! [rejected] master -> master (fetch first)

Is there a good way to explain how to resolve "! [rejected] master -> master (fetch first)'" in Git? When I use this command $ git push origin master it display an error message. ! [rejected] master -> master (fetch first) error: fai...

vertical-align image in div

i have problem with image vertical-align in div .img_thumb { float: left; height: 120px; margin-bottom: 5px; margin-left: 9px; position: relative; width: 147px; background-color: rgba(0, 0, 0, 0.5); border-radius: 3px...

Using CSS to affect div style inside iframe

Is it possible to change styles of a div that resides inside an iframe on the page using CSS only?...

When should we call System.exit in Java

In Java, What is the difference with or without System.exit(0) in following code? public class TestExit { public static void main(String[] args) { System.out.println("hello world"); System.exit(0); // is it necessar...

How to read a local text file?

I’m trying to write a simple text file reader by creating a function that takes in the file’s path and converts each line of text into a char array, but it’s not working. function readTextFile() { var rawFile = new XMLHttpRequest(); rawFil...

Why would $_FILES be empty when uploading files to PHP?

I have WampServer 2 installed on my Windows 7 computer. I'm using Apache 2.2.11 and PHP 5.2.11. When I attempt to upload any file from a form, it seems to upload, but in PHP, the $_FILES array is empty. There is no file in the c:\wamp\tmp folder. I h...

Maven: Failed to retrieve plugin descriptor error

I configured Maven 3.0.3 and tried to download a sample project using archetypes with this command: mvn archetype:generate -DarchetypeGroupId=org.graniteds.archetypes -DarchetypeArtifactId=graniteds-tide-spring-jpa-hibernate...

What is a non-capturing group in regular expressions?

How are non-capturing groups, i.e. (?:), used in regular expressions and what are they good for?...

Remove Style on Element

I was wondering if this is possible. There's this element <div id="sample_id" style="width:100px; height:100px; color:red;"> So I want to remove width:100px; and height:100px; the result would be <div id="sample_id" style="color:red;"...

Why won't my PHP app send a 404 error?

if (strstr($_SERVER['REQUEST_URI'],'index.php')) { header('HTTP/1.0 404 Not Found'); } Why wont this work? I get a blank page....

Android: combining text & image on a Button or ImageButton

I'm trying to have an image (as the background) on a button and add dynamically, depending on what's happening during run-time, some text above/over the image. If I use ImageButton I don't even have the possibility to add text. If I use Button I can...

Biggest differences of Thrift vs Protocol Buffers?

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

Android ListView Text Color

I am trying to set the ListView textColor to black, since I am using a white background. Here is my MailActivity public class MailActivity extends ListActivity { String[] listItems = { "Compose", "Inbox", "Drafts", "Sent" }; @Override ...

How do I combine 2 select statements into one?

I am a noob when it comes to SQL syntax. I have a table with lots of rows and columns of course :P Lets say it looks like this: AAA BBB CCC DDD ----------------------- Row1 | 1 A D X Row2 | 2 B C X Row3 | 3 C D Z Now I wa...

Python print statement “Syntax Error: invalid syntax”

Why is Python giving me a syntax error at the simple print statement on line 9? import hashlib, sys m = hashlib.md5() hash = "" hash_file = raw_input("What is the file name in which the hash resides? ") wordlist = raw_input("What is your wordlist? ...

Generate random integers between 0 and 9

How can I generate random integers between 0 and 9 (inclusive) in Python? For example, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9...

Best way to clear a PHP array's values

Which is more efficient for clearing all values in an array? The first one would require me to use that function each time in the loop of the second example. foreach ($array as $i => $value) { unset($array[$i]); } Or this foreach($blah_bla...

Send raw ZPL to Zebra printer via USB

Typically, when I plug in my Zebra LP 2844-Z to the USB port, the computer sees it as a printer and I can print to it from notepad like any other generic printer. However, my application has some bar code features. My application parses some input an...

How to create a GUID / UUID

I'm trying to create globally-unique identifiers in JavaScript. I'm not sure what routines are available on all browsers, how "random" and seeded the built-in random number generator is, etc. The GUID / UUID should be at least 32 character...

HTML button onclick event

This might be a very basic question; believe me I found very hard to find the answer to this question on the internet. I have 3 HTML pages stored in my server (Tomcat locally) & i want to open these HTML pages on a button click. Any help would ...

How to set placeholder value using CSS?

I want to set the placeholder value of an input box using only CSS and no JavaScript or jQuery. How can I do this?...

Using Pairs or 2-tuples in Java

My Hashtable in Java would benefit from a value having a tuple structure. What data structure can I use in Java to do that? Hashtable<Long, Tuple<Set<Long>,Set<Long>>> table = ... ...

Moving average or running mean

Is there a SciPy function or NumPy function or module for Python that calculates the running mean of a 1D array given a specific window?...

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 get the url parameters using AngularJS

HTML source code <div ng-app=""> <div ng-controller="test"> <div ng-address-bar browser="html5"></div> <br><br> $location.url() = {{$location.url()}}<br> $location.search() = {{$...

How to convert currentTimeMillis to a date in Java?

I have milliseconds in certain log file generated in server, I also know the locale from where the log file was generated, my problem is to convert milliseconds to date in specified format. The processing of that log is happening on server located in...

maximum value of int

Is there any code to find the maximum value of integer (accordingly to the compiler) in C/C++ like Integer.MaxValue function in java?...

Where can I find php.ini?

A few years ago I installed Apache 2.2x and PHP 5.3.1 on a Linux server I maintain. I used .tar.gz's and built them as instructed (instead of rpms and what-have-you). And all was fine. Today I need to install this which seems like a PHP library. I...

Access blocked by CORS policy: Response to preflight request doesn't pass access control check

I'm trying to create a user administration API for my web app. When I send an API call from my frontend to my backend, a cors error occurs. How can the cors problem be solved? I've read a lot of threads, but I haven't made any progress. Error after ...

How to create tar.gz archive file in Windows?

How to create tar.gz archive of my files in Windows to upload and extract in cPanel?...

git with IntelliJ IDEA: Could not read from remote repository

Since a few weeks, I'm not able to pull or push from or to the remote repository. I thought it happend when upgrading to IntelliJ IDEA 14, but I can reproduce the problem with IDEA 13.1.5 as well. The tooltip says "Fetch failed fatal: Could not read...

How to fix: Error device not found with ADB.exe

In cmd when I try to do the command: adb shell it shows device not found error. Can someone help me please. It'll be appreciated....

How to get the browser viewport dimensions?

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

How to clear out session on log out

I redirect the user to the login page when user click log out however I don't think it clears any application or session because all the data persisted when the user logs back in. Currently the login page has a login control and the code behind on t...

How can I analyze a heap dump in IntelliJ? (memory leak)

I have generated a heap dump from my java application which has been running for some days with the jmap tool -> this results in a large binary heap dump file. How can I perform memory analysis of this heap dump within IntellIJ IDEA? I know that th...

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

Can I exclude some concrete urls from <url-pattern> inside <filter-mapping>?

I want some concrete filter to be applied for all urls except for one concrete (i.e. for /* except for /specialpath). Is there a possibility to do that? sample code: <filter> <filter-name>SomeFilter</filter-name> <fi...

Ctrl+click doesn't work in Eclipse Juno

For every version of Eclipse I've used prior to Juno, ctrl+click would find the declaration of a variable/class/method. It was an extremely useful feature when dealing with a large code base. How do I get Juno to do this?...

Jackson - Deserialize using generic class

I have a json string, which I should deSerialize to the following class class Data <T> { int found; Class<T> hits } How do I do it? This is the usual way mapper.readValue(jsonString, Data.class); But how do I mention what T ...

Batch file to map a drive when the folder name contains spaces

I am trying to map a drive using a batch file. I have tried: net use m: \\Server01\myfolder /USER:mynetwork\Administrator "Mypassword" /persistent:yes It works fine. The problem comes when I try to map a folder with spaces on its name: net use m:...

How to get substring of NSString?

If I want to get a value from the NSString @"value:hello World:value", what should I use? The return value I want is @"hello World"....

How to convert a datetime to string in T-SQL

I'm surprised not to be able to find this question here already. I have a date time var and I want to convert it to a string so that I can append it to another string. I want it in a format that can be converted easily back to a date time. How can ...

How to remove/ignore :hover css style on touch devices

I want to ignore all :hover CSS declarations if a user visits our website via touch device. Because the :hover CSS does not make sense, and it can even be disturbing if a tablet triggers it on click/tap because then it might stick until the element l...

How to always show the vertical scrollbar in a browser?

I want to always show vertical scrollbar in my webpage. Is it possible using javascript? I think it is possible using javascript or jQuery. I want vertical scrollbar whether there is enough content to show or not. thanks....

Communication between multiple docker-compose projects

I have two separate docker-compose.yml files in two different folders: ~/front/docker-compose.yml ~/api/docker-compose.yml How can I make sure that a container in front can send requests to a container in api? I know that --default-gateway optio...

Combining paste() and expression() functions in plot labels

Consider this simple example: labNames <- c('xLab','yLabl') plot(c(1:10),xlab=expression(paste(labName[1], x^2)),ylab=expression(paste(labName[2], y^2))) What I want is for the character entry defined by the variable 'labName, 'xLab' or 'yLab...

C# Wait until condition is true

I am trying to write a code that executes when a condition is met. Currently, I am using while...loop, which I know is not very efficient. I am also looking at AutoResetEvent() but i don't know how to implement it such that it keeps checking until th...

connecting to MySQL from the command line

How can you connect to MySQL from the command line in a Mac? (i.e. show me the code) I'm doing a PHP/SQL tutorial, but it starts by assuming you're already in MySQL....

SQL Server Express 2008 Install Side-by-side w/ SQL 2005 Express Fails

When I try to install a new instance of SQL Server 2008 Express on a development machine with SQL 2005 Express already up and running, the install validation fails because the "SQL 2005 Express tools" are installed and I'm told to remove them. What ...

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

Fullscreen Activity in Android?

How do I make an activity full screen? I mean without the notification bar. Any ideas?...

Remote JMX connection

I'm trying to open a JMX connection to java application running on a remote machine. The application JVM is configured with the following options: com.sun.management.jmxremote com.sun.management.jmxremote.port=1088 com.sun.management.jmxremote.aut...

How to search for a string inside an array of strings

After searching for an answer in other posts, I felt I have to ask this. I looked at How do I check if an array includes an object in JavaScript? and Best way to find if an item is in a JavaScript array? and couldn't get the code there to work. I am...

How to make node.js require absolute? (instead of relative)

I would like to require my files always by the root of my project and not relative to the current module. For example if you look at https://github.com/visionmedia/express/blob/2820f2227de0229c5d7f28009aa432f9f3a7b5f9/examples/downloads/app.js line ...

AsyncTask Android example

I was reading about AsyncTask, and I tried the simple program below. But it does not seem to work. How can I make it work? public class AsyncTaskActivity extends Activity { Button btn; /** Called when the activity is first created. */ ...

How to see indexes for a database or table in MySQL?

How do I see if my database has any indexes on it? How about for a specific table?...

Create a shortcut on Desktop

I want to create a shortcut pointing to some EXE file, on the desktop, using .NET Framework 3.5 and relying on an official Windows API. How can I do that? ...

How to check if a variable is a dictionary in Python?

How would you check if a variable is a dictionary in Python? For example, I'd like it to loop through the values in the dictionary until it finds a dictionary. Then, loop through the one it finds: dict = {'abc': 'abc', 'def': {'ghi': 'ghi', 'jkl': 'j...

How to convert Integer to int?

I am working on a web application in which data will be transfer between client & server side. I already know that JavaScript int != Java int. Because, Java int cannot be null, right. Now this is the problem I am facing. I changed my Java int...

How to use the read command in Bash?

When I try to use the read command in Bash like this: echo hello | read str echo $str Nothing echoed, while I think str should contain the string hello. Can anybody please help me understand this behavior?...

What is a "web service" in plain English?

I've been reading about "web services" here on SO, on Wikipedia, Google, etc., and I don't quite understand what they are. What is the plain English definition/description? If I make a simple website using PHP that just, say, prints a random intege...

How can I find a specific file from a Linux terminal?

I am trying to find where index.html is located on my linux server, and was wondering if there was a command to do that. Very new to linux and appreciate any help I can get....

C-like structures in Python

Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 self.field2 = field2 self.field3 = fi...

How to iterate over arguments in a Bash script

I have a complex command that I'd like to make a shell/bash script of. I can write it in terms of $1 easily: foo $1 args -o $1.ext I want to be able to pass multiple input names to the script. What's the right way to do it? And, of course, I w...

In Postgresql, force unique on combination of two columns

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

Check if all values of array are equal

I need to find arrays where all values are equal. What's the fastest way to do this? Should I loop through it and just compare values? ['a', 'a', 'a', 'a'] // true ['a', 'a', 'b', 'a'] // false ...

Clone only one branch

I would like to know how I could clone only one branch instead of cloning the whole Git repository....

Is it possible to opt-out of dark mode on iOS 13?

A large part of my app consists of web views to provide functionality not yet available through native implementations. The web team has no plans to implement a dark theme for the website. As such, my app will look a bit half/half with Dark Mode supp...

Load image with jQuery and append it to the DOM

I'm trying to load an image from a given link var imgPath = $(imgLink).attr('href'); and append it to the page, so I can insert it into a given element for an image viewer. Even though I searched Stackoverflow and the jQuery docs without end, I c...

PDO with INSERT INTO through prepared statements

On my adventure through the jungles of PHP: Data Objects I've encountered a problem with executing MySQL queries through prepared statements. Observe the following code: $dbhost = "localhost"; $dbname = "pdo"; $dbusername = "root"; $dbpassword = "8...

Where can I download JSTL jar

Does anyone know because all the places I've tried seem to timeout!...

the best way to make codeigniter website multi-language. calling from lang arrays depends on lang session?

I'm researching hours and hours, but I could not find any clear, efficient way to make it :/ I have a codeigniter base website in English and I have to add a Polish language now. What is the best way to make my site in 2 language depending visitor s...

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

Number of processors/cores in command line

I am running the following command to get the number of processors/cores in Linux: cat /proc/cpuinfo | grep processor | wc -l It works but it does not look elegant. How would you suggest improve it ? ...

static and extern global variables in C and C++

I made 2 projects, the first one in C and the second one in C++, both work with same behavior. C project: header.h int varGlobal=7; main.c #include <stdio.h> #include <stdlib.h> #include "header.h" void function(int i) { static...

Using css transform property in jQuery

How can you specify cross-browser transform controls using jQuery since each browser seems to use its own methodology? Here is the code I am using for Firefox but I can't even get it to work. I think it's because there is no way to tell which transf...

Call of overloaded function is ambiguous

What does this error message mean? error: call of overloaded ‘setval(int)’ is ambiguous huge.cpp:18: note: candidates are: void huge::setval(unsigned int) huge.cpp:28: note: void huge::setval(const char*) My code looks like thi...

How to move (and overwrite) all files from one directory to another?

I know of the mv command to move a file from one place to another, but how do I move all files from one directory into another (that has a bunch of other files), overwriting if the file already exists?...

Angularjs error Unknown provider

I'm trying to display the configured values author and version in angular value service in html page.Version code is displayed fine but not the author name Here is the html code <!doctype html> <html lang="en" ng-app="myApp"> <hea...

Adding a column after another column within SQL

How do I add a column after another column within MS SQL by using SQL query? TempTable ID int, Type nvarchar(20), Active bit NewTable ID int, Type nvarchar(20), Description text, Active bit That is what I want, how do I do tha...

C++ printing boolean, what is displayed?

I print a bool to an output stream like this: #include <iostream> int main() { std::cout << false << std::endl; } Does the standard require a specific result on the stream (e.g. 0 for false)?...

Textarea that can do syntax highlighting on the fly?

I am storing a number of HTML blocks inside a CMS for reasons of easier maintenance. They are represented by <textarea>s. Does anybody know a JavaScript Widget of some sort that can do syntax highlighting for HTML within a textarea or similar,...

int object is not iterable?

inp = int(input("Enter a number:")) for i in inp: n = n + i; print (n) ... throws an error: 'int' object is not iterable I wanted to find out the total by adding each digit, for eg, 110. 1 + 1 + 0 = 2. How do I do that? Thanks...

Restricting JTextField input to Integers

I know that this question must have been asked and answered a million times, but I just can't find an easy solution. I have a JTextField that is meant to accept only positive integers as input. I need a way to make sure that nothing else gets input h...

Exclude all transitive dependencies of a single dependency

In Maven2, to exclude a single transitive dependency, I have to do something like this: <dependency> <groupId>sample.group</groupId> <artifactId>sample-artifactB</artifactId> <version>1</version> &l...

What is the right way to populate a DropDownList from a database?

I am populating a DropDownList from a SQL Server database as shown below. It works fine, but I'm not sure it's a good way. Can someone shed some light on this method, and give some improvements? private void LoadSubjects() { ddlSubjects.Items.Cl...

Should I Dispose() DataSet and DataTable?

DataSet and DataTable both implement IDisposable, so, by conventional best practices, I should call their Dispose() methods. However, from what I've read so far, DataSet and DataTable don't actually have any unmanaged resources, so Dispose() doesn't...

Serializing an object to JSON

How can I serialize an object to JSON in JavaScript?...

No newline after div?

Is there a way to not have a newline inserted before a div without using float: left on the previous element? Maybe some tag on the div that will just put it to the right?...

Using Apache POI how to read a specific excel column

I'm having a problem in excel while using Apache POI. I can read across rows, but sometimes I'm in a situation where I would like to read a particular column only. So is it possible to read any particular column like only the 'A' column only or the ...

Copying formula to the next row when inserting a new row

I have a row in which there are formulas using values of the same row. The next row is empty, just with a different background color. Now, if I insert a new row (by right-clicking on the empty row and "insert"), I get a new row with NO background co...

What are the differences between char literals '\n' and '\r' in Java?

In Java, the newline and carriage return characters are both seem to be showing same effect. What are the actual differences between char literals \n and \r in Java? Note that the above asks about the \n character, not the newLine() function on B...

How to make a div with a circular shape?

i want to create a div with background color red and completely circular in shape How can i do that? Css or jquery both can be used...

MVC which submit button has been pressed

I have two buttons on my MVC form: <input name="submit" type="submit" id="submit" value="Save" /> <input name="process" type="submit" id="process" value="Process" /> From my Controller action how do I know which one have been pressed?...

PowerShell and the -contains operator

Consider the following snippet: "12-18" -Contains "-" You’d think this evaluates to true, but it doesn't. This will evaluate to false instead. I’m not sure why this happens, but it does. To avoid this, you can use this instead: "12-18".Conta...

How to remove duplicate values from a multi-dimensional array in PHP

How can I remove duplicate values from a multi-dimensional array in PHP? Example array: Array ( [0] => Array ( [0] => abc [1] => def ) [1] => Array ( [0] => ghi [1] => jkl )...

Java Long primitive type maximum limit

I am using the Long primitive type which increments by 1 whenever my 'generateNumber'method called. What happens if Long reaches to his maximum limit? will throw any exception or will reset to minimum value? here is my sample code: class LongTest { ...

Setting the classpath in java using Eclipse IDE

I have an Eclipse project with an external folder containing a lot of JAR files (legacy libraries) . instead of adding all the jars in Eclipse ("add external Jar"), I would prefer to add a ref to this external folder. In the "configure build bath", I...

How to force Eclipse to ask for default workspace?

I noticed that after installing cdt, Eclipse always loads the default workspace. The workspace listed in the config.ini in osgi.instance.area.default. Eclipse does not ask which workspace to open regardless if Prompt for workspace on startup is set o...

How to apply a function to two columns of Pandas dataframe

Suppose I have a df which has columns of 'ID', 'col_1', 'col_2'. And I define a function : f = lambda x, y : my_function_expression. Now I want to apply the f to df's two columns 'col_1', 'col_2' to element-wise calculate a new column 'col_3' , som...

How do you clear a slice in Go?

What is the appropriate way to clear a slice in Go? Here's what I've found in the go forums: // test.go package main import ( "fmt" ) func main() { letters := []string{"a", "b", "c", "d"} fmt.Println(cap(letters)) fmt.Println(len(...

ReDim Preserve to a Multi-Dimensional Array in Visual Basic 6

I'm using VB6 and I need to do a ReDim Preserve to a Multi-Dimensional Array: Dim n, m As Integer n = 1 m = 0 Dim arrCity() As String ReDim arrCity(n, m) n = n + 1 m = m + 1 ReDim Preserve arrCity(n, m) Whenever I do...

How to avoid the "Circular view path" exception with Spring MVC test

I have the following code in one of my controllers: @Controller @RequestMapping("/preference") public class PreferenceController { @RequestMapping(method = RequestMethod.GET, produces = "text/html") public String preference() { retu...

Convert a string to a double - is this possible?

Just wondering in php, if it was possible to convert a string to a double. I am using a financial web service which provides a price as a string. I really need to process this as a double and was wondering how i would convert it thanks...

How do I find out which computer is the domain controller in Windows programmatically?

I am looking for a way to determine what the Name/IP Address of the domain controller is for a given domain that a client computer is connected to. At our company we have a lot of small little networks that we use for testing and most of them have t...

How can I change the value of the elements in a vector?

I have this code, which reads in input from a file and stores it in a vector. So far, I've gotten it to give me the sum of the values within the vector and give the mean of the values using the sum. What I'd like to do now is learn how to access th...

increment date by one month

Let's say I have a date in the following format: 2010-12-11 (year-mon-day) With PHP, I want to increment the date by one month, and I want the year to be automatically incremented, if necessary (i.e. incrementing from December 2012 to January 2013)....

invalid use of incomplete type

I'm trying to use a typedef from a subclass in my project, I've isolated my problem in the example below. Does anyone know where I'm going wrong? template<typename Subclass> class A { public: //Why doesn't it like this? vo...

When do I use super()?

I'm currently learning about class inheritance in my Java course and I don't understand when to use the super() call? Edit: I found this example of code where super.variable is used: class A { int k = 10; } class Test extends A { public vo...

How do I copy items from list to list without foreach?

How do I transfer the items contained in one List to another in C# without using foreach?...

Restarting cron after changing crontab file?

Do I have to restart cron after changing the crontable file?...

iOS 10 - Changes in asking permissions of Camera, microphone and Photo Library causing application to crash

iOS 10, Now Requires User Permission to Access Media Library, Photos, Camera and other Hardware like these. The solution for this is to add their keys into info.plist with a description for user that how we are using their data, I could only find a ...

how to set imageview src?

I have an image view and a string src. I want to set the imageview source to the string src that I have, but am unable to do so beacuse the method expects an int: imgview.setImageResource(int); Since this method takes an int how can I accomplish ...

Launching Spring application Address already in use

I have this error launching my spring application: java -jar target/gs-serving-web-content-0.1.0.jar . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | |...

When should we use Observer and Observable?

An interviewer asked me: What is Observer and Observable and when should we use them? I wasn't aware of these terms, so when I got back home and started Googling about Observer and Observable, I found some points from different resources: 1) Ob...

How does C#'s random number generator work?

I was just wondering how the random number generator in C# works. I was also curious how I could make a program that generates random WHOLE INTEGER numbers from 1-100....

Radio Buttons "Checked" Attribute Not Working

The radio button does not show up as checked by default. I started off without a default choice doing some very simple js validation and it wasn't working. So I opted to just use default values until I figured that out and discovered that something w...

Why do you have to link the math library in C?

If I include <stdlib.h> or <stdio.h> in a C program I don't have to link these when compiling but I do have to link to <math.h>, using -lm with gcc, for example: gcc test.c -o test -lm What is the reason for this? Why do I have t...

ASP.NET strange compilation error

I don't know what's wrong with my machine, but it's a while that I'm getting the following strange error from ASP.NET (for all my applications). Compilation Error Description: An error occurred during the compilation of a resource required to servi...

Char to int conversion in C

If I want to convert a single numeric char to it's numeric value, for example, if: char c = '5'; and I want c to hold 5 instead of '5', is it 100% portable doing it like this? c = c - '0'; I heard that all character sets store the numbers in co...

Flattening a shallow list in Python

Is there a simple way to flatten a list of iterables with a list comprehension, or failing that, what would you all consider to be the best way to flatten a shallow list like this, balancing performance and readability? I tried to flatten such a lis...

Add another class to a div

I have a function that checks the age of a form submission and then returns new content in a div depending on their age. Right now I am just using getElementById to replace the HTML content. BUt I think would work better for me if I could also add a ...

MySQL TEXT vs BLOB vs CLOB

What are the differences, advantages and disadvantages of these different data-types both from a performance standpoint as well as a usability standpoint?...

Is there any publicly accessible JSON data source to test with real world data?

I'm working on a JavaScript dynamically loaded tree view user control. I'd like to test it with real world data. Does anybody know any public service with an API that provides access to hierarchical data in JSON format?...

Difference between Divide and Conquer Algo and Dynamic Programming

What is the difference between Divide and Conquer Algorithms and Dynamic Programming Algorithms? How are the two terms different? I do not understand the difference between them. Please take a simple example to explain any difference between the two...

Swift addsubview and remove it

I want to add sub view and remove with one tap. This is my code: /* To add subview */ var testView: UIView = UIView(frame: CGRectMake(0, 0, 320, 568)) testView.backgroundColor = UIColor.blueColor() testView.alpha = 0.5 testView.tag = 100 super.vi...

Link to reload current page

Is it possible to have a normal link pointing to the current location? I have currently found 2 solutions, but one of them includes JavaScript and in the other you have to know the absolute path to the page: <a href="#" onclick="window.location....

Disable PHP in directory (including all sub-directories) with .htaccess

I'm making a website which allows people to upload files, html pages, etc... Now I'm having a problem. I have a directory structure like this: -/USERS -/DEMO1 -/DEMO2 -/DEMO3 -/etc... (every user has his own direcory here) -index.php...

What is compiler, linker, loader?

I wanted to know in depth meaning and working of compiler, linker and loader. With reference to any language preferably c++....

How to view UTF-8 Characters in VIM or Gvim

I work on webpages involving Non-English scripts from time to time, most of them uses utf-8 charset, VIM and Gvim does not display UTF-8 Characters correctly. Using VIM 7.3.46 on windows 7 64 bit, with set guifont=Monaco:h10 in _vimrc Is there a wa...

HTML form with side by side input fields

I have a html form that is basically vertical but i really have no idea how to make two text fields on the same line. For example the following form below i want the First and Last name on the same line rather then one below the other. <form ...

How to read a file and write into a text file?

I want to open mis file, copy all the data and write into a text file. My mis file. File name – 1.mis M3;3395;44;0;1;;20090404;094144;8193;3;0;;;; M3;3397;155;0;2;;20090404;105941;8193;3;0;;;; M3;3396;160;0;1;;20090404;100825;8193;3;0;;;; M3;339...

How to do a Postgresql subquery in select clause with join in from clause like SQL Server?

I am trying to write the following query on postgresql: select name, author_id, count(1), (select count(1) from names as n2 where n2.id = n1.id and t2.author_id = t1.author_id ) from names as n1 group by name,...

Convert Text to Uppercase while typing in Text box

I am new in Visual Studio and using visual Studio 2008. In a project I want to make all text in uppercase while typed by the user without pressing shift key or caps lock on. I have used this code TextBox1.Text = TextBox1.Text.ToUpper(); but it cap...

How do you do a deep copy of an object in .NET?

I want a true deep copy. In Java, this was easy, but how do you do it in C#?...

Match line break with regular expression

<li><a href="#">Animal and Plant Health Inspection Service Permits Provides information on the various permits that the Animal and Plant Health Inspection Service issues as well as online access for acquiring those permits. I want t...

Comparison of full text search engine - Lucene, Sphinx, Postgresql, MySQL?

I'm building a Django site and I am looking for a search engine. A few candidates: Lucene/Lucene with Compass/Solr Sphinx Postgresql built-in full text search MySQl built-in full text search Selection criteria: result relevance and ranking sea...

Convert Promise to Observable

I am trying to wrap my head around observables. I love the way observables solve development and readability issues. As I read, benefits are immense. Observables on HTTP and collections seem to be straight forward. How can I convert something like ...

Recursive sub folder search and return files in a list python

I am working on a script to recursively go through subfolders in a mainfolder and build a list off a certain file type. I am having an issue with the script. Its currently set as follows for root, subFolder, files in os.walk(PATH): for item in f...

How to create a jar with external libraries included in Eclipse?

I am done with the project which connects to database (MySQL). Now I want to export the project as jar. But I don't know how to include its external dependencies? Is there any way of doing it in Eclipse or should I use any scripts for that?....

how to get vlc logs?

I am trying to run rtsp url from the VLC player. But an error appears, and "see logs for details" comes up in a dialog box. How can I enable logs in VLC?...

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from `songs` where `id` = 5 limit 1)

I am trying to get specific data from the database by using column SongID when a user clicks a link but I am getting this error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from songs where id =...

Should black box or white box testing be the emphasis for testers?

Which type of testing would you say should be the emphasis (for testers/QAs), and why? A quick set of definitions from wikipedia: Black box testing takes an external perspective of the test object to derive test cases. These tests can be functio...

Deny direct access to all .php files except index.php

I want to deny direct access to all .php files except one: index.php The only access to the other .php files should be through php include. If possible I want all files in the same folder. UPDATE: A general rule would be nice, so I don't need to ...

How are iloc and loc different?

Can someone explain how these two methods of slicing are different? I've seen the docs, and I've seen these answers, but I still find myself unable to understand how the three are different. To me, they seem interchangeable in large part, because the...

What is the difference between concurrency and parallelism?

What is the difference between concurrency and parallelism? Examples are appreciated....

Use a JSON array with objects with javascript

I have a function that will get a JSON array with objects. In the function I will be able to loop through the array, access a property and use that property. Like this: Variable that I will pass to the function will look like this: [{ "id": 28, ...

How to install JDBC driver in Eclipse web project without facing java.lang.ClassNotFoundexception

There is a VERY similar question to mine but in my case I don't have any duplicate jars in my build path, so the solution does not work for me. I've searched google for a couple of hours now, but none of the solutions I've found there actually resol...

Simplest SOAP example

What is the simplest SOAP example using Javascript? To be as useful as possible, the answer should: Be functional (in other words actually work) Send at least one parameter that can be set elsewhere in the code Process at least one result value th...

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

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

Split / Explode a column of dictionaries into separate columns with pandas

I have data saved in a postgreSQL database. I am querying this data using Python2.7 and turning it into a Pandas DataFrame. However, the last column of this dataframe has a dictionary of values inside it. The DataFrame df looks like this: Station ID ...

How to make this Header/Content/Footer layout using CSS?

______________________ | Header | |______________________| | | | | | Content | | | | | |______________________| | Footer | |...

Return first N key:value pairs from dict

Consider the following dictionary, d: d = {'a': 3, 'b': 2, 'c': 3, 'd': 4, 'e': 5} I want to return the first N key:value pairs from d (N <= 4 in this case). What is the most efficient method of doing this?...

How to set RelativeLayout layout params in code not in xml?

For example I want to add 3 buttons on screen: one align left, one align center, last one align right. How can I set their layout in code, not in xml?...

Is it a bad practice to use an if-statement without curly braces?

I've seen code like this: if(statement) do this; else do this; However, I think this is more readable: if(statement){ do this; }else{ do this; } Since both methods work, is this simply a matter of preference which to use or woul...

How to negate specific word in regex?

I know that I can negate group of chars as in [^bar] but I need a regular expression where negation applies to the specific word - so in my example how do I negate an actual bar, and not "any chars in bar"?...

How to delete a cookie?

Is my function of creating a cookie correct? How do I delete the cookie at the beginning of my program? is there a simple coding? function createCookie(name,value,days) function setCookie(c_name,value,1) { document.cookie = c_name + "=" +escap...

Compiled vs. Interpreted Languages

I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dyn...

C# constructors overloading

How I can use constructors in C# like this: public Point2D(double x, double y) { // ... Contracts ... X = x; Y = y; } public Point2D(Point2D point) { if (point == null) ArgumentNullException("point"); Contract.EndContra...

Multipart forms from C# client

I am trying to fill a form in a php application from a C# client (Outlook addin). I used Fiddler to see the original request from within the php application and the form is transmitted as a multipart/form. Unfortunately .Net does not come with native...

changing textbox border colour using javascript

I'm doing form validation. when the form input is incorrect i add a red border to the textbox: document.getElementById("fName").style.borderColor="#FF0000" this then gives me a 2px red border. what i want to do is if the user putas in a correct va...

PHP array value passes to next row

I have an array building multiple instances of the following fields: <div class="checkbox_vm"> <input type="hidden" name="fk_row[]" value="<?php echo $i; ?>"> <input type="hidden" name="fk_id[]" value="<?php echo $veh...

Get cookie by name

I have a getter to get the value from a cookie. Now I have 2 cookies by the name shares= and by the name obligations= . I want to make this getter only to get the values from the obligations cookie. How do I do this? So the for splits the data ...

How do I read a date in Excel format in Python?

How can I convert an Excel date (in a number format) to a proper date in Python?...

Error: More than one module matches. Use skip-import option to skip importing the component into the closest module

When I try to create a component in the angular cli, it's showing me this error. How do I get rid of it ? Error: More than one module matches. Use skip-import option to skip importing the component into the closest module. I'm using angular cli...

How to disable an Android button?

I have created a layout that contains two buttons, Next and Previous. In between the buttons I'm generating some dynamic views. So when I first launch the application I want to disable the "Previous" button since there wont be any previous views. I a...

How to split a line into words separated by one or more spaces in bash?

I realize how to do it in python, just with line = db_file.readline() ll=string.split(line) but how can I do the same in bash? is it really possible to do it in a so simple way?...

Using CSS to insert text

I'm relatively new to CSS, and have used it to change the style and formatting of text. I would now like to use it to insert text as shown below: <span class="OwnerJoe">reconcile all entries</span> Which I hope I could get to show as:...

What are the applications of binary trees?

I am wondering what the particular applications of binary trees are. Could you give some real examples?...

Python: How exactly can you take a string, split it, reverse it and join it back together again?

How exactly can you take a string, split it, reverse it and join it back together again without the brackets, commas, etc. using python?...

How to read file using NPOI

I found NPOI is very good to write Excel files with C#. But I want to open, read and modify Excel files in C#. How can I do this?...

If else in stored procedure sql server

I have created a stored procedure as follow: Create Procedure sp_ADD_USER_EXTRANET_CLIENT_INDEX_PHY ( @ParLngId int output ) as Begin SET @ParLngId = (Select top 1 ParLngId from T_Param where ParStrNom = 'Extranet Client') if(@ParLngId = 0) ...

How do I use TensorFlow GPU?

How do I use TensorFlow GPU version instead of CPU version in Python 3.6 x64? import tensorflow as tf Python is using my CPU for calculations. I can notice it because I have an error: Your CPU supports instructions that this TensorFlow binary was ...

How to set UICollectionViewCell Width and Height programmatically

I am trying to implement a CollectionView. When I am using Autolayout, my cells won't change the size, but their alignment. Now I would rather want to change their sizes to e.g. //var size = CGSize(width: self.view.frame.width/10, height: self.view...

Validate that text field is numeric usiung jQuery

I have a simple issue -- I would like to check a field to see if it's an integer if it is not blank. I'm not using any additional plugins, just jQuery. My code is as follows: if($('#Field').val() != "") { if($('#Field').val().match('^(0|[1-9][0-...

Bootstrap center heading

It is my first Twitter Bootstrap experience. I have added some headings (h1, h2, etc.) and they are aligned by left side. What is the right way to center headings?...

Stopword removal with NLTK

I am trying to process a user entered text by removing stopwords using nltk toolkit, but with stopword-removal the words like 'and', 'or', 'not' gets removed. I want these words to be present after stopword removal process as they are operators which...

C# Inserting Data from a form into an access Database

I started learning about C# and have become stuck with inserting information from textboxes into an Access database when a click button is used. The problem I get is during the adding process. The code executes the Try... Catch part and then returns...

How do you assert that a certain exception is thrown in JUnit 4 tests?

How can I use JUnit4 idiomatically to test that some code throws an exception? While I can certainly do something like this: @Test public void testFooThrowsIndexOutOfBoundsException() { boolean thrown = false; try { foo.doStuff(); } catc...

What is the maximum length of a Push Notification alert text?

What is the maximum length of the alert text of an iOS push notification? The documentation states that the notification payload has to be under 256 bytes in total, but surely there must be a specific character limit for the alert text....

SQL Server Insert if not exists

I want to insert data into my table, but insert only data that doesn't already exist in my database. Here is my code: ALTER PROCEDURE [dbo].[EmailsRecebidosInsert] (@_DE nvarchar(50), @_ASSUNTO nvarchar(50), @_DATA nvarchar(30) ) AS BEGIN ...

Run batch file as a Windows service

In order to run one application, a batch file has to be kicked off (which does things like start Jetty, display live logs, etc). The application will work only if this batch file is running. I am hence forced to have this batch file running and not l...

Get the client IP address using PHP

I want to get the client IP address who uses my website. I am using the PHP $_SERVER superglobal: $_SERVER['REMOTE_ADDR']; But I see it can not give the correct IP address using this. I get my IP address and see it is different from my IP address ...

Wavy shape with css

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

How do I get a substring of a string in Python?

Is there a way to substring a string in Python, to get a new string from the third character to the end of the string? Maybe like myString[2:end]? If leaving the second part means 'till the end', and if you leave the first part, does it start from ...

Writing String to Stream and reading it back does not work

I want to write a String to a Stream (a MemoryStream in this case) and read the bytes one by one. stringAsStream = new MemoryStream(); UnicodeEncoding uniEncoding = new UnicodeEncoding(); String message = "Message"; stringAsStream.Write(uniEncodin...

exporting multiple modules in react.js

New to react.js and trying to following tutorial. Unfortunately the code given in the page didn't work. webpack complained ERROR in ./App.jsx Module build failed: SyntaxError: Only one default export allowed per module. Wonder how to fix it. Th...

The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception

I have developed an application that uses Oracle Data Provider for .NET. I copy the application file (.exe) and ODP library (Oracle.DataAccess.dll) on another computer that Oracle client and ODP.NET are NOT installed on. When I run the application, I...

How can I check if a MySQL table exists with PHP?

As simple in theory as it sounds I've done a fair amount of research and am having trouble figuring this out. How can I check if a MySQL table exists and if it does do something. (I guess a simple php if/else statement could work for this) Is there...

Best practice for instantiating a new Android Fragment

I have seen two general practices to instantiate a new Fragment in an application: Fragment newFragment = new MyFragment(); and Fragment newFragment = MyFragment.newInstance(); The second option makes use of a static method newInstance() and ge...

Hash and salt passwords in C#

I was just going through one of DavidHayden's articles on Hashing User Passwords. Really I can't get what he is trying to achieve. Here is his code: private static string CreateSalt(int size) { //Generate a cryptographic random number. RNG...

What is the easiest way to push an element to the beginning of the array?

I can't think of a one line way to do this. Is there a way?...

JAVA_HOME does not point to the JDK

I am trying to follow a tutorial about how to use ant to build and run your application. I've followed all the steps and have created the build file, but when I try to run ant it gives me this error. BUILD FAILED /home/bilal/tmp/ant/build.xml:1...

Logical Operators, || or OR?

I remember reading a while back in regards to logical operators that in the case of OR, using || was better than or (or vice versa). I just had to use this in my project when it came back to me, but I can't remember which operator was recommended or...

How To Pass GET Parameters To Laravel From With GET Method ?

i'm stuck at this very basic form, that i could not accomplish, which i want to build a search form with an text input, and two select controls, with a route that accept 3 parameters, the problem that when the i submit the form, it map the parameters...

Selected value for JSP drop down using JSTL

I have SortedMap in Servlet to populate drop down values in JSP and I have the following code SortedMap<String, String> dept = findDepartment(); request.setAttribute("dept ", dept); and in JSP <select name="department">...

What causes: "Notice: Uninitialized string offset" to appear?

I have a form that users fill out, and on the form there are multiple identical fields, like "project name", "project date", "catagory", etc. Based on how many forms a user is submitting, my goal is to: loop over the number of forms create individu...

How to remove trailing whitespace in code, using another script?

Something like: import fileinput for lines in fileinput.FileInput("test.txt", inplace=1): lines = lines.strip() if lines == '': continue print lines But nothing is being printed on stdout. Assuming some string named foo: foo.lstrip(...

C++: How to round a double to an int?

I have a double (call it x), meant to be 55 but in actuality stored as 54.999999999999943157 which I just realised. So when I do double x = 54.999999999999943157; int y = (int) x; y = 54 instead of 55! This puzzled me for a long time. How do I ...

CSS Margin: 0 is not setting to 0

I'm a new comer to web designing. I created my web page layout using CSS and HTML as below. The problem is even though i set the margin to 0, the upper margin is not setting to 0 and leaves some space. How can i clear this white space? Screen Shot o...

Error message "Linter pylint is not installed"

I want to run Python code in Microsoft Visual Studio Code but it gives an error: Linter pylint is not installed I installed: The Visual Studio Code Python extension Python 3 Anaconda How can I install Pylint?...

Error in spring application context schema

I have a maven-spring project in Eclipse and I have this annoying error message in one of my spring contexts: Referenced file contains errors (jar:file:/M2_HOME/repository/org/springframework/spring-beans/3.1.2.RELEASE/spring-beans-3.1.2.RELEASE....

Uninstall Django completely

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

git status (nothing to commit, working directory clean), however with changes commited

I found many questions with similar subject, but I didn't found any practical guidance about this issue: why git status informs me nothing to commit, working directory clean, even tough I have made a modification at my local branch? Here are the ste...

ImportError: No module named pandas

I am trying to write a code in python to fetch twitter data i am not getting error for twython. But i am getting error for pandas. I have installed pandas using pip install pandas. But i still get this error . Please help F:\>pip install pandas...

.m2 , settings.xml in Ubuntu

In the windows environment you will have .m2 folder in C:\Users\user_name location and you will copy your settings.xml file to it in order to setup your proxy settings and nexus repository locations and etc. So What I have to done on Ubuntu environm...

How to install multiple python packages at once using pip

I know it's an easy way of doing it but i didn't find it neither here nor on google. So i was curious if there is a way to install multiple packages using pip. Something like: pip install progra1 , progra2 ,progra3 ,progra4 . or: pip install...

Can you install and run apps built on the .NET framework on a Mac?

I need to use/continue developing a desktop app developed using .NET on my Mac. Is there a .NET framework 4.0 available for Mac? Would this allow running and developing of .NET-based apps on a Mac? Another option that i am considering is using a win...

How to filter files when using scp to copy dir recursively?

I need to copy all the .class files from server to local with all dir reserved. e.g. server:/usr/some/unknown/number/of/sub/folders/me.class will be /usr/project/backup/some/unknown/number/of/sub/folders/me.class the problem is, there are many other ...

how to destroy bootstrap modal window completely?

I've made use of modal window for a wizard implementation which has around 4,5 steps. I need to destroy it completely after the last step(onFinish) and OnCancel step without having a page refresh. I can of course hide it, but hiding modal windows res...

Java: Why is the Date constructor deprecated, and what do I use instead?

I come from the C# world, so not too experienced with Java yet. I was just told by Eclipse that Date was deprecated: Person p = new Person(); p.setDateOfBirth(new Date(1985, 1, 1)); Why? And what (especially in cases like above) should be used ins...

insert data into database with codeigniter

Trying to insert a row into my database with CodeIgniter. My database table is Customer_Orders and the fields are CustomerName and OrderLines. The variables are being submitted correctly. My Controller is( sales.php ): function new_blank_order_sum...

Xcode 4 - build output directory

I have problems with setting up/locating my output files in Xcode4 (beta 5). They are placed somewhere in ~/Library/Developer/ugly_path/.... I can't even select "show in finder" on my products. It is the same for a simple C project, Foundation tool a...

Command /usr/bin/codesign failed with exit code 1

I have the following error: Command /usr/bin/codesign failed with exit code 1 Here is what I already did for trying to fix this: set the bundle identifier to com.server.pgmname set the code signing to "Any Iphone OS Device" set the Code Signi...

Change New Google Recaptcha (v2) Width

We've just started to implement the new google recaptcha as listed https://www.google.com/recaptcha/intro/index.html However the new method seems to be contained within an iFrame rather than embedded into the page thus making applying CSS more diffi...

How to check whether a string is Base64 encoded or not

I want to decode a Base64 encoded string, then store it in my database. If the input is not Base64 encoded, I need to throw an error. How can I check if a string is Base64 encoded?...

get UTC timestamp in python with datetime

Is there a way to get the UTC timestamp by specifying the date? What I would expect: datetime(2008, 1, 1, 0, 0, 0, 0) should result in 1199145600 Creating a naive datetime object means that there is no time zone information. If I look at the d...

SQL Server Output Clause into a scalar variable

Is there any "simple" way to do this or I need to pass by a table variable with the "OUTPUT ... INTO" syntax? DECLARE @someInt int INSERT INTO MyTable2(AIntColumn) OUTPUT @SomeInt = Inserted.AIntColumn VALUES(12) ...

How to resolve the C:\fakepath?

<input type="file" id="file-id" name="file_name" onchange="theimage();"> This is my upload button. <input type="text" name="file_path" id="file-path"> This is the text field where I have to show the full path of the file. function t...

How to Query an NTP Server using C#?

All I need is a way to query an NTP Server using C# to get the Date Time of the NTP Server returned as either a string or as a DateTime. How is this possible in its simplest form?...

How to compare only date components from DateTime in EF?

I am having two date values, one already stored in the database and the other selected by the user using DatePicker. The use case is to search for a particular date from the database. The value previously entered in the database always has time comp...

Why doesn't JavaScript have a last method?

Its kinda weird that the JavaScript Array class does not offer a last method to retrieve the last element of an array. I know the solution is simple (Ar[Ar.length-1] ), but, still, this is too frequently used. Any serious reasons why this is not inc...

What does `dword ptr` mean?

Could someone explain what this means? (Intel Syntax, x86, Windows) and dword ptr [ebp-4], 0 ...

ImportError: No module named 'selenium'

I'm trying to write a script to check a website. It's the first time I'm using selenium. I'm trying to run the script on a OSX system. Although I checked in /Library/Python/2.7/site-packages and selenium-2.46.0-py2.7.egg is present, when I run the sc...

How to comment in Vim's config files: ".vimrc"?

How do I add a comment in Vim's configuration files, like .vimrc?...

How do I fix the npm UNMET PEER DEPENDENCY warning?

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

How to create XML file with specific structure in Java

I would like to create XML file using Java. My XML file structure: <?xml version="1.0" encoding="UTF-8"?> <CONFIGURATION> <BROWSER>chrome</BROWSER> <BASE>http:fut</BASE> <ENVIRONMENT>abcd</E...

Visualizing decision tree in scikit-learn

I am trying to design a simple Decision Tree using scikit-learn in Python (I am using Anaconda's Ipython Notebook with Python 2.7.3 on Windows OS) and visualize it as follows: from pandas import read_csv, DataFrame from sklearn import tree from os i...

IndexError: too many indices for array

I know there is a ton of these threads but all of them are for very simple cases like 3x3 matrices and things of that sort and the solutions do not even begin to apply to my situation. So I'm trying to graph G versus l1 (that's not an eleven, but an...

MongoDB: Is it possible to make a case-insensitive query?

Example: > db.stuff.save({"foo":"bar"}); > db.stuff.find({"foo":"bar"}).count(); 1 > db.stuff.find({"foo":"BAR"}).count(); 0 ...

How do I get next month date from today's date and insert it in my database?

I have two columns in my db: start_date and end_date, which are both DATE types. My code is updating the dates as follows: $today_date = date("Y-m-d"); $end_date = date("Y-m-d"); // date +1 month ?? $sql1 = "UPDATE `users` SET `start_date` = '".$to...

How to delete the first row of a dataframe in R?

I have a dataset with 11 columns with over a 1000 rows each. The columns were labeled V1, V2, V11, etc.. I replaced the names with something more useful to me using the "c" command. I didn't realize that row 1 also contained labels for each column an...

How do I trim a file extension from a String in Java?

What's the most efficient way to trim the suffix in Java, like this: title part1.txt title part2.html => title part1 title part2 ...

how to fetch array keys with jQuery?

Good afternoon. I have an array with some keys, and values in them. I then need to fetch the array keys and not the data in them. I want to do this with jQuery. I know for example that PHP has a function called array_keys(); which takes the array as ...

UITapGestureRecognizer - single tap and double tap

I am trying to add 2 UITapGestureRecognizers to a view, one for single tap and one for double tap events. The single tap recognizer is working as expected (on its own). But I don't seem to be able to get the double tap recognizer working. Have tri...

How to add a ListView to a Column in Flutter?

I'm trying to construct a simple login page for my Flutter app. I've successfully built the TextFields and log in/Sign in buttons. I want to add a horizontal ListView. When I run the code my elements disappear, if I do it without the ListView, it'...

How can I check if a value is of type Integer?

I need to check if a value is an integer. I found this: How to check whether input value is integer or float?, but if I'm not mistaken, the variable there is still of type double even though the value itself is indeed an integer....

What is the best Java QR code generator library?

I wish to dynamically generate QR codes in Java. What is the best QR code generator library to use. I will consider both commercial and opensource?...

Getting value of HTML Checkbox from onclick/onchange events

<input type="checkbox" onclick="onClickHandler()" onchange="onChangeHandler()" /> From within onClickHandler and/or onChangeHandler, how can I determine what is the new state of the checkbox?...

Ansible: create a user with sudo privileges

I have taken over a Ubuntu 14.04 server. It has a user called "deployer" (used with capistrano), and as such, it needs sudo privileges. With this setup, I can log into the server and do stuff like: workstation> ssh deployer@myserver myserver> ...

How to Disable GUI Button in Java

so I have this small piece of code for my GUI: import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBord...

Click to call html

I want to use html5 tag in my website for mobile view when user click on this link from mobile device it will place a call on the given number.. <p>Book now, call <a href="tel:01234567890">01234 567 890</a></p> What should...

Notepad++ change text color?

I'm using Notepad++ to mock up ISPF screens. I've used StyleConfigurator to select an appropriate font, colored it green, and set a black background. How do I permanently change the color of selected text? E.g., if I have CUSTOMER NAME: THALECRESS,...

XML to CSV Using XSLT

I have the following XML document: <projects> <project> <name>Shockwave</name> <language>Ruby</language> <owner>Brian May</owner> <state>New</state> <startDate>31...

Remove the complete styling of an HTML button/submit

Is there a way of completely removing the styling of a button in Internet Explorer? I use a css sprite for my button, and everything looks ok. But when I click the button, it moves to the top a little, it makes it look out of shape. Is there a css ...

HTTP error 403 in Python 3 Web Scraping

I was trying to scrap a website for practice, but I kept on getting the HTTP Error 403 (does it think I'm a bot)? Here is my code: #import requests import urllib.request from bs4 import BeautifulSoup #from urllib import urlopen import re webpage =...

How to implement class constructor in Visual Basic?

I just would like to know how to implement class constructor in this language....

How to open a specific port such as 9090 in Google Compute Engine

I have 2 Google Compute Engine instances and I want to open port 9090 in both the instances. I think we need to add some firewall rules. Can you tell me how can I do that?...

How to find the port for MS SQL Server 2008?

I am running MS SQL Server 2008 on my local machine. I know that the default port is 1433 but some how it is not listening at this port. The SQL is an Express edition. I have already tried the log, SQL Server Management Studio, registry, and extende...

using stored procedure in entity framework

I am using asp.net mvc 5 and C# with Entity Framework... I have model and domain classes for function... now I need to use stored procedure.... which I am struggling at the movement. I am following code first existing database and I have stored pro...

Type of expression is ambiguous without more context Swift

I am getting a 'Type of expression is ambiguous without more context ' on this part of code from a project I am trying to upgrade to latest Swift version. I can't seem to figure it out. I tried different things but can't get it to work. The problem ...

How to call an async method from a getter or setter?

What'd be the most elegant way to call an async method from a getter or setter in C#? Here's some pseudo-code to help explain myself. async Task<IEnumerable> MyAsyncMethod() { return await DoSomethingAsync(); } public IEnumerable MyList ...

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

Reading a binary file with python

I find particularly difficult reading binary file with Python. Can you give me a hand? I need to read this file, which in Fortran 90 is easily read by int*4 n_particles, n_groups real*4 group_id(n_particles) read (*) n_particles, n_groups read (*) (...

Setting POST variable without using form

Is there a way to set a $_POST['var'] without using form related field (no type='hidden') and using only PHP. Something like $_POST['name'] = "Denniss"; Is there a way to do this? EDIT: Someone asked me for some elaboration on this. So for exampl...

How to include a quote in a raw Python string

Consider: >>> r"what"ever" SyntaxError: invalid syntax >>> r"what\"ever" 'what\\"ever' So how do we get the quote, but not the slash? And please don't suggest r'what"ever', because then the question just becomes how do we includ...

How can I exclude one word with grep?

I need something like: grep ^"unwanted_word"XXXXXXXX ...

Using multiple arguments for string formatting in Python (e.g., '%s ... %s')

I have a string that looks like '%s in %s' and I want to know how to seperate the arguments so that they are two different %s. My mind coming from Java came up with this: '%s in %s' % unicode(self.author), unicode(self.publication) But this does...

Get list of databases from SQL Server

How can I get the list of available databases on a SQL Server instance? I'm planning to make a list of them in a combo box in VB.NET....

Find an element in a list of tuples

I have a list 'a' a= [(1,2),(1,4),(3,5),(5,7)] I need to find all the tuples for a particular number. say for 1 it will be result = [(1,2),(1,4)] How do I do that?...

CSS image overlay with color and transparency

I am trying to figure out if I can add an overlay to an image like a tint and change the opacity without adding background color. I had no luck so I thought I would ask here. I would like to make it red with that opacity. here is what I have so far. ...

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

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

Batch file to run a command in cmd within a directory

I want to have a batch file(must be placed on desktop) which does the following; opens cmd navigates to a directory, e.g. C:\activiti-5.9\setup runs a command within the directory, e.g. ant demo.start (this command runs the activiti server) I tri...

nginx: send all requests to a single html page

Using nginx, I want to preserve the url, but actually load the same page no matter what. I will use the url with History.getState() to route the requests in my javascript app. It seems like it should be a simple thing to do? location / { rewri...

ImageView rounded corners

I wanted image to have rounded corners. I implement this xml code and use this in my image view. but image overlap the shape. I am downloading the image through async task. <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http:...

How to convert a UTF-8 string into Unicode?

I have string that displays UTF-8 encoded characters, and I want to convert it back to Unicode. For now, my implementation is the following: public static string DecodeFromUtf8(this string utf8String) { // read the string as UTF-8 bytes. by...

INSTALL_FAILED_NO_MATCHING_ABIS when install apk

I tried to install my app into Android L Preview Intel Atom Virtual Device, it failed with error: INSTALL_FAILED_NO_MATCHING_ABIS What does it mean?...

How to implement "Access-Control-Allow-Origin" header in asp.net

Is it possible to implement "Access-Control-Allow-Origin" header in asp.net...

Difference between JPanel, JFrame, JComponent, and JApplet

I'm making a physics simulator for fun and I was looking up graphics tutorials when I tried to figure out the difference between all these J's. Can somebody elaborate on them or perhaps provide a link to a helpful source?...

Use Font Awesome Icons in CSS

I have some CSS that looks like this: #content h2 { background: url(../images/tContent.jpg) no-repeat 0 6px; } I would like to replace the image with an icon from Font Awesome. I do not see anyway to use the icon in CSS as a background image....

Why must wait() always be in synchronized block

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

How do I trim whitespace from a string?

How do I remove leading and trailing whitespace from a string in Python? For example: " Hello " --> "Hello" " Hello" --> "Hello" "Hello " --> "Hello" "Bob has a cat" --> "Bob has a cat" ...

How to bring back "Browser mode" in IE11?

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

ng-if check if array is empty

The API I am working with returns this if there are no items in the array items: [] If there are items in the array it returns something like items: [ { name: 'Bla' } ] In my template I believe I need to use ng-if to either show/hide an...

Why is this HTTP request not working on AWS Lambda?

I'm getting started with AWS Lambda and I'm trying to request an external service from my handler function. According to this answer, HTTP requests should work just fine, and I haven't found any documentation that says otherwise. (In fact, people hav...

URL Encode a string in jQuery for an AJAX request

I'm implementing Google's Instant Search in my application. I'd like to fire off HTTP requests as the user types in the text input. The only problem I'm having is that when the user gets to a space in between first and last names, the space is not en...

Recyclerview and handling different type of row inflation

I'm trying to work with the new RecyclerView, but I could not find an example of a RecyclerView with different types of rows/cardviews getting inflated. With ListView I override the getViewTypeCount and getItemViewType, for handling different types ...

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in

I am trying to build a simple custom CMS, but I'm getting an error: Warning: mysqli_query() expects parameter 1 to be MySQLi, null given in Why am I getting this error? All my code is already MySQLi and I am using two parameters, not one. $con...

VBA setting the formula for a cell

I'm trying to set the formula for a cell using a (dynamically created) sheet name and a fixed cell address. I'm using the following line but can't seem to get it working: "=" & strProjectName & "!" & Cells(2, 7).Address Any advice on w...

How to create a numeric vector of zero length in R

I wonder, how can I create a numeric zero-length vector in R?...

Set cookies for cross origin requests

How to share cookies cross origin? More specifically, how to use the Set-Cookie header in combination with the header Access-Control-Allow-Origin? Here's an explanation of my situation: I am attempting to set a cookie for an API that is running on ...

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 make matrices in Python?

I've googled it and searched StackOverflow and YouTube.. I just can't get matrices in Python to click in my head. Can someone please help me? I'm just trying to create a basic 5x5 box that displays: A A A A A B B B B B C C C C C D D D D D E E E E E ...

Setting timezone in Python

Is it possible with Python to set the timezone just like this in PHP: date_default_timezone_set("Europe/London"); $Year = date('y'); $Month = date('m'); $Day = date('d'); $Hour = date('H'); $Minute = date('i'); I can't really install any other mod...

mysql extract year from date format

I need a mysql query to extract the year from the following date format from a table in my database. For eg : subdateshow ---------------- 01/17/2009 01/17/2009 01/17/2009 01/17/2009 01/...

Increasing nesting function calls limit

There is one very bad limit in PHP: if you call some function a1() that calls a2(), that calls a3... so when a99() will call a100() you will see Fatal error: Maximum function nesting level of '100' reached, aborting! Is there any way to increas...

How to add a jar in External Libraries in android studio

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

Stacked bar chart

I would like to create a stacked chart using ggplot2 and geom_bar. Here is my source data: Rank F1 F2 F3 1 500 250 50 2 400 100 30 3 300 155 100 4 200 90 10 I want a stacked chart where x is the rank a...

Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.

The error in the title is thrown only in Google Chrome, according to my tests. I'm base64 encoding a big XML file so that it can be downloaded: this.loader.src = "data:application/x-forcedownload;base64,"+ btoa("<?xml version=\"...

PHP using Gettext inside <<<EOF string

I use PHP's EOF string to format HTML content without the hassle of having to escape quotes etc. How can I use the function inside this string? <?php $str = <<<EOF <p>Hello</p> <p><?= _("World"); ?>&l...

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

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

Apache server keeps crashing, "caught SIGTERM, shutting down"

This just started happening three weeks or so ago. The content of my website hasn't changed, it's just a phpBB forum using MySQL as a backend. Nothing has changed in well over a year but recently, every two days or so, the server just shuts down ...

Swift's guard keyword

Swift 2 introduced the guard keyword, which could be used to ensure that various data is configured ready to go. An example I saw on this website demonstrates an submitTapped function: func submitTapped() { guard username.text.characters.count &...

Count number of objects in list

R function that will return the number of items in a list?...

Pyspark: Exception: Java gateway process exited before sending the driver its port number

I'm trying to run pyspark on my macbook air. When i try starting it up I get the error: Exception: Java gateway process exited before sending the driver its port number when sc = SparkContext() is being called upon startup. I have tried running th...

How to set the Default Page in ASP.NET?

Is there any section or code which allows us to set default page in web.config? For example, when people first visit my website, I want them to see CreateThing.aspx rather than Default.aspx. The solutions I already know: Put this line of code => ...

Twitter Bootstrap: div in container with 100% height

Using twitter bootstrap (2), I have a simple page with a nav bar, and inside the container I want to add a div with 100% height (to the bottom of the screen). My css-fu is rusty, and I can't work this out. Simple HTML: <body> <div class=...

What is the difference between a mutable and immutable string in C#?

What is the difference between a mutable and immutable string in C#?...

Differences in string compare methods in C#

Comparing string in C# is pretty simple. In fact there are several ways to do it. I have listed some in the block below. What I am curious about are the differences between them and when one should be used over the others? Should one be avoided a...

Export a graph to .eps file with R

How do I export a graph to an .eps format file? I typically export my graphs to a .pdf file (using the 'pdf' function), and it works quite well. However, now I have to export to .eps files....

Clicking submit button of an HTML form by a Javascript code

I don't know much about WEB probramming, so feel free to ask if I'm missing any details. There is a certain website which I'm visiting very frequently, and it requires users to log in every time they visit. For the login page of this website, I'm tr...

how to prevent adding duplicate keys to a javascript array

I found a lot of related questions with answers talking about for...in loops and using hasOwnProperty but nothing I do works properly. All I want to do is check whether or not a key exists in an array and if not, add it. I start with an empty array ...

How do I write outputs to the Log in Android?

I want to write some debugging output to the log to review it with logcat. If I write something to System.out this is already displayed in logcat. What is the clean way to write to the log and add levels and tags to my output?...

How to get the azure account tenant Id?

My question is: Is it possible to get the azure active directory tenant id without using powershell command? I found this two blogs and with this help, I'm already able to get the tenant ID and subscriptions ID from powershell. Is it the only way t...

What does $(function() {} ); do?

Sometimes I make a function and call the function later. Example: function example { alert('example'); } example(); // <-- Then call it later Somehow, some functions cannot be called. I have to call those functions inside: $(function() { }); ...

How to convert string date to Timestamp in java?

I want to convert string Date into Timestamp in java. The following coding i have written.I have declare the date for date1 is: 7-11-11 12:13:14. SimpleDateFormat datetimeFormatter1 = new SimpleDateFormat( "yyyy-MM-dd hh:mm:ss"); Dat...

A 'for' loop to iterate over an enum in Java

I have an enum in Java for the cardinal & intermediate directions: public enum Direction { NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, NORTHWEST } How can I write a for loop that iterates through each ...

How to insert a picture into Excel at a specified cell position with VBA

I'm adding ".jpg" files to my Excel sheet with the code below : 'Add picture to excel xlApp.Cells(i, 20).Select xlApp.ActiveSheet.Pictures.Insert(picPath).Select 'Calgulate new picture size With xlApp.Selection.ShapeRange .LockAspectRatio = msoT...