I have been using this function locally to encrypt strings for example a username.
If the user successfully logged in, place the encrypted username into a session, decrypt the username in the admin section and use for various things.
Is it a strong method and are there any security concerns wi...
@Vogel612 It took me a minute to realize what you were referring to. I wouldn't quite call it an operation. But yeah, everything seems to be going well there.
The question in question (no pun intended): Cutting stock recursion
OP basically dumped the problem definition and a solution on us. There is no indication to if the code actually works, it is homework and there is no indication to what the poster want's help with.
This is something I've strugg...
I'm working on medium sized desktop application (with around 100 tables in database). For persistence layer I decided to use Hibernate for the first time to avoid massive redundancy of code for persistence layer.
This is final implementation of DAO interfaces:
public class BaseDAOImpl<E extends...
One way to solve this is to use a three-step solution.
Collect a Map<String, List<LegacyCommit>> commitsByUsername
Create an empty Map<LegacyUser, List<LegacyCommit>> results
Loop through the Lists in commitsByUsername and for each item, get the first commit from the list, use that as a key and...
@Malachi Well, it more refers to the text that is gone, but I am referring to the "..." or "|||" or whatever you could use to hide those words... It's a hard question :(
UPSey daisy; so we had a little ... incident ...
Pretty sure that has power.
We're past that now, and things are returning to normal. It's only appropriate that we take a moment to think about the folks that got pulled out of bed and worked their knuckles to the bone to get things back up and...
If it is anything like Java, it needs a few bytes of space to set up data structures when building an array, and those few bytes mean the array can never be quite MAX values long, typically 5 short of max.
Of course, it has to Generate the entire range of data, associate each value with another Int (random) value, then sort them by the random value.
Once it has done that, it can then take the first count.
Even though you are selecting 'only' 32 million values, you still have to build a sorted(by random value) data structure containing the 'range' number of values.
I'm writing an application that will use the JLayer library to play an mp3 file. Since the player does not have any methods to pause the playback - play() does not return until the song is finished - I decided to put it in a thread and simply control that thread. This is possible because one can ...
-1 because this code is not compatible with the OP's requirements as is, and would likely not complete successfully with a large range (MIN to MAX value for Int). — rolfl ♦2 hours ago
@JeroenVannevel - in fairness, the alternate solution I propose will start to slow down a lot when the returned value set is very large too (as the number of duplicate strikes increases).
but my performance scales relative to the number of values returned not the range of output results.
and it is O(n) throughout, in space as well as time complexity.
Well, not time complexity for very large result sets.
<T> the type of the input elements
<U> type of elements accepted by downstream collector
<A> intermediate accumulation type of the downstream collector
<R> result type of collector
I want to make a query to order by the IN clause items. I read from another thread that I can use ORDER BY FIELD(a.id, val1,val2......) When binding values to parameters for two occurrences of $in, I ended up using two foreach loops:
foreach ($tid as $t) {
$users->...
Can you somehow prototype the typing as something like <X extends Collector<<Pair<LegacyCommit, String>, LegacyUser, ?, List<LegacyCommit>>> and then use Collectors.<X>mapping( ... ?
Here is the problem:
"Add Click event code for the Switch button: Create string variable spelled. Use rand to calculate a random integer from 1 to 4, inclusive. Use a C# switch statement to set spelled to "one" if the value is 1, "two" if 2, "three" if 3, and "out of range" if 4 appears. Display ...
Unfortunately I cannot accept the answer itself, as I feel like my question has been taken over, because right now it asks for the term for the text that has been replaced, rather than the truncation symbol itself
@SimonAndréForsberg I think I'll just implement equals on all JSON objects and go with the very subtle bugs it can introduce... I don't feel it is entirely correct, but I can live with it.
It would possibly create two entries instead of one if the user changes his email during committing.
This code is supposed to take the list from one function to the other. The list will only come with one element. I am a beginner in Python and need some help.
def main():
#get the integers
high = int(input('Enter the high integer for the range '))
low = int(input('Ente...
@rolfl So... at work, we have a handful of battery backups. It's supposed to be able to power two monitors and two computers for about 15 minutes (depending on the monitors/computers, etc). I want to plug them all together in a big chain with none of them plugged into the wall to see how long they last... no one will let me...
So, the 'phase' of the UPS output on battery is supposed to be close to the phase of the mains power, and just keep going at that approximate rate when there is no mains.
So, one of the UPS systems in the chain will be generating an alternating voltage, that the next one will use as a sync..... it will then get used by the next one in the chain, and so on.
by the time it comes back to the first system, it will think, hey, I am 1millisecon out of phase, let me slow down the output.
I suspect that, in short order, the systems will fail to maintian phase sync within tolerances, and things will start beeping, and cutting out in 'waves'.
i am newbee with Asp.net and C# plz help me , i want 4 color warning status ( Green,Yellow,Orange,Red) that working with Register DateTime in the database , i want to compare that DateTime vs DateTime.now to make a algorithm :
before 7 days = Green , between 7 and 14 = Yellow , between 14 and 21 ...
"Whitespace is significant in Python source code."
> No, not in general. Only the indentation level of your statements is significant (i.e. the whitespace at the very left of your statements). Everywhere else, whitespace is not significant
OK, I guess that myth is refuted then?
Or, rather, whitespace is only significant where it is significant, which is true, I guess, for all languages, so Python is no worse than C, which requires space between things lke variable names and keywords.
My python experience is at least 100 times better than maven
(as in, when I worked with python it did what I expected, when I expected, and worked well, within the constraints of its design, it got the job done. I will even use it again, though not necessarily as my first choice, if I get to make that choice - I cannot say the same about Maven)
The following code is the revised/feedback version of my previous post.
The big change was converting RicCache CLASS object to an INSTANTIATED object.
I'm attempting to master LRU Caching. It must be thread safe, and it should preferably perform as well as web image-cache, (avg ~1MB).
Please t...
Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Lo…
@skiwi That kind of makes sense
Because the algo for cutting the text is really stupid.
I wrote myself a util to break a list into batches of given size. I just wanted to know if there is already any apache commons util for this.
public static <T> List<List<T>> getBatches(List<T> collection,int batchSize){
int i = 0;
List<List<T>> batches = new ArrayList<List<T>>();...
public static final <T> List<List<T>> split(int maxsize, List<T> data) {
List<List<T>> toReturn = new ArrayList<>(data.size() / maxsize + 1);
List<T> current = new ArrayList<>(maxsize);
toReturn.add(current);
for (T d : data) {
if (current.size() == maxsize) {
current = new ArrayList<>(maxsize);
toReturn.add(current);
}
current.add(d);
}
return toReturn;
}
How to setup UPS for redundant power supply if 1st UPS goes down then system should work on 2nd UPS if 2nd goes down then system should work with 1st UPS like server power supply.
public static void main(String[] args) {
List<String> data = Arrays.asList("A", "B", "C");
System.out.println(split(-1, data));
}
Exception in thread "main" java.lang.IllegalArgumentException: Illegal Capacity: -2
at java.util.ArrayList.<init>(ArrayList.java:146)
at ListSplitter.split(ListSplitter.java:9)
at ListSplitter.main(ListSplitter.java:24)
No problem, If I was right all the time ..... and did not have to apologize for misreading things ....
@Pimgd split(0,....) causes:
Exception in thread "main" java.lang.ArithmeticException: / by zero
at ListSplitter.split(ListSplitter.java:9)
at ListSplitter.main(ListSplitter.java:24)
@skiwi - you may want to check for 0 value for split size.
A programmer is in the business of specifying ideas and that requires us to grasp every single detail. Yet our brains are wired to abstract these details. So you think "oh, but that's easy, all you need to do is x, y and z and you're done"and then things go wrong
I'll start with giving a bit of background as there are many classes involved and I can't attach all of them because that would make this question wildly too long. For the curios they can be found at my github repo.
I have an immutable structure called a Chassis which consists of 8 immutable Com...
I was not aware there was such a thing as a formatting standard in SQL, TBH I've seen to many different formatting methods at this point. I started writing KEYWORDS IN ALL CAPS but then quickly got tired of switch CAPS LOCK on and off all the time so I write it in small letters now
I was hacking around this morning and wanting to use automatically generate safe-to-use variables from $_POST. Probably not the best use of extract() and compact(), but extract() allowed me to prefix variable names and compact(explode()) seemed like a neat way to stick everything back into an arr...
OBTW
This program doesn’t do too much and you may be
wondering why it needs such a long comment, well,
it’s to help you understand how multiple line
comments work!
TLDR
HAI 1.2
VISIBLE "O RLY?"
KTHXBYE