Code CODE code Code code Code Code if Code Good Code else No Code More Code Code ...
@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 } }