Is there any better approach on this rows to columns table?

enter image description here I pass a function into the variable ($ monthly_receivable) to get the value of each months to pass and get the result of a function.. but the process is dumb slow. This was the only January data but it can add a month range example January 2016 to December 2019.

When I try to remove that variable monthly_receivable it was smooth.

This is my code from server-side to view (client-side):

Controller

public function notes_receivable_summary($  start_date, $  end_date) { $  loans_list = $  this->db->query("SELECT                                  borr_name,                                     co_borrower,                                      released_date,                                      due_from,                                      due_to,                                      pn,                                      no_months,                                      loan_ref,                                      loan_id,                                      pn                                  FROM v_borrowers_nr dd                                 WHERE (df between '$  start_date' AND '$  end_date')                                 ORDER BY loan_ref")->result(); $  months     = $  this->db->query("SELECT dd FROM v_months_nr WHERE dd between '$  start_date' and '$  end_date'")->result();  $  data['monthly_receivable'] = function($  date, $  loan_ref, $  loan_id){         $  enc_url = explode('|', $  this->Main_model->encdec($  this->uri->segment(2), 'd'));         $  s_date  = $  enc_url[1];         $  e_date  = $  enc_url[2];         $  sd      = date('Y-m-d', strtotime('-1 months', strtotime($  s_date)));         $  ed      = $  e_date;    $  q             = $  this->db->query("SELECT * FROM f_monthly_rcvble('$  loan_ref', $  loan_id, '$  start_date', '$  end_date', '$  date')")->row();     return $  q; }; $  this->load->view('pages/ajax/reports/sample_nr', $  data); } 

View

<table id="displayTableNR" class="table displayTableNR js-sort-table">   <?php $  month = array(1=>'Jan', 2=>'Feb', 3=>'Mar', 4=>'Apr', 5=>'May', 6=>'Jun', 7=>'Jul', 8=>'Aug', 9=>'Sep', 10=>'Oct', 11=>'Nov', 12=>'Dec'); ?>   <?php $  total_as_of_h = 0; ?>   <?php $  range_date    = !empty($  months) ? date('M Y', strtotime($  months[0]->dd)) . ' - ' . date('M Y', strtotime($  months[count($  months) - 1]->dd)) : null; ?>   <thead>       <tr class="menu1">           <th class="table-head b-right" scope="col">Ref. No.</th>           <th class="table-head b-right js-sort-string fixed-side" scope="col">Name</th>           <th class="table-head b-right fixed-side" scope="col">Co-Borrower</th>           <th class="table-head b-right fixed-side" scope="col"><div class="wd-132px">Release Date</div></th>           <th class="table-head b-right js-sort-date fixed-side" scope="col">From</th>           <th class="table-head b-right js-sort-date fixed-side" scope="col">To</th>           <th class="table-head b-right fixed-side text-right" scope="col">PN</th>           <th class="table-head fixed-side" scope="col">Terms</th>            <?php $  count = 0; ?>           <?php foreach ($  months as $  row): ?>               <?php $  d = explode('-', $  row->dd); ?>               <th class="table-head text-center font-strong <?php echo $  count % 2 === 0 ? 'hexa-color-1' : 'hexa-color-2'; ?>" colspan="10"><?php echo strtoupper($  month[(int) $  d[1]]) . ' ' . $  d[0]; ?></th>           <?php $  count++; ?>           <?php $  total_as_of_h++; ?>           <?php endforeach; ?>            <?php if ($  total_as_of_h === count($  months)): ?>               <th class="td-head text-center" colspan="3">COLLECTION ACTUAL/CLOSED OB/EFP</th>           <?php endif; ?>       </tr>       <tr class="menu2">           <th class="table-head b-right fixed-side"></th>           <th class="table-head b-right fixed-side"></th>           <th class="table-head b-right fixed-side"></th>           <th class="table-head b-right fixed-side"></th>           <th class="table-head b-right fixed-side"></th>           <th class="table-head b-right fixed-side"></th>           <th class="table-head b-right fixed-side"></th>           <th class="table-head fixed-side"></th>            <?php $  count = 0; ?>           <?php foreach ($  months as $  row): ?>               <th class="table-head font-strong <?php echo $  count % 2 === 0 ? 'hexa-color-1' : 'hexa-color-2'; ?>"><div class="wd-132px text-center">Current Target</div></th>               <th class="table-head font-strong amt_pd <?php echo $  count % 2 === 0 ? 'hexa-color-1' : 'hexa-color-2'; ?>"><div class="wd-132px text-center">Actual Collection</div></th>               <th class="table-head font-strong <?php echo $  count % 2 == 0 ? 'hexa-color-1' : 'hexa-color-2'; ?>"><div class="wd-132px text-center">UA/SP</div></th>               <th class="table-head font-strong <?php echo $  count % 2 == 0 ? 'hexa-color-1' : 'hexa-color-2'; ?>"><div class="wd-132px text-center">Past Due Target UA/SP</div></th>               <th class="table-head font-strong <?php echo $  count % 2 == 0 ? 'hexa-color-1' : 'hexa-color-2'; ?>"><div class="wd-132px text-center">Actual Collection UA/SP</div></th>               <th class="table-head font-strong <?php echo $  count % 2 == 0 ? 'hexa-color-1' : 'hexa-color-2'; ?>"><div class="wd-132px text-center">Past Due Balance UA/SP</div></th>               <th class="table-head font-strong <?php echo $  count % 2 == 0 ? 'hexa-color-1' : 'hexa-color-2'; ?>"><div class="wd-132px text-center">Advanced Payment</div></th>               <th class="table-head font-strong <?php echo $  count % 2 == 0 ? 'hexa-color-1' : 'hexa-color-2'; ?>"><div class="wd-132px text-center">OB Closed</div></th>               <th class="table-head font-strong <?php echo $  count % 2 == 0 ? 'hexa-color-1' : 'hexa-color-2'; ?>"><div class="wd-132px text-center">Early Full Payments</div></th>               <th class="table-head font-strong <?php echo $  count % 2 == 0 ? 'hexa-color-1' : 'hexa-color-2'; ?>"><div class="wd-132px text-center">Adjustments</div></th>           <?php $  count++; ?>           <?php endforeach; ?>            <?php if ($  total_as_of_h === count($  months)): ?>               <th class="table-head">TOTAL</th>               <th class="table-head"><div class="wd-118px text-center">(<?php echo $  range_date; ?>)</div></th>               <th class="table-head">NR BAL</th>           <?php endif; ?>       </tr>   </thead>   <tbody>    <?php $  totAmntToPay             = 0; ?>               <?php $  totCollection            = 0; ?>               <?php $  totBalance               = 0; ?>                <?php foreach($  loans_list as $  r): ?>   <?php $  name   = explode('|', $  r->borr_name); ?>   <tr class="">     <td class="td-border fixed-side"><?php echo $  r->loan_ref; ?></td>     <?php if (count($  name) < 3): ?>       <td class="td-border br-name-nr fixed-side"><div class="wd-210px"><?php echo strtoupper($  name[0]) . ', ' . strtoupper($  name[1]); ?></div></td>     <?php else: ?>       <td class="td-border br-name-nr fixed-side"><div class="wd-210px"><?php echo strtoupper($  name[0]) . ', ' . strtoupper($  name[1]) . ' ' . strtoupper($  name[2]); ?></div></td>     <?php endif; ?>     <td class="td-border fixed-side"><div class="wd-145px"><?php echo strtoupper($  r->co_borrower); ?></div></td>     <td class="td-border fixed-side"><?php echo date('Y-m-d', strtotime($  r->released_date)); ?></td>     <td class="td-border fixed-side"><?php echo date('Y-m-d', strtotime($  r->due_from)); ?></td>     <td class="td-border fixed-side"><?php echo date('Y-m-d', strtotime($  r->due_to)); ?></td>     <td class="td-border text-right fixed-side"><?php echo number_format($  r->pn, 2); ?></td>     <td class="td-border fixed-side"><?php echo number_format($  r->no_months, 0); ?></td>      <!-- TOTALS VARIABLE -->     <?php $  ct1                   = 0; ?>     <?php $  curr_or_prev_uasp     = 0; ?>     <?php $  tot_prev_uasp_balance = 0; ?>      <?php foreach($  months as $  row): ?>     <?php $  lref = $  r->loan_ref; ?>     <?php $  lid  = $  r->loan_id; ?>     <?php $  nr                     = $  monthly_receivable($  row->dd, $  lref, $  lid); ?>       <?php if (is_object($  nr)): ?>         <td class="td-border text-right"><?php echo number_format($  nr->amount_due, 2); ?></td>         <td class="td-border text-right"><?php echo number_format($  nr->actual_collection, 2); ?></td>           <?php if ($  ct1 == 0): ?>             <td class="td-border text-right"></td>           <?php else: ?>               <td class="td-border text-right"><?php echo number_format($  nr->col_ua_sp, 2); ?></td>           <?php endif; ?>         <td class="td-border text-right"><?php echo number_format($  nr->past_due_target_ua_sp, 2); //Past Due Target UA/SP ?></td>         <td class="td-border text-right"><a href="#" class="clrd-tooltip" data-toggle="tooltip" data-placement="right" title=""><?php echo number_format($  nr->past_due_collection_tot_ua_sp, 2); ?></a></td>         <td class="td-border text-right"><?php echo number_format($  nr->past_due_balance, 2); //Past Due Target Balance ?></td>         <td class="td-border text-right"><a href="#" class="clrd-tooltip" data-toggle="tooltip" data-placement="right" title=""><?php echo number_format($  nr->advanced_payment, 2); ?></a></td>         <td class="td-border text-right"><?php echo number_format($  nr->ob_closed, 2); ?></td>         <td class="td-border text-right"><?php echo number_format($  nr->early_full_payments, 2); ?></td>         <td class="td-border text-right"><?php echo number_format($  nr->adjustments, 2); ?></td>       <?php endif; ?>     <!-- TOTALS -->     <?php $  ct1++; ?>      <?php endforeach; ?>     <td class="td-border text-right total-to-pay"><?php echo number_format($  col_tot_pn, 2); ?></td>     <td class="td-border text-right total-coll"><?php echo number_format($  col_tot_col, 2); ?></td>     <td class="td-border text-right total-bal"><?php echo number_format($  col_tot_pn - $  col_tot_col, 2); ?></td>   </tr> </tbody> <tfoot>     <tr>         <th class="table-head b-right fixed-side">Ref. No.</th>         <th class="table-head b-right fixed-side">Name</th>         <th class="table-head b-right fixed-side">Co-Borrower</th>         <th class="table-head b-right fixed-side">Release Date</th>         <th class="table-head b-right fixed-side">From</th>         <th class="table-head b-right fixed-side">To</th>         <th class="table-head b-right text-right fixed-side"><?php echo number_format($  totPN, 2); ?></th>         <th class="table-head fixed-side">Terms</th>          <?php if ($  total_as_of_h === count($  months)): ?>             <td class="table-head text-right"><?php echo number_format($  totAmntToPay, 2); ?></td>             <td class="table-head text-right"><?php echo number_format($  totCollection, 2); ?></td>             <td class="table-head text-right"><?php echo number_format($  totBalance, 2); ?></td>         <?php endif; ?>     </tr>   </tfoot> </table>   

enter image description here

Techniques in becoming a better communicator

I’m looking for advice on mentoring others (or perhaps communication in general).

I’m a newly promoted Senior engineer in my company and I’m managing a new hire for my company. It’s been 2 months, and it’s hasn’t been a fun ride.

I’ve found my relationship with the engineer to be fairly antagonistic. I’m not even sure how to describe this, so here are some notes:

  • He’s confrontational – Whenever I give him opposing feedback in his pull requests, he will very often come over and say “hey, do you want to talk about this?”
  • He’s very resolved – During discussions, he has shown himself to be principled. However, I’ve often disagreed with his decisions and it’s very difficult to convince him that he’s wrong. It’s stressing me out since this happens on a daily basis.
  • He is a bad communicator – English is his second language, and the conversations I have with him have been difficult… He is stoic with his rationalizations, and it is very challenging to change his mind.
  • He is ambitious – I’ve felt that he’s always trying to one-up me. Whenever I speak, he would always try to follow with something.
  • His way is better – When we get into a disagreement and come to an impasse, his resolution has always been “let’s just merge it and see how it goes”. I’ve let this happen a few times.

I understand communication is a two way street. All of the above points can easily be a showcase of how bad of a communicator I’ve been. Here’s what I’ve tried to do so far:

  • Enlist a third-party arbitrator – There was a heated discussion that was going nowhere. I decided to pull in another senior engineer in the company to help give a third opinion.
  • Appeal to convention – It seems he doesn’t value my feedback a lot, so I’ve been feeding him some blog post links during disagreements.

I’m really stressed out. It’s common for our discussions to degrade to arguments, where both sides feel their side is the right side.

What are some techniques I can employ to better the situation?

Daily standup. How to make it better and how to encourage team to embrace it?

For the last two months I’ve been working as a scrum master. I need your help on how to make the daily standup better for all the team members and how to encourage the team to embrace it?

This is the problem: we follow scrum guidelines and limit the daily to 15 minutes, but sometimes we have these issues:

  • Some members feel that they are not heard, therefore, not important

  • Sometimes we go through PBI’s and track it’s progress, but it feels like rapport more than as sync for the team

What my question is, how to make this more as a team sync and less as a team rapport?

I feel that I should remove blockers but I expect from the team to self organize, even when blockers occur, i don’t think that’s only SM’s job. What worries me is that our daily is more work progress status than team sync, that’s my issue.

Can and Should Apache Syncope be Installed and Used without Maven / or a better IAM alternative [on hold]


I’m running Ubuntu 18.04 server on a linode. I need an IAM Solution that will play nice with the other tools I intend to use (namely Vagrant, Jenkins [NOT Maven], and Ansible). I’m asking a compound question:

[a]: Is Syncope really dependent on Maven or am I missing something?
[b]: Is Syncope the best solution for my use case (shown below), and ..
[c]: Asking for suggestions what would be a better alternative (if there is one).


My site is to have primary domain landing page (publicly accessible) and several subdomains –where each subdomain requires authentication. I’m not talking about using apache built in password protection I’m looking for a robust, powerful, production grade solution like one might find in enterprise.

I can’t seem to find much information (other than 2 Apache sources) that talk about installing Syncope at all. Both talk about installing Maven like it isn’t an option. I even attempted to find a way to install from source thinking that might lead to a Maven free Syncope install.

This Link: Shows Maven as a dependency.

Is this really the case or is Apache just aggressively pushing it’s products by bundling them?

If it is either impossible or or just stupid to try to use Syncope without Maven then can someone suggest alternatives that might fit my needs?

Django: Better way to combine these two queries?

I combine two query sets (available_tickets_by_event and sold_tickets_by_event. My end goal is to combine it in ticket_stats_by_event. I wonder if there is a more efficient way to combine these`?

print(available_tickets_by_event)

[{'pk': 4, 'organizer': 1, 'available_tickets': 30}, {'pk': 6, 'organizer': 1, 'available_tickets': 20}, {'pk': 5, 'organizer': 1, 'available_tickets': 10}, {'pk': 1, 'organizer': 1, 'available_tickets': 1721}] 

print(sold_tickets_by_event)

[{'pk': 4, 'organizer': 1, 'sold_tickets': 2}, {'pk': 6, 'organizer': 1, 'sold_tickets': 1}, {'pk': 5, 'organizer': 1, 'sold_tickets': 1}, {'pk': 1, 'organizer': 1, 'sold_tickets': 529}] 

print(ticket_stats_by_event)

{4: {'sold_tickets': 2, 'organizer': 1, 'available_tickets': 30}, 6: {'sold_tickets': 1, 'organizer': 1, 'available_tickets': 20}, 5: {'sold_tickets': 1, 'organizer': 1, 'available_tickets': 10}, 1: {'sold_tickets': 529, 'organizer': 1, 'available_tickets': 1721}} 

Here is the full function:

@property def sold_tickets(self):     return (         Event.objects.filter(organizer__in=self.organizers)         .values('pk', 'organizer')         .annotate(             sold_tickets=Count('attendees', filter=Q(attendees__canceled=False))         )     )  @property def available_tickets(self):     return (         Event.objects.filter(organizer__in=self.organizers)         .values('pk', 'organizer')         .annotate(available_tickets=Coalesce(Sum('tickets__quantity'), 0))     )  def ticket_stats_by_event(self, organizer):     sold_tickets_by_event = [         x for x in self.sold_tickets if x['organizer'] == organizer.pk     ]      available_tickets_by_event = [         x for x in self.available_tickets if x['organizer'] == organizer.pk     ]      ticket_stats_by_event = {         x['pk']: {'sold_tickets': x['sold_tickets']}         for x in sold_tickets_by_event     }      for item in available_tickets_by_event:         pk = item.pop('pk')         ticket_stats_by_event[pk].update(item)      return ticket_stats_by_event 

Explicit bivariate quadratic polynomials where Coppersmith is better than standard solver?

http://www.numbertheory.org/pdfs/general_quadratic_solution.pdf gives a general method to solve quadratic bivariate diophantine equation while Coppersmith introduced a method to solve bivariate polynomials which work provably and have been shown to break $ RSA$ system if half of low significant bits of either $ P$ or $ Q$ are known.

The equation that comes out is $ $ (2^ku+v)(2^ku’+v’)=PQ$ $ where if we assume $ v$ is known. Then $ vv’\equiv PQ\bmod 2^k$ gives $ v’$ .

So we have a quadratic diophantine equation $ $ 2^kuu’+(uv’+u’v)=\frac{PQ-vv’}{2^k}.$ $

Why do I need Coppersmith’s method to solve this? Can’t a regular diophantine solver work here and so are there explicit polynomials where Coppersmith is better than standard solver in bivariate quadratic case?