Quantcast
Channel: User krock - Stack Overflow
Browsing latest articles
Browse All 45 View Live

Comment by krock on MySQL equivalent of DECODE function in Oracle

this only works for boolean expressions, not arbitrary length cases like DECODE() does.

View Article



Comment by krock on Serializing groovy map to string with quotes

.inspect() is extremely helpful for debugging code and pulling example maps out into unit tests. I see many upvotes in your future.

View Article

Comment by krock on Using vagrant to run virtual machines with desktop...

box-cutter don't provide the pre built images any more.

View Article

Comment by krock on Appending a byte[] to the end of another byte[]

@Shashwat in this case, we already know the length of ciphertext and mac byte arrays. That means we know the length of the new byte array should be the combined length of the original 2 byte arrays.

View Article

Comment by krock on Installing python36-devel on rhel7 failing

yum install python36-devel fails on a fresh oracle-linux VM with no existing python installed on the system. Seems to me the yum config got screwed up in the last week with different packages requiring...

View Article


Comment by krock on Gatling-Value baseURL is not a member of...

It looks like baseURL was renamed baseUrl in the gatling libraries at some point (maybe v3). So the case that works will depend on which version of gatling you are using.

View Article

Comment by krock on Openshift CLI - update Application with template and oc...

using oc apply on resources that were created via new-app with a template gives the warning message: "oc apply should be used on resource created by either oc create --save-config or oc apply". This...

View Article

Comment by krock on How to convert DateTime to string using Region Short Date

this seems like a windows only solution

View Article


Comment by krock on Error message: "'chromedriver' executable needs to be...

ChromeDriverManager().install() seems to edit the registry so you need to be a local admin for this to work

View Article


Comment by krock on Getting error with pip search and pip install

the question is basically that pip search is broken now, and what can we do to fix it. Answers show its probably not going to be fixed.

View Article

Comment by krock on Why does CSV file contain a blank line in between each...

this is a python 2 only answer

View Article

Comment by krock on Why the python __builtins__ length changed in debug mode...

what do you see when you use print instead of len? That will give you a hint.

View Article

Comment by krock on how to search a specific string in a xml file and than to...

maybe this question will help: stackoverflow.com/questions/10477294/…

View Article


Comment by krock on Function to replace multiple characters

_str has a length of 5, but the lists are only length of 3 which is why you are going out of range.

View Article

Comment by krock on opening Python script mode on a mac

that is opening the python repl which is a "proper" way to run a python shell. If you don't mean that, what do you mean e.g. IDLE?

View Article


Answer by krock for What is the prerequisite when try to learn the spring or...

In my opinion, the Spring in Action book is a bit behind the times now (Spring 2.0) and doesn't include any of the nifty new features in 2.5 or 3.0. I would start with the spring documentation.

View Article

Answer by krock for Flask web developments passing multiple variables thru...

If you want to get query string parameter values the best way is to do this in your @app.route function. For example, getting the action query string parameter:@app.route('/')def index(): action =...

View Article


Answer by krock for Do I need put " python" infront for the .py if write a...

How to execute a python file without calling "python" directlyIf you want to execute a python file directly set the file to executable (e.g. use chmod +x bot.py) and add a shebang on the first line of...

View Article

Answer by krock for How to ignore last digit and compare two strings using...

The easiest way to ignore the last character in a string is to use slicing, e.g.a[0..-2] == b[0..-2]Use negative numbers in the slice to represent an index from the end.

View Article

Answer by krock for Display time in 24 hour format

Check the date and time patterns table; Month is capital M and minute is lower m. So your date part should look like this: yyyy-MM-dd.The SimpleDateFormat in your code should look like this:new...

View Article

Image may be NSFW.
Clik here to view.

Answer by krock for What is the difference between Collection and List in Java?

Collection is the root interface to the java Collections hierarchy. List is one sub interface which defines an ordered Collection, other sub interfaces are Queue which typically will store elements...

View Article


Answer by krock for Why do I not have to declare "new" inside a generic...

Example 1You declare generic types inside the angle brackets, not construct an instance of an object.For this:error: illegal start of type List<List<Integer> >a =new ArrayList<new...

View Article


Answer by krock for How to extract specific parts of a string JAVA

I'm assuming that the XML fragment in your question is part of a valid XML document. For reading XML you should use an XML parser and not a regular expression.Here is an example of getting that value...

View Article

Answer by krock for Spring MVC / Jackson: Reset objectMapper after completition

You can use the ObjectMapper.copy() to create a new ObjectMapper with the same configuration as the original. Then add your custom MixIns into the new ObjectMapper instance.

View Article

Answer by krock for Is it possible to keep subtracting BigDecimal on every...

The problem is you are creating a new variable x every time.You should be updating the variable amountPending i.e.:amountPending =...

View Article


Answer by krock for Catch exceptions in Python 3 like in C#

From the python documentation on errors you handle errors in python using try/except:>>> while True:... try:... x = int(input("Please enter a number: "))... break... except ValueError:......

View Article

Answer by krock for Designing backend for Mobile app?

This will depend on how your controllers are written.If your controller actions resemble REST like actions you could use spring mvc content negotiation to return html or json depending on the request.

View Article

Answer by krock for Can't run and debug groovy tests under intellij idea

Intellij can automatically add the groovy source as a source directory based on your pom. Add build-helper-maven-plugin config to your maven pom under plugins specifying ${basedir}/src/test/groovy as a...

View Article

Answer by krock for Replace final comma in a string with '&' - Ruby

You can do this using capturing groups around the last comma:>> "one, two, three, four".gsub(/(.*),(.*)/, '\1 &\2')=> "one, two, three & four"These groups will match around the last ,...

View Article



Answer by krock for Find the position of the longest repeated letter

A quick way of achieving this is to use a regex to match repeating characters with (.)(\1+). Then we loop over all those results using a generator comprehension and find the max according to the length...

View Article

Answer by krock for Python: Better way to compare two lists?

You can convert one of the lists to a set and use set.intersection:if not set(List_s).intersection(List_big): print('no common items between lists')Note that the elements in both lists must be hashable.

View Article

Answer by krock for Printing element in array python problems

First of all, change xcoords so that it isn't a list inside a list:xcoords = range(2, 31)We don't need to iterate over a list using an index into the list using len(xcoords). In python we can simply...

View Article

Answer by krock for Javascript: I am having trouble ordering a random string...

You can convert your string into an Array (using split()) and use sort(). Then finally join() your array back into a string:str.split("").sort().join("");

View Article


Answer by krock for Finding Palindromes in Sentences Using Java

To check if a string is a palindrome we need to compare the word reversed and see if they are the same:boolean isPalindrome = word.equals(new StringBuilder(word).reverse().toString());Now that you can...

View Article

Answer by krock for How can a test 'dirty' a spring application context?

Each JUnit test method is assumed to be isolated, that is does not have any side effects that could cause another test method to behave differently. This can be achieved by modifying the state of beans...

View Article

Answer by krock for Java arithmetic int vs. long

When mixing types the int is automatically widened to a long and then the two longs are added to produce the result. The Java Language Specification explains the process for operations containing...

View Article


Image may be NSFW.
Clik here to view.

Answer by krock for C++ corrupt my thinking, how to trust auto garbage...

Turn garbage collection logging on and view the results in GCViewer. This will show you how memory in your app is performing and if enough memory being cleaned up when the garbage collector...

View Article


Image may be NSFW.
Clik here to view.

Answer by krock for Any freeware or open source tool to populate database...

With Jailer you can export data to an SQL script which can traverse foreign key constraints to include all data needed to maintain referential integrity.Here is a screenshot from the Jailer website...

View Article

Image may be NSFW.
Clik here to view.

Answer by krock for Generating getters/setters in Java (again)

That sounds like a lot of work just to generate getter and setter methods. Why not just use eclipses getter and setter generator:(source: eclipse-blog.org)

View Article

Answer by krock for How to exclude older versions of maven dependency and use...

There may be incompatible differences between the version of a library that a dependency requires and the one you want to use. If you are happy to take this risk, you can use maven exclusions to ignore...

View Article

Answer by krock for What is the "volatile" keyword used for?

The volatile keyword has different meanings in both Java and C#.JavaFrom the Java Language Spec :A field may be declared volatile, in which case the Java memory model ensures that all threads see a...

View Article


Answer by krock for How to ping several IP addresses without using the same...

I think you've answered your own question by saying you need 'to iterate'. You should put the ip addresses in a list and iterate over them:ip_addressses = [.....]for ip in ip_addresses:...

View Article

Answer by krock for How do i get the value of an html dropped item in Python?

open up the browser inspection and look at network and you should see what you're posting in the network tab.Forms will post your <input> fields but I can't see any of those in your html code....

View Article


Answer by krock for Explain regular expression in Python

For the regular expression [^aeiouAEIOU]y[^aeiouAEIOU] we can break it down into:[^aeiouAEIOU] - not a vowely - the letter 'y'[^aeiouAEIOU] - not a vowelSpecifically, [aeiou] would be a set of all...

View Article

Answer by krock for What is the meaning of ord in ord() function in Python?

From the python docs for ord()Given a string representing one Unicode character, return an integer representing the Unicode code point of that character... This is the inverse of chr().So ord() will...

View Article

Browsing latest articles
Browse All 45 View Live




Latest Images