Examples On Programing Languages

SQL: Combine Select count(*) from multiple tables

How do you combine multiple select count(*) from different table into one return? I have a similar sitiuation as this post but I want one return. I tried Union all but it spit back 3 separate rows of count. How do you combine them into one? selec...

Redirecting to a new page after successful login

I'm sure this question has been asked before but I have searched thoroughly for an answer but to no avail. (The only answers I've seen involve ajax) But I'm using just javascript, PHP and HTML. I have a login.php page and I have already created a H...

How to regex in a MySQL query

I have a simple task where I need to search a record starting with string characters and a single digit after them. What I'm trying is this SELECT trecord FROM `tbl` WHERE (trecord LIKE 'ALA[d]%') And SELECT trecord FROM `tbl` WHERE (trecord LIK...

How to set background color of a View

I'm trying to set the background color of a View (in this case a Button). I use this code: // set the background to green v.setBackgroundColor(0x0000FF00 ); v.invalidate(); It causes the Button to disappear from the screen. What am I doing wron...

Notepad++ Multi editing

How can I have multiple cursors in Notepad++? I will have a couple of tab delimited values . I need to write a query for all of these values. For example, if I get an Excel file with values like this: 1234 xyz pqr 2345 sdf kkk ... I want to copy ...

What does the NS prefix mean?

Many classes in Cocoa/Cocoa Touch have the NS prefix. What does it mean?...

What is the "Illegal Instruction: 4" error and why does "-mmacosx-version-min=10.x" fix it?

I get Illegal Instruction: 4 errors with binaries compiled with GCC 4.7.2 under Mac OS X 10.8.2 ("Mountain Lion"), when those binaries are run under Mac OS X 10.7.x ("Lion") and earlier versions. The binaries work properly under Mac OS X 10.8.x. I a...

How to set cache: false in jQuery.get call

jQuery.get() is a shorthand for jQuery.ajax() with a get call. But when I set cache:false in the data of the .get() call, what is sent to the server is a parameter called cache with a value of false. While my intention is to send a timestamp with th...

How to fix missing dependency warning when using useEffect React Hook?

With React 16.8.6 (it was good on previous version 16.8.3), I get this error when I attempt to prevent an infinite loop on a fetch request ./src/components/BusinessesList.js Line 51: React Hook useEffect has a missing dependency: 'fetchBusinesses'. ...

Count the items from a IEnumerable<T> without iterating?

private IEnumerable<string> Tables { get { yield return "Foo"; yield return "Bar"; } } Let's say I want iterate on those and write something like processing #n of #m. Is there a way I can find out the value of m ...

How to iterate object keys using *ngFor

I want to iterate [object object] using *ngFor in Angular 2. The problem is the object is not array of object but object of object which contains further objects. { "data": { "id": 834, "first_name": "GS", "last_name": "Shahid", "...

Wait for shell command to complete

I'm running a simple shell command in Excel VBA that runs a batch file in a specified directory like below: Dim strBatchName As String strBatchName = "C:\folder\runbat.bat" Shell strBatchName Sometimes the batch file might take longer on some com...

PHP Using RegEx to get substring of a string

I'm looking for an way to parse a substring using PHP, and have come across preg_match however I can't seem to work out the rule that I need. I am parsing a web page and need to grab a numeric value from the string, the string is like this product...

Laravel Migration Error: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

Migration error on Laravel 5.4 with php artisan make:auth [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 ...

Invoking a PHP script from a MySQL trigger

Is there any way how to invoke a PHP page / function when a record is inserted to a MySQL database table? We don't have control over the record insertion procedure. Is there a trigger mechanism which can call a PHP script back?...

Import JSON file in React

I'm new to React and I'm trying to import a JSON DATA variable from an external file. I'm getting the following error: Cannot find module "./customData.json" Could some one help me? It works if I have my DATA variable in index.js but not when ...

How can I use a DLL file from Python?

What is the easiest way to use a DLL file from within Python? Specifically, how can this be done without writing any additional wrapper C++ code to expose the functionality to Python? Native Python functionality is strongly preferred over using a t...

How to call function of one php file from another php file and pass parameters to it?

I want to call a function in one PHP file from a second PHP file and also pass two parameters to that function. How can I do this? I am very new to PHP. So please tell me, should I include the first PHP file into the second? Please show me an examp...

Iterating through a variable length array

How do I iterate over a Java array of variable length. I guess I would setup a while loop, but how would I detect that I have reached the end of the array. I guess I want something like this [just need to figure out how to represent myArray.notEnd...

Unable to connect PostgreSQL to remote database using pgAdmin

I installed PostgreSQL on my local server (Ubuntu) with IP 192.168.1.10. Now, I'm trying to access the database from my client machine (Ubuntu) with IP 192.168.1.11 with pgAdmin. I know I have to make changes in postgresql.conf and pg_hba.conf to a...

how to make label visible/invisible?

I have these date and time fields, and I want to set a javascript validation for the time. If the format is invalid, it should make the label visible, else it should be invisible. This is the code I have so far. <td nowrap="nowrap" align="l...

ORA-06502: PL/SQL: numeric or value error: character string buffer too small

I tried the following code different ways, like by taking out the while or the if, but when I put both together (if and while), I always get the error at the end... undefine numero set serveroutput on accept numero prompt 'Type # between 100 and 999...

How do I specify unique constraint for multiple columns in MySQL?

I have a table: table votes ( id, user, email, address, primary key(id), ); Now I want to make the columns user, email, address unique (together). How do I do this in MySql? Of course the example is just... an example. So ple...

In Jinja2, how do you test if a variable is undefined?

Converting from Django, I'm used to doing something like this: {% if not var1 %} {% endif %} and having it work if I didn't put var1 into the context. Jinja2 gives me an undefined error. Is there an easy way to say {% if var1 == None %} or similar...

How to round up integer division and have int result in Java?

I just wrote a tiny method to count the number of pages for cell phone SMS. I didn't have the option to round up using Math.ceil, and honestly it seems to be very ugly. Here is my code: public class Main { /** * @param args the command line argum...

How to use workbook.saveas with automatic Overwrite

In this section of code, Excel ALWAYS prompts: "File already exists, do you want to overwrite?" Application.DisplayAlerts = False Set xls = CreateObject("Excel.Application") Set wb = xls.Workbooks.Add fullFilePath = importFolderPath & "\" & ...

How can getContentResolver() be called in Android?

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

Can someone explain how to append an element to an array in C programming?

If I want to append a number to an array initialized to int, how can I do that? int arr[10] = {0, 5, 3, 64}; arr[] += 5; //Is this it?, it's not working for me... I want {0,5, 3, 64, 5} in the end. I'm used to Python, and in Python there is a fun...

Hide element by class in pure Javascript

I have tried the following code, but it doesn't work. Any idea where I have gone wrong? _x000D_ _x000D_ document.getElementsByClassName('appBanner').style.visibility='hidden';_x000D_ <div class="appBanner">appbanner</div>_x000D_ _x000D_ ...

Initializing an Array of Structs in C#

How can I initialize a const / static array of structs as clearly as possible? class SomeClass { struct MyStruct { public string label; public int id; }; const MyStruct[] MyArray = { {"a", 1} {"b...

if (select count(column) from table) > 0 then

I need to check a condition. i.e: if (condition)> 0 then update table else do not update end if Do I need to store the result into a variable using select into? e.g: declare valucount integer begin select count(column) into valuecount fro...

ProgressDialog spinning circle

I want to implement ProgressDialog like this one, without additional frame.: But I'm getting this one. How could I change that? Here is my code for ProgressDialog. Thanks in advance private ProgressDialog mProgressDialog; ............ m...

How to give credentials in a batch script that copies files to a network location?

The environment is Windows Web Server 2008, and I'm just trying to copy a folder full of files to a network location (a managed backup network folder). Here is my .bat file, running in the folder with my .bat files: copy *.bak \\networklocation\*.ba...

How to select all instances of selected region in Sublime Text

Is there a shortcut key or single-step menu option to find and select all instances of a highlighted selection in Sublime Text?...

Removing duplicate rows in Notepad++

Is it possible to remove duplicated rows in Notepad++, leaving only a single occurrence of a line?...

How to find the minimum value of a column in R?

I am new in R and I am trying to do something really simple. I had load a txt file with four columns and now I want to get the minimum value of the second column. This is the code that I have: ## Choose the directory of the file setwd("//Users//d...

Convert array values from string to int?

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

Difference between onCreate() and onStart()?

Possible Duplicate: Android Activity Life Cycle - difference between onPause() and OnStop() I was wondering - what is the difference between onCreate() and onStart() methods? I think that onStart() is a redundant method. onCreate() will A...

How to make an embedded Youtube video automatically start playing?

In my project, there is a video gallery module. In this module, there are two options: direct FLV uploading, and adding a video embed code from YouTube. I am writing some embed code for a div element (actually, the embed code comes from database). ...

is not JSON serializable

I have the following ListView import json class CountryListView(ListView): model = Country def render_to_response(self, context, **response_kwargs): return json.dumps(self.get_queryset().values_list('code', flat=True)) But I ge...

How to include External CSS and JS file in Laravel 5

I am Using Laravel 5.0 , the Form and Html Helper are removed from this version , i dont know how to include external css and js files in my header file. Currently i am using this code. <link rel="stylesheet" href="/css/bootstrap.min.css"> <...

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

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

node.js Error: connect ECONNREFUSED; response from server

I have a problem with this little program: var http = require("http"); var request = http.request({ hostname: "localhost", port: 8000, path: "/", method: "GET" }, function(response) { var statusCode = response.statusCode; var...

How to check if a Docker image with a specific tag exist locally?

I'd like to find out if a Docker image with a specific tag exists locally. I'm fine by using a bash script if the Docker client cannot do this natively. Just to provide some hints for a potential bash script the result of running the docker images c...

Spring 3 RequestMapping: Get path value

Is there a way to get the complete path value after the requestMapping @PathVariable values have been parsed? That is: /{id}/{restOfTheUrl} should be able to parse /1/dir1/dir2/file.html into id=1 and restOfTheUrl=/dir1/dir2/file.html Any ideas wou...

Cannot start GlassFish 4.1 from within Netbeans 8.0.1 Service area

On Windows 7 I downloaded the 'netbeans-8.0.1-javaee-windows.exe' installer from this site https://netbeans.org/downloads/. The installer installs GlassFish 4.1, Java 1.8.0_20 and NetBeans 8.01. After installation, whenever I try to start the GlassFi...

Command to find information about CPUs on a UNIX machine

Do you know if there is a UNIX command that will tell me what the CPU configuration for my Sun OS UNIX machine is? I am also trying to determine the memory configuration. Is there a UNIX command that will tell me that? ...

How to assign from a function which returns more than one value?

Still trying to get into the R logic... what is the "best" way to unpack (on LHS) the results from a function returning multiple values? I can't do this apparently: R> functionReturningTwoValues <- function() { return(c(1, 2)) } R> functi...

Angular2 Material Dialog css, dialog size

Angular2 material team recently released the MDDialog https://github.com/angular/material2/blob/master/src/lib/dialog/README.md I'd like to change the looking and feel about the angular2 material's dialog. For example, to change the fixed size of th...

Why don't Java's +=, -=, *=, /= compound assignment operators require casting?

Until today, I thought that for example: i += j; Was just a shortcut for: i = i + j; But if we try this: int i = 5; long j = 8; Then i = i + j; will not compile but i += j; will compile fine. Does it mean that in fact i += j; is a shortcut ...

How do you get the currently selected <option> in a <select> via JavaScript?

How do you get the currently selected <option> of a <select> element via JavaScript?...

How do you make a div tag into a link

How do you make a div tag into a link. I would like my entire div to be clickable....

Writing a large resultset to an Excel file using POI

This is sort of inline w/ Writing a large ResultSet to a File but the file in question is an Excel file. I'm using the Apache POI library to write an Excel file with a large data set retrieved from a ResultSet object. The data could range from a few...

Best way to "negate" an instanceof

I was thinking if there exists a better/nicer way to negate an instanceof in Java. Actually, I'm doing something like: if(!(str instanceof String)) { /* do Something */ } But I think that a "beautiful" syntax to do this should exist. Does anyone ...

How to force a hover state with jQuery?

Please, considere this CSS code: a { color: #ffcc00; } a:hover { color: #ccff00; } This HTML code: <a href="#" id="link">Link</a> <button id="btn">Click here</button> And, finally, this JS code: $("#btn").click(function...

SQL state [99999]; error code [17004]; Invalid column type: 1111 With Spring SimpleJdbcCall

Hi All I am using spring simple JDBC template to call the oracle procedure the below are my code. The procedure create or replace PROCEDURE get_all_system_users( pi_client_code IN VARCHAR2, po_system_users OUT T_SYSTEM_USER_TAB, po_error_code ...

A potentially dangerous Request.Form value was detected from the client

I have this issue. I have tried everything. ValidateRequest="false".. and decoding and encoding html.. etc. etc.. What I need is a popup box (so im using ModalPopupExtender) to present to a user where people can type in xml settings and click ok/can...

Disable copy constructor

I have a class : class SymbolIndexer { protected: SymbolIndexer ( ) { } public: static inline SymbolIndexer & GetUniqueInstance ( ) { static SymbolIndexer uniqueinstance_ ; return uniqueinstance_ ; } }; How should I modify ...

Call An Asynchronous Javascript Function Synchronously

First, this is a very specific case of doing it the wrong way on-purpose to retrofit an asynchronous call into a very synchronous codebase that is many thousands of lines long and time doesn't currently afford the ability to make the changes to "do i...

Markdown: continue numbered list

In the following markdown code I want item 3 to start with list number 3. But because of the code block in between markdown starts this list item as a new list. Is there any way to prevent that behaviour? Desired output: 1. item 1 2. item 2 ``` Co...

Variable number of arguments in C++?

How can I write a function that accepts a variable number of arguments? Is this possible, how?...

How to parse month full form string using DateFormat in Java?

I tried this: DateFormat fmt = new SimpleDateFormat("MMMM dd, yyyy"); Date d = fmt.parse("June 27, 2007"); error: Exception in thread "main" java.text.ParseException: Unparseable date: "June 27, 2007" The java docs say I should use four charact...

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

Namespace for [DataContract]

I can't find the namespace to use for [DataContract] and [DataMember] elements. According to what I've found, it seems that adding the following should be enough, but in my case it is not. using System; using System.Runtime.Serialization; Here is ...

Gerrit error when Change-Id in commit messages are missing

I set up a branch in the remote repository and made some commits on that branch. Now I want to merge the remote branch to the remote master. Basically follows are my operations: checkout branch checkout master merge branch and fix merging errors c...

Can't find the 'libpq-fe.h header when trying to install pg gem

I am using the Ruby on Rails 3.1 pre version. I like to use PostgreSQL, but the problem is installing the pg gem. It gives me the following error: $ gem install pg Building native extensions. This could take a while... ERROR: Error installing pg: ...

How to set default font family in React Native?

Is there an equivalent to this CSS in React Native, so that the app uses the same font everywhere ? body { font-family: 'Open Sans'; } Applying it manually on every Text node seems overly complicated....

In LaTeX, how can one add a header/footer in the document class Letter?

In LaTeX, how can one create a document using the Letter documentclass, but with customized headers and footers? Typically I would use: \usepackage{fancyhdr} \pagestyle{fancy} \lhead{\footnotesize \parbox{11cm}{Custom left-head-note} } \lfoot{\foo...

Create dynamic URLs in Flask with url_for()

Half of my Flask routes requires a variable say, /<variable>/add or /<variable>/remove. How do I create links to those locations? url_for() takes one argument for the function to route to but I can't add arguments?...

How to send parameters with jquery $.get()

I'm trying to do a jquery GET and i want to send a parameter. here's my function: $(function() { var availableProductNames; $.get("manageproducts.do?option=1", function(data){ availableProductNames = data.split(",");; aler...

What is AndroidX?

I am reading about a room library of Android. I see they changed package android to androidx. I did not understand that. Can someone explain, please? implementation "androidx.room:room-runtime:$room_version" annotationProcessor "androidx.room:room-c...

Python assigning multiple variables to same value? list behavior

I tried to use multiple assignment as show below to initialize variables, but I got confused by the behavior, I expect to reassign the values list separately, I mean b[0] and c[0] equal 0 as before. a=b=c=[0,3,5] a[0]=1 print(a) print(b) print(c) ...

Java Convert integer to hex integer

I'm trying to convert a number from an integer into an another integer which, if printed in hex, would look the same as the original integer. For example: Convert 20 to 32 (which is 0x20) Convert 54 to 84 (which is 0x54)...

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

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

What's better at freeing memory with PHP: unset() or $var = null

I realise the second one avoids the overhead of a function call (update, is actually a language construct), but it would be interesting to know if one is better than the other. I have been using unset() for most of my coding, but I've recently looked...

What is the best open-source java charting library? (other than jfreechart)

Why are there not more opensource easy to use charting libraries for Java?. The only successful opensource project in this area seems to be jfreechart, and it doesn't even have any documentation or examples available....

Lost connection to MySQL server at 'reading initial communication packet', system error: 0

I am getting error: "Lost connection to MySQL server at 'reading initial communication packet, system error: 0" while I am going to connect my db. If I am using localhost everything is working fine. But when I am using my live IP address like ...

Generating an MD5 checksum of a file

Is there any simple way of generating (and checking) MD5 checksums of a list of files in Python? (I have a small program I'm working on, and I'd like to confirm the checksums of the files)....

Clear variable in python

Is there a way to clear the value of a variable in python? For example if I was implementing a binary tree: class Node: self.left = somenode1 self.right = somenode2 If I wanted to remove some node from the tree, I would need to set self.left...

Hyper-V: Create shared folder between host and guest with internal network

Set up: Host: Windows 10 Enterprise Guest: Windows 10 Professional Hypervisor: Hyper-V Aim: Create a shared folder between Host and Guest via an internal network to exchange files How can I achieve this?...

Split bash string by newline characters

I found this. And I am trying this: x='some thing' y=(${x//\n/}) And I had no luck, I thought it could work with double backslash: y=(${x//\\n/}) But it did not. To test I am not getting what I want I am doing: echo ${y[1]} Getting: s...

Count Vowels in String Python

I'm trying to count how many occurrences there are of specific characters in a string, but the output is wrong. Here is my code: inputString = str(input("Please type a sentence: ")) a = "a" A = "A" e = "e" E = "E" i = "i" I = "I" o = "o" O = "O" u ...

How to use awk sort by column 3

I have a file (user.csv)like this ip,hostname,user,group,encryption,aduser,adattr want to print all column sort by user, I tried awk -F ":" '{print|"$3 sort -n"}' user.csv , it doesn't work....

Bash foreach loop

I have an input (let's say a file). On each line there is a file name. How can I read this file and display the content for each one....

Why is textarea filled with mysterious white spaces?

I have a simple text area in a form like this: <textarea style="width:350px; height:80px;" cols="42" rows="5" name="sitelink"> <?php if($siteLink_val) echo $siteLink_val; ?> </textarea> I keep getting extra white space in th...

HTML5 Canvas 100% Width Height of Viewport?

I am trying to create a canvas element that takes up 100% of the width and height of the viewport. You can see in my example here that is occurring, however it is adding scroll bars in both Chrome and FireFox. How can I prevent the extra scroll ba...

Reduce git repository size

I tried looking for a good tutorial on reducing repo size, but found none. How do I reduce my repo size...it's about 10 MB, but the thing is Heroku only allows 50 MB and I'm no where near finished developing my app. I added the usual suspects (log, ...

How do I configure Maven for offline development?

Does maven require a connection to the internet at some point to be able to use it? Meaning specifically getting the internal maven plugins for compiling, cleaning, packaging, etc? ...

Return char[]/string from a function

Im fairly new to coding in C and currently im trying to create a function that returns a c string/char array and assigning to a variable. So far, ive observed that returning a char * is the most common solution. So i tried: char* createStr() { ...

Regex that accepts only numbers (0-9) and NO characters

I need a regex that will accept only digits from 0-9 and nothing else. No letters, no characters. I thought this would work: ^[0-9] or even \d+ but these are accepting the characters : ^,$,(,), etc I thought that both the regexes above would...

Auto margins don't center image in page

In this example the image is not centered. Why? My browser is Google Chrome v10 on windows 7, not IE. <img src="/img/logo.png" style="margin:0px auto;"/> ...

how to send a post request with a web browser

how to send a post request with a web browser?...

What is a lambda expression in C++11?

What is a lambda expression in C++11? When would I use one? What class of problem do they solve that wasn't possible prior to their introduction? A few examples, and use cases would be useful. ...

Getting the parent div of element

This should be really simple but I'm having trouble with it. How do I get a parent div of a child element? My HTML: <div id="test"> <p id="myParagraph">Testing</p> </div> My JavaScript: var pDoc = document.getElemen...

Using OR operator in a jquery if statement

I need to use the OR operator in a jQuery if statement to filter out 10 states. My code works wile only excluding one state, but fails when i try to include multiple states. Is there a correct way to do this? Code I am am using : if ((state != 10)...

XAMPP Apache Webserver localhost not working on MAC OS

I install XAMPP server on MAC OS 10.6 it was working fine. After a lot of days I checked it, but not working this time, localhost not opening this time. after some R&D I reinstall XAMPP server after uninstall When I start the apache after reins...

Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."

I have an application which works fine on Xcode6-Beta1 and Xcode6-Beta2 with both iOS7 and iOS8. But with Xcode6-Beta3, Beta4, Beta5 I'm facing network issues with iOS8 but everything works fine on iOS7. I get the error "The network connection was lo...

How do I Sort a Multidimensional Array in PHP

I have CSV data loaded into a multidimensional array. In this way each "row" is a record and each "column" contains the same type of data. I am using the function below to load my CSV file. function f_parse_csv($file, $longest, $delimiter) { $mda...

MySQL select statement with CASE or IF ELSEIF? Not sure how to get the result

I have a two tables. One has manufacturer information and includes the regions where they can sell. The other has their products for sale. We have to limit visibility of the product based on the regions. This is like Netflix have videos in their ...

How to join entries in a set into one string?

Basically, I am trying to join together the entries in a set in order to output one string. I am trying to use syntax similar to the join function for lists. Here is my attempt: list = ["gathi-109","itcg-0932","mx1-35316"] set_1 = set(list) set_2 = ...

Delete element in a slice

func main() { a := []string{"Hello1", "Hello2", "Hello3"} fmt.Println(a) // [Hello1 Hello2 Hello3] a = append(a[:0], a[1:]...) fmt.Println(a) // [Hello2 Hello3] } How does this delete trick with the append function work? It...

How do I get the current time only in JavaScript

How can I get the current time in JavaScript and use it in a timepicker? I tried var x = Date() and got: Tue May 15 2012 05:45:40 GMT-0500 But I need only current time, for example, 05:45 How can I assign this to a variable?...

SQL Not Like Statement not working

I have the following code within a stored procedure. WHERE WPP.ACCEPTED = 1 AND WPI.EMAIL LIKE '%@MATH.UCLA.EDU%' AND (WPP.SPEAKER = 0 OR WPP.SPEAKER IS NULL) AND WPP.COMMENT NOT LIKE '%CORE%' AND WPP.PROGRAMCODE = 'cmaws3' ...

Only allow specific characters in textbox

How can I only allow certain characters in a Visual C# textbox? Users should be able to input the following characters into a text box, and everything else should be blocked: 0-9, +, -, /, *, (, ). I've used Google to look up this problem, but the o...

Text overwrite in visual studio 2010

Really silly problem here. In Visual Studio 2010, the text cursor has changed from the blinking line, to a blinking grey box around the characters. When I type overwrites the text in front of it. I'm not sure how to get this off? It's like what h...

Send multipart/form-data files with angular using $http

I know there are a lot of questions about this, but I can't get this to work: I want to upload a file from input to a server in multipart/form-data I've tried two approaches. First: headers: { 'Content-Type': undefined }, Which results in e.g....

How to open Visual Studio Code from the command line on OSX?

The docs mention an executable called code, but I'm not sure where I can find that so I can put it on my path. The zip I downloaded from the VSCode site did not include any such executable. (I am able to run the .app just fine.) Is this a Windows-on...

Why is Chrome showing a "Please Fill Out this Field" tooltip on empty fields?

I was contacted by my client saying that users complaint saying that some fields now show a tooltip with a message "Please Fill out This Field". I couldn't believe what I heard... but the client is right - using latest Chrome version some fields show...

#1273 – Unknown collation: ‘utf8mb4_unicode_520_ci’

I have a WordPress website on my local WAMP server. But when I upload its database to live server, I get error #1273 – Unknown collation: ‘utf8mb4_unicode_520_ci’ Any help would be appreciated!...

Post parameter is always null

Since upgrading to RC for WebAPI I'm having some real odd issue when calling POST on my WebAPI. I've even gone back to the basic version generated on new project. So: public void Post(string value) { } and calling from Fiddler: Header: User-Agent...

What is w3wp.exe?

I have a WCF service running under a service user on my local system. Every time I try to debug it is giving me a message Attach Security warning. In Visual Studio, by default (even without attaching), I get this error: Attaching to this process...

How to run crontab job every week on Sunday

I'm trying to figure out how to run a crontab job every week on Sunday. I think the following should work, but I'm not sure if I understand correctly. Is the following correct? 5 8 * * 6 ...

Difference between 2 dates in SQLite

How do I get the difference in days between 2 dates in SQLite? I have already tried something like this: SELECT Date('now') - DateCreated FROM Payment It returns 0 every time....

Why should hash functions use a prime number modulus?

A long time ago, I bought a data structures book off the bargain table for $1.25. In it, the explanation for a hashing function said that it should ultimately mod by a prime number because of "the nature of math". What do you expect from a...

using c# .net libraries to check for IMAP messages from gmail servers

Does anyone have any sample code in that makes use of the .Net framework that connects to googlemail servers via IMAP SSL to check for new emails?...

Platform.runLater and Task in JavaFX

I have been doing some research on this but I am still VERY confused to say the least. Can anyone give me a concrete example of when to use Task and when to use Platform.runLater(Runnable);? What exactly is the difference? Is there a golden rule to ...

Deprecated: mysql_connect()

I am getting this warning, but the program still runs correctly. The MySQL code is showing me a message in PHP: Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:...

When must we use NVARCHAR/NCHAR instead of VARCHAR/CHAR in SQL Server?

Is there a rule when we must use the Unicode types? I have seen that most of the European languages (German, Italian, English, ...) are fine in the same database in VARCHAR columns. I am looking for something like: If you have Chinese --> use ...

How can I restore the MySQL root user’s full privileges?

I accidentally removed some of the privileges from my MySQL root user, including the ability to alter tables. Is there some way I can restore this user to its original state (with all privileges)? UPDATE mysql.user SET Grant_priv = 'Y', Super_priv =...

css transition opacity fade background

I am doing a transition where it fades into transparent white, when a user is hovering an image. My problem is that I need to change the color, that it fades to, to black. I have tried just simply adding background:black; to the class that contains...

Google Chrome Printing Page Breaks

I'm trying to get google chrome to do page breaks. I've been told via a bunch of websites that page-break-after: always; is valid in chrome but I can not seem to get it to work even with a very simple example. is there any way to force a page brea...

PersistenceContext EntityManager injection NullPointerException

I have a war containing the following: META-INF/MANIFEST.MF WEB-INF/classes/META-INF/persistence.xml WEB-INF/classes/com/test/service/TestServlet.class WEB-INF/classes/com/test/service/TestEntity.class WEB-INF/classes/jndi.properties WEB-INF/classes...

Getting the encoding of a Postgres database

I have a database, and I need to know the default encoding for the database. I want to get it from the command line....

Open JQuery Datepicker by clicking on an image w/ no input field

I want to have the JQuery Datepicker open when the user clicks on an image. There is no input field where the selected date appears afterwards; I'm just going to save the entered date to the server via Ajax. Currently I have this code: <img src=...

How to replace a string in an existing file in Perl?

I want to replace word "blue" to "red" in all text files named as 1_classification.dat, 2_classification.dat and so on. I want to edit the same file so I tried this code but it does not work. Where am I going wrong? @files=glob("*_classification.da...

How to squash all git commits into one?

How do you squash your entire repository down to the first commit? I can rebase to the first commit, but that would leave me with 2 commits. Is there a way to reference the commit before the first one?...

What is the maximum recursion depth in Python, and how to increase it?

I have this tail recursive function here: def recursive_function(n, sum): if n < 1: return sum else: return recursive_function(n-1, sum+n) c = 998 print(recursive_function(c, 0)) It works up to n=997, then it just break...

Check for column name in a SqlDataReader object

How do I check to see if a column exists in a SqlDataReader object? In my data access layer, I have create a method that builds the same object for multiple stored procedures calls. One of the stored procedures has an additional column that is not ...

How can I get the number of days between 2 dates in Oracle 11g?

I'm trying to find an integer number of days between two dates in Oracle 11g. I can get close by doing select sysdate - to_date('2009-10-01', 'yyyy-mm-dd') from dual but this returns an interval, and I haven't been successful casting this to a...

Renaming a branch in GitHub

I just renamed my local branch using git branch -m oldname newname but this only renames the local version of the branch. How can I rename the one on GitHub?...

how to initialize a char array?

char * msg = new char[65546]; want to initialize to 0 for all of them. what is the best way to do this in C++?...

How do you revert to a specific tag in Git?

I know how to revert to older commits in a Git branch, but how do I revert back to a branch's state dictated by a tag? I envision something like this: git revert -bytag "Version 1.0 Revision 1.5" Is this possible?...

Convert JS object to JSON string

If I defined an object in JS with: var j={"name":"binchen"}; How can I convert the object to JSON? The output string should be: '{"name":"binchen"}' ...

Hidden Features of Xcode

With a huge influx of newbies to Xcode, I'm sure there are lots of Xcode tips and tricks to be shared. What are yours? ...

JPA entity without id

I have a database with the following structure: CREATE TABLE entity ( id SERIAL, name VARCHAR(255), PRIMARY KEY (id) ); CREATE TABLE entity_property ( entity_id SERIAL, name VARCHAR(255), value TEXT ); When I try to create...

Where to find free public Web Services?

I want some usefull free public WebServices like Weather, Currency Converter, Mathematics etc. Please tell me where I can get them Thanks in advance!...

Gradient text color

Is there a generator , or an easy way to generate text like this but without having to define every letter So something like this: _x000D_ _x000D_ .rainbow {_x000D_ background-image: -webkit-gradient( linear, left top, right top, color-stop(0, #f...

How to connect to a MySQL Data Source in Visual Studio

I use the MySQL Connector/Net to connect to my database by referencing the assembly (MySql.Data.dll) and passing in a connection string to MySqlConnection. I like that because I don't have to install anything. Is there some way to "Choose Data Sou...

How can I produce an effect similar to the iOS 7 blur view?

I'm trying to replicate this blurred background from Apple's publicly released iOS 7 example screen: This question suggests applying a CI filter to the contents below, but that's a whole different approach. It's obvious that iOS 7 doesn't capture ...

Prevent linebreak after </div>

Is there a way to prevent a line break after a div with css? For example I have <div class="label">My Label:</div> <div class="text">My text</div> and want it to display like: My Label: My text ...

Android Saving created bitmap to directory on sd card

I created a bitmap and now i want to save that bitmap to a directory somewhere. Can anyone show me how this is done. Thanks FileInputStream in; BufferedInputStream buf; try { in = new FileInputStream("/mnt/sdca...

How do I 'svn add' all unversioned files to SVN?

I'm looking for a good way to automatically 'svn add' all unversioned files in a working copy to my SVN repository. I have a live server that can create a few files that should be under source control. I would like to have a short script that I ca...

jQuery remove special characters from string and more

I have a string like this: var str = "I'm a very^ we!rd* Str!ng."; What I would like to do is removing all special characters from the above string and replace spaces and in case they are being typed, underscores, with a - character. The above st...

Vim 80 column layout concerns

The way I do 80-column indication in Vim seems incorrect:set columns=80. At times I also set textwidth, but I want to be able to see and anticipate line overflow with the set columns alternative. This has some unfortunate side effects: I can't se...

converting list to json format - quick and easy way

Let's say I have an object MyObject that looks like this: public class MyObject { int ObjectID {get;set;} string ObjectString {get;set;} } I have a list of MyObject and I'm looking to convert it in a json string with a stringbuilder. I know h...

Identify duplicate values in a list in Python

Is it possible to get which values are duplicates in a list using python? I have a list of items: mylist = [20, 30, 25, 20] I know the best way of removing the duplicates is set(mylist), but is it possible to know what values are being duplic...

How to change the Spyder editor background to dark?

I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Cou...

How to write to the Output window in Visual Studio?

Which function should I use to output text to the "Output" window in Visual Studio? I tried printf() but it doesn't show up....

Good beginners tutorial to socket.io?

I am very new to the world of webdevelopment and jumped into the bandwagon because I find the concept of HTML5 very interesting. I am fairly confident on working with canvas and would now like to move over to websockets part of it. I have come to und...

AttributeError("'str' object has no attribute 'read'")

In Python I'm getting an error: Exception: (<type 'exceptions.AttributeError'>, AttributeError("'str' object has no attribute 'read'",), <traceback object at 0x1543ab8>) Given python code: def getEntries (self, sub): url =...

SQL LIKE condition to check for integer?

I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter "A": SELECT * FROM books WHERE title ILIKE "A%" That's fine f...

JavaFX Panel inside Panel auto resizing

I have a JavaFX application which has only one FXML file. In this file I have one AnchorPane which has a StackPane inside it. Here is the screenshot: When I start this application, I want to resize StackPane automatically with the AnchorPane. Thus...

Adding a column after another column within SQL

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

Unpivot with column name

I have a table StudentMarks with columns Name, Maths, Science, English. Data is like Name, Maths, Science, English Tilak, 90, 40, 60 Raj, 30, 20, 10 I want to get it arranged like the following: Name, Subject, Marks T...

OrderBy pipe issue

I'm not able to translate this code from Angualr 1 to Angular 2: ng-repeat="todo in todos | orderBy: 'completed'" This is what i've done following the Thierry Templier's answer: Component template: *ngFor="#todo of todos | sort" Component...

UITextView that expands to text using auto layout

I have a view that is laid out completely using auto layout programmatically. I have a UITextView in the middle of the view with items above and below it. Everything works fine, but I want to be able to expand UITextView as text is added. This should...

mysql update multiple columns with same now()

I need to update 2 datetime columns, and I need them to be exactly the same, using mysql version 4.1.20. I'm using this query: mysql> update table set last_update=now(), last_monitor=now() where id=1; It is safe or there is a chance that the co...

How to change permissions for a folder and its subfolders/files in one step?

I would like to change the permissions of a folder and all its subfolders and files in one step (command) in Linux. I have already tried the below command but it works only for the mentioned folder: chmod 775 /opt/lampp/htdocs Is there a way to set ...

proper way to sudo over ssh

I have a script which runs another script via SSH on a remote server using sudo. However, when I type the password, it shows up on the terminal. (Otherwise it works fine) ssh user@server "sudo script" What's the proper way to do this so I can typ...

How can I concatenate a string and a number in Python?

I was trying to concatenate a string and a number in Python. It gave me an error when I tried this: "abc" + 9 The error is: Traceback (most recent call last): File "<pyshell#5>", line 1, in <module> "abc" + 9 TypeError: cannot c...

JavaScript Editor Plugin for Eclipse

Is there an Eclipse plugin available for JavaScript that allows for syntax checking and autosuggestions for .js files in Eclipse?...

Excluding directory when creating a .tar.gz file

I have a /public_html/ folder, in that folder there's a /tmp/ folder that has like 70gb of files I don't really need. Now I am trying to create a .tar.gz of /public_html/ excluding /tmp/ This is the command I ran: tar -pczf MyBackup.tar.gz /home/u...

What does 'public static void' mean in Java?

What does public static void mean in Java? I'm in the process of learning. In all the examples in the book I'm working from public static void comes before any method that is being used or created. What does this mean? ...

Where do I find the Instagram media ID of a image

I'm am looking for the MediaID of an Instagram image which has been uploaded. It should look like 1234567894561231236_33215652 I have found out the last set of integers are the usersID For example: this is the link for the image directly, how...

Oracle: not a valid month

I have a table with the following fields: Reports (table name) Rep_Date (date) Rep_Time (date) The Rep_Time field has values like '01/01/1753 07:30:00' i.e. the time part is relevant. I have written the following query: select Reports.pid, MaxDat...

How to combine date from one field with time from another field - MS SQL Server

In an extract I am dealing with, I have 2 datetime columns. One column stores the dates and another the times as shown. How can I query the table to combine these two fields into 1 column of type datetime? Dates 2009-03-12 00:00:00.000 2009-03-26 ...

The project description file (.project) for my project is missing

I am using Eclipse PDT 3.5 on Vista (32 bit). It works, though eclipse needs admin rights to execute. This annoys me, but I accept it. But: every now and then (I am not sure, it may even be everytime I want to open a project), I get the error messag...

How to define partitioning of DataFrame?

I've started using Spark SQL and DataFrames in Spark 1.4.0. I'm wanting to define a custom partitioner on DataFrames, in Scala, but not seeing how to do this. One of the data tables I'm working with contains a list of transactions, by account, sili...

Unable to allocate array with shape and data type

I'm facing an issue with allocating huge arrays in numpy on Ubuntu 18 while not facing the same issue on MacOS. I am trying to allocate memory for a numpy array with shape (156816, 36, 53806) with np.zeros((156816, 36, 53806), dtype='uint8') and...

How to Change color of Button in Android when Clicked?

I am working on Android Application. I want to have 4 buttons to be placed horizontally at the bottom of the screen. In these 4 buttons 2 buttons are having images on them. The border of the buttons should be black color and the border should be as t...

How to run DOS/CMD/Command Prompt commands from VB.NET?

The question is self-explanatory. It would be great if the code was one line long (something to do with "Process.Start("...")"?). I researched the web but only found old examples and such ones that do not work (at least for me). I want to use this in...

How to repeat last command in python interpreter shell?

How do I repeat the last command? The usual keys: Up, Ctrl+Up, Alt-p don't work. They produce nonsensical characters. (ve)[kakarukeys@localhost ve]$ python Python 2.6.6 (r266:84292, Nov 15 2010, 21:48:32) [GCC 4.4.4 20100630 (Red Hat 4.4.4-10)] on ...

Webdriver findElements By xpath

1)I am doing a tutorial to show how findElements By xpath works. I would like to know why it returns all the texts that following the <div> element with attribute id=container. code for xpath: By.xpath("//div[@id='container'] 2) how should I...

how to create a Java Date object of midnight today and midnight tomorrow?

In my code I need to find all my things that happened today. So I need to compare against dates from today at 00:00am (midnight early this morning) to 12:00pm (midnight tonight). I know ... Date today = new Date(); ... gets me right now. And ....

When should a class be Comparable and/or Comparator?

I have seen classes which implement both Comparable and Comparator. What does this mean? Why would I use one over the other?...

What is the shortest function for reading a cookie by name in JavaScript?

What is the shortest, accurate, and cross-browser compatible method for reading a cookie in JavaScript? Very often, while building stand-alone scripts (where I can't have any outside dependencies), I find myself adding a function for reading cookie...

Correct way to quit a Qt program?

How should I quit a Qt Program, e.g when loading a data file, and discovered file corruption, and user need to quit this app or re-initiate data file? Should I: call exit(EXIT_FAILURE) call QApplication::quit() call QCoreApplication::quit() And ...

Test if a string contains a word in PHP?

In SQL we have NOT LIKE %string% I need to do this in PHP. if ($string NOT LIKE %word%) { do something } I think that can be done with strpos() But can’t figure out how… I need exactly that comparission sentence in valid PHP. if ($string N...

Android Studio Run/Debug configuration error: Module not specified

I am getting a 'Module not specified' error in my run config. I have no module showing in the drop down yet I can see my module no probs. The issue came about when I refactored my module name, changed the settings.gradle to new name. Now when I go t...

Getting DOM elements by classname

I'm using PHP DOM and I'm trying to get an element within a DOM node that have a given class name. What's the best way to get that sub-element? Update: I ended up using Mechanize for PHP which was much easier to work with....

Mysql - delete from multiple tables with one query

I have 4 tables that stores different information about a user in each. Each table has a field with user_id to identify which row belongs to which user. If I want to delete the user is this the best way to delete that users information from multipl...

Putting an if-elif-else statement on one line?

I have read the links below, but it doesn't address my question. Does Python have a ternary conditional operator? (the question is about condensing if-else statement to one line) Is there an easier way of writing an if-elif-else statement so it fit...

adding 30 minutes to datetime php/mysql

I have a datetime field (endTime) in mysql. I use gmdate() to populate this endTime field. The value stored is something like 2009-09-17 04:10:48. I want to add 30 minutes to this endtime and compare it with current time. ie) the user is allowed t...

Spring Data: "delete by" is supported?

I am using Spring JPA for database access. I am able to find examples such as findByName and countByName, for which I dont have to write any method implementation. I am hoping to find examples for delete a group of records based on some condition. D...

Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2

I'm getting below error. Failed to parse JSON due to: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 Server Url public static final String SERVER_URL = "h...

How to show PIL Image in ipython notebook

This is my code from PIL import Image pil_im = Image.open('data/empire.jpg') I would like to do some image manipulation on it, and then show it on screen. I am having problem with showing PIL Image in python notebook. I have tried: print pil...

Confirm deletion in modal / dialog using Twitter Bootstrap?

I have an HTML table of rows tied to database rows. I'd like to have a "delete row" link for each row, but I would like to confirm with the user beforehand. Is there any way to do this using the Twitter Bootstrap modal dialog?...

Upload files from Java client to a HTTP server

I'd like to upload a few files to a HTTP server. Basically what I need is some sort of a POST request to the server with a few parameters and the files. I've seen examples of just uploading files, but didn't find how to also pass additional parameter...

Best place to insert the Google Analytics code

Where’s the best place to insert the Google Analytics code in WordPress, header or footer? I prefer footer, because I wanted my site to load faster by reducing the number of scripts in the header, but can it work even if the script is in the footer...

Undefined symbols for architecture i386: _OBJC_CLASS_$_SKPSMTPMessage", referenced from: error

I have imported framework for sending email from application in background i.e. SKPSMTPMessage Framework. Can somebody suggest why below error is shown Undefined symbols for architecture i386: "_OBJC_CLASS_$_SKPSMTPMessage", referenced from: objc...

IIS7: Setup Integrated Windows Authentication like in IIS6

This is for IIS 7 on a Windows Server 2008 that is not part of an AD domain. I would like to password protect a website, where people have to enter a username/password (a windows account for example) to view the website. The website would then use ...

How do you convert CString and std::string std::wstring to each other?

CString is quite handy, while std::string is more compatible with STL container. I am using hash_map. However, hash_map does not support CStrings as keys, so I want to convert the CString into a std::string. Writing a CString hash function seems to t...

Prevent content from expanding grid items

TL;DR: Is there anything like table-layout: fixed for CSS grids? I tried to create a year-view calendar with a big 4x3 grid for the months and therein nested 7x6 grids for the days. The calendar should fill the page, so the year grid container ge...

Set a path variable with spaces in the path in a Windows .cmd file or batch file

I'm new to script writing and can't get this one to work. I could if I moved the files to a path without a space in it, but I'd like it to work with the space if it could. I want to extract a bunch of Office updates to a folder with a .cmd file. ...

Alternative to Intersect in MySQL

I need to implement the following query in MySQL. (select * from emovis_reporting where (id=3 and cut_name= '?????' and cut_name='??') ) intersect ( select * from emovis_reporting where (id=3) and ( cut_name='?????' or cut_name='??') ) I know tha...

Socket transport "ssl" in PHP not enabled

I'm having trouble enabling the socket transport "ssl" in PHP. When I run my script, I get the error: Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://www.my.site.com:443 (Unable to find the socket transport "ssl" - ...

How To Add An "a href" Link To A "div"?

I need to know how to add an a href link to a div? Do you put the a href tag arounf the entire "buttonOne" div? Or should it be around or inside the "linkedinB" div? Here's my HTML: <div id="buttonOne"> <div id="linkedinB"> <im...

Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util

On Updating version my project gradle to 5.0 release I am getting error in android studio it was working fine with gradle 5.0 rc 3 and 4 release. following is the error detail: Cause: org.jetbrains.plugins.gradle.tooling.util.ModuleComponentIde...

Reading from stdin

What are the possible ways for reading user input using read() system call in Unix. How can we read from stdin byte by byte using read()?...

How can I do SELECT UNIQUE with LINQ?

I have a list like this: Red Red Brown Yellow Green Green Brown Red Orange I am trying to do a SELECT UNIQUE with LINQ, i.e. I want Red Brown Yellow Green Orange var uniqueColors = from dbo in database.MainTable where dbo.Propert...

How to add data via $.ajax ( serialize() + extra data ) like this

I want to add extra data after i use $('#myForm').serialize() + extra data $.ajax({ type: 'POST', url: $('#myForm').attr('action'), data: $('#myForm').serialize(), // I WANT TO ADD EXTRA DATA + SERIALIZE DATA success: function(data){ ...

Increment variable value by 1 ( shell programming)

I am a beginner to shell programming and it sounds like a very stupid question but i cant seem to be able to increase the variable value by 1. I have looked at tutorial but it only shows how to add together 2 variables I have tried the following met...

Fade Effect on Link Hover?

on many sites, such as http://www.clearleft.com, you'll notice that when the links are hovered over, they will fade into a different color as opposed to immediately switching, the default action. I assume JavaScript is used to create this effect, do...

Share data between html pages

I want to send some data from one HTML page to another. I am sending the data through the query parameters like http://localhost/project/index.html?status=exist. The problem with this method is that data remains in the URL. Is there any other method...

How do we control web page caching, across all browsers?

Our investigations have shown us that not all browsers respect the HTTP cache directives in a uniform manner. For security reasons we do not want certain pages in our application to be cached, ever, by the web browser. This must work for at least th...

Permission denied for relation

I tried to run simple sql command: select * from site_adzone; and I got this error ERROR: permission denied for relation site_adzone What could be the problem here? I tried also to do select for other tables and got same issue. I also tried t...

Is it good practice to use the xor operator for boolean checks?

I personally like the exclusive or, ^, operator when it makes sense in the context of boolean checks because of its conciseness. I much prefer to write if (boolean1 ^ boolean2) { //do it } than if((boolean1 && !boolean2) || (boolean2 &...

Good tutorial for using HTML5 History API (Pushstate?)

I am looking into using the HTML5 History API to resolve deep linking problems with AJAX loaded content, but I am struggling to get off the ground. Does any one know of any good resources? I want to use this as it seems a great way to allow to the p...

Mockito verify order / sequence of method calls

Is there a way to verify if a methodOne is called before methodTwo in Mockito? public class ServiceClassA { public void methodOne(){} } public class ServiceClassB { public void methodTwo(){} } public class TestClass { public void ...

Any difference between await Promise.all() and multiple await?

Is there any difference between: const [result1, result2] = await Promise.all([task1(), task2()]); and const t1 = task1(); const t2 = task2(); const result1 = await t1; const result2 = await t2; and const [t1, t2] = [task1(), task2()]; const ...

How to create user for a db in postgresql?

I have installed PostgreSQL 8.4 on my CentOS server and connected to root user from shell and accessing the PostgreSQL shell. I created the database and user in PostgreSQL. While trying to connect from my PHP script it shows me authentication faile...

PHP Excel Header

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

'foo' was not declared in this scope c++

I'm just learning c++ (first day looking at it since I took a 1 week summer camp years ago) I was converting a program I'm working on in Java to C++: #ifndef ADD_H #define ADD_H #define _USE_MATH_DEFINES #include <iostream> #include <math....

glob exclude pattern

I have a directory with a bunch of files inside: eee2314, asd3442 ... and eph. I want to exclude all files that start with eph with the glob function. How can I do it?...

len() of a numpy array in python

If I use len(np.array([[2,3,1,0], [2,3,1,0], [3,2,1,1]])), I get back 3. Why is there no argument for len() about which axis I want the length of in multidimensional arrays? This is alarming. Is there an alternative?...

Angular ng-repeat Error "Duplicates in a repeater are not allowed."

I am defining a custom filter like so: <div class="idea item" ng-repeat="item in items" isoatom> <div class="section comment clearfix" ng-repeat="comment in item.comments | range:1:2"> .... </div> </div> ...

Getting value of HTML text input

Say I have an HTML form like this to collect an email from a website visitor: <form name="input" action="handle_email.php" method="post"> Email: <input type="text" name="email" /> <input type="submit" value="Newsletter" /> </for...

Linux command line howto accept pairing for bluetooth device without pin

Is there a way to pair a device in linux without requiring a pin(for testing purposes so I need it to be done w/out human interaction, assuming you have root access)? bluez-simple-agent seems to require a pin except with some simple devices such as ...

Javascript - object key->value

var obj = { a: "A", b: "B", c: "C" } console.log(obj.a); // return string : A but i want to get by through a variable like this var name = "a"; console.log(obj.name) // but return undefined How to do this?...

Best way to copy a database (SQL Server 2008)

Dumb question - what's the best way to copy instances in an environment where I want to refresh a development server with instances from a production server? I've done backup-restore, but I've heard detach-copy-attach and one guy even told me he w...

Looking to understand the iOS UIViewController lifecycle

Could you explain me the correct manner to manage the UIViewController lifecycle? In particular, I would like to know how to use Initialize, ViewDidLoad, ViewWillAppear, ViewDidAppear, ViewWillDisappear, ViewDidDisappear, ViewDidUnload and Dispose m...

How to sort alphabetically while ignoring case sensitive?

I have this code, but works only for lower case letters. I want this to sort the list while ignoring the upper case letters.. package sortarray.com; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.os...

Change primary key column in SQL Server

UPDATE Here are the constraints as a result of the query SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME = 'history' CONSTRAINT_NAME COLUMN_NAME ORDINAL_POSITION PK_history userKey 1 PK_history name ...

How can I write maven build to add resources to classpath?

I am building a jar using maven with simple maven install. If I add a file to src/main/resources it can be found on the classpath but it has a config folder where I want that file to go but moving it inside the config folder makes it disappear from t...

Turning off auto indent when pasting text into vim

I am making the effort to learn Vim. When I paste code into my document from the clipboard, I get extra spaces at the start of each new line: line line line I know you can turn off auto indent but I can't get it to work because I have some ...

How to force cp to overwrite without confirmation

I'm trying to use the cp command and force an overwrite. I have tried cp -rf /foo/* /bar, but I am still prompted to confirm each overwrite....

How to push changes to github after jenkins build completes?

I have a jenkins job that clones the repository from github, then runs the powershell script that increments the version number in the file. I'm now trying to publish that update file back to the original repository on github, so when developer pulls...

Extract regression coefficient values

I have a regression model for some time series data investigating drug utilisation. The purpose is to fit a spline to a time series and work out 95% CI etc. The model goes as follows: id <- ts(1:length(drug$Date)) a1 <- ts(drug$Rate) a2 <- ...

Sorting arrays in NumPy by column

How can I sort an array in NumPy by the nth column? For example, a = array([[9, 2, 3], [4, 5, 6], [7, 0, 5]]) I'd like to sort rows by the second column, such that I get back: array([[7, 0, 5], [9, 2, 3], [4, ...

How can I reorder a list?

If I have a list [a,b,c,d,e] how can I reorder the items in an arbitrary manner like [d,c,a,b,e]? Edit: I don't want to shuffle them. I want to re-order them in a predefined manner. (for example, I know that the 3rd element in the old list should be...

How to uncheck a checkbox in pure JavaScript?

Here is the HTML Code: <div class="text"> <input value="true" type="checkbox" checked="" name="copyNewAddrToBilling"><label> I want to change the value to false. Or just uncheck the checkbox. I'd like to do this in pure JavaSc...

Loop over array dimension in plpgsql

In plpgsql, I want to get the array contents one by one from a two dimension array. DECLARE m varchar[]; arr varchar[][] := array[['key1','val1'],['key2','val2']]; BEGIN for m in select arr LOOP raise NOTICE '%',m; END LOOP; END; But...

How to pick element inside iframe using document.getElementById

I have a iframe like this <iframe name="myframe1" id="myframe1" width="100%" height="100%" src="a.html"> <html> <head></head> <frameset name="myframe2" cols="0%, 100%" border="0" frameBorder="0" frameSpacing="0">...

overlay two images in android to set an imageview

I am trying to overlay two images in my app, but they seem to crash at my canvas.setBitmap() line. What am I doing wrong? private void test() { Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.t); Bitmap mBitmap2 = Bi...

Age from birthdate in python

How can I find an age in python from today's date and a persons birthdate? The birthdate is a from a DateField in a Django model....

Convert JSON string to array of JSON objects in Javascript

I would like to convert this string {"id":1,"name":"Test1"},{"id":2,"name":"Test2"} to array of 2 JSON objects. How should I do it? best...

How can I use String substring in Swift 4? 'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator

I have the following simple code written in Swift 3: let str = "Hello, playground" let index = str.index(of: ",")! let newStr = str.substring(to: index) From Xcode 9 beta 5, I get the following warning: 'substring(to:)' is deprecated: Please u...

Format numbers in thousands (K) in Excel

In MS Excel, I would like to format a number in order to show only thousands and with 'K' in from of it, so the number 123000 will be displayed in the cell as 123K It is easy to format to show only thousands (123), but I'd like to add the K symbol i...

Android: Getting a file URI from a content URI?

In my app the user is to select an audio file which the app then handles. The problem is that in order for the app to do what I want it to do with the audio files, I need the URI to be in file format. When I use Android's native music player to brows...

How do I pick randomly from an array?

I want to know if there is a much cleaner way of doing this. Basically, I want to pick a random element from an array of variable length. Normally, I would do it like this: myArray = ["stuff", "widget", "ruby", "goodies", "java", "emerald", "etc" ]...

Render partial from different folder (not shared)

How can I have a view render a partial (user control) from a different folder? With preview 3 I used to call RenderUserControl with the complete path, but whith upgrading to preview 5 this is not possible anymore. Instead we got the RenderPartial met...

In log4j, does checking isDebugEnabled before logging improve performance?

I am using Log4J in my application for logging. Previously I was using debug call like: Option 1: logger.debug("some debug text"); but some links suggest that it is better to check isDebugEnabled() first, like: Option 2: boolean debugEnabled =...

No value accessor for form control with name: 'recipient'

I got this error after upgrading to Angular 2 Rc.5. This is my component template: <md-input [(ngModel)]="recipient" name="recipient" placeholder="Name" class="col-sm-4" (blur)="addRecipient(recipient)"> </md-input> ...

Shell script variable not empty (-z option)

How to make sure a variable is not empty with the -z option ? errorstatus="notnull" if [ !-z $errorstatus ] then echo "string is not null" fi It returns the error : ./test: line 2: [: !-z: unary operator expected ...

An error when I add a variable to a string

I have this line of SQL: $sql = "SELECT ID, ListStID, ListEmail, Title FROM $entry_database WHERE ID = '". $ReqBookID ."'"; $result = mysqli_query($conn, $sql); As you can see, I am selecting an entry's ID, ListStID, ListEmail and Title Column if ...

How do I do base64 encoding on iOS?

I'd like to do base64 encoding and decoding, but I could not find any support from the iPhone SDK. How can I do base64 encoding and decoding with or without a library?...

Return value in SQL Server stored procedure

I have a stored procedure that has an if statement in it. If the number of rows counted is greater than 0 then it should set the only output parameter @UserId to 0 However it only returns a value in the second part of the query. @EmailAddress varch...

How to initialize a List<T> to a given size (as opposed to capacity)?

.NET offers a generic list container whose performance is almost identical (see Performance of Arrays vs. Lists question). However they are quite different in initialization. Arrays are very easy to initialize with a default value, and by definitio...

Why Would I Ever Need to Use C# Nested Classes

I'm trying to understand about nested classes in C#. I understand that a nested class is a class that is defined within another class, what I don't get is why I would ever need to do this....

PHP validation/regex for URL

I've been looking for a simple regex for URLs, does anybody have one handy that works well? I didn't find one with the zend framework validation classes and have seen several implementations....

Can I use an HTML input type "date" to collect only a year?

I have a field that is required to collect a year from the user (i.e. a date with a year resolution - for ease of storage I'd prefer to store an actual date value and not a number). I would like to use the date input UI supported by modern browsers...

Installing pip packages to $HOME folder

Is it possible? When installing pip, install the python packages inside my $HOME folder. (for example, I want to install mercurial, using pip, but inside $HOME instead of /usr/local) I'm with a mac machine and just thought about this possibility, in...

Reading from memory stream to string

I am trying to write an object to an Xml string and take that string and save it to a DB. But first I need to get the string... private static readonly Encoding LocalEncoding = Encoding.UTF8; public static string SaveToString<T> (T se...

What is the preferred Bash shebang?

Is there any Bash shebang objectively better than the others for most uses? #!/usr/bin/env bash #!/bin/bash #!/bin/sh #!/bin/sh - etc I vaguely recall a long time ago hearing that adding a dash to the end prevents someone passing a command to you...

Sorting objects by property values

How to implement the following scenario using Javascript only: Create a car object with properties (top speed, brand, etc.) Sort a list of cars ordered by those properties ...

PHP Curl And Cookies

I have some problem with PHP Curl and cookies authentication. I have a file Connector.php which authenticates users on another server and returns the cookie of the current user. The Problem is that I want to authenticate thousands of users with cur...

MySQL Workbench Edit Table Data is read only

When trying Edit Table Data in MySQL Workbench 5.2.37, its in read only mode. It is editable only if the table has a primary key. Is there any fix to deal with table without primary key?? Thanks As one of the suggestion I tried upgrading WB 5.2.4...

Skip first line(field) in loop using CSV file?

Possible Duplicate: When processing CSV data, how do I ignore the first line of data? I am using python to open CSV file. I am using formula loop but I need to skip the first row because it has header. So far I remember was something like t...

Excel 2010: how to use autocomplete in validation list

I'm using a large validation list on which a couple of vlookup() functions depend. This list is getting larger and larger. Is there a way to type the first letters of the list item I'm looking for, instead of manually scrolling down the list searchin...

Python: subplot within a loop: first panel appears in wrong position

I am fairly new to Python and come from a more Matlab point of view. I am trying to make a series of 2 x 5 panel contourf subplots. My approach so far has been to convert (to a certain degree) my Matlab code to Python and plot my subplots within a...

Download all stock symbol list of a market

I need to download in some way a list of all stock symbol of specified market. I've found in this link ho can I do it someway. It uses following link in order to retrieve stock list that statisfies some parameters: https://www.google.com/finance?...

Making the Android emulator run faster

The Android emulator is a bit sluggish. For some devices, like the Motorola Droid and the Nexus One, the app runs faster in the actual device than the emulator. This is a problem when testing games and visual effects. How do you make the emulator ru...

how to re-format datetime string in php?

I receive a datetime from a plugin. I put it into a variable: $datetime = "20130409163705"; That actually translates to yyyymmddHHmmss. I would need to display this to the user as a transaction time but it doesn't look proper. I would like to a...

Sequel Pro Alternative for Windows

Well my macbook pro is kind of not cutting it for me anymore and I have a perfectly good Windows Laptop I would actually rather use but I cannot find a reliable replacement for my SQL client. So I am looking for a replacement for SequelPro for Window...

How can I have linebreaks in my long LaTeX equations?

My equation is very long. How do I get it to continue on the next line rather than go off the page?...

Relative instead of Absolute paths in Excel VBA

I have written an Excel VBA macro which imports data from a HTML file (stored locally) before performing calculations on the data. At the moment the HTML file is referred to with an absolute path: Workbooks.Open FileName:="C:\Documents and Settings...

Simplest way to download and unzip files in Node.js cross-platform?

Just looking for a simple solution to downloading and unzipping .zip or .tar.gz files in Node.js on any operating system. Not sure if this is built in or I have to use a separate library. Any ideas? Looking for just a couple lines of code so when ...

How can I get relative path of the folders in my android project?

How can I get the relative path of the folders in my project using code? I've created a new folder in my project and I want its relative path so no matter where the app is, the path will be correct. I'm trying to do it in my class which extends and...

Nginx no-www to www and www to no-www

I am using nginx on Rackspace cloud following a tutorial and having searched the net and so far can't get this sorted. I want www.mysite.com to go to mysite.com as normal in .htaccess for SEO and other reasons. My /etc/nginx/sites-available/www.exa...

Bootstrap 4 align navbar items to the right

How do I align a navbar item to right? I want to have the login and register to the right. But everything I try does not seem to work. This is what I have tried so far: <div> around the <ul> with the atribute: style="float: right" ...

How to remove leading and trailing zeros in a string? Python

I have several alphanumeric strings like these listOfNum = ['000231512-n','1209123100000-n00000','alphanumeric0000', '000alphanumeric'] The desired output for removing trailing zeros would be: listOfNum = ['000231512-n','1209123100000-n','alphanu...

MySQLi prepared statements error reporting

I'm trying to get my head around MySQli and I'm confused by the error reporting. I am using the return value of the MySQLi 'prepare' statement to detect errors when executing SQL, like this: $stmt_test = $mysqliDatabaseConnection->stmt_init(); i...

Oracle - how to remove white spaces?

I am running this statement: select trim(a),trim(b) from table x; Even though I used the trim() statement, my output looks like this: A B ___ ...

Node.js https pem error: routines:PEM_read_bio:no start line

I am messing with login form right now with node.js, I tried creating a pem key and csr using openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem However I been getting errors for running node server.js Here is my server.js va...

Append a single character to a string or char array in java?

Is it possible to append a single character to the end of array or string in java. Example: private static void /*methodName*/ () { String character = "a" String otherString = "helen"; //this is where i nee...

Android get current Locale, not default

How do I get the user's current Locale in Android? I can get the default one, but this may not be the current one correct? Basically I want the two letter language code from the current locale. Not the default one. There is no Locale.current()...

CSS @media print issues with background-color;

I'm new here at this company and we have a product that uses miles of css. I'm attempting to make a printable stylesheet for our app but I'm having issues with background-color in @media print. @media print { #header{display:none;} #...

How can I Insert data into SQL Server using VBNet

I am new to vb.net I need to insert data in table by using vb.net please can any one help I have tried this Here I tried Sample Code I got this exception Column name or number of supplied values does not match table definition. thanks advance ...

How (and why) to use display: table-cell (CSS)

I have a site with a very active background (I'm talking 6 or so different z-indexes here 2 with animations). I wanted a in the foreground that had content but wanted a "window" through to the background in it. Some problems I had: you can't "punc...

Select entries between dates in doctrine 2

I will go insane with this minimal error that I'm not getting fix. I want to select entries between two days, the examples below ilustrate all my fails: opt 1. $qb->where('e.fecha > ' . $monday->format('Y-m-d')); $qb->andWhere('e.fecha ...

Emulator error: This AVD's configuration is missing a kernel file

This problem was discovered when I tried to run the Android emulator in Eclipse. Can't figure out what happened. I searched online for the solution, but it seemed to be vague and I don't understand clearly. I was following the steps to install the A...

How to search for an element in an stl list?

Is there a find() function for list as there was in vector? Is there a way to do that in list?...

Sort hash by key, return hash in Ruby

Would this be the best way to sort a hash and return Hash object (instead of Array): h = {"a"=>1, "c"=>3, "b"=>2, "d"=>4} # => {"a"=>1, "c"=>3, "b"=>2, "d"=>4} Hash[h.sort] # => {"a"=>1, "b"=>2, "c"=>3, "d"=&g...

Specific Time Range Query in SQL Server

I'm trying to query a specific range of time: i.e. 3/1/2009 - 3/31/2009 between 6AM-10PM each day Tues/Wed/Thurs only I've seen that you can get data for a particular range, but only for start to end and this is quite a bit more specific. I di...

Creating a singleton in Python

This question is not for the discussion of whether or not the singleton design pattern is desirable, is an anti-pattern, or for any religious wars, but to discuss how this pattern is best implemented in Python in such a way that is most pythonic. In ...

How to fix a collation conflict in a SQL Server query?

I am working on a view, wherein I am using an inner join on two tables which are from two different servers. We are using linked server. When running the query I am getting this message: Cannot resolve the collation conflict between "SQL_Latin1_G...

Caesar Cipher Function in Python

I'm trying to create a simple Caesar Cipher function in Python that shifts letters based on input from the user and creates a final, new string at the end. The only problem is that the final cipher text shows only the last shifted character, not an e...

Creating a button in Android Toolbar

How can I create a button inside Android's Toolbar that looks like this iOS example? ...

Prevent jQuery UI dialog from setting focus to first textbox

I have setup a jQuery UI modal dialog to display when a user clicks a link. There are two textboxes (I only show the code for 1 for brevity) in that dialog div tag and it is changed to be a jQuery UI DatePicker textbox that reacts on focus. The pro...

how to add background image to activity?

using theme or ImageView ?...

Which language uses .pde extension?

While searching for an implementation of the Barnsley's Fern fractal I came across a implementation that has .pde extension. Which programming language uses this extension? Implementation Page...

Cleaning `Inf` values from an R dataframe

In R, I have an operation which creates some Inf values when I transform a dataframe. I would like to turn these Inf values into NA values. The code I have is slow for large data, is there a faster way of doing this? Say I have the following da...

How to implement the ReLU function in Numpy

I want to make a simple neural network which uses the ReLU function. Can someone give me a clue of how can I implement the function using numpy....

Package name does not correspond to the file path - IntelliJ

I'm trying to import a project from VCS (well, I'm doing it for the first time actually) and this is my (imported) project's structure: BTW. this screen is made after many tries of changing these directories' properties (in their context menus). ...

encapsulation vs abstraction real world example

For an example of encapsulation i can think of the interaction between a user and a mobile phone. The user does not need to know the internal working of the mobile phone to operate, so this is called abstraction. But where does encapsulation fit in t...

Printing list elements on separated lines in Python

I am trying to print out Python path folders using this: import sys print sys.path The output is like this: >>> print sys.path ['.', '/usr/bin', '/home/student/Desktop', '/home/student/my_modules', '/usr/lib/pyth on2.6', '/usr/lib/python...

Replace line break characters with <br /> in ASP.NET MVC Razor view

I have a textarea control that accepts input. I am trying to later render that text to a view by simply using: @Model.CommentText This is properly encoding any values. However, I want to replace the line break characters with <br /> and ...

Split code over multiple lines in an R script

I want to split a line in an R script over multiple lines (because it is too long). How do I do that? Specifically, I have a line such as setwd('~/a/very/long/path/here/that/goes/beyond/80/characters/and/then/some/more') Is it possible to split t...

IF EXISTS, THEN SELECT ELSE INSERT AND THEN SELECT

How do you say the following in Microsoft SQL Server 2005: IF EXISTS (SELECT * FROM Table WHERE FieldValue='') THEN SELECT TableID FROM Table WHERE FieldValue='' ELSE INSERT INTO TABLE(FieldValue) VALUES('') SELECT TableID FROM Table WHERE ...

Getting an "ambiguous redirect" error

The following line in my Bash script echo $AAAA" "$DDDD" "$MOL_TAG >> ${OUPUT_RESULTS} gives me this error: line 46: ${OUPUT_RESULTS}: ambiguous redirect Why?...

How to map to multiple elements with Java 8 streams?

I have a class like this: class MultiDataPoint { private DateTime timestamp; private Map<String, Number> keyToData; } and i want to produce , for each MultiDataPoint class DataSet { public String key; List<DataPoi...

Git diff says subproject is dirty

I have just run a git diff, and I am getting the following output for all of my approx 10 submodules diff --git a/.vim/bundle/bufexplorer b/.vim/bundle/bufexplorer --- a/.vim/bundle/bufexplorer +++ b/.vim/bundle/bufexplorer @@ -1 +1 @@ -Subproject ...

PHP upload image

Alright I have way to much time invested in this. I am new to PHP programming and trying to grasp the basics, but I am a little lost as of last night I was able to get a PHP form to upload basic data like a name address and stuff to my (MySQL) server...

How can I install a .ipa file to my iPhone simulator

I have an iphone simulator running on my Mac. I have a .ipa file, can you please tell me how can I install it on the simulator?...

How to detect if a string contains at least a number?

How to detect if a string contains at least a number (digit) in SQL server 2005?...

How do I programmatically set device orientation in iOS 7?

I am working on an iPad app, using AutoLayout, where if the user enables a certain mode ("heads-up" mode), I want to support only portrait (or portrait upside down) orientation, and furthermore, if the device is in landscape, I'd like to automaticall...

Can an interface extend multiple interfaces in Java?

Can an interface extend multiple interfaces in Java? This code appears valid in my IDE and it does compile: interface Foo extends Runnable, Set, Comparator<String> { } but I had heard that multiple inheritance was not allowed in Java. Why do...

Font Awesome icon inside text input element

I am trying to insert a user icon inside username input field. I've tried one of the solution from the similar question knowing that background-image property won't work since Font Awesome is a font. The following is my approach and I can't get t...

git replace local version with remote version

How can I tell git to ignore my local file and take the one from my remote branch without trying to merge and causing conflicts?...

How do I remove a file from the FileList

I'm building a drag-and-drop-to-upload web application using HTML5, and I'm dropping the files onto a div and of course fetching the dataTransfer object, which gives me the FileList. Now I want to remove some of the files, but I don't know how, or i...

Simple and clean way to convert JSON string to Object in Swift

I have been searching for days to convert a fairly simple JSON string to an object type in Swift but with no avail. Here is the code for web service call: func GetAllBusiness() { Alamofire.request(.GET, "http://MyWebService/").responseStr...

Selecting multiple columns in a Pandas dataframe

I have data in different columns, but I don't know how to extract it to save it in another variable. index a b c 1 2 3 4 2 3 4 5 How do I select 'a', 'b' and save it in to df1? I tried df1 = df['a':'b'] df1 = df.ix[:, 'a':'b']...

Viewing all defined variables

I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such). Is there a way, an...

Set cursor position on contentEditable <div>

I am after a definitive, cross-browser solution to set the cursor/caret position to the last known position when a contentEditable='on' <div> regains focus. It appears default functionality of a content editable div is to move the caret/cursor to...

How to directly execute SQL query in C#?

Ok, I have an old batch file that does exactly what I need. However, with out new administration we can't run the batch file anymore so I need to start up with C#. I'm using Visual Studio C# and already have the forms set up for the application I n...

ZIP Code (US Postal Code) validation

I thought people would be working on little code projects together, but I don't see them, so here's an easy one: Code that validates a valid US Zip Code. I know there are ZIP code databases out there, but there are still uses, like web pages, quick ...

How to remove specific object from ArrayList in Java?

How can I remove specific object from ArrayList? Suppose I have a class as below: import java.util.ArrayList; public class ArrayTest { int i; public static void main(String args[]){ ArrayList<ArrayTest> test=new ArrayList&...

copy-item With Alternate Credentials

I'm using the CTP of powershell v2. I have a script written that needs to go out to various network shares in our dmz and copy some files. However, the issue I have is that evidently powershell's cmdlets such as copy-item, test-path, etc do not suppo...

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

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

Format Date as "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"

I need to format a date as yyyy-MM-dd'T'HH:mm:ss.SSS'Z' as specified by Parse's REST API for Facebook. I was wondering what the most lightweight solution to this would be....

Python: Pandas Dataframe how to multiply entire column with a scalar

How do I multiply each element of a given column of my dataframe with a scalar? (I have tried looking on SO, but cannot seem to find the right solution) Doing something like: df['quantity'] *= -1 # trying to multiply each row's quantity column wit...

How do I check if a string is valid JSON in Python?

In Python, is there a way to check if a string is valid JSON before trying to parse it? For example working with things like the Facebook Graph API, sometimes it returns JSON, sometimes it could return an image file....

Simple file write function in C++

I have this code: // basic file operations #include <iostream> #include <fstream> using namespace std; int main() { writeFile(); } int writeFile () { ofstream myfile; myfile.open ("example.txt"); myfile << "Writing thi...

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

Can I get div's background-image url?

I have a button of which when I click it I want to alert the background-image URL of #div1. Is it possible?...

Foreach Control in form, how can I do something to all the TextBoxes in my Form?

How can I use a Foreach Statement to do something to my TextBoxes? foreach (Control X in this.Controls) { Check if the controls is a TextBox, if it is delete it's .Text letters. } ...

Difference between webdriver.Dispose(), .Close() and .Quit()

What is the difference between these Webdriver.Close() Webdriver.Quit() Webdriver.Dispose() Which one to be used and when?...

How can I see the current value of my $PATH variable on OS X?

$ $PATH returns: -bash: /usr/local/share/npm/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/local/sbin:~/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bi...

SQL - IF EXISTS UPDATE ELSE INSERT Syntax Error

I have the following SQL query: IF EXISTS(SELECT * FROM component_psar WHERE tbl_id = '2' AND row_nr = '1') UPDATE component_psar SET col_1 = '1', col_2 = '1', col_3 = '1', col_4 = '1', col_5 = '1', col_6 = '1', unit = '1'...

Server returned HTTP response code: 400

I am trying to get an InputStream from a URL. The URL can be a opened from Firefox. It returns a json and I have installed an addon for viewing json in Firefox so I can view it there. So I tried to get it from Java by: URL url = new URL(urlString);...

Array Length in Java

I declared an array as shown below: int[] arr = new int[10]; Then I assigned following values to the array: arr[0] = 1; arr[1] = 2; arr[2] = 3; arr[3] = 4; Then I declared and initialized an integer variable: int arrayLength = arr.length; Th...

How to edit a text file in my terminal

I'm using Linux mint and using the vi command to create text files, now that I created a text file and saved it. How do I get back into to edit the text file again? vi helloWorld.txt ...

Convert object of any type to JObject with Json.NET

I often need to extend my Domain model with additional info before returning it to the client with WebAPI. To avoid creation of ViewModel I thought I could return JObject with additional properties. I could not however find direct way to convert obje...

PHP: How to check if a date is today, yesterday or tomorrow

I would like to check, if a date is today, tomorrow, yesterday or else. But my code doesn't work. Code: $timestamp = "2014.09.02T13:34"; $date = date("d.m.Y H:i"); $match_date = date('d.m.Y H:i', strtotime($timestamp)); if($date == $match_date) { ...

Java: splitting a comma-separated string but ignoring commas in quotes

I have a string vaguely like this: foo,bar,c;qual="baz,blurb",d;junk="quux,syzygy" that I want to split by commas -- but I need to ignore commas in quotes. How can I do this? Seems like a regexp approach fails; I suppose I can manually scan and en...

Suppress Scientific Notation in Numpy When Creating Array From Nested List

I have a nested Python list that looks like the following: my_list = [[3.74, 5162, 13683628846.64, 12783387559.86, 1.81], [9.55, 116, 189688622.37, 260332262.0, 1.97], [2.2, 768, 6004865.13, 5759960.98, 1.21], [3.74, 4062, 3263822121.39, 30668690...

Could not load type from assembly error

I have written the following simple test in trying to learn Castle Windsor's Fluent Interface: using NUnit.Framework; using Castle.Windsor; using System.Collections; using Castle.MicroKernel.Registration; namespace WindsorSample { public class ...

How do I calculate the normal vector of a line segment?

Suppose I have a line segment going from (x1,y1) to (x2,y2). How do I calculate the normal vector perpendicular to the line? I can find lots of stuff about doing this for planes in 3D, but no 2D stuff. Please go easy on the maths (links to worked e...

How to select an item from a dropdown list using Selenium WebDriver with java?

How can I select an item from a drop down list like gender (eg male, female) using Selenium WebDriver with Java? I have tried this WebElement select = driver.findElement(By.id("gender")); List<WebElement> options = select.findElements(By.tagN...

How to pass boolean parameter value in pipeline to downstream jobs?

I'm using Jenkins v2.1 with the integrated delivery pipeline feature (https://jenkins.io/solutions/pipeline/) to orchestrate two existing builds (build and deploy). In my parameterized build I have 3 user parameters setup, which also needs to be sel...

How to check if an element is visible with WebDriver

With WebDriver from Selenium 2.0a2 I am having trouble checking if an element is visible. WebDriver.findElement returns a WebElement, which unfortunately doesn't offer an isVisible method. I can go around this by using WebElement.clear or WebElement...

How to clear all input fields in bootstrap modal when clicking data-dismiss button?

How to clear all input fields in a Bootstrap V3 modal when clicking the data-dismiss button?...

How to resize an image with OpenCV2.0 and Python2.6

I want to use OpenCV2.0 and Python2.6 to show resized images. I used and adopted this example but unfortunately, this code is for OpenCV2.1 and does not seem to be working on 2.0. Here my code: import os, glob import cv ulpath = "exampleshq/&qu...

Is there a method that calculates a factorial in Java?

I didn't find it, yet. Did I miss something? I know a factorial method is a common example program for beginners. But wouldn't it be useful to have a standard implementation for this one to reuse? I could use such a method with standard types (Eg. i...

How to evaluate a math expression given in string form?

I'm trying to write a Java routine to evaluate math expressions from String values like: "5+3" "10-40" "(1+10)*3" I want to avoid a lot of if-then-else statements. How can I do this?...

Scale image to fit a bounding box

Is there a css-only solution to scale an image into a bounding box (keeping aspect-ratio)? This works if the image is bigger than the container: img { max-width: 100%; max-height: 100%; } Example: Use case 1 (works): http://jsfiddle.net/Jp5A...

Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from/to central (http://repo1.maven.org/maven2)

I have created a new maven project in SpringSource Tool Suite. I am getting this error in my new maven project. Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from http://repo1.maven.org/maven2 was cached in the ...

How to send JSON instead of a query string with $.ajax?

Can someone explain in an easy way how to make jQuery send actual JSON instead of a query string? $.ajax({ url : url, dataType : 'json', // I was pretty sure this would do the trick data : data, type : 'POST', comple...

How can I find out what version of git I'm running?

I'm trying to follow some tutorials to learn how to use Git but some of the instructions are for specific versions. Is there a command that I can use find out what version I have installed?...

Is it possible to pass parameters programmatically in a Microsoft Access update query?

I have a query that's rather large, joining over a dozen tables, and I want to pull back records based on an id field (e.g.: between nStartID and nEndID). I created two parameters and tested them as criteria and they work fine. The issue is, I need...

mysqldump & gzip commands to properly create a compressed file of a MySQL database using crontab

I am having problems with getting a crontab to work. I want to automate a MySQL database backup. The setup: Debian GNU/Linux 7.3 (wheezy) MySQL Server version: 5.5.33-0+wheezy1(Debian) directories user, backup and backup2 have 755 permission The...

How do I list all the files in a directory and subdirectories in reverse chronological order?

I want to do something like ls -t but also have the files in subdirectories included. But the problem is that I don't want the output formated like ls -R does, which is like this: [test]$ ls -Rt b testdir test ./testdir: a I want it to be f...

How to execute raw queries with Laravel 5.1?

So I have this tiny query to run on my DB and it works fine in MySQL Workbench. Basically, a SELECT with LEFT JOIN and UNION with LEFT JOIN again. SELECT cards.id_card, cards.hash_card, cards.`table`, users.name, 0 as total, ...

Add CSS class to a div in code behind

I have a div and I am trying to add a CSS class to it in code but I receive the following error when I try Property or indexer 'System.Web.UI.HtmlControls.HtmlControl.Style' cannot be assigned to -- it is read only I am using the following code: ...

Understanding Apache's access log

What do each of the things in this line from my access log mean? 127.0.0.1 - - [05/Feb/2012:17:11:55 +0000] "GET / HTTP/1.1" 200 140 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.5 Safari/535.19"...

Java - Reading XML file

I am trying to read in some data from an XML file and having some trouble, the XML I have is as follows: <xml version="1.0" encoding="UTF-8"?> <EmailSettings> <recipient>[email protected]</recipient> <sender>test2@...

Adding minutes to date time in PHP

I'm really stuck with adding X minutes to a datetime, after doing lots of google'ing and PHP manual reading, I don't seem to be getting anywhere. The date time format I have is: 2011-11-17 05:05: year-month-day hour:minute Minutes to add will jus...

Tests not running in Test Explorer

I am currently working on a solution that has currently 32 Unittests. I have been working with the resharper test runner - which works fine. All tests are running, all tests are showing the right test outcome. However, the tests are not running when ...

How to call Android contacts list?

I'm making an Android app, and need to call the phone's contact list. I need to call the contacts list function, pick a contact, then return to my app with the contact's name. Here's the code I got on the internet, but it doesnt work. import android...

How to handle login pop up window using Selenium WebDriver?

How to handle the login pop up window using Selenium Webdriver? I have attached the sample screen here. How can I enter/input Username and Password to this login pop up/alert window? Thanks & Regards, ...

How do I export html table data as .csv file?

I have a table of data in an html table on a website and need to know how to export that data as .csv file. How would this be done?...

Jquery - Uncaught TypeError: Cannot use 'in' operator to search for '324' in

I'm trying to send a Get request by ajax and output json data that is returned by server in html. But, I got this error. Uncaught TypeError: Cannot use 'in' operator to search for '324' in [{"id":50,"name":"SEO"},{"id":22,"name":"LPO",}] This is...

How do I analyze a .hprof file?

I have a production server running with the following flag: -XX:+HeapDumpOnOutOfMemoryError Last night it generated a java-38942.hprof file when our server encountered a heap error. It turns out that the developers of the system knew of the flag but...

Vertically center text in a 100% height div?

I am working with a div that is 100% of the parent divs height. The div only contains a single line of text. The div cannot have a fixed height. So my question is. How do I vertically center the line of text? I have tried using: display: table-...

Switching users inside Docker image to a non-root user

I'm trying to switch user to the tomcat7 user in order to setup SSH certificates. When I do su tomcat7, nothing happens. whoami still ruturns root after doing su tomcat7 Doing a more /etc/passwd, I get the following result which clearly shows that...

How to pattern match using regular expression in Scala?

I would like to be able to find a match between the first letter of a word, and one of the letters in a group such as "ABC". In pseudocode, this might look something like: case Process(word) => word.firstLetter match { case([a-c][A-C]) =...

IOException: The process cannot access the file 'file path' because it is being used by another process

I have some code and when it executes, it throws a IOException, saying that The process cannot access the file 'filename' because it is being used by another process What does this mean, and what can I do about it?...

Double % formatting question for printf in Java

%s is a string in printf, and %d is a decimal I thought...yet when putting in writer.printf("%d dollars is the balance of %s\r\n", bal, nm); ..an exception is thrown telling me that %d != lang.double. Ideas?...

How do I set vertical space between list items?

Within a <ul> element, clearly the vertical spacing between lines can be formatted with the line-height attribute. My question is, within a <ul> element, how do I set the vertical spacing between the list items?...

Check if a specific value exists at a specific key in any subarray of a multidimensional array

I need to search a multidimensional array for a specific value in any of the indexed subarrays. In other words, I need to check a single column of the multidimensional array for a value. If the value exists anywhere in the multidimensional array, I...

How do I change a single value in a data.frame?

Could anyone explain how to change a single cell in a data.frame to something else. Basically I just want to rename that one cell, not all cells which matches it. I can´t use the edit() command because it will screw up my script since im using the d...

How can I access global variable inside class in Python

I have this: g_c = 0 class TestClass(): global g_c def run(self): for i in range(10): g_c = 1 print(g_c) t = TestClass() t.run() print(g_c) how can I actually modify my global variable g_c?...

In Python, how do I convert all of the items in a list to floats?

I have a script which reads a text file, pulls decimal numbers out of it as strings and places them into a list. So I have this list: ['0.49', '0.54', '0.54', '0.54', '0.54', '0.54', '0.55', '0.54', '0.54', '0.54', '0.55', '0.55', '0.55', '0.54'...

How to add extra whitespace in PHP?

I was wondering how can I add extra whitespace in php is it something like \s please help thanks. Is there a tutorial that list these kind of things thanks....

Get IP address of visitors using Flask for Python

I'm making a website where users can log on and download files, using the Flask micro-framework (based on Werkzeug) which uses Python (2.6 in my case). I need to get the IP address of users when they log on (for logging purposes). Does anyone know ...

How to convert string to XML using C#

Global variable m_xDoc I have a property of public XmlDocument xDoc { get {return m_xDoc; } set {value = m_xDoc; } } string xml = "<head><body><Inner> welcome </head></Inner><Outer> Bye</...

How to get value of checked item from CheckedListBox?

I have used a CheckedListBox over my WinForm in C#. I have bounded this control as shown below - chlCompanies.DataSource = dsCompanies.Tables[0]; chlCompanies.DisplayMember = "CompanyName"; chlCompanies.ValueMember = "ID"; I can get the indices of...

Writing image to local server

Update The accepted answer was good for last year but today I would use the package everyone else uses: https://github.com/mikeal/request Original I'm trying to grab google's logo and save it to my server with node.js. This is what I have right...

Access-control-allow-origin with multiple domains

In my web.config I would like to specify more than one domain for the access-control-allow-origin directive. I don't want to use *. I've tried this syntax: <add name="Access-Control-Allow-Origin" value="http://localhost:1506, http://localhost:1...

How to check whether a string contains a substring in Ruby

I have a string variable with content: varMessage = "hi/thsid/sdfhsjdf/dfjsd/sdjfsdn\n" "/my/name/is/balaji.so\n" "call::myFunction(int const&)\n" "void::secondFunction(char const&)\n" ...

Auto refresh page every 30 seconds

I have a JSP page which has to display the status of various jobs that are running. Some of these jobs take time, so it takes a while for their status to change from processing to complete. Is it a good idea to have a javascript function that would ...

Adding integers to an int array

I am trying to add integers into an int array, but Eclipse says: cannot invoke add(int) on the array type int[] Which is completely illogical to me. I also tried addElement() and addInt(), however they don't work either. public static void ma...

adb uninstall failed

I am writing some sample apps. After I debug these apps, I don't see an uninstall button in my device's application management. When I do adb uninstall, it always says Failure without any reason. In DDMS I saw that my apk is stored in /data/app/com.k...

How to measure height, width and distance of object using camera?

I referred lot many links but still I am not able to get any point from that I can start my development. I want to measure my image height, width and distance using camera. I found this app . I want to make this type of application not exactly same b...

what's the default value of char?

char c = '\u0000'; When I print c, it shows 'a' in the command line window. So what's the default value of a char type field? Someone said '\u0000' means null in unicode; is that right?...

Installing MySQL Python on Mac OS X

Long story short, when I write the following: sudo easy_install MySQL-python I get the error EnvironmentError: mysql_config not found All right, so there are plenty of threads and the like on how to fix that, so I run this code: export PATH...

HTML Display Current date

I am using website builder called 'clickfunnels', and they don't support feature that would allow me to display current date. But, I can add custom html to it. I was wondering if anyone knows how to show on website current date in format: dd/mm/yyyy...

How do I get java logging output to appear on a single line?

At the moment a default entry looks something like this: Oct 12, 2008 9:45:18 AM myClassInfoHere INFO: MyLogMessageHere How do I get it to do this? Oct 12, 2008 9:45:18 AM myClassInfoHere - INFO: MyLogMessageHere Clarification I'm using java.ut...

Detect user scroll down or scroll up in jQuery

Possible Duplicate: Differentiate between scroll up/down in jquery? Is it possible to detect if user scroll down or scroll up ? Example : $(window).scroll(function(){ // IF USER SCROLL DOWN DO ACTION // IF USER SCR...

Spring Boot java.lang.NoClassDefFoundError: javax/servlet/Filter

I Started a new project with Spring Boot 1.2.3. I'm getting error java.lang.NoClassDefFoundError: javax/servlet/Filter Gradle Dependencies: dependencies { compile("org.springframework.boot:spring-boot-starter-actuator") compile("org.spr...

jquery: get id from class selector

Is there any way that I can get the id of an element from something like: <a href="#" class="test" id="test_1">Some text</a> <a href="#" class="test" id="test_2">Some text</a> <a href="#" class="test" id="test_3">Some t...

How to create a backup of a single table in a postgres database?

Is there a way to create a backup of a single table within a database using postgres? And how? Does this also work with the pg_dump command?...

Write a number with two decimal places SQL Server

How do you write a number with two decimal places for sql server?...

Using Javascript can you get the value from a session attribute set by servlet in the HTML page

I have a servlet that forwards to a HTML page, using redirect. Because I am using ajax and php on the html page to do other functions. Can turn into a jsp. Is there a way I can get the name -"poNumber" I get in servlet in the session attributes. I wa...

How to set adaptive learning rate for GradientDescentOptimizer?

I am using TensorFlow to train a neural network. This is how I am initializing the GradientDescentOptimizer: init = tf.initialize_all_variables() sess = tf.Session() sess.run(init) mse = tf.reduce_mean(tf.square(out - out_)) train_step = tf....

How do I convert an Array to a List<object> in C#?

How do I convert an Array to a List<object> in C#?...

What is bootstrapping?

I keep seeing "bootstrapping" mentioned in discussions of application development. It seems both widespread and important, but I've yet to come across even a poor explanation of what bootstrapping actually is; rather, it seems as though everyone is ...

How do I remove a key from a JavaScript object?

Let's say we have an object with this format: var thisIsObject= { 'Cow' : 'Moo', 'Cat' : 'Meow', 'Dog' : 'Bark' }; I wanted to do a function that removes by key: removeFromObjectByKey('Cow'); ...

How to remove foreign key constraint in sql server?

I want to remove foreign key from another table so i can insert values of my choice. I am new in databases so please tell me correct sql query to drop or remove foreign key value....

How to find SQL Server running port?

Yes I read this How to find the port for MS SQL Server 2008? no luck. telnet 1433 returns connection failed, so I must specify other port. I tried to use netstat -abn but I don't see sqlservr.exe or something similar on this list. Why ...

getting "No column was specified for column 2 of 'd'" in sql server cte?

I have this query, but its not working as it should, with c as (select month(bookingdate) as duration, count(*) as totalbookings from entbookings group by month(bookingdate) ...

How do I check if an element is really visible with JavaScript?

In JavaScript, how would you check if an element is actually visible? I don't just mean checking the visibility and display attributes. I mean, checking that the element is not visibility: hidden or display: none underneath another element scrolle...

git add only modified changes and ignore untracked files

I ran "git status" and listed below are some files that were modified/or under the heading "changes not staged for commit". It also listed some untracked files that I want to ignore (I have a ".gitignore" file in these directories). I want to put th...

How can I make Flexbox children 100% height of their parent?

I'm trying to fill the vertical space of a flex item inside a Flexbox. _x000D_ _x000D_ .container {_x000D_ height: 200px;_x000D_ width: 500px;_x000D_ display: flex;_x000D_ flex-direction: row;_x000D_ }_x000D_ .flex-1 {_x000D_ width: 100px;...

jQuery $.ajax(), $.post sending "OPTIONS" as REQUEST_METHOD in Firefox

Having trouble with what I thought was a relatively simple jQuery plugin... The plugin should fetch data from a php script via ajax to add options to a <select>. The ajax request is pretty generic: $.ajax({ url: o.url, type: 'post', co...

position fixed header in html

I have a header (dynamic height) with a fixed position. I need to place the container div right below the header. As the header height is dynamic, I can't use the fixed value for top margin. How can this be done? Here's my CSS: #header-wrap ...

Making a mocked method return an argument that was passed to it

Consider a method signature like: public String myFunction(String abc); Can Mockito help return the same string that the method received?...

How to position a DIV in a specific coordinates?

I want to position a DIV in a specific coordinates ? How can I do that using Javascript ?...

How do you stretch an image to fill a <div> while keeping the image's aspect-ratio?

I need to make this image stretch to the maximum size possible without overflowing it's <div> or skewing the image. I can't predict the aspect-ratio of the image, so there's no way to know whether to use: <img src="url" style="width: 10...

How do I drag and drop files into an application?

I've seen this done in Borland's Turbo C++ environment, but I'm not sure how to go about it for a C# application I'm working on. Are there best practices or gotchas to look out for?...

jQuery click anywhere in the page except on 1 div

How can I trigger a function when I click anywhere on my page except on one div (id=menu_content) ?...

Java Thread Example?

Could anyone give an example program that explains Java Threads in a simple way? For example, say I have three threads t1, t2 and t3. I want a code that demonstrates that the threads execute simultaneously, and not sequentially....

Pass arguments to Constructor in VBA

How can you construct objects passing arguments directly to your own classes? Something like this: Dim this_employee as Employee Set this_employee = new Employee(name:="Johnny", age:=69) Not being able to do this is very annoying, and you end up ...

RuntimeError: module compiled against API version a but this version of numpy is 9

Code: import numpy as np import cv Console: >>> runfile('/Users/isaiahnields/.spyder2/temp.py', wdir='/Users/isaiahnields/.spyder2') RuntimeError: module compiled against API version a but this version of numpy is 9 Traceback (most recen...

How to float 3 divs side by side using CSS?

I know how to make 2 divs float side by side, simply float one to the left and the other to the right. But how to do this with 3 divs or should I just use tables for this purpose?...

JPanel setBackground(Color.BLACK) does nothing

I have the folowing custom JPanel and I have aded it to my frame using Netbeans GUI builder but the background won't change! I can see the circle, drawing with g.fillOval(). What's wrong? public class Board extends JPanel{ private Player player...

Database development mistakes made by application developers

What are common database development mistakes made by application developers?...

Copy/Paste from Excel to a web page

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

Mysql: Select rows from a table that are not in another

How to select all rows in one table that do not appear on another? Table1: +-----------+----------+------------+ | FirstName | LastName | BirthDate | +-----------+----------+------------+ | Tia | Carrera | 1975-09-18 | | Nikki | Taylor ...

Re-sign IPA (iPhone)

I currently build all my applications with hudson using xcodebuild followed by a xcrun without any problems I've received a couple of IPA files from different people that I would like to re-sign with a enterprise account instead of the corporate acc...

Javascript : array.length returns undefined

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

How to call Stored Procedures with EntityFramework?

I have generated an EF4 Model from a MySQL database and I have included both StoredProcedures and Tables. I know how to make regular instert/update/fetch/delete operations against the EF but I can't find my StoredProcedures. This was what I was hop...

Increase permgen space

I am working with tomcat 6.0, and while I am indexing (not while i am starting tomcat), I have a permgen space error. How could I increase that space?? Thanks...

Why is jquery's .ajax() method not sending my session cookie?

After logging in via $.ajax() to a site, I am trying to send a second $.ajax() request to that site - but when I check the headers sent using FireBug, there is no session cookie being included in the request. What am I doing wrong?...

How to check if datetime happens to be Saturday or Sunday in SQL Server 2008

Given a datetime, is there a way we can know it happens to be a Saturday or Sunday. Any ideas and suggestions are appreciated!...

SQL Server : trigger how to read value for Insert, Update, Delete

I have the trigger in one table and would like to read UserId value when a row is inserted, updated or deleted. How to do that? The code below does not work, I get error on UPDATED ALTER TRIGGER [dbo].[UpdateUserCreditsLeft] ON [dbo].[Order] ...

Converting HTML to Excel?

I know that Excel is capable of opening HTML files directly. But the content of the file will still be HTML. Is there any way I can change the contents of the file from HTML to XLS or XLSX?...

Foreign Key to multiple tables

I've got 3 relevant tables in my database. CREATE TABLE dbo.Group ( ID int NOT NULL, Name varchar(50) NOT NULL ) CREATE TABLE dbo.User ( ID int NOT NULL, Name varchar(50) NOT NULL ) CREATE TABLE dbo.Ticket ( ID int NOT NULL, ...

Html table tr inside td

I am trying to create a table in HTML. I have the following design to create. I had added a <tr> inside the <td> but somehow the table is not created as per the design. Can anyone suggest me how I can achieve this? I am unable to crea...

C# 4.0 optional out/ref arguments

Does C# 4.0 allow optional out or ref arguments?...

Android translate animation - permanently move View to new position using AnimationListener

I have android translate Animation. I have an ImageView with random generated position (next1, next2). I am calling void every 3 seconds. It generates new position of the View and then make animation and move View to destination position. Translate a...

docker error - 'name is already in use by container'

Running the docker registry with below command always throws an error: dev:tmp me$ docker run \ -d --name registry-v1 \ -e SETTINGS_FLAVOR=local \ -e STORAGE_PATH=/registry \ -e SEARCH_BACKEND=sqlalchemy \ -e LOGLEVEL=DEBUG ...

How to print exact sql query in zend framework ?

I have the following piece of code which i taken from model, ... $select = $this->_db->select() ->from($this->_name) ->where('shipping=?',$type) ->wh...

Mock HttpContext.Current in Test Init Method

I'm trying to add unit testing to an ASP.NET MVC application I have built. In my unit tests I use the following code: [TestMethod] public void IndexAction_Should_Return_View() { var controller = new MembershipController(); controller.SetFak...

Django DoesNotExist

I am having issues on trying to figure "DoesNotExist Errors", I have tried to find the right way for manage the no answer results, however I continue having issues on "DoesNotExist" or "Object hast not Attribute DoestNotExists" from django.http imp...

VBA code to set date format for a specific column as "yyyy-mm-dd"

I have a macro which I specify the date (in mm/dd/yyyy) in a textbox and I want to set this value for column A in yyyy-mm-dd format. I have the following code: Sheets("Sheet1").Range("A2", "A50000").Value = TextBox3.Value Sheet1.Range("A2", "A50000...

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

AJAX jQuery refresh div every 5 seconds

I got this code from a website which I have modified to my needs: <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> </head> <div id="links"> </div&g...

mysql: get record count between two date-time

I am stuck with a problem in MySQL. I want to get the count of records between two date-time entries. For example: I have a column in my table named 'created' having the datetime data type. I want to count records which were created date-time betwee...

"The system cannot find the file specified" when running C++ program

I installed Visual Studio 2010. I wrote a simple code which I'm sure is correct but unfortunately, when I run the code, I get the error below. Here is my code: #include<iostream> using namespace std; int main (){ cout <<"Hello StackO...

How to show/hide JPanels in a JFrame?

The application I am developing is a game. What I want to do is have JPanels that appear in the JFrame, like a text or message window, and then disappear when they are no longer used. I have designed these JPanels in Netbeans as external classes an...

How do I check if the user is pressing a key?

In java I have a program that needs to check continuously if a user is pressing a key. So In psuedocode, somthing like if (isPressing("w")) { //do somthing } Thanks in advance!...

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

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

How to change the JDK for a Jenkins job?

I have imported the jenkins jobs from existing jenkins server from another machine. But the problem is, it has the JDK referenced as per the old machines and I want to change it to use the JDK configured in my new jenkins. But I am unable to find any...

Github: Can I see the number of downloads for a repo?

In Github, is there a way I can see the number of downloads for a repo? ...

Accessing dictionary value by index in python

I would like to get the value by key index from a Python dictionary. Is there a way to get it something like this? dic = {} value_at_index = dic.ElementAt(index) where index is an integer...

Ukkonen's suffix tree algorithm in plain English

I feel a bit thick at this point. I've spent days trying to fully wrap my head around suffix tree construction, but because I don't have a mathematical background, many of the explanations elude me as they start to make excessive use of mathematical ...

Uncaught ReferenceError: jQuery is not defined

I have implemented some JavaScript on my site but I keep getting the following error messages: Uncaught ReferenceError: jQuery is not defined and Uncaught SyntaxError: Unexpected token < This is the JavaScript that I am using in the...

How to set a class attribute to a Symfony2 form input

How can I set the HTML class attribute to a form <input> using the FormBuilder in Symfony2 ? Something like this: ->add('birthdate', 'date',array( 'input' => 'datetime', 'widget' => 'single_text', 'attr' => array...

How do you decrease navbar height in Bootstrap 3?

I want to make my navbar in BS3 to be of height 20px. How do I do this? I've tried the following: .tnav .navbar .container { height: 28px; } Did nothing. .navbar-fixed-top { height: 25px; /* Whatever you want. */ } Appears to be able to in...

Checking if a number is a prime number in Python

I have written the following code, which should check if the entered number is a prime number or not, but there is an issue i couldn't get through: def main(): n = input("Please enter a number:") is_prime(n) def is_prime(a): x = True for i...

SSL Error: CERT_UNTRUSTED while using npm command

I am trying to install express framework using npm command but getting following error. error message is E:\myFindings\nodejs_programs\node>npm install -g express npm http GET https://registry.npmjs.org/express npm ERR! Error: SSL Error: CERT...

Check if a number has a decimal place/is a whole number

I am looking for an easy way in JavaScript to check if a number has a decimal place in it (in order to determine if it is an integer). For instance, 23 -> OK 5 -> OK 3.5 -> not OK 34.345 -> not OK if(number is integer) {...}...

How do I mock a static method that returns void with PowerMock?

I have a few static util methods in my project, some of them just pass or throw an exception. There are a lot of examples out there on how to mock a static method that has a return type other than void. But how can I mock a static method that returns...

select a value where it doesn't exist in another table

I have two tables Table A: ID 1 2 3 4 Table B: ID 1 2 3 I have two requests: I want to select all rows in table A that table B doesn't have, which in this case is row 4. I want to delete all rows that table B doesn't have. I am using SQL S...

Volatile vs. Interlocked vs. lock

Let's say that a class has a public int counter field that is accessed by multiple threads. This int is only incremented or decremented. To increment this field, which approach should be used, and why? lock(this.locker) this.counter++;, Interlocke...

Difference between onLoad and ng-init in angular

I am learning angular. I don't understand what is difference between onLoad and ng-init for initialization of a variable. In which scope it creates this variable. For example <ng-include onLoad="selectedReq=reqSelected" src="'partials/abc.html'"...

How to split one string into multiple strings separated by at least one space in bash shell?

I have a string containing many words with at least one space between each two. How can I split the string into individual words so I can loop through them? The string is passed as an argument. E.g. ${2} == "cat cat file". How can I loop through it...

How to append text to an existing file in Java?

I need to append text repeatedly to an existing file in Java. How do I do that?...

When should I create a destructor?

For example: public class Person { public Person() { } ~Person() { } } When should I manually create a destructor? When have you needed to create a destructor? ...

Python - Check If Word Is In A String

I'm working with Python v2, and I'm trying to find out if you can tell if a word is in a string. I have found some information about identifying if the word is in the string - using .find, but is there a way to do an IF statement. I would like to ha...

Get column index from column name in python pandas

In R when you need to retrieve a column index based on the name of the column you could do idx <- which(names(my_data)==my_colum_name) Is there a way to do the same with pandas dataframes?...

Open Excel file for reading with VBA without display

I want to search through existing Excel files with a macro, but I don't want to display those files when they're opened by the code. Is there a way to have them open "in the background", so to speak?...

The developers of this app have not set up this app properly for Facebook Login?

I'm trying to make login with Facebook available in my script. I've done everything, but when I attempt to login with a Facebook account I get this error from Facebook: Error App Not Setup: The developers of this app have not set up this app...

Change project name on Android Studio

I want to change the name of my project and module. But if I try to rename them Android Studio notify me some errors... e.g. I want to change the name from "MyApplication" to "AndroidApp" as shown in the image below. In the first rectangle I want to...

With Spring can I make an optional path variable?

With Spring 3.0, can I have an optional path variable? For example @RequestMapping(value = "/json/{type}", method = RequestMethod.GET) public @ResponseBody TestBean testAjax( HttpServletRequest req, @PathVariable String type, ...

Flatten List in LINQ

I have a LINQ query which returns IEnumerable<List<int>> but i want to return only List<int> so i want to merge all my record in my IEnumerable<List<int>> to only one array. Example : IEnumerable<List<int>> i...

How to use color picker (eye dropper)?

There is a very useful tool built in chrome dev tool, that I have just discovered. I even don't know its name, and I am not able to find it on google. I would say it is a pixel inspector tool. I find the following method how to use it: 1a. Inspect ...

How to remove trailing and leading whitespace for user-provided input in a batch file?

I know how to do this when the variable is pre-defined. However, when asking for the user to enter in some kind of input, how do I trim leading and trailing whitespace? This is what I have so far: @echo off set /p input=: echo. The input is %input%...

How to use OKHTTP to make a post request?

I read some examples which are posting jsons to the server. some one says : OkHttp is an implementation of the HttpUrlConnection interface provided by Java. It provides an input stream for writing content and doesn't know (or care) about wha...

Get all attributes of an element using jQuery

I am trying to go through an element and get all the attributes of that element to output them, for example an tag may have 3 or more attributes, unknown to me and I need to get the names and values of these attributes. I was thinking something alon...

How do I animate constraint changes?

I'm updating an old app with an AdBannerView and when there is no ad, it slides off screen. When there is an ad it slides on the screen. Basic stuff. Old style, I set the frame in an animation block. New style, I have a IBOutlet to the auto-layout c...

Is it possible to display my iPhone on my computer monitor?

As the title says, is this possible? I want to "mirror" my actions on the iPhone so it shows on the computer monitor. We've seen this on the Apple key notes, but I am not sure if this feature is public....

Setting Java heap space under Maven 2 on Windows

I get this message during build of my project java.lang.OutOfMemoryError: Java heap space How do I increase heap space, I've got 8Gb or RAM its impossible that maven consumed that much, I found this http://vikashazrati.wordpress.com/2007/07/...

How to get Android application id?

In Android, how do I get the application's id programatically (or by some other method), and how can I communicate with other applications using that id?...

C# "must declare a body because it is not marked abstract, extern, or partial"

I'm not sure why i'm getting this error to be honest. private int hour { get; set { //make sure hour is positive if (value < MIN_HOUR) { hour = 0; MessageBox.Show("Hour value " + value.T...

onNewIntent() lifecycle and registered listeners

I'm using a singleTop Activity to receive intents from a search-dialog via onNewIntent(). What I noticed is that onPause() is called before onNewIntent(), and then afterwards it calls onResume(). Visually: search dialog initiated search intent fi...

Python - AttributeError: 'numpy.ndarray' object has no attribute 'append'

This is related to my question, here. I now have the updated code as follows: import numpy as np import _pickle as cPickle from PIL import Image import sys,os pixels = [] labels = [] traindata = [] i = 0 directory = 'C:\\Users\\abc\\Desktop\\Test...

Change Placeholder Text using jQuery

I am using a jQuery placeholder plugin(https://github.com/danielstocks/jQuery-Placeholder). I need to change the placeholder text with the change in dropdown menu. But it is not changing. Here is the code: $(function () { $('input[placeholder], ...

Arduino Sketch upload issue - avrdude: stk500_recv(): programmer is not responding

I have an Arduino Duemilanove with an ATmega328. I am working on Ubuntu 12.04 (Precise Pangolin), and the Arduino IDE's version is 1.0. Recently, I tried to upload a few of the sample sketches onto it, such as the Blink one. However, none of my ...

How to run wget inside Ubuntu Docker image?

I'm trying to download a Debian package inside a Ubuntu container as follows: sudo docker run ubuntu:14.04 wget https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.8.2-omnibus.1-1_amd64.deb I get exec: "wget": executable file not fo...

ASP.NET 5 MVC: unable to connect to web server 'IIS Express'

What I'm doing: Opening Visual Studio Community 2015 File -> New -> Project Under Visual C#: Web -> ASP.NET Web Application Web Application And press f5 for the popup error "unable to connect to web server 'IIS Express'." Deleting applicationhost...

Draw Circle using css alone

Is it possible to draw circle using css only which can work on most of the browsers (IE,Mozilla,Safari) ?...

How do I get the file extension of a file in Java?

Just to be clear, I'm not looking for the MIME type. Let's say I have the following input: /path/to/file/foo.txt I'd like a way to break this input up, specifically into .txt for the extension. Is there any built in way to do this in Java? I woul...

Oracle TNS names not showing when adding new connection to SQL Developer

I'm trying to connect to an oracle database with SQL Developer. I've installed the .Net oracle drivers and placed the tnsnames.ora file at C:\Oracle\product\11.1.0\client_1\Network\Admin I'm using the following format in tnsnames.ora: dev = (DE...

How do I create a singleton service in Angular 2?

I've read that injecting when bootstrapping should have all children share the same instance, but my main and header components (main app includes header component and router-outlet) are each getting a separate instance of my services. I have a Fa...

Javascript Object push() function

I have a javascript object (I actually get the data through an ajax request): var data = {}; I have added some stuff into it: data[0] = { "ID": "1"; "Status": "Valid" } data[1] = { "ID": "2"; "Status": "Invalid" } Now I want to remove all objec...

How to do associative array/hashing in JavaScript

I need to store some statistics using JavaScript in a way like I'd do it in C#: Dictionary<string, int> statistics; statistics["Foo"] = 10; statistics["Goo"] = statistics["Goo"] + 1; statistics.Add("Zoo", 1); Is there an Hashtable or some...

Angular2 material dialog has issues - Did you add it to @NgModule.entryComponents?

I am trying to follow the docs on https://material.angular.io/components/component/dialog but I cannot understand why it has the below issue? I added the below on my component: @Component({ selector: 'dialog-result-example-dialog', templateUrl:...

Is Android using NTP to sync time?

Do Android Devices use the network time protocol (NTP) to synchronize the time? In my Device-Settings I see a checkbox with the following text "synchronize with network", but I don't know if they are using NTP. I need this for my Bachelor Thesis fo...

How to launch multiple Internet Explorer windows/tabs from batch file?

I would like a batch file to launch two separate programs then have the command line window close. Actually, to clarify, I am launching Internet Explorer with two different URLs. So far I have something like this: start "~\iexplore.exe" "url1" star...

How to show MessageBox on asp.net?

if I need to show a MessageBox on my ASP.NET WebForm, how to do it? I try: Messagebox.show("dd"); But it's not working....

Get escaped URL parameter

I'm looking for a jQuery plugin that can get URL parameters, and support this search string without outputting the JavaScript error: "malformed URI sequence". If there isn't a jQuery plugin that supports this, I need to know how to modify it to suppo...

Xcode doesn't see my iOS device but iTunes does

I have a strange problem. I have an iPad with iOS 5.0.1 (9A405) and iOS SDK 5.0.1 with Xcode 4.2 (Build 4C199) installed on my Mac. Xcode doesn't see my device. It says "iOS Device" not "Sauron's iPad" as usual. (I am sure that device is connected ...

"End of script output before headers" error in Apache

Apache on Windows gives me the following error when I try to access my Perl script: Server error! The server encountered an internal error and was unable to complete your request. Error message: End of script output before headers: sample.pl If ...

SQLite - getting number of rows in a database

I want to get a number of rows in my table using max(id). When it returns NULL - if there are no rows in the table - I want to return 0. And when there are rows I want to return max(id) + 1. My rows are being numbered from 0 and autoincreased. Here...

How to negate the whole regex?

I have a regex, for example (ma|(t){1}). It matches ma and t and doesn't match bla. I want to negate the regex, thus it must match bla and not ma and t, by adding something to this regex. I know I can write bla, the actual regex is however more comp...

Shell Script Syntax Error: Unexpected End of File

In the following script I get an error: syntax error: unexpected end of file What is this error how can I resove it? It is pointing at the line whee the function is called. #!/bin/sh expected_diskusage="264" expected_dbconn="25" expected_htt...

How to switch between frames in Selenium WebDriver using Java

I am using java with WebDriver.I have to switch between two frames. I have recorded the test case in selenium IDE and in that I got the values as selectFrame relative=top select Frame=middle Frame But there is a problem it is not able to recognize t...

how to fix Cannot call sendRedirect() after the response has been committed?

I am trying to pass values from servlet to jsp page using the code below: public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); try { ...