How to update a list item from one list to another using a 2010 workflow in SP Designer

1. I hope you know that there exists an ID column in every list which has unique ID for every new item created.

See as follows:

enter image description here

2. Now our task would be as follows for List2:

Create a column in SharePoint List 2(suggestions) to store this item Id from List 1 using a 2010 workflow from SPD. This workflow should run every item a new item is created in List 1. So you will have to update this column in List 2 using a Wrokflow. (only after you created list item in List 2)

Now whenever You wish to update the item in second list, you can use the :

Update List item Action

–> So afterwards we need something from both the lists for using this action( as you mentioned a lookup ) :

enter image description here

–> Here in the screenshot over the bottom, the item id is the column we had created in the 1st step( in List 2) and Current Item:ID is the column from List 1. That means this workflow should run on item change event over the first workflow.

This way both the lists will stay related and associated and based on ID’s you can easily update items in second list. This is similar to foreign key relations in Relational Database, if you are aware about Database concepts.

postgresql – How do I quickly fetch rows based on bits?

I really hope you guys can help me out here. Basically I’m dealing with slow queries due to the sheer amount of possibilities. I’m looking for a better solution or help with the solution I already have in motion.

Background Context:

We have people in our system with role X who’s job is to approve/deny content in table called stories.

We have people in our system with role Y (referred to as owners) who’s job is to look at ONLY approved content from role X and may or may not “claim” the content. However, role Y only see records on platform_story, not the stories themselves. Also there’s a “filter” that whittles out content not relevant to the owners.

We have this concept known as “claiming” content which lives in the claims table. If an owner claims a piece of content, they cannot claim it more than once.

Table Info:

Relationships:

  • stories is one-to-many with platform_story
  • platform_story is one-to-many with claims
  • owners is one-to-many with claims
  • pools is one-to-many with owners
  • pools is one-to-many with stories

The pools is basically a way to reduce the number of owners and content we’re dealing with. Just to give you an idea I wouldn’t see more than 10,000 owners in one pool and no more than 10,000 stories in one pool.

Current total records:

  • claims has about 2.1 million records
  • platform_story has about 147,419 records
  • stories has about 125,000 records
  • owners has about 24,784 records
  • pools has about 125 records

Problem:

The root of the problem is basically the sheer amount of content available to owners combined with the fact that it is CPU intensive (from a non-query, programmer perspective) to determine if a piece of content is relevant to a particular owner.

My first thought was to make a pivot table which cached the relationships between owner’s and platform_story records they are eligible for… but I quickly realized that’s a problem because the table would take up a ton of space.

For example say we made a table called owner_content which had the following columns:

  • owner_id
  • platform_story_id

If it’s omitted from the table, that would basically mean that platform_story isn’t relevant to that owner.

Okay… so let’s say you have 5,000 platform_story records that the software deems relevant for 5,000 owners. Well that’s 5,000 * 5,000 = 25 million rows. And that’s the typical size of ONE pool.

What I’ve done so far:

So I tried to come up with a way to use a VIEW so that the data didn’t need to exist and maybe postgres could whittle down the amount based on other indexes hopefully supplied when querying the view.

I added a column owners.eligible_index and platform_story.eligible_owners.

Then I made a view like so

CREATE VIEW prospects_view AS
SELECT
    o.pool_id AS pool_id,
    o.id AS owner_id,
    s.id AS story_id,
    ps.id AS platform_story_id,
    ps.platform_id AS platform_id
FROM owners o
INNER JOIN stories s ON (
    s.pool_id = o.pool_id
    AND s.deleted_at IS NULL
)
INNER JOIN platform_story ps ON (
    ps.story_id = s.id
    AND substr(ps.eligible_owners, o.eligible_index + 1, 1) = '1'
)
WHERE o.deleted_at IS NULL

You’ll notice ps.eligible_owners is a TEXT type, mostly because the integer columns are not big enough and I didn’t know postgres had binary types. This is a LOT faster than before to find these records, but I was hoping it could be faster if I stored eligible_owners as a binary type.

I dug into postgres docs and found that there is a couple different types: bit(n), bit varying, and bytea. I not sure why you would use one over the other, if there’s any preformance advantages being a limited size for example.

Knowing the structure of my view, what type is the best for my view and why?

plotting – trying to contourplot deviation but it is not giving output or error

I am trying to have contourplots of deviation dc for variables a and b.

In(27):= (Alpha)1(l_, b_, a_, (Theta)_, M_, 
r_) := -(a^2*(1 + l)*(2*M + 2*r + b) + 
  r*(2*r^2 + 3*b*r + b^2 - 2*M*(3*r + b)))/((a*
   Sqrt(1 + l)*(2*M - 2*r - b))*Sin((Theta)))
In(28):= (Beta)1(l_, b_, a_, (Theta)_, M_, r_) := 
 Sqrt((r^2*(8*a^2*(1 + l)*
         M*(2*r + b) - (2*r^2 + 3*b*r + b^2 - 2*M*(3*r + b))^2)/((1 + 
          l)*a^2*(2*M - 2*r - b)^2)) + 
   a^2*Cos((Theta))^2*(1 + l) - (Alpha)1(l, b, a, (Theta), M, r)^2*
    Cos((Theta))^2)
In(29):= re1(l_, b_, a_, (Theta)_, M_) := 
 RankedMax(
  r /. NSolve({(Beta)1(l, b, a, (Theta), M, r) == 0, r > 0}, r, 
    Reals), 1)
In(30):= pr1(l_, b_, a_, (Theta)_, M_) := 
 RankedMax(
  r /. NSolve({(Beta)1(l, b, a, (Theta), M, r) == 0, r > 0}, r, 
    Reals), 2)
In(31):= xc1(l_, b_, a_, (Theta)_, M_) := 
 NIntegrate((Alpha)1(l, b, a, (Theta), M, r)*(Beta)1(l, b, 
     a, (Theta), M, r)*D((Alpha)1(l, b, a, (Theta), M, r), r), {r, 
    pr1(l, b, a, (Theta), M), re1(l, b, a, (Theta), M)})/
  NIntegrate((Beta)1(l, b, a, (Theta), M, r)*
    D((Alpha)1(l, b, a, (Theta), M, r), r), {r, 
    pr1(l, b, a, (Theta), M), re1(l, b, a, (Theta), M)})
In(32):= R(l_, b_, a_, (Theta)_, M_, 
  r_) := ((Alpha)1(l, b, a, (Theta), M, r) - 
     xc1(l, b, a, (Theta), M))*
   D((Beta)1(l, b, a, (Theta), M, r), r) - (Beta)1(l, b, 
    a, (Theta), M, r)*D((Alpha)1(l, b, a, (Theta), M, r), r)
In(33):= raverage(l_, b_, a_, (Theta)_, M_) := 
 Sqrt((1/(Pi))*
   NIntegrate(
    R(l, b, a, (Theta), M, r), {r, re1(l, b, a, (Theta), M), 
     pr1(l, b, a, (Theta), M)}))
In(34):= R1(l_, b_, a_, (Theta)_, M_, 
  r_) := ((Sqrt(((Alpha)1(l, b, a, (Theta), M, r) - 
           xc1(l, b, a, (Theta), M))^2 + (Beta)1(l, b, a, (Theta), 
          M, r)^2) - 
      raverage(l, b, a, (Theta), 
       M))^2)*((((Alpha)1(l, b, a, (Theta), M, r) - 
         xc1(l, b, a, (Theta), M))*
       D((Beta)1(l, b, a, (Theta), M, r), r) - (Beta)1(l, b, 
        a, (Theta), M, r)*
       D((Alpha)1(l, b, a, (Theta), M, r), 
        r))/(((Alpha)1(l, b, a, (Theta), M, r) - 
         xc1(l, b, a, (Theta), M))^2 + (Beta)1(l, b, a, (Theta), M,
         r)^2))
In(41):= dc1(l_, b_, a_, (Theta)_, 
   M_) := (1/raverage(l, b, a, (Theta), M))*
   Sqrt((1/(Pi))*
     NIntegrate(
      R1(l, b, a, (Theta), M, r), {r, re1(l, b, a, (Theta), M), 
       pr1(l, b, a, (Theta), M)}));
In(43):= ContourPlot(
 ConditionalExpression(dc1(0, b, a, 17*(Pi)/180, 1), 
  Im(dc1(0, b, a, 17*(Pi)/180, 1)) == 0), {b, 0, .42^2}, {a, .001, 1})
Out(43)= $Aborted

The code calculates the average radius of a parametric curve and then find the deviation of the curve from circularity in terms of rms value. the last line is not giving any output neither giving any error.

dnd 5e – Can I let a single PC use the Spell Points variant rule without unbalance?

At 5th level, your druid will have the option of creating up to 13 1st-level spell slots, 5 3rd-level spell slots, or some combination between those two extremes. Compare this to a druid of the same level, who may cast 9 spells total, only two of which may be as high as 3rd-level. In this instance, the druid with spell points will have the advantage… though when the regular druid’s spell slots are broken down into points, they’ll have the same value as the number of points a spell point druid would have.

At higher levels, however, the situation alters.

You can use spell points to create one slot each level of 6th or higher. You can’t create another slot of the same level until you finish a long rest.

This particular rule very slightly throttles the power curve of the druid (who would have similar spell slot restrictions until 19th level anyway). That’s not much of a change, but it is worth noting.

So how do higher level druids with and without spell points compare?

10th level: A druid without spell points can cast up to 15 spells a day, up to 2 of them 5th level and the rest evenly distributed among the levels. A druid with spell points can cast up to 9 5th-level spells or 32 1st level spells. Again, point value is identical- the advantage lies in the spell point druid’s ability to effectively convert his lower spell slots into more 5th level slots.

15th level: If you’re running one of the official campaigns, such as Tyranny of Dragons or Princes of the Apocalypse, this is probably as high as you’ll have to worry about. Without spell points, your druid can cast 18 spells- the same as 10th level, plus 1 slot each for 6th, 7th, and 8th-level spells. With spell points, the high end looks identical- one each of the upper three slots, and the same possible combinations as 10th level.

Why are spell points balanced?

Consider three different spellcasting schemes.

  1. Your druid casts as many high-level spells as possible.

  2. Your druid casts as many spells as he can.

  3. Your druid casts spells haphazardly as he needs them.

In the first case, congratulations- you’ve turned your druid into a warlock without the invocations. You’ll be able to cast more spells than a warlock as long as they take only one short rest per day; after that, the warlock is more effective.

In the second case, you will be able to cast a number of spells that dwarfs all others… none of which will be higher than 1st level. This may be handy for a utility caster, but those who wish to control the battlefield or deal damage will be woefully underpowered.

The third case, by what must surely be a strange coincidence, causes you to cast spells in roughly the same amount and power as those without spell points.

Conclusion:

Spell points as a variant would indeed give your druid an advantage, but only in terms of flexibility… and in the long run, your druid will either accept some hefty drawbacks to use that flexibility effectively, or cast spells in a similar spread to your other casters. Either way, your druid can look forward to more bookkeeping to keep track of it all.

Why are some Firefox windows not cycling through the entire list of windows I have open?

I’ve got a bunch of open windows in Firefox and somehow two of them (this one included which is the most recent one I’ve opened) are isolated into their own group. The other 8 or so windows will cycle through when I hit the command-~ key, but this window and the other window in its group never come up and I have to use the mouse and Window menu to select one of those windows. After I select one of the windows in that other group, the command-~ key will cycle through just those two windows and ignores the other 8 windows. Are those different desktop spaces? How can I get all the windows to be in one group?

(I’m talking about browser windows only here. Each window might have any number of tabs in it, but that doesn’t seem to be relevant.)

MacOS Sierra, Firefox 89.0 (64-bit)

java – Rock Paper Scissors with Visitor Pattern

I’ve been going over the Visitor Pattern to try to understand it. Is this a correct implementation of the Visitor Pattern for RPS??

diagram class

Here’s the implementation code:

public enum ResultEnum {

    WIN,
    LOSE,
    DRAW

}

public interface ElementVisitor {

    ResultEnum visit(Rock rock);

    ResultEnum visit(Paper paper);

    ResultEnum visit(Scissors scissors);

}

public class PaperVisitor implements ElementVisitor {

    @Override
    public ResultEnum visit(Rock rock) {
        return ResultEnum.WIN;
    }

    @Override
    public ResultEnum visit(Paper paper) {
        return ResultEnum.DRAW;
    }

    @Override
    public ResultEnum visit(Scissors scissors) {
        return ResultEnum.LOSE;
    }

}

public class RockVisitor implements ElementVisitor {

    @Override
    public ResultEnum visit(Rock rock) {
        return ResultEnum.DRAW;
    }

    @Override
    public ResultEnum visit(Paper paper) {
        return ResultEnum.LOSE;
    }

    @Override
    public ResultEnum visit(Scissors scissors) {
        return ResultEnum.WIN;
    }

}

public class ScissorsVisitor implements ElementVisitor {

    @Override
    public ResultEnum visit(Rock rock) {
        return ResultEnum.LOSE;
    }

    @Override
    public ResultEnum visit(Paper paper) {
        return ResultEnum.WIN;
    }

    @Override
    public ResultEnum visit(Scissors scissors) {
        return ResultEnum.DRAW;
    }

}

public interface Element {

    ResultEnum accept(ElementVisitor elementVisitor);

}

public class Paper implements Element {

    @Override
    public ResultEnum accept(ElementVisitor elementVisitor) {
        return elementVisitor.visit(this);
    }

}

public class Rock implements Element {

    @Override
    public ResultEnum accept(ElementVisitor elementVisitor) {
        return elementVisitor.visit(this);
    }

}

public class Scissors implements Element {

    @Override
    public ResultEnum accept(ElementVisitor elementVisitor) {
        return elementVisitor.visit(this);
    }

}

@SpringBootApplication
public class TestsApplication implements CommandLineRunner {

    public static void main(String() args) {
        SpringApplication.run(TestsApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        Element e1 = new Rock();
        Element e2 = new Paper();

        System.out.println(e1.accept(new PaperVisitor()));
        System.out.println(e2.accept(new RockVisitor()));
    }

}

Result:
WIN
LOSE

I think I understang the gist of it (avoid the instanceof operator) but it seems a bit cumbersome in the sense that if you have N visitable elements, you need to implement N*N methods. In this case it’s only 9 and you can combine every element with itself and other elements, but I can’t think of a real case scenario where this would happen (in a IO bound web app). Have you ever implemented this pattern in a real web app??

javascript – Is there a better way to copy dynamic data from one sheet to another in google sheets script?

I’m pulling data in from an API and putting it in the top two rows of a sheet. This script is to copy the data from the “pull” sheet into a daily sheet. The rub is that the data may change and I want to dynamically copy the data over; i.e. if the column header exists, put the new data in the bottom row. If the column header does not exist, create a new column and copy in the data into the correct row.

The script feels cumbersome and not reusable. Is there a better and/or more generic way to do this?

 function runCopyToDailyScript(){
var souceSheetName = "AAVE Data Pull";
var targetSheetName = "AAVE Daily" ;
let ss = SpreadsheetApp.getActiveSpreadsheet();           // get active spredsheet
let sourceSheet = ss.getSheetByName(souceSheetName);
let targetSheet = ss.getSheetByName(targetSheetName);
var nextTargetRow = targetSheet.getLastRow() + 1. // where the next row of data is going

// get the data in top two rows of source sheet
var sourceRange = sourceSheet.getDataRange();  // get range of all data on source sheet
var sourceData = sourceRange.getValues(); // get the values of all the data in the source sheet
var sourceArray = transposeArray(sourceData); // transposeArray from genearal functions

// target data
var targetHeadersRange = targetSheet.getRange(1,1,1,targetSheet.getLastColumn());  // get top row of daily data
var targetHeaders2DArray = targetHeadersRange.getValues();  // array of headers within an array
var targetHeaders = targetHeaders2DArray(0);  // creats an array of the headers

/** go through source (the data pull) headers and see if they are in target sheet */
sourceArray.forEach(element => checkDailySheet(element));  // goes through each pair of source data. checkDailySheet is another function

function checkDailySheet(subArray){
  let theIndex = targetHeaders.indexOf(subArray(0)) // returns the index of the key in the pair in the target sheet if it exists

  // test to see if the the column head is in the target sheet
  if (theIndex != -1) { 
          let targetCell = targetSheet.getRange(nextTargetRow, theIndex + 1, 1, 1) // nextTargetRow is constant declared above
          targetCell.setValue(subArray(1)) // sets the last row in the target column to the source value
          
  } else {
          /** find the next avail column in target range */
          targetHeadersRange = targetSheet.getRange(1,1,1,targetSheet.getLastColumn() + 1);
          targetHeaders2DArray = targetHeadersRange.getValues();
          targetHeaders = targetHeaders2DArray(0); // array with the target headers + one extra
          let targetHeadersLength = targetHeaders.length;

          let newTargetHeaderCell = targetSheet.getRange(1, targetHeadersLength, 1, 1);
          newTargetHeaderCell.setValue(subArray(0)); // set the next collum header with the missing key

          let targetCell = targetSheet.getRange(nextTargetRow, targetHeadersLength, 1, 1) // nextTargetRow is constant declared above
          targetCell.setValue(subArray(1)) // sets the last row in the target column to the source value
          
   }; // end of else
  }; //end of CheckDailySheet
}; // end of runCopyToDailyScript()