w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘
Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType);

Categories : Asp Net Mvc

Unable to open Alfresco admin-consle.jsp
Are you trying to navigate to the Admin console in Alfresco Explorer by hitting the JSP directly? Pretty sure that's not going to work. Instead, click the admin console icon, which is the first icon on the left at the top of the screen that looks like a little DJ console, see below: Do note that the Alfresco Explorer client is quite old and if possible, you should be using Alfresco Share instead. It also includes an admin console.

Categories : Java

overwrite current exe from process
I accomplished this by having a "Restart to update" button in the main application, which performs the following steps: Start the updater with a switch containing the PID of the main process. The main process begins to shut down. The updater finds the process with the given PID and waits for it to exit. The updater overwrites the main application with the new version. The updater starts the main application. The updater shuts down.

Categories : C#

Java SFTP upload using JSch, but how to overwrite the current file?
I've never used JSch but from the looks of it there are a number of overloaded put methods where one matches your current signature with the addition of a "mode" parameter and there seems to be three static mode parameters in the ChannelSftp class (OVERWRITE = 0, RESUME = 1, APPEND = 2) so you should be able to use: channelSftp.put(new FileInputStream(f1), f1.getName(), ChannelSftp.OVERWRITE);

Categories : Java

Cannot overwrite pom maven-surefire-plugin from command line
Using profile can do the trick. It requires you change the pom file though it gives you the behaviour you want. Set a property in project element <properties> <runtests>false</runtests> </properties> Now create a profile <profile> <id>run-tests</id> <properties> <runtests>true</runtests> </properties> </profile> in surefire plugin configuration <skipTests>${runtests}</skipTests> Now run mvn install -P run-tests This command will activate the profile, thus set the runtests property to true

Categories : Java

How can I join (Shift+J) the next N words to current line, instead of the entire line?
How about letting vim handle the formatting of your comment blocks. gqap does one paragraph. If it doesn't do what you want out of the box, check out :help 'fo (format options) and especially :help 'fo-table. For instance, setting :set fo+=j might help with those C blocks (remove comment leader automatically when joining lines.)

Categories : Vim

Shell Script: Overwrite entire line in a text file if a partial match is found
try this sed line: sed '/ABC/s/.*/AAAAAAA/' file example: kent$ echo "ABCdefg hijklmn xxABC"|sed '/ABC/s/.*/AAAAAAA/' AAAAAAA hijklmn AAAAAAA or awk one-liner: awk '/ABC/{$0="AAAAAAA"}7' file test omitted.

Categories : Shell

Python append or overwrite list element
You could use: selector[level:level+1] = [i+1] If selector[level] already exists, this replaces the value. If it does not already exist, it appends the value. For example, In [102]: selector = [] In [103]: selector[0:1] = [100] In [104]: selector Out[104]: [100] In [105]: selector[0:1] = [200] In [106]: selector Out[106]: [200] Notice what happens if the index is beyond the length of selector: In [107]: selector[7:8] = [300] In [108]: selector Out[108]: [200, 300] It does not insert at that index location, it just appends.

Categories : Python

Intellij IDEA: equivalent of Eclipse's "Complete Current Statement" (Ctrl+Shift+Enter)?
Is this Feature present in Eclipse ( at least even as a plugin will be fine ) . I use Ctrl+Shift+enter in IntelliJ a lot . Some of the things it will do are if it is normal statement then it will format the current line and add semicolon ( also the cursor position will be end of the line ) if it is a loop/conditional like for,if etc if -> if ([cursor position]) { } -> if() { [cursor position]} [ -> means ctrl + shift + enter command ] If statement is already completed then it will format the current line and goes to next line indented position. people might think these things are very trivial/not important but only when you try to use this you will find how useful this small feature will be and how much you miss in eclipse .

Categories : Java

Python 3 - Reading line by line from a textfile and doing action for each line
urlFile = "path/to/file" urls = open(urlFile).readLines() for url in urls: doAction(url) OR you could just put it all in the url file reading loop; with open(urlFile) as f: for line in f: doAction(line)

Categories : Python

batch file to overwrite a line in a text file
These links will help you How to replace BatchSubstitute

Categories : File

reading file line by line , modify the line and write this line on same file. Python
Because you've used .split on the line, you're working with a list of strings. While a string is conceptually just a list of characters, it's still not a list of strings. Try using the .join method of a string to join your array before you write it out, for example: ''.join(["one, two"]) == "onetwo"

Categories : Python

echo new line to terminal only when current terminal line is not empty
Test your variable's value if it's not empty with -n: [[ -n $VAR ]] && echo "$VAR" # POSIX or Original sh compatible: [ -n "$VAR" ] && echo "$VAR" # With if: if [[ -n $VAR ]]; then echo "$VAR" fi if [ -n "$VAR" ]; then echo "$VAR" fi It's actually equivalent to [[ $VAR != "" ]] or ! [ "$VAR" = "" ]. Furthermore in Bash you can test it if it's only filled with whitespaces: shopt -s extglob ## Place this somewhere at the start of the script [[ $VAR == +([[:space:]]) ]] && echo "$VAR" if [[ $VAR == +([[:space:]]) ]]; then echo "$VAR" fi Use [[:blank:]] to only match spaces and tabs and not newlines and the likes if it's more helpful. If you want to remove empty lines from input file or pipe you can use other tools like sed: sed -ne '/^$/!p'

Categories : Bash

what is the python equivalent of "new" in C++
My problem is that this append happens by reference and I can't figure out how to initialize newdata to new memoryspace. If you're trying to append objects into a list by value, you might want to use something like copy.copy or copy.deepcopy to make sure what is being appended is copied. >>> # The Problem >>> class ComplexObject: ... def __init__(self, herp, derp): ... self.herp = herp ... self.derp = derp ... >>> obj = ComplexObject(1, 2) >>> list = [] >>> list.append(obj) >>> obj.derp = 5 >>> list[0].derp 5 >>> # obj and list[0] are the same thing in memory >>> obj <__main__.ComplexObject instance at 0x0000000002243D48> >>> list[0] <__main__.ComplexObject instance

Categories : Python

What's the advantage of having multi-line & single-line string literals in python?
The advantage of having to be explicit about creating a multi-line string literal is probably best demonstrated with an example: with open("filename.ext) as f: for line in f: print(line.upper()) Of course, any decent syntax-highlighting editor will catch that, but: It isn't always the case that you're using a syntax-highlighting editor Python has no control over what editor you are using. Two of Python's design principles are that errors should never pass silently, and explicit is better than implicit. Outside docstrings, multi-line strings are rarely used in Python, so the example above is much more likely to occur (everyone mistypes sometimes) than the case where you want a multi-line string, but forgot to explicitly say so by triple-quoting. It's similar to Pyth

Categories : Python

How to read the input(line by line) from a multiline Tkinter Textbox in Python?
From the document, the get method on tkinter.text will just return the string, including the new line . You can not treat the tkinter.text as file, but you can use other ways. Read them all and split them into a list. Loop the list then. def retrieve_input(): text = self.txt.get('1.0', END).splitlines() for line in text: ... Using io.StringIO to emulate a file, but in this case it will not strip the newline. def retrieve_input(): text = io.StringIO(self.txt.get('1.0', END)) for line in text: line = line.rstrip() ...

Categories : Python

Is there an equivalent of the "in" function from Python in C++?
If you are using C++ vectors: if (std::find(vector.begin(), vector.end(), yourItem)!=vector.end() ) .... would be the equivalent of if yourItem in vector:

Categories : C++

GAE - Python equivalent of getRemainingMillis()
Assuming that anything available as a method call would be available in their development system to facilitate offline development, there's no record of anything close in their 1.8.3 Python library. The apiproxy code making RPC calls appears to just set/use plain old socket timers, which doesn't appear to have a "how much longer until my timeout hits" method of any sort. Looks like you might be on your own to implement such a check, but would be an awesome feature request to make to Google, I'd vote it up myself: https://code.google.com/p/googleappengine/issues/

Categories : Python

Is there a Python equivalent for C++ "multiset"?
You can keep a list ordered using the bisect functions. For example find will become def index(a, x): 'Locate the leftmost value exactly equal to x' i = bisect_left(a, x) if i != len(a) and a[i] == x: return i raise ValueError You will find other equivalents in the docs. Instead of checking against end you will now get a ValueError

Categories : C++

equivalent from MATLAB to Python
Matplotlib offers nearly all plotting options Matlab does. Surface plots can be done as well: http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#surface-plots To load images scipy has a PIL-wrapper (no clown included, sorry), which loads matplotlib-compatible numpy arrays. To sum up, you want the following packages: numpy, scipy, matplotlib and PIL. The combination of those four libraries should give you all you need. Also check out the pylab interface of these libraries, as it is very similar to Matlab. Example that does what I believe you want to do: from mpl_toolkits.mplot3d import Axes3D from scipy.misc import imread from matplotlib.pyplot import figure, show from numpy import linspace, meshgrid, sqrt, sin, mean, flipud clown = imread('clown.png') fig = figure() ax = fig.gca

Categories : Python

(gdb) p/x equivalent in gdb python script?
You probably have "set print address" off. I wouldn't do this. It's arguably a bug that the str operator is respecting this setting. There isn't a good way to reproduce "p/x" other than just invoking it directly. See gdb.execute. You can get the value of any field using []. Like val = something['fieldname'] It's usually better, IMO, to use the API rather than parse_and_eval. That is, you can cast, look up fields, etc, directly from Python.

Categories : Python

Python equivalent for a C expression
Python Conditional Expression: From Python 2.5 onwards, the conditional expression - a ? b : c can be written like this: b if a else c So, your expression will be equivalent to: val = 1 if dim == 0 else S(dim) * pow(radius * 0.5, dim) / dim

Categories : Python

Ruby equivalent for python try
begin some_code rescue handle_error ensure this_code_is_always_executed end Details: http://crodrigues.com/try-catch-finally-equivalent-in-ruby/

Categories : Python

Python: Trying to create the equivalent of and(or(value,value,value))
In python, the output of an expression containing BOOLEAN OPERATORS need not be a BOOLEAN (http://docs.python.org/2/library/stdtypes.html) e.g., sysReq1 = ('system requirements' and '?') will make sysReq1='?' and note here that sysReq1 is not a boolean value but a string equalling to QUESTION MARK. Similarly, sysReq2 will also be equal to ? . And also, look for TRUTH VALUE TESTING in the above link as that will explain what values will be considered as FALSE expressions.

Categories : Python

Equivalent expression in Python
Here's the thing... you can't do pointers in python, so what you're showing here is not "portable" in the sense that: float *px, *pz; <-- this doesn't exist int lx = LX; /* constant defined somewhere else */ int lz = LZ; /* constant defined somewhere else */ px = &(table[kx[i]][0][0])+lx; pz = &(table[kz[i]][0][0])+lz; ^ ^ ^ | | | +----+----------------------+---- Therefore none of this makes any sense... What you're trying to do is have a pointer to some offset in your multidimensional array table, because you can't do that in python, you don't want to "port" this code verbatim. Follow the logic beyond this, what are you doing with px and pz? That is the code you need to understand to try and port.

Categories : Python

Is there a python equivalent to Laravel 4?
Yes. Pyramid is what you are looking for. It's written from the ground up to be based in common Python libraries and components, and you can swap out pieces for other pieces as you wish. Python as a language is geared for TDD, and Pyramid takes advantage of that. You can push your own libraries, if they are abstract enough, out to PyPi for yourself, if you wish, but you can of course just keep them within your own projects too. There are other Python frameworks, but if you're looking for modular and extensible, without a whole lot of framework interference in your working style preference, Pyramid is the way to go. P.S. this question is better suited for programmers.stackexchange.com.

Categories : Python

What's the numpy equivalent of python's zip(*)?
Do you actually need to return tuples or do you want to reshape the array? >>> a array([[[ 1, 2], [ 3, 4], [ 5, 6]], [[ 7, 8], [ 9, 10], [11, 12]]]) >>> a.swapaxes(0,1) array([[[ 1, 2], [ 7, 8]], [[ 3, 4], [ 9, 10]], [[ 5, 6], [11, 12]]])

Categories : Python

Python dir() equivalent in JavaScript?
You could use Object.keys(), e.g.: > Object.keys(window) ["top", "window", "location", "external", "chrome", "Intl", "v8Intl", "document", "$", "jQuery", "MSIsPlayback", "i", "prepareEditor", "StackExchange", "scriptSrc", "careers_adurl", "careers_cssurl", "careers_leaderboardcssurl", "careers_companycssurl", "careers_adselector", "_gaq", "_qevents", "jQuery171008060155878774822", "__qc", "quantserve", "uh", "_gat", "gaGlobal", "gauth", "genuwine", "moveScroller", "styleCode", "sanitizeAndSplitTags", "initTagRenderer", "showFadingHelpText", "initFadingHelpText", "profileLink", "EventEmitter", "votesCast", "tagRendererRaw", "tagRenderer", "ytCinema", "IN_GLOBAL_SCOPE", "prettyPrintOne", "prettyPrint", "PR_SHOULD_USE_CONTINUATION", "PR", "Markdown", "apiCallbacks"]

Categories : Javascript

Python list equivalent in C++?
Maybe storing boost::any in a std::vector? http://www.boost.org/doc/libs/1_54_0/doc/html/boost/any.html Here is a simple working example. See James comments below too. #include "../boost_1_54_0/boost/any.hpp" #include <vector> #include <string> #include <iostream> int main() { std::vector<boost::any> myList; myList.push_back(std::string("Hello")); myList.push_back(10); myList.push_back(std::string("World")); std::string any1 = boost::any_cast<std::string> (myList[0]); int any2 = boost::any_cast<int> (myList[1]); std::string any3 = boost::any_cast<std::string> (myList[2]); std::cout<<any1<<" "<<any2<<" "<<any3<<std::endl; return 0; }

Categories : C++

IDL interpol equivalent for python
In your notation, the IDL interp function uses a as the input values, b as input abscissa values and c is the desired abscissa values you want to interpolate onto. In python (for 1D) it would be scipy.interpolate.interp1d: from scipy import interpolate interpfunc = interpolate.interp1d(b,a, kind='linear') x=interpfuc(c) scipy includes many more interpolation functions, including interp2d and griddata that you may find useful: http://docs.scipy.org/doc/scipy/reference/interpolate.html

Categories : Python

Scala equivalent of Python help()
I do not know of one built-in but you should use Scaladocs to find the same information. Unless you use eclipse which has an auto complete with short explanations. For instance it will give you all the commands for arrays after typing 'array.'.

Categories : Python

Dynamically get the current line number
You can create a Throwable and use its StackTraceElements: System.err.println(new Throwable().getStackTrace()[0].getLineNumber()); As @Joachim said, you can also use Thread.getStackTrace(), e.g. like System.err.println(Thread.currentThread().getStackTrace()[1].getLineNumber()); Be aware that the second approach returns a somewhat different array - you need to use the array element with index 1 to get the current line number, since it includes the call to getStackTrace() itself as the first element. Also note the comments about Logging and performance from @Joachim's answer.

Categories : Java

Make tab indent the current line
Not exactly what you need, but you can try Code | Auto-Indent Lines. There is also a known bug about the difference in the selection indent/unindent behavior.

Categories : Intellij Idea

Can python ignore the error and return to the line next to the raised line and going on
You can put the print lines after the try... except statement, and use a second try... except statement for the second except. try: try: 1/0 except ZeroDivisionError: print "It is not a critical error, go to next..." except: print "I have no idea, just stop work..." print "hello world" print "every thing seems fine..." Althrough, in the second except case, if you just want to stop the program you should not catch the exception.

Categories : Python

How to pipe input to python line by line from linux program?
I do not quite understand why you want to use commandline arguments instead of simply reading from standard input. Python has a simple idiom for iterating over lines at stdin: import sys for line in sys.stdin: sys.stdout.write(line) My usage example: $ echo -e "first line second line" | python python_iterate_stdin.py first line second line Your usage example: $ echo "days go by and still" | python python_iterate_stdin.py days go by and still

Categories : Python

How to delete a line from a text file using the line number in python
You start counting at one, but python indices are always zero-based. Start your line count at zero: for num, line in enumerate(myFile): # default is to start at 0 or subtract one from num, deleting from lines (not line): del lines[num - 1] Note that in order for your .readlines() call to return any lines, you need to either re-open the file first, or seek to the start: myFile.seek(0)

Categories : Python

Is there a C# equivalent to python's type() function?
You can try using GetType() method: Type myType = myVariable.GetType(); For instance String typeName = "My String".GetType().Name; // <- "String"

Categories : C#

Is there a Python equivalent of Java's IdentityHashMap?
The purpose of Java's IdentityHashMap is to simulate dynamic field. Since Python language already supports dynamic attributes directly, you don't need the map, just assign Y to an X's attribute x.someSuchRelation = y;

Categories : Java

Is there an equivalent of the python function id() in matlab?
For all handle-like objects the identifier analogue to id() is probably the double-converted value: >> h = uicontrol h = 9.7656e-004 >> handle(h) ans = uicontrol For non-handle type objects such a thing probably doesn't exists, since Matlab usually uses call-by-value instead of call-by-reference. So in general, upon changing a variable's value, there's no guarantee that the underlying object remains the same.

Categories : Python

Python equivalent of Scala's lazy val
Generator expression >>> weights = [(1,2), (2,0), (3, 1)] >>> numNonZero = (k for k, w in weights if w > 0) >>> next(numNonZero) 1 >>> next(numNonZero) 3 >>> next(numNonZero) Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration >>> next(numNonZero, -1) -1 >>> numNonZero = (k for k, w in weights if w > 0) >>> for k in numNonZero: ... print(k) ... 1 3 Python tutorial: Generator expressions

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.