// How many Items does a Sales Order have...
// ... if we're in the context of a Sales Order record
var itemCount = nlapiGetLineItemCount("item");
// ... or if we've loaded the Sales Order
var order = nlapiLoadRecord("salesorder", 123);
var itemCount = order.getLineItemC...
// Working with Sublists in Standard mode ...
// ... if the record is in context:
// Add item 456 with quantity 10 at the end of the item sublist
var nextIndex = nlapiGetLineItemCount("item") + 1;
nlapiSetLineItemValue("item", "item", nextIndex, 456);
nlapiSetL...
// Adding a line item to the end of a sublist in Dynamic Mode...
// ... if the record is in context:
nlapiSelectNewLineItem("item");
nlapiSetCurrentLineItemValue("item", "item", 456);
nlapiSetCurrentLineItemValue("item", "quantity", 10);
nlapi...
// How many lines in a sublist in SuiteScript 2.0...
require(["N/record"], function (r) {
var rec = r.load({
"type": r.Type.SALES_ORDER,
"id": 123
});
// How many lines are on the Items sublist?
var itemCount = rec.getLineCount...
// Working with a sublist in Standard Mode in SuiteScript 2.0...
require(["N/record"], function (r) {
var rec = r.create({
"type": r.Type.SALES_ORDER,
"isDynamic": false
});
// Set relevant body fields ...
// Add line item 45...
// Working with Sublists in Dynamic Mode in SuiteScript 2.0...
require(["N/record"], function (r) {
var rec = r.create({
"type": r.Type.SALES_ORDER,
"isDynamic": true
});
// Set relevant body fields ...
// Add line item 456 w...
Use Enum.chunk/2 to group elements into sub-lists, and Map.new/2 to convert it into a Map:
[1, 2, 3, 4, 5, 6]
|> Enum.chunk(2)
|> Map.new(fn [k, v] -> {k, v} end)
Would give:
%{1 => 2, 3 => 4, 5 => 6}
DispatchGroup allows for aggregate synchronization of work. You can
use them to submit multiple different work items and track when they
all complete, even though they might run on different queues. This
behavior can be helpful when progress can’t be made until all of the
specified tasks are c...
DispatchSemaphore provides an efficient implementation of a
traditional counting semaphore, which can be used to control access to
a resource across multiple execution contexts.
A scenario for when to use a semaphore could be if you are doing some file reading/writing, if multiple tasks are t...
Swift 3
Serial Queue
func serialQueues () {
let serialQueue = DispatchQueue(label: "com.example.serial") //default queue type is a serial queue
let start = Date ()
for i in 0...3 { //launch a bunch of tasks
serialQueue.a...
Redis allows you to add items to either the right or the left of a list.
If I was working with a list, my_list and I wanted to prepend 3 to the list, I could do that using the Redis LPUSH command:
LPUSH my_list 3
If I wanted to append 3 to my_list, I would instead use the RPUSH command:
RPUSH ...
Redis provides the LPOP and RPOP commands as a counterpart to the LPUSH and RPUSH commands for fetching data items.
If I was working with a list my_list that had several data items in it already, I can get the first item in the list using the LPOP command:
LPOP my_list
The result of this comman...
The size of a Redis list can be deterimed using the LLEN command. If I have a four element list stored at the key my_list, I can get the size using:
LLEN my_list
which will return 4.
If a user specifies a key that doesn't exist to LLEN, it will return a zero, but if a key is used that points t...
Since we have many different algorithms to choose from, when we want to sort an array, we need to know which one will do it's job. So we need some method of measuring algoritm's speed and reliability. That's where Asymptotic analysis kicks in.
Asymptotic analysis is the process of describing the ef...
In the tsconfig.json set
"sourceMap": true,
to generate mappings alongside with js-files from the TypeScript sources using the tsc command.
The launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"type"...
Add ts-node to your TypeScript project:
npm i ts-node
Add a script to your package.json:
"start:debug": "ts-node --inspect=5858 --debug-brk --ignore false index.ts"
The launch.json needs to be configured to use the node2 type and start npm running the start:debug script:
...
create Dynamic web project in sts/eclipse
download the eclipse paho jar from click here to download and paste jar file in webcontent->webinf->folder->lib
Publish Example
String broker = "tcp://localhost:1883";
String topicName = "test/topic";
int qos = 1;
Mqt...
See Ellie for a working example. This example uses the NoRedInk/elm-decode-pipeline module.
Given a list of JSON objects, which themselves contain lists of JSON objects:
[
{
"id": 0,
"name": "Item 1",
"transactions": [
{ "id&quo...