text:
Q: SageMaker batch transform not loading CSV correctly I am running a batch transform job that us uploading data from a CSV. The CSV is formatted as such
"joe annes rifle accesories discount"
"cute puppies for sale"
"Two dudes talk about sports"
"Smith & Wesson M&P 500 review"
"Glock vs 1911 handgun"
My code for creating the batch transform is below
elec_model = HuggingFaceModel(
    model_data='s3://some_path/binary-model',
    role=role,
    entry_point='torchserve_.py',
    source_dir='source_dir',
    transformers_version="4.17.0",
    pytorch_version='1.10.2',
    py_version='py38'
)

nl_detector = elec_model.transformer(
    instance_type = 'ml.g4dn.xlarge',
    strategy="MultiRecord",
    assemble_with="Line",
    output_path = "s3://some_path/trash_output"
)

nl_detector.transform(
    "s3://some_bucket/trash",
    content_type="text/csv",
    split_type="Line"
)

When I run this code instead of the batch job taking the CSV and breaking up the examples with every space, which is what
split_type="Line"
is telling the algorithm to do, but instead it just ingests all of the sentences in the above CSV, and outputs 1 probability.
When I print the input payload it looks like this EDIT: all three sentences are printed at once.
"joe annes rifle accesories discount"

2022-10-26T21:03:04,265 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle -

"cute puppies for sale"

2022-10-26T21:03:04,265 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle -

"Two dudes talk about sports"

2022-10-26T21:03:04,265 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle

Where each sentence is an inference example, and is separated by this statement
2022-10-26T21:03:04,265 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle

So it seems like sagemaker is separating the inference examples. But when I try and pass these sentences into a huggingface tokenizer, the tokenizer tokenizes them like they are one inference example, when they should be 3 distinct inference examples. I've also tried printing and or returning the above object at an indice, hoping the object pointed at an indice would return a sentence. But it instead just returns a character, which seems to confirm the object above with three sentences is treated as one string instead of three
EDIT 1:
Here is the code for my inference logic torch_serve_.py
import numpy as np
import os
import sys
import logging
import json

import torch
from sagemaker_inference import content_types, decoder

import subprocess
#subprocess.check_call([sys.executable, "-m", "pip", "install", 'transformers'])

from transformers import ElectraTokenizer

def model_fn(model_dir):
    """
    Load the model for inference
    """

    model= torch.load(model_dir + "/arms_ammunition.pth")
    model.eval()
    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    model.to(device)

    #use_cuda = torch.cuda.is_available()
    #if use_cuda:
    #    model.cuda()
    ##return model.to(device)
    return model

def predict_fn(input_data, model):
    """
    Apply model to the incoming request
    """

    print('listy!!!!!!!!!:   ', input_data)

    tokenizer = ElectraTokenizer.from_pretrained('google/electra-base-discriminator')
    sm = torch.nn.Softmax(dim=2)

    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    #model.to(device)
    #model.eval()
    encoded_inputs = tokenizer(input_data, max_length=220, padding = 'longest', truncation = True)
    print('encoded_inputs', encoded_inputs)
    tokened_words = encoded_inputs['input_ids']
    #print('tokened_wordssssssss:   ', tokened_words)
    attention_mask = encoded_inputs['attention_mask']
    #print('attention_maskkkkkkkk:   ', attention_mask)

    with torch.no_grad():
        outputs = model(torch.tensor(tokened_words).unsqueeze(0).to(device), torch.tensor(attention_mask).unsqueeze(0).to(device))
        #print('mmooddeell!!!!!!!!!  ', model)
        #probs = sm(outputs.logits)
        probs = torch.nn.functional.softmax(outputs.logits, 1)

        return probs
        #return model(input_data.float()).numpy()[0]

def input_fn(request_body, request_content_type):
    """
    Deserialize and prepare the prediction input
    """
    print("type of jawn!!!!!!!!!!!!!!!!!!!!", type(request_body))
    print('request_content_type', request_content_type)
    print('requ_body', request_body)
    return request_body

def output_fn(prediction_output, accept):
    print("prediction_output.tolist()", prediction_output)
    return prediction_output.tolist()
    #return json.dumps(prediction_output.tolist())

EDIT 2: SNIPPET OF LOGS BELOW
2022-10-27T19:52:00,401 [INFO ] W-9000-model-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Model model loaded io_fd=0242a9fffefeff83-0000001c-00000001-1c705d0aba004d53-1d21a7ab
2022-10-27T19:52:00,402 [INFO ] W-9000-model com.amazonaws.ml.mms.wlm.WorkerThread - Backend response time: 4800
2022-10-27T19:52:00,404 [WARN ] W-9000-model com.amazonaws.ml.mms.wlm.WorkerLifeCycle - attachIOStreams() threadName=W-model-1
2022-10-27T19:52:00,406 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - type of jawn!!!!!!!!!!!!!!!!!!!! <class 'str'>
2022-10-27T19:52:00,407 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - request_content_type text/csv
2022-10-27T19:52:00,407 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - requ_body "New Delhi\, June 04 (ANI): Food Safety and Standards Association of India (FSSAI) CEO Yudhvir Singh Malik on Thursday said that the reports submitted by Delhi and Kerala are fully authentic while that submitted by Goa was inappropriate. He also said that Goa food officials are asked to submit their proper report in 2-3 days time. Further\, Malik said that the food business manufacturer should have their own plans for checking of their products so as to avoid such lapses. He also said that the food safety commissioners are asked to not only focus on Nestle but also to pick up samples from other manufacturers."
2022-10-27T19:52:00,408 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - "MW 328 अश्लील फोटोचा धाक दाखवून विवाहितेवर सलग 2 दिवस अत्याचार | औरंगाबाद |\\n\\nGAON MAJHA NEWS is one of Most Watched Marathi News channel. \\n\\nHere you can watch live Marathi news\, breaking news\, politics news\, latest news\, entertainment news\, tech news\, auto news\, lifestyle news & more. TODAYS MARATHI NEWS\, Trending News\,  RECENT NEWS\, CURRENT NEWS\,   WORLD NEWS\, DAILY NEWS\, latest news\, Marathi news\, Latest Marathi News\, Latest News in Marathi\, Marathi news live\, News Marathi\, Breaking News in Marathi\, Live Marathi News\, News in Marathi\, ताज्या मराठी बातम्या \, Marathi Batmya.\\n\\n\\nSUBSCRIBE TO GAON MAJHA NEWS :- \\nFacebook page:-\\nhttps://www.facebook.com/gaonmajhanews/\\n\\nTwitter:-\\nhttps://twitter.com/gaonmajhanews1\\n\\nGaonmajha  Official Website:-\\nhttp://www.gaonmajha.in/\\n\\nGoogle+:-\\nhttps://plus.google.com/u/0/\\n\\nYoutube:-\\nhttps://www.youtube.com/channel/UCbVX89IreHNyjcHuDTIqicQ?view_as=subscriber\\n\\n\\nStay tuned for all the breaking news in Marathi  with GAON MAJHA NEWS!"
2022-10-27T19:52:00,409 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - "Subscribe our channel for More Video & Updates: https://go./j07htL\\r\\n\\r\\nFollow us on\\r\\nFacebook : https://www.facebook.com/gstv.news\\r\\nTwitter : https://twitter.com/gstv_news\\r\\n#gujaratinews #gstv #gstvnews  #GSTVLIVE #gujaratinewslive #gujaratinewspaper #gujaratinews2020 \\r\\n#gujaratinewscoronavirustoday #covind19\\r\\n#GujaratSamacharLiveTV #GujaratSamachar"
2022-10-27T19:52:00,409 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - "Minutes count when you're having a heart attack. But it took the Chicago Fire Department more than 40 minutes to get a 56-year-old man to a hospital for help. CBS 2's Pam Zekman reports."
2022-10-27T19:52:00,409 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - "Margie Pargie & The Yoga Hangout SRQ kicked off the Sexy Transformation Challenge with a visit to local boxing gym\, Uppercut Boxing & Fitness. We joined Aaron Jaco\, Pro Boxer and owner of the gym for a kickass\, heart pumping\, beast mode workout. The atmosphere\, intense yet playful\, kept everyone pushing hard until the last minute. Traditional elements of boxing mixed with plyometrics\, weight training\, and high intensity cardio blended for a solid 500-1000 calorie burn session. If you are looking for results\, a supportive community\, and a workout built for the most hardcore\, you should visit Aaron! He will show you all the moves to be your sexiest self!\\n\\nwww.aerialyogaschool.com to enter the Sexy Transformation Challenge \\nwww.uppercutboxingsarasota.com for info about taking Aaron Jaco's class"
2022-10-27T19:52:00,409 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle -
2022-10-27T19:52:00,410 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - listy!!!!!!!!!:    "New Delhi\, June 04 (ANI): Food Safety and Standards Association of India (FSSAI) CEO Yudhvir Singh Malik on Thursday said that the reports submitted by Delhi and Kerala are fully authentic while that submitted by Goa was inappropriate. He also said that Goa food officials are asked to submit their proper report in 2-3 days time. Further\, Malik said that the food business manufacturer should have their own plans for checking of their products so as to avoid such lapses. He also said that the food safety commissioners are asked to not only focus on Nestle but also to pick up samples from other manufacturers."
2022-10-27T19:52:00,410 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - "MW 328 अश्लील फोटोचा धाक दाखवून विवाहितेवर सलग 2 दिवस अत्याचार | औरंगाबाद |\\n\\nGAON MAJHA NEWS is one of Most Watched Marathi News channel. \\n\\nHere you can watch live Marathi news\, breaking news\, politics news\, latest news\, entertainment news\, tech news\, auto news\, lifestyle news & more. TODAYS MARATHI NEWS\, Trending News\,  RECENT NEWS\, CURRENT NEWS\,   WORLD NEWS\, DAILY NEWS\, latest news\, Marathi news\, Latest Marathi News\, Latest News in Marathi\, Marathi news live\, News Marathi\, Breaking News in Marathi\, Live Marathi News\, News in Marathi\, ताज्या मराठी बातम्या \, Marathi Batmya.\\n\\n\\nSUBSCRIBE TO GAON MAJHA NEWS :- \\nFacebook page:-\\nhttps://www.facebook.com/gaonmajhanews/\\n\\nTwitter:-\\nhttps://twitter.com/gaonmajhanews1\\n\\nGaonmajha  Official Website:-\\nhttp://www.gaonmajha.in/\\n\\nGoogle+:-\\nhttps://plus.google.com/u/0/\\n\\nYoutube:-\\nhttps://www.youtube.com/channel/UCbVX89IreHNyjcHuDTIqicQ?view_as=subscriber\\n\\n\\nStay tuned for all the breaking news in Marathi  with GAON MAJHA NEWS!"
2022-10-27T19:52:00,411 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - "Subscribe our channel for More Video & Updates: https://go/j07htL\\r\\n\\r\\nFollow us on\\r\\nFacebook : https://www.facebook.com/gstv.news\\r\\nTwitter : https://twitter.com/gstv_news\\r\\n#gujaratinews #gstv #gstvnews  #GSTVLIVE #gujaratinewslive #gujaratinewspaper #gujaratinews2020 \\r\\n#gujaratinewscoronavirustoday #covind19\\r\\n#GujaratSamacharLiveTV #GujaratSamachar"
2022-10-27T19:52:00,412 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - "Minutes count when you're having a heart attack. But it took the Chicago Fire Department more than 40 minutes to get a 56-year-old man to a hospital for help. CBS 2's Pam Zekman reports."
2022-10-27T19:52:00,412 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - "Margie Pargie & The Yoga Hangout SRQ kicked off the Sexy Transformation Challenge with a visit to local boxing gym\, Uppercut Boxing & Fitness. We joined Aaron Jaco\, Pro Boxer and owner of the gym for a kickass\, heart pumping\, beast mode workout. The atmosphere\, intense yet playful\, kept everyone pushing hard until the last minute. Traditional elements of boxing mixed with plyometrics\, weight training\, and high intensity cardio blended for a solid 500-1000 calorie burn session. If you are looking for results\, a supportive community\, and a workout built for the most hardcore\, you should visit Aaron! He will show you all the moves to be your sexiest self!\\n\\nwww.aerialyogaschool.com to enter the Sexy Transformation Challenge \\nwww.uppercutboxingsarasota.com for info about taking Aaron Jaco's class"
2022-10-27T19:52:00,464 [WARN ] W-model-1-stderr com.amazonaws.ml.mms.wlm.WorkerLifeCycle -
2022-10-27T19:52:00,470 [WARN ] W-model-1-stderr com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Downloading:   0%|          | 0.00/226k [00:00<?, ?B/s]
2022-10-27T19:52:00,470 [WARN ] W-model-1-stderr com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Downloading: 100%|██████████| 226k/226k [00:00<00:00, 40.3MB/s]
2022-10-27T19:52:00,561 [WARN ] W-model-1-stderr com.amazonaws.ml.mms.wlm.WorkerLifeCycle -
2022-10-27T19:52:00,562 [WARN ] W-model-1-stderr com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Downloading:   0%|          | 0.00/27.0 [00:00<?, ?B/s]
2022-10-27T19:52:00,562 [WARN ] W-model-1-stderr com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Downloading: 100%|██████████| 27.0/27.0 [00:00<00:00, 38.7kB/s]
2022-10-27T19:52:00,603 [WARN ] W-model-1-stderr com.amazonaws.ml.mms.wlm.WorkerLifeCycle -
2022-10-27T19:52:00,604 [WARN ] W-model-1-stderr com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Downloading:   0%|          | 0.00/666 [00:00<?, ?B/s]
2022-10-27T19:52:00,605 [WARN ] W-model-1-stderr com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Downloading: 100%|██████████| 666/666 [00:00<00:00, 593kB/s]
2022-10-27T19:52:00,650 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle -
2022-10-27T19:52:00,652 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - encoded_inputs {'input_ids': [101, 1000, 2047, 6768, 1032, 1010, 2238, 5840, 1006, 2019, 2072, 1007, 1024, 2833, 3808, 1998, 4781, 2523, 1997, 2634, 1006, 1042, 11488, 2072, 1007, 5766, 9805, 16425, 21663, 5960, 14360, 2006, 9432, 2056, 2008, 1996, 4311, 7864, 2011, 6768, 1998, 8935, 2024, 3929, 14469, 2096, 2008, 7864, 2011, 15244, 2001, 15884, 1012, 2002, 2036, 2056, 2008, 15244, 2833, 4584, 2024, 2356, 2000, 12040, 2037, 5372, 3189, 1999, 1016, 1011, 1017, 2420, 2051, 1012, 2582, 1032, 1010, 14360, 2056, 2008, 1996, 2833, 2449, 7751, 2323, 2031, 2037, 2219, 3488, 2005, 9361, 1997, 2037, 3688, 2061, 2004, 2000, 4468, 2107, 10876, 2229, 1012, 2002, 2036, 2056, 2008, 1996, 2833, 3808, 12396, 2024, 2356, 2000, 2025, 2069, 3579, 2006, 9089, 2571, 2021, 2036, 2000, 4060, 2039, 8168, 2013, 2060, 8712, 1012, 1000, 1000, 12464, 25256, 1311, 29872, 29870, 29878, 29870, 100, 1326, 29876, 29851, 1325, 29876, 29852, 29871, 29863, 1335, 29877, 29871, 29876, 29875, 29877, 29859, 29871, 29869, 1338, 29870, 29853, 1016, 1325, 29877, 29871, 29874, 1311, 29859, 29868, 29876, 29854, 29876, 29869, 1064, 100, 1064, 1032, 1032, 1050, 1032, 1032, 12835, 7113, 2078, 16686, 3270, 2739, 2003, 2028, 1997, 2087, 3427, 18388, 2739, 3149, 1012, 1032, 1032, 1050, 1032, 1032, 18699, 7869, 2017, 2064, 3422, 2444, 18388, 2739, 1032, 1010, 4911, 2739, 1032, 1010, 4331, 2739, 1032, 1010, 6745, 2739, 102], 'token_type_ids': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}
2022-10-27T19:52:00,605 [WARN ] W-model-1-stderr com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Downloading: 100%|██████████| 666/666 [00:00<00:00, 593kB/s]
2022-10-27T19:52:00,650 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle -
2022-10-27T19:52:00,652 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - encoded_inputs {'input_ids': [101, 1000, 2047, 6768, 1032, 1010, 2238, 5840, 1006, 2019, 2072, 1007, 1024, 2833, 3808, 1998, 4781, 2523, 1997, 2634, 1006, 1042, 11488, 2072, 1007, 5766, 9805, 16425, 21663, 5960, 14360, 2006, 9432, 2056, 2008, 1996, 4311, 7864, 2011, 6768, 1998, 8935, 2024, 3929, 14469, 2096, 2008, 7864, 2011, 15244, 2001, 15884, 1012, 2002, 2036, 2056, 2008, 15244, 2833, 4584, 2024, 2356, 2000, 12040, 2037, 5372, 3189, 1999, 1016, 1011, 1017, 2420, 2051, 1012, 2582, 1032, 1010, 14360, 2056, 2008, 1996, 2833, 2449, 7751, 2323, 2031, 2037, 2219, 3488, 2005, 9361, 1997, 2037, 3688, 2061, 2004, 2000, 4468, 2107, 10876, 2229, 1012, 2002, 2036, 2056, 2008, 1996, 2833, 3808, 12396, 2024, 2356, 2000, 2025, 2069, 3579, 2006, 9089, 2571, 2021, 2036, 2000, 4060, 2039, 8168, 2013, 2060, 8712, 1012, 1000, 1000, 12464, 25256, 1311, 29872, 29870, 29878, 29870, 100, 1326, 29876, 29851, 1325, 29876, 29852, 29871, 29863, 1335, 29877, 29871, 29876, 29875, 29877, 29859, 29871, 29869, 1338, 29870, 29853, 1016, 1325, 29877, 29871, 29874, 1311, 29859, 29868, 29876, 29854, 29876, 29869, 1064, 100, 1064, 1032, 1032, 1050, 1032, 1032, 12835, 7113, 2078, 16686, 3270, 2739, 2003, 2028, 1997, 2087, 3427, 18388, 2739, 3149, 1012, 1032, 1032, 1050, 1032, 1032, 18699, 7869, 2017, 2064, 3422, 2444, 18388, 2739, 1032, 1010, 4911, 2739, 1032, 1010, 4331, 2739, 1032, 1010, 6745, 2739, 102], 'token_type_ids': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}
2022-10-27T19:51:58.086:[sagemaker logs]: MaxConcurrentTransforms=1, MaxPayloadInMB=50, BatchStrategy=MULTI_RECORD
2022-10-27T19:52:01,360 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - prediction_output.tolist() tensor([[0.9766, 0.0234]], device='cuda:0')
2022-10-27T19:52:01,360 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Preprocess time - 0.04482269287109375 ms
2022-10-27T19:52:01,361 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Predict time - 951.9212245941162 ms
2022-10-27T19:52:01,361 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Postprocess time - 1.8284320831298828 ms
2022-10-27T19:52:01,362 [INFO ] W-9000-model com.amazonaws.ml.mms.wlm.WorkerThread - Backend response time: 956
2022-10-27T19:52:01,362 [INFO ] W-9000-model ACCESS_LOG - /169.254.255.130:37830 "POST /invocations HTTP/1.1" 200 3223
2022-10-27T19:52:01,360 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - prediction_output.tolist() tensor([[0.9766, 0.0234]], device='cuda:0')
2022-10-27T19:52:01,360 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Preprocess time - 0.04482269287109375 ms
2022-10-27T19:52:01,361 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Predict time - 951.9212245941162 ms
2022-10-27T19:52:01,361 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Postprocess time - 1.8284320831298828 ms
2022-10-27T19:52:01,362 [INFO ] W-9000-model com.amazonaws.ml.mms.wlm.WorkerThread - Backend response time: 956
2022-10-27T19:52:01,362 [INFO ] W-9000-model ACCESS_LOG - /169.254.255.130:37830 "POST /invocations HTTP/1.1" 200 3223

A: In the SageMaker TensorFlow container I created a numpy array of the input that then allows me to access each record. I suspect you can do something similar in the HuggingFace container.
For example,
def read_csv(csv):
    return np.array([[float(j) for j in i.split(",")] for i in csv.splitlines()])

def input_handler(data, context):
    """Pre-process request input before it is sent to TensorFlow Serving REST API
    Args:
        data (obj): the request data stream
        context (Context): an object containing request and configuration details
    Returns:
        (dict): a JSON-serializable dict that contains request body and headers
    """

    if context.request_content_type == "text/csv":

        payload = data.read().decode("utf-8")
        inputs = read_csv(payload)

        input = {"inputs": inputs.tolist()}

        return json.dumps(input)

https://github.com/aws/amazon-sagemaker-examples/blob/main/sagemaker_batch_transform/custom_tensorflow_inference_script_csv_and_tfrecord/custom_tensorflow_inference_script_csv_and_tfrecord.ipynb


text:
Q: min() function in python3 It seems that the inbuilt min() function for determining the minimum value in a given iterable. I have this line of code:
result = min(cost+futureCost(newState) \
                for action, newState, cost in problem.succAndCost(state))

where newState is of integer type and the function futureCost() returns an integer. How the enclosed parameters form an iterable in this case?

A: This is called a generator expression. https://www.python.org/dev/peps/pep-0289

redpajama_set_name: RedPajamaStackExchange


text:
Q: how to precompile a dust template dust-compiler -s controllers/inbox/views/inbox.dust -d    public/js/custom/inbox/messages.js

but i am getting error
 if (err) throw err;
               ^
Error: ENOTDIR, scandir 'C:\jbk\buy2gthr-master\controllers\inbox\views\inbox.dust'
    at Error (native)

i have inbox.dust file:
{>"../../../layout/layout"/}

 {<css-content}
 {/css-content}
 {<page-content}
 {/<page-content}

**

**
 {/page-content}
 {

  {/script-content}

and inbox.js file
$(document).ready(function () {
    var data = {
        "title": "Famous People",
        "names" : [{ "name": "Larry" },{ "name": "Curly" },{ "name": "Moe" }]
    }

    var source   = $("#entry-template").html();
    var compiled = dust.compile(source, "intro");
    console.log(compiled);

    dust.loadSource(compiled);

    dust.render("intro", data, function(err, out) {
        if(err) console.log(err);
        else
        console.log(out);

        $("#output").html(out);
    });
});

still i am gettting

A: I'm not sure what dust compiler you're using, but just use dustc -- it comes with Dust.
You can read about all the dustc API options, but to precompile a single file you'd do something like
dustc controllers/inbox/views/inbox.dust --output=public/js/custom/inbox/messages.js

dustc compiles templates using absolute names instead of relative ones, because Dust is not filesystem-aware. Unless you've specifically set up your dust.onLoad function to handle relative paths, you'll want to make your includes look something like {> "inbox/messages" /}.


text:
Q: Urgent help with TempDB log file growth mystery I need some urgent guidance for a tempdb issue for past last week:
The tempDB log file is growing starting a specific time, lets say 2 PM. And almost continue to grow upto 150 GB and then comes down after 10 or so hours.
I have used various queries listed here but nothing shows up as in that duration there is no long running transaction.
Queries of mix workload keeps coming and going. There is no stuck transaction as such.
The user databases on this instance are all part of Log shipping setup and log backups happen every 15 mins.
In addition i added the Xevent
CREATE EVENT SESSION [tempdb_file_size_changed] ON SERVER ADD EVENT
sqlserver.database_file_size_change(SET collect_database_name=(1)ACTION(sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.is_system,sqlserver.query_hash,sqlserver.session_id,sqlserver.session_nt_username,sqlserver.sql_text,sqlserver.username) WHERE ([database_id]=(2))) ADD TARGETpackage0.event_file(SET filename=N'C:\ExtendedEvents\TempDBGrowth.xel',max_file_size=(100),max_rollover_files=(25)) WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=1 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=ON)

Nothing gets captured even in XE and its just blank in those 10 hours.
I have no clue what is eating my tempDB log as none of the queries or XE gets me the data. I have never seen this thing and generally get database growth using XE but here i am just clueless.
I am running DBCC SQLPERF(logspace) and i can see log used just keeps increasing by 1 Gb every 5 mins or so. We have TempDB log set to max 200 GB but by 10 hours its almost 160-180 GB and then suddenly comes down.
Running below query almost every time gives ACTIVE TRANSACTION.
SELECT log_reuse_wait, log_reuse_wait_desc
FROM sys.databases d
WHERE database_id = 2;

Please help what i might be doing wrong and why i cant see any transaction using TempDB log file usage?
Update- As requested in answer from @J.D, i checked and verified that there is no database mail or Service broker is being used internally to cause the growth:
However over last week i see the growth in log file of tempdb is zig zag and the trend of that zig zag growth is bit higher:
I need to help understand :-
How is the transaction log growth increasing upto 80% and then lowering down back to 0 and then increasing and growing and so on , with reaching lmoast max 90-95%.
I confirmed there is no manual shrinking going on. Could there be multiple processes contributing as this is OLTP server with tempdb usage throughout the day. Just dont understand how in last week it has grown near its max capacity?
thanks

A: What you are you seeing is by design for tempdb Transaction Log file. I wish Microsoft had better documentation on this.

How is the transaction log growth increasing upto 80% and then
lowering down back to 0 and then increasing and growing and so on ,
with reaching almost max 90-95%.

From the First reference article:

Tempdb is not recovered in the event of a crash, and so there is no
need to force dirty tempdb pages to disk, except in the case where the
lazywriter process (part of the buffer pool) has to make space for
pages from other databases.
A checkpoint is only done for tempdb when the tempdb log file reaches
70% full – this is to prevent the tempdb log from growing if at all possible (note that a long-running transaction can still
essentially hold the log hostage and prevent it from clearing, just
like in a user database).
Of course, when you issue a manual CHECKPOINT, all the dirty pages
are flushed, but for automatic checkpoints, they're not.

I suggest you monitor your tempdb Transaction Log usage and set it to a reasonable size that under normal workload it does not have to grow and shrink.
I do not know exactly why your tempdb logfile filled to 100%. There has to be a reason why the log file did not get truncated.
Will indirect checkpoint help?
In most cases no.

Any non-logged "bulk" operation that qualifies for an "eager write" in
tempdb is not a candidate to be flushed by the recovery writer (the
internal thread that runs the indirect checkpoint).
This raises an important question: which data load operation is
minimally logged on tempdb? This is important to know because
minimally logged operations on tempdb will not be flushed by the
indirect checkpoint. The following list can be used to assist you in
understanding which load operations on tempdb will be minimally logged
and which will not.

For details read Tempdb – Here's a Problem You Didn't Know You Had by Fabiano Amorim
I noticed this question is for SQL Server 2014, if someone is reading this for SQL Server 2016 read the below documentation by Microsoft.

*

*Database Checkpoints (SQL Server) - check the "Indirect Checkpoint" section.

*Change the Target Recovery Time of a Database (SQL Server).

*Indirect Checkpoint and tempdb – the good, the bad and the non-yielding scheduler by Parikshit Savjani

Reference:

*

*What does checkpoint do for tempdb? by Paul Randal

*See question and answer section Inside the Storage Engine: What's in the buffer pool? by Paul Randal

A: Try using the TempDBInfo procedure, it shows what currently is inside TempDB's files and who is using it most
https://github.com/aleksey-vitsko/Database-Administrator-Tools/blob/master/TempDB%20-%20TempDBInfo.sql
Procedure is not fully finished, I am going to rework the way it shows summary information, and also I am planning to add logging capabilities
But it is still good at looking who is the current consumer (which session or task is using most) and might help you to diagnose the problem
Here what it shows for me:

If you have any comments or suggestions for SP, let me know

A: Interesting that you don't see any running transactions but it continues to grow, as there has to be an underlying cause. Have you explored the last piece of advice Aaron mentions in that answer you linked?

You may also consider that your tempdb log usage may be caused by internal processes that you have little or no control over - for example database mail, event notifications, query notifications and service broker all use tempdb in some way. You can stop using these features, but if you're using them you can't dictate how and when they use tempdb.

Outside of that you might want to start looking into look into WhoIsActive which is an amazing query by Adam Machanic that essentially shows every running query on a server with some performance analysis information, and/or some of the procedures in the First Responder Kit by Brent Ozar's team such as sp_BlitzFirst, sp_BlitzWho, or sp_BlitzCache. You can even try scheduling a job that routinely runs and caches any of these, so you can get the before, during, and after story of what's going on with your SQL Server.


text:
Q: WCF low level communication hacking I've just read about how WCF can send reliable messages and I wanted to check something.
If the WCF service is set to use Reliable Messaging and a client requested some data from a service.  If the client had been hacked to keep saying this data not received would the WCF service keep resending the data indefinitely? Could this be used to affect the stability of the server and is it a risk?
Are there security measures which should be put in place if the WCF service is public?
I suppose it's not much worse than clients clicking refresh on a webpage. But is there anything else which should be considered?

A: There is a MaxRetryCount property:

This value, which defaults to 8
  (minimum 1, maximum 20), specifies how
  many times the infrastructure shall
  retry to resend a message in case of a
  transmission failure. Once a message
  has been unsuccessfully resent for the
  configured number of retries, the
  failure is considered to be
  unrecoverable and causes the channel
  to fault.


text:
Q: Retrieving DataTable from Memory Stream. I have a data table that is formatted from an array of Column Names, I.e.
        DataTable ThisTable = new DataTable();

        for (int i = 0; i <= col.GetUpperBound(0); i++)
        {
            try
            {
                ThisTable.Columns.Add(new DataColumn(col[i].ToString(), typeof(string)));
            }
            catch (Exception e)
            {
                MessageBox.Show("Uploader  Error"+e.ToString());
                return null;
            }
        }

i then use a BinaryFormatter object to Serialize/Deserialize a memory stream so that I can read the data from the stream into a table. Essentially users will be uploading an excel sheet that will be read into a database. Although I realize that it is possible, I DO NOT want to write the sheet to disk then read it in.
However when I go to retrieve the datatable from the Deserialize() call, I dont get an error, however I get an empty DataSet.
Mem would be my memory stream object.
        BinaryFormatter bformat = new BinaryFormatter();
        bformat.Serialize(Mem, ThisTable);
        Mem.Seek(0, SeekOrigin.Begin);
        byte[] bt = Mem.ToArray();

        Stream s = new MemoryStream(bt);
        Mem.Position = 0;
        s.Position = 0;
        ThisTable = (DataTable)bformat.Deserialize(Mem);
        DS.Tables.Add(ThisTable);

        return DS;

A: I would suggest using the OpenXml SDK to read the Excel file into the DataTable.
Take a look at the answer from M_R_H for an example:
From Excel to DataTable in C# with Open XML
You can also look at the answer from amurra here for another example:
reading Excel Open XML is ignoring blank cells

A: Unless there is an error in the sample code you posted, you aren't populating the DataTable with any data, you are just creating columns.  You can add rows to the DataTable via DataTable.Rows.Add():
foreach(var o in myDataSource)
{
    ThisTable.Rows.Add(o.Prop1, o.Prop2, etc);
}


text:
Q: Can OmniTure SiteCatalyst or any web Analytics Software track Critical Page Views? I need to track only human visits to my article pages. I hear that SiteCatalyst is the best of the best for page tracking. Here is what I am trying to do. I need to track every human visit if possible because this will affect the amount of money i have to pay. I will need to download site statistics for all of my pages with an accurate hit count. Again, I don't want to track spiders/bots. Once I download the site statistics I will use it to update hit counts to each of my articles. Then I will pay my writers according to how many hits they receive. Is SiteCatalyst able to do this. If not, who do you think can do something like this?

A: Luke - Quick answer there currently is no %100 accurate way to get this.
Omniture's SiteCatalyst does provide a very good tool for acquiring visitor information.  You can acquire visitor information from any of the other vendors as well including the free option Google Analytics.
You may have been lead to believe as I had that Omniture strips out all bots and spiders by default.  Omniture states that most bots and spiders do not load images or execute JavaScript, which is what they rely upon for tracking.  I am not sure what the exact percentage is, but not all bots and spiders act in this way.
In order for you to gain a more accurate report on the number of "humans" you will need to know what the IP address of the visitor is and possibly the user agent.  You can populate the agent and IP in PHP with these two variables $_SERVER['HTTP_USER_AGENT'] and $_SERVER['REMOTE_ADDR'].   You will then need to strip out the IP address of known bots/spiders from your reporting.  You can do this with lists like this: http://www.user-agents.org/index.shtml or manually by looking at the user agent.  Beware of relying upon the user agent as the bot can easily spoof this.  This will never be %100 accurate because new bots/spiders pop up every day.  I suggest looking further into "click fraud".
Contact me if you want further info.

A: omniture also weeds out traffic from known bots/spiders.  But yeah...there is an accepted margin of error in the analytics industry because it can never be 100%, due to the nature of the currently available technology.


text:
Q: I se a white page when I deploy an agular app with ssr on Firebase I am trying to deploy my Angular app on Firebase, but after deploy, my app don't run. I changed index.html with this:
   <!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>App</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body class="mat-typography">
  <app-root></app-root>
</body>
</html>

Can this be because of main.js? I did it following this tutorial, but I had to add the server folder from dist into my functions folder in order to work


text:
Q: How to POST without using Submit? I want to post the Form but don't want to use the Submit method. If I use JQuery, how to handle the Form input controls?

A: Just create a function that is triggered by whatever event you want, for example: (found this code in another question)
function example() {
// get all the inputs into an array.
    var $inputs = $('#myForm :input');

    // not sure if you wanted this, but I thought I'd add it.
    // get an associative array of just the values.
    var values = {};
    $inputs.each(function() {
        values[this.name] = $(this).val();
    });
}

After that you can do whatever you want with the input values. You might want to consider using more advanced processing though, there are plenty of plugins that can provide this kind of functionality.

A: You can use the jQuery AJAX .post function functions. An example (untested, but should be working):
<script>
function postit(obj) {
  var data = $(obj).serialize();
  $.post($(obj).attr("action"), data, function() {
    //Put callback functionality here, to be run when the form is submitted.
  });
}
</script>
<form action="posthandler.php" onsubmit="postit(this); return false;">
<input type="text" name="field">
<input type="submit">
</form>

Also, read about serialize
(Of course you need to include the jQuery library in your code before using this code).

A: I am not sure if I understood the question correctly.
If you don't want to use submit(), you can do the same thing via jQuery.post() using Ajax. The main difference is you have to construct the key value data from the input fields yourself rather than the browser doing it automatically and you won't get a page refresh.

A: Either Post function or Load function will work.
@PRK are you trying to post the Form when the page loads or when a user hit a button?
load(url, parameters, callback)
eg:
$("#loadItHere").load("some.php", {somedata: 1});


text:
Q: OS independent C library for calculating time lapse? So in my game I need to simulate the physics in a hardware independent manner.
I'm going to use a fixed time-step simulation, but I need to be able to calculate how much time is passing between calls.
I tried this and got nowhere:
#include <time.h>
double time_elapsed;
clock_t last_clocks = clock();
while (true) {
  time_elapsed = ( (double) (clock() - last_clocks) / CLOCKS_PER_SEC);
  last_clocks = clock();
  printf("%f\n", time_elapsed);
}

Thanks!

A: You can use gettimeofday to get the number of seconds plus the number of microseconds since the Epoch. If you want the number of seconds, you can do something like this:
#include <sys/time.h>
float getTime()
{
    struct timeval time;
    gettimeofday(&time, 0);
    return (float)time.tv_sec + 0.000001 * (float)time.tv_usec;
}

I misunderstood your question at first, but you might find the following method of making a fixed-timestep physics loop useful.
There are two things you need to do to make a fixed-timestep physics loop.
First, you need to calculate the time between now and the last time you ran physics.
last = getTime();
while (running)
{
    now = getTime();
    // Do other game stuff
    simulatePhysics(now - last);
    last = now;
}

Then, inside of the physics simulation, you need to calculate a fixed timestep.
void simulatePhysics(float dt)
{
    static float timeStepRemainder; // fractional timestep from last loop
    dt += timeStepRemainder * SIZE_OF_TIMESTEP;

    float desiredTimeSteps = dt / SIZE_OF_TIMESTEP;
    int nSteps = floorf(desiredTimeSteps); // need integer # of timesteps

    timeStepRemainder = desiredTimeSteps - nSteps;

    for (int i = 0; i < nSteps; i++)
        doPhysics(SIZE_OF_TIMESTEP);

}

Using this method, you can give whatever is doing physics (doPhysics in my example) a fixed timestep, while keeping a synchronization between real time and game time by calculating the  right number of timesteps to simulate since the last time physics was run.

A: clock_gettime(3).


text:
Q: Replace '>' with '>\n' in several files in shell/bash I have several files in a single folder and I want to replace the character > with >\n everywhere in all of those files.
But whatever I do, the \n character does not get added after the > character.
I have tried the following:
echo '>ABCCHACAC' | tr '\>' '>\\n'
echo '>ABCCHACAC' | tr '>' '>\\n'
echo '>ABCCHACAC' | tr '>' '>\n'
echo '>ABCCHACAC' | tr '>' '\>\n'
echo '>ABCCHACAC' | tr '>' '\>\\n'
echo '>ABCCHACAC' | tr '>' '\>\\n'

But I get the same input string as output, whereas the correct output I want is:
>
ABCCHACAC

And I am using this script to do the same thing on many files:
for f in *.txt
do
  tr ">" ">\n" < "$f" > $(basename "$f" .txt)_newline_added.txt
done

A: tr is for one-for-one character replacements, not replacing strings. E.g. if you translate abc with def, it replaces all a with d, all b with e, and all c with f. When the second string is longer than the first, the extra characters are ignored. So tr '>' '>\n' means to replace > with > and ignores \n.
Use sed to perform string replacements.
sed 's/>/>\n/g' "$f" > "$(basename "$f" .txt)_newline_added.txt"

A: In addition to Barmar's answer, if you're using a BSD based *nix (eg. OS X) you'll either need to include an escaped literal newline, or possibly use tr in addition to sed.
Escaped literal newline:
$ sed 's/^>/>\
/' "$f"

sed with tr:
$ sed 's/^>/>▾/' "$f" | tr '▾' '\n'

↳ Insert newline (\n) using sed


text:
Q: Move out files via rsync, but keep local copies for a while - how? I have a Linux server that periodically creates new data files I need elsewhere.
I need to move any new data files to another PC periodically, but also keep local copies of them for a limited amount of time (e. g. 7 days).
I can easily do the "moving away" part via rsync. But is there a reliable "standard" solution for creating and keeping local copies for up to a specific amount of time (and deleting older copies automatically), or do I have to write my own script for that?
Note that I need to create copies and not just keep the original files for a little longer (because otherwise, rsync would copy them again and again in case the files are gone from the remote PC for further processing).
Thanks!


text:
Q: Is there any way to add multiple reminders for the same event in android? Is there any way to add multiple reminders for the same event in android (I need it before 4 hours, 3 hours, 2 hours, 1 hour)) Hope you guys can help me..Thanks in advance

A: you should be more specific, where do you want multiple reminders? In the callendar app?
You should take a look at this :
Add event and multiple reminder to that event in calender app
how to set multiple reminders in Android

A: if you are using alarm manager then here is code
    // context variable contains your `Context`
AlarmManager mgrAlarm = (AlarmManager) context.getSystemService(ALARM_SERVICE);
ArrayList<PendingIntent> intentArray = new ArrayList<PendingIntent>();

for(i = 0; i < 10; ++i)
{
   Intent intent = new Intent(context, OnAlarmReceiver.class);
   // Loop counter `i` is used as a `requestCode`
   PendingIntent pendingIntent = PendingIntent.getBroadcast(context, i, intent, 0);
   // Single alarms in 1, 2, ..., 10 minutes (in `i` minutes)
   mgrAlarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                SystemClock.elapsedRealtime() + 60000 * i,
                pendingIntent);

   intentArray.add(pendingIntent);
}


text:
Q: In Angular, is there a way to import and use external libraries downloaded with npm within component scope? I am trying to import and use https://github.com/zefoy/ngx-color-picker as the color picker as the default Angular color picker only allows rgb and does not intake the alpha value in the rgba.
Currently, I'm trying to use it within page that is at a component scope. I did do some research and it was suggested to be imported and used with @ngModule which is a module, but I am currently finding a method to import it within the component html page where @component is used as the project that I'm working on is not my own project and I have limitation changing the overall architecture of the project.
import { Component, OnInit } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { HeaderNavigationItem } from 'src/app/shared/models/headerNavigationItem';
import { CacheService } from 'src/app/shared/services/cache.service';
import { CustomConfigDetailService } from 'src/app/shared/services/custom-config-detail.service';
import { HeaderNavigationTitleService } from 'src/app/shared/services/header-navigation-title.service';
import { LoaderService } from 'src/app/shared/services/loader.service';
import { environment } from 'src/environments/environment';
import { ColorPickerModule } from 'ngx-color-picker';

@Component({
  selector: 'app-maps-colorline',
  templateUrl: './maps-colorline.component.html',
  styleUrls: ['./maps-colorline.component.css'],
})

// @NgModule({
//   imports: [ColorPickerModule],
// })

Any help or other method would be greatly appreciated.
Thank you.


text:
Q: reading two variable values after decrypting I am working on "Forgot Password". I am trying to create a reset token with email + current_time. email is user login whilst code will check if time >= 5 minutes then this link will not work. Here is my code:
// preparing token email + time
Date now            = new Date();
String prepareToken = "?email="+email+"&tokenTime="+now.getTime();

// encrypt prepareToken value
Encryptor enc = new Encryptor();
resetToken    = enc.encrypt(resetToken);

The token will be sent as for example as http://domainname.com/ForgotPassword?resetToken=adj23498ljj238809802340823
Problem:
When user click it then I got as request parameter and obviously decrypt this parameter but how can I get email in one String +  time as another String
Please advise

A: If your issue is simply parsing the decoded String to get some sort of Map of your parameters, I'd suggest you to read Parse a URI String into Name-Value Collection .
Hope it helps.
EDIT :
Assuming you have the splitQuery(URL url) method from the previous link and that you successfully decoded the token :
public String getEmailFromToken(String decodedToken) {
        // if you decoded your token it will looks like the prepareToken String
        String stubUrl = "http://localhost"+decodedToken;
        Map<String,String> map = splitQuery(new URL(stubUrl));
        return map.get("timeToken");
    }

I created a properly formed URL to respect the URL syntax.
With little tweak, you should be able to implement splitQuery for a String. I hope you can manage that.


text:
Q: Dynamic ROOT With SQL Server For JSON PATH I have a keyword table that I want to render to a Json object:
ID  Keyword     Text    Value
4   Category    A       10
5   Category    B       20
1   Season      Winter  1
2   Season      Spring  2
3   Season      Summer  3
9   Season      Fall    4
6   UnitType    Ft      Feet
7   UnitType    Set     Set
8   UnitType    $   Dollar

that groups each category into it's own object.
I've being able to create this:
{"Keywords":[
{"Keyword":"Category","Values":[{"Value":"10","Text":"A"},{"Value":"20","Text":"B"}]},
{"Keyword":"Season","Values":[{"Value":"1","Text":"Winter"},{"Value":"2","Text":"Spring"},{"Value":"3","Text":"Summer"},{"Value":"4","Text":"Fall"}]},
{"Keyword":"UnitType","Values":[{"Value":"Dollar","Text":"$"},{"Value":"Feet","Text":"Ft"},{"Value":"Set","Text":"Set"}]}
]}

using:
SELECT T.Keyword AS 'Keyword',
(SELECT [subT].[Value] AS 'Value', [subT].[Text] AS 'Text'
FROM tblKeywords subT WHERE subT.Keyword=T.Keyword
ORDER BY [subT].[Value]
FOR JSON PATH) AS 'Values'
FROM tblKeywords T
GROUP BY T.Keyword
FOR JSON PATH, ROOT('Keywords')

But I'd like to be able to set the ROOT for the sub query to be keyword itself. Is this even possible?
The desired result is:
{"Keywords":[
{"Category":[{"Value":"10","Text":"A"},{"Value":"20","Text":"B"}]},
{"Season":[{"Value":"1","Text":"Winter"},{"Value":"2","Text":"Spring"},{"Value":"3","Text":"Summer"},{"Value":"4","Text":"Fall"}]},
{"UnitType":[{"Value":"Dollar","Text":"$"},{"Value":"Feet","Text":"Ft"},{"Value":"Set","Text":"Set"}]}
]}

A: Initial data:
DROP TABLE IF EXISTS #tblKeywords;
CREATE TABLE #tblKeywords (ID INT, Keyword NVARCHAR(255), [Text] NVARCHAR(255), Value NVARCHAR(255));
INSERT INTO #tblKeywords(ID,Keyword,Text,[Value])VALUES
     (4,'Category','A','10')
    ,(5,'Category','B','20')
    ,(1,'Season','Winter','1')
    ,(2,'Season','Spring','2')
    ,(3,'Season','Summer','3')
    ,(9,'Season','Fall','4')
    ,(6,'UnitType','Ft','Feet')
    ,(7,'UnitType','Set','Set')
    ,(8,'UnitType','$','Dollar')
;

I know, Dynamic SQL, however:
DECLARE @DynSql NVARCHAR(MAX) = (
    SELECT 'SELECT ' + STUFF((
            SELECT DISTINCT N',(SELECT [subT].[Value] AS [Value], [subT].[Text] AS [Text]
            FROM #tblKeywords subT
            WHERE subT.Keyword = ''' + t.Keyword + N'''
            ORDER BY [subT].[Value]
            FOR JSON PATH
            ) AS [' + t.Keyword + N']' + CHAR(13) + '   '
            FROM #tblKeywords t
            FOR XML PATH(''),TYPE).value('(./text())[1]','NVARCHAR(MAX)'),1,1,'')
        + 'FOR JSON PATH, ROOT(''Keywords'')'
)
;
--PRINT @DynSql;
EXEC (@DynSql);

A: Another possible approach using combination of FOR JSON and string manipulation, but without dynamic statement:
Input:
CREATE TABLE #tblKeywords (
   Id int,
   [Keyword] nvarchar(50),
   [Text] nvarchar(50),
   [Value] nvarchar(50)
);
INSERT INTO #tblKeywords
   (ID, [Keyword], [Text], [Value])
VALUES
   (4, 'Category', 'A',      '10'),
   (5, 'Category', 'B',      '20'),
   (1, 'Season',   'Winter', '1'),
   (2, 'Season',   'Spring', '2'),
   (3, 'Season',   'Summer', '3'),
   (9, 'Season',   'Fall',   '4'),
   (6, 'UnitType', 'Ft',     'Feet'),
   (7, 'UnitType', 'Set',    'Set'),
   (8, 'UnitType', '$',      'Dollar')

T-SQL:
SELECT CONCAT(
   N'{"Keywords":[',
   STUFF(
      (
      SELECT DISTINCT CONCAT(N',{"', k.[Keyword], '":', c.[Json], N'}')
      FROM #tblKeywords k
      CROSS APPLY (
         SELECT [Value], [Text]
         FROM #tblKeywords
         WHERE [Keyword] = k.[Keyword]
         FOR JSON PATH
      ) c([Json])
      FOR XML PATH('')
      ), 1, 1, N''
   ),
   N']}'
) AS JsonOutput

Output:
JsonOutput

{"Keywords":[{"Category":[{"Value":"10","Text":"A"},{"Value":"20","Text":"B"}]},{"Season":[{"Value":"1","Text":"Winter"},{"Value":"2","Text":"Spring"},{"Value":"3","Text":"Summer"},{"Value":"4","Text":"Fall"}]},{"UnitType":[{"Value":"Feet","Text":"Ft"},{"Value":"Set","Text":"Set"},{"Value":"Dollar","Text":"$"}]}]}


text:
Q: Simplify boolean expression to minimum number of literals Problem is to simplify this boolean expression:
$(a+b+c')(a'b'+c)$
I expanded it out and simplified to get to $a'b'c' + c(a+b)$ but that doesn't reduce the number of literals. Tried everything I could think of but I must be missing something...

A: How is this?

Found using Logic Friday 1.


text:
Q: How do you retrieve mean values from a `gmdistribution` object? Running the function:
obj = gmdistribution.fit(X,n)

outputs an obj of class gmdistribution. However, I would like to output an n x 1 matrix of means, what commands should I use?

A: From the gmdistribution object - obj, you can get the nx1 mean vector by simply referencing that field as follows:
meanVector=obj.mu;


text:
Q: mongoose /node.js - update an object inside a dynamic array I have the following MongoDB collection:
user: "user123",
array1 = [
     {
     id: 1,
     active: true
     },
     {
     id: 2,
     active: true
     }
],
array2 = [
     {
     id: 3,
     active: true
     },
     {
     id: 4,
     active: true
     }
],
array3 = [
     {
     id: 5,
     active: true
     },
     {
     id: 6,
     active: true
     }
]

i need to update active to be false.
i am given the user, the array to update and also the id dynamically from the client.
so lets say for example i have following variables
let arrayToUpdate = 'array1'
let idToUpdate = 2
let user = 'user123'

according to mongoose docs i need to use the following method:
   const query = { user: user, "arrayToUpdate.id": idToUpdate}; //the problem is here
    const updateDocument = {
      $set: { "arrayToUpdate.$.active": "false" }
    };
    const result = await AutoUsersPositions.updateOne(query, updateDocument);

my problem is that the 2nd arguemnt of the query (arrayToUpdate.id) have to be inside "" which means i cant use it dynamically. i tried using ${} but it didnt work.
the same problem might be happening also on the $set part.
any solution?

A: Here is a simple way to generate dynamic key names, you just need to define the string first:
const arrayUpdateKey = `arrayToUpdate.${id}`
const query = { user: user, [arrayUpdateKey]: idToUpdate};


text:
Q: i have three places for users to log in, on the same page, how can i get all three buttons to work and three forms to process within one function so i have three seperate login forms located on three different locations on the same page and i wantn to know how i can do this login process without having to write out three different forms and functions,  all three do the same thing but they are all in different areas, here is the example. this code works, but i have also $div2 and $div3 which are also login forms on the same page.
$div1 = "

        log in

        log in!

    <form id=\"loginform1\" onsubmit=\"return false;\">
        <input type=\"text\" id=\"emaill\" placeholder=\"  enter email address\" onfocus=\"emptyElement('statusl')\" maxlength=\"88\">
        <input type=\"password\" id=\"passwordl\" placeholder=\"  enter password\" onfocus=\"emptyElement('statusl')\" maxlength=\"100\">
        <button id=\"loginbtn\" onclick=\"login()\">log in</button>

        forgot your password?
    </form>

";

function login(){
    var el = _("emaill").value;
    var pl = _("passwordl").value;
    if(el == "" || pl == ""){
        _("statusl").innerHTML = "
please complete the form";
    } else {
        _("loginbtn").style.display = "none";
        _("statusl").innerHTML = 'please wait...';
        var ajax = ajaxObj("POST", "login.php");
        ajax.onreadystatechange = function() {
            if(ajaxReturn(ajax) == true) {
                if(ajax.responseText == "login_failed"){
                    _("statusl").innerHTML = "login was unsuccessful, please try again.";
                    _("loginbtn").style.display = "block";
                } else {
                    location.reload();
                }
            }
        }
        ajax.send("el="+el+"&pl="+pl);
    }
}

A: In the login button's onclick="login()" attribute, you can input a function parameter like this:
onclick="login(1)" where 1 can be a unique number for each form, ie. $div1 has onclick="login(1)", $div2 has onclick="login(2)" etc...
You can then add the parameter to the login function:
function login(formNum) {...}
and then get the corresponding email and password for that form like this:
var el = _("emaill" + formNum).value;
var pl = _("passwordl" + formNum).value;
...

Of course you would need to change the email and password inputs' ids to include their corresponding form number like this:
<input type="text" id="emaill1" ...> for $div1, <input type="text" id="emaill2" ...> for $div2...
And also the forms', login buttons' and status paragraphs' ids in the same fashion.
In the end it would look something like this:
In Div1:
<form id="loginform1" onsubmit="return false;">
    <input type="text" id="email1" placeholder="  enter email address" onfocus="emptyElement('statusl1')" maxlength="88">
    <input type="password" id="passwordl1" placeholder="  enter password" onfocus="emptyElement('statusl1')" maxlength="100">
    <button id="loginbtn1" onclick="login(1)">log in</button>

    forgot your password?
</form>

In Div2:
<form id="loginform2" onsubmit="return false;">
    <input type="text" id="email2" placeholder="  enter email address" onfocus="emptyElement('statusl2')" maxlength="88">
    <input type="password" id="passwordl2" placeholder="  enter password" onfocus="emptyElement('statusl2')" maxlength="100">
    <button id="loginbtn2" onclick="login(2)">log in</button>

    forgot your password?
</form>

In Div3:
<form id="loginform3" onsubmit="return false;">
    <input type="text" id="email3" placeholder="  enter email address" onfocus="emptyElement('statusl3')" maxlength="88">
    <input type="password" id="passwordl3" placeholder="  enter password" onfocus="emptyElement('statusl3')" maxlength="100">
    <button id="loginbtn3" onclick="login(3)">log in</button>

    forgot your password?
</form>

And Javascript:
function login(formNum){
    var el = _("emaill" + fornNum).value;
    var pl = _("passwordl" + fornNum).value;
    if(el == "" || pl == ""){
        _("statusl" + fornNum).innerHTML = "
please complete the form";
    } else {
        _("loginbtn" + fornNum).style.display = "none";
        _("statusl" + fornNum).innerHTML = 'please wait...';
        var ajax = ajaxObj("POST", "login.php");
        ajax.onreadystatechange = function() {
            if(ajaxReturn(ajax) == true) {
                if(ajax.responseText == "login_failed"){
                    _("statusl" + fornNum).innerHTML = "login was unsuccessful, please try again.";
                    _("loginbtn" + fornNum).style.display = "block";
                } else {
                    location.reload();
                }
            }
        }
        ajax.send("el="+el+"&pl="+pl);
    }
}


text:
Q: How to sort a list in order of weekdays in python? I have a list of tuples witch looks like this:
lst = [(2921, 'string', 1, 1, 7), (2922, 'string', 2, 1, 1), (2923, 'string', 3, 1, 4),
        (2924, 'string', 4, 2, 2), (2925, 'string', 5, 2, 3), (2926, 'string', 6, 2, 5),
        (2927, 'string', 7, 2, 3), (2928, 'string', 8, 3, 4), (2929, 'string', 9, 3, 4),
        (2930, 'string', 10, 3, 5), (2931, 'string', 11, 3, 5), (2932, 'string', 12, 4, 6),
        (2933, 'string', 13, 4, 6), (2934, 'string', 14, 4, 7), (2935, 'string', 15, 7, 1),
        (2936, 'string', 16, 5, 1), (2937, 'string', 17, 5, 2)]

The last element (fifth item) in each tuple corresponds to the day of the week numbered 1 thru 7.
I would to sort the list so that the resulting tuples cycle through the days of the week in ascending order as follows:

*

*Select the first tuple with 1, then first with 2, until 7 (skip number if no tuple with that number)

*Select the second tuple with 2, then the second with 3, until reach 7 again.

*Continue this cycling process (i.e. of first, second, third, etc.) until out of tuples.

Desired Output:
(2922, 'string', 2, 1, 1)
(2924, 'string', 4, 2, 2)
(2925, 'string', 5, 2, 3)
(2923, 'string', 3, 1, 4)
(2926, 'string', 6, 2, 5)
(2932, 'string', 12, 4, 6)
(2921, 'string', 1, 1, 7)
(2935, 'string', 15, 7, 1)
(2937, 'string', 17, 5, 2)
(2927, 'string', 7, 2, 3)
(2928, 'string', 8, 3, 4)
(2930, 'string', 10, 3, 5)
(2933, 'string', 13, 4, 6)
(2934, 'string', 14, 4, 7)
(2936, 'string', 16, 5, 1)
(2929, 'string', 9, 3, 4)
(2931, 'string', 11, 3, 5)

I tried to do it with custom sort function, but it is not working as I need:
days = [1, 2, 3, 4, 5, 6, 7]

sorted_list = sorted(list, key=lambda x: (x[4], days.index))

for i in sorted_list:
    print(i)

Maybe 'sorting' isn't actually the right term for it.. anyway I want to order the list elements based on the fifth element of the tuples. And I want to order them like weekdays: from Monday to Sunday and after Sunday comes Monday again. So, 1 to 7 and then again 1 to 7. Like this: 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2 ...
not 1, 1, 2, 2, 2, 3, 3 ...

A: Dict object is one of the data-structure to solve this problem. Check out this code:
list_ = [(2921, 'string', 1, 1, 7), (2922, 'string', 2, 1, 1), (2923, 'string', 3, 1, 4),
        (2924, 'string', 4, 2, 2), (2925, 'string', 5, 2, 3), (2926, 'string', 6, 2, 5),
        (2927, 'string', 7, 2, 3), (2928, 'string', 8, 3, 4), (2929, 'string', 9, 3, 4),
        (2930, 'string', 10, 3, 5), (2931, 'string', 11, 3, 5), (2932, 'string', 12, 4, 6),
        (2933, 'string', 13, 4, 6), (2934, 'string', 14, 4, 7), (2935, 'string', 15, 7, 1),
        (2936, 'string', 16, 5, 1), (2937, 'string', 17, 5, 2)]

days = [1, 2, 3, 4, 5, 6, 7]

dict_sort_ = {f'{i}':[j for j in list_ if j[-1] == i] for i in days}

condn = True
day = 1
while  condn:
    try:
        print(dict_sort_[str(day)][0])
        dict_sort_[str(day)].pop(0)
        if day >= 7:
            day %= 7
    except:
        continue
    finally:
        day += 1
    if all([True if len(dict_sort_[i])==0 else False for i in dict_sort_]):
        condn = False

OUTPUT:
(2922, 'string', 2, 1, 1)
(2924, 'string', 4, 2, 2)
(2925, 'string', 5, 2, 3)
(2923, 'string', 3, 1, 4)
(2926, 'string', 6, 2, 5)
(2932, 'string', 12, 4, 6)
(2921, 'string', 1, 1, 7)
(2935, 'string', 15, 7, 1)
(2937, 'string', 17, 5, 2)
(2927, 'string', 7, 2, 3)
(2928, 'string', 8, 3, 4)
(2930, 'string', 10, 3, 5)
(2933, 'string', 13, 4, 6)
(2934, 'string', 14, 4, 7)
(2936, 'string', 16, 5, 1)
(2929, 'string', 9, 3, 4)
(2931, 'string', 11, 3, 5)


text:
Q: How to Mock the Property File in Junit I am creating a Unit test case using Junit . Now My application is Maven Based with many profile Also I am using the Values from configuration file (Property File ) which Varies from one profile to other. I want that Unit Test run will have specified properties only not the profile one when it is running the test cases.
These can be done in 2 ways
1) Either i Mock the Property File for Unit Test .( which i dont know How) .
2) Or during run time i change the property file parameter values.(Again difficult to answer) . Any help will be appreciated .

A: One option: use dependency injection in order to acquire a java.util.Properties object for example.
Meaning: your production code simply holds a Properties object; like:
class Foo {
  private final Properties properties;

  public Foo(Properties) {
    this.properties = properties;

At runtime, when the class that creates Foo objects reads property files from disk, turns them into a Properties object and gives it to the Foo constructor.
In your unit test, your test code creates a Properties object and adds whatever values you require upon creating a Foo object.
The less elegant detour: make sure that your production code reads its properties from a location that gets defined at runtime. That would allow you to create custom property files in some temp directory, and then  you instruct your code under test to work with those files.

A: Did not got your question exactly - In one side, you are saying: you don't want to use profile related values and other side you are saying: you'll need to run with specific values (do you mean runtime values or test specific values).
Now, To answer your 1st question:
1) Either i Mock the Property File for Unit Test:
you can instantiate and load a property file(test specific) and keep the required values there in that file.
2) Or during run time i change the property file parameter values:
you can mock specific property keys with values. like below:
 public void shouldBuyBread() throws Exception {
    //given
    given(mypropertyUtil.getProperty("NUMBER_OF_BREADS")).willReturn(10);

    //when
    Goods goods = shop.buyBread();

    //then
    assertThat(goods, containBread());
  }


text:
Q: Don't order by attribute I have DB, consists of 2 tables:
**Job**
     job_id (int, primary key),
     job_nm (nchar(50))

**Employee**
     empl_id (int, primary key)
     job_id (int, forein key) (one-to-many)
     first_name (nchar(50))
     last_name (nchar(50))
     salary (float)

I output the table by pages (5 rows by page).
It realize:
ViewBag.Tab = (from employee in db.Employees
               join job in db.Jobs on employee.job_id equals job.job_id
               where job.job_nm == sel1
               orderby employee.salary
               select employee
              ).Skip(pageSize * pageNum)
               .Take(pageSize)
               .ToList();

But I have unsorted by "salary"-field list.
I tried this code:
ViewBag.Tab = (from employee in db.Employees
               join job in db.Jobs
               on employee.job_id equals job.job_id
               where job.job_nm == sel1
               orderby employee.salary
               select employee
              ).Skip(pageSize * pageNum)
               .Take(pageSize)
               .ToList()
               .OrderBy(s => s.salary);

but it haven't result.
What did I do wrong?

A: The OrderBy needs to come before the Skip and Take. Other wise you are just going to order your small result set.
Try:
ViewBag.Tab = (from employee in db.Employees
               join job in db.Jobs
               on employee.job_id equals job.job_id
               where job.job_nm == sel1
               orderby employee.salary
               select employee
              ).OrderBy(s => s.salary)
               .Skip(pageSize * pageNum)
               .Take(pageSize)
               .ToList();


text:
Q: How to disable the search filtering option in Magento store In my magento store I would like to disable the filtering option from the left pane (see attachment below). I don't want the filtering option to be there. How could I achieve that through admin panel?
I would appreciate if anyone could help.

A: In the admin Panel :
1- go under Catalog => Categories
2- choose category
3- In the "Display Settings" section disable "Anchor" :


text:
Q: Shopping cart in rails via book Via such book:

Agile Web Development with Rails

i'm creating shopping cart for my application. There is such code:
class Cart < ActiveRecord::Base
    attr_accessible :id
    has_many :line_items, dependent: :destroy

  def add_article(article_id)
    current_item = line_items.find_by_ART_ID(article_id)
      if current_item
      current_item.quantity += 1
      else
      current_item = line_items.build(ART_ID: article_id)
      end
    current_item
  end
  def total_price
    line_items.to_a.sum { |item| item.total_price(item.ART_ID) }
  end
  def total_count
    line_items.to_a.sum { |item| item.quantity }
  end

end

On my previous project on rails 3.0.9 all was ok, but now it's say that

nil can't be coerced into Fixnum
  in db, quantity is null

if i change my code for like this
current_item = line_items.find_by_ART_ID(article_id)
          if current_item
          current_item.quantity = 1
          else
          current_item = line_items.build(ART_ID: article_id)
          current_item.quntity = 1
          end
        current_item

all is good, but what's wrong? why rails 3.2.6 and ruby 1.9.3 don't understand my += assignments?

A: Its not a problem with += , the problem is you are try to do this with your code.
nil + 1

quantity is nil for the first time.


text:
Q: Nautilus how filter every files by extension I want to filter every mp3 files in certain folder and its sub-folders. I typed *.mp3 in the search box but it is not working.

A: Press Ctrl+S.
In the appearing dialog you can enter a regex, such as *.mp3, in order to select all matching file names in the folder itself.

A: You can search/find.
Press Ctrl+F and enter the extension, like .ogg and all the files with the extension .ogg will be shown, depending on the directories you search in.
It's not quite what you asked for, but it's as close as I can think of.


text:
Q: Comparing a specific set of numbers I have a google spreadsheet that has 6 cells with specific numbers in them.  Every week, a series of numbers is entered in and I would like to flag the numbers in a separate column if they appear for that week.  I was using the formula below where my numbers are in D2->I2 and the weekly ones would be in D18->I18 for example.
=arrayformula(sumproduct((D2:I2=D18:I18)))

Now, while this works, it's not quite what I'm trying to do.  Unless the numbers match each other exactly, 1 2 3 4 5 6 to 1 2 3 4 5 6 then the addition doesn't happen.  What I would like to have happen is that if, for example, the master column has 1 2 3 4 5 6 and the weekly column has 3 7 9 1 8 5 then the cell with the formula would display the value of 3 for matching three of the numbers that week.
Does anyone have a suggestion on how best to accomplish this?

A: See if this works ?
=ArrayFormula(sum(--regexmatch(D2:I2&"", join("|", D18:I18&""))))

with exclusion of empty cells in both ranges:
=iferror(ArrayFormula(sum(--regexmatch(to_text(filter(D2:I2, len(D2:I2))), "\b("&join("|", to_text(filter(D18:I18, len(D18:I18))))&")\b"))))


text:
Q: system file, read write o create custom metadata or attributes extended :
I am looking for a way to read, write or create (custom) tags, extended attributes or metadata from any file. Without libraries and language c or c + +. I think I can be with fopen, fread, fwrite, but not how to access the metadata.
Thanks in advance,

A: The Linux system calls for manipulating extended attributes are setxattr, getxattr, and remotexattr. This program might do what you are asking for:
// UNTESTED
#include <sys/types.h>
#include <sys/xattr.h>
#include <cstring>
#include <cstdio>

int main () {
  const char* file = "/work/a.txt";
  const char* attr = "user.MyAttr";
  const char* value = "MyValue";
  int rc = setxattr(file, attr, value, strlen(value), 0);
  if(rc < 0)
    perror(file);
  return !!rc;
}


text:
Q: MongoDB Schema for multiple user types There are three different user types in my application.
1.Creator
2.Company
3.Admin
The fields will be almost same for all the three,except there wont be full name for company.But there will be company name field.
 id: string;
 email: string;
 phone: string;
 password: string;
 user_type: string;
 full_name: string;
 company_name:string

Should I follow the same schema with single collection or 3 different collections for each user type ?

A: In my experience, in situations like this it is usually better in the long term to stick with a single collection and then differentiate via queries. This allows you to easily add additional user types in the future (that you do not foresee now) without requiring adding more collections.


text:
Q: Google AutoML projects visibility I have two google account (one private and one for business).
If I log in to my business account and navigate to AutoML I do land on the 'Specify Google Cloud project'. That's right. But when I want do select the associated GCP project the list that appears includes all projects that are part of my private google account.
I deleted all cookies, closed the browser and startet to log in (only to my business account) again -> the same happens again.
That's weird.
Do anyone else have this kind of behaviour? I don't see any connection between my private and my business account. Why do this happen?
I did not add any extra priviledges to the GPC project inside my private account.

A: Can you try signing out of the AutoML UI? This is a multi-login issue related to the credentials used when you first logged into AutoML.


text:
Q: Reinforcement Learning (Using Tensorflow and a Matlab Env) I coupled a RL agent with a environment which is implemted in matlab.
So I let the python script (using tensorflow V2) run, write a txt file with the actions and call the matlab environment via system command. In matlab the txt file is read, then the calculation is carried out in matlab and a result txt file is written. This txt file is then read by python, and the py script runs further.
That works, however the calculation times are relative long, one step takes between 9 and 13 seconds, although the matlab calculation need only about 1.5 -2 seconds. Therefore the training time is very high which is very annoying.
Unfortunately you can't rewrite the environment to Python, would be too much work and compiling to c++ would also be rather difficult.
Is there nevertheless a better way?
Does anyone have an idea how to improve that?
Is there any interface between python and matlab which could help here?
Thanks in advance!
Best
Chris

A: I would try calling matlab from python using subprocess and setting up a stdin/out pipe. You can read all about that here or here. Writing into and reading from files (depending on your OS of course, but generally) takes much, much more time than piping data between processes. Feel free to read up on IPC (Inter Process Communication), in my opinion, stdio is the best choice for you.


text:
Q: pushing multiple values in getData() implementation for facebook insights connector I'm writing a facebook insights connector to use in google data studio but i cannot find the right way to process the response when using the metric page_fans_city in the request. The returned data has the following format:
{
  "data": [
    {
      "name": "page_fans_city",
      "period": "lifetime",
      "values": [
        {
          "value": {
            "Ancona, Marche, Italy": 61,
            "Arezzo, Tuscany, Italy": 42,
            "Bari, Puglia, Italy": 362,
            "Bergamo, Lombardia, Italy": 48,
            "Bologna, Emilia-Romagna, Italy": 388,
            "Brescia, Lombardia, Italy": 103,
            "Cagliari, Sardinia, Italy": 145,
            "Caserta, Campania, Italy": 64,
            "Catania, Sicilia, Italy": 272,
            "Ferrara, Emilia-Romagna, Italy": 50,
            ...
          },
          "end_time": "2017-11-13T08:00:00+0000"
        },
...
}

as you can see the "value" is not a single item (number or string) but is an object. My data schema includes:
  {
    name: 'city_name',
    label: 'City',
    dataType: 'STRING',
    semantics: {
      conceptType: 'DIMENSION'
    }
  },
  {
    name: 'city_likes',
    label: 'Likes per City',
    dataType: 'NUMBER',
    semantics: {
      conceptType: 'METRIC'
    }
  }

In my getData(request) function implementation i need to push all the pairs city name - likes for every day in a specifc time range, so i wrote:
case 'city_name':
  var dataObj = response.data[1].values[0].value;
  var objKeys = Object.keys(dataObj);
  //pushing all the keys
  for (var n=0; n<objKeys.length; n++) {
    values.push(objKeys[n]);
  }
  break;

case 'city_likes':
  var dataObj = response.data[1].values[0].value;
  var objKeys = Object.keys(dataObj);
  //pushing all the values
  for (var n=0; n<objKeys.length; n++) {
    values.push(dataObj[objKeys[n]]);
  }
  break;

but i get a system error on the data studio dashboard if i use these dimension/metric to build a table for example. Does anyone know the correct way to manage this scenario? Maybe the schema has to be different?
Thanks in advance.
update
this is what i'm currently sending:
{
    schema=
    [
        {
            dataType=NUMBER,
            name=city_likes,
            label=Likes per City,
            semantics=
            {
                conceptType=METRIC
            }
        },
        {
            dataType=STRING,
            name=city_name,
            label=City,
            semantics=
            {
                conceptType=DIMENSION
            }
        }
    ],
    rows=
    [
        {
            values=[62, 326, 78, 396, 130, 179, 73, 248, 48, 65, 450, 80, 47, 277, 57, 83, 85, 87, 82, 2065, 88, 901, 144, 466, 87, 140, 53, 102, 63, 89, 56, 81, 94, 85, 1992, 88, 71, 52, 98, 631, 50, 212, 164, 55, 49, Ancona, Bari, Bergamo, Bologna, Brescia, Cagliari, Caserta, Catania, Como, Ferrara, Florence, Foggia, Forlì, Genova, La Spezia, Lecce, Livorno, Lucca, Messina, Milan, Modena, Naples, Padua, Palermo, Parma, Perugia, Pesaro, Pescara, Pisa, Prato, Ravenna, Reggio di Calabria, Reggio nell Emilia, Rimini, Rome, Sassari, Taranto, Terni, Trieste, Turin, Udine, Venice, Verona, Vicenza, Vietri sul Mare]
        }
    ]
}

any ideas?

A: Your response should look more like this:
{
schema=
[
    {
        dataType=NUMBER,
        name=city_likes,
        label=Likes per City,
        semantics=
        {
            conceptType=METRIC
        }
    },
    {
        dataType=STRING,
        name=city_name,
        label=City,
        semantics=
        {
            conceptType=DIMENSION
        }
    }
],
rows=
[
  {
    "values": [62, "Ancona"]
  },
  {
    "values": [326, "Bari"]
  },
  {
    "values": [78, "Bergamo"]
  },
  {
    "values": [396, "Bologna"]
  },
...
]
}


text:
Q: Bootstrap's contextual colors Why and when do web developers use Bootstrap's contextual colors?
What's the point of primary, success, info, warning, danger classes if they already have colors assigned to them?

A: They are for precisely what they say on the tin. When presenting the user with an alert for example, those colours convey the type of message being displayed.
https://v4-alpha.getbootstrap.com/components/alerts/
They are, of course, open to modification. You're free to set the colours you choose.


text:
Q: An invalid argument was supplied in socket programming I want to create a UDP client and server in C# and when I run those, after first send and receive message, this error implement. My code is:
byte[] barray = new byte[1024];
EndPoint ipre = new IPEndPoint(IPAddress.Any, 4040);
socketClint.Bind((IPEndPoint)ipre);
int rc = socketClint.ReceiveFrom(barray, ref ipre);

if (rc > 0)
{
    listBox1.Items.Add("Server: "+ BitConverter.ToInt32(barray,0));
}

This error is about socketClint.Bind((IPEndPoint)ipre); line.
the Error is:
System.Net.Sockets.SocketException was unhandled
HResult=-2147467259
Message=An invalid argument was supplied
Source=System
ErrorCode=10022
NativeErrorCode=10022
StackTrace:
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at client1.Form1.getmsg() in c:\Users\Inspiron 1545\Desktop\UDP\client1\client1\Form1.cs:line 38
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

InnerException:

A: Winsock error 10022 is WSAEINVAL:

WSAEINVAL
  10022
Invalid argument.
  Some invalid argument was supplied (for example, specifying an invalid level to the setsockopt function). In some instances, it also refers to the current state of the socket — for instance, calling accept on a socket that is not listening.

In the context of the Winsock bind() function (which Socket.Bind() uses internally), it means this:

WSAEINVAL
An invalid argument was supplied.
This error is returned if the socket s is already bound to an address.

Once a socket has been bound to a local address, you can't re-bind it to a new local address.  You are supposed to bind it only one time.
So, in your case, call Bind() after creating socketClint only. Do not call it before every call to socketClint.ReceiveFrom().


text:
Q: Manually assigning colors with scale_fill_manual only works for certain hexagon sizes I am trying to create a scatterplot that is summarized by hexagon bins of counts. I would like the user to be able to define the count breaks for the color scale. I have this working, using scale_fill_manual(). Oddly, however, it only works sometimes. In the MWE below, using the given seed value, if xbins=10, there are issues resulting in a plot as follows:

However, if xbins=20 or 40, for example, the plot doesn't seem to have problems:

My MWE is as follows:
library(ggplot2)
library(hexbin)
library(RColorBrewer)

set.seed(1)
xbins <- 20

x <- abs(rnorm(10000))
y <- abs(rnorm(10000))
minVal <- min(x, y)
maxVal <- max(x, y)
maxRange <- c(minVal, maxVal)
buffer <- (maxRange[2] - maxRange[1]) / (xbins / 2)
h <- hexbin(x = x, y = y, xbins = xbins, shape = 1, IDs = TRUE,
            xbnds = maxRange, ybnds = maxRange)
hexdf <- data.frame (hcell2xy(h),  hexID = h@cell, counts = h@count)
my_breaks <- c(2, 4, 6, 8, 20, 1000)
clrs <- brewer.pal(length(my_breaks) + 3, "Blues")
clrs <- clrs[3:length(clrs)]
hexdf$countColor <- cut(hexdf$counts, breaks = c(0, my_breaks, Inf),
                        labels = rev(clrs))

ggplot(hexdf, aes(x = x, y = y, hexID = hexID, fill = countColor)) +
  scale_fill_manual(values = levels(hexdf$countColor)) +
  geom_hex(stat = "identity") +
  geom_abline(intercept = 0, color = "red", size = 0.25) +
  coord_fixed(xlim = c(-0.5, (maxRange[2] + buffer)),
              ylim = c(-0.5, (maxRange[2] + buffer))) +
  theme(aspect.ratio=1)

My goal is to tweak this code so that the plot does not have problems (where suddenly certain hexagons are different sizes and shapes than the rest) regardless of the value assigned to xbins. However, I am puzzled what may be causing this problem for certain xbins values. Any advice would be greatly appreciated.
EDIT:
I am updating the example code after taking into account comments by @bdemarest and @Axeman. I followed the most popular answer in the link @Axeman recommends, and believe it is more useful when you are working with scale_fill_continuous() on an integer vector. Here, I am working on scale_fill_manual() on a factor vector. As a result, I am still unable to get this goal to work. Thank you.
library(ggplot2)
library(hexbin)
library(RColorBrewer)

set.seed(1)
xbins <- 10

x <- abs(rnorm(10000))
y <- abs(rnorm(10000))
minVal <- min(x, y)
maxVal <- max(x, y)
maxRange <- c(minVal, maxVal)
buffer <- (maxRange[2] - maxRange[1]) / (xbins / 2)
bindata = data.frame(x=x,y=y,factor=as.factor(1))

h <- hexbin(bindata, xbins = xbins, IDs = TRUE, xbnds = maxRange, ybnds = maxRange)

counts <- hexTapply (h, bindata$factor, table)
counts <- t (simplify2array (counts))
counts <- melt (counts)
colnames (counts)  <- c ("factor", "ID", "counts")
counts$factor =as.factor(counts$factor)

hexdf <- data.frame (hcell2xy (h),  ID = h@cell)
hexdf <- merge (counts, hexdf)

my_breaks <- c(2, 4, 6, 8, 20, 1000)
clrs <- brewer.pal(length(my_breaks) + 3, "Blues")
clrs <- clrs[3:length(clrs)]
hexdf$countColor <- cut(hexdf$counts, breaks = c(0, my_breaks, Inf), labels = rev(clrs))

ggplot(hexdf, aes(x = x, y = y, fill = countColor)) +
  scale_fill_manual(values = levels(hexdf$countColor)) +
  geom_hex(stat = "identity") +
  geom_abline(intercept = 0, color = "red", size = 0.25) +
  coord_cartesian(xlim = c(-0.5, maxRange[2]+buffer), ylim = c(-0.5, maxRange[2]+ buffer)) + theme(aspect.ratio=1)

A: you can define colors in 'geom' instead of 'scale' that modifies the scale of plot:
ggplot(hexdf, aes(x = x, y = y)) +
geom_hex(stat = "identity",fill =hexdf$countColor)


text:
Q: Diagonal elements of the inverted correlation matrix Is it true that the diagonal elements of the inverted correlation matrix will always be larger than 1? Why?

A: Yes, it is true: the diagonal elements can never be less than unity.
By permuting the order of the variables, any diagonal element can be made to appear in the upper left corner, so it suffices to study that element.  The statement is trivially true for $n=1$.  For $n\gt 1$, any $n$ by $n$ correlation matrix can be written in block form as
$$\mathbb C = \pmatrix{ 1 & \mathbf {\vec e} \\ \mathbf e &\mathbb D}$$
where $\mathbb D$ is the correlation matrix of variables $2, 3, \ldots, n$ and $\mathbf {\vec e}$ is the transpose of the column vector $\mathbf e$ containing the correlations between the first variable and the remaining variables.
Assume for the moment that $\mathbb C$ is invertible.  By Cramer's Rule, the upper left corner of its inverse is
$$\left(\mathbb C^{-1}\right)_{11} = \det \mathbb D / \det \mathbb C.$$
If we can prove that this ratio cannot be less than $1$, we are done in the general case (even for singular $\mathbb C$), because the entries in the inverse are continuous functions of $\mathbb C$ and the non-invertible ones form a lower-dimensional submanifold of the space of all such $\mathbb C$.

The problem is reduced, then, to showing that determinants of invertible correlation matrices cannot increase as the number of variables is increased.  Invertibility of $\mathbb C$ implies $\mathbb D$ is invertible, enabling allows row-reduction to simplify the top row.  This will help us relate the determinant of $\mathbb C$ to that of $\mathbb D$.  Reduction of that row amounts to left-multiplication by the inverse of
$$\mathbb P = \pmatrix{ 1 & \mathbf {\vec e}\,\mathbb D ^{-1} \\ \mathbf 0 &\mathbf 1_{n-1,n-1}},$$
showing that
$$ \mathbb C = \mathbb P\pmatrix{ 1 - \mathbf {\vec e}\,\mathbb D ^{-1}\, \mathbf e &\mathbf {\vec 0} \\ \mathbf e &\mathbb D}.$$
Taking determinants yields
$$\det \mathbb C = \det \mathbb P \det \pmatrix{ 1 - \mathbf {\vec e}\,\mathbb D ^{-1} \,\mathbf e &\mathbf {\vec 0} \\ \mathbf e &\mathbb D} = \left( 1 - \mathbf {\vec e}\,\mathbb D ^{-1}\, \mathbf e \right)\det \mathbb D$$
because $\det \mathbb P = \det(1)\det \mathbf{1}_{n-1,n-1}=1$.
Since $\mathbb D$, being an invertible correlation matrix in its own right, is positive-definite, and $\mathbb C$ is positive definite, we immediately deduce that

*

*$\mathbf {\vec e}\,\mathbb D ^{-1}\, \mathbf e \ge 0$.

*$\det \mathbb D \gt 0$.

*$\det \mathbb C \gt 0$.
Therefore $1 \ge 1 - \mathbf {\vec e}\,\mathbb D ^{-1}\, \mathbf e \gt 0$, whence $\det \mathbb C \le \det \mathbb D$, QED.


text:
Q: Application crashes in windows 8.1 One of my windows application in [.net 3.5] is installed in windows 8.1, to upload images.
I open the application, and I am using a dll to browse the images present in local disk to select and upload them.
Once after browsing the selection of image is done, if I create a "New Folder" in my system, the application crashes - it gives me exception as :

a problem caused the program to stop working correctly.
    windows will close the program and notify...

I cross checked the event log, and here is a respective log added for the same :
Faulting application name: DesktopPhotoUploader.exe, version: 1.0.0.0, time stamp: 0x529f6471
Faulting module name: ntdll.dll, version: 6.3.9600.16408, time stamp: 0x523d5305
Exception code: 0xc0000374
Fault offset: 0x00000000000f387c
Faulting process id: 0x8d0
Faulting application start time: 0x01cf2c7f30046a99
Faulting application path: C:\Users\AppData\Local\Apps\2.0\7HWTE4KV.OXA\9K6HG17J.XZB\desk..tion_5f682daadb7f3a73_0002.0000_11d13f4927f45bcc\DesktopPhotoUploader.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
Report Id: 8ca29b6c-9872-11e3-8255-00219b71cec5
Faulting package full name:
Faulting package-relative application ID:

Please let me what can be a reason for this?

A: Exception 0xc0000374 is STATUS_HEAP_CORRUPTION. It indicates your application manipulates the heap in an incorrect way and corrupts it. Is a bug in your code. You can analyze the dump to understand the problem. I recommend you get a copy of Advanced Windows Debugging, it has ample chapters dedicated to heap corruption. A common technique is to use GFlags, see Detecting Heap Corruption Using GFlags and Dumps.


text:
Q: How to properly scale graph of highly disproprtionate matrix in matplotlib? I have a set of matrices I'm graphing with plt.matshow(matrix) and it works fine for matrices with dimensions that are close to each other (i.e. 56,000 x 5,000 or 64x6). However, when I try it with a 56,000x6 matrix, I just get a really large scale and no graph (See attached image), which I suspect is due to matplotlib not being sure how to scale the image. Does anyone know how to handle this?

A: you could use a logarithmic scale:
import matplotlib.pyplot as plt
import numpy as np

# dummy matrix:
a = np.arange(20000).reshape(10000, 2)

plt.matshow(a)
plt.yscale('log')

plt.show()

Alternatively, you can manually change the aspect of your plot:
plt.matshow(a)
plt.gca().set_aspect(0.0001)


text:
Q: Input File Format for NIST Test for Randomness I wish to check the randomness of the 32-bits numbers generated via. a random number generator. I have 1000 numbers of 32-bits each.
How should I create my ASCII file?
What is the value for the bitstream in .\assess bitstream command? Is it '1000*32' or '1000' or '32'?
Reference:
https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-22r1a.pdf

A: The individual tests (there are 15 different tests) that are conducted in NIST take a bit sequence and compute a P-value for this sequence which is used to decide randomness. Now, different tests have different lower limits for the sequence length (n). The minimum value for n ranges from 100 to 1,000,000 in the tests available on NIST.
So if you want to run a test, you need at least 100 bits in your sequence. And finally, you need multiple sequences for each test to decide randomness reliably (e.g., 100 or 1000 sequences each with n bits). All these sequences will be tested individually and the proportion of sequences that passed the tests will be reported at the end.
Here is an example. I have 100,000,000 (100M) bits randomly generated from some source. I run the NIST test dividing them into 100 sequences, each with 1,000,000 bits. Therefore, the NIST command in my case would be:
./assess 1000000
Later the program will put a prompt for the number of sequences and I will have to enter 100 there.
You can also use different lengths for different tests by running them separately.


text:
Q: What is the "input" being fed into a Delta-Sigma Modulator in a Fractional-N PLL? Are bits needed for a specific resolution at the input or output? I'm doing some reading into Fractional-N PLL design and I have a bit of conceptual confusion regarding a delta-sigma modulator used to toggle the modulus of a divider. If you're trying for a certain fractional frequency division, you want a the output to average at a specific value to, on average, divide by some non-integer value. This output is the input put through a Delta-Sigma modulator; if this average should be constant, shouldn't the input be constant?
In diagrams I often see the PLL Feedback fed into the delta-sigma modulator at some point, "fdivided" as seen in the example below.

Is "fdivided" in this case meant to be the frequency the DSM is oversampling by? (So if f_ref is 1MHz and fdivided is 1MHz, if the DSM's oversampling rate (OSR) is 8, then the sampling rate is 8MHz)?
When it's said a specific number of bits is needed for resolution on a divider, that's referring to the bits in the input, correct? So for a DC input, that is how precise that DC value can be (-0.5 and 0.5, or -.3, -.1, .1, .3, something of the like)? Textbooks I've read sometimes don't distinct if the bits needed is at the input (the "DC" value) or the output (i.e. the bits of the Quantizer, also related to the amount of moduli on the frequency divider).
Sorry these questions are a bit scattered, I'm just slightly confused conceptually on how some things have been phrased in various papers or textbooks.

A: It's far easier to think of a synthesiser as multiplying, whether a fractional synth, or an integer synth. For every cycle of fref, the synthesiser produces N cycles at the VCO, where N is the number being fed into the divider.
The operation of the VCO and loop filter averages the output frequency. The input N to the MMD is the output frequency we want in units of the fref. In an integer synthesiser, this input is static. To make it concrete, let's say we have a 1 MHz fref, and we're synthesising 40 MHz. N will be 40.
Let's take the most trivial case of fractional N synthesis, making an fref/2 step to give us 40.5 MHz. This fraction, 1/2, we'll refer to as the modulus, M. We can alternate the N value between 40 and 41 each fref cycle. The alternating behaviour at 500 kHz generates a phase modulation at a frequency of fref/M, which in this case will be completely filtered out by the PLL.
It's the job of the Delta Sigma Modulator to create a stream of numbers that has the average frequency we want to generate. Its input has enough bits to represent the output frequency we want. This is simplest if we code it as an integer number of fref/M, though we can also refer to it as fractional fref. This number is usually static. Its output is a stream of integers, one per fref clock cycle. It needs only enough bits to represent all values the divider can take, this is in integer units of fref.
If we now tried the same trick to synthesise 1 Hz steps, so a modulus of 10^6, we will run into practical problems. Although the average of 999,999 counts of 40 and one count of 41 is indeed 40.000001 MHz, the spurious phase modulation is now at 1 Hz. No practical PLL will use a loop bandwidth low enough to reject this modulation.
We need the DSM to generate a number stream with another property, that the phase modulation at low frequencies is small enough to meet the spurious specifications of the synthesiser.
Your use of the ADC tag, and the word 'quantiser' suggest you are looking at a particular implementation of a DSM. However, your question asks about the inputs and outputs of the DSM, and shows a block diagram with those marked.
There are several algorithms the DSM block can use, I know of at least 4 classes, and within each class there are many variations. Each class suppresses low frequency components in different ways. However, they all end up generating numbers from a larger range than just 40 and 41. The design of these algorithms is beyond the scope of this Q/A.
For instance, when synthesising 40.000001, the number stream might start 40, 40, 40, 41, 39, 40, 40, 40 ... in a second order DSM. That little +1/-1 twitch adds no average frequency, but it does even out the phase advance a little bit, rather than leaving a whole cycle of phase to be advanced at the end of one second, suppressing the 1 Hz phase modulation.
I'd recommend reading this patent for a fractional N synthesiser. It has a very clear description of the process. If you're not familiar with reading patents, ignore the claims, print out the diagrams, and read the description with the diagrams in hand.
Note the diagram you have used is a little misleading. The signal coming into the side of the DSM is simply fref, not 'some unspecified output from the PFD'.


text:
Q: Time lag of variables in Pandas What is the best way in Pandas to calculate a time lag of a list of variables within spatial units?
Let's say I have a Pandas dataframe that looks like this:
>>> MyData=pd.DataFrame(columns=['Year','Location','Var1','Var2'], data=[[2001, 'A',1,2],[2002, 'A',3,4],[2003, 'A',5,6],[2001, 'B',7,8],[2002, 'B',9,10],[2003, 'B',11,12]])

>>> print MyData
   Year Location  Var1  Var2
0  2001        A     1     2
1  2002        A     3     4
2  2003        A     5     6
3  2001        B     7     8
4  2002        B     9    10
5  2003        B    11    12
>>>

I want a new dataframe with each location taking on the Var1 and Var2 values of the previous year. The dataframe will include 1 less year because you can't lag the first year.
I wrote a function that does this, but it feels a little clunky and I'm wondering if there are ways to improve it or do it more efficiently. Any suggestions on how my code can be improved would be greatly appreciated.
>>> def TimeLag(df, TimeVar, LocationVar, LagVars):
...     AllPeriods=sorted(df[TimeVar].unique().tolist())
...     ResultList=[]
...     for Period in AllPeriods[1:]:
...         d=df[df[TimeVar]==Period][[TimeVar, LocationVar]]
...         dtlag=df[df[TimeVar]==Period-1][[LocationVar]+LagVars]
...         d=pd.merge(d, dtlag, on='Location')
...         d=d.rename(columns={Var:Var+'_tlag' for Var in LagVars})
...         ResultList.append(d)
...     Final=pd.concat(ResultList).reset_index(drop=True)
...     return Final
...
>>>
>>> print TimeLag(MyData, 'Year','Location', ['Var1','Var2'])
   Year Location  Var1_tlag  Var2_tlag
0  2002        A          1          2
1  2002        B          7          8
2  2003        A          3          4
3  2003        B          9         10
>>>

A: OK, after looking at what you want it'll be quicker to take the first rows and then shift the rest of the df after performing a groupby and then concat:
In [77]:
first = MyData[MyData['Year']==2001]
first

Out[77]:
   Year Location  Var1  Var2
0  2001        A     1     2
3  2001        B     7     8

In [80]:
rest = MyData[MyData['Year']!=2001]
rest = rest.groupby('Location',as_index=False).shift().dropna()
pd.concat([first,rest])
Out[80]:
   Year Location  Var1  Var2
0  2001        A     1     2
3  2001        B     7     8
2  2002        A     3     4
5  2002        B     9    10

A: def lag_year(df):
    shifted_years = df.shift().dropna(how = 'all')
    years = df.iloc[1:]
    final = pd.DataFrame({'Year' : years.Year  , 'Var1' : shifted_years.Var1 , 'Var2' : shifted_years.Var2})
    return final

MyData.groupby('Location').apply(lag_year).reset_index().drop('level_1' , axis = 1)

Location    Var1    Var2    Year
    A         1        2    2002
    A         3        4    2003
    B         7        8    2002
    B         9       10    2003

if you want you can sort by year
MyData.groupby('Location').apply(lag_year).reset_index().drop('level_1' , axis = 1).sort_index(by = 'Year')