Examples On Programing Languages

Regex: match word that ends with "Id"

I need help putting together a regex that will match word that ends with "Id" with case sensitive match....

How to show math equations in general github's markdown(not github's blog)

After investigating, I've found mathjax can do this. But when I write some example in my markdown file, it doesn't show the correct equations: I have added this in the head of markdown file: <script type="text/javascript" src="http://cdn.mathjax...

Converting Java file:// URL to File(...) path, platform independent, including UNC paths

I am developing a platform independent application. I am receiving a file URL*. On windows these are: file:///Z:/folder%20to%20file/file.txt file://host/folder%20to%20file/file.txt (an UNC path) I am using new File(URI(urlOfDocument).getPath())wh...

Apache: Restrict access to specific source IP inside virtual host

I have several named virtual hosts on the same apache server, for one of the virtual host I need to ensure only a specific set of IP addresses are allowed to access. Please suggest the best way to do this. I have looked at mod_authz_hosts module bu...

How to tell bash that the line continues on the next line

In a bash script I got from another programmer, some lines exceeded 80 columns in length. What is the character or thing to be added to the line in order to indicate that the line continues on the next line?...

Switch statement with returns -- code correctness

Let's say I have code in C with approximately this structure: switch (something) { case 0: return "blah"; break; case 1: case 4: return "foo"; break; case 2: case 3: return "bar"; break; ...

High Quality Image Scaling Library

I want to scale an image in C# with quality level as good as Photoshop does. Is there any C# image processing library available to do this thing?...

How do I use JDK 7 on Mac OSX?

I would like to use the WatchService API as mentioned in this link: http://download.oracle.com/javase/tutorial/essential/io/notification.html After reading around, I found out that WatchService is part of the NIO class which is scheduled for JDK 7. ...

How to set the min and max height or width of a Frame?

The size of Tkinter windows can be controlled via the following methods: .minsize() .maxsize() .resizable() Are there equivalent ways to control the size of Tkinter or ttk Frames? @Bryan: I changed your frame1.pack code to the following: frame1....

CSS: 100% font size - 100% of what?

There are many articles and questions about percentage-sized vs other-sized fonts. However, I can not find out WHAT the reference of the percent-value is supposed to be. I understand this is 'the same size in all browsers'. I also read this, for inst...

Keep a line of text as a single line - wrap the whole line or none at all

I'd like to keep a line of text together such that either the whole line drops down a line or none at all Acceptable How do I wrap this line of text - asked by Peter 2 days ago Acceptable How do I wrap this line of text - asked by Peter 2 days ...

Posting JSON data via jQuery to ASP .NET MVC 4 controller action

I'm having trouble trying to pass a complex JSON object to an MVC 4 controller action. As the JSON content is variable, I don't want MVC to map individual properties/elements of the JSON to parameters in the action method's parameter list. I just w...

What regex will match every character except comma ',' or semi-colon ';'?

Is it possible to define a regex which will match every character except a certain defined character or set of characters? Basically, I wanted to split a string by either comma (,) or semi-colon (;). So I was thinking of doing it with a regex which ...

Is there a mechanism to loop x times in ES6 (ECMAScript 6) without mutable variables?

The typical way to loop x times in JavaScript is: for (var i = 0; i < x; i++) doStuff(i); But I don't want to use the ++ operator or have any mutable variables at all. So is there a way, in ES6, to loop x times another way? I love Ruby's mech...

CURL alternative in Python

I have a cURL call that I use in PHP: curl -i -H 'Accept: application/xml' -u login:key "https://app.streamsend.com/emails" I need a way to do the same thing in Python. Is there an alternative to cURL in Python. I know of urllib but I'm a Pytho...

How do you specify a byte literal in Java?

If I have a method void f(byte b); how can I call it with a numeric argument without casting? f(0); gives an error....

Android SQLite Example

I am new to Android and I have to create an application where I need to use a SQLite database. I am not so well equipped with the SQLite. Could you tell me what the purpose and use of the SQLiteOpenHelper class, and provide a simple database creatio...

Suppress output of a function

I'm looking to suppress the output of one command (in this case, the apply function). Is it possible to do this without using sink()? I've found the described solution below, but would like to do this in one line if possible. How to suppress outpu...

How to construct a std::string from a std::vector<char>?

Short of (the obvious) building a C style string first then using that to create a std::string, is there a quicker/alternative/"better" way to initialize a string from a vector of chars?...

invalid use of non-static data member

For a code like this: class foo { protected: int a; public: class bar { public: int getA() {return a;} // ERROR }; foo() : a (p->param) }; I get this error: invalid use of non-static data member 'foo:...

C compiler for Windows?

I'm fine working on Linux using gcc as my C compiler but would like a Windows solution. Any ideas? I've looked at Dev-C++ from Bloodshed but looking for more options....

How is an HTTP POST request made in node.js?

How can I make an outbound HTTP POST request, with data, in node.js?...

Get installed applications in a system

How to get the applications installed in the system using c# code?...

Drop Down Menu/Text Field in one

I'm working on building new site, and I need a drop down menu to select the amount of something in my site. But at the same time I need this drop down list to accept text. So if the client wants to choose from the drop down list then he can, also if ...

What's the difference between nohup and ampersand

Both nohup myprocess.out & or myprocess.out & set myprocess.out to run in the background. After I shutdown the terminal, the process is still running. What's the difference between them?...

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

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

How do you get assembler output from C/C++ source in gcc?

How does one do this? If I want to analyze how something is getting compiled, how would I get the emitted assembly code?...

Responding with a JSON object in Node.js (converting object/array to JSON string)

I'm a newb to back-end code and I'm trying to create a function that will respond to me a JSON string. I currently have this from an example function random(response) { console.log("Request handler 'random was called."); response.writeHead(200, ...

What's the difference between Perl's backticks, system, and exec?

Can someone please help me? In Perl, what is the difference between: exec "command"; and system("command"); and print `command`; Are there other ways to run shell commands too?...

How to display request headers with command line curl

Command line curl can display response header by using -D option, but I want to see what request header it is sending. How can I do that?...

Purpose of Activator.CreateInstance with example?

Can someone explain Activator.CreateInstance() purpose in detail?...

What is the most effective way to get the index of an iterator of an std::vector?

I'm iterating over a vector and need the index the iterator is currently pointing at. AFAIK this can be done in two ways: it - vec.begin() std::distance(vec.begin(), it) What are the pros and cons of these methods?...

better way to drop nan rows in pandas

On my own I found a way to drop nan rows from a pandas dataframe. Given a dataframe dat with column x which contains nan values,is there a more elegant way to do drop each row of dat which has a nan value in the x column? dat = dat[np.logical_not(np...

Border around specific rows in a table?

I'm trying to design some HTML/CSS that can put a border around specific rows in a table. Yes, I know I'm not really supposed to use tables for layout but I don't know enough CSS to completely replace it yet. Anyways, I have a table with multiple ro...

size of NumPy array

Is there an equivalent to the MATLAB size() command in Numpy? In MATLAB, >>> a = zeros(2,5) 0 0 0 0 0 0 0 0 0 0 >>> size(a) 2 5 In Python, >>> a = zeros((2,5)) >>> array([[ 0., 0., 0., 0., 0.], ...

CSS Animation onClick

How can I get a CSS Animation to play with a JavaScript onClick? I currently have: .classname { -webkit-animation-name: cssAnimation; -webkit-animation-duration:3s; -webkit-animation-iteration-count: 1; -webkit-animation-timing-function: eas...

Function not defined javascript

For some reason my javascript code is messed up. When run through firebug, I get the error proceedToSecond not defined, but it is defined! JavaScript: <script type = "text/javascript"> function proceedToSecond () { document.getEl...

How can I read pdf in python?

How can I read pdf in python? I know one way of converting it to text, but I want to read the content directly from pdf. Can anyone explain which module in python is best for pdf extraction...

Calculate difference in keys contained in two Python dictionaries

Suppose I have two Python dictionaries - dictA and dictB. I need to find out if there are any keys which are present in dictB but not in dictA. What is the fastest way to go about it? Should I convert the dictionary keys into a set and then go about...

CSS Outside Border

I want to be able to draw a border OUTSIDE of my Div! So if my div is say 20px by 20px, I want a 1px border outside of this (so in essence, I get a div 22x22px large). I understand that I can just make the div 22x22 to start with, but for reasons I...

How to select <td> of the <table> with javascript?

I know this is very easy question, but I couldn't find the answer anywhere. Only answers are the ones using jQuery, not pure JS. I've tried the code below and it doesn't work. I don't know why. var t = document.getElementById("table"), d = t.ge...

Setting href attribute at runtime

What is the best way to set the href attribute of the <a> tag at run time using jQuery? Also, how do you get the value of the href attribute of the <a> tag using jQuery?...

class << self idiom in Ruby

What does class << self do in Ruby?...

Best way to test if a row exists in a MySQL table

I'm trying to find out if a row exists in a table. Using MySQL, is it better to do a query like this: SELECT COUNT(*) AS total FROM table1 WHERE ... and check to see if the total is non-zero or is it better to do a query like this: SELECT * FROM ...

How to download an entire directory and subdirectories using wget?

I am trying to download the files for a project using wget, as the SVN server for that project isn't running anymore and I am only able to access the files through a browser. The base URLs for all the files is the same like http://abc.tamu.edu/p...

Force drop mysql bypassing foreign key constraint

I'm trying to delete all tables from a database except one, and I end up having the following error: Cannot delete or update a parent row: a foreign key constraint fails Of course I could trial and error to see what those key constraints are a...

What is a semaphore?

A semaphore is a programming concept that is frequently used to solve multi-threading problems. My question to the community: What is a semaphore and how do you use it?...

How to run (not only install) an android application using .apk file?

Is there any command on cmd.exe that would allow me to start the main activity of a particular android application using the .apk file of that application. Please note that I know this command which only installs an android application: adb install ...

Conditional formatting, entire row based

I've searched and read through answers related to conditional formatting, but I can't seem to get mine to work, so maybe I'm doing something wrong. I have a worksheet for work. It contains a list of animals in our shelter. What I'm attempting to do ...

Running shell command and capturing the output

I want to write a function that will execute a shell command and return its output as a string, no matter, is it an error or success message. I just want to get the same result that I would have gotten with the command line. What would be a code exa...

Right way to split an std::string into a vector<string>

Possible Duplicate: How to split a string? What is the right way to split a string into a vector of strings. Delimiter is space or comma....

Driver executable must be set by the webdriver.ie.driver system property

I am using Selenium for automating the tests. My application exclusively uses IE, it will not work on other Browsers. Code: import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; i...

Error:Cannot fit requested classes in a single dex file.Try supplying a main-dex list. # methods: 72477 > 65536

I want to add fused location services but it shows me some error. Help me. apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion "27.0.1" defaultConfig { applicationId "com.example.adil.blo...

Write and read a list from file

This is a slightly weird request but I am looking for a way to write a list to file and then read it back some other time. I have no way to remake the lists so that they are correctly formed/formatted as the example below shows. My lists have data ...

Pick any kind of file via an Intent in Android

I would like to start an intentchooser for apps which can return any kind of file Currently I use (which I copied from the Android email source code for file attachment) Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Inte...

How can I view the Git history in Visual Studio Code?

I can execute various Git commands from Visual Studio Code, however I couldn't find a way to visualize the history....

Warning: Null value is eliminated by an aggregate or other SET operation in Aqua Data Studio

I have a problem when data is null and the warning has appear when the result is display. How to solve this problem?. How to change the null data to 0 when no data in the table?. This is my code:- SELECT DISTINCT c.username AS assigner_...

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

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

Multidimensional arrays in Swift

Edit: As Adam Washington points out, as from Beta 6, this code works as is, so the question is no longer relevant. I am trying to create and iterate through a two dimensional array: var array = Array(count:NumColumns, repeatedValue:Array(count:Num...

adb shell command to make Android package uninstall dialog appear

I have adb running and device is connected to my system in debugging mode, I want to uninstall app using intent launch using adb shell am start <INTENT> I don't want to uninstall using adb uninstall com.company.apppackage and I don't want to ...

Increase number of axis ticks

I'm generating plots for some data, but the number of ticks is too small, I need more precision on the reading. Is there some way to increase the number of axis ticks in ggplot2? I know I can tell ggplot to use a vector as axis ticks, but what I wa...

React.js: Identifying different inputs with one onChange handler

Curious what the right way to approach this is: var Hello = React.createClass({ getInitialState: function() { return {total: 0, input1:0, input2:0}; }, render: function() { return ( <div>{this.state.total}<br/> ...

Check if value exists in column in VBA

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

Find the day of a week

Let's say that I have a date in R and it's formatted as follows. date 2012-02-01 2012-02-01 2012-02-02 Is there any way in R to add another column with the day of the week associated with the date? The dataset is really large, so it woul...

SQL SELECT everything after a certain character

I need to extract everything after the last '=' (http://www.domain.com?query=blablabla - > blablabla) but this query returns the entire strings. Where did I go wrong in here: SELECT RIGHT(supplier_reference, CHAR_LENGTH(supplier_reference) - SUBSTRI...

How to use Global Variables in C#?

How do I declare a variable so that every class (*.cs) can access its content, without an instance reference?...

Python Pandas User Warning: Sorting because non-concatenation axis is not aligned

I'm doing some code practice and applying merging of data frames while doing this getting user warning /usr/lib64/python2.7/site-packages/pandas/core/frame.py:6201: FutureWarning: Sorting because non-concatenation axis is not aligned. A future ...

How do I configure the proxy settings so that Eclipse can download new plugins?

I am working with Eclipse 3.7, on an Windows XP environment behind a web proxy. I want to install the Groovy plugin on a newly unzipped Eclipse Indigo (Eclipse Java EE Indigo M4). I added the update site to the Available Software Site list. But Ecl...

Replace multiple characters in one replace call

Very simple little question, but I don't quite understand how to do it. I need to replace every instance of '_' with a space, and every instance of '#' with nothing/empty. var string = '#Please send_an_information_pack_to_the_following_address:';...

Implementing autocomplete

I am having trouble finding a good autocomplete component for Angular2. Just anything that I can pass a list of key-label objects to and have a nice autocomplete on an input field. Kendo does not support Angular 2 yet and that it what we mostly use ...

How can I hide an HTML table row <tr> so that it takes up no space?

How can I hide an HTML table row <tr> so that it takes up no space? I have several <tr>'s set to style="display:none;", but they still affect the size of the table and the table's border reflects the hidden rows....

How to make an array of arrays in Java

Hypothetically, I have 5 string array objects: String[] array1 = new String[]; String[] array2 = new String[]; String[] array3 = new String[]; String[] array4 = new String[]; String[] array5 = new String[]; and I want another array object to conta...

moment.js 24h format

How do I display my time in 24h format instead of 12? I am using moment.js. I am pretty sure that these lines could have something to do with it. meridiem : function (hours, minutes, isLower) { if (hours > 11) { return is...

Transparent background in JPEG image

How can I set a transparent background on JPEG image? This is a doubt of many colleagues of mine. What would be the solution using Paint on Windows? What are the other simple alternatives?...

Html ordered list 1.1, 1.2 (Nested counters and scope) not working

I use nested counters and scope to create an ordered list: _x000D_ _x000D_ ol {_x000D_ counter-reset: item;_x000D_ padding-left: 10px;_x000D_ }_x000D_ li {_x000D_ display: block_x000D_ }_x000D_ li:before {_x000D_ content: counters(it...

ValueError : I/O operation on closed file

import csv with open('v.csv', 'w') as csvfile: cwriter = csv.writer(csvfile, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MINIMAL) for w, c in p.items(): cwriter.writerow(w + c) Here, p is a dictionary, w and c both are strings. W...

How to install toolbox for MATLAB

I am just wondering, if I need a toolbox which not available in my MATLAB, how do I do that? For example: if I need image processing toolbox, how do I get it?...

What does "zend_mm_heap corrupted" mean

All of the sudden I've been having problems with my application that I've never had before. I decided to check the Apache's error log, and I found an error message saying "zend_mm_heap corrupted". What does this mean. OS: Fedora Core 8 Apache: 2.2...

React Native version mismatch

Getting the following message when I init a new project and then launch the Xcode emulator: React-Native Version Mismatch Javascript Version 0.50.1 Native version: 0.50.0 Make sure you have rebuilt the native code. ... Does anyone ...

syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

I have been staring at this code for hours now and I cannot figure out where my mistake is. I know this syntax error usually comes up because of some missing or out of place curly brace or some issue with single/double quotes and I'm not sure there i...

How to serve up a JSON response using Go?

Question: Currently I'm printing out my response in the func Index like this fmt.Fprintf(w, string(response)) however, how can I send JSON properly in the request so that it maybe consumed by a view? package main import ( "fmt" "github.com...

How do I give ASP.NET permission to write to a folder in Windows 7?

I have a new Win7 workstation and I am trying to get ScrewTurn Wiki to run on the machine. My STW installation is using the file system option to store its data, and as such I need to give write permissions to the ASP.NET worker process in the folde...

Pandas - 'Series' object has no attribute 'colNames' when using apply()

I need to use a lambda function to do a row by row computation. For example create some dataframe import pandas as pd import numpy as np def myfunc(x, y): return x + y colNames = ['A', 'B'] data = np.array([np.arange(10)]*2).T df = pd.DataFra...

Cannot find firefox binary in PATH. Make sure firefox is installed

In Selenium Grid I am trying to execute a simple program and I'm getting Cannot find firefox binary in PATH though I have added the binary path in my code. My code and the error are given below. Kindly need help. Thanks in advance. Code package Sam...

Regular expression for 10 digit number without any special characters

What is the regular expression for a 10 digit numeric number (no special characters and no decimal)....

PHP form - on submit stay on same page

I have a PHP form that is located on file contact.html. The form is processed from file processForm.php. When a user fills out the form and clicks on submit, processForm.php sends the email and direct the user to - processForm.php with a message o...

Creating virtual directories in IIS express

Is there any way to create a virtual directory in IIS express? I know that Cassini can't do this and it would be nice to be able to do this without using a full version of IIS. I've got it so far that I can browse to my application locally in IIS ex...

Using column alias in WHERE clause of MySQL query produces an error

The query I'm running is as follows, however I'm getting this error: #1054 - Unknown column 'guaranteed_postcode' in 'IN/ALL/ANY subquery' SELECT `users`.`first_name`, `users`.`last_name`, `users`.`email`, SUBSTRING(`locations`.`raw`,-6,4) AS `...

Replace last occurrence of a string in a string

Anyone know of a very fast way to replace the last occurrence of a string with another string in a string? Note, the last occurrence of the string might not be the last characters in the string. Example: $search = 'The'; $replace = 'A'; $subject = 'T...

Merge two array of objects based on a key

I have two arrays: Array 1: [ { id: "abdc4051", date: "2017-01-24" }, { id: "abdc4052", date: "2017-01-22" } ] and array 2: [ { id: "abdc4051", name: "ab" }, { id: "abdc4052", name: "abc" } ] I need to merge these two arrays based on...

How to round a floating point number up to a certain decimal place?

Suppose I have 8.8333333333333339, and I want to convert it to 8.84. How can I accomplish this in Python? round(8.8333333333333339, 2) gives 8.83 and not 8.84. I am new to Python or programming in general. I don't want to print it as a string, and ...

Project with path ':mypath' could not be found in root project 'myproject'

I'm migrated from Eclipse to android studio 0.5.8, after importing my project to android studio i was getting the error Project with path ':progressfragment' could not be found in root project 'project_name'. Project Struture : Libs Complete St...

How to enable copy paste from between host machine and virtual machine in vmware, virtual machine is ubuntu

I am trying to copy and paste from my pc to the vm but i cant. I also enable copy and paste but i still can't copy and paste from my pc to the vm. My pc runs windows 8.1 my vm has fedora....

What is a 'workspace' in Visual Studio Code?

I can't quite believe I am asking this question, but I have not been able to find a definition in the documentation. In case it isn't painfully obvious, I am (very) new to Visual Studio Code. For example, Visual Studio Code talks about applying sett...

Difference between npx and npm?

I have just started learning React, and Facebook helps in simplifying the initial setup by providing the following ready-made project. If I have to install the skeleton project I have to type npx create-react-app my-app in command-line. I was won...

How to make a gap between two DIV within the same column

I have two paragraphs. The two paragraphs are located in the same column. Now my question is I need to make the two paragraphs in two separate boxes, down each other. In other words, gap between two boxes coming down each other. HTML Code <d...

how do I loop through a line from a csv file in powershell

I want to process a csv file in powershell, but I don't know what the column headings in the CSV file will be when it is processed. For example: $path = "d:\scratch\export.csv" $csv = Import-csv -path $path foreach($line in $csv) { foreach (...

Image, saved to sdcard, doesn't appear in Android's Gallery app

I save an image to the sdcard and it doesn't appear in the Gallery application until I pull off the sdcard and return it back. Do you have any idea why is it so? Seems like the Gallery application has some cache that isn't updated on file save... ...

Bootstrap: add margin/padding space between columns

I'm trying to put some extra margin/padding space between columns on my Bootstrap grid layout. I've tried this but I don't like the result. Here is my code: <div class="row"> <div class="text-center col-md-6"> Wid...

Arrays.asList() of an array

What is wrong with this conversion? public int getTheNumber(int[] factors) { ArrayList<Integer> f = new ArrayList(Arrays.asList(factors)); Collections.sort(f); return f.get(0)*f.get(f.size()-1); } I made this after reading the ...

Maximum concurrent Socket.IO connections

This question has been asked previously but not recently and not with a clear answer. Using Socket.io, is there a maximum number of concurrent connections that one can maintain before you need to add another server? Does anyone know of any active ...

Importing a long list of constants to a Python file

In Python, is there an analogue of the C preprocessor statement such as?: #define MY_CONSTANT 50 Also, I have a large list of constants I'd like to import to several classes. Is there an analogue of declaring the constants as a long sequence of sta...

Django download a file

I'm quite new to using Django and I am trying to develop a website where the user is able to upload a number of excel files, these files are then stored in a media folder Webproject/project/media. def upload(request): if request.POST: fo...

How do I get the Session Object in Spring?

I am relatively new to Spring and Spring security. I was attempting to write a program where I needed to authenticate a user at the server end using Spring security, I came up with the following: public class CustomAuthenticationProvider extends A...

How to make Bootstrap 4 cards the same height in card-columns?

I am using Bootstrap 4 alpha 2 and taking advantage on cards. Specifically, I am working with this example taken from the official docs. How can I make all cards to be the same height? All I can think by now is setting the following CSS rule: .car...

MSSQL Error 'The underlying provider failed on Open'

I was using an .mdf for connecting to a database and entityClient. Now I want to change the connection string so that there will be no .mdf file. Is the following connectionString correct? <connectionStrings> <!--<add name="conString...

How to check if the given string is palindrome?

Definition: A palindrome is a word, phrase, number or other sequence of units that has the property of reading the same in either direction How to check if the given string is a palindrome? This was one of the FAIQ [Frequently Asked Interview Ques...

How does python numpy.where() work?

I am playing with numpy and digging through documentation and I have come across some magic. Namely I am talking about numpy.where(): >>> x = np.arange(9.).reshape(3, 3) >>> np.where( x > 5 ) (array([2, 2, 2]), array([0, 1, 2]))...

.htaccess not working apache

I have a server from AWS EC2 service running on Linux ubuntu and I have installed apache, php, and mysql. I have added a .htaccess file in my document root /var/www/html. I entered this code in it: ErrorDocument 404 /var/www/html/404.php and it is...

How do I get milliseconds from epoch (1970-01-01) in Java?

I need to get the number of milliseconds from 1970-01-01 UTC until now UTC in Java. I would also like to be able to get the number of milliseconds from 1970-01-01 UTC to any other UTC date time....

assigning column names to a pandas series

I have a pandas series object x Ezh2 2 Hmgb 7 Irf1 1 I want to save this as a dataframe with column names Gene and Count respectively I tried x_df = pd.DataFrame(x,columns = ['Gene','count']) but it does not work.The final form I want i...

Viewing full version tree in git

I am using the command line version of Git and gitk. I want to see the full version tree, not just the part that is reachable from the currently checked out version. Is it possible?...

Difference between float and decimal data type

What difference does it make when I use float and decimal data types in MySQL?. When should I use which?...

Executing command line programs from within python

I'm building a web application that will is going to manipulate (pad, mix, merge etc) sound files and I've found that sox does exactly what I want. Sox is a linux command line program and I'm feeling a little uncomfortable with having the python web ...

How to convert enum value to int?

I have a function which return a type int. However, I only have a value of the TAX enumeration. How can I cast the TAX enumeration value to an int? public enum TAX { NOTAX(0),SALESTAX(10),IMPORTEDTAX(5); private int value; private TAX(...

CURL Command Line URL Parameters

I am trying to send a DELETE request with a url parameter using CURL. I am doing: curl -H application/x-www-form-urlencoded -X DELETE http://localhost:5000/locations` -d 'id=3' However, the server is not seeing the parameter id = 3. I tried using ...

Set new id with jQuery

"this" is a text field, "new_id" is an integer. When I apply the following snippet: $(this).attr('id', this.id + '_' + new_id); $(this).attr('name', this.name + '_' + new_id); $(this).attr('value', 'test'); the id changes, the name changes too,...

Options for initializing a string array

What options do I have when initializing string[] object?...

Formatting a Date String in React Native

I'm trying to format a Date String in React Native. Ex: 2016-01-04 10:34:23 Following is the code I'm using. var date = new Date("2016-01-04 10:34:23"); console.log(date); My problem is, when I'm emulating this on a iPhone 6S, it'll print Mon Ja...

Rounding Bigdecimal values with 2 Decimal Places

I want a function to convert Bigdecimal 10.12 for 10.12345 and 10.13 for 10.12556. But no function is satisfying both conversion in same time.Please help to achieve this. Below is what I tried. With value 10.12345: BigDecimal a = new BigDecimal("10...

Remove excess whitespace from within a string

I receive a string from a database query, then I remove all HTML tags, carriage returns and newlines before I put it in a CSV file. Only thing is, I can't find a way to remove the excess white space from between the strings. What would be the best w...

IndentationError: unexpected unindent WHY?

IndentationError: unexpected unindent WHY??? #!/usr/bin/python import sys class Seq: def __init__(self, id, adnseq, colen): self.id = id self.dna = adnseq self.cdnlen = colen self.prot = "" def __str_...

How to completely uninstall python 2.7.13 on Ubuntu 16.04

I installed Python 2.7.13 on Ubuntu 16.04 according to this guide, and it became the default version as an alternative to the version 2.7.12. But, I wanted to completely remove Python 2.7.13 and return back to the version 2.7.12 as the default versio...

"Comparison method violates its general contract!"

Can someone explain me in simple terms, why does this code throw an exception, "Comparison method violates its general contract!", and how do I fix it? private int compareParents(Foo s1, Foo s2) { if (s1.getParent() == s2) return -1; if (s2....

python 3.2 UnicodeEncodeError: 'charmap' codec can't encode character '\u2013' in position 9629: character maps to <undefined>

I'm trying to make a script that gets data out from an sqlite3 database, but I have run in to a problem. The field in the database is of type text and the contains a html formated text. see the text below <html> <head> <title>Yaho...

cURL POST command line on WINDOWS RESTful service

My problem: Using the command line tool to curl my localhost server while sending some data along with my POST request is not working. What seems to be causing the error: Imagine something like this curl -i -X POST -H 'Content-Type: application/...

Why are interface variables static and final by default?

Why are interface variables static and final by default in Java?...

Python 3.6 install win32api?

Is there a way to install the win32api module for python 3.6 or do I have to change my version of python? Everytime I try to install it using pip I get the following error: Could not find a version that satisfies the requirement win32api (from vers...

How to check whether a variable is a class or not?

I was wondering how to check whether a variable is a class (not an instance!) or not. I've tried to use the function isinstance(object, class_or_type_or_tuple) to do this, but I don't know what type would a class will have. For example, in the foll...

Create a button with rounded border

How would you make a FlatButton into a button with a rounded border? I have the rounded border shape using RoundedRectangleBorder but somehow need to color the border. new FlatButton( child: new Text("Button text), onPressed: null, shape: new ...

What techniques can be used to speed up C++ compilation times?

What techniques can be used to speed up C++ compilation times? This question came up in some comments to Stack Overflow question C++ programming style, and I'm interested to hear what ideas there are. I've seen a related question, Why does C++ comp...

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

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

What's the meaning of System.out.println in Java?

Is this static println function in out class from System namespace? namespace System { class out { static println ... } How can I interpret this name? And where in JRE this function is defined? In java.lang.System/java.lang.Object?...

How to join components of a path when you are constructing a URL in Python

For example, I want to join a prefix path to resource paths like /js/foo.js. I want the resulting path to be relative to the root of the server. In the above example if the prefix was "media" I would want the result to be /media/js/foo.js. os.path...

How can I add reflection to a C++ application?

I'd like to be able to introspect a C++ class for its name, contents (i.e. members and their types) etc. I'm talking native C++ here, not managed C++, which has reflection. I realise C++ supplies some limited information using RTTI. Which additional ...

Refresh a page using JavaScript or HTML

How can I refresh a page using JavaScript or HTML?...

Bootstrap change div order with pull-right, pull-left on 3 columns

I’ve been working on this the whole day but don’t come up with a solution. I have 3 columns in one row in a container. 1: right content – pull-right 2: navigation – pull-left 3: main content What it looks on big screens: ----------------...

How to make Sonar ignore some classes for codeCoverage metric?

I have a Sonar profile in Maven. Everything works fine except the code coverage metric. I want to make Sonar ignore some classes only for the code coverage metric. I have the following profile: <profile> <id>sonar</id> &l...

How to ftp with a batch file?

I want a batch file to ftp to a server, read out a text file, and disconnect. The server requires a user and password. I tried @echo off pause @ftp example.com username password pause but it never logged on. How can I get this to work?...

NodeJS: How to get the server's port?

You often see example hello world code for Node that creates an Http Server, starts listening on a port, then followed by something along the lines of: console.log('Server is listening on port 8000'); But ideally you'd want this instead: console....

What is the difference between typeof and instanceof and when should one be used vs. the other?

In my particular case: callback instanceof Function or typeof callback == "function" does it even matter, what's the difference? Additional Resource: JavaScript-Garden typeof vs instanceof...

How to get .app file of a xcode application

I have created an xcode project. Now I want to give .app file to my friend to use that application. From where do I get this file? How to install this .app file in his Applications folder using an installer package?...

How to write a UTF-8 file with Java?

I have some current code and the problem is its creating a 1252 codepage file, i want to force it to create a UTF-8 file Can anyone help me with this code, as i say it currently works... but i need to force the save on utf.. can i pass a parameter o...

Call to undefined function oci_connect()

I got this error. Fatal error: Call to undefined function oci_connect() $conn = oci_connect('localhost', 'username', 'password') or die(could not connect:'.oci_error) that is the code. This is the error I got. Fatal error: Call to undefined func...

Default session timeout for Apache Tomcat applications

What is the default session timeout for web applications deployed on Tomcat5.5? Is it browser specific? In my web application, default timeout is mentioned neither in web.xml nor in code....

git diff between two different files

In HEAD (the latest commit), I have a file named foo. In my current working tree, I renamed it to bar, and also edited it. I want to git diff foo in HEAD, and bar in my current working tree....

Error Running React Native App From Terminal (iOS)

I am following the tutorial on the official React Native website. Using the following to build my project: react-native run-ios I get the error: Found Xcode project TestProject.xcodeproj xcrun: error: unable to find utility "instruments", not a ...

Difference between binary tree and binary search tree

Can anyone please explain the difference between binary tree and binary search tree with an example?...

AngularJs event to call after content is loaded

I have a function which I want to call after page content is loaded. I read about $viewContentLoaded and it doesn't work for me. I am looking for something like document.addEventListener('DOMContentLoaded', function () { //Content goes here ...

Read file As String

I need to load an xml file as String in android so I can load it to TBXML xml parser library and parse it. The implementation I have now to read the file as String takes around 2seconds even for a very small xml file of some KBs. Is there any known f...

What's the difference between a proxy server and a reverse proxy server?

What is the difference between a proxy server and a reverse proxy server?...

Why can't I define a default constructor for a struct in .NET?

In .NET, a value type (C# struct) can't have a constructor with no parameters. According to this post this is mandated by the CLI specification. What happens is that for every value-type a default constructor is created (by the compiler?) which initi...

PHP: Split a string in to an array foreach char

I am making a method so your password needs at least one captial and one symbol or number. I was thinking of splitting the string in to lose chars and then use preggmatch to count if it contains one capital and symbol/number. however i did something...

Using Intent in an Android application to show another activity

In my Android application, I have two activity classes. I have a button on the first one and I want to show the second when it is clicked, but I get an error. Here are the classes: public class FirstActivity extends Activity { @Override publi...

How in node to split string by newline ('\n')?

How in node to split string by newline ('\n') ? I have simple string like var a = "test.js\nagain.js" and I need to get ["test.js", "again.js"]. I tried a.split("\n"); a.split("\\n"); a.split("\r\n"); a.split("\r"); but none of above doesn't work...

Open local folder from link

How can I open a local folder view by clicking on any link? I tried many options like <a href="file:///D:/Tools/">Open folder</a> or <a onclick="file:///D:/Tools/">Open folder</a> or <a onclick="window.open(file:///D:/...

Is there a /dev/null on Windows?

What is the equivalent of /dev/null on Windows?...

How do you change the character encoding of a postgres database?

I have a database that was set up with the default character set SQL_ASCII. I want to switch it to UNICODE. Is there an easy way to do that?...

When to favor ng-if vs. ng-show/ng-hide?

I understand that ng-show and ng-hide affect the class set on an element and that ng-if controls whether an element is rendered as part of the DOM. Are there guidelines on choosing ng-if over ng-show/ng-hide or vice-versa?...

Split string based on a regular expression

I have the output of a command in tabular form. I'm parsing this output from a result file and storing it in a string. Each element in one row is separated by one or more whitespace characters, thus I'm using regular expressions to match 1 or more sp...

Remove the newline character in a list read from a file

I have a simple program that takes an ID number and prints information for the person matching the ID. The information is stored in a .dat file, with one ID number per line. The problem is that my program is also reading the newline character \n fro...

How to show progress dialog in Android?

I want to show ProgressDialog when I click on Login button and it takes time to move to another page. How can I do this?...

How to split the name string in mysql?

How to split the name string in mysql ? E.g.: name ----- Sachin ramesh tendulkar Rahul dravid Split the name like firstname,middlename,lastname: firstname middlename lastname --------- ------------ ------------ sachin ramesh ...

CSS Printing: Avoiding cut-in-half DIVs between pages?

I'm writing a plug-in for a piece of software that takes a big collection of items and pops them into HTML in a WebView in Cocoa (which uses WebKit as its renderer, so basically you can assume this HTML file is being opened in Safari). The DIVs it m...

How can I get query string values in JavaScript?

Is there a plugin-less way of retrieving query string values via jQuery (or without)? If so, how? If not, is there a plugin which can do so?...

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

Change GitHub Account username

I want to change my account's user name on GitHub, but I can't find how to do it. Is this possible at all? To clarify, I'm not talking about the user.name parameter in a git repository, but the username of the actual GitHub account....

mongodb/mongoose findMany - find all documents with IDs listed in array

I have an array of _ids and I want to get all docs accordingly, what's the best way to do it ? Something like ... // doesn't work ... of course ... model.find({ '_id' : [ '4ed3ede8844f0f351100000c', '4ed3f117a844e0471100000d', ...

Restart pods when configmap updates in Kubernetes?

How do I automatically restart Kubernetes pods and pods associated with deployments when their configmap is changed/updated? I know there's been talk about the ability to automatically restart pods when a config maps changes but to my knowledge th...

How to install mechanize for Python 2.7?

I saved mechanize in my Python 2.7 directory. But when I type import mechanize into the Python shell, I get an error message that reads: Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> import mechanize Im...

Javascript to sort contents of select element

is there a quick way to sort the items of a select element? Or I have to resort to writing javascript? Please any ideas. <select size="4" name="lstALL" multiple="multiple" id="lstALL" tabindex="12" style="font-size:XX-Small;height:95%;width:100%...

Remove quotes from a character vector in R

Suppose you have a character vector: char <- c("one", "two", "three") When you make reference to an index value, you get the following: > char[1] [1] "one" How can you strip off the quote marks from the return value to get the following? ...

How to redirect all HTTP requests to HTTPS

I'm trying to redirect all insecure HTTP requests on my site (e.g. http://www.example.com) to HTTPS (https://www.example.com). I'm using PHP btw. Can I do this in .htaccess?...

concatenate variables

I need to do a .bat for DOS that do the following: set ROOT = c:\programas\ set SRC_ROOT = (I want to put the ROOT Here)System\Source so after defining ROOT I want to have SRC_ROOT = c:\programas\System\Source How can I do that?...

Convert base64 png data to javascript file objects

I have two base64 encoded in PNG, and I need to compare them using Resemble.JS I think that the best way to do it is to convert the PNG's into file objects using fileReader. How can I do it?...

SQL Server : Arithmetic overflow error converting expression to data type int

I'm getting this error msg 8115, level 16, state 2, line 18 Arithmetic overflow error converting expression to data type int. with this SQL query DECLARE @year VARCHAR(4); DECLARE @month VARCHAR(2); ...

Uncaught ReferenceError: <function> is not defined at HTMLButtonElement.onclick

I have created my problem on JSFiddle at https://jsfiddle.net/kgw0x2ng/5/. The code is as follows HTML CODE <div class="loading">Loading&#8230;</div> <button type="submit" onClick="hideButton()">Hide</button> <butto...

TypeScript function overloading

Section 6.3 of the TypeScript language spec talks about function overloading and gives concrete examples on how to implement this. However if I try something like this: export class LayerFactory { constructor (public styleFactory: Symbology.S...

Grant all on a specific schema in the db to a group role in PostgreSQL

Using PostgreSQL 9.0, I have a group role called "staff" and would like to grant all (or certain) privileges to this role on tables in a particular schema. None of the following work GRANT ALL ON SCHEMA foo TO staff; GRANT ALL ON DATABASE mydb TO s...

How to easily resize/optimize an image size with iOS?

My application is downloading a set of image files from the network, and saving them to the local iPhone disk. Some of those images are pretty big in size (widths larger than 500 pixels, for instance). Since the iPhone doesn't even have a big enough ...

Multiple "order by" in LINQ

I have two tables, movies and categories, and I get an ordered list by categoryID first and then by Name. The movie table has three columns ID, Name and CategoryID. The category table has two columns ID and Name. I tried something like the followin...

Ukkonen's suffix tree algorithm in plain English

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

How to shut down the computer from C#

What's the best way to shut down the computer from a C# program? I've found a few methods that work - I'll post them below - but none of them are very elegant. I'm looking for something that's simpler and natively .net....

How to set a Postgresql default value datestamp like 'YYYYMM'?

As title, how can I set a table's column to have the default value the current year and month, in format 'YYYYMM', like 200905 for today?...

Error: JavaFX runtime components are missing, and are required to run this application with JDK 11

I'm trying to run the sample JavaFX project using IntelliJ but it fails with the exception : Error: JavaFX runtime components are missing, and are required to run this application I have downloaded JDK 11 here : http://jdk.java.net/11/ I have down...

Is there a CSS selector by class prefix?

I want to apply a CSS rule to any element whose one of the classes matches specified prefix. E.g. I want a rule that will apply to div that has class that starts with status- (A and C, but not B in following snippet): <div id='A' class='foo-clas...

How to give Jenkins more heap space when it´s started as a service under Windows?

I want to increase the available heap space for Jenkins. But as it is installed as a service I don´t know how to do it....

Building a fat jar using maven

I have a code base which I want to distribute as jar. It also have dependency on external jars, which I want to bundle in the final jar. I heard that this can be done using maven-assembly-plug-in, but I don't understand how. Could someone point me ...

javascript regex : only english letters allowed

Quick question: I need to allow an input to only accept letters, from a to z and from A to Z, but can't find any expression for that. I want to use the javascript test() method....

Closing database connections in Java

I am getting a little confused. I was reading the below from Java Database Connectivity: Connection conn = DriverManager.getConnection( "jdbc:somejdbcvendor:other data needed by some jdbc vendor", "myLogin", "m...

How to apply !important using .css()?

I am having trouble applying a style that is !important. I’ve tried: $("#elem").css("width", "100px !important"); This does nothing; no width style whatsoever is applied. Is there a jQuery-ish way of applying such a style without having to overw...

How to save python screen output to a text file

I'm new to Python. I need to query items from a dict and save the result to a text file. Here's what I have: import json import exec.fullog as e input = e.getdata() #input now is a dict() which has items, keys and values. #Query print 'Data colle...

How do I find the index of a character in a string in Ruby?

For example, str = 'abcdefg'. How do I find the index if c in this string using Ruby?...

`React/RCTBridgeModule.h` file not found

Getting this error while building a react-native iOS app on xcode. Started getting this error after npm install and rpm linking react-native-fs library. But after searching online for a solution, I noticed that many people are getting the same err...

How to run console application from Windows Service?

I have a windows service, written in c# and I need to run a console application from it. Console application also written in c#. Console application is running fine when it is run not from windows service. When it is ran from ws it doesn`t do anyth...

How do I write a compareTo method which compares objects?

I am learning about arrays, and basically I have an array that collects a last name, first name, and score. I need to write a compareTo method that will compare the last name and then the first name so the list could be sorted alphabetically startin...

Inserting a string into a list without getting split into characters

I'm new to Python and can't find a way to insert a string into a list without it getting split into individual characters: >>> list=['hello','world'] >>> list ['hello', 'world'] >>> list[:0]='foo' >>> list ['f', '...

How to run Gradle from the command line on Mac bash

I have a very simple question. I am brand new to Mac and I am trying to get my Java project moved over to my new Mac. The project has a Gradlew file that I thought I could run from the command line to build and run on any machine. When I do gradlew f...

Aren't promises just callbacks?

I've been developing JavaScript for a few years and I don't understand the fuss about promises at all. It seems like all I do is change: api(function(result){ api2(function(result2){ api3(function(result3){ // do work ...

When using a Settings.settings file in .NET, where is the config actually stored?

When using a Settings.settings file in .NET, where is the config actually stored? I want to delete the saved settings to go back to the default state, but can't find where it's stored... any ideas?...

How to add trendline in python matplotlib dot (scatter) graphs?

How could I add trendline to a dot graph drawn using matplotlib.scatter?...

What is .htaccess file?

I am a beginner to Zend framework and I want to know more about the .htaccess file and its uses. Can somebody help me? I found an example like this: .htacess file AuthName "Member's Area Name" AuthUserFile /path/to/password/file/.htpasswd Aut...

String array initialization in Java

If I declare a String array: String names[] = new String[3]; Then why can't we assign values to the array declared above like this: names = {"Ankit","Bohra","Xyz"}; ...

Non-static method requires a target

I have a controller action that works fine on Firefox both locally and in production, and IE locally, but not IE in production. Here is my controller action: public ActionResult MNPurchase() { CalculationViewModel calculationViewModel = (Calcul...

How do I use StringUtils in Java?

I'm a beginner in Java. I want to use StringUtils.replace but Eclipse outputs "StringUtils cannot be resolved". I tried import java.lang.*;, but it doesn't work....

move a virtual machine from one vCenter to another vCenter

I have the following problem: There two separate vCenters (ESXi). They cannot see each other or communicate in any way. I can create a Clone of a VM in vCenter1 but then I want to move that Clone in vCenter2. Is there a way that I can copy the Clon...

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

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

Disabled form inputs do not appear in the request

I have some disabled inputs in a form and I want to send them to a server, but Chrome excludes them from the request. Is there any workaround for this without adding a hidden field? <form action="/Media/Add"> <input type="hidden" nam...

Best way to update an element in a generic List

Suppose we have a class called Dog with two strings "Name" and "Id". Now suppose we have a list with 4 dogs in it. If you wanted to change the name of the Dog with the "Id" of "2" what would be the best way to do it? Dog d1 = new Dog("Fluffy", "1");...

Convert HttpPostedFileBase to byte[]

In my MVC application, I am using following code to upload a file. MODEL public HttpPostedFileBase File { get; set; } VIEW @Html.TextBoxFor(m => m.File, new { type = "file" }) Everything working fine .. But I am trying to convert the resul...

Encoding an image file with base64

I want to encode an image into a string using the base64 module. I've ran into a problem though. How do I specify the image I want to be encoded? I tried using the directory to the image, but that simply leads to the directory being encoded. I want t...

What's the proper way to compare a String to an enum value?

Homework: Rock Paper Scissors game. I've created an enumeration: enum Gesture{ROCK,PAPER,SCISSORS}; from which I want to compare values to decide who wins--computer or human. Setting the values works just fine, and the comparisons work prop...

Best practices for circular shift (rotate) operations in C++

Left and right shift operators (<< and >>) are already available in C++. However, I couldn't find out how I could perform circular shift or rotate operations. How can operations like "Rotate Left" and "Rotate Right" be performed? Rotating ri...

Difference between MongoDB and Mongoose

I wanted to use the mongodb database, but I noticed that there are two different databases with either their own website and installation methods: mongodb and mongoose. So I came up asking myself this question: "Which one do I use?". So in order to ...

Mongod complains that there is no /data/db folder

I am using my new mac for the first time today. I am following the get started guide on the mongodb.org up until the step where one creates the /data/db directory. btw, I used the homebrew route. So I open a terminal, and I think I am at what you c...

AppSettings get value from .config file

I'm not able to access values in configuration file. Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var clientsFilePath = config.AppSettings.Settings["ClientsFilePath"].Value; // the second line gets ...

Should I use window.navigate or document.location in JavaScript?

What's the preferred method to use to change the location of the current web page using JavaScript? I've seen both window.navigate and document.location used. Are there any differences in behavior? Are there differences in browser implementations? ...

How to create an Explorer-like folder browser control?

Using C# and WinForms in VS2008, I want to create a file browser control that looks and acts like the left pane in Windows Explorer. To my astonishment, such a control does not ship with .NET by default. Ideally, I would like its contents to be exac...

How to change a css class style through Javascript?

According to the book that I am reading, it is better to change a css, by class when you are using Javascript for changing css. But how? Can someone give a sample snippet for this?...

Get GMT Time in Java

In Java, I want to get the current time in GMT. I tried various options like this: Date date = new Date(); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); date1 = calendar.getTime(); But the date is always is interpreted in...

Highcharts - redraw() vs. new Highcharts.chart

I'm struggling to understand the correct way to update a highcharts chart. Supposing I have rendered a chart, and then I want to update it in some way. For instance, I may want to change the values of the data series, or I may want to enable dataLa...

Jquery each - Stop loop and return object

Can anybody tell me why the loop did not stop after the 5 entry? http://jsbin.com/ucuqot/edit#preview $(document).ready(function() { someArray = new Array(); someArray[0] = 't5'; someArray[1] = 'z12'; someArray[2] = 'b88'; someArray[3] ...

Check div is hidden using jquery

This is my div <div id="car2" style="display:none;"></div> Then I have a Show button that will show the div when you click: $("show").click(function() { $("$car2").show(); }); So right now I want to check if the div #car2 is s...

Subscript out of range error in this Excel VBA script

I would like to copy data from a CSV file into an Excel worksheet. There are 11 .csv files. So far I have this (it is a modified version from a previous post): Sub importData() Dim filenum(0 To 10) As Long filenum(0) = 052 filenum(1) = 060 ...

Convert Datetime column from UTC to local time in select statement

I'm doing a few SQL select queries and would like to convert my UTC datetime column into local time to be displayed as local time in my query results. Note, I am NOT looking to do this conversion via code but rather when I am doing manual and random ...

How to place the "table" at the middle of the webpage?

I have a very basic Table structure to be placed in middle/center of the web page. I Have a code below, I know its incomplete to make this happen, as I am bad in structuring the HTML part, please help me <div align="center" style="vertical-align:...

Include in SELECT a column that isn't actually in the database

I'm trying to execute a SELECT statement that includes a column of a static string value. I've done this in Access, but never with raw SQL. Is this possible? Example: Name | Status ------+-------- John | Unpaid Terry | Unpaid Joe | Unpai...

Best way to represent a Grid or Table in AngularJS with Bootstrap 3?

I am creating an App with AngularJS and Bootstrap 3. I want to show a table/grid with thousands of rows. What is the best available control for AngularJS & Bootstrap with features like Sorting, Searching, Pagination etc....

How to access ssis package variables inside script component

How can I access variables inside my C# code which I've used in Data Flow -> Script Component - > My c# Script with my SSIS package? I have tried with which is also not working IDTSVariables100 varCollection = null; this.VariableDispenser.LockForRe...

How to hide UINavigationBar 1px bottom line

I have an app that sometimes needs its navigation bar to blend in with the content. Does anyone know how to get rid of or to change color of this annoying little bar? On the image below situation i have - i'm talking about this 1px height line be...

Apply CSS to jQuery Dialog Buttons

So I currently have a jQuery dialog with two buttons: Save and Close. I create the dialog using the code below: $dialogDiv.dialog({ autoOpen: false, modal: true, width: 600, resizable: false, buttons: { Cancel: function()...

Find a file by name in Visual Studio Code

How can I find a file by name in Visual Studio Code? A Visual Studio shortcut I'm used to is CTRL+,, but it does not work here....

How to check if an appSettings key exists?

How do I check to see if an Application Setting is available? i.e. app.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key ="someKey" value="someValue"/> </appSettings> </...

How to run a shell script at startup

On an Amazon S3 Linux instance, I have two scripts called start_my_app and stop_my_app which start and stop forever (which in turn runs my Node.js application). I use these scripts to manually start and stop my Node.js application. So far so good. M...

How to mock location on device?

How can I mock my location on a physical device (Nexus One)? I know you can do this with the emulator in the Emulator Control panel, but this doesn't work for a physical device....

How to delete Certain Characters in a excel 2010 cell

In column A I have a load of name that look like this [John Smith] I still want them in A but the [] removed... ...

how to use math.pi in java

I am having problems converting this formula V = 4/3 p r^3. I used Math.PI and Math.pow, but I get this error: ';' expected Also, the diameter variable doesn't work. Is there an error there? import java.util.Scanner; import javax.swing.JOptio...

How to check which PHP extensions have been enabled/disabled in Ubuntu Linux 12.04 LTS?

I'm using Ubuntu Linux 12.04 LTS on my local machine. I've installed LAMP long ago on my machine. Now I want to enable following PHP extensions: php_zip php_xml php_gd2 For it first I want to check whether these PHP extensions are enabled or not....

Creating custom function in React component

I have a React component export default class Archive extends React.Component { ... } componentDidMount and onClick methods partially use the same code, except for slight change in parameters. Is it possible to create a function inside the co...

Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

This is the output of my Gradle console, I am unable to build my project D:\Android Projects\....\app\src\main\res\layout\topic_view_header.xml Error:error: resource attr/?? (aka -packagename- :attr/??) not found. Error:error: resource attr/?? (aka ...

How to compute precision, recall, accuracy and f1-score for the multiclass case with scikit learn?

I'm working in a sentiment analysis problem the data looks like this: label instances 5 1190 4 838 3 239 1 204 2 127 So my data is unbalanced since 1190 instances are labeled with 5. For the classification Im...

SSIS how to set connection string dynamically from a config file

I am using SQL Server Integration Services (SSIS) in SQL Server Business Intelligent Development Studio. I need to do a task that is as follows. I have to read from a source database and put it into a destination flat file. But at the same time th...

Bootstrap number validation

I'm having Bootstrap and I have problem with validation. I need input only positive integer. How to implement it? For example: <div> <input type="number" id="replyNumber" data-bind="value:replyNumber" /> ...

Is ConfigurationManager.AppSettings available in .NET Core 2.0?

I've got a method that reads settings from my config file like this: var value = ConfigurationManager.AppSettings[key]; It compiles fine when targeting .NET Standard 2.0 only. Now I need multiple targets, so I updated my project file with: &l...

"Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))"

I am trying to use an application, the application is working fine, i am trying to edit the existing item in the application. while clicking the edit am getting the following error, System.Runtime.InteropServices.COMException was unhandled Message...

How to Animate Addition or Removal of Android ListView Rows

In iOS, there is a very easy and powerful facility to animate the addition and removal of UITableView rows, here's a clip from a youtube video showing the default animation. Note how the surrounding rows collapse onto the deleted row. This animatio...

PDO support for multiple queries (PDO_MYSQL, PDO_MYSQLND)

I do know that PDO does not support multiple queries getting executed in one statement. I've been Googleing and found few posts talking about PDO_MYSQL and PDO_MYSQLND. PDO_MySQL is a more dangerous application than any other traditional MySQ...

Styling Password Fields in CSS

I'm experiencing a minor issue with fonts in my stylesheet. This is my CSS: body { ... font: normal 62.5% "Lucida Sans Unicode",sans-serif; } #wrapper_page { ... font-size: 1.2em; } input, select, textarea { ... font: bold 100% "Lucid...

Getting a list of all subdirectories in the current directory

Is there a way to return a list of all the subdirectories in the current directory in Python? I know you can do this with files, but I need to get the list of directories instead....

Kubernetes how to make Deployment to update image

I do have deployment with single pod, with my custom docker image like: containers: - name: mycontainer image: myimage:latest During development I want to push new latest version and make Deployment updated. Can't find how to do that, withou...

standard_init_linux.go:190: exec user process caused "no such file or directory" - Docker

When I am running my docker image on windows 10. I am getting this error: standard_init_linux.go:190: exec user process caused "no such file or directory" my docker file is: FROM openjdk:8 EXPOSE 8080 VOLUME /tmp ADD appagent.tar.gz /opt/app-a...

Pair/tuple data type in Go

While doing the final exercise of the Tour of Go, I decided I needed a queue of (string, int) pairs. That's easy enough: type job struct { url string depth int } queue := make(chan job) queue <- job{url, depth} But this got me thinking...

Multiple argument IF statement - T-SQL

How do I write an IF statement with multiple arguments in T-SQL? Current source error: DECLARE @StartDate AS DATETIME DECLARE @EndDate AS DATETIME SET @StartDate = NULL SET @EndDate = NULL IF (@StartDate IS NOT NULL AND @EndDate IS NOT NULL) ...

NameError: name 'reduce' is not defined in Python

I'm using Python 3.2. Tried this: xor = lambda x,y: (x+y)%2 l = reduce(xor, [1,2,3,4]) And got the following error: l = reduce(xor, [1,2,3,4]) NameError: name 'reduce' is not defined Tried printing reduce into interactive console - got this err...

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

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

Convert Object to JSON string

jQuery.parseJSON('{"name":"John"}') converts string representation to object but I want the reverse. Object is to be converted to JSON string I got a link http://www.devcurry.com/2010/03/convert-javascript-object-to-json.html but it need to have json...

Round up value to nearest whole number in SQL UPDATE

I'm running SQL that needs rounding up the value to the nearest whole number. What I need is 45.01 rounds up to 46. Also 45.49 rounds to 46. And 45.99 rounds up to 46, too. I want everything up one whole digit. How do I achieve this in an UPDATE st...

How to get Time from DateTime format in SQL?

I want to get only Time from DateTime column using SQL query using SQL Server 2005 and 2008 Default output: AttDate == 2011-02-09 13:09:00 2011-02-09 14:10:00 I'd like this output: AttDate Time == 2011-...

Column/Vertical selection with Keyboard in SublimeText 3

I'm on a Mac. I have 7 columns in Sublime Text 3, each 300 lines each. If possible, I would like to select only the 4th column using a single keyboard shortcut. Unsuitable options ctrl + shift + up/down alt + mouse + drag ctrl + alt + up/down. (T...

How can I change from SQL Server Windows mode to mixed mode (SQL Server 2008)?

I have installed SQL Server 2008 Express Edition, but by mistake I kept the Windows authentication mode. Now I want to change that to SQL Server mixed mode. How can I do this?...

How to get screen width and height

I tried to use following code to get screen width and height in android app development: Display display = getWindowManager().getDefaultDisplay(); int screenWidth = display.getWidth(); int screenHeight = display.getHeight(); but I got NullPointer...

How do I remove a CLOSE_WAIT socket connection

I have written a small program that interacts with a server on a specific port. The program works fine, but: Once the program terminated unexpectedly, and ever since that socket connection is shown in CLOSE_WAIT state. If I try to run a program it h...

Clear input fields on form submit

I know this is continuously asked anew, and I've checked out different answers and tried different solutions but to no avail. In some cases it can be really be a case by case thing depending on how the code has been redacted. I'd like to simply have...

Jenkins Slave port number for firewall

We use Jenkins 1.504 on Windows. We need to have Master and Slave in different sub-networks with firewall in between. We can't have ANY to ANY port firewall rules, we must specify exact port numbers. I know the port Master is listening on. I also ...

Select all text inside EditText when it gets focus

I have an EditText with some dummy text in it. When the user clicks on it I want it to be selected so that when the user starts typing the dummy text gets deleted. How can I achieve this?...

Write variable to a file in Ansible

I am pulling JSON via the URI module and want to write the received content out to a file. I am able to get the content and output it to the debugger so I know the content has been received, but I do not know the best practice for writing files....

Python: Tuples/dictionaries as keys, select, sort

Suppose I have quantities of fruits of different colors, e.g., 24 blue bananas, 12 green apples, 0 blue strawberries and so on. I'd like to organize them in a data structure in Python that allows for easy selection and sorting. My idea was to put the...

How to use KeyListener

I am currently trying to implement a keylistener in my program so that it does an action when I pressed an arrow key, the object in my program either moves left or right. Here is the moving method in my program public void moveDirection(KeyEvent e)...

How to rename JSON key

I have a JSON object with the following content: [ { "_id":"5078c3a803ff4197dc81fbfb", "email":"[email protected]", "image":"some_image_url", "name":"Name 1" }, { "_id":"5078c3a803ff4197dc81fbfc", "email":"[email protected]...

JavaScript hashmap equivalent

As made clear in update 3 on this answer, this notation: var hash = {}; hash[X] does not actually hash the object X; it actually just converts X to a string (via .toString() if it's an object, or some other built-in conversions for various primitive...

Reading Datetime value From Excel sheet

when am trying to read datetime type value from excel sheet it is returning a double value.for example if want to read value '2007-02-19 14:11:45.730' like this, i am getting a double type value .further i am converting this double value using timesp...

JS: iterating over result of getElementsByClassName using Array.forEach

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

Docker error : no space left on device

I installed docker on a Debian 7 machine in the following way $ echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list $ sudo apt-get update $ curl -sSL https://get.docker.com/ubuntu/ | sudo sh After that when I...

Create a Dropdown List for MVC3 using Entity Framework (.edmx Model) & Razor Views && Insert A Database Record to Multiple Tables

After reading 100's of articles on here about how to create a DropDown List in MVC 3 with Razor Views, I could not find one that fit my case. Situation: I am ultimately trying to create a View to Add an Employee to a Database. Here is an image of t...

How do I update a GitHub forked repository?

I recently forked a project and applied several fixes. I then created a pull request which was then accepted. A few days later another change was made by another contributor. So my fork doesn't contain that change. How can I get that change into m...

MySQL LIMIT on DELETE statement

I put together a test table for a error I recently came across. It involves the use of LIMIT when attempting to delete a single record from a MySQL table. The error I speak of is "You have an error in your SQL syntax; check the manual that correspon...

Best cross-browser method to capture CTRL+S with JQuery?

My users would like to be able to hit Ctrl+S to save a form. Is there a good cross-browser way of capturing the Ctrl+S key combination and submit my form? App is built on Drupal, so jQuery is available....

Quickest way to clear all sheet contents VBA

I have a large sheet that I need to delete all the contents of. When I try to simply clear it without VBA it goes into not responding mode. When using a macro such as: Sub ClearContents () Application.Calculation = XlManual Application.ScreenUpdat...

How do I access store state in React Redux?

I am just making a simple app to learn async with redux. I have gotten everything working, now I just want to display the actual state onto the web-page. Now, how do I actually access the store's state in the render method? Here is my code (everyt...

smtpclient " failure sending mail"

here is my code for(int i = 0; i < number ; i++) { MailAddress to = new MailAddress(iMail.to); MailAddress from = new MailAddress(iMail.from, iMail.displayName); string body = iMail.body; string subject = iMail.sub; oMail = new...

MySql server startup error 'The server quit without updating PID file '

On Snow Leopard, starting MySQL gives the following error: The server quit without updating PID file my.cnf [mysqld] port = 3306 socket = /tmp/mysql.sock skip-external-locking key_buffer_size = 16K pid-file=/var/run/mys...

Set default value of javascript object attributes

Is there a way to set the default attribute of a javascript object such that: var emptyObj = {}; // do some magic emptyObj.nonExistingAttribute // => defaultValue IE can be disregarded, Chrome Frame has relieved me of that headache....

Calculate distance between two points in google maps V3

How do you calculate the distance between two markers in Google maps V3? (Similar to the distanceFrom function inV2.) Thanks.....

How can I revert multiple Git commits (already pushed) to a published repository?

New to git, and already messing up. I've commited and pushed some changes to a remote dev machine. I need to recover an older version, but keep the "bad progress" doing so far to keep working on a separate branch; I was thinking doing it like this:...

How to update one file in a zip archive

Is it possible to replace a file in a zip file without unzipping deleting the old file adding the new file and rezipping it back? Reason is I have a zip file which is really big there is one xml inside the zip file that I have to update sometimes. ...

How to remove files from git staging area?

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

What is Mocking?

What is Mocking??    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ....

Android: How to bind spinner to custom object list?

In the user interface there has to be a spinner which contains some names (the names are visible) and each name has its own ID (the IDs are not equal to display sequence). When the user selects the name from the list the variable currentID has to be ...

Is there a way I can retrieve sa password in sql server 2005

I just forgot the password. Can anyone help me how to get back the password....

Calling a method every x minutes

I want to call some method on every 5 minutes. How can I do this? public class Program { static void Main(string[] args) { Console.WriteLine("*** calling MyMethod *** "); Console.ReadLine(); } private MyMethod() ...

Converting serial port data to TCP/IP in a Linux environment

I need to get data from the serial port of a Linux system and convert it to TCP/IP to send to a server. Is this difficult to do? I have some basic programming experience, but not much experience with Linux. Is there an open source application that do...

git cherry-pick says "...38c74d is a merge but no -m option was given"

I made some changes in my master branch and want to bring those upstream. when I cherry-pick the following commits however I get stuck on fd9f578 where git says: $ git cherry-pick fd9f578 fatal: Commit fd9f57850f6b94b7906e5bbe51a0d75bf638c74d is a m...

Numpy Resize/Rescale Image

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

Triggering change detection manually in Angular

I'm writing an Angular component that has a property Mode(): string. I would like to be able to set this property programmatically not in response to any event. The problem is that in the absence of a browser event, a template binding {{Mode}} does...

Pip error: Microsoft Visual C++ 14.0 is required

I just ran the following command: pip install -U steem and the installation worked well until it failed to install pycrypto. Afterwards I did the pip install cryptography command because I thought it was the missing package. So my question is, how ...

How to get value of selected radio button?

I want to get the selected value from a group of radio buttons. Here's my HTML: <div id="rates"> <input type="radio" id="r1" name="rate" value="Fixed Rate"> Fixed Rate <input type=&...

Plotting time-series with Date labels on x-axis

I know that this question might be a cliche, but I'm having hard time doing it. I've data set in the following format: Date Visits 11/1/2010 696537 11/2/2010 718748 11/3/2010 799355 11/4/2010 ...

Adding and using header (HTTP) in nginx

I am using two system (both are Nginx load balancer and one act as backup). I want to add and use few HTTP custom headers. Below are my codes for both; upstream upstream0 { #list of upstream servers server backend:80; server backup_loa...

Eclipse - "Workspace in use or cannot be created, chose a different one."

I'm trying to create a workspace in the /Users/Shared/ directory with the thought that I can share that workspace between users. The problem is that after I create the workspace and change the permission on it, I encounter the error below (image) wit...

Updating state on props change in React Form

I am having trouble with a React form and managing the state properly. I have a time input field in a form (in a modal). The initial value is set as a state variable in getInitialState, and is passed in from a parent component. This in itself works f...

CSS rule to apply only if element has BOTH classes

Let's say we have this markup: <div class="abc"> ... </div> <div class="xyz"> ... </div> <div class="abc xyz" style="width: 100px"> ... </div> Is there a way to select only the <div> which has BOTH abc and...

Make an image width 100% of parent div, but not bigger than its own width

I’m trying to get an image (dynamically placed, with no restrictions on dimensions) to be as wide as its parent div, but only as long as that width isn’t wider than its own width at 100%. I’ve tried this, to no avail: img { width: 100%; ...

What's the right way to pass form element state to sibling/parent elements?

Suppose I have a React class P, which renders two child classes, C1 and C2. C1 contains an input field. I'll refer to this input field as Foo. My goal is to let C2 react to changes in Foo. I've come up with two solutions, but neither of them...

How to delete duplicates on a MySQL table?

I need to DELETE duplicated rows for specified sid on a MySQL table. How can I do this with an SQL query? DELETE (DUPLICATED TITLES) FROM table WHERE SID = "1" Something like this, but I don't know how to do it....

How to remove a TFS Workspace Mapping?

I had a project in tfs within a team project then we moved the project to a different location in another team project. I had configured Jenkins to connect to the team project and build my solution but when I changed the settings to connect to the n...

Ubuntu: Using curl to download an image

I want to download an image accessible from this link: https://www.python.org/static/apple-touch-icon-144x144-precomposed.png into my local system. Now, I'm aware that the curl command can be used to download remote files through the terminal. So, I ...

Are vectors passed to functions by value or by reference in C++

I'm coding in C++. If I have some function void foo(vector<int> test) and I call it in my program, will the vector be passed by value or reference? I'm unsure because I know vectors and arrays are similar and that a function like void bar(int t...

How to use custom font in a project written in Android Studio

I was trying to use custom font in Android Studio as we did in Eclipse. But unfortunately could not figure out where to put the 'assets' folder!...

VMware Workstation and Device/Credential Guard are not compatible

I have been running VMware for the last year no problems, today I opened it up to start one of my VM and get an error message, see screen shot. I did follow the link and went through the steps, on step 4 I need to mount a volume using "mountvol". ...

Django Model() vs Model.objects.create()

What it the difference between running two commands: foo = FooModel() and bar = BarModel.objects.create() Does the second one immediately create a BarModel in the database, while for FooModel, the save() method has to be called explicitly to ad...

Set folder for classpath

From the command line, how do I set the Java CLASSPATH option to point to one or more directories containing multiple jar file? Are there wildcards for recursive directory and sub-directory support? (My JAR files are sorted in several sub-directorie...

An URL to a Windows shared folder

Is there a way to incorporate a working link to a Windows shared folder into an HTML page? E.g. a link to \\server\folder\path? For simplicity, let's say the page will be opened on a Windows machine (and on the same intranet where the server is loc...

Negate if condition in bash script

I'm new to bash and I'm stuck at trying to negate the following command: wget -q --tries=10 --timeout=20 --spider http://google.com if [[ $? -eq 0 ]]; then echo "Sorry you are Offline" exit 1 This if condition returns true if I'm c...

Should I return EXIT_SUCCESS or 0 from main()?

It's a simple question, but I keep seeing conflicting answers: should the main routine of a C++ program return 0 or EXIT_SUCCESS? #include <cstdlib> int main(){return EXIT_SUCCESS;} or int main(){return 0;} Are they the exact same thing? ...

Android Button click go to another xml page

So what I've done in Eclipse, in layouts I have: activity_main.xml and activity_main2.xml. What I tried is to create a button in activity_main.xml and on click to go on screen of activity_main2.xml so in com.example.myfirstapp I have MainActivity....

Phone validation regex

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

What's the difference between deadlock and livelock?

Can somebody please explain with examples (of code) what is the difference between deadlock and livelock?...

Casting int to bool in C/C++

I know that in C and C++, when casting bools to ints, (int)true == 1 and (int)false == 0. I'm wondering about casting in the reverse direction... In the code below, all of the following assertions held true for me in .c files compiled with Visual St...

How do I find my host and username on mysql?

I need to open my database through PHP. But I need to know my username and the name of my host (e.g. localhost), and I don't know them. When I used mysql and did my database, it just asked me directly for a password. How do I find my host and usernam...

How to set a class attribute to a Symfony2 form input

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

Calculate difference between two datetimes in MySQL

I am storing the last login time in MySQL in, datetime-type filed. When users logs in, I want to get the difference between the last login time and the current time (which I get using NOW()). How can I calculate it?...

How to set timer in android?

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

Convert Map<String,Object> to Map<String,String>

How can I convert Map<String,Object> to Map<String,String> ? This does not work: Map<String,Object> map = new HashMap<String,Object>(); //Object is containing String Map<String,String> newMap =new HashMap<String,St...

Inline SVG in CSS

Is it possible to use an inline SVG definition in CSS? I mean something like: .my-class { background-image: <svg>...</svg>; } ...

Running Python code in Vim

I am writing Python code using Vim, and every time I want to run my code, I type this inside Vim: :w !python This gets frustrating, so I was looking for a quicker method to run Python code inside Vim. Executing Python scripts from a terminal maybe...

How to calculate number of days between two given dates?

If I have two dates (ex. '8/18/2008' and '9/26/2008'), what is the best way to get the number of days between these two dates?...

How to add soap header in java

i have a NO-.net webservice from oracle To access i need to add the soap header. How can i add the soap header in java? Authenticator.setDefault(new ProxyAuthenticator("username", "password")); System.getProperties().put("proxySet", ...

What is a pre-revprop-change hook in SVN, and how do I create it?

I wanted to edit a log comment in the repository browser and received an error message that no pre-revprop-change hook exists for the repository. Besides having a scary name, what is a pre-revprop-change hook, and how do I create it?...

How to set cache: false in jQuery.get call

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

How to change target build on Android project?

I currently have an Android project in Eclipse. I created it with a target build of 1.5 (sdk 3). Now I want to change it so that it has a minSdk of 3 and targetSdk of 8. To do this I see that I must build against the newest SDK (2.2) To do this i...

Omitting one Setter/Getter in Lombok

I want to use a data class in Lombok. Since it has about a dozen fields, I annotated it with @Data in order to generate all the setters and getter. However there is one special field for which I don't want to the accessors to be implemented. How do...

Check that an email address is valid on iOS

Possible Duplicate: Best practices for validating email address in Objective-C on iOS 2.0? I am developing an iPhone application where I need the user to give his email address at login. What is the best way to check if an email address i...

Constants in Kotlin -- what's a recommended way to create them?

How is it recommended to create constants in Kotlin? And what's the naming convention? I've not found that in the documentation. companion object { //1 val MY_CONST = "something" //2 const val MY_CONST = "something" //3 val...

Converting array to list in Java

How do I convert an array to a list in Java? I used the Arrays.asList() but the behavior (and signature) somehow changed from Java SE 1.4.2 (docs now in archive) to 8 and most snippets I found on the web use the 1.4.2 behaviour. For example: int[]...

Change the location of the ~ directory in a Windows install of Git Bash

I am not even sure I am asking the right question. Let me explain my situation: This is about Git on Windows 7. My company sets up the Windows user directory on a network drive, not on the local hard drive (for backup and other purposes beyond...

List comprehension vs map

Is there a reason to prefer using map() over list comprehension or vice versa? Is either of them generally more efficient or considered generally more pythonic than the other?...

LINQ: combining join and group by

I have a query that combines a join and a group, but I have a problem. The query is like: var result = from p in Products join bp in BaseProducts on p.BaseProductId equals bp.Id group p by p.SomeId into...

How do I create a view controller file after creating a new view controller?

I am developing a tabbed application. When I create a new view controller and link it to the tab bar controller, unlike the other two default view controllers, this one has no viewcontroller.swift file. How can I create this file? I am using Xcode...

Plotting 4 curves in a single plot, with 3 y-axes

I have 4 sets of values: y1, y2, y3, y4 and one set x. The y values are of different ranges, and I need to plot them as separate curves with separate sets of values on the y-axis. To put it simple, I need 3 y-axes with different values (scales) for ...

Create a new database with MySQL Workbench

Being new to MySQL, I have installed the latest version of the MySQL Workbench (5.2.33). I would like to know how you can create a database with this application. In the Overview tab of the SQL editor there are few "MySQL Schema" displayed, are these...

How can I fix WebStorm warning "Unresolved function or method" for "require" (Firefox Add-on SDK)

I'm using WebStorm 7 for Firefox Add-on SDK development. WebStorm shows a warning: "Unresolved function or method" for require(). I want to get rid of the warning. var pageMod = require("sdk/page-mod"); NOTE:I already configured JavaScript-libra...

jQuery prevent change for select

I want to prevent a select box from being changed if a certain condition applies. Doing this doesn't seem to work: $('#my_select').bind('change', function(ev) { if(my_condition) { ev.preventDefault(); return false; } }); I'm guessin...

How do you add multi-line text to a UIButton?

I have the following code... UILabel *buttonLabel = [[UILabel alloc] initWithFrame:targetButton.bounds]; buttonLabel.text = @"Long text string"; [targetButton addSubview:buttonLabel]; [targetButton bringSubviewToFront:buttonLabel]; ...the idea bei...

Empty set literal?

[] = empty list () = empty tuple {} = empty dict Is there a similar notation for an empty set? Or do I have to write set()?...

How do I use a compound drawable instead of a LinearLayout that contains an ImageView and a TextView

Ran the new Lint tool against my code. It came up with a lot of good suggestions, but this one I cannot understand. This tag and its children can be replaced by one and a compound drawable Issue: Checks whether the current node can be replaced by ...

Difference between logical addresses, and physical addresses?

I am reading Operating Systems Concept and I am on the 8th chapter! However I could use some clarification, or reassurance that my understanding is correct. Logical Addresses: Logical addresses are generated by the CPU, according to the book. What ...

Does Python have a ternary conditional operator?

If Python does not have a ternary conditional operator, is it possible to simulate one using other language constructs?...

How do I detect when someone shakes an iPhone?

I want to react when somebody shakes the iPhone. I don't particularly care how they shake it, just that it was waved vigorously about for a split second. Does anyone know how to detect this?...

Determine the size of an InputStream

My current situation is: I have to read a file and put the contents into InputStream. Afterwards I need to place the contents of the InputStream into a byte array which requires (as far as I know) the size of the InputStream. Any ideas? As requested...

Best practices for styling HTML emails

I'm designing an HTML template for an email newsletter. I've learned that many email clients ignore linked stylesheets, and many others (including Gmail) ignore CSS block declarations altogether. Are inline style attributes my only choice? What are t...

Error using eclipse for Android - No resource found that matches the given name

Common problem I'm sure, but I can't figure it out. In my AndroidManifest.xml and main.xml I'm getting the no resource found that matches the given name. I've double checked for typos and it used to work, but now I'm popping up with all these error...

Get the _id of inserted document in Mongo database in NodeJS

I use NodeJS to insert documents in MongoDB. Using collection.insert I can insert a document into database like in this code: // ... collection.insert(objectToInsert, function(err){ if (err) return; // Object inserted successfully. var obje...

Determine if Python is running inside virtualenv

Is it possible to determine if the current script is running inside a virtualenv environment?...

PHP - Indirect modification of overloaded property

I know this question has been asked several times, but none of them have a real answer for a workaround. Maybe there's one for my specific case. I'm building a mapper class which uses the magic method __get() to lazy load other objects. It looks som...

Retrieve data from a ReadableStream object?

How may I get information from a ReadableStream object? I am using the Fetch API and I don't see this to be clear from the documentation. The body is being returned as a ReadableStream and I would simply like to access a property within this stre...

"Content is not allowed in prolog" when parsing perfectly valid XML on GAE

I've been beating my head against this absolutely infuriating bug for the last 48 hours, so I thought I'd finally throw in the towel and try asking here before I throw my laptop out the window. I'm trying to parse the response XML from a call I made...

Convert a number range to another range, maintaining ratio

I'm trying to convert one range of numbers to another, maintaining ratio. Maths is not my strong point. I have an image file where point values may range from -16000.00 to 16000.00 though the typical range may be much less. What I want to do is comp...

Basic authentication for REST API using spring restTemplate

I am completely new in RestTemplate and basically in the REST APIs also. I want to retrieve some data in my application via Jira REST API, but getting back 401 Unauthorised. Found and article on jira rest api documentation but don't really know how t...

In Python, how do I read the exif data for an image?

I'm using PIL. How do I turn the EXIF data of a picture into a dictionary?...

Multiple file-extensions searchPattern for System.IO.Directory.GetFiles

What is the syntax for setting multiple file-extensions as searchPattern on Directory.GetFiles()? For example filtering out files with .aspx and .ascx extensions. // TODO: Set the string 'searchPattern' to only get files with // the extension '.aspx...

PHP Parse HTML code

Possible Duplicate: Best methods to parse HTML How can I parse HTML code held in a PHP variable if it something like: <h1>T1</h1>Lorem ipsum.<h1>T2</h1>The quick red fox...<h1>T3</h1>... jumps over the ...

How can I get the size of an std::vector as an int?

I tried: #include <vector> int main () { std::vector<int> v; int size = v.size; } but got the error: cannot convert 'std::vector<int>::size' from type 'std::vector<int>::size_type (std::vector<int>::)() cons...

How do I access properties of a javascript object if I don't know the names?

Say you have a javascript object like this: var data = { foo: 'bar', baz: 'quux' }; You can access the properties by the property name: var foo = data.foo; var baz = data["baz"]; But is it possible to get these values if you don't know the name...

How to send a POST request from node.js Express?

Could someone show me the simplest way to send a post request from node.js Express, including how to pass and retrieve some data? I am expecting something similar to cURL in PHP....

How do I view the list of functions a Linux shared library is exporting?

I want to view the exported functions of a shared library on Linux. What command allows me to do this? (On Windows I use the program depends)...

Facebook API - How do I get a Facebook user's profile image through the Facebook API (without requiring the user to "Allow" the application)

I'm working on a CMS that fetches a user's profile image from their Facebook URL (that is, http://facebook.com/users_unique_url). How can I accomplish this? Is there a Faceboook API call that fetches a user's profile image URL without the user needin...

List all column except for one in R

Possible Duplicate: Drop Columns R Data frame Let's say I have a dataframe with column c1, c2, c3. I want to list just c1 and c2. How do I do that? I've tried: head(data[column!="c3"]) head(data)[,2] head(data[!"c3"]) ...

Deleting rows with MySQL LEFT JOIN

I have two tables, one for job deadlines, one for describe a job. Each job can take a status and some statuses means the jobs' deadlines must be deleted from the other table. I can easily SELECT the jobs/deadlines that meets my criteria with a LEFT ...

super() fails with error: TypeError "argument 1 must be type, not classobj" when parent does not inherit from object

I get some error that I can't figure out. Any clue what is wrong with my sample code? class B: def meth(self, arg): print arg class C(B): def meth(self, arg): super(C, self).meth(arg) print C().meth(1) I got the sample te...

Unzip All Files In A Directory

I have a directory of ZIP files (created on a Windows machine). I can manually unzip them using unzip filename, but how can I unzip all the ZIP files in the current folder via the shell? Using Ubuntu Linux Server....

Remove Sub String by using Python

I already extract some information from a forum. It is the raw string I have now: string = 'i think mabe 124 + <font color="black"><font face="Times New Roman">but I don\'t have a big experience it just how I see it in my eyes <font c...

Response.Redirect to new window

I want to do a Response.Redirect("MyPage.aspx") but have it open in a new browser window. I've done this before without using the JavaScript register script method. I just can't remember how?...

Select specific row from mysql table

Ideally I need a query that is equivalent to select * from customer where row_number() = 3 but that's illegal. I can't use an auto incremented field. row_number() is the row that needs to be selected. How do I go about this? EDIT: Well, I us...

How to set UICollectionViewCell Width and Height programmatically

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

How do you push just a single Git branch (and no other branches)?

I am working on a local git repository. There are two branches, master and feature_x. I want to push feature_x to the remote repo, but I do not want to push the changes on the master branch. Will a git push origin feature_x from my feature_x branch...

Angular window resize event

I would like to perform some tasks based on the window re-size event (on load and dynamically). Currently I have my DOM as follows: <div id="Harbour"> <div id="Port" (window:resize)="onResize($event)" > <router-outlet>...

Download a file from HTTPS using download.file()

I would like to read online data to R using download.file() as shown below. URL <- "https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Fss06hid.csv" download.file(URL, destfile = "./data/data.csv", method="curl") Someone suggested to me that...

$_POST vs. $_SERVER['REQUEST_METHOD'] == 'POST'

Some guy called one of my Snipplr submissions "crap" because I used if ($_SERVER['REQUEST_METHOD'] == 'POST') instead of if ($_POST) Checking the request method seems more correct to me because that's what I really want to do. Is there some operatio...

Clearing input in vuejs form

Just completed a todolist tutorial. When submitting the form the input field doesn't clear. After trying both: document.getElementById("todo-field").reset(); document.getElementById("#todo-field").value = ""; The input field properly cl...

Displaying Windows command prompt output and redirecting it to a file

How can I run a command-line application in the Windows command prompt and have the output both displayed and redirected to a file at the same time? If, for example, I were to run the command dir > test.txt, this would redirect output to a file c...

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 to use ng-repeat without an html element

I need to use ng-repeat (in AngularJS) to list all of the elements in an array. The complication is that each element of the array will transform to either one, two or three rows of a table. I cannot create valid html, if ng-repeat is used on an e...

android.os.FileUriExposedException: file:///storage/emulated/0/test.txt exposed beyond app through Intent.getData()

The app is crashing when I'm trying to open a file. It works below Android Nougat, but on Android Nougat it crashes. It only crashes when I try to open a file from the SD card, not from the system partition. Some permission problem? Sample code: Fi...

What is 'Currying'?

I've seen references to curried functions in several articles and blogs but I can't find a good explanation (or at least one that makes sense!)...

Matplotlib connect scatterplot points with line - Python

I have two lists, dates and values. I want to plot them using matplotlib. The following creates a scatter plot of my data. import matplotlib.pyplot as plt plt.scatter(dates,values) plt.show() plt.plot(dates, values) creates a line graph. But wha...

Submit form after calling e.preventDefault()

I'm doing some simple form validation here and got stuck on a very basic issue. I have 5 field pairs for name and entree (for a dinner registration). The user can enter 1-5 pairs, but an entree must be selected if a name is present. Code: http://jsf...

Sequelize OR condition object

By creating object like this var condition= { where: { LastName:"Doe", FirstName:["John","Jane"], Age:{ gt:18 } } } and pass it in Student.findAll(condition) .success(function(students){ }) It could beautif...

How to run certain task every day at a particular time using ScheduledExecutorService?

I am trying to run a certain task everyday at 5 AM in the morning. So I decided to use ScheduledExecutorService for this but so far I have seen examples which shows how to run task every few minutes. And I am not able to find any example which show...

Formatting struct timespec

How to format struct timespec to string? This structure is returned e.g. by clock_gettime() on Linux gcc: struct timespec { time_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ }; ...

How to drop all tables in a SQL Server database?

I'm trying to write a script that will completely empty a SQL Server database. This is what I have so far: USE [dbname] GO EXEC sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all' EXEC sp_msforeachtable 'DELETE ?' When I run it in the Managem...

Creating an IFRAME using JavaScript

I have a webpage hosted online and I would like it to be possible that I could insert an IFRAME onto another webpage using some JavaScript. How would this be the best way possible, that I just add my webpage URL to the JavaScript and that it work on...

How to find the index of an element in an array in Java?

I am looking to find the index of a given element, knowing its contents, in Java. I tried the following example, which does not work: class masi { public static void main( String[] args ) { char[] list = {'m', 'e', 'y'}; // s...

Publish to IIS, setting Environment Variable

Reading these two questions/answers I was able to run an Asp.net 5 app on IIS 8.5 server. Asp.net vNext early beta publish to IIS in windows server How to configure an MVC6 app to work on IIS? The problem is that the web app is still using env.Env...

Fast Bitmap Blur For Android SDK

Currently in an Android application that I'm developing I'm looping through the pixels of an image to blur it. This takes about 30 seconds on a 640x480 image. While browsing apps in the Android Market I came across one that includes a blur featur...

Issue with parsing the content from json file with Jackson & message- JsonMappingException -Cannot deserialize as out of START_ARRAY token

Given the following .json file: [ { "name" : "New York", "number" : "732921", "center" : [ "latitude" : 38.895111, "longitude" : -77.036667 ] }, { "name" : "San...

Navigation Drawer (Google+ vs. YouTube)

Does anyone know how to implement a sliding menu like some of the top apps of today? Other Stack Overflow questions haven't had any answers on how to do this, so I'm trying to gather as much info to help out others. All the applications I mention b...

Specific Time Range Query in SQL Server

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

500 internal server error, how to debug

I have internal server errors on my POST requests. How can I debug them ? Is it something to set up in php.ini ? THe file is really big and the word 'error' is met there many-many times....

How do I update the element at a certain position in an ArrayList?

I have one ArrayList of 10 Strings. How do I update the index 5 with another String value?...

The relationship could not be changed because one or more of the foreign-key properties is non-nullable

I am getting this error when I GetById() on an entity and then set the collection of child entities to my new list which comes from the MVC view. The operation failed: The relationship could not be changed because one or more of the foreign-k...

Scala: write string to file in one statement

For reading files in Scala, there is Source.fromFile("file.txt").mkString Is there an equivalent and concise way to write a string to file? Most languages support something like that. My favorite is Groovy: def f = new File("file.txt") // Read ...

jquery toggle slide from left to right and back

I have a "Menu" button on the left hand side of the page and once selected I have a div containing the menu items show. I then have another button that can be selected to hide the menu. Ideally I want this to slide out (from left to right) and back...

How to show a confirm message before delete?

I want to get a confirm message on clicking delete (this maybe a button or an image). If the user selects 'Ok' then delete is done, else if 'Cancel' is clicked nothing happens. I tried echoing this when the button was clicked, but echoing stuff mak...

How to send a stacktrace to log4j?

Say you catch an exception and get the following on the standard output (like, say, the console) if you do a e.printStackTrace() : java.io.FileNotFoundException: so.txt at java.io.FileInputStream.<init>(FileInputStream.java) at...

Gridview row editing - dynamic binding to a DropDownList

I'm trying to get an ASP.NET 3.5 GridView to show a selected value as string when being displayed, and to show a DropDownList to allow me to pick a value from a given list of options when being edited. Seems simple enough? My gridview looks like thi...

DECODE( ) function in SQL Server

SELECT PC_COMP_CODE, 'R', PC_RESUB_REF, DECODE(PC_SL_LDGR_CODE, '02', 'DR', 'CR'), PC_DEPT_NO DEPT, '', --PC_DEPT_NO, PC_SL_LDGR_CODE + '/' + PC_SL_ACNO, SUM(DECODE(PC_SL_LDGR_CODE, '02', 1, -1) * PC_A...

Call to a member function fetch_assoc() on boolean in <path>

I'm getting the above error when running the below code to display bookings made from a database. <?php $servername = "localhost"; $username = "*********"; $password = "********"; ...

EPPlus - Read Excel Table

Using EPPlus, I want to read an excel table, then store all the contents from each column into its corresponding List. I want it to recognize the table's heading and categorize the contents based on that. For example, if my excel table is as below: ...

angular js unknown provider

I'm trying to "customize" the mongolab example to fit my own REST API. Now I'm running into this error and I am not sure what I am doing wrong: Error: Unknown provider: ProductProvider <- Product at Error (unknown source) at http://localh...

Regex to match only uppercase "words" with some exceptions

I have technical strings as the following: "The thing P1 must connect to the J236 thing in the Foo position." I would like to match with a regular expression those only-in-uppercase words (namely here P1 and J236). The problem is that I don't want...

Convert pandas dataframe to NumPy array

I am interested in knowing how to convert a pandas dataframe into a NumPy array. dataframe: import numpy as np import pandas as pd index = [1, 2, 3, 4, 5, 6, 7] a = [np.nan, np.nan, np.nan, 0.1, 0.1, 0.1, 0.1] b = [0.2, np.nan, 0.2, 0.2, 0.2, np.n...

MySQL Job failed to start

I'm on Kubuntu 12.04, and after installing mysql via an apt-get (mysql ver: 5.5.35), i'm trying to start mysql service, but I got this error: sudo service mysql start start: Job failed to start So I googled this problem, it says i have to ...

Send a base64 image in HTML email

Using a rich-text editor, our users can drag and drop a saved image from their desktop to the editor. The image appears and displays properly in the web page after they submit. Since the image is not uploaded anywhere, the editor saves the image as ...

How to detect reliably Mac OS X, iOS, Linux, Windows in C preprocessor?

If there's some cross-platform C/C++ code that should be compiled on Mac OS X, iOS, Linux, Windows, how can I detect them reliably during preprocessor process?...

Delete item from state array in react

The story is, I should be able to put Bob, Sally and Jack into a box. I can also remove either from the box. When removed, no slot is left. people = ["Bob", "Sally", "Jack"] I now need to remove, say, "Bob". The new array would be: ["Sally", "Jac...

Capture close event on Bootstrap Modal

I have a Bootstrap Modal to select events. If the user clicks on the X button or outside the modal, I would like to send them to the default event. How can I capture these events? This is my HTML code: <div class="modal" id="myModal"> <...

How to set MouseOver event/trigger for border in XAML?

I want the border to turn green when the mouse is over it and then to return to blue when the mouse is no longer over the border. I attempted this without any luck: <Border Name="ClearButtonBorder" Grid.Column="1" CornerRadius="0...

Insert entire DataTable into database at once instead of row by row?

I have a DataTable and need the entire thing pushed to a Database table. I can get it all in there with a foreach and inserting each row at a time. This goes very slow though since there are a few thousand rows. Is there any way to do the entire da...

Forcing Internet Explorer 9 to use standards document mode

How can I force Internet Explorer 9 to use standards document mode? I built a website and I'm finding that IE9 uses quirks mode to render the website pages. But I want to use standards mode for rendering....

Turn off display errors using file "php.ini"

I am trying to turn off all errors on my website. I have followed different tutorials on how to do this, but I keep getting read and open error messages. Is there something I am missing? I have tried the following in my php.ini file: ;Error display...

C pointers and arrays: [Warning] assignment makes pointer from integer without a cast

I'm having some trouble with pointers and arrays in C. Here's the code: #include<stdio.h> int *ap; int a[5]={41,42,43,44,45}; int x; int main() { ap = a[4]; x = *ap; printf("%d",x); return 0; } When I compile and run the c...

Exact time measurement for performance testing

What is the most exact way of seeing how long something, for example a method call, took in code? The easiest and quickest I would guess is this: DateTime start = DateTime.Now; { // Do some work } TimeSpan timeItTook = DateTime.Now - start; B...

Cannot access a disposed object - How to fix?

In a VB.NET WinForms project, I get an exception Cannot access a disposed of object when closing a form. It occurs very rarely and I cannot recreate it on demand. The stack trace looks like this: Cannot access a disposed object. Object name: '...

Using Vim's tabs like buffers

I have looked at the ability to use tabs in Vim (with :tabe, :tabnew, etc.) as a replacement for my current practice of having many files open in the same window in hidden buffers. I would like every distinct file that I have open to always be in it...

What's a good way to extend Error in JavaScript?

I want to throw some things in my JS code and I want them to be instanceof Error, but I also want to have them be something else. In Python, typically, one would subclass Exception. What's the appropriate thing to do in JS?...

DB2 SQL error: SQLCODE: -206, SQLSTATE: 42703

I am getting this JDBC exception. I googled it but the explanation was very abstract. DB2 SQL error: SQLCODE: -206, SQLSTATE: 42703 com.misys.liq.jsqlaccess.adapter.jdbcadapter.util.JDBCAdapterException: com.ibm.db2.jcc.a.SqlException: DB2 SQL erro...

Code signing is required for product type 'Application' in SDK 'iOS5.1'

I am using xCode 4.3.1. After i created a project, i build it and tried to Archive. Then i got an error saying; (This is my first project in xCode 4.3.1) CodeSign error: code signing is required for product type 'Application' in SDK 'iOS5.1' ...

Angular 2: Can't bind to 'ngModel' since it isn't a known property of 'input'

I'm trying to implement Dynamic Forms in Angular 2. I've added additional functionalities like Delete and Cancel to the dynamic forms. I've followed this documentation: https://angular.io/docs/ts/latest/cookbook/dynamic-form.html I've made some ...

How to pass a type as a method parameter in Java

In Java, how can you pass a type as a parameter (or declare as a variable)? I don't want to pass an instance of the type but the type itself (eg. int, String, etc). In C#, I can do this: private void foo(Type t) { if (t == typeof(String)) { ...

Check if string contains only whitespace

How can I test if a string contains only whitespace? Example strings: " " (space, space, space) " \t \n " (space, tab, space, newline, space) "\n\n\n\t\n" (newline, newline, newline, tab, newline) ...

Indentation shortcuts in Visual Studio

I'm new to Visual Studio 2010 and C#. How can I indent the selected text to left/right by using shortcuts? In the Delphi IDE the equivalents are Ctrl+Shift+I and Ctrl+Shift+U...

React - Preventing Form Submission

I've been experimenting with React. In my experiement, I'm using the Reactstrap framework.When I click a button, I've noticed that the HTML form submits. Is there a way to prevent form submission when a button is clicked? I've recreated my issue he...

Python "SyntaxError: Non-ASCII character '\xe2' in file"

I am writing some python code and I am receiving the error message as in the title, from searching this has to do with the character set. Here is the line that causes the error hc = HealthCheck("instance_health", interval=15, target808="HTTP:8080/...

Hash string in c#

I have a problem when trying get a hash string in c#. I already tried a few websites, but most of them are using files to get the hash. Others that are for strings are a bit too complex. I found examples for Windows authentication for web like this:...

How to insert values into the database table using VBA in MS access

I've started to use access recently. I am trying to insert a few rows into the database; however, I am stuck as it is throwing an error: Too few parameters. I have a table test with only one column in it named start_date I want to insert all t...

How do I handle newlines in JSON?

I've generated some JSON and I'm trying to pull it into an object in JavaScript. I keep getting errors. Here's what I have: var data = '{"count" : 1, "stack" : "sometext\n\n"}'; var dataObj = eval('('+data+')'); This gives me an error: untermina...

Converting a float to a string without rounding it

I'm making a program that, for reasons not needed to be explained, requires a float to be converted into a string to be counted with len(). However, str(float(x)) results in x being rounded when converted to a string, which throws the entire thing of...

Disable elastic scrolling in Safari

I just wanted to diable the elastic scrolling/bounce effect in Safari (OSX Lion). I found the solution to set overflow: hidden for body in css, but as expected it only disables the scrollbar, so if the website is "longer" than the screen you won't b...

How to "grep" for a filename instead of the contents of a file?

grep is used to search within a file to see if any line matches a given regular expression. However, I have this situation - I want to write a regular expression that will match the filename itself (and not the contents of the file). I will run this ...

Install .ipa to iPad with or without iTunes

I have the .ipa from PhoneGap build and I need to test it. I got provisioning profile from Developer account. So my question is: can I directly put my .ipa to iPad to install for testing, or do I have to follow some rules to install?...

How to handle static content in Spring MVC?

I am developing a webapp using Spring MVC 3 and have the DispatcherServlet catching all requests to '/' like so (web.xml): <servlet> <servlet-name>app</servlet-name> <servlet-class>org.springframework.web.servlet.Di...

How can I display a pdf document into a Webview?

I want to display pdf contents on webview. Here is my code: WebView webview = new WebView(this); setContentView(webview); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl("http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_paramete...

Built in Python hash() function

Windows XP, Python 2.5: hash('http://stackoverflow.com') Result: 1934711907 Google App Engine (http://shell.appspot.com/): hash('http://stackoverflow.com') Result: -5768830964305142685 Why is that? How can I have a hash function that will give ...

How do I clone into a non-empty directory?

I have directory A with files matching directory B. Directory A may have other needed files. Directory B is a git repo. I want to clone directory B to directory A but git-clone won't allow me to since the directory is non-empty. I was hoping it wou...

Xcode 7 error: "Missing iOS Distribution signing identity for ..."

I tried to upload my App to iTunes Connect resp. AppStore and got the following error: Failed to locate or generate matching signing assets Xcode attempted to locate or generate matching signing assets and failed to do so because of the foll...

Random float number generation

How do I generate random floats in C++? I thought I could take the integer rand and divide it by something, would that be adequate enough?...

How to initialize log4j properly?

After adding log4j to my application I get the following output every time I execute my application: log4j:WARN No appenders could be found for logger (slideselector.facedata.FaceDataParser). log4j:WARN Please initialize the log4j system properly. ...

How do I auto-resize an image to fit a 'div' container?

How do you auto-resize a large image so that it will fit into a smaller width div container whilst maintaining its width:height ratio? Example: stackoverflow.com - when an image is inserted onto the editor panel and the image is too large to fit o...

Changing image size in Markdown

I just got started with Markdown. I love it, but there is one thing bugging me: How can I change the size of an image using Markdown? The documentation only gives the following suggestion for an image: ![drawing](drawing.jpg) If it is possible I...

Spring JDBC Template for calling Stored Procedures

What is the correct way to invoke stored procedures using modern day (circa 2012) Spring JDBC Template? Say, I have a stored procedure that declares both IN and OUT parameters, something like this: mypkg.doSomething( id OUT int, name IN Str...

How to use ADB Shell when Multiple Devices are connected? Fails with "error: more than one device and emulator"

$ adb --help -s SERIAL use device with given serial (overrides $ANDROID_SERIAL) $ adb devices List of devices attached emulator-5554 device 7f1c864e device $ adb shell -s 7f1c864e error: more than one device and emulator ...

Check if not nil and not empty in Rails shortcut?

I have a show page for my Users and each attribute should only be visible on that page, if it is not nil and not an empty string. Below I have my controller and it is quite annoying having to write the same line of code @user.city != nil && @...

How should I copy Strings in Java?

String s = "hello"; String backup_of_s = s; s = "bye"; At this point, the backup variable still contains the original value "hello" (this is because of String's immutability right?). But is it really safe to copy Strings with this meth...

how to show lines in common (reverse diff)?

I have a series of text files for which I'd like to know the lines in common rather than the lines which are different between them. Command line unix or windows is fine. foo: linux-vdso.so.1 => (0x00007fffccffe000) libvlc.so.2 => /usr/lib/l...

JavaScript: Create and save file

I have data that I want to write to a file, and open a file dialog for the user to choose where to save the file. It would be great if it worked in all browsers, but it has to work in Chrome. I want to do this all client-side. Basically I want to ...

Difference between Node object and Element object?

I am totally confused between Node object and Element object. document.getElementById() returns Element object while document.getElementsByClassName() returns NodeList object(Collection of Elements or Nodes?) If a div is an Element Object then what ...

Oracle 11g Express Edition for Windows 64bit?

I registered on http://Oracle.com in order to download 11g R2 Express edition database. But http://Oracle.com offered me download links only for Windows 32bit and for Linux 64bit. Is there somewhere 64bit Windows version of Oracle 11g XE database? ...

Optimum way to compare strings in JavaScript?

I am trying to optimize a function which does binary search of strings in JavaScript. Binary search requires you to know whether the key is == the pivot or < the pivot. But this requires two string comparisons in JavaScript, unlike in C like lan...

Scraping: SSL: CERTIFICATE_VERIFY_FAILED error for http://en.wikipedia.org

I'm practicing the code from 'Web Scraping with Python', and I keep having this certificate problem: from urllib.request import urlopen from bs4 import BeautifulSoup import re pages = set() def getLinks(pageUrl): global pages html = urlop...

Order of execution of tests in TestNG

How to customize the order of execution of tests in TestNG? For example: public class Test1 { @Test public void test1() { System.out.println("test1"); } @Test public void test2() { System.out.println("test2"); } @Test ...

How to pass variables from one php page to another without form?

I want to know how to pass a variable from one page to another in PHP without any form. What I want to achieve is this: The user clicks on a link A variable is passed which contains a string. The variable can be accessed on the other page so that ...

Troubleshooting misplaced .git directory (nothing to commit)

I started getting this message. No matter what I edit and try to commit, it says there is nothing to commit. Looks like git does not see my working directory and looking somewhere else. If I run git status it outputs the same: nothing to commit (w...

regex match any single character (one character only)

How do you match any one character with a regular expression? I am writing this question and the following answer for a general reference. A number of other questions on Stack Overflow sound like they promise a quick answer, but are actually asking ...

What is a callback in java

Possible Duplicate: What is a callback function? I have read the wikipedia definition of a callback but I still didn't get it. Can anyone explain me what a callback is, especially the following line In computer programming, a callback...

Draw on HTML5 Canvas using a mouse

I want to draw on a HTML Canvas using a mouse (for example, draw a signature, draw a name, ...) How would I go about implementing this?...

Foreach with JSONArray and JSONObject

I'm using org.json.simple.JSONArray and org.json.simple.JSONObject. I know that these two classes JSONArray and JSONObject are incompatible, but still I want to do quite a natural thing - I want to for-each over JSONArray parsing at each iteration st...

How does delete[] know it's an array?

Alright, I think we all agree that what happens with the following code is undefined, depending on what is passed, void deleteForMe(int* pointer) { delete[] pointer; } The pointer could be all sorts of different things, and so performing an u...

IntelliJ, can't start simple web application: Unable to ping server at localhost:1099

I'm trying to make a simple web app in IntelliJ by following this tutorial: http://wiki.jetbrains.net/intellij/Creating_a_simple_Web_application_for_Tomcat_in_IntelliJ_IDEA_12 I believe my Tomcat is installed correctly since I see the tomcat picture...

Batch Files - Error Handling

I'm currently writing my first batch file for deploying an asp.net solution. I've been Googling a bit for a general error handling approach and can't find anything really useful. Basically if any thing goes wrong I want to stop and print out what we...

How to run TypeScript files from command line?

I'm having a surprisingly hard time finding an answer to this. With plain Node.JS, you can run any js file with node path/to/file.js, with CoffeeScript it's coffee hello.coffee and ES6 has babel-node hello.js. How do I do the same with Typescript? M...

JCheckbox - ActionListener and ItemListener?

Both ActionListener and ItemListener are used to fire an event with JCheckBox? So, what's the difference between them and in which case one of them is preferred to the other?...

how to clear localstorage,sessionStorage and cookies in javascript? and then retrieve?

How to completely clear localstorage, sessionStorage and cookies in javascript ? Is there any way one can get these values back after clearing them ?...

How to make a view with rounded corners?

I am trying to make a view in android with rounded edges. The solution I found so far is to define a shape with rounded corners and use it as the background of that view. Here is what I did, define a drawable as given below: <padding andr...

How do I install the ext-curl extension with PHP 7?

I've installed PHP 7 using this repo, but when I try to run composer install, it's giving this error: [package] requires ext-curl * -> the requested PHP extension curl is missing from your system. With PHP 5, you can easily install it by ...

How to break out or exit a method in Java?

The keyword break in Java can be used for breaking out of a loop or switch statement. Is there anything which can be used to break from a method?...

Open URL in new window with JavaScript

I'm making a "share button" to share the current page. I would like to take the current page URL and open it in a new window. I have the current URL part working, but can't seem to get the next part working. I'm struggling with the syntax. I would ...

Typescript Date Type?

How do I express dates in TypeScript? Dates aren't a TypeScript type, so do I use any or object? Seems like there would be a "right" way to do: let myDate: any = new Date(); I couldn't find much on Google, despite it being such a simple question....

How do you do a ‘Pause’ with PowerShell 2.0?

OK, I'm losing it. PowerShell is annoying me. I'd like a pause dialog to appear, and it won't. PS W:\>>> $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") Exception calling "ReadKey" with "1" argument(s): "The method or operation is not imple...

mat-form-field must contain a MatFormFieldControl

We are trying to build our own form-field-Components at our Company. We are trying to wrap material design's Components like this: field: <mat-form-field> <ng-content></ng-content> <mat-hint align="start"><strong&...

codes for ADD,EDIT,DELETE,SEARCH in vb2010

I'm currently working on my thesis in school and they required me to use VB2010 and MS ACCESS 2010. what could be the easier way to connect and manipulate the DB? is it by using MS ACCESS 2003? or MS ACCESS 2007? I need some help because I'm new ...

Is there a keyboard shortcut (hotkey) to open Terminal in macOS?

One of my primary tools used for programming is my Terminal. It makes my programming process more efficient when I'm able to quickly open a Terminal window. In Ubuntu, I was using (window+Alt+T) to open Terminal. But now I use a Macbook at my progra...

ArrayList initialization equivalent to array initialization

I am aware that you can initialize an array during instantiation as follows: String[] names = new String[] {"Ryan", "Julie", "Bob"}; Is there a way to do the same thing with an ArrayList? Or must I add the contents individually with array.add()?...

The resource could not be loaded because the App Transport Security policy requires the use of a secure connection

I am facing the Problem when I have updated my Xcode to 7.0 or iOS 9.0. Somehow it started giving me the Titled error "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection" Webserv...

How to set the background image of a html 5 canvas to .png image

I would like to know how it is possible to set the background image of a canvas to a .png file. I do not want to add the image in the back of the canvas and make the canvas transparent. I want the user to be able to actually draw on that canvas wit...

Failed to load resource: the server responded with a status of 500 (Internal Server Error) in Bind function

I'm trying to send a call using Ajax but in Chrome it is rising error but in Firefox there is no error. But still it can't calling the method. I tried to record my call in Firebug but there is no call request in Firebug. So that's the reason there is...

How can I get the first two digits of a number?

I want to check the first two digits of a number in Python. Something like this: for i in range(1000): if(first two digits of i == 15): print("15") elif(first two digits of i == 16): print("16") Is there a command to chec...

Initialising mock objects - MockIto

There are many ways to initialize a mock object using MockIto. What is best way among these ? 1. public class SampleBaseTestCase { @Before public void initMocks() { MockitoAnnotations.initMocks(this); } @RunWith(MockitoJUnitRunner....

Differences between git pull origin master & git pull origin/master

What is the difference between git pull origin master and git pull origin/master ?...

Cropping an UIImage

I've got some code that resizes an image so I can get a scaled chunk of the center of the image - I use this to take a UIImage and return a small, square representation of an image, similar to what's seen in the album view of the Photos app. (I know ...

Why would a "java.net.ConnectException: Connection timed out" exception occur when URL is up?

I'm getting a ConnectException: Connection timed out with some frequency from my code. The URL I am trying to hit is up. The same code works for some users, but not others. It seems like once one user starts to get this exception they continue to ...

How can I dynamically add items to a Java array?

In PHP, you can dynamically add elements to arrays by the following: $x = new Array(); $x[] = 1; $x[] = 2; After this, $x would be an array like this: {1,2}. Is there a way to do something similar in Java?...

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

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

htons() function in socket programing

I am new to socket programming and I am trying to understand the operation of htons(). I've read a few tutorials on the Internet like this and this one for instance. But I couldn't understand what htons() does exactly. I tried the following code: #...

Maven and adding JARs to system scope

I have a JAR in my Android project and I want it to be added to final APK. Okay, here I go: <dependency> <groupId>com.loopj.android.http</groupId> <artifactId>android-async-http</artifactId> ...

How can I stop "property does not exist on type JQuery" syntax errors when using Typescript?

I am only using one line of jQuery in my application: $("div.printArea").printArea(); But this is giving me a Typescript error: The property 'printArea' does not exist on type JQuery? Can someone tell me how I can stop this error appearing?...

height: calc(100%) not working correctly in CSS

I have a div that I want to fill the whole height of the body less a set number in pixels. But I can't get height: calc(100% - 50px) to work. The reason I want to do this is I have elements that have dynamic heights based on some varying criteria, ...

Error: " 'dict' object has no attribute 'iteritems' "

I'm trying to use NetworkX to read a Shapefile and use the function write_shp() to generate the Shapefiles that will contain the nodes and edges, but when I try to run the code it gives me the following error: Traceback (most recent call last): Fi...

rsync copy over only certain types of files using include option

I use the following bash script to copy only files of certain extension(in this case *.sh), however it still copies over all the files. what's wrong? from=$1 to=$2 rsync -zarv --include="*.sh" $from $to ...

Add column to dataframe with constant value

I have an existing dataframe which I need to add an additional column to which will contain the same value for every row. Existing df: Date, Open, High, Low, Close 01-01-2015, 565, 600, 400, 450 New df: Name, Date, Open, High, Low, Close abc, 01...

NumPy array is not JSON serializable

After creating a NumPy array, and saving it as a Django context variable, I receive the following error when loading the webpage: array([ 0, 239, 479, 717, 952, 1192, 1432, 1667], dtype=int64) is not JSON serializable What does this mean?...