Catching ball – finding the maximum number of caught balls

I’m attempting to solve the following problem:

Balls are falling from the sky. We know at which location (on a straight line) will each ball drop, and we know the time (in seconds) at which will the ball reach the ground. We are trying to catch them into a ball net, which we can move left or right, but each movement costs 1 second. The initial position of a ballnet is always on the left (position 0). We are allowed to > drop (not catch) $ k$ number of balls.

What is the highest score we can achieve?

My first attempt at solving this was a greedy algorithm:

if the |next ball position - current position of the ball net| > (time of the next ball - current time)       then attempts++      if attempts>$  k$              print game over else      current ball net position = next ball position      current time = time of the next ball      score++ 

however my algorithm doesn’t take into consideration that sometimes it’s better to sacrifice some number of balls in order to reach a higher score in the long run. This needs an approach via dynamic programming, I think.

Is this problem a known one so I can find some help? Could you help me with this problem? I can solve this in a greedy way, however I am failing to do it dynamically.


What to do if caught in a Red Team engagement?

I’ve seen a lot of people talk about how to pentest and how NOT to get caught during engagements but have a hard time finding “How to behave when caught during a Red Team engagement”.

Red Teams are to simulate adversaries attacking systems. Many actions can’t be done (or at least very hard to) with just some computers and Red Teams often have to go on site and break in (legally). What I’ve seen so far is people succeeding in not getting caught. However, I haven’t seen anyone talk about what to do when caught. It may just be some suspicion or even being chased by security (possibly armed).

In cases wear a Red Teamer is caught during an engagement, what should he/she do?

  • Say “I’m a security tester. You’ve caught me so I’ll just leave.”
  • Run away like a criminal with their stolen data (which sounds fun but dangerous) to be more like an actual criminal attacker
  • Contact the employer to report it and get a “just continue” pass
  • Quietly come along for some possible interrogation (I think this would be the safest)

Is there any way to use a nulled Vbulletin (4 or 5) without getting caught?

Just to make this clear, I already purchased Vbulletin, so I'm not trying to do this myself. If you're involved with Vbulletin in any way, though, you're probably going to hear about it being nulled. I'm just interested in this topic because I hear some people saying it's completely possible to get away with a nulled version without being caught, while others say it's absolutely impossible.

With that being said, I know Vbulletin is very strict, and they do their best to catch and terminate…

Is there any way to use a nulled Vbulletin (4 or 5) without getting caught?

Getting caught in loops with LSTM

I recently implemented a name generating RNN “from scratch” which was doing ok but far from perfect. So I thought about trying my luck with pytorch’s LSTM class to see if it makes a difference. Indeed it does and the outpus looks way better for the first 7 ~ 8 characters. But then the networks gets caught in a loop and outputs things like “laulaulaulau” or “rourourourou” (it is supposed the generate french names).

Is it a often occuring problem ? If so do you know a way to fix it ? I’m concern about the fact the network doesn’t produce EOS tokens…

here is the model :

class pytorchLSTM(nn.Module):     def __init__(self,input_size,hidden_size):         super(pytorchLSTM,self).__init__()         self.input_size = input_size         self.hidden_size = hidden_size         self.lstm = nn.LSTM(input_size, hidden_size)         self.output_layer = nn.Linear(hidden_size,input_size)         self.tanh = nn.Tanh()         self.softmax = nn.LogSoftmax(dim = 2)      def forward(self, input, hidden)             out, hidden = self.lstm(input,hidden)             out = self.tanh(out)             out = self.output_layer(out)             out = self.softmax(out)         return out, hidden 

The input and target are two sequences of one-hot encoded vectors respectively with a start of sequence and end of sequence vector at the start and the end. They represent the characters inside of a name taken from the name list.

training loop :

 def train_lstm(model):     start = time.time()     criterion = nn.NLLLoss()     optimizer = torch.optim.Adam(model.parameters())     n_iters = 20000     print_every = 1000     plot_every = 500     all_losses = []     total_loss = 0     for iter in range(1,n_iters+1):         line = randomChoice(category_line)         input_line_tensor = inputTensor(line)         target_line_tensor = targetTensor(line).unsqueeze(-1)         optimizer.zero_grad()                loss = 0         output, hidden = model(input_line_tensor)         for i in range(input_line_tensor.size(0)):             l = criterion(output[i], target_line_tensor[i])             loss += l         loss.backward()         optimizer.step()  

the sampling function :

def sample():     max_length = 20     input = torch.zeros(1,1,n_letters)     input[0][0][n_letters - 2] = 1     output_name = ""     hidden = (torch.zeros(2,1,lstm.hidden_size),torch.zeros(2,1,lstm.hidden_size))       for i in range(max_length):         output, hidden = lstm(input)         output = output[-1][:][:]         l = torch.multinomial(torch.exp(output[0]),num_samples = 1).item()         if l == n_letters - 1:             break         else:             letter = all_letters[l]             output_name += letter         input = inputTensor(letter)     return output_name 

The typical sampled output looks something like that :

Laurayeerauerararauo Leayealouododauodouo Courouauurourourodau 

Do you know how I can improve that ?

Situation where an exception can’t be caught in Django view

I’m quite happy with this delete view:

def price_unit_delete(request, pk):     pu = PriceUnit.objects.get(pk=pk)     template = 'includes/modal/modal_form.html'     if request.POST:         pu.delete()         template = 'dashboard_staff/settings/includes/priceunits.html'     ctx = {'action': reverse("dashboard_staff:settings_delete_priceunit", args=(, )),            'title': 'do you ?',            'form': PriceUnitDeleteForm(),            'priceunits': PriceUnit.objects.all()}     return TemplateResponse(request, template, ctx) 

Sometimes you can’t delete an item which is referenced somewhere else as a foreign key and it fails. I thought to catch this integrity error (firstly raised by psycopg2 and secondly by django.db itself) using a try block.

Effectively you can do in python console:

# in case of ```o``` being referenced somewhere else, returns False def delete(o):    try:        o.delete()    except:        return False 

I naively thought to include such a block in the view like this:

    if request.POST:         try:             pu.delete()         except:             return JsonResponse({'data': _(                 "You can't delete this object as it is used somewhere else."             )}, status=400) 

And in this case the exception is not caught. I wrote this view as a CBV as well, it fails to catch the exception too.

If I type a assert False in the try, it works fine. Is there a reason why it doesn’t work in case of Integrity exception?

JSF1073: java.lang.NullPointerException caught during processing of RENDER_RESPONSE 6 : UIComponent-ClientId=, Message=null

Please help we have encountered an error on our application base from the logs are below and we do not have any idea where to start searching that error due to the message from the line in the logs is = null. ( please see below error logs).

configuration: tomcat7 java 7 running on 64bit linux 1.2.0

********************* { CALL cc_get_system_settings(?) } org.icefaces.impl.application.ExtendedExceptionHandler handle WARNING: queued exception java.lang.NullPointerException

com.sun.faces.context.ExceptionHandlerImpl log FATAL: JSF1073: java.lang.NullPointerException caught during processing of RENDER_RESPONSE 6 : UIComponent-ClientId=, Message=null com.sun.faces.context.ExceptionHandlerImpl log FATAL: No associated message java.lang.NullPointerException

User session has expired! User session has expired! User session has expired! User session has expired! User session has expired!

Caught with illegal software on office PC [on hold]

Our Antivirus software caught illegal exe file from my office PC. What ste the possible actions from my organization, if the illegal exe was installed during non working ours? Will I get a note from my employer, what are possible consequences? I was contacted by my security office that my PC will be contained and it’s already enlisted for a clean wipe/reinstall? This is my first offence, will they be any other action? Does anyone has any experience with such situation?