LOGO
Open Computing Ltd - North Point House, North Point Business Park, Old Mallow Road, Cork T23 AT2P - registered in Dublin, Ireland, Reg. no. 597154 VAT ID IE3455711EH

Code

    CODE
    code
    
        Code code
        
Code

    Code
    
        if Code
            Good Code
        else
            No Code
            
    More Code
    
    Code
        ...
CONTACT
@Controller()
public class TheController {

  @Autowired
  TheRepository repo;

  @RequestMapping(value = "/q", produces = "application/json")
  @ResponseBody
  public SResult query(@RequestParam(value = "query", required = true) String query,
      @RequestParam(value = "start", required = false, defaultValue = "1") Integer start) {
    return repo.doQuery(query, start);
  }

}
function query(q) {
    if ( q ) {
        queryString = '/q?query='+q;
        if ( resultCount > 0 )
            queryString += '&start='+(resultCount+1);
        $.ajax({
            url: queryString
        }).then(function(data) {
            if ( data.items ) {
               for ( i = 0; i < data.items.length; i++ ) {
                   display(data.items[i]);
               }
               if (isElementVisible(document.getElementById('visibility'))) {
                   query(q);
               }
            } else {
               $('#visibility').before('<h2>'+data.kind+'</h2>');
            }
        });
    }
}
@Test
public void testMontlySum() {
  for (int i = 0; i < ITERATIONS; i++) {
    Salary s = new Salary(); // CHECKME: use makeSalary instead?
    s.getParams();
    s.getParams().setRateCeiling(SVariables.rateCeilingAmounts[RateCeilingCategory.Single.ordinal()]);
    s.getParams().setTaxCredits(3300.0);
    s.getTotals().setAnnualGrossSalary(TestUtil.randomSalary(10000d, 100000d));
    
    s.calculateFromAnnualGross();
    s.roundTotals();
    s.roundMonths();
    
    Double sumGross = s.getMonths().stream().collect(Collectors.summingDouble(SMonth::getGross));
    assertEquals("Gross sum ", s.getTotals().getAnnualGrossSalary(), Util.round(sumGross));
    Double sumNet = s.getMonths().stream().collect(Collectors.summingDouble(SMonth::getNet));
    assertEquals("Net sum", s.getTotals().getAnnualNetSalary(), Util.round(sumNet));
    Double sumCredit = s.getMonths().stream().collect(Collectors.summingDouble(SMonth::getCredit));
    assertEquals("Credit sum", s.getParams().getTaxCredits(), Util.round(sumCredit));
    Double sumPaye = s.getMonths().stream().collect(Collectors.summingDouble(SMonth::getPaye));
    assertEquals("PAYE sum", s.getTotals().getPayePayable(), Util.round(sumPaye));
    Double sumPrsi = s.getMonths().stream().collect(Collectors.summingDouble(SMonth::getPrsi));
    assertEquals("PRSI sum", s.getTotals().getPrsi(), Util.round(sumPrsi));
    Double sumUsc = s.getMonths().stream().collect(Collectors.summingDouble(SMonth::getUsc));
    assertEquals("USC sum", s.getTotals().getUsc(), Util.round(sumUsc));
  }
}
public void calculateFromAnnualNet() {
  double target = getTotals().getAnnualNetSalary();
  double precision = 0.001d; // this precision usually gets job done in 20-25 iterations
  // good old binary search :)
  double factor = 1;
  double offset = 1;
  for (int i = 1; i < 100; i++) {
    clearTotals();
    double gross = target * (1 + factor);
    offset /= 2;
    getTotals().setAnnualGrossSalary(gross);
    calculateFromAnnualGross();
    double current = getTotals().getAnnualNetSalary();
    if (current > target + precision) {
      factor -= offset;
    } else if (current < target - precision) {
      factor += offset;
    } else {
      // got it!
      break;
    }
  }
}
<screen name="survey">
    <section>
        <actions>
            <set field="leftbarScreenName" value="leftbar"/>
            <set field="rightbarScreenName" value="rightbar"/>
            <set field="MainColumnStyle" value="center"/>
            
            <set field="titleProperty" value="PageTitleAdditionalInfo"/>
        </actions>
        <widgets>
            <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
                <decorator-section name="body">
                    <platform-specific><html><html-template location="component://order/webapp/ordermgr/entry/survey.ftl"/></html></platform-specific>
                </decorator-section>
            </decorator-screen>
        </widgets>
    </section>
</screen>
inline void SoftwareSerial::tunedDelay(uint16_t delay) {
  uint8_t tmp=0;

  asm volatile(
#if CORE == LGT8F
    "nop \n\t"                // 1 cycle
    "nop \n\t"
#endif
    "sbiw    %0, 0x01 \n\t"   // sbiw: avr 2, lgt 1 cycles
    "ldi %1, 0xFF \n\t"       // ldi: avr 2, lgt 1
    "cpi %A0, 0xFF \n\t"      // 1 cycle
    "cpc %B0, %1 \n\t"        // 1
#if CORE == LGT8F
    "brne .-12 \n\t"          // 1/2 cycles
#else
    "brne .-10 \n\t"
#endif
    : "+r" (delay), "+a" (tmp)
    : "0" (delay)
    );
}
<fo:table-cell>
  <fo:block>${uiLabelMap.OrderOrderQuote}:</fo:block>
</fo:table-cell>
<fo:table-cell>
  <fo:block>
	<#list orderItems as item>
		${item.quoteId?if_exists}
		<#break>
	</#list>
  </fo:block>
</fo:table-cell>
invoiceItems.each { invoiceItem ->
    invoiceItem.amount = invoiceItem.getBigDecimal("amount").multiply(conversionRate).setScale(decimals, rounding);
    invoiceItemsConv.add(invoiceItem);
    // get party tax id for VAT taxes: they are required in invoices by EU
    // also create a map with tax grand total amount by VAT tax: it is also required in invoices by UE
    taxRate = invoiceItem.getRelatedOne("TaxAuthorityRateProduct", false);
    if (taxRate && "VAT_TAX".equals(taxRate.taxAuthorityRateTypeId)) {
        taxInfos = EntityUtil.filterByDate(delegator.findByAnd("PartyTaxAuthInfo", 
            [partyId : billingParty.partyId, taxAuthGeoId : taxRate.taxAuthGeoId, taxAuthPartyId : taxRate.taxAuthPartyId],
            null, false), invoice.invoiceDate);
        taxInfo = EntityUtil.getFirst(taxInfos);
        if (taxInfo) {
            context.billingPartyTaxId = taxInfo.partyTaxId;
        }
        vatTaxesByTypeAmount = vatTaxesByType[taxRate.taxAuthorityRateSeqId];
        if (!vatTaxesByTypeAmount) {
            vatTaxesByTypeAmount = 0.0;
        }
        vatTaxesByType.put(taxRate.taxAuthorityRateSeqId, vatTaxesByTypeAmount + invoiceItem.amount);
    }
}
  /* insert file having hardlinks into hardlink hashtable  */
  if ( statp.st_nlink > 1 && type != TN_DIR && type != TN_DIR_NLS ) {
     if ( ! LinkFI ) {
        /* first occurence - file hardlinked to */
        entry = (HL_ENTRY *)tree->root->hardlinks.hash_malloc(sizeof(HL_ENTRY));
        entry->key = (((uint64_t) JobId) << 32) + FileIndex;
        entry->node = node;
        tree->root->hardlinks.insert(entry->key, entry);
#ifdef HARDLINKS_INMEM
     } else {
        /* hardlink to known file index: lookup original file */
        uint64_t file_key = (((uint64_t) JobId) << 32) + LinkFI;
        HL_ENTRY *first_hl = (HL_ENTRY *) tree->root->hardlinks.lookup(file_key);
        if ( first_hl && first_hl->node ) {
           /* then add hardlink entry to linked node*/
           entry = (HL_ENTRY *)tree->root->hardlinks.hash_malloc(sizeof(HL_ENTRY));
           entry->key = (((uint64_t) JobId) << 32) + FileIndex;
           entry->node = first_hl->node;
           tree->root->hardlinks.insert(entry->key, entry);
        }
#endif
     }
  }
Some laws require web sites to put some notifications that you need to acknowledge in order to see what's on the site, so we added some notifications too. They do not serve any real purpose, as far as we can tell, because nobody ever reads them in the first place, not even regulators. I mean, would you really expect some bureaucrat to read what's written over here in small letters? Well maybe, you never know; bureaucracy does all kinds of pointless tasks after all. And not just them! Once I heard about a guy who was tasked with pushing huge boulder up the hill whole day long, only to have it roll down from the top, and then he had to do it all over again. If only he had piezoelectric generator embedded in that boulder, imagine how much energy he could produce... but without it, it was just a waste of time and energy, just as reading this text is. But reading it all the way through requires quite some patience and curiosity, so congratulations are in order.