Examples On Programing Languages

Why is sed not recognizing \t as a tab?

sed "s/\(.*\)/\t\1/" $filename > $sedTmpFile && mv $sedTmpFile $filename I am expecting this sed script to insert a tab in front of every line in $filename however it is not. For some reason it is inserting a t instead....

Set UILabel line spacing

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

Running a Python script from PHP

I'm trying to run a Python script from PHP using the following command: exec('/usr/bin/python2.7 /srv/http/assets/py/switch.py arg1 arg2'); However, PHP simply doesn't produce any output. Error reporting is set to E_ALL and display_errors is on. H...

Using putty to scp from windows to Linux

I'm trying to test some C code that I'm writing. The only issue is that the code needs to be executed on a remote machine. My laptop is pretty old, and there is no driver for my wireless card available for Ubuntu, so booting into Linux to circumvent...

How can I change NULL to 0 when getting a single value from a SQL function?

I have a query that counts the price of all items between two dates. Here is the select statement: SELECT SUM(Price) AS TotalPrice FROM Inventory WHERE (DateAdded BETWEEN @StartDate AND @EndDate) You can assume all of the tables have been set up ...

Logout button php

I have this code and need the code to add a logout button, can anyone write out the code for a log out button that will log out the user, I read something about destroy session but do not know how to write the code out, thank you! <?php inclu...

android - How to get view from context?

I want to get the view or findViewById() from Context? Or from intent? I'm trying to reach a specific view in my broadcast receiver and the parameter of onReceive are context and intent. Well, I have a class and within it is my broadcast receiver. ...

Are the PUT, DELETE, HEAD, etc methods available in most web browsers?

I've seen a couple questions around here like How to debug RESTful services, which mentions: Unfortunately that same browser won't allow me to test HTTP PUT, DELETE, and to a certain degree even HTTP POST. I've also heard that browsers support ...

How can I clear the content of a file?

I need to clear the contents of a particular file every time the applications starts. How do I do it?...

The import org.junit cannot be resolved

I need to solve a java problem for an interview, and they have sent me the test class. It starts with import org.junit.Before; and also has the following syntax at places: @RunWith(JUnit4.class) ... @Before ... @Test I haven't used Java in a w...

Razor View Engine : An expression tree may not contain a dynamic operation

I have a model similar to this: public class SampleModel { public Product Product { get; set; } } And in my controller I get an exception trying to print out @Html.TextBoxFor(p => p.Product.Name) This is the error: Exception: An expre...

Play local (hard-drive) video file with HTML5 video tag?

I want to achieve the following. <video src="file:///Users/username/folder/video.webm"> </video> The intent is that the user will be able to select a file from his/her hard drive. And the reason for not uploading is of course transmis...

How do I do a simple 'Find and Replace" in MsSQL?

Question is pretty self explanitory. I want to do a simple find and replace, like you would in a text editor on the data in a column of my database (which is MsSQL on MS Windows server 2003)...

Best practice multi language website

I've been struggling with this question for quite some months now, but I haven't been in a situation that I needed to explore all possible options before. Right now, I feel like it's time to get to know the possibilities and create my own personal pr...

How to negate 'isblank' function

I want to do "is not blank" in a custom formula. There is a isblank() function but I can find neither an isnotblank() function nor a way to say not, such as ! or ==False. How can I say is not blank?...

What is the difference between children and childNodes in JavaScript?

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

Resizing an Image without losing any quality

How can I resize an image, with the image quality unaffected?...

iPhone hide Navigation Bar only on first page

I have the code below that hides and shows the navigational bar. It is hidden when the first view loads and then hidden when the "children" get called. Trouble is that I cannot find the event/action to trigger it to hide again when they get back to...

Ideal way to cancel an executing AsyncTask

I am running remote audio-file-fetching and audio file playback operations in a background thread using AsyncTask. A Cancellable progress bar is shown for the time the fetch operation runs. I want to cancel/abort the AsyncTask run when the user can...

Is there any free OCR library for Android?

I'm looking for a Java OCR that runs on Android, however Asprise doesn't seem to be a platform independent OCR. is there any opensource/free Java OCR I can use for android application development?...

JavaScript equivalent of PHP's in_array()

Is there a way in JavaScript to compare values from one array and see if it is in another array? Similar to PHP's in_array function?...

Git: How to find a deleted file in the project commit history?

Once upon a time, there was a file in my project that I would now like to be able to get. The problem is: I have no idea of when have I deleted it and on which path it was. How can I locate the commits of this file when it existed?...

AngularJs - ng-model in a SELECT

JSfiddle Problem: I have a SELECT-element in my page, which is filled in with an ng-repeat. It also has a ng-model which has a default value. When I change the value, the ng-model adapts, that's ok. But the dropdown-list shows an empty slot at lau...

How can I get the current array index in a foreach loop?

How do I get the current index in a foreach loop? foreach ($arr as $key => $val) { // How do I get the index? // How do I get the first element in an associative array? } ...

Insert Data Into Tables Linked by Foreign Key

I am using PostgreSQL. Customer ================== Customer_ID | Name Order ============================== Order_ID | Customer_ID | Price To insert an order, here is what I need to do usually, For example, "John" place "1.34" priced order. (1) ...

How do you generate a random double uniformly distributed between 0 and 1 from C++?

How do you generate a random double uniformly distributed between 0 and 1 from C++? Of course I can think of some answers, but I'd like to know what the standard practice is, to have: Good standards compliance Good randomness Good speed (speed i...

Unresolved reference issue in PyCharm

I have a directory structure +-- simulate.py +-- src ¦   +-- networkAlgorithm.py ¦   +-- ... And I can access the network module with sys.path.insert(). import sys import os.path sys.path.insert(0, "./src") from networkAlgorithm import ...

HTML radio buttons allowing multiple selections

In my HTML form I have the below as a set of radio buttons, depending on what radio button you select depends on what the next form <fieldset> is revealed, this all works. The problem is for some reason they are working like a check box and not...

How to use 'cp' command to exclude a specific directory?

I want to copy all files in a directory except some files in a specific sub-directory. I have noticed that cp command didn't have the --exclude option. So, how can I achieve this?...

How do I set an un-selectable default description in a select (drop-down) menu in HTML?

I have a drop down where the user selects a language: <select> <option>English</option> <option>Spanish</option> </select> I want the default option that is initially displayed to say "Select a language...

How to set aliases in the Git Bash for Windows?

How to alias command in Git Bash for Windows downloaded from git-scm.com ? I mean Bash commands not Git. (windows7) Edit: Writing aliases in .bashrc file (as suggested by @gturri) not adding it in console.(after system reboot)(I have never wrot...

How to pass parameters to $http in angularjs?

Assume that I have two input boxes with corresponding ng-model as fname and lname. If I call http request as : $http({method:'GET', url:'/search', params:{fname: fname, lname: lname}}) will it call to the url : /search?fname=fname&lname=lname...

How to import data from one sheet to another

I have two different work sheets in excel with the same headings in in all the row 1 cells(a1 = id, b1 = name, c1 = price). My question is, is there a way to import data(like the name) from 1 worksheet to the other where the "id" is the same in both ...

Launch programs whose path contains spaces

I need to launch programs in my local system using VBScript. But I am having trouble with the syntax. This is what I am using right now - Dim objShell Set objShell = WScript.CreateObject( "WScript.Shell" ) objShell.Run("iexplore") Set objShell = No...

How can I replace newlines using PowerShell?

Given test.txt containing: test message I want to end up with: testing a message I think the following should work, but it doesn't: Get-Content test.txt |% {$_-replace "t`r`n", "ting`r`na "} How can I do a find and replace where what I'm fin...

How do I convert a pandas Series or index to a Numpy array?

Do you know how to get the index or column of a DataFrame as a NumPy array or python list? ...

How to upgrade PowerShell version from 2.0 to 3.0

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

CSS last-child(-1)

I am looking for a css selector that lets me select the pre-last child of list. <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <!-- select the...

Convert Unicode to ASCII without errors in Python

My code just scrapes a web page, then converts it to Unicode. html = urllib.urlopen(link).read() html.encode("utf8","ignore") self.response.out.write(html) But I get a UnicodeDecodeError: Traceback (most recent call last): File "/Applications...

How to align this span to the right of the div?

I have the following HTML: <div class="title"> <span>Cumulative performance</span> <span>20/02/2011</span> </div> with this CSS: .title { display: block; border-top: 4px solid #a7a59b; backg...

Python: Removing spaces from list objects

I have a list of objects appended from a mysql database and contain spaces. I wish to remove the spaces such as below, but the code im using doesnt work? hello = ['999 ',' 666 '] k = [] for i in hello: str(i).replace(' ','') k.append(i) p...

Get text from DataGridView selected cells

I have a DataGridView with cells from a database file that contains data. Basically, I want to get the text from the selected cells in the DataGridView and display it in a textbox at the click of the button. The code for the button click event is: P...

Python error: "IndexError: string index out of range"

I'm currently learning python from a book called 'Python for the absolute beginner (third edition)'. There is an exercise in the book which outlines code for a hangman game. I followed along with this code however I keep getting back an error in the ...

MySQL Insert query doesn't work with WHERE clause

What's wrong with this query: INSERT INTO Users( weight, desiredWeight ) VALUES ( 160, 145 ) WHERE id = 1; It works without the WHERE clause. I've seemed to have forgot my SQL....

Comment out HTML and PHP together

I have this code, <tr> <td><?php echo $entry_keyword; ?></td> <td><input type="text" name="keyword" value="<?php echo $keyword; ?>" /></td> </tr> <tr> <td&g...

Upgrade python in a virtualenv

Is there a way to upgrade the version of python used in a virtualenv (e.g. if a bugfix release comes out)? I could pip freeze --local > requirements.txt, then remove the directory and pip install -r requirements.txt, but this requires a lot of re...

Best practice for storing and protecting private API keys in applications

Most app developers will integrate some third party libraries into their apps. If it's to access a service, such as Dropbox or YouTube, or for logging crashes. The number of third party libraries and services is staggering. Most of those libraries an...

CSS Div stretch 100% page height

I have a navigation bar on the left hand side of my page, and I want it to stretch to 100% of the page height. Not just the height of the viewport, but including the areas hidden until you scroll. I don't want to use javascript to accomplish this. C...

Is Task.Result the same as .GetAwaiter.GetResult()?

I was recently reading some code that uses a lot of async methods, but then sometimes needs to execute them synchronously. The code does: Foo foo = GetFooAsync(...).GetAwaiter().GetResult(); Is this the same as Foo foo = GetFooAsync(...).Result; ...

Sending JSON object to Web API

I am trying to figure out how I can send some information from a form to a Web API action. This is the jQuery/AJAX I'm trying to use: var source = { 'ID': 0, 'ProductID': $('#ID').val(), 'PartNumber': $('#part-number').val...

Allowed memory size of 262144 bytes exhausted (tried to allocate 24576 bytes)

I was going crazy with this. I got the next message: Allowed memory size of 262144 bytes exhausted (tried to allocate 24576 bytes) TODO LIST Check phpinfo(), got the right php.ini route and edit it. Change memory_limit to memory_limit = 128M ...

Replace part of a string in Python?

I used regular expressions to get a string from a web page and part of the string may contain something I would like to replace with something else. How would it be possible to do this? My code is this, for example: stuff = "Big and small" if stuff....

How can I use goto in Javascript?

I have some code that I absolutely must implement using goto. For example, I want to write a program like this: start: alert("RINSE"); alert("LATHER"); repeat: goto start Is there a way to do that in Javascript?...

How do I flush the PRINT buffer in TSQL?

I have a very long-running stored procedure in SQL Server 2005 that I'm trying to debug, and I'm using the 'print' command to do it. The problem is, I'm only getting the messages back from SQL Server at the very end of my sproc - I'd like to be able ...

Counting unique values in a column in pandas dataframe like in Qlik?

If I have a table like this: df = pd.DataFrame({ 'hID': [101, 102, 103, 101, 102, 104, 105, 101], 'dID': [10, 11, 12, 10, 11, 10, 12, 10], 'uID': ['James', 'Henry', 'Abe', 'James', 'Henry', 'Brian', 'Claude', 'James'], ...

How to handle Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause()

Below is my code in aspx page to allow playing audio's of wav format in the browser but with my current code I am unable to play wav audios in Chrome browser but it works in Firefox. How can I handle this exception? <script> window.onload ...

How to support HTTP OPTIONS verb in ASP.NET MVC/WebAPI application

I've setup an ASP.NET web application starting with a MVC 4/Web API template. It seems as though things are working really well - no problems that I'm aware of. I've used Chrome and Firefox to go through the site. I've tested using Fiddler and all of...

Why am I getting Unknown error in line 1 of pom.xml?

Getting unknown error at Line 1 in pom.xml in Eclipse IDE. It was working fine till yesterday, but all of a sudden after updating my project from master and after fixing merge conflicts getting "Unknown error" in pom.xml. Except me, none of my teamma...

SQLPLUS error:ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA

I downloaded SQLPLUS from Oracle: http://www.oracle.com/technetwork/topics/winx64soft-089540.html Basic Lite and SQL*Plus I then fired up SQL*Plus: c:\Program Files\Oracle\instantclient_12_1>sqlplus /nolog SQL*Plus: Release 12.1.0.2.0 Product...

How do I push a new local branch to a remote Git repository and track it too?

I want to be able to do the following: Create a local branch based on some other (remote or local) branch (via git branch or git checkout -b) Push the local branch to the remote repository (publish), but make it trackable so git pull and git push w...

Numpy where function multiple conditions

I have an array of distances called dists. I want to select dists which are between two values. I wrote the following line of code to do that: dists[(np.where(dists >= r)) and (np.where(dists <= r + dr))] However this selects only for the c...

Swift Open Link in Safari

I am currently opening the link in my app in a WebView, but I'm looking for an option to open the link in Safari instead....

Which characters need to be escaped when using Bash?

Is there any comprehensive list of characters that need to be escaped in Bash? Can it be checked just with sed? In particular, I was checking whether % needs to be escaped or not. I tried echo "h%h" | sed 's/%/i/g' and worked fine, without escapi...

Multiple bluetooth connection

I want to connect 3 devices via bluetooth (My Droid must connect to 2 bluetooth devices). I 've connected my Droid to 1 device using Bluetooth chat How should I modify it for multiple bluetooth devices? Could you help me please?...

Disable clipboard prompt in Excel VBA on workbook close

I have an Excel workbook, which using VBA code that opens another workbook, copies some data into the original, then closes the second workbook. When I close the second workbook (using Application.Close), I get a prompt for: Do you want to save ...

javascript create empty array of a given size

in javascript how would I create an empty array of a given size Psuedo code: X = 3; createarray(myarray, X, ""); output: myarray = ["","",""] ...

Function return value in PowerShell

I have developed a PowerShell function that performs a number of actions involving provisioning SharePoint Team sites. Ultimately, I want the function to return the URL of the provisioned site as a String so at the end of my function I have the follo...

Can VS Code run on Android?

Does anybody know about plans of MS to support running VS Code so it can run on Android OS?...

How can I monitor the thread count of a process on linux?

I would like to monitor the number of threads used by a specific process on Linux. Is there an easy way to get this information without impacting the performance of the process?...

Removing a non empty directory programmatically in C or C++

How to delete a non empty directory in C or C++? Is there any function? rmdir only deletes empty directory. Please provide a way without using any external library. Also tell me how to delete a file in C or C++?...

Pytorch reshape tensor dimension

For example, I have 1D vector with dimension (5). I would like to reshape it into 2D matrix (1,5). Here is how I do it with numpy >>> import numpy as np >>> a = np.array([1,2,3,4,5]) >>> a.shape (5,) >>> a = np.r...

How to get a value from a Pandas DataFrame and not the index and object type

Say I have the following DataFrame Letter Number A 1 B 2 C 3 D 4 Which can be obtained through the following code import pandas as pd letters=pd.Series(('A', 'B', 'C', 'D')) numbers=pd.Series((1, 2, 3, 4))...

What is the difference between a symbolic link and a hard link?

Recently I was asked this during a job interview. I was honest and said I knew how a symbolic link behaves and how to create one, but do not understand the use of a hard link and how it differs from a symbolic one....

Open links in new window using AngularJS

Is there a way to tell AngularJS that I want links to be opened in new windows when the user clicks on them? With jQuery I would do this: jQuery("a.openInNewWindow").click( function() { window.open(this.href); return false; }) Is there an...

ASP.NET MVC Page Won't Load and says "The resource cannot be found"

I am having a problem where I try to open my ASP.NET MVC application but I get the ASP.NET error page which says this: Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for ...

MySQl Error #1064

I keep getting this error: MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO books.book(isbn10,isbn13,title,edition,aut...

Reset the graphical parameters back to default values without use of dev.off()

Such as margins, orientations and such... dev.off() does not work for me. I am often using RStudio, with its inbuilt graphics device. I then have plotting functions, which I want to plot either in the default RStudio graphics device, or if I called ...

What is the purpose of class methods?

I'm teaching myself Python and my most recent lesson was that Python is not Java, and so I've just spent a while turning all my Class methods into functions. I now realise that I don't need to use Class methods for what I would done with static meth...

Export table to file with column headers (column names) using the bcp utility and SQL Server 2008

I have seen a number of hacks to try to get the bcp utility to export column names along with the data. If all I am doing is dumping a table to a text file what is the most straightforward method to have bcp add the column headers? Here's the bcp co...

Where and how is the _ViewStart.cshtml layout file linked?

Here's the About.cshtml from the default MVC 3 template: @{ ViewBag.Title = "About Us"; } <h2>About</h2> <p> Put content here. </p> I would expect that a reference to the _ViewStart file would be found in the Abou...

R Markdown - changing font size and font type in html output

I am using R Markdown in RStudio and the knit HTML option to create HTML output. However, the font used in the ouput for plain text blocks is rather small and I would like to change it to a differnt font and increase the font size. Can someone show a...

Read tab-separated file line into array

I would like to read a file into a script, line by line. Each line in the file is multiple values separated by a tab, I'd like to read each line into an array. Typical bash "read file by line" example; while read line do echo $line; done < "myf...

How to handle Pop-up in Selenium WebDriver using Java

I want to handle sign-in part in rediff.com, but the below code doesn't work for that: driver.get("http://www.rediff.com/"); WebElement sign = driver.findElement(By.xpath("//html/body/div[3]/div[3]/span[4]/span/a")); sign.click(); String myWindowHan...

Using module 'subprocess' with timeout

Here's the Python code to run an arbitrary command returning its stdout data, or raise an exception on non-zero exit codes: proc = subprocess.Popen( cmd, stderr=subprocess.STDOUT, # Merge stdout and stderr stdout=subprocess.PIPE, sh...

AWS : The config profile (MyName) could not be found

Every time I want to config something with AWS I get the following error : "The config profile (myname) could not be found" like : aws configure I'm using Python 3.4 and I want to use AWS CLI Keyring to encrypt my credentials.. ...

Sum values in foreach loop php

foreach($group as $key=>$value) { echo $key. " = " .$value. "<br>"; } For example: doc1 = 8 doc2 = 7 doc3 = 1 I want to count $value, so the result is 8+7+1 = 16. What should i do? Thanks....

launch sms application with an intent

I have a question about an intent... I try to launch the sms app... Intent intent = new Intent(Intent.ACTION_MAIN); intent.setType("vnd.android-dir/mms-sms"); int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.F...

How to create a JQuery Clock / Timer

I have a simple quiz application and I want display a nice timer / clock at the top of the page which shows the user how long they've been going for. (If I could somehow show them a timer for Total Quiz Time and also a second one for This Question Ti...

How to execute a file within the python interpreter?

I'm trying to execute a file with python commands from within the interpreter. EDIT: I'm trying to use variables and settings from that file, not to invoke a separate process....

Can "git pull --all" update all my local branches?

I often have at least 3 remote branches: master, staging and production. I have 3 local branches that track those remote branches. Updating all my local branches is tedious: git fetch --all git rebase origin/master git checkout staging git rebase o...

SQL get the last date time record

I'm trying to get the last datetime record from a table that happens to store multiple status. My table looks like so: +---------+------------------------+-------+ |filename |Dates |Status | +---------+------------------------+----...

How to add hours to current time in python

I am able to get the current time as below: from datetime import datetime str(datetime.now())[11:19] Result '19:43:20' Now, i am trying to add 9 hours to the above time, how can I add hours to current time in Python?...

Angular: date filter adds timezone, how to output UTC?

I'm using the date filter to render a unix timestamp in a certain format. I've noticed the filter adds the local timezone to the output. Is there any way to simply output the exact timestamp, without adding any timezone information? Input: talk.co...

Setting an environment variable before a command in Bash is not working for the second command in a pipe

In a given shell, normally I'd set a variable or variables and then run a command. Recently I learned about the concept of prepending a variable definition to a command: FOO=bar somecommand someargs This works... kind of. It doesn't work when you'...

How to get element-wise matrix multiplication (Hadamard product) in numpy?

I have two matrices a = np.matrix([[1,2], [3,4]]) b = np.matrix([[5,6], [7,8]]) and I want to get the element-wise product, [[1*5,2*6], [3*7,4*8]], equaling [[5,12], [21,32]] I have tried print(np.dot(a,b)) and print(a*b) but both give ...

How to use andWhere and orWhere in Doctrine?

WHERE a = 1 AND (b = 1 Or b = 2) AND (c = 1 OR c = 2) How can i make this in Doctrine? $q->where("a = 1"); $q->andWhere("b = 1") $q->orWhere("b = 2") $q->andWhere("c = 1") $q->orWhere("d = 2") this isnt correctly... Should be: $q...

ArrayBuffer to base64 encoded string

I need an efficient (read native) way to convert an ArrayBuffer to a base64 string which needs to be used on a multipart post. ...

How to Sort Multi-dimensional Array by Value?

How can I sort this array by the value of the "order" key? Even though the values are currently sequential, they will not always be. Array ( [0] => Array ( [hashtag] => a7e87329b5eab8578f4f1098a152d6f4 [titl...

Load CSV file with Spark

I'm new to Spark and I'm trying to read CSV data from a file with Spark. Here's what I am doing : sc.textFile('file.csv') .map(lambda line: (line.split(',')[0], line.split(',')[1])) .collect() I would expect this call to give me a list of ...

pip install fails with "connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)"

I am very new to Python and trying to > pip install linkchecker on Windows 7. Some notes: pip install is failing no matter the package. For example, > pip install scrapy also results in the SSL error. Vanilla install of Python 3.4.1 included ...

regular expression: match any word until first space

I have the following line: hshd household 8/29/2007 LB I want to match anything that comes before the first space (whitespace). So, in this case, I want to get back hshd ...

In nodeJs is there a way to loop through an array without using array size?

Let's say I have myArray = ['item1', 'item2'] I tried for (var item in myArray) {console.log(item)} It prints 0 1 What I wish is to have item1 item2 Is there any other syntax that works without using for (var i = 0; i <...

The name 'ConfigurationManager' does not exist in the current context

I am trying to access connectionStrings from the config file. The code is ASP.NET + C#. I have added System.Configuration to reference and also mentioned with using. But still it wouldn't accept the assembly. I am using VSTS 2008. Any idea what coul...

How do I remove an object from an array with JavaScript?

I have an JavaScript object like this: id="1"; name = "serdar"; and I have an Array which contains many objects of above. How can I remove an object from that array such as like that: obj[1].remove(); ...

BeautifulSoup getText from between <p>, not picking up subsequent paragraphs

Firstly, I am a complete newbie when it comes to Python. However, I have written a piece of code to look at an RSS feed, open the link and extract the text from the article. This is what I have so far: from BeautifulSoup import BeautifulSoup import ...

filtering NSArray into a new NSArray in Objective-C

I have an NSArray and I'd like to create a new NSArray with objects from the original array that meet certain criteria. The criteria is decided by a function that returns a BOOL. I can create an NSMutableArray, iterate through the source array and c...

SELECT * FROM multiple tables. MySQL

SELECT name, price, photo FROM drinks, drinks_photos WHERE drinks.id = drinks_id yeilds 5 rows (5 arrays), photo is the only unique field in a row. name, price get repeated (here, fanta- name, price repeat 3 times.) How do i get rid of these dupl...

Changing an element's ID with jQuery

I need to change an element's ID using jQuery. Apparently these don't work: jQuery(this).prev("li").attr("id")="newid" jQuery(this).prev("li")="newid" I found out that I can make it happen with the following code: jQuery(this).prev("li")show(f...

Jquery in React is not defined

Hi I just want to receive ajax request, but the problem is that jquery is not defined in React. React version is 14.0 Error message Uncaught ReferenceError: $ is not defined I have two files : index.js import React from 'react'; import { rend...

How can I comment a single line in XML?

This rather is a verification just not to miss out. Is/n't there a line-comment in XML? So, one without a closer, like "//" the compiler uses. I saw How do I comment out a block of tags in XML? and several other discussions. This type of comment w...

Copy all the lines to clipboard

Is there any way to copy all lines from open file to clipboard in VI editor. I tried yG but it's not using clipboard to store those lines. So is it possible?...

Angular 2 Date Input not binding to date value

trying to get a form set up but for some reason, the Date input in my html is not binding to the object's date value, despite using [(ngModel)] html: <input type='date' #myDate [(ngModel)]='demoUser.date'/><br> form component: export...

How to downgrade Xcode to previous version?

I have to use Xcode occasionally, and have now come across a problem where I've upgraded to Xcode 4.6, but another piece of software I'm using doesn't support it, so I need to go back to Xcode 4.5. I'm not used to the way Macs work in general, so if...

COALESCE with Hive SQL

Since there is no IFNULL, ISNULL, or NVL function supported on Hive, I'm having trouble converting NULL to 0. I tried COALESCE(*column name*, 0) but received the below error message: Argument type mismatch 0: The expressions after COALESCE shoul...

Get size of all tables in database

I have inherited a fairly large SQL Server database. It seems to take up more space than I would expect, given the data it contains. Is there an easy way to determine how much space on disk each table is consuming?...

How to implement an android:background that doesn't stretch?

I found this great thread describing how to "eat the cake and have it too", i.e. use image for a Button instead of ImageButton (which doesn't allow SetText(), resizing, etc.). This is achieved by using the View attribute: android:background="@drawa...

Java Replace Line In Text File

How do I replace a line of text found within a text file? I have a string such as: Do the dishes0 And I want to update it with: Do the dishes1 (and vise versa) How do I accomplish this? ActionListener al = new ActionListener() { ...

ORA-01652 Unable to extend temp segment by in tablespace

I am creating a table like create table tablename as select * for table2 I am getting the error ORA-01652 Unable to extend temp segment by in tablespace When I googled I usually found ORA-01652 error showing some value like Unable to extend te...

SignalR - Sending a message to a specific user using (IUserIdProvider) *NEW 2.0.0*

In the latest version of Asp.Net SignalR, was added a new way of sending a message to a specific user, using the interface "IUserIdProvider". public interface IUserIdProvider { string GetUserId(IRequest request); } public class MyHub : Hub { ...

css width: calc(100% -100px); alternative using jquery

I'd like to use width: calc(100% -100px); which does the job perfectly for what I need it for, the only problem is its compatibility. At the moment it only works in the latest browsers and not at all in Safari. Could I make an alternative using jQu...

.prop('checked',false) or .removeAttr('checked')?

With the introduction of the prop method, now I need to know the accepted way of unchecking a checkbox. Is it: $('input').filter(':checkbox').removeAttr('checked'); or $('input').filter(':checkbox').prop('checked',false); ...

HTML5 image icon to input placeholder

I'd like to add an image icon to an input placeholder, like in this picture: Please note that this is a placeholder, so when the user starts typing, the icon also disappears. I came with the following solution for webkit (Safari+Chrome) using ::-w...

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 do I clone a Django model instance object and save it to the database?

Foo.objects.get(pk="foo") <Foo: test> In the database, I want to add another object which is a copy of the object above. Suppose my table has one row. I want to insert the first row object into another row with a different primary key. How c...

Dilemma: when to use Fragments vs Activities:

I know that Activities are designed to represent a single screen of my application, while Fragments are designed to be reusable UI layouts with logic embedded inside of them. Until not long ago, I developed an application as it said that they should ...

Right click to select a row in a Datagridview and show a menu to delete it

I have few columns in my DataGridView, and there is data in my rows. I saw few solutions in here, but I can not combine them! Simply a way to right-click on a row, it will select the whole row and show a menu with an option to delete the row and whe...

python replace single backslash with double backslash

In python, I am trying to replace a single backslash ("\") with a double backslash("\"). I have the following code: directory = string.replace("C:\Users\Josh\Desktop\20130216", "\", "\\") However, this gives an error message saying it doesn't like...

NameError: global name 'xrange' is not defined in Python 3

I am getting an error when running a python program: Traceback (most recent call last): File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 110, in <module> File "C:\Program Files (x86)\Wing IDE 101 4.1\src\d...

HttpContext.Current.Request.Url.Host what it returns?

I'm having a local application which has a path: http://localhost:950/m/pages/Searchresults.aspx?search=knife&filter=kitchen but when this goes to integration environment or perhaps the production, it will be something like http://www.somesho...

The term 'ng' is not recognized as the name of a cmdlet

Today, while working through some basic AngularJS Intro, I ran into a problem. I opened PowerShell to get going on the project. NPM worked. I was able to install the Angular using: npm install -g @angular/cli Anytime I tried to run ng, I would ...

how to define ssh private key for servers fetched by dynamic inventory in files

I met one configuration problem when coding ansible playbook for ssh private key file. As we know, we can define combination with host server, ip & related ssh private key in ansible hosts file for static inventory servers. But i have no idea h...

get all keys set in memcached

How can I get all the keys set in my memcached instance(s)? I tried googling, but didn't find much except that PHP supports a getAllKeys method, which means it is actually possible to do this somehow. How can I get the same within a telnet session? ...

How to only get file name with Linux 'find'?

I'm using find to all files in directory, so I get a list of paths. However, I need only file names. i.e. I get ./dir1/dir2/file.txt and I want to get file.txt...

How do I reference to another (open or closed) workbook, and pull values back, in VBA? - Excel 2007

Basically I need to gather a fair few figures from another workbook (Which is found and can be opened by a UserForm, therefore the location and names are variable). I need to use VBA for this as I also need to populate a chart with this data. I would...

About .bash_profile, .bashrc, and where should alias be written in?

Possible Duplicate: What's the difference between .bashrc, .bash_profile, and .environment? It seems that if I use alias ls='ls -F' inside of .bashrc on Mac OS X, then the newly created shell will not have that alias. I need to type b...

What is console.log?

What is the use of console.log? Please explain how to use it in JavaScript, with a code example....

Setting the selected attribute on a select list using jQuery

I have the following HTML: <select id="dropdown"> <option>A</option> <option>B</option> <option>C</option> </select> I have the string "B" so I want to set the selected attribute on it so...

Why can't I center with margin: 0 auto?

I have a #header div that is 100% width and within that div I have an unordered list. I have applied margin: 0 auto to the unordered list but it won't center it within the header div. Can anybody please tell me why? I thought that if I define the w...

Any way to exit bash script, but not quitting the terminal

When I use exit command in a shell script, the script will terminate the terminal (the prompt). Is there any way to terminate a script and then staying in the terminal? My script run.sh is expected to execute by directly being sourced, or sourced fr...

Mysql error 1452 - Cannot add or update a child row: a foreign key constraint fails

I'm having a bit of a strange problem. I'm trying to add a foreign key to one table that references another, but it is failing for some reason. With my limited knowledge of MySQL, the only thing that could possibly be suspect is that there is a forei...

ActionBarActivity: cannot be resolved to a type

I am new to android-programming. I am following this tutorial to add an ActionBar to my Main_Activity using the explanation in the "Support Android 2.1 and Above" section. I followed this tutorial to add a Library-Project. Then after adding the libr...

pythonic way to do something N times without an index variable?

Every day I love python more and more. Today, I was writing some code like: for i in xrange(N): do_something() I had to do something N times. But each time didn't depend on the value of i (index variable). I realized that I was creating a va...

Create a Maven project in Eclipse complains "Could not resolve archetype"

I am totally a newbie with Maven. I want to create a Maven project with Eclipse Juno EE with archetype "webapp". I installed "Maven Integration for Eclipse WTP (incubation)" and I also have installed "Maven Integration for Eclipse" (found it on Insta...

How do I create a WPF Rounded Corner container?

We are creating an XBAP application that we need to have rounded corners in various locations in a single page and we would like to have a WPF Rounded Corner container to place a bunch of other elements within. Does anyone have some suggestions or s...

Keyboard shortcut to clear cell output in Jupyter notebook

Does anyone know what is the keyboard shortcut to clear (not toggle) the cell output in Jupyter Notebook?...

adding and removing classes in angularJs using ng-click

I am trying to work how to add a class with ngClick. I have uploaded up my code onto plunker Click here. Looking at the angular documentation i can't figure out the exact way it should be done. Below is a snippet of my code. Can someone guide me in t...

Private pages for a private Github repo

Couldn't find anything in the github documentation and also here on SO. But I was wondering if there could be a http://foo.github.com for a private repository named foo which is accessible only one had access to the foo repository itself. I remember...

Delete/Reset all entries in Core Data?

Do you know of any way to delete all of the entries stored in Core Data? My schema should stay the same; I just want to reset it to blank. Edit I'm looking to do this programmatically so that a user can essentially hit a reset button....

Stop Visual Studio from launching a new browser window when starting debug?

I already have a window open with the web site I'm debugging. I don't need VS to launch another one for me every time I need to debug. Is there a way to stop this behavior?...

How do I properly compare strings in C?

I am trying to get a program to let a user enter a word or character, store it, and then print it until the user types it again, exiting the program. My code looks like this: #include <stdio.h> int main() { char input[40]; char check[...

MySQL - DATE_ADD month interval

I face a problem with the function DATE_ADD in MySQL. My request looks like this : SELECT * FROM mydb WHERE creationdate BETWEEN "2011-01-01" AND DATE_ADD("2011-01-01", INTERVAL 6 MONTH) GROUP BY MONTH(creationdate) The problem is that, in the...

Discard all and get clean copy of latest revision?

I'm moving a build process to use mercurial and want to get the working directory back to the state of the tip revision. Earlier runs of the build process will have modified some files and added some files that I don't want to commit, so I have local...

When do I need to do "git pull", before or after "git add, git commit"?

What is the right way? git add foo.js git commit foo.js -m "commit" git pull git push Or git pull git add foo.js git commit foo.js -m "commit" git push Or git add foo.js git pull git commit foo.js -m "commit" git push UPD: I forgot to menti...

Add a column in a table in HIVE QL

I'm writing a code in HIVE to create a table consisting of 1300 rows and 6 columns: create table test1 as SELECT cd_screen_function, SUM(access_count) AS max_count, MIN(response_time_min) as response_time_min, AVG(response_time_avg) a...

how to put focus on TextBox when the form load?

I have in my C# program textBox I need that when the program start, the focus will be on the textBox I try this on Form_Load: MyTextBox.Focus(); but it wont work...

How to display image with JavaScript?

I am trying to display image, through JavaScript, but i can't figure out how to do that. I have following function image(a,b,c) { this.link=a; this.alt=b; this.thumb=c; } function show_image() { document.write("img src="+this.link+">"); ...

jQuery document.createElement equivalent?

I'm refactoring some old JavaScript code and there's a lot of DOM manipulation going on. var d = document; var odv = d.createElement("div"); odv.style.display = "none"; this.OuterDiv = odv; var t = d.createElement("table"); t.cellSpacing = 0; t.cla...

How to get a user's client IP address in ASP.NET?

We have Request.UserHostAddress to get the IP address in ASP.NET, but this is usually the user's ISP's IP address, not exactly the user's machine IP address who for example clicked a link. How can I get the real IP Address? For example, in a Stack O...

UITableView example for Swift

I've been working with Swift and iOS for a number of months now. I am familiar with many of the ways things are done but I'm not good enough that I can just write things up without looking. I've appreciated Stack Overflow in the past for providing qu...

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

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

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

How I add Headers to http.get or http.post in Typescript and angular 2?

getHeroes (): Observable<Heros[]> { return this.http.get(this.heroesUrl) .map(this.extractData) .catch(this.handleError); } Where I add the headers and how? looking for a simple example....

Selecting pandas column by location

I'm simply trying to access named pandas columns by an integer. You can select a row by location using df.ix[3]. But how to select a column by integer? My dataframe: df=pandas.DataFrame({'a':np.random.rand(5), 'b':np.random.rand(5)}) ...

Generate ER Diagram from existing MySQL database, created for CakePHP

For CakePHP application, I created MySQL database. Which tool to be used to create ER Diagram of database? Fields and relations between tables are created in a way cakePHP likes. thank you in advance!...

Show git diff on file in staging area

Is there a way I can see the changes that were made to a file after I have done git add file? That is, when I do: git add file git diff file no diff is shown. I guess there's a way to see the differences since the last commit but I don't know wh...

Is it possible to have multiple styles inside a TextView?

Is it possible to set multiple styles for different pieces of text inside a TextView? For instance, I am setting the text as follows: tv.setText(line1 + "\n" + line2 + "\n" + word1 + "\t" + word2 + "\t" + word3); Is it possible to have a differen...

Upgrading PHP in XAMPP for Windows?

I would like to know how you upgrade PHP in Xampp for Windows? I tried to download the latest PHP version from the main PHP site but when I check (phpinfo) I still get that the previous version is still in use....

T-SQL STOP or ABORT command in SQL Server

Is there a command in Microsoft SQL Server T-SQL to tell the script to stop processing? I have a script that I want to keep for archival purposes, but I don't want anyone to run it....

How to include (source) R script in other scripts

I've created a utility R script, util.R, which I want to use from other scripts in my project. What is the proper way to ensure that the function this script defines are available to function in my other scripts? I'm looking for something similar to...

How to check if a string array contains one string in JavaScript?

I have a string array and one string. I'd like to test this string against the array values and apply a condition the result - if the array contains the string do "A", else do "B". How can I do that?...

How to remove all non-alpha numeric characters from a string in MySQL?

I'm working on a routine that compares strings, but for better efficiency I need to remove all characters that are not letters or numbers. I'm using multiple REPLACE functions now, but maybe there is a faster and nicer solution ?...

get next and previous day with PHP

I have got two arrows set up, click for next day, next two days, soon and previous day, two days ago, soon. the code seem not working? as it only get one next and previous day. <a href="home.php?date=<?= date('Y-m-d', strtotime('-1 day', strto...

How to remove duplicate objects in a List<MyObject> without equals/hashcode?

I have to remove duplicated objects in a List. It is a List from the object Blog that looks like this: public class Blog { private String title; private String author; private String url; private String description; ... } A dup...

How do I position a div relative to the mouse pointer using jQuery?

Suppose I have one link in my page and I want that when I place my mouse just over the link, a div will show there according to mouse x,y. How can I accomplish this using jQuery?...

How to run multiple Python versions on Windows

I had two versions of Python installed on my machine (versions 2.6 and 2.5). I want to run 2.6 for one project and 2.5 for another. How can I specify which I want to use? I am working on Windows XP SP2....

How do I run a terminal inside of Vim?

I am used to Emacs, but I am trying out Vim to see which one I like better. One thing that I like about Emacs is the ability to run a terminal inside Emacs. Is this possible inside of Vim? I know that you can execute commands from Vim, but I would ...

Can't push image to Amazon ECR - fails with "no basic auth credentials"

I'm trying to push a docker image to an Amazon ECR registry. I'm using docker client Docker version 1.9.1, build a34a1d5. I use aws ecr get-login --region us-east-1 to get the docker login creds. Then I successfully login with those creds as follows:...

Pandas group-by and sum

I am using this data frame: Fruit Date Name Number Apples 10/6/2016 Bob 7 Apples 10/6/2016 Bob 8 Apples 10/6/2016 Mike 9 Apples 10/7/2016 Steve 10 Apples 10/7/2016 Bob 1 Oranges 10/7/2016 Bob 2 Oranges 10/6/2016 Tom 15 O...

how to print a string to console in c++

Im trying to print a string to console in c++ console application. void Divisibility::print(int number, bool divisible) { if(divisible == true) { cout << number << " is divisible by" << divisibleBy << endl; ...

Fluid or fixed grid system, in responsive design, based on Twitter Bootstrap

I'm getting confused about the various options in the twitter bootstrap grid, and how they go together. To begin with, you can have an ordinary fixed container, or a container-fluid. Then either one can include either an ordinary row, or a fluid ...

How schedule build in Jenkins?

How do I schedule a Jenkins build such that it would be able to build only at specific hours every day? For example to start at 4 PM 0 16 1-7 * * I understand that as: 0 minutes, at 4 o'clock PM from Monday to Sunday every month, however it build...

How to concatenate and minify multiple CSS and JavaScript files with Grunt.js (0.3.x)

Note: This question is only relevant for Grunt 0.3.x and has been left for reference. For help with the latest Grunt 1.x release please see my comment below this question. I'm currently trying to use Grunt.js to setup an automatic build process for ...

Create a pointer to two-dimensional array

I need a pointer to a static 2-dimensional array. How is this done? static uint8_t l_matrix[10][20]; void test(){ uint8_t **matrix_ptr = l_matrix; //wrong idea } I get all kinds of errors like: warning: assignment from incompatible pointer ...

Why was the name 'let' chosen for block-scoped variable declarations in JavaScript?

I understand why var takes that name - it is variable, const - it is a constant, but what is the meaning behind the name for let, which scopes to the current block? Let it be?...

How do you specify a different port number in SQL Management Studio?

I am trying to connect to a Microsoft SQL 2005 server which is not on port 1433. How do I indicate a different port number when connecting to the server using SQL Management Studio?...

How to remove index.php from URLs?

All of my URLs on my Magento installation require index.php in them, like: http://example.com/index.php/admin/ http://example.com/index.php/customer/account/login/ The problem is that the system by default links to URLs like http://example.com/ad...

How to printf a 64-bit integer as hex?

With the following code I am trying to output the value of a unit64_t variable using printf(). Compiling the code with gcc, returns the following warning: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has ...

invalid command code ., despite escaping periods, using sed

Being forced to use CVS for a current client and the address changed for the remote repo. The only way I can find to change the remote address in my local code is a recursive search and replace. However, with the sed command I'd expect to work: fin...

"Could not find a part of the path" error message

I am programming in c# and want to copy a folder with subfolders from a flash disk to startup. Here is my code: private void copyBat() { try { string source_dir = "E:\\Debug\\VipBat"; string destination_dir = "C:\\Users\\pc\...

Array.Add vs +=

I've found some interesting behaviour in PowerShell Arrays, namely, if I declare an array as: $array = @() And then try to add items to it using the $array.Add("item") method, I receive the following error: Exception calling "Add" with "1" arg...

List file using ls command in Linux with full path

Many will found that this is repeating questions but i have gone through all the questions before asked about this topic but none worked for me. I want to print full path name of the certain file format using ls command so far i found chunk of code ...

Current timestamp as filename in Java

I want to name new files created by my Java application with the current timestamp. I need help with this. How do I name the new files created with the current timestamp? Which classes should I include?...

Find empty or NaN entry in Pandas Dataframe

I am trying to search through a Pandas Dataframe to find where it has a missing entry or a NaN entry. Here is a dataframe that I am working with: cl_id a c d e A1 A2 A3 0 1 ...

Android: failed to convert @drawable/picture into a drawable

In my drawable folder I have a few images and they all reference perfect, but when I try and add any more images with the exact same size in the same folder, and try to reference it, is flags up an error "Failed to convert @drawable/picture into a dr...

Error when deploying an artifact in Nexus

Im' getting an error when deploying an artifact in my own repository in a Nexus server: "Failed to deploy artifacts: Could not transfer artifact" "Failed to transfer file http:///my_artifact. Return code is: 400" I have Nexus running with one custom...

XPath selecting a node with some attribute value equals to some other node's attribute value

<grand id="grand"> <parent> <child age="18" id="#not-grand"/> <child age="20" id="#grand"/> <!-- This is what I want to locate --> </parent> </grand> Can anybody tell me how to express for locat...

Two constructors

As I remember I can use first constuctor in second constuctor, but there is mistake on bold line, could you help me to correct it? public FaceExtAdditionCanvas() { profileImage.setSize(IMAGE_WIDTH, IMAGE_HEIGHT); add(profileImage, getWidth...

How can I get nth element from a list?

How can I access a list by index in Haskell, analog to this C code? int a[] = { 34, 45, 56 }; return a[1]; ...

How to create a data file for gnuplot?

I'm trying to make a graph with gnuplot. I specified my xrange, yrange, and labels, but when I typed in the following command: gnuplot> plot "data.txt" using 1:2 with lines gnuplot tells me: warning: Skipping unreadable file "data.txt" No d...

Pull is not possible because you have unmerged files, git stash doesn't work. Don't want to commit

I just want to pull. I have changes to disregard, my Gemfile and Gemlock files and I'd be happy to just overwrite them and just pull. I tried stashing my changes away, this didn't work out for me. What do I do? git pull M Gemfile U Gemfile.lock ...

How to use global variables in React Native?

In React Native I want to use global variables when I am moving between different screens Can anyone help me how to achieve it?...

Example to use shared_ptr?

Hi I asked a question today about How to insert different types of objects in the same vector array and my code in that question was gate* G[1000]; G[0] = new ANDgate() ; G[1] = new ORgate; //gate is a class inherited by ANDgate and ORgate classe...

Convert Unix timestamp to a date string

Is there a quick, one-liner way to convert a Unix timestamp to a date from the Unix command line? date might work, except it's rather awkward to specify each element (month, day, year, hour, etc.), and I can't figure out how to get it to work properl...

Validating with an XML schema in Python

I have an XML file and an XML schema in another file and I'd like to validate that my XML file adheres to the schema. How do I do this in Python? I'd prefer something using the standard library, but I can install a third-party package if necessary....

error: resource android:attr/fontVariationSettings not found

Warning:The android.dexOptions.incremental property is deprecated and it has no effect on the build process. /home/midhilaj/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.1.0.aar/be3106efb0df111fe5a3f7b356dd070b/res/values/values.xml ...

WAMP error: Forbidden You don't have permission to access /phpmyadmin/ on this server

I am new to WAMP and I have just installed it today. The setup went well and localhost seems to work, but when I try to access phpMyAdmin I get this error: Forbidden You don't have permission to access /phpmyadmin/ on this server. Why do I g...

How to use order by with union all in sql?

I tried the sql query given below: SELECT * FROM (SELECT * FROM TABLE_A ORDER BY COLUMN_1)DUMMY_TABLE UNION ALL SELECT * FROM TABLE_B It results in the following error: The ORDER BY clause is invalid in views, inline functions, derived t...

How to hide navigation bar permanently in android activity?

I want to hide navigation bar permanently in my activity(not whole system ui). now i'm using this piece of code getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); It hides the bar but when user touches the sc...

Text file in VBA: Open/Find Replace/SaveAs/Close File

Here is pseudocode for what I am hoping to do: Open text File Find "XXXXX" and Replace with "YYYY" Save text File As Close text file This is what I have so far Private Sub CommandButton1_Click() Dim sBuf As String Dim sTemp As String Dim iFil...

Remove all stylings (border, glow) from textarea

I want to remove the stylings from a textarea and leave it all white without any border or glow, if possible. I've tried with different stuff found here on SO, but nothing works (tried with FF and Chrome). So, is it possible and if so how to do it? ...

Disable back button in android

How to disable back button in android while logging out the application?...

Adding Table rows Dynamically in Android

I am trying to create a layout where I need to add table rows dynamically. Below is the table layout xml <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="ma...

Simulation of CONNECT BY PRIOR of Oracle in SQL Server

How can I get the functionality of CONNECT BY PRIOR of Oracle in SQL Server 2000/2005/2008?...

This declaration has no storage class or type specifier in C++

I have multiple classes in my program. A) When I create an object of a class in another class I am getting no error but when I use the object to call a function I get the above error. B)Also if I create an object of another class and call a function ...

javascript: calculate x% of a number

I am wondering how in javascript if i was given a number (say 10000) and then was given a percentage (say 35.8%) how would I work out how much that is (eg 3580)...

Error: Cannot match any routes. URL Segment: - Angular 2

I am new to angular2. I am trying to understand how to use multiple <router-outlets> in a particular template. I have gone though many QA here but couldn't resolve my error. router.module.ts const routes: Routes = [ { path: '', redire...

"The specified Android SDK Build Tools version (26.0.0) is ignored..."

In Android Studio 3, I'm seeing this issue: The specified Android SDK Build Tools version (26.0.0) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.0. Android SDK Build Tools 26.0.2 will be ...

How to make Java Set?

Can anyone help me? example A {1,2,3} B {1,4,5} Code snippet: a.intersect(b).print() // Result 1 . twin between two object a.merge(b).print() // Result 1,2,3,4,5 It is valid if I write code below? If not, which part I have to fix? public sta...

How to slice an array in Bash

Looking the "Array" section in the bash(1) man page, I didn't find a way to slice an array. So I came up with this overly complicated function: #!/bin/bash # @brief: slice a bash array # @arg1: output-name # @arg2: input-name # @args: seq args ...

Jaxb, Class has two properties of the same name

with jaxb, i try to read an xml file only a few element in xml file are interesting, so i would like to skip many element xml content xml i try to read <?xml version="1.0" encoding="UTF-8"?> <!--Sample XML file generated by XMLSpy v2010 r...

SQL Server 2012 Install or add Full-text search

I am working in SQL Server 2012, and would like to use the CONTAINS() function only it seems I need to have full-text search enabled for to be able to use it. How do I enable/install this feature to an existing SQL Server 2012 install? What I need ar...

How can I find all the subsets of a set, with exactly n elements?

I am writing a program in Python, and I realized that a problem I need to solve requires me, given a set S with n elements (|S|=n), to test a function on all possible subsets of a certain order m (i.e. with m number of elements). To use the answer to...

Auto number column in SharePoint list

In a SharePoint list I want an auto number column that as I add to the list gets incremented. How best can I go about this?...

How to mute an html5 video player using jQuery

I've found how to pause and play the video using jquery $("video").get(0).play(); $("video").get(0).pause(); But I can't find the mute button, if there isn't a jquery solution, I'm fine with just an onclick js solution. I need it asap.Also is ther...

Importing data from a JSON file into R

Is there a way to import data from a JSON file into R? More specifically, the file is an array of JSON objects with string fields, objects, and arrays. The RJSON Package isn't very clear on how to deal with this http://cran.r-project.org/web/packages...

Convert file to byte array and vice versa

I've found many ways of converting a file to a byte array and writing byte array to a file on storage. What I want is to convert java.io.File to a byte array and then convert a byte array back to a java.io.File. I don't want to write it out to sto...

Best way to do multiple constructors in PHP

You can't put two __construct functions with unique argument signatures in a PHP class. I'd like to do this: class Student { protected $id; protected $name; // etc. public function __construct($id){ $this->id = $id; // ...

powershell is missing the terminator: "

I have the following script code #[string]$password = $( Read-Host "Input password, please" ) param ( [string]$ReleaseFile = $(throw "-ReleaseFile is required"), [string]$Destination = $(throw "-Destination is required") ...

What's the difference between abstraction and encapsulation?

In interviews I have been asked to explain the difference between abstraction and encapsulation. My answer has been along the lines of Abstraction allows us to represent complex real world in simplest manner. It is the process of identifying the r...

Combine two pandas Data Frames (join on a common column)

I have 2 dataframes: restaurant_ids_dataframe Data columns (total 13 columns): business_id 4503 non-null values categories 4503 non-null values city 4503 non-null values full_address 4503 non-null values latitude ...

How to revert the last migration?

I've made a migration that added a new table and want to revert it and delete the migration, without creating a new migration. How do I do it? Is there a command to revert last migration and then I can simply delete the migration file?...

Combination of async function + await + setTimeout

I am trying to use the new async features and I hope solving my problem will help others in the future. This is my code which is working: async function asyncGenerator() { // other code while (goOn) { // other code var fileList...

Android Layout Right Align

I have the following layout in place <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_he...

Define variable to use with IN operator (T-SQL)

I have a Transact-SQL query that uses the IN operator. Something like this: select * from myTable where myColumn in (1,2,3,4) Is there a way to define a variable to hold the entire list "(1,2,3,4)"? How should I define it? declare @myList {data t...

C++ code file extension? .cc vs .cpp

I have seen C++ code saved as both .cc and .cpp files. Is there a difference between the two? The Google style guide seems to suggest .cc, but provides no explanation. I am mainly concerned with programs on Linux systems....

how to cancel/abort ajax request in axios

I use axios for ajax requests and reactJS + flux for render UI. In my app there is third side timeline (reactJS component). Timeline can be managed by mouse's scroll. App sends ajax request for the actual data after any scroll event. Problem that pro...

What's the difference between select_related and prefetch_related in Django ORM?

In Django doc, select_related() "follows" foreign-key relationships, selecting additional related-object data when it executes its query. prefetch_related() does a separate lookup for each relationship, and does the "joining" in ...

VSCode: How to Split Editor Vertically

In Visual Studio code, a while ago, when I used View->Split Editor, it would split vertically. (One file on the left and one file on the right.) I updated Visual Studio Code and when when I do View->Split Editor, it always splits horizontally. (One ...

Is "else if" faster than "switch() case"?

I'm an ex Pascal guy, currently learning C#. My question is the following: Is the code below faster than making a switch? int a = 5; if (a == 1) { .... } else if(a == 2) { .... } else if(a == 3) { .... } else if(a == 4) { .... } el...

Install Windows Service created in Visual Studio

When I create a new Windows Service in Visual Studio 2010, I get the message stating to use InstallUtil and net start to run the service. I have tried the following steps: Create new project File -> New -> Project -> Windows Service Project Name: ...

How can I write these variables into one line of code in C#?

I am new to C#, literally on page 50, and i am curious as to how to write these variables in one line of code: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace consoleHelloWorld { class Program ...

Check if a String is in an ArrayList of Strings

How can I check if a String is there in the List? I want to assign 1 to temp if there is a result, 2 otherwise. My current code is: Integer temp = 0; List<String> bankAccNos = new ArrayList<String>();//assume list contains values Strin...

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

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

Error Code 1292 - Truncated incorrect DOUBLE value - Mysql

I am not sure what is this error! #1292 - Truncated incorrect DOUBLE value: I don't have double value field or data! I have wasted a whole hour trying to figure this out! here is my query INSERT INTO call_managment_system.contact_numbers ...

How to pass parameters or arguments into a gradle task

I have a gradle build script into which I am trying to include Eric Wendelin's css plugin - http://eriwen.github.io/gradle-css-plugin/ Its easy enough to implement, and because I only want minification (rather than combining and gzipping), I've got ...

How to adjust an UIButton's imageSize?

How can I adjust the image size of the UIButton? I am setting the image like this: [myLikesButton setImage:[UIImage imageNamed:@"icon-heart.png"] forState:UIControlStateNormal]; However this fills up the image to the full button, how do I make the...

How to initialize std::vector from C-style array?

What is the cheapest way to initialize a std::vector from a C-style array? Example: In the following class, I have a vector, but due to outside restrictions, the data will be passed in as C-style array: class Foo { std::vector<double> w_; p...

What permission do I need to access Internet from an Android application?

I get the following Exception running my app: java.net.SocketException: Permission denied (maybe missing INTERNET permission) How do I solve the missing permission problem?...

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

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

Use Mockito to mock some methods but not others

Is there any way, using Mockito, to mock some methods in a class, but not others? For example, in this (admittedly contrived) Stock class I want to mock the getPrice() and getQuantity() return values (as shown in the test snippet below) but I want t...

Windows cannot find 'http:/.127.0.0.1:%HTTPPORT%/apex/f?p=4950'. Make sure you typed the name correctly, and then try again

I am trying to install Oracle Express 11g, after I download the zip file OracleXE112_Win64 - I unzip it, and open Disk 1 then setup. I go through the entire installation process without any problems. However when I go to open "Get Started" I come acr...

Set width to match constraints in ConstraintLayout

I would like to constrain a View's left and right sides to it's parent view's margins and make it fill the allotted space. However, setting width to either match_parent or wrap_content appears to produce the same result. Is there something equivalen...

Seaborn Barplot - Displaying Values

I'm looking to see how to do two things in Seaborn with using a bar chart to display values that are in the dataframe, but not in the graph 1) I'm looking to display the values of one field in a dataframe while graphing another. For example, below,...

How do you use String.substringWithRange? (or, how do Ranges work in Swift?)

I have not yet been able to figure out how to get a substring of a String in Swift: var str = “Hello, playground” func test(str: String) -> String { return str.substringWithRange( /* What goes here? */ ) } test (str) I'm not able to create...

Get response from PHP file using AJAX

So here's my issue, I am using AJAX (jQuery) to post a form to process.php but the page actually needs to echo out a response such as apple or plum. I'm not sure how to take the response from process.php and have it stored as a variable... Here's th...

Formatting a number with leading zeros in PHP

I have a variable which contains the value 1234567. I would like it to contain exactly 8 digits, i.e. 01234567. Is there a PHP function for that?...

NewtonSoft.Json Serialize and Deserialize class with property of type IEnumerable<ISomeInterface>

I am trying to move some code to consume ASP.NET MVC Web API generated Json data instead of SOAP Xml. I have run into a problem with serializing and deserializing properties of type: IEnumerable<ISomeInterface>. Here is a simple example: p...

How do I make a placeholder for a 'select' box?

I'm using placeholders for text inputs which is working out just fine. But I'd like to use a placeholder for my selectboxes as well. Of course I can just use this code: <select> <option value="">Select your option</option> ...

Line break in SSRS expression

I'm having trouble adding a line break in SSRS 2008. I've tried all of these different ways but nothing is doing it. "+ chr(10) +" , "& chr(10) &" , "& chr(13) & chr(10) &" , "& vbcrlf &" , "+ vbcrlf +" , "Environment.Ne...

How to pass values between Fragments

I am pretty new to using Fragments. I am just trying to build a simple sample application that uses Fragments. My scenario is, I have two activities with one fragment inside each activity. The first fragment has an edittext and a button. The second ...

How to Solve Max Connection Pool Error

I have a application in asp.net 3.5 and Database is Sql server 2005. "Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size wa...

How to urlencode a querystring in Python?

I am trying to urlencode this string before I submit. queryString = 'eventName=' + evt.fields["eventName"] + '&' + 'eventDescription=' + evt.fields["eventDescription"]; ...

How can I tell if I'm running in 64-bit JVM or 32-bit JVM (from within a program)?

How can I tell if the JVM in which my application runs is 32 bit or 64-bit? Specifically, what functions or properties I can used to detect this within the program?...

How to restart a rails server on Heroku?

Locally I just interrupt (ctrl-c) and then start it again. How do I do the same thing with an app on heroku?...

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

Checking if a website is up via Python

By using python, how can I check if a website is up? From what I read, I need to check the "HTTP HEAD" and see status code "200 OK", but how to do so ? Cheers Related How do you send a HEAD HTTP request in Python? ...

How to create a fixed-size array of objects

In Swift, I am trying to create an array of 64 SKSpriteNode. I want first to initialize it empty, then I would put Sprites in the first 16 cells, and the last 16 cells (simulating an chess game). From what I understood in the doc, I would have expec...

Java properties UTF-8 encoding in Eclipse

I've recently had to switch encoding of webapp I'm working on from ISO-xx to utf8. Everything went smooth, except properties files. I added -Dfile.encoding=UTF-8 in eclipse.ini and normal files work fine. Properties however show some strange behaviou...

Is there an equivalent to the SUBSTRING function in MS Access SQL?

I want to do something like this within an MS Access query, but SUBSTRING is an undefined function. SELECT DISTINCT SUBSTRING(LastName, 1, 1) FROM Authors; ...

How to do a num_rows() on COUNT query in codeigniter?

This works: $sql = "SELECT id FROM `users` WHERE `account_status` = '" . $i . "'"; $query = $this->db->query($sql); var_dump($query->num_rows()); But this doesn't: $sql = "...

JavaScript equivalent of PHP’s die

Is there something like "die" in JavaScript? I've tried with "break", but doesn't work :)...

Facebook share link without JavaScript

The following link is for sharing a page on Twitter: http://twitter.com/share Is there a similar option for Facebook that doesn't require JavaScript? I know about http://facebook.com/sharer.php, but that requires a get parameter to be inserted man...

How do I return a char array from a function?

I've tried the following: char[10] testfunc() { char[10] str; return str; } ...

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

Pass value to iframe from a window

I need to send a value to an iframe. The iframe is present within the current window. How can I achieve this? I need to do it with javascript in the parent window that contains the iframe....

Set start value for column with autoincrement

I have a table Orders with the following fields: Id | SubTotal | Tax | Shipping | DateCreated The Id column is set to autoincrement(1,1). This is to be used in an E-commerce storefront. Sometimes a current E-commerce store is migrated to my pl...

How to get input textfield values when enter key is pressed in react js?

I want to pass textfield values when user press enter key from keyboard. In onChange() event, I am getting the value of the textbox, but How to get this value when enter key is pressed ? Code: import TextField from 'material-ui/TextField'; class ...

How organize uploaded media in WP?

I am new in WordPress and I came from Joomla. How can I (if I can do it...) organize the uploaded media into folder and subfolder using WordPress? If I go in my backend administration panel I have the Media sub panel in which I can add a file (for e...

How to receive JSON as an MVC 5 action method parameter

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

How to get input text value on click in ReactJS

I am learning ReactJS and I want to understand how to get the input text values in ReactJS using simple onclick event. I have followed there tutorial and although i am able to get the parameter of text input. But somehow i am not able to get its valu...

How to get ER model of database from server with Workbench

Is there any way to get an ER model of a database from the server that is connected to my MySQL Workbench?...

How to extract text from a string using sed?

My example string is as follows: This is 02G05 a test string 20-Jul-2012 Now from the above string I want to extract 02G05. For that I tried the following regex with sed $ echo "This is 02G05 a test string 20-Jul-2012" | sed -n '/\d+G\d+/p' But...

Android transparent status bar and actionbar

I've done a few researches on this topic and I couldn't find a complete solution so, step by step and with some trial and error, I finally find out how can we achieve these results: having a transparent or coloured Actionbar and Statusbar. See my an...

CSS: how to add white space before element's content?

None of the following code works : p:before { content: " "; } p:before { content: "&nbsp;"; } How do I add white space before element's content ? Note: I need to color the border-left and the margin-left for semantic use and use the space as...

Python RuntimeWarning: overflow encountered in long scalars

I am new to programming. In my latest Python 2.7 project I encountered the following: RuntimeWarning: overflow encountered in long_scalars Could someone please elaborate what this means and what I could do to fix that? The code runs through, b...

How to fix "'System.AggregateException' occurred in mscorlib.dll"

I'm receiving an unhandled exception while debugging, and the program stops executing. The debugger doesn't show me the line so I don't know what to fix. An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll Add...

Get generic type of class at runtime

How can I achieve this? public class GenericClass<T> { public Type getMyType() { //How do I return the type of T? } } Everything I have tried so far always returns type Object rather than the specific type used....

Git: How to remove proxy

I am trying to push to my repo but receiving an error: fatal: unable to access 'https://github.com/myrepo.git/': Could not resolve proxy: --list I already changed the proxy settings : git config --global --unset http.proxy my global c...

Running interactive commands in Paramiko

I'm trying to run an interactive command through paramiko. The cmd execution tries to prompt for a password but I do not know how to supply the password through paramiko's exec_command and the execution hangs. Is there a way to send values to the t...

Darkening an image with CSS (In any shape)

So I have seen quite a few ways to darken images with CSS, including ones with rounded corners, but my problem is different. Let's say I have an .png image that looks like a little dog (just go with it, I don't have any good examples), when I place ...

Where do I download JDBC drivers for DB2 that are compatible with JDK 1.5?

Where do I download JDBC drivers for DB2 that are compatible with JDK 1.5? They seem to be very elusive and I hit many dead-ends at IBM's website. I managed to find versions of the driver bundled with some tools such as IBM Data Studio. Unfortunately...

Inserting a blank table row with a smaller height

I have a table consisting of a header row and a couple of data rows. What I want to do is to create a blank row in between the header and the data rows, but I want this blank row to be smaller in height than the other rows (so that there isn't such a...

How to print the data in byte array as characters?

In my byte array I have the hash values of a message which consists of some negative values and also positive values. Positive values are being printed easily by using the (char)byte[i] statement. Now how can I get the negative value?...

Sublime Text 3, convert spaces to tabs

I know there are a lot of posts about this, but I couldn´t get it to work. I use tabs for coding. Is there a way, to convert always spaces to tabs? I.e. on open and on Save files? Anyone got an idea? // edit: My desire is to do this automatically! ...

ConvergenceWarning: Liblinear failed to converge, increase the number of iterations

Running the code of linear binary pattern for Adrian. This program runs but gives the following warning: C:\Python27\lib\site-packages\sklearn\svm\base.py:922: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. "t...

instanceof Vs getClass( )

I see gain in performance when using getClass() and == operator over instanceOf operator. Object str = new Integer("2000"); long starttime = System.nanoTime(); if(str instanceof String) { System.out.println("its string"); } else { if (str...

Android Studio says "cannot resolve symbol" but project compiles

I'm importing twitter4j in AndroidStudio, using the following in my build.gradle: dependencies { compile 'com.android.support:support-v4:18.0.+' compile files('libs/twitter4j-core-3.0.4.jar') } The project compiles fine, and I can create twitt...

How to put a List<class> into a JSONObject and then read that object?

I have a List<class> that I would like to convert into a json object and then traverse the data out of the json object. If this were just a list<String> I could just do something like: JSONObject obj = new JSONObject(); List<String...

javascript code to check special characters

I have JavaScript code to check if special characters are in a string. The code works fine in Firefox, but not in Chrome. In Chrome, even if the string does not contain special characters, it says it contains special characters. var iChars = "~`!#$%...

Ruby: Calling class method from instance

In Ruby, how do you call a class method from one of that class's instances? Say I have class Truck def self.default_make # Class method. "mac" end def initialize # Instance method. Truck.default_make # gets the default via th...

Using PHP variables inside HTML tags?

I am pretty new to php but I'm stuck on this problem... Say i wait to put a link to another site with a given parameter, how do I do it correclty? This is what i have now: <html> <body> <?php $param = "test"; echo "<a href="h...

How to insert data into elasticsearch

I am new to Elasticearch, and I have been trying for 2 days to insert some data into Elasticearch. I found on Google that there are many pages to help to create an index (I am not clear about "index", does it mean "insert" in other terms?) Then many ...

Create a menu Bar in WPF?

I want to create a menu bar identical to the one in windows forms in my WPF application. How would I do this? The menu option in the WPF controls toolbox only gives a blank bar....

PyCharm shows unresolved references error for valid code

I am using PyCharm to work on a project. The project is opened and configured with an interpreter, and can run successfully. The remote interpreter paths are mapped properly. This seems to be the correct configuration, but PyCharm is highlighting ...

How do I add a Maven dependency in Eclipse?

I don't know how to use Maven at all. I've been developing for a couple years with Eclipse and haven't yet needed to know about it. However, now I'm looking at some docs that suggest I do the following: "To include it within your project, just ad...

AJAX post error : Refused to set unsafe header "Connection"

I have the following custom ajax function that posts data back to a PHP file. Everytime the post of data happens I get the following two errors : Refused to set unsafe header "Content-length" Refused to set unsafe header "Connection" Code : ...

How to load images dynamically (or lazily) when users scrolls them into view

I've noticed this in numerous "modern" websites (e.g. facebook and google image search) where the images below the fold load only when user scrolls down the page enough to bring them inside the visible viewport region (upon view source, the page show...

"ArrayAdapter requires the resource ID to be a TextView" xml problems

I am getting an error when trying to set my view to display the ListView for the file I want to display(text file). I am pretty sure it has something to do with the xml. I just want to display the information from this.file = fileop.ReadFileAsList("I...

How to resolve a Java Rounding Double issue

Seems like the subtraction is triggering some kind of issue and the resulting value is wrong. double tempCommission = targetPremium.doubleValue()*rate.doubleValue()/100d; 78.75 = 787.5 * 10.0/100d double netToCompany = targetPremium.doubleValue()...

C++: variable 'std::ifstream ifs' has initializer but incomplete type

Sorry if this is pretty noobish, but I'm pretty new to C++. I'm trying to open a file and read it using ifstream: vector<string> load_f(string file) { vector<string> text; ifstream ifs(file); string buffer, str_line; int bracke...

CSS Change List Item Background Color with Class

I am trying to change the background color of one list item while there is another background color for other list items. This is what I have: _x000D_ _x000D_ <style type="text/css">_x000D_ _x000D_ ul.nav li_x000D_ {_x000D_ display:inli...

Fatal error: Call to a member function query() on null

I'm not sure what's going wrong here. I was just following a tutorial online and these errors popped up. I'm getting the following errors Error Notice: Undefined variable: db in C:\xampp\htdocs\wisconsindairyfarmers\admin\login.php on line 7 Fata...

How do I get list of methods in a Python class?

I want to iterate through the methods in a class, or handle class or instance objects differently based on the methods present. How do I get a list of class methods? Also see: How can I list the methods in a Python 2.5 module? Looping over a Pyth...

C# Generics and Type Checking

I have a method that uses an IList<T> as a parameter. I need to check what the type of that T object is and do something based on it. I was trying to use the T value, but the compiler does not not allow it. My solution is the following: pri...

Any way (or shortcut) to auto import the classes in IntelliJ IDEA like in Eclipse?

In Eclipse, while coding in Java and press Ctrl + Shift + O auto import all the Classes automatically. In NetBeans, this is done with Ctrl + Shift + I. Is any way to do this in IntelliJ IDEA? I searched an equivalent shortcut in google, StackOverfl...

Display html text in uitextview

How can I display HTML text in textview? For example, string &lt;h1&gt;Krupal testing &lt;span style="font-weight: bold;"&gt;Customer WYWO&lt;/span&gt;&lt;/h1&gt; Suppose text is bold so it display in textview as b...

What does it mean when an HTTP request returns status code 0?

What does it mean when JavaScript network calls such as fetch or XMLHttpRequest, or any other type of HTTP network request, fail with an HTTP status code of 0? This doesn't seem to be a valid HTTP status code as other codes are three digits in HTTP ...

Make the current Git branch a master branch

I have a repository in Git. I made a branch, then did some changes both to the master and to the branch. Then, tens of commits later, I realized the branch is in much better state than the master, so I want the branch to "become" the master and disr...

Dynamically Add C# Properties at Runtime

I know there are some questions that address this, but the answers usually follow along the lines of recommending a Dictionary or Collection of parameters, which doesn't work in my situation. I am using a library that works through reflection to do ...

While loop to test if a file exists in bash

I'm working on a shell script that does certain changes on a txt file only if it does exist, however this test loop doesn't work, I wonder why? Thank you! while [ ! -f /tmp/list.txt ] ; do sleep 2 done ...

In Python, how do you convert seconds since epoch to a `datetime` object?

The time module can be initialized using seconds since epoch: >>> import time >>> t1=time.gmtime(1284286794) >>> t1 time.struct_time(tm_year=2010, tm_mon=9, tm_mday=12, tm_hour=10, tm_min=19, tm_sec=54, t...

What is an IndexOutOfRangeException / ArgumentOutOfRangeException and how do I fix it?

I have some code and when it executes, it throws a IndexOutOfRangeException, saying, Index was outside the bounds of the array. What does this mean, and what can I do about it? Depending on classes used it can also be ArgumentOutOfRangeExcept...

How do I initialize Kotlin's MutableList to empty MutableList?

Seems so simple, but, how do I initialize Kotlin's MutableList to empty MutableList? I could hack it this way, but I'm sure there is something easier available: var pusta: List<Kolory> = emptyList() var cos: MutableList<Kolory> = pusta....

Removing unwanted table cell borders with CSS

I have a peculiar and frustrating problem. For the simple markup: <table> <thead> <tr><th>1</th><th>2</th><th>3</th></tr> </thead> <tbody> <tr>...

How to change the plot line color from blue to black?

I am stuck when I have generated a set of data and tried to color the plot line in python. For example I would like to change the line color from blue to black here. This is what I have and returns is the set of data that I got from pandas. ax=pl...

NameError: name 'datetime' is not defined

I'm teaching myself Python and was just "exploring". Google says that datetime is a global variable but when I try to find todays date in the terminal I receive the NameError in the question title? mynames-MacBook:pythonhard myname$ python Enthought...

Jupyter Notebook not saving: '_xsrf' argument missing from post

I've been running a script on jupyter notebooks for about 26 hour; I haven't really been using my computer for anything else, but it needs to run this program that will take ~30 hours to complete. At about 21 hours in, it stopped saving and my termin...

File.Move Does Not Work - File Already Exists

I've got a folder: c:\test I'm trying this code: File.Move(@"c:\test\SomeFile.txt", @"c:\test\Test"); I get exception: File already exists The output directory definitely exists and the input file is there....

Best way to implement multi-language/globalization in large .NET project

I'll soon be working on a large c# project and would like to build in multi-language support from the start. I've had a play around and can get it working using a separate resource file for each language, then use a resource manager to load up the st...

How to check if a variable is NULL, then set it with a MySQL stored procedure?

I have a MySQL stored procedure where I find the max value from a table. If there is no value I want to set the variable to yesterday's date. DECLARE current_procedure_name CHAR(60) DEFAULT 'accounts_general'; DECLARE last_run_time datetime DEFAUL...

How to calculate a mod b in Python?

Is there a modulo function in the Python math library? Isn't 15 % 4, 3? But 15 mod 4 is 1, right?...

Java: How to read a text file

I want to read a text file containing space separated values. Values are integers. How can I read it and put it in an array list? Here is an example of contents of the text file: 1 62 4 55 5 6 77 I want to have it in an arraylist as [1, 62, 4, 55...

Whoops, looks like something went wrong. Laravel 5.0

I installed Laravel 5.0 properly by cloning in git, and composer install, when I ran it to browser http://localhost/laravel/public/, it says "Whoops, looks like something went wrong." I did not make any changes after composer install. Update a...

Get string between two strings in a string

I have a string like: "super exemple of string key : text I want to keep - end of my string" I want to just keep the string which is between "key : " and " - ". How can I do that? Must I use a Regex or can I do it in another way?...

How to add Options Menu to Fragment in Android

I am trying to add an item to the options menu from a group of fragments. I have created a new MenuFragment class and extended this for the fragments I wish to include the menu item in. Here is the code: Java: public class MenuFragment extends Fra...

Unsupported operand type(s) for +: 'int' and 'str'

I am currently learning Python so I have no idea what is going on. num1 = int(input("What is your first number? ")) num2 = int(input("What is your second number? ")) num3 = int(input("What is your third number? ")) numlist = [num1, num2, num3] prin...

How to write a stored procedure using phpmyadmin and how to use it through php?

I want to be able create stored procedures using phpMyAdmin and later on use it through php. But I dont know how to? From what I know, I found out that we cannot manage stored procedures through phpMyAdmin. What other tool can manage stored procedure...

HTML button opening link in new tab

So this is the simple code for the button to open a certain link <button class="btn btn-success" onclick="location.href='http://google.com';"> Google</button> but it opens it on the same page, I want the link to open on...

How do you create an asynchronous method in C#?

Every blog post I've read tells you how to consume an asynchronous method in C#, but for some odd reason never explain how to build your own asynchronous methods to consume. So I have this code right now that consumes my method: private async void b...

How to enable support of CPU virtualization on Macbook Pro?

I have the VirtualBox installed on my Macbook Pro, and I want to install a linux VM on VirtualBox. When I launched the new VM, it prompts that "Your CPU does not support long mode. Use a 32bit distribution." After searching for this problem, I foun...

How do I get and set Environment variables in C#?

How can I get Environnment variables and if something is missing, set the value?...

Float right and position absolute doesn't work together

I want a div to be always at the right of its parent div, so I use float:right. It works. But I also want it to not affect other content when inserted, so I use position:absolute. Now float:right doesn't work, my div is always at the left of its pa...

Extract every nth element of a vector

I would like to create a vector in which each element is the i+6th element of another vector. For example, in a vector of length 120 I want to create another vector of length 20 in which each element is value i, i+6, i+12, i+18... of the initial vec...

How to install mongoDB on windows?

I am trying to test out mongoDB and see if it is anything for me. I downloaded the 32bit windows version, but have no idea on how to continue from now on. I normally use the WAMP services for developing on my local computer. Can i run mongoDB on Wam...

Concatenate in jQuery Selector

Simple problem. I have a js variable I want to be concatenated too within a jQuery selector. However it is not working. No errors are popping up either. What is wrong? How do I correctly concatenate a variable to some text in a jQuery selector. <...

How to change Label Value using javascript

I want to change the label value from '0' to 'thanks' in below label, on checkbox click event. <input type="hidden" name="label206451" value="0" /> <label for="txt206451" class="swatch_text" >Chestnut Leather</label> <input type...

PHPExcel - creating multiple sheets by iteration

I'm trying to create multiple sheets by iteration in phpexcel: $i=0; while ($i < 10) { // Add new sheet $objWorkSheet = $objPHPExcel->createSheet(); // Attach the newly-cloned sheet to the $objPHPExcel workbook $objPHPExcel->addSheet($o...

Getting path of captured image in Android using camera intent

I have been trying to get path of captured image in order to delete image. Found many answers on StackOverflow but none of them are working for me. I got the following answer: private String getLastImagePath() { final String[] imageColumns = { M...

"Use the new keyword if hiding was intended" warning

I have a warning at the bottom of my screen: Warning 1 'WindowsFormsApplication2.EventControlDataSet.Events' hides inherited member 'System.ComponentModel.MarshalByValueComponent.Events'. Use the new keyword if hiding was intended. C...

Generating a unique machine id

I need to write a function that generates an id that is unique for a given machine running a Windows OS. Currently, I'm using WMI to query various hardware parameters and concatenate them together and hash them to derive the unique id. My question i...

What is the difference between IQueryable<T> and IEnumerable<T>?

What is the difference between IQueryable<T> and IEnumerable<T>? See also What's the difference between IQueryable and IEnumerable that overlaps with this question....

CSS Flex Box Layout: full-width row and columns

Hello fellow programmers! I've got a simple box-layout which I would love to achieve using flexbox, but I simply can't figure it out. It should look like this image. So basically a row and two columns, with the row being fixed at lets say 100px i...

Java reverse an int value without using array

Can anyone explain to me how to reverse an integer without using array or String. I got this code from online, but not really understand why + input % 10 and divide again. while (input != 0) { reversedNum = reversedNum * 10 + input % 10; inp...

Jasmine.js comparing arrays

Is there a way in jasmine.js to check if two arrays are equal, for example: arr = [1, 2, 3] expect(arr).toBe([1, 2, 3]) expect(arr).toEqual([1, 2, 3]) Neither seems to work....

How to write macro for Notepad++?

I would like to write a macro for Notepad++ which should replace char1, char2, char3 with char4, char5, char6, respectively....

Android Layout Weight

I am new to Android development and I have a question about setting weight in a linear layout. I am trying to create a row with two custom buttons and a custom edit text. The edit text should only take up as much room as its content, and the two ...

"Object doesn't support this property or method" error in IE11

I am getting the error Critical Error: Object doesn't support this property or method addeventlistener while accessing the InfoPath form page (using InfoPath enabled list form e.g. displayifs.aspx) in IE 11 browser. This error is specific to ...

Can I load a .NET assembly at runtime and instantiate a type knowing only the name?

Is it possible to instantiate an object at runtime if I only have the DLL name and the class name, without adding a reference to the assembly in the project? The class implements a interface, so once I instantiate the class, I will then cast it to th...

jQuery: click function exclude children.

Trying to wrap my head around the jQuery ".not()" function, and running into a problem. I would like to have the parent div to be "clickable" but if a user clicks on a child element, the script is not called. $(this).not(children()).click(function()...

CSS change button style after click

I was wondering if there was a way to change a button's style, in css, after it's been clicked, so not a element:active. Thanks!...

Unsupported Media Type in postman

I am implementing spring security with oauth2 and jwt. the below is my login function function doLogin(loginData) { $.ajax({ url : back+"/auth/secret", type : "POST", data : JSON.stringify(loginData), contentTyp...

Updating the list view when the adapter data changes

When the data associated with array adapter is changed, invalidating the listview is sufficient to show the updated values? Following piece of code is not working, did i misunderstood something here.? public class ZeroItemListActivity extends Activi...

TypeError: $(...).on is not a function

I am using jQuery litebox. After adding JS and CSS files I got this error TypeError: $(...).on is not a function at this line in js file "return $('body').on('click', 'a[rel^=lightbox], area[rel^=...

Is it necessary to assign a string to a variable before comparing it to another?

I want to compare the value of an NSString to the string "Wrong". Here is my code: NSString *wrongTxt = [[NSString alloc] initWithFormat:@"Wrong"]; if( [statusString isEqualToString:wrongTxt] ){ doSomething; } Do I really have to create an N...

How to remove empty lines with or without whitespace in Python

I have large string which I split by newlines. How can I remove all lines that are empty, (whitespace only)? pseudo code: for stuff in largestring: remove stuff that is blank ...

@AspectJ pointcut for all methods of a class with specific annotation

I want to monitor all public methods of all Classes with specified annotation (say @Monitor) (note: Annotation is at class level). What could be a possible pointcut for this? Note: I am using @AspectJ style Spring AOP....

How do I get column names to print in this C# program?

I've cobbled together a C# program that takes a .csv file and writes it to a DataTable. Using this program, I can loop through each row of the DataTable and print out the information contained in the row. The console output looks like this: --- Ro...

WCF Service, the type provided as the service attribute values…could not be found

When I right click on Eval.svc within Visual Studio 2012 and view in browser, I get the following - The type 'EvalServiceLibary.Eval', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element...

How to convert 'binary string' to normal string in Python3?

For example, I have a string like this(return value of subprocess.check_output): >>> b'a string' b'a string' Whatever I did to it, it is always printed with the annoying b' before the string: >>> print(b'a string') b'a string' &...

VIM Disable Automatic Newline At End Of File

So I work in a PHP shop, and we all use different editors, and we all have to work on windows. I use vim, and everyone in the shop keeps complaining that whenever I edit a file there is a newline at the bottom. I've searched around and found that th...

Does "\d" in regex mean a digit?

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

Group dataframe and get sum AND count?

I have a dataframe that looks like this: Company Name Organisation Name Amount 10118 Vifor Pharma UK Ltd Welsh Assoc for Gastro & Endo 2700.00 10119 Vifor Pharma UK Ltd Welsh IBD Specialist Group, 169.00 10120 ...

Commands out of sync; you can't run this command now

I am trying to execute my PHP code, which calls two MySQL queries via mysqli, and get the error "Commands out of sync; you can't run this command now". Here is the code I am using <?php $con = mysqli_connect("localhost", "user", "password", "db"...

how to delete files from amazon s3 bucket?

I need to write code in python that will delete the required file from an Amazon s3 bucket. I am able to connect to the Amazon s3 bucket, and also to save files, but how can I delete a file?...

How can I detect keydown or keypress event in angular.js?

I'm trying to get the value of a mobile number textbox to validate its input value using angular.js. I'm a newbie in using angular.js and not so sure how to implement those events and put some javascript to validate or manipulate the form inputs on m...

Where is the Microsoft.IdentityModel dll

I have installed the Windows Identity Foundation but can't find the Microsoft.IdentityModel dll. According to the Azure Hands-on-Labs it should just be in Add Reference in VS2010. However it's not there. I also looked in c:\Program Files(x86)\Window...

Convert a Python int into a big-endian string of bytes

I have a non-negative int and I would like to efficiently convert it to a big-endian string containing the same data. For example, the int 1245427 (which is 0x1300F3) should result in a string of length 3 containing three characters whose byte value...

How do I merge changes to a single file, rather than merging commits?

I have two branches (A and B) and I want to merge a single file from branch A with a corresponding single file from Branch B....

How do I prevent a form from being resized by the user?

I have a form that needs to be maximized in VB.net. I don't want the user to be able to change its size or move it around. How can I do this?...

Is there any way to debug chrome in any IOS device

Is there any way to debug chrome browser on IOS device? If there is no way, how i can approach to bug in chrome on ios? Searched the web and didn't find sufficient answer....

Sending simple message body + file attachment using Linux Mailx

I am writing a shell script to send an email using Linux Mailx, the email must contain a file attachment and a message body. Currently sending an email with an attachment: output.txt | mail -s "Daily Monitoring" [email protected] I wish to add a mes...

Makefile If-Then Else and Loops

Can someone explain how to use if-then statements and for loops in Makefiles? I can't seem to find any good documentation with examples....

Undefined reference to `sin`

I have the following code (stripped down to the bare basics for this question): #include<stdio.h> #include<math.h> double f1(double x) { double res = sin(x); return 0; } /* The main function */ int main(void) { return 0; } ...

UITableView, Separator color where to set?

I have added a UITableView in IB and set the "delegate" and "datasource" and all is working well. What I wanted to do next was change the separator color, but the only way I could find to do this was to add the method to one of the delegate callbacks...

angular-cli where is webpack.config.js file - new angular6 does not support ng eject

UPDATE: December 2018 (see 'Aniket' answer) With Angular CLI 6 you need to use builders as ng eject is deprecated and will soon be removed in 8.0 UPDATE: June 2018: Angular 6 does not support ng eject** UPDATE: February 2017: use ng eject UPDATE...

Data-frame Object has no Attribute

I know that this kind of question was asked before and I've checked all the answers and I have tried several times to find a solution but in vain. In fact I call a Dataframe using Pandas. I've uploaded a csv.file. When I type data.Country and dat...

Put Excel-VBA code in module or sheet?

What is good practice and good code hygiene? Putting code in Modules or Sheets? I have this Excel Workbook, with user interfaces in each sheet. Each sheet within the workbook does a different part of some overall task. Should I place the code releva...

What is the purpose of Node.js module.exports and how do you use it?

What is the purpose of Node.js module.exports and how do you use it? I can't seem to find any information on this, but it appears to be a rather important part of Node.js as I often see it in source code. According to the Node.js documentation: modu...

Warning as error - How to get rid of these

I cannot figure out how to get rid of errors that basically should not be halting my compile in Visual Studio 2010 and should not be show stoppers, or at least I will fix them later, but I don't want the compile to just error and halt on th...

How to remove a variable from a PHP session array

I have PHP code that is used to add variables to a session: <?php session_start(); if(isset($_GET['name'])) { $name = isset($_SESSION['name']) ? $_SESSION['name'] : array(); $name[] = $_GET['name']; $_SESSION['...

How to parse JSON array in jQuery?

EDIT I checked the jQuery documentation and using $.ajax with the json datatype specified returns an evaluated javascript object, so eval() isn't the answer here. I knew that anyway, since I am able to parse single JSON objects, just not arrays. Th...

Getting Index of an item in an arraylist;

I have a Class called AuctionItem. The AuctionItem Class has a method called getName() that returns a String. If I have an ArrayList of type AuctionItem, what is the best way to return the index of an item in the ArrayList that has a specific name? ...

What does question mark and dot operator ?. mean in C# 6.0?

With C# 6.0 in the VS2015 preview we have a new operator, ?., which can be used like this: public class A { string PropertyOfA { get; set; } } ... var a = new A(); var foo = "bar"; if(a?.PropertyOfA != foo) { //somecode } What exactly does...

How to wait till the response comes from the $http request, in angularjs?

I am using some data which is from a RESTful service in multiple pages. So I am using angular factories for that. So, I required to get the data once from the server, and everytime I am getting the data with that defined service. Just like a global v...

Convert Swift string to array

How can I convert a String "Hello" to an Array ["H","e","l","l","o"] in Swift? In Objective-C I have used this: NSMutableArray *characters = [[NSMutableArray alloc] initWithCapacity:[myStrin...

startsWith() and endsWith() functions in PHP

How can I write two functions that would take a string and return if it starts with the specified character/string or ends with it? For example: $str = '|apples}'; echo startsWith($str, '|'); //Returns true echo endsWith($str, '}'); //Returns true...

Convert DateTime to TimeSpan

I want to convert a DateTime instance into a TimeSpan instance, is it possible? I've looked around but I couldn't find what I want, I only find time difference. More specifically, I want to convert a DateTime instance into milliseconds, to then sav...

Program to find largest and second largest number in array

I have searched many websites for this question. They are doing it by some different approach. This code is just not giving output if I input first element of array as largest i.e. a[0]. I think some minor change is required. can anyone please tell m...

Buiding Hadoop with Eclipse / Maven - Missing artifact jdk.tools:jdk.tools:jar:1.6

I am trying to import cloudera's org.apache.hadoop:hadoop-client:2.0.0-cdh4.0.0 from cdh4 maven repo in a maven project in eclipse 3.81, m2e plugin, with oracle's jdk 1.7.0_05 on win7 using <dependency> <groupId>org.apache.hadoop<...

Using Axios GET with Authorization Header in React-Native App

I'm trying to use axios for a GET request with an API which requires an Authorization header. My current code: const AuthStr = 'Bearer ' + USER_TOKEN; where USER_TOKEN is the access token needed. This string concatenation may be the issue as if I...

How to convert a boolean array to an int array

I use Scilab, and want to convert an array of booleans into an array of integers: >>> x = np.array([4, 3, 2, 1]) >>> y = 2 >= x >>> y array([False, False, True, True], dtype=bool) In Scilab I can use: >>>...

jQuery .search() to any string

I saw this code snippet: $("ul li").text().search(new RegExp("sometext", "i")); and wanted to know if this can be extended to any string? I want to accomplish the following, but it dosen't work: $("li").attr("title").search(new RegExp("sometext"...

Is there a command like "watch" or "inotifywait" on the Mac?

I want to watch a folder on my Mac (Snow Leopard) and then execute a script (giving it the filename of what was just moved into a folder (as a parameter... x.sh "filename")). I have a script all written up in bash (x.sh) that will move some files an...

JVM property -Dfile.encoding=UTF8 or UTF-8?

I would like to know what is the value of the Java Virtual Machine (JVM) property to set my file encoding to UTF-8. Do I put -Dfile.encoding=UTF8 or -Dfile.encoding=UTF-8?...

How to convert existing non-empty directory into a Git working directory and push files to a remote repository

I have a non-empty directory (eg /etc/something) with files that cannot be renamed, moved, or deleted. I want to check this directory into git in place. I want to be able to push the state of this repository to a remote repository (on another machin...

How to remove a row from JTable?

I want to remove some rows from a JTable. How can I do it?...

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

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

increase legend font size ggplot2

Is there a way to increase the font size in ggplot2? I think I need to specify something like legend.key.width = unit(2, "line") in the theme function, but that is used to adjust the keys in legends, not the font sizes. Thanks!...

How to remove old and unused Docker images

When running Docker for a long time, there are a lot of images in system. How can I remove all unused Docker images at once safety to free up the storage? In addition, I also want to remove images pulled months ago, which have the correct TAG. So, ...

Submit form without page reloading

I have a classifieds website, and on the page where ads are showed, I am creating a "Send a tip to a friend" form... So anybody who wants can send a tip of the ad to some friends email-adress. I am guessing the form must be submitted to a php page ...

How to output an Excel *.xls file from classic ASP

I have a number of generated html tables that I need to output as an Excel file. The site is codded in classic ASP. Is this possible? Could it be done by somehow using the Open Office libraries? EDIT: Thus far, I have tried some of the suggestions...

Removing all unused references from a project in Visual Studio projects

I just wondered if it possible within various Visual Studio versions to automatically remove all references from a project that were never been used? In your answer, please specify which version of VS the solution applies to....

How to run Spyder in virtual environment?

I have been using Spyder installed with with Anaconda distribution which uses Python 2.7 as default. Currently I need to set up a development virtual environment with Python 3.4. Top two suggestions after research online are: to set up virtual en...

Get driving directions using Google Maps API v2

I am trying to get the driving direction between the two positions: LatLng(12.917745600000000000,77.623788300000000000) LatLng(12.842056800000000000,7.663096499999940000) The code which i have tried: Polyline line = mMap.addPolyline(new PolylineO...

Laravel 5 call a model function in a blade view

I want to build a blade view from 3 tables: "inputs_details" - fields: article_type (values: 'p' for product,'s' for service), article_id, .... "products" - fields: id, name "services" - fields: id, name But, in browser, I have the error: "Clas...

How to use if statements in underscore.js templates?

I'm using the underscore.js templating function and have done a template like this: <script type="text/template" id="gridItem"> <div class="griditem <%= gridType %> <%= gridSize %>"> <img src="<%= image %&g...

How may I sort a list alphabetically using jQuery?

I'm a bit out of my depth here and I'm hoping this is actually possible. I'd like to be able to call a function that would sort all the items in my list alphabetically. I've been looking through the jQuery UI for sorting but that doesn't seem to be...

Google Maps v2 - set both my location and zoom in

My question is, does anyone know how to set google maps up, to open up both my location and in a zoomed-in view? Currently, the main view opens up to Africa, all the way zoomed out. And so I have been searching for days now, and all I can find are:...

How to get current working directory using vba?

I am using MS Excel 2010 and trying to get the current directory using the below code, path = ActiveWorkbook.Path But ActiveWorkbook.Path returns blank....

Specify a Root Path of your HTML directory for script links?

I'm writing a template for dreamweaver, and don't want to change the scripts for subfolder pages. Is there a way to make the path relative to the root directory? for example: <link type="text/css" rel="stylesheet" href="**root**/style.css" />...

Google maps responsive resize

I'm trying to get google maps responsive and resize while keeping its center when windows resizes. I read other stack questions in regards such as: Responsive Google Map? and Center Google Maps (V3) on browser resize (responsive) from the second st...

Finding what methods a Python object has

Given a Python object of any kind, is there an easy way to get the list of all methods that this object has? Or, if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error oc...

Have a reloadData for a UITableView animate when changing

I have a UITableView that has two modes. When we switch between the modes I have a different number of sections and cells per section. Ideally, it would do some cool animation when the table grows or shrinks. Here is the code I tried, but it doesn...

How to convert from []byte to int in Go Programming

I need to create a client-server example over TCP. In the client side I read 2 numbers and I send them to the server. The problem I faced is that I can't convert from []byte to int, because the communication accept only data of type []byte. Is there...

How do I add an existing directory tree to a project in Visual Studio?

The issue is simple really. Instead of creating folders in Visual Studio, I create a directory structure for my project on the file system. How do I include all the folders and files in a project, keeping the structure? If I "Add Existing File" on a...

Unable to locate an executable at "/usr/bin/java/bin/java" (-1)

I am having a pathetic issue with Java in my mac osx 10.7.3 . Previously I installed it and it was working fine. After some changes in the .bash_profile and .profile file in the course of time, I am having an error like Unable to locate an executab...

The name 'ViewBag' does not exist in the current context

I am trying to use ViewBag in my application, I have all of the recent dlls, the latest version of MVC 3, but yet I am still getting the Error: "The name 'ViewBag' does not exist in the current context" I have even uninstalled and then re-insta...

How to use PHP OPCache?

PHP 5.5 has been released and it features a new code caching module called OPCache, but there doesn't appear to be any documentation for it. So where is the documentation for it and how do I use OPcache?...

How to destroy an object?

As far as I know (which is very little) , there are two ways, given: $var = new object() Then: // Method 1: Set to null $var = null; // Method 2: Unset unset($var); Other better method? Am I splitting hairs here?...

How to view UTF-8 Characters in VIM or Gvim

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

How to enable CORS in AngularJs

I have created a demo using JavaScript for Flickr photo search API. Now I am converting it to the AngularJs. I have searched on internet and found below configuration. Configuration: myApp.config(function($httpProvider) { $httpProvider.defaults...

MySQL : transaction within a stored procedure

The basic structure of my stored procedure is, BEGIN .. Declare statements .. START TRANSACTION; .. Query 1 .. .. Query 2 .. .. Query 3 .. COMMIT; END MySQL version: 5.1.61-0ubuntu0.11.10.1-log Current...

Select value from list of tuples where condition

I have a list of tuples. Every tuple has 5 elements (corresponding to 5 database columns) and I'd like to make a query select attribute1 from mylist where attribute2 = something e.g. personAge = select age from mylist where person_id = 10 Is it...

How to remove the arrow from a select element in Firefox

I'm trying to style a select element using CSS3. I'm getting the results I desire in WebKit (Chrome / Safari), but Firefox isn't playing nicely (I'm not even bothering with IE). I'm using the CSS3 appearance property, but for some reason I can't sha...

How can I show figures separately in matplotlib?

Say that I have two figures in matplotlib, with one plot per figure: import matplotlib.pyplot as plt f1 = plt.figure() plt.plot(range(0,10)) f2 = plt.figure() plt.plot(range(10,20)) Then I show both in one shot plt.show() Is there a way to sho...

Rails: How to reference images in CSS within Rails 4

There's a strange issue with Rails 4 on Heroku. When images are compiled they have hashes added to them, yet the reference to those files from within CSS don't have the proper name adjusted. Here's what I mean. I have a file called logo.png. Yet w...

Best way to incorporate Volley (or other library) into Android Studio project

I've seen different advice on the best way to do this This question covers creating a jar. Elsewhere, I've seen advice to simply copy the volley source into your own project. This section on libraries at android.com would seem the most authoritative....

Nullable property to entity field, Entity Framework through Code First

Using the data annotation Required like so: [Required] public int somefield {get; set;} Will set somefield to Not Null in database, How can I set somefield to allow NULLs?, I tried setting it through SQL Server Management Studio but Entity Framewo...

How can I determine browser window size on server side C#

How can I get the exact height and width of the currently open browser screen window?...

Should I use alias or alias_method?

I found a blog post on alias vs. alias_method. As shown in the example given in that blog post, I simply want to alias a method to another within the same class. Which should I use? I always see alias used, but someone told me alias_method is better....

Getting "TypeError: failed to fetch" when the request hasn't actually failed

I'm using fetch API within my React app. The application was deployed on a server and was working perfectly. I tested it multiple times. But, suddenly the application stopped working and I've no clue why. The issue is when I send a get request, I'm r...

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

"message failed to fetch from registry" while trying to install any module

I can't install any node module from the npm. npm install socket.io The above command resulted to below output, it is not able to install socket.io npm http GET https://registry.npmjs.org/socket.io npm ERR! Error: failed to fetch from registry: ...

Unsuccessful append to an empty NumPy array

I am trying to fill an empty(not np.empty!) array with values using append but I am gettin error: My code is as follows: import numpy as np result=np.asarray([np.asarray([]),np.asarray([])]) result[0]=np.append([result[0]],[1,2]) And I am getting...

Making a drop down list using swift?

What is the library to make drop down menu in swift? I am new to Xcode and the Swift language, so can anyone please direct me on how to implement the drop down list in swift?...

Java sending and receiving file (byte[]) over sockets

I am trying to develop a very simple client / server where the client converts a file to bytes, sends it to the server, and then converts the bytes back in to a file. Currently the program just creates an empty file. I'm not a fantastic Java develo...

How to search a string in another string?

Possible Duplicate: How to see if a substring exists inside another string in Java 1.4 How would I search for a string in another string? This is an example of what I'm talking about: String word = "cat"; String text = "The cat is on the...

How can I use a carriage return in a HTML tooltip?

I'm currently adding verbose tooltips to our site, and I'd like (without having to resort to a whizz-bang jQuery plugin, I know there are many!) to use carriage returns to format the tooltip. To add the tip I'm using the title attribute. I've looked...

Ignore mapping one property with Automapper

I'm using Automapper and I have the following scenario: Class OrderModel has a property called 'ProductName' that isn't in the database. So when I try to do the mapping with: Mapper.CreateMap<OrderModel, Orders>(); It generates an exception...

How can I represent 'Authorization: Bearer <token>' in a Swagger Spec (swagger.json)

I am trying to convey that the authentication/security scheme requires setting a header as follows: Authorization: Bearer <token> This is what I have based on the swagger documentation: securityDefinitions: APIKey: type: apiKey na...

Call to undefined function curl_init().?

When i am going to implement Authorize.net payment gateway. However, I got this error: Call to undefined function curl_init() Please let me know what is wrong in it....

What are callee and caller saved registers?

I'm having some trouble understanding the difference between caller and callee saved registers and when to use what. I am using the MSP430 : procedure: mov.w #0,R7 mov.w #0,R6 add.w R6,R7 inc.w R6 cmp.w R12,R6 jl l$loop mov.w R7,R12 ret t...

Twitter Bootstrap Modal Form Submit

I've recently been fiddling around with twitter bootstrap, using java/jboss, and i've been attempting to submit a form from a Modal interface, the form contains just a hidden field and nothing else so display etc. is unimportant. The form is externa...

Use of alloc init instead of new

Learning Objective-C and reading sample code, I notice that objects are usually created using this method: SomeObject *myObject = [[SomeObject alloc] init]; instead of: SomeObject *myObject = [SomeObject new]; Is there a reason for this, as I h...

Frequency table for a single variable

One last newbie pandas question for the day: How do I generate a table for a single Series? For example: my_series = pandas.Series([1,2,2,3,3,3]) pandas.magical_frequency_function( my_series ) >> { 1 : 1, 2 : 2, 3 : 3 } ...

Disable JavaScript error in WebBrowser control

I am developing a windows application with a WebBrowser control that navigates to a sharepoint site. My problem is that i am getting JavaScript error. How can i disable the JavaScript error? I don't want them to pop up....

Check if any type of files exist in a directory using BATCH script

Hello I'm looking to write a batch file to check to see if there are any files of any type inside a given folder. So far I've tried the following if EXIST FOLDERNAME\\*.* ( echo Files Exist ) ELSE ( echo "Empty" ) I can get it to work if I know ...

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

json.net has key method?

If my response has key "error" I need to process error and show warning box. Is there "haskey" method exists in json.net? Like: var x= JObject.Parse(string_my); if(x.HasKey["error_msg"]) MessageBox.Show("Error!") ...

YAML: Do I need quotes for strings in YAML?

I am trying to write a YAML dictionary for internationalisation of a Rails project. I am a little confused though, as in some files I see strings in double-quotes and in some without. A few points to consider: example 1 - all strings use double quot...

What is the difference between SQL, PL-SQL and T-SQL?

What is the difference between SQL, PL-SQL and T-SQL? Can anyone explain what the differences between these three are, and provide scenarios where each would be relevantly used?...

Moving from one activity to another Activity in Android

I want to move from one activity to another (using virtual device). When I click on button to move, My emulator ones a dialog box showing unfortunately SMS1 has stopped working (SMS1 is my app name). Can anybody help me in correcting my code? Main...

MySql export schema without data

I'm using a MySql database with a Java program, now I want to give the program to somebody else. How to export the MySql database structure without the data in it, just the structure?...

How to give spacing between buttons using bootstrap

I want to give spacing between buttons is there a way to give spacing using bootstrap so that they will be consistent for different screen resolutions. I tried using margin-left But is it the correct way to do this.?? Here is the demo HTML: <d...

Leave out quotes when copying from cell

Problem: When copying a cell from Excel outside of the program, double-quotes are added automatically. Details: I'm using Excel 2007 on a Windows 7 machine. If I have a cell with the following formula: ="1"&CHAR(9)&"SOME NOTES FOR LINE 1....

mysql-python install error: Cannot open include file 'config-win.h'

I am trying to run pip install mysql-python connector but it keeps giving me an error "Cannot open include file: 'config-win.h'". The installation works fine on my Mac and another Windows machine, but not this one. I have downloaded Visual Studio C+...

Get Line Number of certain phrase in file Python

I need to get the line number of a phrase in a text file. The phrase could be: the dog barked I need to open the file, search it for that phrase and print the line number. I'm using Python 2.6 on Windows XP This Is What I Have: o = open("C:/f...

Jackson and generic type reference

I want to use jackson json library for a generic method as follows: public MyRequest<T> tester() { TypeReference<MyWrapper<T>> typeRef = new TypeReference<MyWrapper<T>>(); MyWrapper<T> requestWrapper = (...

Swift presentViewController

I programatically have multiple View Controllers in an iOS Swift Project. I do not have the storyboards and would like to avoid them if possible. Is there a way to switch to another viewcontroller.swift file (We will call it view2.swift) and have it ...

SQL Server: Best way to concatenate multiple columns?

I am trying to concatenate multiple columns in a query in SQL Server 11.00.3393. I tried the new function CONCAT() but it's not working when I use more than two columns. So I wonder if that's the best way to solve the problem: SELECT CONCAT(CONCAT...

Swift extract regex matches

I want to extract substrings from a string that match a regex pattern. So I'm looking for something like this: func matchesForRegexInText(regex: String!, text: String!) -> [String] { ??? } So this is what I have: func matchesForRegexInTex...

How to set up subdomains on IIS 7

I have a website sitting on an IIS 7 server: WWW.example.COM I would like to create several sub domains that looks like SUBDOMAIN1.example.COM I created an IIS website and I set the bindings to be http, port 80, the ip address of my server, and SUB...

jQuery Ajax simple call

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

How to fix error with xml2-config not found when installing PHP from sources?

When I try to install php 5.3 stable from source on Ubuntu (downloading compressed installation file from http://www.php.net/downloads.php) and I run ./configure I get this error: configure: error: xml2-config not found. Please check your libxml2 in...

How can you tell when a layout has been drawn?

I have a custom view that draws a scrollable bitmap to the screen. In order to initialize it, i need to pass in the size in pixels of the parent layout object. But during the onCreate and onResume functions, the Layout has not been drawn yet, and so ...

How to check if a string starts with "_" in PHP?

Example: I have a $variable = "_foo", and I want to make absolutely sure that $variable does not start with an underscore "_". How can I do that in PHP? Is there some access to the char array behind the string?...

Hide Utility Class Constructor : Utility classes should not have a public or default constructor

I am getting this warning on Sonar.I want solution to remove this warning on sonar. My class is like this : public class FilePathHelper { private static String resourcesPath; public static String getFilePath(HttpServletRequest request) { ...

Listing all extras of an Intent

For debugging reasons I want to list all extras (and their values) of an Intent. Now, getting the keys isn't a problem Set<String> keys = intent.getExtras().keySet(); but getting the values of the keys is one for me, because some values are ...

How to copy java.util.list Collection

I am implementing a Java class responsible for ordering java.util.List. The problem comes when I use this class. I'm able to ordering the list but I want to copy the "original" list without modification so that I could register every change made on t...

Adding days to a date in Java

How do I add x days to a date in Java? For example, my date is (dd/mm/yyyy) = 01/01/2012 Adding 5 days, the output should be 06/01/2012....

TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array

I want to write a function that randomly picks elements from a training set, based on the bin probabilities provided. I divide the set indices to 11 bins, then create custom probabilities for them. bin_probs = [0.5, 0.3, 0.15, 0.04, 0.0025, 0.0025, ...

Storing data into list with class

I have the following class: public class EmailData { public string FirstName{ set; get; } public string LastName { set; get; } public string Location{ set; get; } } I then did the following but was not working properly: List<EmailD...

Taking the record with the max date

Let's assume I extract some set of data. i.e. SELECT A, date FROM table I want just the record with the max date (for each value of A). I could write SELECT A, col_date FROM TABLENAME t_ext WHERE col_date = (SELECT MAX (col_date) ...

commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated

Sometimes, when using <h:commandLink>, <h:commandButton> or <f:ajax>, the action, actionListener or listener method associated with the tag are simply not being invoked. Or, the bean properties are not updated with submitted UIInput...

AngularJs: Reload page

<a ng-href="#" class="navbar-brand" title="home" data-translate>PORTAL_NAME</a> I want to reload the page. How can I do this?...

Iterating over Typescript Map

I'm trying to iterate over a typescript map but I keep getting errors and I could not find any solution yet for such a trivial problem. My code is: myMap : Map<string, boolean>; for(let key of myMap.keys()) { console.log(key); } And I ge...

How to obtain the total numbers of rows from a CSV file in Python?

I'm using python (Django Framework) to read a CSV file. I pull just 2 lines out of this CSV as you can see. What I have been trying to do is store in a variable the total number of rows the CSV also. How can I get the total number of rows? file = o...

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

Is a DIV inside a TD a bad idea?

It seems like I heard/read somewhere that a <div> inside of a <td> was a no-no. Not that it won't work, just something about them not being really compatible based on their display type. Can't find any evidence to back up my hunch, so I m...

How to make exe files from a node.js app?

I have a node app that I wrote, that I run as follows: node.exe app.js inputArg Is there some way I can package this into a .exe by itself? So I can just do something like this? App.exe inputArg I have some way of faking this by using a batch fil...

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

SQL Server add auto increment primary key to existing table

As the title, I have an existing table which is already populated with 150000 records. I have added an Id column (which is currently null). I'm assuming I can run a query to fill this column with incremental numbers, and then set as primary key and ...

Log4j2 configuration - No log4j2 configuration file found

Lately I decided to learn how to use the log4j2 logger. I downloaded required jar files, created library, xml comfiguration file and tried to use it. Unfortunately i get this statement in console (Eclipse) : ERROR StatusLogger No log4j2 configurati...

Kill process by name?

I'm trying to kill a process (specifically iChat). On the command line, I use these commands: ps -A | grep iChat Then: kill -9 PID However, I'm not exactly sure how to translate these commands over to Python....

How can I read Chrome Cache files?

A forum I frequent was down today, and upon restoration, I discovered that the last two days of forum posting had been rolled back completely. Needless to say, I'd like to get back what data I can from the forum loss, and I am hoping I have at leas...

How to finish current activity in Android

I have an Android application. I am making a loading screen with a progress bar. I entered a delay in the onCreate method. When the timer finishes, I want to finish the current activity and start a new one. It just gives me an exception when it...

Convert string date to timestamp in Python

How to convert a string in the format "%d/%m/%Y" to timestamp? "01/12/2011" -> 1322697600 ...

How to run Unix shell script from Java code?

It is quite simple to run a Unix command from Java. Runtime.getRuntime().exec(myCommand); But is it possible to run a Unix shell script from Java code? If yes, would it be a good practice to run a shell script from within Java code?...

Where does Visual Studio look for C++ header files?

I checked out a copy of a C++ application from SourceForge (HoboCopy, if you're curious) and tried to compile it. Visual Studio tells me that it can't find a particular header file. I found the file in the source tree, but where do I need to put it,...

What is the opposite of :hover (on mouse leave)?

Is there any way to do the opposite of :hover using only CSS? As in: if :hover is on Mouse Enter, is there a CSS equivalent to on Mouse Leave? Example: I have a HTML menu using list items. When I hover one of the items, there is a CSS color animati...