Skip to content

Instantly share code, notes, and snippets.

@js1972
js1972 / gist:1823195
Created February 14, 2012 03:25
Test code - comparing receipt-bank receipts with mongo db
require 'bundler'
Bundler.require
# This is a demo program for the receipt-bank.com rest api.
class ReceiptBank
def initialize(u, p)
@js1972
js1972 / CMM_InvoiceReplication_V01_to_ProConInvoiceActivityMessage.xsl
Last active July 20, 2017 06:06
Example #XSLT #PI #mapping working with a SAP #Invoice message
<?xml version="1.0" encoding="UTF-8"?>
<!--
Name: ProCon Invoice Mapping
Author: Chris Mills
Details: Mapping implemented as an XSL as single SAP Invoice message needs to be split to mutliple ProCon messages, 1 per PO
and financials calculated by unique PO. i.e. if invoice has 3 line items which relate to two PO's then need to split to
two output messages and calculate the tax and net amounts by PO, recursion much easier in XSL
NOTE: This will only send items from the invoice that relate to a contract, the business rules are meant to be no multi-contract
invoices and no mix of 1 item against a contract and another not but if it happens ProCon will only see parts of the invoice
@js1972
js1972 / app.js
Created September 5, 2013 04:00
#JavaScript for #html encoding and decoding a value with #jQuery
/*
Use jQuery to html encode a value
*/
function htmlEncode(value){
//create a in-memory div, set its inner text(which jQuery automatically encodes)
//then grab the encoded contents back out. The div never exists on the page.
return $('<div/>').text(value).html();
}
/*
@js1972
js1972 / app.js
Created September 5, 2013 04:54
#JavaScript formatXML will format an xml string with line feeds (pretty printer)
/*
Format a XML string - pretty printer (with line feeds)
*/
function formatXml(xml) {
var formatted = '';
var reg = /(>)(<)(\/*)/g;
xml = xml.replace(reg, '$1\r\n$2$3');
var pad = 0;
jQuery.each(xml.split('\r\n'), function(index, node) {
@js1972
js1972 / app.js
Created September 5, 2013 04:55
#javaScript pad will pad a number with leading zeros
/* function to pad a number with leading zeroes */
function pad(num, size) {
var s = num+"";
while (s.length < size) s = "0" + s;
return s;
}
@js1972
js1972 / app.css
Created September 5, 2013 06:55
#JavaScript to find and highlight text on a page (or in any element)
#all_text span
{
text-decoration:underline;
background-color:yellow;
}
@js1972
js1972 / get_non_ded_tax_po_item.abap
Last active December 22, 2015 23:38
#ABAP code to calculate the #tax from a gross amount. The example here calculates any non-deductible tax from a gross amount. Its used by the ZCL_PURCHASE_ORDER_STATUS class. Interestingly non-deductible tax is added to the amount shown as DELIVERED in the PO status screen (ME23N) which is confusing as the other amount such as PO ordered amount …
method get_non_ded_tax_po_item.
data: tax_code type mwskz,
company_code type bukrs,
currency type waers,
tax_jurisdiction type txjcd,
gross_amount type wrbtr.
select single bukrs waers into (company_code, currency)
from ekko
@js1972
js1972 / IdentityMapWithXSL.java
Created September 24, 2013 06:23
Basic PI Java Mapping to copy the input to the output - identity mapping! #Java #mapping. The JavaMapCopy.java file shows how to copy to the input to the output with an InputStreamReader and a Stringbuffer. The IdentityMapWithXSL.java file includes a buildMessage() method which shows the same thing but with an XML Transformer instead. The benefi…
package au.com.inpex.mapping.lib;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
@js1972
js1972 / hana_sql_server.js
Created November 7, 2013 06:50
Node program to execute SQL query on HANA DB #HANA #JavaScript #Node
/*
Use the HANA Node.js client library to execute a HANA SQL command.
See http://scn.sap.com/docs/DOC-48721?utm_campaign=CRM-XM13-SOC-TW_SCNL &
https://github.com/sap/node-hdb for details.
Example usage:
C:\MyScratchFolder\nodejs>node hana_sql_server.js <username> <password> <schema> "select * from t_persons"
Parameters:
@js1972
js1972 / di-value-injection-warmer
Created January 5, 2014 05:42 — forked from rintcius/di-value-injection-warmer
Example used in the explanation of the "Cake" pattern for dependency injection in Scala.
// =======================
// service interfaces
trait OnOffDevice {
def on: Unit
def off: Unit
}
trait SensorDevice {
def isCoffeePresent: Boolean
}