Examples On Programing Languages

How to check if a column exists in a SQL Server table?

I need to add a specific column if it does not exist. I have something like the following, but it always returns false: IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'myTableName' AND C...

Difference between `npm start` & `node app.js`, when starting app?

I have installed an application using the command express new 'filename'. I have just learned that you can start an application using: npm start Thus far I have used: node app.js to start my server. Anyone know what the difference is between t...

Best practice to call ConfigureAwait for all server-side code

When you have server-side code (i.e. some ApiController) and your functions are asynchronous - so they return Task<SomeObject> - is it considered best practice that any time you await functions that you call ConfigureAwait(false)? I had read th...

How to fix "containing working copy admin area is missing" in SVN?

I deleted manually a directory I just added, offline, in my repository. I can't restore the directory. Any attempt to do an update or a commit will fail with: "blabla/.svn" containing working copy admin area is missing. I understand why, but is ...

How to check if two arrays are equal with JavaScript?

var a = [1, 2, 3]; var b = [3, 2, 1]; var c = new Array(1, 2, 3); alert(a == b + "|" + b == c); demo How can I check these array for equality and get a method which returns true if they are equal? Does jQuery offer any method for this?...

Converting string to date in mongodb

Is there a way to convert string to date using custom format using mongodb shell I am trying to convert "21/May/2012:16:35:33 -0400" to date, Is there a way to pass DateFormatter or something to Date.parse(...) or ISODate(....) method?...

Difference of keywords 'typename' and 'class' in templates?

For templates I have seen both declarations: template < typename T > template < class T > What's the difference? And what exactly do those keywords mean in the following example (taken from the German Wikipedia article about template...

How to redirect output of an already running process

Normally I would start a command like longcommand &; I know you can redirect it by doing something like longcommand > /dev/null; for instance to get rid of the output or longcommand 2>&1 > output.log to capture output. But...

AngularJS does not send hidden field value

For a specific use case I have to submit a single form the "old way". Means, I use a form with action="". The response is streamed, so I am not reloading the page. I am completely aware that a typical AngularJS app would not submit a form that way, b...

How to add Web API to an existing ASP.NET MVC 4 Web Application project?

I wish to add an ASP.NET Web API to an ASP.NET MVC 4 Web Application project, developed in Visual Studio 2012. Which steps must I perform to add a functioning Web API to the project? I'm aware that I need a controller deriving from ApiController, but...

Excel - Using COUNTIF/COUNTIFS across multiple sheets/same column

I am trying to "COUNT" the number of a certain object in column I (in this instance) across multiple sheets. That value in column I is the result of a formula (if it matters). So far I have: =COUNTIF('Page M904'!I:I,A13)+COUNTIF('Page M905'!I:I,A13)...

Print <div id="printarea"></div> only?

How do I print the indicated div (without manually disabling all other content on the page)? I want to avoid a new preview dialog, so creating a new window with this content is not useful. The page contains a couple of tables, one of them contains ...

When to use: Java 8+ interface default method, vs. abstract method

Java 8 allows for default implementation of methods in interfaces called Default Methods. I am confused between when would I use that sort of interface default method, instead of an abstract class (with abstract method(s)). So when should interface...

comparing two strings in SQL Server

Is there any way to compare two strings in SQL Server 2008 stored procedure like below? int returnval = STRCMP(str1, str2) returns 0 if the strings are the same returns -1 if the first argument is smaller than the second according to the current ...

Header set Access-Control-Allow-Origin in .htaccess doesn't work

I can't figure out why my .htaccess header settings doesn't work. My .htaccess file content: Header set Access-Control-Allow-Origin * Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" Header always set Access-Control-...

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

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

How do I show a "Loading . . . please wait" message in Winforms for a long loading form?

I have a form that is very slow because there are many controls placed on the form. As a result the form takes a long time to loaded. How do I load the form first, then display it and while loading delay show another form which that have message...

Hide separator line on one UITableViewCell

I'm customizing a UITableView. I want to hide the line separating on the last cell ... can i do this? I know I can do tableView.separatorStyle = UITableViewCellStyle.None but that would affect all the cells of the tableView. I want it to only affect...

How to dockerize maven project? and how many ways to accomplish it?

I am new to Docker, and don't know how to run a java project with maven even though I have read many documents and tried many methods. Should I build the image using Dockerfile? What is the commands like when it is to run the maven project in the ...

How to set Google Chrome in WebDriver

I am trying to set Chrome as my browser for testing with Web-Driver and set the chromedriver.exe file properly but I am still getting the following error: org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the ...

Ruby on Rails 3 Can't connect to local MySQL server through socket '/tmp/mysql.sock' on OSX

I have a standard Rails3 environment, RVM 1.2.9, Rails 3.0.5, Ruby 1.9.2p180, MySQL2 Gem 0.2.7, mysql-5.5.10-osx10.6-x86_64 Error I get when running rake db:migrate to create database is: Can't connect to local MySQL server through socket '/tmp/my...

File path for project files?

I am working on a media player in C# but when I want to make my test I have a problem. I have to create a new object song with the following path: @"C:\Users\Jesus Antonio\Desktop\JukeboxV2.0\JukeboxV2.0\Datos\ich will.mp3" It works but when I ch...

pandas read_csv index_col=None not working with delimiters at the end of each line

I am going through the 'Python for Data Analysis' book and having trouble in the 'Example: 2012 Federal Election Commision Database' section reading the data to a DataFrame. The trouble is that one of the columns of data is always being set as the in...

Detecting a redirect in ajax request?

I want to use jQuery to GET a URL and explicitly check if it responded with a 302 redirect, but not follow the redirect. jQuery's $.ajax appears to always follow redirects. How can I prevent this, and see the redirect without following it? There a...

Why do I need to do `--set-upstream` all the time?

I create a new branch in Git: git branch my_branch Push it: git push origin my_branch Now say someone made some changes on the server and I want to pull from origin/my_branch. I do: git pull But I get: You asked me to pull without telling m...

GIT_DISCOVERY_ACROSS_FILESYSTEM not set

I have searched and read few post but my problem is not the same as described. So here's the issue: using git clone into folder under external partition of the disk works fine but all git commands fails. can't execute git status or git log... I alway...

Http Basic Authentication in Java using HttpClient?

I am trying to mimic the functionality of this curl command in Java: curl --basic --user username:password -d "" http://ipaddress/test/login I wrote the following using Commons HttpClient 3.0 but somehow ended up getting an 500 Internal Server Err...

React Native absolute positioning horizontal centre

It seems that with position:absolute in use an element cannot be centred using justifyContent or alignItems. There's a workaround to use marginLeft but does not display the same for all devices even using dimensions to detect height and width of devi...

How to checkout a specific Subversion revision from the command line?

I want to checkout a specific revision of a folder in Subversion using the command line. I don't see an option for specifying the revision number in TortoiseProc.exe, TortoiseProc.exe /command:checkout <url> How do I get the revision I want...

Find PHP version on windows command line

I just tried to know version of my PHP from windows command typing, C:\> php -v But it is not working. It says php is not recognized as internal or external command....

Slice indices must be integers or None or have __index__ method

I'm trying something with Python. I want to slice a list (plateau) in several list (L[i]) but I have the following error message: File "C:\Users\adescamp\Skycraper\skycraper.py", line 20, in <module> item = plateau[debut:fin] TypeError: ...

$(document).ready(function(){ Uncaught ReferenceError: $ is not defined

Hi I am having a "Uncaught ReferenceError: $ is not defined" while using bellow codes I am currently getting the following error in my log. I have been looking at the samples in the framework and I just can't seem to find where the error is. It's be...

Make REST API call in Swift

I'm trying to use Swift to make a GET call to a REST API, and have tried to follow numerous tutorials, but can't figure it out. Either because I cannot figure out how to translate all the Obj-C to Swift, or because half of the methods n' such are de...

What is the simplest and most robust way to get the user's current location on Android?

The LocationManager API on Android seems like it's a bit of a pain to use for an application that only needs an occasional and rough approximation of the user's location. The app I'm working on isn't really a location app per se, but it does need to...

How to remove underline from a name on hover

I have such html: <legend class="green-color"><a name="section1">Section</a></legend> legend.green-color{ color:green; } In my case Section looking green, but when i put mouse pointer on it it became looking like an a ...

How do I get list of all tables in a database using TSQL?

What is the best way to get the names of all of the tables in a specific database on SQL Server?...

How to upgrade PowerShell version from 2.0 to 3.0

The OS that I am using is Windows 7, and the PowerShell version that is installed here is 2.0. Is it possible for me to upgrade it to version 3.0 or 4.0? Because there are cmdlets that version 2.0 can't recognize....

Circular dependency in Spring

How does Spring resolve this: bean A is dependent on bean B, and bean B on bean A....

Style jQuery autocomplete in a Bootstrap input field

I have implemented a jQuery autocomplete function to a Bootstrap input. The jQuery autocomplete is working fine but I want to see the results as a combo and I guess it's now happening because I'm using BootStrap. This is the field that I'm assigning...

Check if ADODB connection is open

I use the following from within some excel procedures to establish a connection to our database. Private Const strConn As String = _ "PROVIDER=SQLOLEDB.1 ..." Sub OpenConnection() Set cn = CreateObject("ADODB.Connection") cn.Open strConn ...

Using an HTML button to call a JavaScript function

I am trying to use an HTML button to call a JavaScript function. Here's the code: <input type="button" value="Capacity Chart" onclick="CapacityChart();"> It doesn't seem to work correctly though. Is there a better way to do this? Here is t...

What is the canonical way to check for errors using the CUDA runtime API?

Looking through the answers and comments on CUDA questions, and in the CUDA tag wiki, I see it is often suggested that the return status of every API call should checked for errors. The API documentation contains functions like cudaGetLastError, cuda...

What does "exited with code 9009" mean during this build?

What does this error message mean? What could I do to correct this issue? AssemblyInfo.cs exited with code 9009 The problem is probably happening as part of a post-build step in a .NET solution in Visual Studio....

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

Double exclamation points?

Possible Duplicate: What is the !! (not not) operator in JavaScript? What does the !! operator (double exclamation point) mean in JavaScript? So I was debuging some code and ran across this: var foo.bar = 0; // this is actually passed f...

How do you share code between projects/solutions in Visual Studio?

I have two solutions which have some common code, so I'd like to extract it out and share it between them. Furthermore, I'd like to be able to release that library independently because it might be useful to others. What's the best way to do it wi...

Value cannot be null. Parameter name: source

This is probably the biggest waste of time problem I have spent hours on solving for a long time. var db = new hublisherEntities(); establishment_brands est = new establishment_brands(); est.brand_id = 1; est.establishment_id = 1; est.price = colle...

What is INSTALL_PARSE_FAILED_NO_CERTIFICATES error?

I was trying to change my default/main/startup (whatever you call it) activity by editing the androidmanifest.xml file. All i did was change the android:name property. however, this completely broke the entire app. when I try to install it fails and ...

How to get annotations of a member variable?

I want to know a class's some member variable's annotations , I use BeanInfo beanInfo = Introspector.getBeanInfo(User.class) to introspect a class , and use BeanInfo.getPropertyDescriptors() , to find specific property , and use Class type = property...

how to get current datetime in SQL?

Want to get current datetime to insert into lastModifiedTime column. I am using MySQL database. My questions are: is there a function available in SQL? or it is implementation depended so each database has its own function for this? what is the fu...

Passing a 2D array to a C++ function

I have a function which I want to take, as a parameter, a 2D array of variable size. So far I have this: void myFunction(double** myArray){ myArray[x][y] = 5; etc... } And I have declared an array elsewhere in my code: double anArray...

Initialize a vector array of strings

Would it be possible to initialize a vector array of strings. for example: static std::vector<std::string> v; //declared as a class member I used static just to initialize and fill it with strings. Or should i just fill it in constructor if ...

SQL Server - stop or break execution of a SQL script

Is there a way to immediately stop execution of a SQL script in SQL server, like a "break" or "exit" command? I have a script that does some validation and lookups before it starts doing inserts, and I want it to stop if any of the validations or lo...

Where is svn.exe in my machine?

I have Tortoise svn installed on my desktop. I want to perform some tasks using commandline svn.exe? But I am not able to find svn.exe on my machine. Do we have to install something else to get the svn.exe commands?...

Shell command to tar directory excluding certain files/folders

Is there a simple shell command/script that supports excluding certain files/folders from being archived? I have a directory that need to be archived with a sub directory that has a number of very large files I do not need to backup. Not quite solu...

Faking an RS232 Serial Port

I'm developing a project that has a number of hardware sensors connecting to the deployment machine through RS232 serial ports. But ... I'm developing on a machine without an physical RS232 serial ports, but I would like to make fake serial ports th...

Command copy exited with code 4 when building - Visual Studio restart solves it

Every now and then when I build my solution here (with 7 projects in it) I get the dreaded 'Command copy exited with code 4' error, in Visual Studio 2010 Premium ed. This is because of the post-build event not being able to go through. Here's what ...

CodeIgniter Disallowed Key Characters

CodeIgniter is giving me a Disallowed Key Characters error. I've narrowed it down to the name attribute of a form field: name='prod[50-4121.5]' but I'm not sure what to do about it....

How do I find the length/number of items present for an array?

Possible Duplicate: length of array in function argument My array size is 5. For example: arrCustId[5] How can I know how many Customer IDs are already present in my array? In short how to find length of array?...

python encoding utf-8

I am doing some scripts in python. I create a string that I save in a file. This string got lot of data, coming from the arborescence and filenames of a directory. According to convmv, all my arborescence is in UTF-8. I want to keep everything in UT...

Call a python function from jinja2

I am using jinja2, and I want to call a python function as a helper, using a similar syntax as if I were calling a macro. jinja2 seems intent on preventing me from making a function call, and insists I repeat myself by copying the function into a tem...

How to specify function types for void (not Void) methods in Java8?

I'm playing around with Java 8 to find out how functions as first class citizens. I have the following snippet: package test; import java.util.*; import java.util.function.*; public class Test { public static void myForEach(List<Integer>...

AutoComplete TextBox in WPF

Is it possible to make a textbox autocomplete in WPF? I found a sample where a combo box is used and the triangle is removed by editing the style template. Is there a better solution?...

How to use onClick event on react Link component?

I am using the Link component from the reactjs router and I cannot get the onClickevent working. This is the code: <Link to={this.props.myroute} onClick='hello()'>Here</Link> Is this the way to do it or another way?...

Http Get using Android HttpURLConnection

I'm new to Java and Android development and try to create a simple app which should contact a web server and add some data to a database using a http get. When I do the call using the web browser in my computer it works just fine. However, when I do...

What does it mean when Statement.executeUpdate() returns -1?

A query that works in management studio and in the executeUpdatemakes that same executeUpdate return -1, which is undefined in any documentation we can find. Its supposed to return only the rowcount or 0. What does this mean? The driver is the JDBC-O...

How to keep console window open

When I run my program, the console window seems to run and close. How to keep it open so I can see the results? class Program { public class StringAddString { public virtual void AddString() ...

Can't bind to 'ngForOf' since it isn't a known property of 'tr' (final release)

I'm using Angular2 Final release (2.1.0). When I want to display a list of companies, I got this error. in file.component.ts : public companies: any[] = [ { "id": 0, "name": "Available" }, { "id": 1, "name": "Ready" }, { "id": 2, "name...

Use Font Awesome Icon in Placeholder

Is it possible to use Font Awesome Icon in a Placeholder? I read that HTML isn't allowed in a placeholder. Is there a workaround? placeholder="<i class='icon-search'></i>" ...

Converting a POSTMAN request to Curl

I am calling my java webservice (POST request) via POSTMAN in the following manner which works perfectly fine (i.e. I can see my records getting inserted into the database): And, here's how the contents inside the Headers(1) tab looks like: Instead...

How do I view / replay a chrome network debugger har file saved with content?

I love the network debugger, that being said, what programs are out there that let me step forward and backward through multiple 'hars' so I can replay them? if the 'hars' are saved with content, can the replay handle that as well? right now I just ...

Iterate through object properties

_x000D_ _x000D_ var obj = {_x000D_ name: "Simon",_x000D_ age: "20",_x000D_ clothing: {_x000D_ style: "simple",_x000D_ hipster: false_x000D_ }_x000D_ }_x000D_ _x000D_ for(var propt in obj){_x000D_ console.log(propt ...

git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054

I'm having trouble cloning a repo on git. I've been trying for to days and have tried quite a few solutions (in most the problem was slightly different but seemed to apply) but nothing has done anything to make a difference. I've tried switching off...

How can I draw vertical text with CSS cross-browser?

I want to rotate a single word of text by 90 degrees, with cross-browser (>= IE6, >= Firefox 2, any version of Chrome, Safari, or Opera) support. How can this be done?...

How to get the changes on a branch in Git

What is the best way to get a log of commits on a branch since the time it was branched from the current branch? My solution so far is: git log $(git merge-base HEAD branch)..branch The documentation for git-diff indicates that git diff A...B is e...

Adding sheets to end of workbook in Excel (normal method not working?)

This is the VBA code im using to try add a new sheet to the last place in the workbook mainWB.Sheets.Add(After:=Sheets(Sheets.Count)).Name = new_sheet_name I saw this in a similar question on this site. Its not working. I do this in a loop and ea...

XPath to get all child nodes (elements, comments, and text) without parent

I need an XPath to fetch all ChildNodes ( including Text Element, Comment Element & Child Elements ) without Parent Element. Any help Sample Example: <DOC> <PRESENTEDIN> <X> First Text Node #1 <y> Y ...

Check if value exists in column in VBA

I have a column of numbers of over 500 rows. I need to use VBA to check if variable X matches any of the values in the column. Can someone please help me?...

Load an image from a url into a PictureBox

I want to load an image into a PictureBox. This is the image I want to load: http://www.gravatar.com/avatar/6810d91caff032b202c50701dd3af745?d=identicon&r=PG How do I do this?...

How do I fix the multiple-step OLE DB operation errors in SSIS?

I'm attempting to make a DTS package to transfer data between two databases on the same server and I'm getting the following errors. Iv read that the Multiple-step OLE DB operation generated error can occur when you are transferring between different...

What is JAVA_HOME? How does the JVM find the javac path stored in JAVA_HOME?

I would like to know what is JAVA_HOME. Where do I set the path of javac.exe and java.exe. It is in environment variables. When I compile a Java program from command prompt, how does the JVM find javac.exe?...

Generate a random number in a certain range in MATLAB

How can I generate a random number in MATLAB between 13 and 20?...

How to instantiate a javascript class in another js file?

Suppose if I define a class in file1.js function Customer(){ this.name="Jhon"; this.getName=function(){ return this.name; }; }; Now if I want to create a Customer object in file2.js var customer=new Customer(); var name=custom...

How to write a Unit Test?

I have a Java class. How can I unit test it? In my case, I have class does a binary sum. It takes two byte[] arrays, sums them, and returns a new binary array....

Git push/clone to new server

I'm just learning Git and there is something I can't work out. After creating and using a git repository locally on my Mac, can I push a copy to another server somewhere else? I am behind a firewall so unfortunately I can't run git clone from the oth...

What is a "method" in Python?

Can anyone, please, explain to me in very simple terms what a "method" is in Python? The thing is in many Python tutorials for beginners this word is used in such way as if the beginner already knew what a method is in the context of Python. While I...

Can you have if-then-else logic in SQL?

I need to do select data from a table based on some kind of priority like so: select product, price from table1 where project = 1 -- pseudo: if no price found, do this: select product, price from table1 where customer = 2 -- pseudo: if still no pr...

Search and get a line in Python

Is there a way to search, from a string, a line containing another string and retrieve the entire line? For example: string = qwertyuiop asdfghjkl zxcvbnm token qwerty asdfghjklñ retrieve_line("token") = "token qwerty" ...

python filter list of dictionaries based on key value

I have a list of dictionaries and each dictionary has a key of (let's say) 'type' which can have values of 'type1', 'type2', etc. My goal is to filter out these dictionaries into a list of the same dictionaries but only the ones of a certain "type". ...

Declare an array in TypeScript

I'm having trouble either declaring or using a boolean array in Typescript, not sure which is wrong. I get an undefined error. Am I supposed to use JavaScript syntax or declare a new Array object? Which one of these is the correct way to create the...

Git submodule push

If I modify a submodule, can I push the commit back to the submodule origin, or would that require a clone? If clone, can I store a clone inside another repository?...

Installing a plain plugin jar in Eclipse 3.5

Since Eclipse 3.5 there seems to be no option to have drop a plugin jar ( not a feature ) in the Eclipse base directory and have it picked up at next startup. Is there any possiblity to have plain plugins jars installed in Eclipse 3.5?...

How to index into a dictionary?

I have a Dictionary below: colors = { "blue" : "5", "red" : "6", "yellow" : "8", } How do I index the first entry in the dictionary? colors[0] will return a KeyError for obvious reasons....

How to make join queries using Sequelize on Node.js

I am using sequelize ORM; everything is great and clean, but I had a problem when I use it with join queries. I have two models: users and posts. var User = db.seq.define('User',{ username: { type: db.Sequelize.STRING}, email: { type: db.Seq...

Check if element at position [x] exists in the list

If I have a list of strings List<String> list = new list<String>(); list.add("str1"); list.add("str2"); list.add("str3"); and I want to know if for example index position 2 contains an element, is there a simple way of doing this with...

in a "using" block is a SqlConnection closed on return or exception?

First question: Say I have using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); string storedProc = "GetData"; SqlCommand command = new SqlCommand(storedProc, connection); command.CommandType ...

Why use #ifndef CLASS_H and #define CLASS_H in .h file but not in .cpp?

I have always seen people write class.h #ifndef CLASS_H #define CLASS_H //blah blah blah #endif The question is, why don't they also do that for the .cpp file that contain definitions for class functions? Let's say I have main.cpp, and main.c...

How to install PyQt4 on Windows using pip?

I'm using Python 3.4 on Windows. When I run a script, it complains ImportError: No Module named 'PyQt4' So I tried to install it, but pip install PyQt4 gives Could not find any downloads that satisfy the requirement PyQt4 although it does sh...

Call Python script from bash with argument

I know that I can run a python script from my bash script using the following: python python_script.py But what about if I wanted to pass a variable / argument to my python script from my bash script. How can I do that? Basically bash will work o...

how to make log4j to write to the console as well

Is there any way to tell to log4j to write its log to the file and to the console? thanks there are my properties: log4j.rootLogger=DEBUG,console,R log4j.rootLogger=INFO, FILE log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.C...

Explain ExtJS 4 event handling

I've recently started learning ExtJS, and have trouble understanding how to handle Events. I have no experience of any previous versions of ExtJS. From reading various manuals, guides and documentation pages, I've figured out how to use it, but I'm...

How to set header and options in axios?

I use Axios to perform an HTTP post like this: import axios from 'axios' params = {'HTTP_CONTENT_LANGUAGE': self.language} headers = {'header1': value} axios.post(url, params, headers) Is this correct? Or should I do: axios.post(url, params: para...

How to detect the device orientation using CSS media queries?

In JavaScript the orientation mode can be detected using: if (window.innerHeight > window.innerWidth) { portrait = true; } else { portrait = false; } However, is there a way to detect the orientation using CSS only? Eg. something like:...

Regex match entire words only

I have a regex expression that I'm using to find all the words in a given block of content, case insensitive, that are contained in a glossary stored in a database. Here's my pattern: /($word)/i The problem is, if I use /(Foo)/i then words like Fo...

Must JDBC Resultsets and Statements be closed separately although the Connection is closed afterwards?

It is said to be a good habit to close all JDBC resources after usage. But if I have the following code, is it necessary to close the Resultset and the Statement? Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; try { ...

How to update a single pod without touching other dependencies

I understand that the following command will update a single pod: pod update <podname>. However this also updates the dependencies of other pods (pods that were not included in the update command) that you have previously installed. Is there a ...

Could not load file or assembly "Oracle.DataAccess" or one of its dependencies

I am trying to run this web application. I keep getting this error "Could not load file or assembly "Oracle.DataAccess" or one of its dependencies. An attempt was made to load a program with an incorrect format." Exception details: System.BadImageFor...

Hashmap does not work with int, char

Possible Duplicate: Storing primitive values in a Java collection? In java when I use the following :- public HashMap<char, int> buildMap(String letters) { HashMap<char, int> checkSum = new HashMap<char, int>(); ...

Auto populate columns in one sheet from another sheet

I would like to populate columns in sheet2 from sheet1. If I have column A in Sheet1 I want A in Sheet2 to have the same information. I tried using =sheet1!A1 but it only returns the value from A1 in sheet1. I tried using =sheet1!A but it only retur...

ERROR 1064 (42000): You have an error in your SQL syntax; Want to configure a password as root being the user

I have just downloaded WAMP. I want to configure a password for the MySQL root user using MySQL console. No password has been set previously. The following is the input mysql-> use mysql Database changed mysql-> UPDATE user ...

Maven artifact and groupId naming

I'm currently in the process of moving some project from Ant to Maven. Conformist as I am, I want to use well-established conventions for finding groupId and artifactId, but I can't find any detailed conventions (there are some, but they don't cover ...

Node.js/Windows error: ENOENT, stat 'C:\Users\RT\AppData\Roaming\npm'

I have Windows 7 32-bit. I installed the latest Node.js 32 bit. When I try to run the command npm install jquery, I receive the error: Error: ENOENT, stat 'C:\Users\RT\AppData\Roaming\npm How does one resolve it?...

Check for internet connection with Swift

When I try to check for an internet connection on my iPhone I get a bunch of errors. Can anyone help me to fix this? The code: import Foundation import SystemConfiguration public class Reachability { class func isConnectedToNetwork() -> Bool {...

I want to remove double quotes from a String

I want to remove the "" around a String. e.g. if the String is: "I am here" then I want to output only I am here....

port 8080 is already in use and no process using 8080 has been listed

I am trying to start Tomcat from Eclipse, but a problem occured: Port 8080 required by Tomcat v6.0 Server at localhost is already in use. The server may already be running in another process, or a system process may be using the port. To start ...

Nginx 403 forbidden for all files

I have nginx installed with PHP-FPM on a CentOS 5 box, but am struggling to get it to serve any of my files - whether PHP or not. Nginx is running as www-data:www-data, and the default "Welcome to nginx on EPEL" site (owned by root:root with 644 per...

HTML button to NOT submit form

I have a form. Outside that form, I have a button. A simple button, like this: <button>My Button</button> Nevertheless, when I click it, it submits the form. Here's the code: <form id="myform"> <input /> </form> ...

Convert Uri to String and String to Uri

I'm developing some Application which allows select image from SD Card, save it into database and set this value for ImageView. I need to know way for converting uri to string and string to uri. Now I used getEncodedPath() method of Uri, but, for exa...

How to add a single item to a Pandas Series

How Do I add a single item to a serialized panda series. I know it's not the most efficient way memory wise, but i still need to do that. Something along: >> x = Series() >> N = 4 >> for i in xrange(N): >> x.some_appendi...

How to call a function after delay in Kotlin?

As the title, is there any way to call a function after delay (1 second for example) in Kotlin?...

How would you count occurrences of a string (actually a char) within a string?

I am doing something where I realised I wanted to count how many /s I could find in a string, and then it struck me, that there were several ways to do it, but couldn't decide on what the best (or easiest) was. At the moment I'm going with something...

Continuous Integration vs. Continuous Delivery vs. Continuous Deployment

What's the difference between these three terms? My university provides the following definitions: Continuous Integration basically just means that the developer's working copies are synchronized with a shared mainline several times a day. Continuo...

Show loading image while $.ajax is performed

I am just wondering how to show an image that indicates that the async request is running. I use the following code to perform a async request: $.ajax({ url: uri, cache: false, success: function(html){ $('.info').append(html); } }); An...

How to remove all options from a dropdown using jQuery / JavaScript

I have a dropdown as seen below: <select id="models" onchange="removeElements()"> <option id = "remove" value="0">R8</option> <option id = "remove" value="1">Quattro</option> <opti...

How to extract string following a pattern with grep, regex or perl

I have a file that looks something like this: <table name="content_analyzer" primary-key="id"> <type="global" /> </table> <table name="content_analyzer2" primary-key="id"> <type="global" /> &...

How do I make a redirect in PHP?

Is it possible to redirect a user to a different page through the use of PHP? Say the user goes to www.example.com/page.php and I want to redirect them to www.example.com/index.php, how would I do so without the use of a meta refresh? Is it possible...

Convert data.frame column format from character to factor

I would like to change the format (class) of some columns of my data.frame object (mydf) from charactor to factor. I don't want to do this when I'm reading the text file by read.table() function. Any help would be appreciated....

How to remove word wrap from textarea?

my simple textarea doesn't show a horizontal bar when text overflows. It wraps text for a new line. So how do I remove wordwrap and display horizontal bar when text overflows?...

GIT_DISCOVERY_ACROSS_FILESYSTEM problem when working with terminal and MacFusion

I'm using MacFusion with OSXFuse(similar to MacFuse) to mount my server over SSH onto my office machine. When I cd into my rails work directory on the server, i can't see any git info in my zsh prompt. If i try a git pull origin, i get the following ...

Does bootstrap 4 have a built in horizontal divider?

Does bootstrap 4 have a built in horizontal divider? I can do this, <style type="text/css"> .h-divider{ margin-top:5px; margin-bottom:5px; height:1px; width:100%; border-top:1px solid gray; } </style> But I want to use the built i...

Can we use join for two different database tables?

Can we use the join operation for two tables from different databases? If yes, how do I do it? Both databases are on the same server and DBMS is the same....

How to write/update data into cells of existing XLSX workbook using xlsxwriter in python

I am able to write into new xlsx workbook using import xlsxwriter def write_column(csvlist): workbook = xlsxwriter.Workbook("filename.xlsx",{'strings_to_numbers': True}) worksheet = workbook.add_worksheet() row = 0 col = 0 for...

How to style the menu items on an Android action bar

There's been many questions on styling on action bars, but the ones I've found either are relating to styling the tabs, or have answers that don't work for me. The question is really quite simple. I want to be able to change the text styling (even j...

Redeploy alternatives to JRebel

JRebel allows for newly compiled code to be redeployed without restarting the application. I am wondering if there are any alternative (free?). The FAQ page answers this question, but I am sure it's biased towards JRebel. This question was asked ...

How to fix ReferenceError: primordials is not defined in node

I have installed node modules by npm install, then I tried to do gulp sass-watch in command prompt. After that I got the below response. [18:18:32] Requiring external module babel-register fs.js:27 const { Math, Object, Reflect } = primordials; ...

Trim Whitespaces (New Line and Tab space) in a String in Oracle

I need to trim New Line (Chr(13) and Chr(10) and Tab space from the beginning and end of a String) in an Oracle query. I learnt that there is no easy way to trim multiple characters in Oracle. "trim" function trims only single character. It would be ...

Visual studio - getting error "Metadata file 'XYZ' could not be found" after edit continue

I have stumbled into an issue that is really annoying. When I debug my software, everything runs OK, but if I hit a breakpoint and edit the code, when I try to continue running I get an error: Metadata file 'XYZ' could not be found After looking aro...

How to start up spring-boot application via command line?

I have a spring-boot application which I need to start up by going to the folder directory and start up my web application via command line. I have a class called Application.java and the code inside it is as followed. @SpringBootApplication(scanBas...

How do I escape only single quotes?

I am writing some JavaScript code that uses a string rendered with PHP. How can I escape single quotes (and only single quotes) in my PHP string? <script type="text/javascript"> $('#myElement').html('say hello to <?php echo $mystringWit...

How to delete a workspace in Perforce (using p4v)?

I'm new to Perforce and have created a few workspaces as exercises for getting familiar with it. Now I would like to delete some of the workspaces. I just want to get rid of the workspaces so that they do not appear on the drop-down in the workspaces...

HTML5 Local storage vs. Session storage

Apart from being non persistent and scoped only to the current window, are there any benefits (performance, data access, etc) to Session Storage over Local Storage?...

Python string.replace regular expression

I have a parameter file of the form: parameter-name parameter-value Where the parameters may be in any order but there is only one parameter per line. I want to replace one parameter's parameter-value with a new value. I am using a line replace ...

Find and replace with sed in directory and sub directories

I run this command to find and replace all occurrences of 'apple' with 'orange' in all files in root of my site: find ./ -exec sed -i 's/apple/orange/g' {} \; But it doesn't go through sub directories. What is wrong with this command? Here are s...

Android: Scale a Drawable or background image?

On a layout I want to scale the background image (keeping its aspect ratio) to the space allocated when the page gets created. Does anyone have an idea how to do this? I am using layout.setBackgroundDrawable() and a BitmapDrawable() to set gravity f...

How to output to the console in C++/Windows

When using iostream in C++ on Linux, it displays the program output in the terminal, but in Windows, it just saves the output to a stdout.txt file. How can I, in Windows, make the output appear in the console?...

How can I set a custom baud rate on Linux?

I want to communicate over my serial port on Linux to a device with a non-standard-baud rate that is not defined in termios.h. I tried the "baud rate aliasing"-method from this post, but when I execute my C-program (I’ve named it "testprogram"), L...

How to disable XDebug

I think that my server became slow since I installed XDebug. So, in order to test my hypothesis I want to disable XDebug completely. I've been searching for tutorials on how to do this but I can't find such information....

Check that Field Exists with MongoDB

So I'm attempting to find all records who have a field set and isn't null. I try using $exists, however according to the MongoDB documentation, this query will return fields who equal null. $exists does match documents that contain the field tha...

CodeIgniter query: How to move a column value to another column in the same row and save the current time in the original column?

In my db table, I have two datetime columns: Last and Current. These column allow me to keep track of when someone last used a valid login to the service I am building up. Using CodeIgniter's active record, is it possible to update a row so that the...

How to select some rows with specific rownames from a dataframe?

I have a data frame with several rows. I want to select some rows with specific rownames (such as stu2,stu3,stu5,stu9) from this dataframe. The input example dataframe is as follows: attr1 attr2 attr3 attr4 stu1 0 0 1 0 ...

require(vendor/autoload.php): failed to open stream

I know that this issue has been posted many times, but for me it seems to be a different problem. Indeed, this error Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\site_web\send_mail.php on...

Execute jQuery function after another function completes

I want to execute a custom jQuery function after another custom function completes The first function is used for creating a "typewriting" effect function Typer() { var srcText = 'EXAMPLE '; var i = 0; var result = srcText[i]; setIn...

SQL-Server: The backup set holds a backup of a database other than the existing

I am trying to restore a SQL Server backup file for my database, but it is throwing an error as follow: The backup set holds a backup of a database other than the existing My database in SQL Server 2008 and the backup file is in 2005. What ca...

Node package ( Grunt ) installed but not available

I'm trying to build a github jquery-ui library using grunt, but after running npm install I still can't run the command according to the readme file. It just gives No command 'grunt' found: james@ubuntu:~/Documents/projects/ad2/lib/jquery-ui$ grunt...

How to not wrap contents of a div?

I've got a fixed-width div with two buttons in it. If the labels of the buttons are too long, they wrap – one button stays on the first line, and the next button follows underneath it instead of adjacent to it. How can I force the div to expan...

(13: Permission denied) while connecting to upstream:[nginx]

I am working with configuring Django project with Nginx and Gunicorn. While I am accessing my port gunicorn mysite.wsgi:application --bind=127.0.0.1:8001 in Nginx server, I am getting the following error in my error log file; 2014/05/30 11:59:42...

Why does modulus division (%) only work with integers?

I recently ran into an issue that could easily be solved using modulus division, but the input was a float: Given a periodic function (e.g. sin) and a computer function that can only compute it within the period range (e.g. [-p, p]), make a funct...

How to configure Glassfish Server in Eclipse manually

I have GlassFish server3.1.2.2 pre installed on my machine. Which I want to use in my Eclipse Luna How do I manually configure it to use in Eclipse? When I tried using Eclipse Market Place i got an error No repository found at http://download.oracl...

What's causing my java.net.SocketException: Connection reset?

We are seeing frequent but intermittent java.net.SocketException: Connection reset errors in our logs. We are unsure as to where the Connection reset error is actually coming from, and how to go about debugging. The issue appears to be unrelated to...

What is the difference between HTTP and REST?

After reading a lot about the differences between REST and SOAP, I got the impression that REST is just another word for HTTP. Can someone explain what functionality REST adds to HTTP? Note: I'm not looking for a comparison of REST versus SOAP. Upd...

CSS technique for a horizontal line with words in the middle

I'm trying to make a horizontal rule with some text in the middle. For example: ----------------------------------- my title here ----------------------------- Is there a way to do that in CSS? Without all the "-" dashes obviously....

How to go to a URL using jQuery?

How to go to a URL using jQuery or JavaScript. <a href="javascript:void(0)" onclick="javascript:goToURL()">Go To URL</a> function goToURL(url){ // some code to go to url } I don't want to use window.location as I want to invoke thi...

Filter dict to contain only certain keys?

I've got a dict that has a whole bunch of entries. I'm only interested in a select few of them. Is there an easy way to prune all the other ones out?...

Java array assignment (multiple values)

I have a Java array defined already e.g. float[] values = new float[3]; I would like to do something like this further on in the code: values = {0.1f, 0.2f, 0.3f}; But that gives me a compile error. Is there a nicer way to define multiple value...

Select Rows with id having even number

I am passing a simple query where I am searching for specific rows where OrderID is an even number SELECT * FROM Orders WHERE mod(OrderID,2) = 0; Error : Syntax error (missing operator) in query expression 'mod(OrderID,2) = 0'. ...

Error in your SQL syntax; check the manual that corresponds to your MySQL server version

HTML CODE <!DOCTYPE html> <html> <head> <style> #right { margin-top:109px; margin-right:225px; } #button { margin-right:; margin-top:22px; } </style>...

jQuery: If this HREF contains

Why can't I get this to work?? $("a").each(function() { if ($(this[href$="?"]).length()) { alert("Contains questionmark"); } }); Ps.: This is just at simplifyed example, to make it easier for you to get an overview....

Check if string is neither empty nor space in shell script

I am trying to run the following shell script which is supposed to check if a string is neither space nor empty. However, I am getting the same output for all the 3 mentioned strings. I have tried using the "[[" syntax as well but to no avail. Here ...

How to make an HTTP get request with parameters

Is it possible to pass parameters with an HTTP get request? If so, how should I then do it? I have found an HTTP post requst (link). In that example the string postData is sent to a webserver. I would like to do the same using get instead. Google fou...

How do I find the distance between two points?

Let's say I have x1, y1 and also x2, y2. How can I find the distance between them? It's a simple math function, but is there a snippet of this online?...

AngularJS How to dynamically add HTML and bind to controller

I'm just getting started with angularJS and struggling to figure out proper architecture for what I'm trying to do. I have a single page app but the URL always should stay the same; I don't want the user to be able to navigate to any routes beyond t...

Reading/parsing Excel (xls) files with Python

What is the best way to read Excel (XLS) files with Python (not CSV files). Is there a built-in package which is supported by default in Python to do this task?...

How does OAuth 2 protect against things like replay attacks using the Security Token?

As I understand it, the following chain of events occurs in OAuth 2 in order for Site-A to access User's information from Site-B. Site-A registers on Site-B, and obtains a Secret and an ID. When User tells Site-A to access Site-B, User is sent to S...

Alternative to the HTML Bold tag

Okay, so I know that in HTML you can use the <b> tag, but isn't there a "weight=bold" attribute that I can use in the <p> tag? Or is that in CSS, or Javascript?...

Python logging not outputting anything

In a python script I am writing, I am trying to log events using the logging module. I have the following code to configure my logger: ERROR_FORMAT = "%(levelname)s at %(asctime)s in %(funcName)s in %(filename) at line %(lineno)d: %(message)s" DEBUG...

What do pty and tty mean?

I noticed many mentions of pty and tty in some open source projects, could someone tell me what do they mean and what is the difference between them?...

Traverse a list in reverse order in Python

So I can start from len(collection) and end in collection[0]. I also want to be able to access the loop index....

HTML form action and onsubmit issues

I want to run JavaScript user validation on some textbox entries. The problem I'm having is that my form has the action of going to a new page within our site, and the onsubmit attribute never runs the JavaScript function. Is there a better solution,...

Throw HttpResponseException or return Request.CreateErrorResponse?

After reviewing an article Exception Handling in ASP.NET Web API I am a bit confused as to when to throw an exception vs return an error response. I am also left wondering whether it is possible to modify the response when your method returns a domai...

Mvn install or Mvn package

I am new to Maven, I have a Java based web project with maven configured in my MyEclipse. Now if I modified any java files then do I need to do Run as -> Mvn install or Mvn package?...

Sending JSON to PHP using ajax

I want to send some data in json format to php and do some operation in php. My problem is i can't send json data via ajax to my php file.Please help me how can i do that. I have tried this way.. <script> $(function (){ $("#add-cart").click(f...

Fatal error: "No Target Architecture" in Visual Studio

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

Python copy files to a new directory and rename if file name already exists

I've already read this thread but when I implement it into my code it only works for a few iterations. I'm using python to iterate through a directory (lets call it move directory) to copy mainly pdf files (matching a unique ID) to another director...

How can I create an editable combo box in HTML/Javascript?

I need to let users select an item from a dropdown list, but also allow them to instead enter any text, even if it doesn't match an item in the list. How can I achieve this on a web page with HTML and Javascript? The select field doesn't let users e...

Dots in URL causes 404 with ASP.NET mvc and IIS

I have a project that requires my URLs have dots in the path. For example I may have a URL such as www.example.com/people/michael.phelps URLs with the dot generate a 404. My routing is fine. If I pass in michaelphelps, without the dot, then everythi...

Meaning of tilde in Linux bash (not home directory)

First off, I know that ~/ is the home directory. CDing to ~ or ~/ takes me to the home directory. However, cd ~X takes me to a special place, where X seems to be anything. In bash, if I hit "cd ~" and hit tab, it shows a bunch of possible ~X option...

Android: Quit application when press back button

In my application i want exit from app when press back button, this my code: @Override public void onBackPressed() { new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle("Exit") .setMessage("...

How do you change the width and height of Twitter Bootstrap's tooltips?

I created a tooltip using Twitter Bootstrap. The tooltip is displaying with three lines. However, I would like to display the tooltip with only one line. How do I change the width of the tooltip? Is this specific to Twitter Bootstrap or to tooltips...

Node.js ES6 classes with require

So up until now, i have created classes and modules in node.js the following way: var fs = require('fs'); var animalModule = (function () { /** * Constructor initialize object * @constructor */ var Animal = function (name...

Clear listview content?

I have a little problem with ListView. How do I clear a ListView content, knowing that it has a custom adapter? edit - the custom adapter class extends BaseAdapter, it looks like this: import android.app.Activity; import android.content.Context; im...

Select from multiple tables without a join?

What is the easiest way to select data from two tables and rather than join them, have them appear as separate rows. Both tables have similar or matching fields and I want to run some aggregate function on them such as avg all the rows that occurred ...

How to escape a while loop in C#

I am trying to escape a while loop. Basically, if the "if" condition is met, I would like to be able to exit this loop: private void CheckLog() { while (true) { Thread.Sleep(5000); if (!System.IO.File.Exists("Command.bat")) ...

How to verify static void method has been called with power mockito

I am using the following. Powermock-mockito 1.5.12 Mockito 1.95 junit 4.11 Here is my utils class public void InternalUtils { public static void sendEmail(String from, String[] to, String msg, String body) { } } here is gist of the clas...

What’s the best RESTful method to return total number of items in an object?

I’m developing a REST API service for a large social networking website I’m involved in. So far, it’s working great. I can issue GET, POST, PUT and DELETE requests to object URLs and affect my data. However, this data is paged (limited to 30 re...

Stretch and scale a CSS image in the background - with CSS only

I want that my background image stretch and scale depending on the browser viewport size. I've seen some questions on Stack Overflow that do the job, like Stretch and scale CSS background for example. It works well, but I want to place the imag...

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

How to create a file on Android Internal Storage?

I want to save a file on internal storage into a specific folder. My code is: File mediaDir = new File("media"); if (!mediaDir.exists()){ mediaDir.createNewFile(); mediaDir.mkdir(); } File f = new File(getLocalPath()); f.createNewFile(); File...

Find and Replace text in the entire table using a MySQL query

Usually I use manual find to replace text in a MySQL database using phpmyadmin. I'm tired of it now, how can I run a query to find and replace a text with new text in the entire table in phpmyadmin? Example: find keyword domain.com, replace with ww...

How to go back last page

Is there a smart way to go back last page in Angular 2? Something like this._router.navigate(LASTPAGE); For example, page C has a Go Back button, Page A -> Page C, click it, back to page A. Page B -> Page C, click it, back to page B. Does rou...

How do I apply the for-each loop to every character in a String?

So I want to iterate for each character in a string. So I thought: for (char c : "xyz") but I get a compiler error: MyClass.java:20: foreach not applicable to expression type How can I do this?...

jQuery click function doesn't work after ajax call?

The jQuery click function works fine here <div id="LangTable"><a class="deletelanguage">delete</a></div> $('.deletelanguage').click(function(){ alert("success"); }); but if I set some <a> by ajax, $('.deletel...

How do I add a library (android-support-v7-appcompat) in IntelliJ IDEA

I created a project, copied the resource files in the project, library, added it to the project structure, prescribed style Theme.AppCompat. Compiled without errors, but when you start the relegation Exception: 08-03 00:50:00.406: ERROR/AndroidRunti...

What's the difference between <b> and <strong>, <i> and <em>?

What's the difference between <b> and <strong>, <i> and <em> in HTML/XHTML? When should you use each?...

Find row where values for column is maximal in a pandas DataFrame

How can I find the row for which the value of a specific column is maximal? df.max() will give me the maximal value for each column, I don't know how to get the corresponding row....

What is the best way to determine a session variable is null or empty in C#?

What is the best way to check for the existence of a session variable in ASP.NET C#? I like to use String.IsNullOrEmpty() works for strings and wondered if there was a similar method for Session. Currently the only way I know of is: var session...

Switch statement for string matching in JavaScript

How do I write a swtich for the following conditional? If the url contains "foo", then settings.base_url is "bar". The following is achieving the effect required but I've a feeling this would be more manageable in a switch: var doc_location = docu...

Working copy XXX locked and cleanup failed in SVN

I get this error when I do an svn update: Working copy XXXXXXXX locked Please execute "Cleanup" command When I run cleanup, I get Cleanup failed to process the following paths: XXXXXXXX How do I get out of this loop?...

How do I vertically center text with CSS?

I have a <div> element which contains text and I want to align the contents of this <div> vertically center. Here is my <div> style: _x000D_ _x000D_ #box { height: 170px; width: 270px; background: #000; font-size: 48px; co...

Subtracting two lists in Python

In Python, How can one subtract two non-unique, unordered lists? Say we have a = [0,1,2,1,0] and b = [0, 1, 1] I'd like to do something like c = a - b and have c be [2, 0] or [0, 2] order doesn't matter to me. This should throw an exception if a does...

What exactly is an instance in Java?

What is the difference between an object, instance, and reference? They say that they have to create an instance to their application? What does that mean?...

Secure hash and salt for PHP passwords

It is currently said that MD5 is partially unsafe. Taking this into consideration, I'd like to know which mechanism to use for password protection. This question, Is “double hashing” a password less secure than just hashing it once? suggests th...

How to pass parameter to function using in addEventListener?

In the traditional way to add event listener: function getComboA(sel) { var value = sel.options[sel.selectedIndex].value; } <select id="comboA" onchange="getComboA(this)"> <option value="">Select combo</option> <option va...

Regex to test if string begins with http:// or https://

I'm trying to set a regexp which will check the start of a string, and if it contains either http:// or https:// it should match it. How can I do that? I'm trying the following which isn't working: ^[(http)(https)]:// ...

Add A Year To Today's Date

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

How to display list of repositories from subversion server

I'm looking for a way to search a whole subversion server. I already got a piece of the puzzle to search within a repository. Now I need to do this for every repository. Update: I have to access this list from some unix shell script (perl, bash, ...

Replace all 0 values to NA

I have a dataframe with some numeric columns. Some row has a 0 value which should be considered as null in statistical analysis. What is the fastest way to replace all the 0 value to NULL in R? ...

Convert IQueryable<> type object to List<T> type?

I have IQueryable<> object. I want to Convert it into List<> with selected columns like new { ID = s.ID, Name = s.Name }. Edited Marc you are absolutely right! but I have only access to FindByAll() Method (because of my architecture)....

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

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

Generate a random letter in Python

Is there a way to generate random letters in Python (like random.randint but for letters)? The range functionality of random.randint would be nice but having a generator that just outputs a random letter would be better than nothing....

How to get the name of the current Windows user in JavaScript

I was wondering how I would get the name of the current user in JavaScript as part of an HTML document. In Java, one would type System.getProperty("user.name"); to achieve this. What is the alternative to this in JavaScript?...

Handler vs AsyncTask vs Thread

I got slightly confused about the differences between Handlers, AsyncTask and Threads in Android. I've read quite a few blogs and questions here in StackOverflow. Handler are background threads that provide you to communicate with the UI. Updating ...

Does it matter what extension is used for SQLite database files?

Are there advantages or disadvantages to the file extension used for SQLite databases? It seems that SQLite itself does not require a naming convention, but there might be other reasons that a particular extension would be useful or problematic - for...

Play audio file from the assets directory

I have the following code: AssetFileDescriptor afd = getAssets().openFd("AudioFile.mp3"); player = new MediaPlayer(); player.setDataSource(afd.getFileDescriptor()); player.prepare(); player.start(); The problem is that, when I run this code, i...

How to force a view refresh without having it trigger automatically from an observable?

Note: this is mostly for debugging and understanding KnockoutJS. Is there a way to explicitly request Knockout to refresh the view from (already bound) view model? I am looking for something like: ko.refreshView(); I understand that this is not ...

How would I get a cron job to run every 30 minutes?

I'm looking to add a crontab entry to execute a script every 30 minutes, on the hour and 30 minutes past the hour or something close. I have the following, but it doesn't seem to run on 0. */30 * * * * What string do I need to use? The cron is ru...

The APR based Apache Tomcat Native library was not found on the java.library.path

I'm newly at server development and have been started from easy tutorial by Lars Vogel. Servlet and JSP development with Eclipse WTP . Step by step accord this tutorial: installed Eclipse Java EE Kepler; installed tomcat 7 on Ubuntu 12.04 - htt...

font-weight is not working properly?

http://www.i3physics.com/blog/2010/07/dsfsdf/ Here is an example. The part where it said "PHP" (the right top corner) remained as slim as it was. here is part of the css code .wp_syntax_lang { background-color:#3c3c3c; position:absolute; ri...

Use dynamic variable names in JavaScript

In PHP you can do amazing/horrendous things like this: $a = 1; $b = 2; $c = 3; $name = 'a'; echo $$name; // prints 1 Is there any way of doing something like this with Javascript? E.g. if I have a var name = 'the name of the variable'; can I get ...

SSIS Convert Between Unicode and Non-Unicode Error

I have an ssis package where I am using an OLEDB source linking to SQL Server 2005 table. All columns except a date column are NVARCHAR(255). I am using an Excel destination and using a SQL statement to create the sheet in the Excel workbook, the SQL...

How can you program if you're blind?

Sight is one of the senses most programmers take for granted. Most programmers would spend hours looking at a computer monitor (especially during times when they are in the zone), but I know there are blind programmers (such as T.V. Raman who current...

How do I prevent the padding property from changing width or height in CSS?

I am creating a site with DIVs. Everything's working out except when I create a DIV. I create them like this (example): newdiv { width: 200px; height: 60px; padding-left: 20px; text-align: left; } When I add the padding-left proper...

ObjectiveC Parse Integer from String

I'm trying to extract a string (which contains an integer) from an array and then use it as an int in a function. I'm trying to convert it to a int using intValue. Here's the code I've been trying. NSArray *_returnedArguments = [serverOutput comp...

Difference between declaring variables before or in loop?

I have always wondered if, in general, declaring a throw-away variable before a loop, as opposed to repeatedly inside the loop, makes any (performance) difference? A (quite pointless) example in Java: a) declaration before loop: double intermediat...

Is null check needed before calling instanceof?

Will null instanceof SomeClass return false or throw a NullPointerException?...

row-level trigger vs statement-level trigger

I am having a hard time understanding the difference between 'row-level triggers' and 'statement-level triggers'. From my understanding, in the scenario a statement level trigger is created, the whole table can be modified. A row level trigger would ...

Convert list to tuple in Python

I'm trying to convert a list to a tuple. Most solutions on Google offer the following code: l = [4,5,6] tuple(l) However, the code results in an error message when I run it: TypeError: 'tuple' object is not callable How can I fix this problem?...

Open a URL in a new tab (and not a new window)

I'm trying to open a URL in a new tab, as opposed to a popup window. I've seen related questions where the responses would look something like: window.open(url,'_blank'); window.open(url); But none of them worked for me, the browser still tried t...

Text was truncated or one or more characters had no match in the target code page including the primary key in an unpivot

I'm trying to import a flat file into an oledb target sql server database. here's the field that's giving me trouble: here are the properties of that flat file connection, specifically the field: here's the error message: [Source - 1894297...

Asynchronous method call in Python?

I was wondering if there's any library for asynchronous method calls in Python. It would be great if you could do something like @async def longComputation(): <code> token = longComputation() token.registerCallback(callback_function) # a...

C# Parsing JSON array of objects

I have an array of objects like this in json format: {"results":[{"SwiftCode":"","City":"","BankName":"Deutsche Bank","Bankkey":"10020030","Bankcountry":"DE"},{"SwiftCode":"","City":"10891 Berlin","BankName":"Commerzbank Berlin (West)","Bankkey":"10...

Iteration ng-repeat only X times in AngularJs

How can I use ng-repeat like for in Javascript? example: <div ng-repeat="4">Text</div> I want to iterate with ng-repeat 4 times but how can I do it?...

'DataFrame' object has no attribute 'sort'

I face some problem here, in my python package I have install numpy, but I still have this error 'DataFrame' object has no attribute 'sort' Anyone can give me some idea.. This is my code : final.loc[-1] =['', 'P','Actual'] final.index = final.inde...

How can I keep my branch up to date with master with git?

I have a bug fix in my master, and I also want my branch to get that bug fix. What git command do I use?...

Simple excel find and replace for formulas

I have numerous cells all over the place on a worksheet that look like =((E9-E8)/E8). I want to use the first two values to go into this new formula, (EXP((LN(E9/E8)/14.32))-1). How can I change them all to the new formula in one fell swoop?...

Method to get all files within folder and subfolders that will return a list

I have a method that will iterate through a folder and all of its subfolders and get a list of the file paths. However, I could only figure out how to create it and add the files to a public List, but not how to return the list. Here's the method: p...

Access PHP variable in JavaScript

Possible Duplicate: How to access PHP variables in JavaScript or jQuery rather than <?php echo $variable ?> Is there any way to get access to a PHP variable in JavaScript? I have a variable, $a, in PHP and want to get its value in a...

How to know which version of Symfony I have?

I know that I have downloaded a Symfony2 project and started with but I have updated my vendor several times and I want to know which version of symfony I have Any idea ?...

Determining if a number is prime

I have perused a lot of code on this topic, but most of them produce the numbers that are prime all the way up to the input number. However, I need code which only checks whether the given input number is prime. Here is what I was able to write, bu...

How to return part of string before a certain character?

If you look at the jsfiddle from question, var str = "Abc: Lorem ipsum sit amet"; str = str.substring(str.indexOf(":") + 1); This returns all characters after the :, how can I adjust this to return all the characters before the : something like v...

How can I get argv[] as int?

i have a piece of code like this: int main (int argc, char *argv[]) { printf("%d\t",(int)argv[1]); printf("%s\t",(int)argv[1]); } and in shell i do this: ./test 7 but the first printf result is not 7, how can I get argv[] as a int? many ...

How to declare std::unique_ptr and what is the use of it?

I try to understand how std::unique_ptr works and for that I found this document. The author starts from the following example: #include <utility> //declarations of unique_ptr using std::unique_ptr; // default construction unique_ptr<int>...

Why would a JavaScript variable start with a dollar sign?

I quite often see JavaScript with variables that start with a dollar sign. When/why would you choose to prefix a variable in this way? (I'm not asking about $('p.foo') syntax that you see in jQuery and others, but normal variables like $name and $or...

SQL Server find and replace specific word in all rows of specific column

I have a table TblKit that has columns Id and Number. Id is primary key of type int and Number is varchar(50). The data in the table looks like this: Id Number --- ------ 1 KIT001 2 KIT002 3 DMB001 4 DM002 5 KIT003 I...

Temporary table in SQL server causing ' There is already an object named' error

I have the following issue in SQL Server, I have some code that looks like this: DROP TABLE #TMPGUARDIAN CREATE TABLE #TMPGUARDIAN( LAST_NAME NVARCHAR(30), FRST_NAME NVARCHAR(30)) SELECT LAST_NAME,FRST_NAME INTO #TMPGUARDIAN FROM TBL_PEOPLE Wh...

How to plot a function curve in R

What are the alternatives for drawing a simple curve for a function like eq = function(x){x*x} in R? It sounds such an obvious question, but I could only find these related questions on stackoverflow, but they are all more specific Plot line fu...

How to update a menu item shown in the ActionBar?

I have an Activity that has 2 fragments. Both are ListFragments and both contribute MenuItems to the Menu. I have one MenuItem that I've set the attribute android:showAsAction to have it show as a button on the ActionBar. Which works fine. Now th...

How to pass an array to a function in VBA?

I am trying to write a function that accepts an array as an argument. The array can have any number of elements. Function processArr(Arr() As Variant) As String Dim N As Variant dim finalStr as string For N = LBound(Arr) To UBoun...

ArrayList of String Arrays

I would like to do something like this: private ArrayList<String[]> addresses = new ArrayList<String[3]>(); This does not seem to work. Whats the easiest way of storing multiple addresses with 3 fields per address in an array without c...

Make an image responsive - the simplest way

I notice that my code is responsive, in the fact that if I scale it down to the size of a phone or tablet - all of the text, links, and social icons scale accordingly. However, the ONLY thing that doesn't is my image in the body; which is wrapped in...

How To Define a JPA Repository Query with a Join

I would like to make a Join query using Jpa repository with annotation @Query. I have two tables: table user with iduser,user_name and: table area with idarea, area_name and iduser The native query is: SELECT u.user_name FROM us...

How to handle command-line arguments in PowerShell

What is the "best" way to handle command-line arguments? It seems like there are several answers on what the "best" way is and as a result I am stuck on how to handle something as simple as: script.ps1 /n name /d domain AND script.ps1 /d domain ...

Detecting real time window size changes in Angular 4

I have been trying to build a responsive nav-bar and do not wish to use a media query, so I intend to use *ngIF with the window size as a criterion. But I have been facing a problem as I am unable to find any method or documentation on Angular 4 wind...

On a CSS hover event, can I change another div's styling?

When I hover over a div or class with an id of "a", can I get the background color of a div or class with the id of "b" to change? ...

cannot find zip-align when publishing app

cannot.find.zip.align=The zipalign tool was not found in the SDK. Please update to the latest SDK and re-export your application or run zipalign manually. Aligning applications allows Android to use application resources more efficiently. This is...

Understanding ibeacon distancing

Trying to grasp a basic concept of how distancing with ibeacon (beacon/ Bluetooth-lowenergy/BLE) can work. Is there any true documentation on how far exactly an ibeacon can measure. Lets say I am 300 feet away...is it possible for an ibeacon to detec...

How can I determine the sector size in windows?

How can I determine the Physical Sector Size (e.g. if i have an Advanced Format drive with 4,096 byte sectors rather than the legacy 512 byte sectors) in Windows 7? I know that by clicking on a file and get properties we can find out the NTFS Cluste...

Read and write a String from text file

I need to read and write data to/from a text file, but I haven't been able to figure out how. I found this sample code in the Swift's iBook, but I still don't know how to write or read data. import Cocoa class DataImporter { /* DataImporte...

Changing button text onclick

When I click on myButton1 button, I want the value to change to Close Curtain from Open Curtain.HTML: <input onclick="change()" type="button" value="Open Curtain" id="myButton1"></input> Javascript: function change(); { document.g...

How to split a python string on new line characters

In python3 in Win7 I read a web page into a string. I then want to split the string into a list at newline characters. I can't enter the newline into my code as the argument in split(), because I get a syntax error 'EOL while scanning string litera...

displayname attribute vs display attribute

What is difference between DisplayName attribute and Display attribute in ASP.NET MVC?...

Extracting hours from a DateTime (SQL Server 2005)

I can extract the month and day by using Day(Date()), Month(Date()). I can't extract hours, with HOUR(Date()). I get the following error. 'HOUR' is not a recognized built-in function name. How can I extract hours?...

Injecting Mockito mocks into a Spring bean

I would like to inject a Mockito mock object into a Spring (3+) bean for the purposes of unit testing with JUnit. My bean dependencies are currently injected by using the @Autowired annotation on private member fields. I have considered using Reflec...

Visual Studio Code Search and Replace with Regular Expressions

I want to use "Search And Replace" in Visual Studio Code to change every instance of <h1>content</h1> to #### content within a document using a Regular Expression. How can I accomplish that?...

Should I use string.isEmpty() or "".equals(string)?

I'm usually testing this alongside a string == null, so I'm not really concerned about a null-safe test. Which should I use? String s = /* whatever */; ... if (s == null || "".equals(s)) { // handle some edge case here } or if (s == nu...

How to select first parent DIV using jQuery?

var classes = $(this).attr('class').split(' '); // this gets the current element classes var classes = $(this).parent().attr('class').split(' '); // this gets the parent classes. The parent in the above situation is an ankor. If I wanted to get t...

Getting an odd error, SQL Server query using `WITH` clause

The following query: WITH CteProductLookup(ProductId, oid) AS ( SELECT p.ProductID, p.oid FROM [dbo].[ME_CatalogProducts] p ) SELECT rel.Name as RelationshipName, pl.ProductId as FromProductId, pl2.P...

process.start() arguments

when i do the following command into dos it will work fine ffmpeg -f image2 -i frame%d.jpg -vcodec mpeg4 -b 800k video.avi When I try to use the process class in c#, without the arguments, it loads ffmpeg in a console window then dissapears like u...

How to remove origin from git repository

Basic question: How do I disassociate a git repo from the origin from which it was cloned? git branch -a shows: * master remotes/origin/HEAD -> origin/master and I want to remove all knowledge of origin, and the associated revisions. Longer...

Virtual Memory Usage from Java under Linux, too much memory used

I have a problem with a Java application running under Linux. When I launch the application, using the default maximum heap size (64 MB), I see using the tops application that 240 MB of virtual Memory are allocated to the application. This creates ...

How can I convert a std::string to int?

Just have a quick question. I've looked around the internet quite a bit and I've found a few solutions but none of them have worked yet. Looking at converting a string to an int and I don't mean ASCII codes. For a quick run-down, we are passed in a...

Pure Javascript listen to input value change

Is there any way I can create a constant function that listens to an input, so when that input value changes, something is triggered immediately? I am looking for something using pure javascript, no plugins, no frameworks and I can't edit the HTML. ...

adding css class to multiple elements

I have created a CSS class called 'button' and applied it to all of my INPUT tags by simply using : .button input { //css stuff here } <p class="button"> <input type="submit" Name='submit' value="Confirm Selection"/> </p> which ...

Static Block in Java

I was looking over some code the other day and I came across: static { ... } Coming from C++, I had no idea why that was there. Its not an error because the code compiled fine. What is this "static" block of code?...

How to implement swipe gestures for mobile devices?

I have an application made in AngularJS which has arrow key navigation to switch views. I want to implement this navigation using swipe for touch devices. I tried jGestures library but it doesn't go well with swipe. I have been recommended NOT to us...

ERROR:'keytool' is not recognized as an internal or external command, operable program or batch file

When i use the command C:\>keytool -list -alias androiddebugkey -keystore .android\debug.keystore -storepass android -keypass android I get this error: 'keytool' is not recognized as an internal or external comman...

How to alter a column and change the default value?

I got the following error while trying to alter a column's data type and setting a new default value: ALTER TABLE foobar_data ALTER COLUMN col VARCHAR(255) NOT NULL SET DEFAULT '{}'; ERROR 1064 (42000): You have an error in your SQL syntax; che...

Windows 10 SSH keys

I am having a really hard time getting my SSH keys up and running after installing Windows 10. Normal method is create it and throw it in the user's account under .ssh. This folder does not appear to be available in Windows 10. Anyone else run int...

MySql Table Insert if not exist otherwise update

UPDATE AggregatedData SET datenum="734152.979166667", Timestamp="2010-01-14 23:30:00.000" WHERE datenum="734152.979166667"; It works if the datenum exists, but I want to insert this data as a new row if the datenum does not exist. UPDATE the d...

multiple where condition codeigniter

How can I convert this query to active record? "UPDATE table_user SET email = '$email', last_ip = '$last_ip' where username = '$username' and status = '$status'"; I tried to convert the query above to: $data = array('email' => $email, 'las...

How to make a copy of a file in android?

In my app I want to save a copy of a certain file with a different name (which I get from user) Do I really need to open the contents of the file and write it to another file? What is the best way to do so?...

Close popup window

I have a popup window which is opened using this code: function _openpageview(fieldid,objectid,opennew) { var url='/s_viewpagefield.jsp?fieldid='+fieldid+'&codedid='+objectid; web_window = window.open(url,'_blank', 'menubar=yes,location=no,sc...

Uploading a file in Rails

I'm new to rails, and I'm writing a RESTful website using the CRUD technique. So far I have created three pages, all of which allow the user to create, edit, and delete a row from the database. However, my fourth page will need to include an upload f...

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

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

Changing the CommandTimeout in SQL Management studio

How can I change the CommandTimeout in SQL Management Studio?...

Colors in JavaScript console

Can Chrome's built-in JavaScript console display colors? I want errors in red, warnings in orange and console.log's in green. Is that possible?...

Pass object to javascript function

I have recently been messing around with jQuery on my website, and I have a fairly limited knowledge of Javascript. I am beginning to like the jQuery ability to pass variables to a jQuery function inside the curly braces, like so: $(somediv).animate...

C linked list inserting node at the end

I'm having some trouble with my insertion method for a linked list in C. It seems to only add at the beginning of the list. Any other insertion I make fail. And this CodeBlocks debugger is so hard to understand I still don't get it. It never gives me...

Can I get all methods of a class?

Suppose that I have a .class file, can I get all the methods included in that class ?...

How to test the type of a thrown exception in Jest

I'm working with some code where I need to test the type of an exception thrown by a function (is it TypeError, ReferenceError, etc.?). My current testing framework is AVA and I can test it as a second argument t.throws method, like here: it('should ...

Using PropertyInfo to find out the property type

I want to dynamically parse an object tree to do some custom validation. The validation is not important as such, but I want to understand the PropertyInfo class better. I will be doing something like this: public bool ValidateData(object data) { ...

Print array without brackets and commas

I'm porting a Hangman game to Android and have met a few problems. The original Java program used the console, so now I have to somehow beautify the output so that it fits my Android layout. How do I print an array without the brackets and commas? T...

Connecting to MySQL from Android with JDBC

I used the following code to connect MySQL in localhost from Android. It only displays the actions given in catch section . I do not know whether it is a connection problem or not. package com.test1; import java.sql.Connection; import java.sql.Dri...

java.time.format.DateTimeParseException: Text could not be parsed at index 21

I get the datetime value as created_at '2012-02-22T02:06:58.147Z' Read-only. The time at which this task was created. Which is given by Asana API I am using Java 8 to parse the date time as following import java.time.*; import java.time.forma...

How to Replace dot (.) in a string in Java

I have a String called persons.name I want to replace the DOT . with /*/ i.e my output will be persons/*/name I tried this code: String a="\\*\\"; str=xpath.replaceAll("\\.", a); I am getting StringIndexOutOfBoundsException. How do I replace t...

How to get the Development/Staging/production Hosting Environment in ConfigureServices

How do I get the Development/Staging/production Hosting Environment in the ConfigureServices method in Startup? public void ConfigureServices(IServiceCollection services) { // Which environment are we running under? } The ConfigureServices met...

Format decimal for percentage values?

What I want is something like this: String.Format("Value: {0:%%}.", 0.8526) Where %% is that format provider or whatever I am looking for. Should result: Value: %85.26.. I basically need it for wpf binding, but first let's solve the general forma...

When maven says "resolution will not be reattempted until the update interval of MyRepo has elapsed", where is that interval specified?

With maven, I occasionally hit an artifact that comes from some 3rd-party repo that I haven't built or included in my repository yet. I'll get an error message from the maven client saying that an artifact can't be found: Failure to find org.jf...

SQL Developer with JDK (64 bit) cannot find JVM

I just wasted one morning trying to get SQL developer to work on my current setup: OS: Windows 8.1 virtual machine running on mac via Parallels. No oracle client or instant client installed No Java installed The reproducible steps are I downloaded...

PHP Warning: PHP Startup: ????????: Unable to initialize module

After upgrading php from 5.1 to 5.2.10, I got the following warnings when php -v: # php -v PHP Warning: PHP Startup: fileinfo: Unable to initialize module Module compiled with module API=20050922, debug=0, thread-safety=0 PHP com...

How can I define fieldset border color?

I want to set border color of field set. I am using class but this is not working properly because i want to remove fieldset default border color. so how can I use fieldset border color. <fieldset class="field_set"> <legend>box</l...

date() method, "A non well formed numeric value encountered" does not want to format a date passed in $_POST

I unfortunately can't use DateTime() as the server this project is on is running PHP v.5.2. the line in question: $aptnDate2 = date('Y-m-d', $_POST['nextAppointmentDate']); throws the following error: Notice: A non well formed numeric value enc...

sorting a List of Map<String, String>

I have a list variable created like this: List<Map<String, String>> list = new ArrayList<Map<String, String>>(); In my Android application, this list gets populated. just an example: Map<String, String> map1 = new H...

check if "it's a number" function in Oracle

I'm trying to check if a value from a column in an oracle (10g) query is a number in order to compare it. Something like: select case when ( is_number(myTable.id) and (myTable.id >0) ) then 'Is a number greater than 0' e...

How to write a unit test for a Spring Boot Controller endpoint

I have a sample Spring Boot app with the following Boot main class @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } Controller ...

Cycles in family tree software

I am the developer of some family tree software (written in C++ and Qt). I had no problems until one of my customers mailed me a bug report. The problem is that the customer has two children with their own daughter, and, as a result, he can't use my ...

How to pass credentials to httpwebrequest for accessing SharePoint Library

I'm trying to read files from a SharePoint document library using HttpWebRequest. In order to do that I have to pass some credentials. I'm using the below request: HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "...

Copy multiple files in Python

How to copy all the files present in one directory to another directory using Python. I have the source path and the destination path as string....

HTML5 Canvas vs. SVG vs. div

What is the best approach for creating elements on the fly and being able to move them around? For example, let's say I want to create a rectangle, circle and polygon and then select those objects and move them around. I understand that HTML5 provid...

Eclipse compilation error: The hierarchy of the type 'Class name' is inconsistent

I have downloaded some open source software written in Java and tried to compile it using Eclipse. I got the error: "The hierarchy of the type 'Class name' is inconsistent" in some files. What causes these errors and how do I fix them?...

Git vs Team Foundation Server

I introduced Git to my dev team, and everyone hates it except me. They want to replace it with Team Foundation Server. I feel like this is a huge step backwards, although I am not very familiar with TFS. Can someone with experience compare branching ...

How to read from stdin line by line in Node

I'm looking to process a text file with node using a command line call like: node app.js < input.txt Each line of the file needs to be processed individually, but once processed the input line can be forgotten. Using the on-data listener of the...

How do Mockito matchers work?

Mockito argument matchers (such as any, argThat, eq, same, and ArgumentCaptor.capture()) behave very differently from Hamcrest matchers. Mockito matchers frequently cause InvalidUseOfMatchersException, even in code that executes long after any matc...

Add a column to a table, if it does not already exist

I want to write a query for MS SQL Server that adds a column into a table. But I don't want any error display, when I run/execute the following query. I am using this sort of query to add a table ... IF EXISTS ( SELECT * FROM sys.ob...

What is the parameter "next" used for in Express?

Suppose you have a simple block of code like this: app.get('/', function(req, res){ res.send('Hello World'); }); This function has two parameters, req and res, which represent the request and response objects respectively. On the other hand, ...

Difference between using bean id and name in Spring configuration file

Is there any difference between using an id attribute and name attribute on a <bean> element in a Spring configuration file?...

URL to compose a message in Gmail (with full Gmail interface and specified to, bcc, subject, etc.)

I found a post that provides an example for a link which opens just a compose message window. However, I would like it to open a window with the full Gmail interface but ready to compose a new message. Of course this works: https://mail.google.com/...

Select unique values with 'select' function in 'dplyr' library

Is it possible to select all unique values from a column of a data.frame using select function in dplyr library? Something like "SELECT DISTINCT field1 FROM table1" in SQL notation. Thanks!...

How to perform OR condition in django queryset?

I want to write a Django query equivalent to this SQL query: SELECT * from user where income >= 5000 or income is NULL. How to construct the Django queryset filter? User.objects.filter(income__gte=5000, income=0) This doesn't work, because i...

What does Java option -Xmx stand for?

java -Xmx1024m filename what does -Xmx mean?...

How do I properly 'printf' an integer and a string in C?

I have the following code: char *s1, *s2; char str[10]; printf("Type a string: "); scanf("%s", str); s1 = &str[0]; s2 = &str[2]; printf("%s\n", s1); printf("%s\n", s2); When I run the code, and enter the input "A 1" as follow: Type a s...

Eclipse: How to build an executable jar with external jar?

I am trying to build an executable jar program which depends on external jar downloaded. In my project, I included them in the build path and can be run and debug within eclipse. When I tried to export it to a jar, I can run the program but I can't ...

Removing the password from a VBA project

How can I programmatically remove a (known) password from an Excel VBA project? To be clear: I want to remove the password from the VBA Project, not the workbook or any worksheets....

Div vertical scrollbar show

I am wondering how its possible to permanently show the vertical bar of a div (greyed out if there is no scrolling) similar to our regular bars. Basically I am trying to place an entire website in a div (like gmail/facebook), so if the page is not lo...

How do I raise the same Exception with a custom message in Python?

I have this try block in my code: try: do_something_that_might_raise_an_exception() except ValueError as err: errmsg = 'My custom error message.' raise ValueError(errmsg) Strictly speaking, I am actually raising another ValueError, not...

how to set font size based on container size?

I have a container that has a % width and height, so it scales depending on external factors. I would like the font inside the container to be a constant size relative to the size of containers. Is there any good way to do this using CSS? The font-si...

How create table only using <div> tag and Css

I want to create table only using <div> tag and CSS. This is my sample table. <body> <form id="form1"> <div class="divTable"> <div class="headRow"> <div class="divCell" align="ce...

How to update specific key's value in an associative array in PHP?

I've a following associative array named $data Array ( [0] => Array ( [transaction_user_id] => 359691e27b23f8ef3f8e1c50315cd506 [transaction_no] => 19500912050218 [transaction_total_amount] =&...

How to redirect verbose garbage collection output to a file?

How do I redirect verbose garbage collection output to a file? Sun’s website shows an example for Unix but it doesn't work for Windows....

Inserting an image with PHP and FPDF

I'm trying to insert an image but do not want to specify the x and y coordinates. Is that possible? $pdf->Image($image1, 5, 70, 33.78); I want to be able to specify the size (33.78) but not the x and y so that it moves based on the content. $p...

is there any way to force copy? copy without overwrite prompt, using windows?

I want to write a list of windows commands(it's a long list) where it does all these magical things for me, but whenever I use copy, it stops to ask fro overwrite prompt. When I type yes, it overwrites the old file then just stops there. How do I ma...

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

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

Where does Java's String constant pool live, the heap or the stack?

I know the concept of a constants pool and the String constant pool used by JVMs to handle String literals. But I don't know which type of memory is used by the JVM to store String constant literals. The stack or the heap? Since its a literal which i...

Are these methods thread safe?

i have the following static class with generic methods and i'm wondering if it's safe to use it from different threads and with different objects? i'm not sure how this works below the covers so an explanation of would help public static class Seria...

How are VST Plugins made?

I would like to make (or learn how to make) VST plugins. Is there a special SDK for this? how does one yield a .vst instead of a .exe? Also, if one is looking to make Audio Units for Logic Pro, how is that done? Thanks...

Download file from web in Python 3

I am creating a program that will download a .jar (java) file from a web server, by reading the URL that is specified in the .jad file of the same game/application. I'm using Python 3.2.1 I've managed to extract the URL of the JAR file from the JAD ...

Open images? Python

Im creating a text based labryinth game, but I figured it needed some pictures to illustrate whats going on. For some reason it just dies when I try to go to a2(Where the picture should pop up). I am a beginner so dont judge my code so much ^^ impor...

How to stop mysqld

To find out the start command for mysqld (using a mac) I can do: ps aux|grep mysql I get the following output, which allows me to start mysql server. /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=... How would I find the nece...

How do I change the JAVA_HOME for ant?

I'm doing java work on a class server where I don't have root. Whenever I try to compile using ant, it points to the wrong directory (/usr/tomcat instead of /usr/tomcat/jre ). One of the things we were told to do when setting up our user accounts w...

Java Inheritance - calling superclass method

Lets suppose I have the following two classes public class alpha { public alpha(){ //some logic } public void alphaMethod1(){ //some logic } } public class beta extends alpha { public beta(){ //some lo...

How to configure a HTTP proxy for svn

I want to check code from the repository http://code.sixapart.com/svn/perlbal/ . I can only access the the repository url by setting a proxy. I guess if I want to get the code from the same URL by svn I need to configure a proxy, too. So does anyone ...

Reading text files using read.table

I have a text file with an id and name column, and I'm trying to read it into a data frame in R: d = read.table("foobar.txt", sep="\t") But for some reason, a lot of lines get merged -- e.g., in row 500 of my data frame, I'll see something like r...

Bootstrap-select - how to fire event on change

I'm using Bootstrap 3.0.2 and the Bootstrap-select plugin. Here's my select list: <select class="selectpicker" data-live-search="true" data-size="7"> <option>Petr Karel</option> <option>Honza Novák</option> <...

How can I see the specific value of the sql_mode?

There are some sql_mode values in MySQL: ANSI, IGNORE_SPACE, STRICT_TRANS_TABLES, etc How can I see the one particular value? The manual says: You can retrieve the current mode by issuing a SELECT @@sql_mode statement. But it just shows...

Creating java date object from year,month,day

int day = Integer.parseInt(request.getParameter("day")); // 25 int month = Integer.parseInt(request.getParameter("month")); // 12 int year = Integer.parseInt(request.getParameter("year")); // 1988 System.out.println(year); Calendar c = Calendar.ge...

Java Replacing multiple different substring in a string at once (or in the most efficient way)

I need to replace many different sub-string in a string in the most efficient way. is there another way other then the brute force way of replacing each field using string.replace ? ...

Npm install cannot find module 'semver'

I can't use npm install using the command prompt in NodeJS. I'm getting these errors when running npm install: module.js:339 throw err; ^ Error: Cannot find module 'semver' at Function.Module._resolveFilename (module.js:337:15) at Fu...

How to write header row with csv.DictWriter?

Assume I have a csv.DictReader object and I want to write it out as a CSV file. How can I do this? I know that I can write the rows of data like this: dr = csv.DictReader(open(f), delimiter='\t') # process my dr object # ... # write out object outp...

Git remote branch deleted, but still it appears in 'branch -a'

Let's say I had a branch named coolbranch in my repository. Now, I decided to delete it (both remotely and locally) with: git push origin :coolbranch git branch -D coolbranch Great! Now the branch is really deleted. But when I run git branch -a...

User GETDATE() to put current date into SQL variable

I'm trying to get the current date into a variable inside a SQL stored procedure using the following commands DECLARE @LastChangeDate as date SET @LastChangeDate = SELECT GETDATE() This gives me the following error: "Incorrect Syntax near 'SELECT'...

C# - Making a Process.Start wait until the process has start-up

I need to make sure that a process is running before moving on with a method. The statement is: Process.Start("popup.exe"); Can you do a WAIT command or set a delay on this value?...

Get Last Part of URL PHP

I'm just wondering how I can extract the last part of a URL using PHP. The example URL is: http://domain.com/artist/song/music-videos/song-title/9393903 Now how can I extract the final part using PHP? 9393903 There is always the same number of...

Using DISTINCT along with GROUP BY in SQL Server

Is there any purpose for using both DISTINCT and GROUP BY in SQL? Below is a sample code SELECT DISTINCT Actors FROM MovieDetails GROUP BY Actors Does anyone know of any situations where both DISTINCT and GROUP BY need to be used, to get any spec...

R plot: size and resolution

I have stacked into the question: I need to plot the image with DPI=1200 and specific print size. By default the png looks ok... png("test.png",width=3.25,height=3.25,units="in",res=1200) par(mar=c(5,5,2,2),xaxs = "i",yaxs = "i",cex.axis=1.3,cex.l...

Angularjs on page load call function

I am learning AngularJS. I have some article tag and on clicking on a button each article page is showed without any page refresh. This is one page website. What I want is that when article id "showSelector" is loaded I want to call myFunction() and ...

What's the best way to generate a UML diagram from Python source code?

A colleague is looking to generate UML class diagrams from heaps of Python source code. He's primarily interested in the inheritance relationships, and mildly interested in compositional relationships, and doesn't care much about class attributes th...

Numpy Resize/Rescale Image

I would like to take an image and change the scale of the image, while it is a numpy array. For example I have this image of a coca-cola bottle: bottle-1 Which translates to a numpy array of shape (528, 203, 3) and I want to resize that to say the ...

SQL query to select dates between two dates

I have a start_date and end_date. I want to get the list of dates in between these two dates. Can anyone help me pointing the mistake in my query. select Date,TotalAllowance from Calculation where EmployeeId=1 and Date between 2011/02/25 and 201...

Casting string to enum

I'm reading file content and take string at exact location like this string fileContentMessage = File.ReadAllText(filename).Substring(411, 3); Output will always be either Ok or Err On the other side I have MyObject which have ContentEnum like t...

How to put a text beside the image?

I'm making a website on Google Sites. I choose the 3 column layout and put the images one by one. I want to put the text beside the image, but it only works with the first line, and even that is in "the end" of the image. The screenshot bel...

How to convert hashmap to JSON object in Java

How to convert or cast hashmap to JSON object in Java, and again convert JSON object to JSON string?...

Reducing the gap between a bullet and text in a list item

How can I reduce default gap between bullet and text in an <li>? Item 1 Item 2 Item 3 I want to reduce gap between the bullet and "I"....

UILabel text margin

I'm looking to set the left inset/margin of a UILabel and can't find a method to do so. The label has a background set so just changing its origin won't do the trick. It would be ideal to inset the text by 10px or so on the left hand side....

How to set timer in android?

Can someone give a simple example of updating a textfield every second or so? I want to make a flying ball and need to calculate/update the ball coordinates every second, that's why I need some sort of a timer. I don't get anything from here....

Why does git revert complain about a missing -m option?

So I'm working on a project with other people, and there's multiple github forks being worked on. Someone just made a fix for a problem and I merged with his fork, but then I realized that I could find a better solution. I want to revert the commit I...

JQuery html() vs. innerHTML

Can I completely rely upon jQuery's html() method behaving identical to innerHTML? Is there any difference between innerHTML and jQuery's html() method? If these methods both do the same, can I use jQuery's html() method in place of innerHTML? My pr...

C++ [Error] no matching function for call to

I can't compile my code because of some errors. Here some of them : In function 'int main(int, char**)': [Error] no matching function for call to 'deckOfCards::shuffle(deckOfCards&)' [Note] candidate is: In file included from main.cpp [Not...

Specify an SSH key for git push for a given domain

I have the following use case: I would like to be able to push to [email protected]:gitolite-admin using the private key of user gitolite-admin, while I want to push to [email protected]:some_repo using 'my own' private key. AFAIK, I can't solve ...

How do I implement interfaces in python?

public interface IInterface { void show(); } public class MyClass : IInterface { #region IInterface Members public void show() { Console.WriteLine("Hello World!"); } #endregion } How do I implement Python equiva...

How can I do string interpolation in JavaScript?

Consider this code: var age = 3; console.log("I'm " + age + " years old!"); Are there any other ways to insert the value of a variable in to a string, apart from string concatenation?...

Display the binary representation of a number in C?

Possible Duplicate: Is there a printf converter to print in binary format? Still learning C and I was wondering: Given a number, is it possible to do something like the following? char a = 5; printf("binary representation of a = %b",a);...

Identifying country by IP address

Is there a way to figure out the country name just by looking at an IP address? I mean, do countries have specific ranges of IP addresses? For example, Australia can have IP addresses only in the range of 123.45.56.89 - 231.54.65.98 (just an example)...

Delete all items from a c++ std::vector

I'm trying to delete everything from a std::vector by using the following code vector.erase( vector.begin(), vector.end() ); but it doesn't work. Update: Doesn't clear destruct the elements held by the vector? I don't want that, as I'm still us...

CSS @font-face not working with Firefox, but working with Chrome and IE

The following code works in Google Chrome beta as well as IE 7. However, Firefox seems to have a problem with this. I'm suspecting it to be a problem of how my CSS files are included, cause I know Firefox is not too friendly about cross-domain import...

How to sort an array of integers correctly

Trying to get the highest and lowest value from an array that I know will contain only integers seems to be harder than I thought. _x000D_ _x000D_ var numArray = [140000, 104, 99]; numArray = numArray.sort(); console.log(numArray)_x000D_ _x000D_ _x00...

How to write to file in Ruby?

I need to read the data out of database and then save it in a text file. How can I do that in Ruby? Is there any file management system in Ruby?...

Convert string to binary then back again using PHP

Is there a way to convert a string to binary then back again in the standard PHP library? To clarify what I'm trying to do is store a password on a database. I'm going to convert it first using a hash function then eventually store it as binary. ...

Can Google Chrome open local links?

I am linking on an intranet page to a local file on a shared drive: <a href="file:///s:/test.xls"> Test</a> This works in IE and Firefox with an addon called local link. How can I get this to open in Google Chrome?...

Toggle show/hide on click with jQuery

I got a div element, so when I click on it, another div which is hidden by default is sliding and showing, here is the code for the animation itself: $('#myelement').click(function(){ $('#another-element').show("slide", { direction: "right" }, ...

Call a Class From another class

I want to call class2 from class1 but class2 doesn't have a main function to refer to like Class2.main(args); ...

How can I use JavaScript in Java?

I wanted to build a small product in which I wanted to give a kind of feature in which user can write a script language kind of JavaScript. And also from JavaScript able to build objects and calling methods on them. Is there any framework for this?...

How to repeat a char using printf?

I'd like to do something like printf("?", count, char) to repeat a character count times. What is the right format-string to accomplish this? EDIT: Yes, it is obvious that I could call printf() in a loop, but that is just what I wanted to avoid....

Git - remote: Repository not found

I have SourceTree with local working copy. And all operations work good, I can simple fetch, push, pull and etc via SourceTree. I just needed to make force push which does not exist in SourceTree. I opened terminal made git push -f remote: Reposito...

How do I size a UITextView to its content?

Is there a good way to adjust the size of a UITextView to conform to its content? Say for instance I have a UITextView that contains one line of text: "Hello world" I then add another line of text: "Goodbye world" Is there a good way in Cocoa T...

How to escape single quotes in MySQL

How do I insert a value in MySQL that consist of single or double quotes. i.e This is Ashok's Pen. The single quote will create problems. There might be other escape characters. How do you insert the data properly?...

How to set proper codeigniter base url?

when I had my site on development environment - it was url: testurl.com Now on production server my codeigniter app's address has to be someurl.com/mysite/ I moved it there, and everytime I'm trying to run some function, example /home/test - it get...

How to give a Blob uploaded as FormData a file name?

I am currently uploading images pasted from the clipboard with the following code: // Turns out getAsFile will return a blob, not a file var blob = event.clipboardData.items[0].getAsFile(), form = new FormData(), request = new XMLHttpReques...

Image size (Python, OpenCV)

I would like to get the Image size in python,as I do it with c++. int w = src->width; printf("%d", 'w'); ...

How to set session attribute in java?

I am able to set session attribute in scriptlet but when I am trying to set session attribute inside java class it shows error like "session cannot be resolved". So how to set session in java? <%String username = (String)request.getAttribute("un...

How to remove unique key from mysql table

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

printf and long double

I am using the latest gcc with Netbeans on Windows. Why doesn't long double work? Is the printf specifier %lf wrong? Code: #include <stdio.h> int main(void) { float aboat = 32000.0; double abet = 5.32e-5; long double dip = 5.32e-...

How to change status bar color in Flutter?

I am trying to change the status bar color to white. I found this pub on flutter. I tried to use the example code on my dart files....

Convert a list of characters into a string

If I have a list of chars: a = ['a','b','c','d'] How do I convert it into a single string? a = 'abcd' ...

How to print Two-Dimensional Array like table

I'm having a problem with two dimensional array. I'm having a display like this: 1 2 3 4 5 6 7 9 10 11 12 13 14 15 16 . . . etc What basically I want is to display to display it as: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ...

How to set the id attribute of a HTML element dynamically with angularjs (1.x)?

Provided an HTML element of type div, how to set the value of its id attribute, which is the concatenation of a scope variable and a string ? ...

How to upload files in asp.net core?

How to upload files or images using Asp.net MVC 6 with some model data? Example, I have a form like this; <form> <input type="file"> <input type="text" placeholder="Image name..."> <input type="text" placeholder="Ima...

How to replace values at specific indexes of a python list?

If I have a list: to_modify = [5,4,3,2,1,0] And then declare two other lists: indexes = [0,1,3,5] replacements = [0,0,0,0] How can I take to_modify's elements as index to indexes, then set corresponding elements in to_modify to replacements, i...

Angular - Can't make ng-repeat orderBy work

I've tried many examples of ng-repeat with orderBy, but I can't make my json work with it. <div ng-app> <script type="text/javascript" src="http://code.angularjs.org/1.0.1/angular-1.0.1.js"></script> <div ng:controller="...

Parse JSON file using GSON

I want to parse this JSON file in JAVA using GSON : { "descriptor" : { "app1" : { "name" : "mehdi", "age" : 21, "messages": ["msg 1","msg 2","msg 3"] }, "app2" : { "name" :...

How do I get the picture size with PIL?

How do I get a size of a pictures sides with PIL or any other Python library?...

Save child objects automatically using JPA Hibernate

I have a one-to-many relation between Parent and Child table. In the parent object I have a List<Child> setChildren(List<Child> childs) I also have a foreign key in the Child table. This foreign key is an ID that references a Parent ...

possibly undefined macro: AC_MSG_ERROR

I have the following in configure.ac: AC_CHECK_PROGS(MAKE,$MAKE make gmake,error) if test "x$MAKE" = "xerror" ;then AC_MSG_ERROR([cannot find a make command]) fi This has been in our project for a long time, but in some set ups, I get this error...

PHP - Check if two arrays are equal

I'd like to check if two arrays are equal. I mean: same size, same index, same values. How can I do that? Using !== as suggested by a user, I expect that the following would print enter if at least one element in the array(s) are different, but in f...

How can I disable notices and warnings in PHP within the .htaccess file?

I just want to only turn on PHP errors and disable all notices and warnings in PHP files....

Does Ruby have a string.startswith("abc") built in method?

Does Ruby have a some_string.starts_with("abc") method that's built in?...

Undefined variable: $_SESSION

I'm getting E_NOTICE errors in a core CakePHP file when it tries to reference a never-set or unset session (cake/libs/cake_session.php line 372): function read($name = null) { if (is_null($name)) { return $this->__returnSessionVars();...

How to pass command line arguments to a rake task

I have a rake task that needs to insert a value into multiple databases. I'd like to pass this value into the rake task from the command line, or from another rake task. How can I do this?...

How can I run a PHP script in the background after a form is submitted?

Problem I have a form that, when submitted, will run basic code to process the information submitted and insert it into a database for display on a notification website. In addition, I have a list of people who have signed up to receive these notific...

Selecting only first-level elements in jquery

How can I select the link elements of only the parent <ul> from a list like this? <ul> <li><a href="#">Link</a></li> <li><a href="#">Link</a> <ul> <li><a href="#">Link<...

Skip first entry in for loop in python?

In python, How do I do something like: for car in cars: # Skip first and last, do work for rest ...

How can I set my Cygwin PATH to find javac?

I have a Windows 7 system on which I have installed the latest Java compiler. I also have the latest Cygwin. I want to use the Java compiler from Cygwin's shell. I edited the PATH variable in Cygwin as follows: export PATH=$PATH:"/cygdrive/C/Program...

Filtering a list of strings based on contents

Given the list ['a','ab','abc','bac'], I want to compute a list with strings that have 'ab' in them. I.e. the result is ['ab','abc']. How can this be done in Python?...

Stacked Tabs in Bootstrap 3

I am trying to implement left-aligned stacked tabs using the Tab jquery plugin in Bootstrap 3 where tabs are rendered vertically to the left of tab content, rather than on top. When I try the following; <ul class="nav nav-tabs nav-stacked">...

Python pandas: fill a dataframe row by row

The simple task of adding a row to a pandas.DataFrame object seems to be hard to accomplish. There are 3 stackoverflow questions relating to this, none of which give a working answer. Here is what I'm trying to do. I have a DataFrame of which I alre...

Import numpy on pycharm

I'm trying to import numpy on Pycharm. Using the Pycharm terminal and Miniconda I've launched the command: conda install numpy And this was the output Fetching package metadata: .... Solving package specifications: .................... # All req...

Connecting postgresql with sqlalchemy

I know this might be really a simple question but I don't know the solution. What is happening here when I try to connect to postgresql? I am self learner in this field of database and programming so please be gentle with me. When I try following cod...

Handle spring security authentication exceptions with @ExceptionHandler

I'm using Spring MVC's @ControllerAdvice and @ExceptionHandler to handle all the exception of a REST Api. It works fine for exceptions thrown by web mvc controllers but it does not work for exceptions thrown by spring security custom filters because ...

Insert multiple lines into a file after specified pattern using shell script

I want to insert multiple lines into a file using shell script. Let us consider my input file contents are: input.txt: abcd accd cdef line web Now I have to insert four lines after the line 'cdef' in the input.txt file. After inserting my file sho...

Extract the first (or last) n characters of a string

I want to extract the first (or last) n characters of a string. This would be the equivalent to Excel's LEFT() and RIGHT(). A small example: # create a string a <- paste('left', 'right', sep = '') a # [1] "leftright" I would like to produce b, ...

Using Django time/date widgets in custom form

How can I use the nifty JavaScript date and time widgets that the default admin uses with my custom view? I have looked through the Django forms documentation, and it briefly mentions django.contrib.admin.widgets, but I don't know how to use it? He...

Create thumbnail image

I want to display thumbnail image in a gridview from file location. How to generate that of .jpeg file? I am using C# language with asp.net....

Using Google maps API v3 how do I get LatLng with a given address?

If a user inputs an address, I want to convert to the equivalent LatLng. I've read the documentation, and I think I can use the Geocoder class to do this, but can't figure out how to implement it. Thanks for any help!...

how to add super privileges to mysql database?

I am trying to execute query in mysql. SET GLOBAL log_bin_trust_function_creators =1; Error: SQL query: SET GLOBAL log_bin_trust_function_creators =1 MySQL said: #1227 - Access denied; you need the SUPER privilege for this operation I want to kno...

Find and replace entire mysql database

i would like to do a find and replace inside an entire database not just a table. How can i alter the script below to work? update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]'); Do i just use an a...

How do I ignore files in Subversion?

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

What does from __future__ import absolute_import actually do?

I have answered a question regarding absolute imports in Python, which I thought I understood based on reading the Python 2.5 changelog and accompanying PEP. However, upon installing Python 2.5 and attempting to craft an example of properly using fro...

How to Copy Text to Clip Board in Android?

Can anybody please tell me how to copy the text present in a particular textview to clipboard when a button is pressed? @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setCon...

What is the syntax for Typescript arrow functions with generics?

The typescript handbook currently has nothing on arrow functions. Normal functions can be generically typed with this syntax: example: function identity<T>(arg: T): T { return arg; } What is the syntax for arrow functions? ...

How to display the value of the bar on each bar with pyplot.barh()?

I generated a bar plot, how can I display the value of the bar on each bar? Current plot: What I am trying to get: My code: import os import numpy as np import matplotlib.pyplot as plt x = [u'INFO', u'CUISINE', u'TYPE_OF_PLACE', u'DRINK', u'...

How to overlay one div over another div

I need assistance with overlaying one individual div over another individual div. My code looks like this: <div class="navi"></div> <div id="infoi"> <img src="info_icon2.png" height="20" width="32"/> </div> Unfor...

SQL Server Linked Server Example Query

While in Management Studio, I am trying to run a query/do a join between two linked servers. Is this a correct syntax using linked db servers: select foo.id from databaseserver1.db1.table1 foo, databaseserver2.db1.table1 bar where foo.name=b...

How do you declare string constants in C?

I know it's quite idiomatic, or good style at least, in C to declare numeric constants as enums instead of #defineing them. /* bad style */ #define MAXLINE 1024 /* good/better style */ enum { MAX_LINE = 1024 }; Is there an equivalent rule for...

How to set image in circle in swift

How can i make i circle picture with swift ? My ViewController : import UIKit import Foundation class FriendsViewController : UIViewController{ @IBOutlet weak var profilPicture: UIImageView! override func viewDidLoad() { super.vi...

How do I crop an image in Java?

I want to crop an image manually using the mouse. Suppose the image has some text, and I want to select some text from an image, then for that purpose I want to crop that area by using the mouse. ...

Postgresql: error "must be owner of relation" when changing a owner object

What is the grant option/trick I need to give to the current user ("userA") to allow him to change a object's owner which belongs by another user ("userC")? More precisely, the contact table is owned by the userC and when I perform the following que...

In Python, how do I create a string of n characters in one line of code?

I need to generate a string with n characters in Python. Is there a one line answer to achieve this with the existing Python library? For instance, I need a string of 10 letters: string_val = 'abcdefghij' ...

Regex pattern for numeric values

I need an regular expression pattern to only accept positive whole numbers. It can also accept a single zero. I do not want to accept decimals, negative number and numbers with leading zeros. Any suggestions?...

Angular - "has no exported member 'Observable'"

Typescript code: import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { of } from 'rxjs/observable/of'; import { Hero } from './hero'; import { HEROES } from './mock-heroes'; @Injectable({ providedI...

Is module __file__ attribute absolute or relative?

I'm having trouble understanding __file__. From what I understand, __file__ returns the absolute path from which the module was loaded. I'm having problem producing this: I have a abc.py with one statement print __file__, running from /d/projects/ ...

How to display Toast in Android?

I have a slider that can be pulled up and then it shows a map. I can move the slider up and down to hide or show the map. When the map is on front, I can handle touch events on that map. Everytime I touch, a AsyncTask is fired up, it downloads some d...

blur vs focusout -- any real differences?

Is there any difference between JS events blur vs focusout? I have two textboxes: pwd and confirm pwd. I want to check password match when user tabs out of the confirm pwd textbox, for example. In this case which event should I use or does it matter...

How do I output coloured text to a Linux terminal?

How do I print coloured characters to a Linux terminal that supports it? How do I tell whether the terminal supports colour codes?...

How to Apply Gradient to background view of iOS Swift App

I'm trying to apply a gradient as the background color of a View (main view of a storyboard). The code runs, but nothing changes. I'm using xCode Beta 2 and Swift. Here's the code: class Colors { let colorTop = UIColor(red: 192.0/255.0, green: 38...

"call to undefined function" error when calling class method

this is the error Fatal error: Call to undefined function assign( this is the code, as you can see i obviously have defined the function so why is it not working class shades { function create($name, $shades, $slug, $shortDesc, $longDesc, $posit...

What is the best comment in source code you have ever encountered?

What is the best comment in source code you have ever encountered?...

How to install package from github repo in Yarn

When I use npm install fancyapps/fancybox#v2.6.1 --save, so fancybox package at v2.6.1 tag will be installed. This behavior is described in docs I want to ask, how to do this with yarn? Is this command the right alternative? In yarn docs isn't anyt...

SQLSTATE[HY000] [1045] Access denied for user 'username'@'localhost' using CakePHP

I am new to PHP and CakePHP. I am finding problems while wiring my database using CakePHP. Below is my application configuration. I am on Bitnami WAMP stack 5.4.40-0. I am using CakePHP 3.0.4 to create a web MVC application Entry for datasources i...

Rewrite all requests to index.php with nginx

In my apache configuration I have the following simple rewrite rule which unless file exists will rewrite to index.php on the urls you never see the file extension (.php) how can I rewrite this in nginx? # # Redirect all to index.php # RewriteEn...

Understanding PIVOT function in T-SQL

I am very new to SQL. I have a table like this: ID | TeamID | UserID | ElementID | PhaseID | Effort ----------------------------------------------------- 1 | 1 | 1 | 3 | 5 | 6.74 2 | 1 | 1 | 3 | 6 ...

Move UIView up when the keyboard appears in iOS

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

CASE WHEN statement for ORDER BY clause

I am using SQL Server 2008 R2. I want the priority based sorting for records in a table. So that I am using CASE WHEN statement in ORDER BY clause. The ORDER BY clause is as below : ORDER BY CASE WHEN TblList.PinRequestCount <> 0 THEN Tb...

Regular expression to get a string between two strings in Javascript

I have found very similar posts, but I can't quite get my regular expression right here. I am trying to write a regular expression which returns a string which is between two other strings. For example: I want to get the string which resides between...

What does %~dp0 mean, and how does it work?

I find %~dp0 very useful, and I use it a lot to make my batch files more portable. But the label itself seems very cryptic to me... What is the ~ doing? Does dp mean drive and path? Does the 0 refer to %0, the path to the batch file that includes th...

Python: Checking if a 'Dictionary' is empty doesn't seem to work

I am trying to check if a dictionary is empty but it doesn't behave properly. It just skips it and displays ONLINE without anything except of display the message. Any ideas why ? def isEmpty(self, dictionary): for element in dictionary: i...

Android - Get value from HashMap

I have tried to search on HashMap in Android, but getting problem: Consider this example: HashMap<String, String> meMap=new HashMap<String, String>(); meMap.put("Color1","Red"); meMap.put("Color2","Blue"); meMap.put("Color3","Green"); m...

A Windows equivalent of the Unix tail command

I'm looking for the equivalent of the Unix 'tail' command that will allow me to watch the output of a log file while it is being written to....

Aligning a float:left div to center?

I want to have a group of images display horizontally across the page. Each image has a few link below it so I need to put a container around each image/link-group. The closest I have gotten to what I want is putting them in divs that float:left. Th...

UITableView Cell selected Color?

I have created a custom UITableViewCell. The table view is showing data fine. What I am stuck in is when user touches cell of tableview, then I want to show the background color of the cell other than the default [blue color] values for highlighting ...

How to declare a variable in SQL Server and use it in the same Stored Procedure

Im trying to get the value from BrandID in one table and add it to another table. But I can't get it to work. Anybody know how to do it right? CREATE PROCEDURE AddBrand AS DECLARE @BrandName nvarchar(50), @CategoryID int, @BrandID int SELECT @Bra...

How can I represent an infinite number in Python?

How can I represent an infinite number in python? No matter which number you enter in the program, no number should be greater than this representation of infinity....

Insert images to XML file

I would like to insert an images within an element the XML file, what is the best way to do this? Would you please suggest some good way to include an images to xml file?...

How to list files inside a folder with SQL Server

How do I list files inside a folder in SQL Server without using the xp_cmdshell stored procedure?...

What are the advantages and disadvantages of recursion?

With respect to using recursion over non-recursive methods in sorting algorithms or, for that matter, any algorithm what are its pros and cons?...

What is the naming convention in Python for variable and function names?

Coming from a C# background the naming convention for variables and method names are usually either camelCase or PascalCase: // C# example string thisIsMyVariable = "a" public void ThisIsMyMethod() In Python, I have seen the above but I have also ...

Carousel with Thumbnails in Bootstrap 3.0

I need to make Bootstrap 3.0 Carousel to display a slide of thumbnails. How can I do this? This is an image of what I´m looking for: This is a working example for Bootstrap 2, but I need this for Bootstrap 3.0.: Bootstrap Thumbnail Slider...

Full-screen responsive background image

I am very new to Front-end development and Foundation. I am trying to get <div class="main-header"> to be a full screen image that scales down responsively. Can anyone tell me what I am doing wrong? It is scaling properly, but is not showing...

Why does Eclipse automatically add appcompat v7 library support whenever I create a new project?

Why does Eclipse automatically add appcompat v7 library support whenever I create a new project? I am creating a simple project whose MainActivity should extend Activity, but it does not. Eclipse automatically adds action bar support. How do I crea...

How to sum up elements of a C++ vector?

What are the good ways of finding the sum of all the elements in a std::vector? Suppose I have a vector std::vector<int> vector with a few elements in it. Now I want to find the sum of all the elements. What are the different ways for the same...

How to create an email form that can send email using html

I know that are a lot of examples using the mailto: post action to send emails using just html form. But using that will actually, popup the send email dialog box e.g. outlook dialog box and it is actually using our own smtp server to send the email...

Extending an Object in Javascript

I am currently transforming from Java to Javascript, and it's a bit hard for me to figure out how to extend objects the way I want it to do. I've seen several people on the internet use a method called extend on object. The code will look like this:...

Apply vs transform on a group object

Consider the following dataframe: columns = ['A', 'B', 'C', 'D'] records = [ ['foo', 'one', 0.162003, 0.087469], ['bar', 'one', -1.156319, -1.5262719999999999], ['foo', 'two', 0.833892, -1.666304], ['bar', 'three', -2.026673, -0....

How to fix '.' is not an internal or external command error

I have followed few links to try and solve this issue, such as link1 , where they have asked to me include the path of the exe in the environment variables. This is the following command I tried, to get this error D:\Gesture Recognition\Gestu...

Generics in C#, using type of a variable as parameter

I have a generic method bool DoesEntityExist<T>(Guid guid, ITransaction transaction) where T : IGloballyIdentifiable; How do I use the method in the following way: Type t = entity.GetType(); DoesEntityExist<t>(entityGuid, transaction...

How to align center the text in html table row?

I am using an HTML <table> and I want to align the text of <td> to the center in each cell. How do I center align the text horizontally and vertically?...

Node.js check if file exists

How do i check the existence of a file? In the documentation for the module fs there's a description of the method fs.exists(path, callback). But, as I understand, it checks for the existence of only directories. And I need to check the file! How c...

Adding an onclicklistener to listview (android)

I've managed to implement a great listview that I found here http://www.learn-android.com/2011/11/22/lots-of-lists-custom-adapter/comment-page-1/ but I can't seem to add an onclicklistener I just want to be able to do an action when I click on the ro...

The type must be a reference type in order to use it as parameter 'T' in the generic type or method

I'm getting deeper into generics and now have a situation I need help with. I get a compile error on the 'Derived' class below as shown in the subject title. I see many other posts similar to this one but I'm not seeing the relationship. Can someone ...

What is the difference between const int*, const int * const, and int const *?

I always mess up how to use const int*, const int * const, and int const * correctly. Is there a set of rules defining what you can and cannot do? I want to know all the do's and all don'ts in terms of assignments, passing to the functions, etc....

Transmitting newline character "\n"

Given the following URL (working, try it!) https://select-test.wp3.rbsworldpay.com/wcc/purchase?instId=151711&cartId=28524&currency=GBP&amount=1401.49&testMode=100&name=Tom%20Gul&address=24%20House%20Road\nSome Place\nCo...

How to switch between hide and view password

Is there a clever way to let the user switch between hide and view password in an android EditText? A number of PC based apps let the user do this....

How to check if multiple array keys exists

I have a variety of arrays that will either contain story & message or just story How would I check to see if an array contains both story and message? array_key_exists() only looks for that single key in the array. Is there a way to d...

How to remove "href" with Jquery?

<a id="a$id" onclick="check($id,1)" href="javascript:void(0)" class="black">Qualify</a> After "href" is removed, is "Qualify" still clickable?...

How to fix Python Numpy/Pandas installation?

I would like to install Python Pandas library (0.8.1) on Mac OS X 10.6.8. This library needs Numpy>=1.6. I tried this $ sudo easy_install pandas Searching for pandas Reading http://pypi.python.org/simple/pandas/ Reading http://pandas.pydata.org Rea...

Delete all data in SQL Server database

How I can delete all records from all tables of my database? Can I do it with one SQL command or I need for one SQL command per one table?...

$.ajax - dataType

What is the difference between contentType: "application/json; charset=utf-8", dataType: "json", vs. contentType: "application/json", dataType: "text", ...

How do you right-justify text in an HTML textbox?

I have a need to display many numerical values in columns. These values need to be easily editable so I cannot just display them in a table. I am using textboxes to display them. Is there a way for me to right-justify the text displayed in a textbox?...

How do I format date and time on ssrs report?

on SSRS report I need to show todays date and current time i tried this =FormatDateTime(Now,"MM/dd/yyyy hh:mm tt") but this is not working for me giving an error. Anyone please help me for expression ? I want output display like 4/12/2013 12:05 P...

Catch multiple exceptions at once?

It is discouraged to simply catch System.Exception. Instead, only the "known" exceptions should be caught. Now, this sometimes leads to unnecessary repetitive code, for example: try { WebId = new Guid(queryString["web"]); } ca...

How to set a default entity property value with Hibernate

How do I set a default value in Hibernate field?...

How to set response header in JAX-RS so that user sees download popup for Excel?

I wrote code that generate Excel file using REST JAX-RS and I confirmed that the generated Excel file is in GlassFish server directory. But my goal is when user click on the button (which generate Excel .xls), I want download popup to show up asking...

How to display multiple images in one figure correctly?

I am trying to display 20 random images on a single Figure. The images are indeed displayed, but they are overlaid. I am using: import numpy as np import matplotlib.pyplot as plt w=10 h=10 fig=plt.figure() for i in range(1,20): img = np.random.r...