text:
Q: Filter different columns dataframe in R based on another dataframe I have some semi-complex filtering I need to do:
Identifier <- c(1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 5, 5)
item1 <- c("a", "b", "c", "a", "b", "c", "d", "a", "b", "d", "b", "a", "c")
item2 <- c("x", "y", "z", "z", "x", "y", "z", "y", "z", "x", "y", "x", "y")
item3 <- c("p", "q", "r", "p", "q", "r", "p", "q", "r", "p", "q", "r", "p")
df1 <- data.frame(Identifier, item1, item2, item3)
df1

header <- c("Identifier","item1","item2","item3")
values <- c("1","b","y","p")
needed<- c("yes","yes","yes","no")
df2 <- data.frame(header, values, needed)
df2

I then want to use df2, to apply multiple filters on df1.
So based on df2, I want to:

*

*Filter for "1" in df1$Identifier

*Filter for "b" in df1$item 1

*Filter for "y" in df1$item 2

*Remove "p" in df1$item 3

The goal is then to have df2 as an excel csv file, and the user can include what columns they would like filtered, and for what value. So, these would remain dynamic without them needing to edit the R code.

A: We may use Map in base R.  When we filter (keep or remove those elements, there is a possibility to have different lengths for each columns as showed before
Map(function(x, nm) {
       i1 <- match(nm, df2$header)
        if(df2$needed[i1] == "yes") x[x == df2$values[i1]]
       else x[x != df2$values[i1]]} , df1, names(df1))

-output
$Identifier
[1] 1 1 1

$item1
[1] "b" "b" "b" "b"

$item2
[1] "y" "y" "y" "y" "y"

$item3
[1] "q" "r" "q" "r" "q" "r" "q" "r"

If we want to keep the data as data.frame, it may be better to replace those doesn't conform to the logic as NA
library(dplyr)
df1 %>%
   mutate(across(everything(), ~  {
    i1 <- match(cur_column(), df2$header)
   case_when((df2$needed[i1] == "yes" &.x == df2$values[i1])|
      (df2$needed[i1] == "no" & .x != df2$values[i1]) ~ .x )
  }))

-output
   Identifier item1 item2 item3
1           1  <NA>  <NA>  <NA>
2           1     b     y     q
3           1  <NA>  <NA>     r
4          NA  <NA>  <NA>  <NA>
5          NA     b  <NA>     q
6          NA  <NA>     y     r
7          NA  <NA>  <NA>  <NA>
8          NA  <NA>     y     q
9          NA     b  <NA>     r
10         NA  <NA>  <NA>  <NA>
11         NA     b     y     q
12         NA  <NA>  <NA>     r
13         NA  <NA>     y  <NA>

If we need a single value
df1 %>%
   mutate(across(everything(), ~  {
    i1 <- match(cur_column(), df2$header)
   case_when((df2$needed[i1] == "yes" &.x == df2$values[i1])|
      (df2$needed[i1] == "no" & .x != df2$values[i1]) ~ .x )
  })) %>%
   summarise(across(everything(), ~ .x[complete.cases(.x)][1]))

-output
   Identifier item1 item2 item3
1          1     b     y     q


text:
Q: Why do methods and types impose different constraints on variance? I'm puzzled why scala treats def and type differently when counting variance constraints?
I tried to break my wall of text and factored my return type into a separate type declaration, and got a variance error immediately. Here is a minimized example:
class Bad[+A] {
  type Check[B >: A] = Bad[B]
  def check[B >: A] : Check[B] = this
}

which fails:
covariant.scala:2: error: covariant type A occurs in invariant position in type  >: A of type B
  type Check[B >: A] = Bad[B]
             ^
one error found

Still, it works fine without the extra type declaration:
class Good[+A] {
  def check[B >: A]: Good[B] = this
}

class Ugly[+A] {
  type Check[B >: A @scala.annotation.unchecked.uncheckedVariance] = Ugly[B]
  def check[B >: A] : Check[B] = this
}

A: This is because as soon as the type member Check escapes to the outside,
it can immediately appear both in co- and contravariant positions in functions and
methods:
class Bad[+A] {
  type Check[B]
}

class B
class A extends B

val bad: Bad[A] = ???
import bad._

def hypotheticalMethodSomewhereOutside1(c: Check[B]) = ???
def hypotheticalMethodSomewhereOutside2(i: Int): Check[B] = ???

The crucial difference to the [B >: A] type argument in the method check
def check[B >: A]: Good[B] = this

is that the single method check is under your control, you can guarantee that
it does not use A in a not-covariant position.
In contrast to that, the type member Check can appear in infinitely many other methods
in both co- and contravariant positions, and those methods are not under your control,
so you cannot prohibit the usage of Check in positions in which A appears not-covariant,
e.g. you cannot prevent hypotheticalMethodSomewhereOutsideN from the example above to
be defined by someone else.

Note that the presence of the method check is not necessary for your Bad example to fail:
// error: covariant type A occurs in invariant position in type  >: A of type B
class Bad[+A] {
  type Check[B >: A] = Bad[B]
  // def check[B >: A] : Check[B] = this
}

However, if you hide the member type Check from everyone
(really everyone, including even other instances of same class, that is,
with the extremely reclusive private[this] access modifier):
class Bad[+A] {
  private[this] type Check[B >: A] = Bad[B]
}

it compiles just nicely.
The private[this] solves the problem, because with this modifier, only the methods
inside the class have to be inspected, no hypothetical methods somewhere outside
have to be taken into consideration:
class Ok[+A] {
  private[this] type Check[B >: A] = Ok[B]
  def ok[B >: A](c: Check[B]): Unit = ???
  def alsoOk[B >: A]: Check[B] = ???
}

Note that the above can be written just as
class Good[+A] {
  type Check[+B] = Good[B]
  def ok[B >: A](c: Check[B]): Unit = ???
  def alsoOk[B >: A]: Check[B] = ???
}

which makes sense only if the type constructor Good has way more arguments than Check.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How do I perform an insecure URLSession query in iOS I'm trying to perform a query to a website that I run. However, currently, this website's certificate is invalid (for a valid reason for now).
I'm trying to query it with this code:
private static func performQuery(_ urlString: String) {
    guard let url = URL(string: urlString) else {
        return
    }
    print(url)
    URLSession.shared.dataTask(with: url) {
        (data, response, error) in
        if error != nil {
            print(error!.localizedDescription)
        }
        guard let data = data else {
            return
        }
        do {
            let productDetails = try JSONDecoder().decode([ProductDetails].self, from: data)
            DispatchQueue.main.async {
                print(productDetails)
            }
        } catch let jsonError {
            print(jsonError)
        }
    }.resume()
}

However, I get:
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
The certificate for this server is invalid. You might be connecting to a server that is pretending to be "mydomain.com" which could put your confidential information at risk.

How can I make an insecure URLSession query (equivalent to -k in CURL)?
I've tried setting these:
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>mydomain.com</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
            <false/>
            <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

And yes I don't intend to release this to the App Store with insecure access, but I need to get the code tested and right now we can't get a valid certificate, so this is purely for development purposes.

A: First, set the delegate of the session to your class which conforms to URLSessionDelegate like :
let session = URLSession(configuration: .default, delegate: self, delegateQueue: OperationQueue.main)

Add the implementation of didReceiveChallenge method in your class which conforms to URLSessionDelegate protocol
public func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
    completionHandler(.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!))
}

This will allow insecure connection by trusting the server.
WARNING : DO NOT use this code in production apps, this is a potential security risk.

A: Try these exceptions:
<key>NSExceptionMinimumTLSVersion</key>
  <string>TLSv1.0</string>
  <key>NSExceptionRequiresForwardSecrecy</key>
  <false/>
  <key>NSExceptionAllowsInsecureHTTPLoads</key>
  <true/>
  <key>NSIncludesSubdomains</key>
<true/>


text:
Q: What is __brkval for AVR, and where is it defined? I have seen the freeMemory function in https://playground.arduino.cc/Code/AvailableMemory , and it seems to use something called __brkval. However, I simply cannot find where is this macro or variable defined:
$ grep -ri brkval /c/arduino-1.8.8/ --include='*.c' --include='*.h'
/c/arduino-1.8.8/libraries/Robot_Control/src/Fat16util.h:  extern int* __brkval;
/c/arduino-1.8.8/libraries/Robot_Control/src/Fat16util.h:  if (reinterpret_cast<int>(__brkval) == 0) {
/c/arduino-1.8.8/libraries/Robot_Control/src/Fat16util.h:                  - reinterpret_cast<int>(__brkval);
/c/arduino-1.8.8/libraries/SD/src/utility/SdFatUtil.h:  extern int* __brkval;
/c/arduino-1.8.8/libraries/SD/src/utility/SdFatUtil.h:  if (reinterpret_cast<int>(__brkval) == 0) {
/c/arduino-1.8.8/libraries/SD/src/utility/SdFatUtil.h:                  - reinterpret_cast<int>(__brkval);

$ grep -ri brkval /c/avr-gcc-8.2.0-x64-mingw/ --include='*.c' --include='*.h'
# nothing

$ grep -ri brkval /c/Program\ Files\ \(x86\)/Atmel/Studio/ --include='*.c' --include='*.h'
# nothing

$ grep -ri brkval /c/cvavr/ --include='*.c'
# nothing

That is, only Arduino IDE has some references to it, but only as extern int* reference, it does not have a definition.
Closest I came to some sort of a verbose explanation is from https://github.com/greiman/SdFat/blob/master/src/FreeStack.h :
/** boundary between stack and heap. */
extern char *__brkval;

... but again, no definition.
So where is this variable or macro defined?

EDIT: as per comments, searching through all files:
$ grep -ri brkval /c/cvavr/
# nothing

$ grep -ri brkval /c/Program\ Files\ \(x86\)/Atmel/Studio/
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr25/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr25/tiny-stack/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr3/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr31/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr35/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr4/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr5/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr51/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr6/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrtiny/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega2/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega3/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega3/short-calls/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega4/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega5/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega6/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega7/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/tiny-stack/libc.a matches
/c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/doc/avr-libc/avr-libc-user-manual/stdlib__private_8h_source.html:00045 extern char *__brkval;      /* first location not yet allocated */

$ grep -ri brkval /c/avr-gcc-8.2.0-x64-mingw/
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr25/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr25/tiny-stack/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr3/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr31/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr35/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr4/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr5/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr51/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr6/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avrtiny/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avrxmega2/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avrxmega4/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avrxmega5/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avrxmega6/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avrxmega7/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/tiny-stack/libc.a matches

$ grep -ri brkval /c/arduino-1.8.8/
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr25/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr25/tiny-stack/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr3/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr31/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr35/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr4/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr5/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr51/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr6/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrtiny/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega2/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega3/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega3/short-calls/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega4/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega5/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega6/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega7/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/tiny-stack/libc.a matches
/c/arduino-1.8.8/libraries/Robot_Control/src/Fat16util.h:  extern int* __brkval;
/c/arduino-1.8.8/libraries/Robot_Control/src/Fat16util.h:  if (reinterpret_cast<int>(__brkval) == 0) {
/c/arduino-1.8.8/libraries/Robot_Control/src/Fat16util.h:                  - reinterpret_cast<int>(__brkval);
/c/arduino-1.8.8/libraries/SD/src/utility/SdFatUtil.h:  extern int* __brkval;
/c/arduino-1.8.8/libraries/SD/src/utility/SdFatUtil.h:  if (reinterpret_cast<int>(__brkval) == 0) {
/c/arduino-1.8.8/libraries/SD/src/utility/SdFatUtil.h:                  - reinterpret_cast<int>(__brkval);

A: There are many others with the same question.  And as is pointed out, in simplest terms it is used to mark the boundary between stack and heap memory.  Here are some related discussions with content that includes __brkval:

*

*Arduino: Question about memory allocation analysis.

*Free Memory Questions, Arduino.

*Arduino:You know you have a memory problem when....

*AVRGCC: Monitoring stack usage.

*Arduino Playground: CorruptArrayVariablesAndMemory.

The final link addresses your main question, at least for Arduino environments:

with the memory profiler function added (note that it uses freeMemory via MemoryFree.h, which is also given in the thread above), and starting array size of 100 elements (400 bytes):

// minitest.pde

static unsigned long mydata_count;

static const long SERSPEED=115200;
static const int SIZE=100;
static const char RSTSTR[] = "RESET!!";

static unsigned long mydata[SIZE];

#include <MemoryFree.h>

extern unsigned int __data_start;
extern unsigned int __data_end;
extern unsigned int __bss_start;
extern unsigned int __bss_end;
extern unsigned int __heap_start;
//extern void *__malloc_heap_start; --> apparently already declared as char*
//extern void *__malloc_margin; --> apparently already declared as a size_t
extern void *__brkval;


text:
Q: php imploding array help I am trying to the  implode the userIDs in the $users_in_range array the  problem is it is iploding miles instead of userid
<?PHP
$users_in_range = users_in_range($lat, $long, 500, true);

// implode users into mysql friendly list
$comma_separated = implode(",", $users_in_range);
echo $comma_separated;

// this is just for output while debugging
foreach ($users_in_range as $userid => $miles_away) {
    echo "UserID=$userid is $miles_away miles away from me.
";
}
?>

A: The userid is the key of the array, so you need to do:
$comma_separated = implode(",", array_keys($users_in_range));

A: try :
$comma_separated = implode(',', array_keys($users_in_range));


text:
Q: I cannot calculate mean and sd in dplyr My problem is that I don't understand why I cannot calculate mean and sd of a variable total.
Steps that I have done:

*

*I filtered the dataset in order to see data only from day 1 to 7.

*I have summarised values from the variable "x" and created a new variable "Total"

I have a dataset:
name  day  x
ab    1    3
cd    3    5
fg    7    2
ll    3    1
kk    9    0

My code:
df_changed <- df%>%
dplyr::group_by(`name`, `day` )%>%
dplyr::filter(`day`>= 1, `day`<= 7) %>%
dplyr::summarise(Total=sum(x, na.rm = TRUE))%>%
dplyr::summarise(mean = mean(Total), sd = sd(Total)) %>%
view(df_changed)

A: Perhaps you may want to calculate mean and SD of x instead of Total as stated.  Try this code
library(tidyverse)

df_changed <- df%>%
dplyr::group_by(`name`, `day` )%>%
dplyr::filter(`day`>= 1, `day`<= 7) %>%
dplyr::summarise(Total=sum(x, na.rm = TRUE),
                 mean = mean(x, na.rm = T),
                 sd = sd(x, na.rm =T))


text:
Q: Mongo filter/find all elements in embedded array that match a criteria and return surrounding documents? Basically, I have a Mongo DB with the following structure:
[
  {
    "id": 1,
    "other_thing": "whatever",
    "annoying_array": [
      {
        "sub_id": "a",
        "thing_type": "apple"
      },
      {
        "sub_id": "b",
        "thing_type": "pear"
      }
    ]
  },
  {
    "id": 2,
    "other_thing": "whatever_else",
    "annoying_array": [
      {
        "sub_id": "c",
        "thing_type": "carrot"
      },
      {
        "sub_id": "d",
        "thing_type": "pear"
      },
      {
        "sub_id": "e",
        "thing_type": "pear"
      }
    ]
  }
]

I'd basically like to do something like db.docs.find( {annoying.array.thing_type: "pear"}) and have it return:
[
  {
    "id": 1,
    "other_thing": "whatever",
    "annoying_array": [
      {
        "sub_id": "b",
        "thing_type": "pear"
      }
    ]
  },
  {
    "id": 2,
    "other_thing": "whatever_else",
    "annoying_array": [
      {
        "sub_id": "d",
        "thing_type": "pear"
      },
      {
        "sub_id": "e",
        "thing_type": "pear"
      }
    ]
  }
]

This question seems relevant, but is almost 10 years old, and I know a ton of the filter/aggregation pipeline has changed since then.  There's probably a much cleaner way of doing it.
I've tried everything I could think of, from find to match and elemMatch but everything returns all document and sub-arrays for which there exists thing_type: 'pear', not every element in the sub-array for which thing_type = pear.  Even if it didn't return the surrounding metadata (i.e. didn't include other_thing, etc.) I'd settle for just returning every element (sub-document) for which a key matches a specific value.
It'd also be nice to have the option to return each matching element of the annoying_array that matches as its own document, with the document-wide data (i.e. id, or other_thing) projected to each match.

A: You can use Aggregation Pipeline:

*

*$match to find all documents which annoying_array contains item which thing_type propery is equal to pear.

*$project to specify which properties you want to return from the result

*$filter to filter only those items in annoying_array which thing_type propery is equal to pear.

db.collection.aggregate([
  {
    "$match": {
      "annoying_array.thing_type": "pear"
    }
  },
  {
    "$project": {
      "id": 1,
      "other_thing": 1,
      "annoying_array": {
        "$filter": {
          input: "$annoying_array",
          as: "item",
          cond: {
            "$eq": [
              "$$item.thing_type",
              "pear"
            ]
          }
        }
      }
    }
  }
])

Here is the working exmaple: https://mongoplayground.net/p/7bLcScBQv8c


text:
Q: How to figure out what is running on my (NVIDIA) GPU? I am using my GPU (Tesla K80) to train neural networks using tensorflow, and something has gone wrong. When I type nvidia-smi I see that 11239MiB / 11439MiB of the memory is being used, but no processes are listed for the GPU.
Normally when this happens I can type ps aux | grep python and find the process that is using up the GPU, but this time nothing is coming up.
How do I figure out what is running on my GPU, and how do I kill it?

A: See all processes being run by the user who used the GPU. Kill all processes that may have used the GPU.
ps -ef | grep <username>

You could also try
sudo nvidia-smi --gpu-reset

If nothing works then consider rebooting.


text:
Q: Getter undefined vuex and axios I'm trying to get a getter in my component but it says an error. This is my code store.js
const store = new Vuex.Store({
    state: {
        config:{
            themes: [],
            typographies:[],
        },
        user: {
            typography_id: 1,
            theme_id: null
        }
    },
    mutations: {
         FETCH_CONFIG(state, config) {
            state.config.themes = config.themes;
            state.config.typographies = config.typographies;
        },
        FETCH_USER(state, user) {
            state.user.theme_id = user.theme_id;
            state.user.typography_id = user.typography_id;
        },
    },
    actions: {
        fetchConfig({commit}) {
            axios.get('/api/config').then( function( response ){
                commit('FETCH_CONFIG', response.data);
            });
        },
        fetchUser({commit}) {
            axios.get('/api/user').then( function( response ){
                commit('FETCH_USER', response.data.data[0]);
            });
        },
    },
    getters: {
        themes(state) {
            return state.config.themes;
        },
        typographies(state) {
            return state.config.typographies;
        },
        typography(state) {
            if (state.user.theme_id == 1) {
                return state.user.typography_id;
            } else {
                var theme = state.config.themes.filter(function (el) {
                    return el.id == state.user.theme_id;
                });
                return theme[0].typography_id;
            }
        },
        user_theme(state) {
            return state.user.theme_id;
        },
    }
});

And in my component in computed I have:
...mapGetters(['typographies', 'typography'])

And ths is the error I get:

I guess I'm doing something wrong but I don't know what.

A: Your getter for typography returns the error because first it goes into the else and then tries to return theme[0].typography_id - but there is an empty array.. if you are loading the date, later on, make sure that the getter returns null before data is loaded.. like:
const store = new Vuex.Store({
    state: {
        config:{
            themes: [],
            typographies:[],
        },
        user: {
            typography_id: 1,
            theme_id: null
        }
    },
    mutations: {
         FETCH_CONFIG(state, config) {
            state.config.themes = config.themes;
            state.config.typographies = config.typographies;
        },
        FETCH_USER(state, user) {
            state.user.theme_id = user.theme_id;
            state.user.typography_id = user.typography_id;
        },
    },
    actions: {
        fetchConfig({commit}) {
            axios.get('/api/config').then( function( response ){
                commit('FETCH_CONFIG', response.data);
            });
        },
        fetchUser({commit}) {
            axios.get('/api/user').then( function( response ){
                commit('FETCH_USER', response.data.data[0]);
            });
        },
    },
    getters: {
        themes(state) {
            return state.config.themes;
        },
        typographies(state) {
            return state.config.typographies;
        },
        typography(state) {
            if (state.user.theme_id == 1) {
                return state.user.typography_id;
            } else {
                var theme = state.config.themes.filter(function (el) {
                    return el.id == state.user.theme_id;
                });
                return theme.length > 0 ? theme[0].typography_id: 1;
            }
        },
        user_theme(state) {
            return state.user.theme_id;
        },
    }
});


text:
Q: How to integrate moving Heaviside block? I spent a lot of time figuring out how to integrate a convolution of a heaviside function with another heaviside function, but so far I couldn't find any closed form.
$$\int_{-\infty}^{\infty} H\left(\frac{1}{2}-\tau\right) H_\frac{1}{2}(\tau)H_1(t-\tau) d\tau$$ and by $H_a$ I mean:
$$
H_a(x)=
 \begin{cases}
      1 & -a\leq x\leq a \\
      0 &  \;\text{ otherwise}
  \end{cases}
$$
I know the integral is equal to:
$$\int_{-\frac{1}{2}}^{\frac{1}{2}}H_1(t-\tau) d\tau$$
But I can't work this off any further.

A: I have changed a little bit the notation by putting $H_a=\chi_a$, meaning this as the characteristic function. of the interval $[-a,a]$: therefore we have
$$
\begin{split}
\int\limits_{-\infty}^{+\infty} H\left(\frac{1}{2}-\tau\right) \chi_\frac{1}{2}(\tau)\,\chi_1(t-\tau) \mathrm{d}\tau &= \int\limits_{-\infty}^{+\frac{1}{2}}  \chi_\frac{1}{2}(\tau)\,\chi_1(t-\tau) \mathrm{d}\tau \\
& = \int\limits_{-\frac{1}{2}}^{+\frac{1}{2}} \chi_1(t-\tau) \mathrm{d}\tau \\
\text{ and by the change of variables $t-\tau =z$ (and } z=\tau &\text{) we have that}\\
& = \int\limits_{t-\frac{1}{2}}^{t+\frac{1}{2}} \chi_1(\tau) \mathrm{d}\tau\\
\end{split}\label{1}\tag{1}
$$
Now we have to analyze the different values of the integral for $t$ varying in $\mathbb{R}$ (I will consider only the values $t>0$ and $|t|\le \frac{1}{2}$ since the method is identical for $t<0$):

*

*if $-\frac{1}{2}\le t\le \frac{1}{2}$, then $|\tau|\le 1$ thus  $\chi_1(\tau)$ is equal to $1$. The last integral at the right member of \eqref{1} is then equal to the measure of the interval $\left[t-\frac{1}{2},t+ \frac{1}{2}\right]$ i.e. $1$:
$$
\int\limits_{t-\frac{1}{2}}^{t+\frac{1}{2}} \chi_1(\tau) \mathrm{d}\tau = \int\limits_{t-\frac{1}{2}}^{t+\frac{1}{2}}\mathrm{d}\tau
=\left[ \tau\right]^{t+\frac{1}{2}}_{t-\frac{1}{2}}=1
$$

*if $\frac{1}{2} < t \le \frac{3}{2}$, then $\tau \in [a,b]$ where $0 < a=t-\frac{1}{2}\le 1$ and $1 < b =t+\frac{1}{2}\le 2$. Then the function $\chi_1(\tau)$ is equal to $1$ only on the interval $[a,1]$ and the integral \eqref{1} is equal to
$$
\int\limits_{t-\frac{1}{2}}^{t+\frac{1}{2}} \chi_1(\tau) \mathrm{d}\tau = \int\limits_{t-\frac{1}{2}}^{1}\mathrm{d}\tau = \left[ \tau\right]^{1}_{t-\frac{1}{2}}=\frac{3}{2}-t
$$

*if $\frac{3}{2} < t $, then $\tau$ is always larger than $1$, thus the function $\chi_1(\tau)$ and as a consequence the integral \eqref{1} is always $0$.
In sum, to evaluate integral \eqref{1} we have to compare the support of the indicator (characteristic function) of $[-1,+1]$ and the domain of integration as $t$ varies in $\mathbb{R}$, as shown in the picture below for $t>0$:

A: Write the integrand as
$$
f(t,\tau ) = H\left( {{1 \over 2} - \tau } \right)H_{\,1/2} \left( \tau  \right)H_{\,1} \left( {t - \tau } \right)
$$
then according to your definitions, the integrand will be one when all the three terms are so, and null otherwise.
That means to impose the contemporaneous validity of the following inequalities:
$$
\eqalign{
  & f(t,\tau ) = 1\;:\;\left\{ \matrix{
  0 \le {1 \over 2} - \tau  \hfill \cr
   - {1 \over 2} \le \tau  \le {1 \over 2} \hfill \cr
   - 1 \le t - \tau  \le 1 \hfill \cr}  \right.\quad  \Rightarrow   \cr
  &  \Rightarrow \quad \left\{ \matrix{
   - {1 \over 2} \le \tau  \le {1 \over 2} \hfill \cr
   - 1 + t \le \tau  \le 1 + t \hfill \cr}  \right.\quad  \Rightarrow   \cr
  &  \Rightarrow \quad \left\{ {\matrix{
   { - {1 \over 2} \le \tau  \le 1 + t} & {\left| {\; - {3 \over 2} \le t <  - {1 \over 2}} \right.}  \cr
   { - {1 \over 2} \le \tau  \le {1 \over 2}} & {\left| {\; - {1 \over 2} \le t < {1 \over 2}} \right.}  \cr
   { - 1 + t \le \tau  \le {1 \over 2}} & {\left| {\;{1 \over 2} \le t < {3 \over 2}} \right.}  \cr
 } } \right. \cr}
$$
Thus the integral will be
$$
\int_{ - \infty }^\infty  {f(t,\tau )d\tau }  = \left\{ {\matrix{
   {{3 \over 2} + t} & {\left| {\; - {3 \over 2} \le t <  - {1 \over 2}} \right.}  \cr
   1 & {\left| {\; - {1 \over 2} \le t < {1 \over 2}} \right.}  \cr
   {{3 \over 2} - t} & {\left| {\;{1 \over 2} \le t < {3 \over 2}} \right.}  \cr
 } } \right.
$$

A: Let $f(t) = \int_{-\infty}^{\infty} H(\frac{1}{2}-t) H_\frac{1}{2}(\tau)H_1(t-\tau) d\tau$
$$ \int_{-\infty}^{\infty} H(\frac{1}{2}-t) H_\frac{1}{2}(\tau)H_1(t-\tau) d\tau =$$
\begin{multline*}
=\int_{-\infty}^{-\frac{1}{2}} H(\frac{1}{2}-t) H_\frac{1}{2}(\tau)H_1(t-\tau) d\tau\ + \\ + \int_{-\frac{1}{2}}^{\frac{1}{2}} H(\frac{1}{2}-t) H_\frac{1}{2}(\tau)H_1(t-\tau) d\tau\ + \\ + \int_{\frac{1}{2}}^{\infty} H(\frac{1}{2}-t) H_\frac{1}{2}(\tau)H_1(t-\tau) d\tau
\end{multline*}
First and third integral equal to zero, because $H_{\frac{1}{2}}(\tau) = 0,\ \tau \in (-\infty; -\dfrac{1}{2}) \cup (\dfrac{1}{2}; \infty)$
$$f(t) = \int_{-\frac{1}{2}}^{\frac{1}{2}} H(\frac{1}{2}-t)H_1(t-\tau) d\tau$$
If ($\dfrac{1}{2} - t) < 0 \text{, or } t > \dfrac{1}{2} \Rightarrow H(\frac{1}{2}-t) = 0 \Rightarrow f(t) = 0$
Otherwise:
$$ f(t) = \int_{-\frac{1}{2}}^{\frac{1}{2}} H_1(t-\tau) d\tau\qquad t \in [\dfrac{1}{2}; \infty)$$


text:
Q: Continuously updating data web scraped I'm trying to car e-commerce application using Android Java. I've already scraped data on a  car website but my issue is how would I continuously update the data being scraped to get newer cars on the platform.

A: couldn't you just run the webscraper periodically using a timed process.

A: Use generater with timer hopefully it will continue updating data.


text:
Q: Align an icon with the Toolbar icon - Android Material Design In the new Material Design (using AppCompat), I am trying to align some action icons with the drawer icon of the new toolbar. Something like:

I think I am looking in all the metrics correctly...
Touch Target Size

The problem is that I can't perfectly align it, because after that left padding of 16px, the icons should start, but the icon itself has also some "padding" (icon from material github), like:

Maybe is silly but I do not know what I am missing. How can I take into account the padding inside the image to properly align it? I have same problem with aligning radio buttons or checkbox with that action bar icon.
I tried this piece of code:
<RelativeLayout
    android:id="@+id/image_button"
    android:layout_width="72dp"
    android:layout_height="wrap_content">

    <ImageView
        android:layout_width="32dp"
        android:layout_height="48dp"
        android:layout_marginLeft="16dp"
        android:layout_marginStart="16dp"
        android:src="@drawable/ic_label_grey600_48dp" />
</RelativeLayout>

But does not look align to me (like in the first screenshot I posted). Here also looks perfectly align:

And looks likes is taking in account something more than that 72px and 16px of padding.

UPDATE
Ok, let me show you guys more examples and some code. Imaging that my list item has a radio button with a label text.
<RadioButton
     style="?android:textAppearanceMedium"
     android:layout_width="wrap_content"
     android:layout_height="48dp"
     android:layout_marginLeft="16dp"
     android:paddingLeft="32dp"
     android:singleLine="true"/>

Result:

I don't actually see a rule to set marginLeft and paddingLeft to the right values without using a custom button as a radio button (and knowing the dimensions of that button) ... <-- Which is a bad option because the color button is taken fro my accentColor (new stuff of Material).
It also looks like new Gmail app is facing some alignment issues (see when I select a mail, the 1 is not aligned anymore with the mail title):

A:
The problem is that I can't perfectly align it, because after that
  left padding of 16px, the icons should start, but the icon itself has
  also some "padding" (icon from material github)

Yes, the icon must have some padding and it varies depending on which screen resolution the icon will be displayed.
The padding for different screen density:

mdpi        4px * 1.0 = 4px

hdpi         4px * 1.5 = 6px

xhdpi       4px * 2.0 = 8px

xxhdpi     4px * 3.0 = 12px

xxxhdpi   4px * 4.0 = 16px

This is the padding included in the icon drawable and you shouldn't remove it.

http://www.google.com/design/spec/style/icons.html#icons-system-icons


text:
Q: Compare column value with 3 array list and replace the column value with array name from pyspark.sql.functions import when,col
from pyspark.sql.functions import udf
#Your code here to create a new variable df_kmeans_new with a new column Position_Group,..
from pyspark.sql.types import *

#Your code to complete
DEF= ["LB","LWB","RB","LCB","RCB","CB","RWB"]
FWD=  ["RF","LF","LW","RS","RW","LS","CF","ST"]
MID=  ["LCM","LM","RDM","CAM","RAM","RCM","CM","CDM","RM","LAM","LDM"]

df  = spark.createDataFrame(
    [(1, "LB", "4"),
      (2, "LM", "0"),
       (3, "LCB", "4"),
        (4, "RS", "4")],
          ("id", "Position", "Position_x"))

def check_in_def(cell_val):
    if cell_val in DEF:
      return "DEF"
    elif cell_val in FWD:
      return "FWD"
    elif cell_val in MID:
      return "MID"
    else:
      return "NA"

df = df.withColumn("Position_Group",when(check_in_def(df.Position)=="DEF","DEF").when(check_in_def(df.Position)=="FWD","FWD").otherwise(0)).show()

i want to create a new col in the df that will contains one of the 3 array names, DEF, FWD, and MID if the Position col value is found in the particular array.
but the code is not working..please someone help!

A: Instead of a function ,you can also create dictionary and then reverse it , then map the dictionary to a new column using create_map:
from itertools import chain
import pyspark.sql.functions as F

d = {"DEF":DEF,"FWD":FWD,"MID":MID}
d1 = {i:k for k,v in d.items() for i in v}

mapping = F.create_map([F.lit(x) for x in chain(*d1.items())])
df.withColumn("Position_Group",mapping[df['Position']]).show()

+---+--------+----------+--------------+
| id|Position|Position_x|Position_Group|
+---+--------+----------+--------------+
|  1|      LB|         4|           DEF|
|  2|      LM|         0|           MID|
|  3|     LCB|         4|           DEF|
|  4|      RS|         4|           FWD|
+---+--------+----------+--------------+

A: Your function doesn't work on withColumn because it passes the whole column instead of single value. With vectorizing your code instead of writing bunch of if statements:
from pyspark.sql.functions import when,col
from pyspark.sql.functions import udf
#Your code here to create a new variable df_kmeans_new with a new column Position_Group,..
from pyspark.sql.types import *

#Your code to complete
dict = {
'DEF' : ["LB","LWB","RB","LCB","RCB","CB","RWB"]
,'FWD' :  ["RF","LF","LW","RS","RW","LS","CF","ST"]
,'MID' :  ["LCM","LM","RDM","CAM","RAM","RCM","CM","CDM","RM","LAM","LDM"]
}

df_map_list = []
for key, value in dict.items():
  for v in value:
    df_map_list.append((key, v))

df_map  = spark.createDataFrame(df_map_list, ('key', 'Position'))

df  = spark.createDataFrame(
    [(1, "LB", "4"),
      (2, "LM", "0"),
       (3, "LCB", "4"),
        (4, "RS", "4")],
          ("id", "Position", "Position_x"))

df = df.alias('a').join(df_map.alias('b'), col('a.Position') == col('b.Position'), 'left').select(['a.*'] + [col('b.key').alias('Position_Group')])

df.show()


text:
Q: Xamarin Uploading sqllite file to Azure Blob storage, sqlite .db3 file is empty on Blob storage I'm trying to upload the local database of the app build in Xamarin forms iOS. There is data in the local database and the app can see all the table and data just fine.
I want to investigate the database, so I upload it to an Azure Blob storage.
The code look like this:
public class BlobStorageService
    {
        readonly static CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(Constants.blogStorageConnectionString);
        readonly static CloudBlobClient blobClient = cloudStorageAccount.CreateCloudBlobClient();
    public static async Task UploadFileToBlobStorage(string filePath)
    {
        if (!File.Exists(filePath))
            return;

        var fileName = Path.GetFileName(filePath);
        CloudBlobContainer container = blobClient.GetContainerReference("sqllitefiles");
        await container.CreateIfNotExistsAsync();

        BlobContainerPermissions permissions = await container.GetPermissionsAsync();
        permissions.PublicAccess = BlobContainerPublicAccessType.Container;  //TODO: disable this later.
        await container.SetPermissionsAsync(permissions);

        CloudBlockBlob blockBlob = container.GetBlockBlobReference(fileName);

        await blockBlob.UploadFromFileAsync(filePath);
    }
}

And the filePath is :
public static readonly string DatabasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CaseNotesSQLite.db3");
Database file is uploaded successfully, however, the file is only 4KB and when I open the database file using SQLLite Browser, there is no data and no table structure at all.
Anyone know why ?


text:
Q: Run Geolocation on DalvikVM I know that is possible to run a simple(f.e. HelloWorld) java programms with dalvikvm on Android. I want  to start a simple Geolocation App, but what is with Context? I became just Context don´t found Exception. Does it means that there are no Context for jars, what are started with dalvikvm? Exist some possibilities  to run something like  LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); on dalvikvm and is it generally possible to run some of the standard android function (like Internet or SMS) with dalvikvm?

A: Like you mentioned, you can run a simple java program from a terminal. However, you can't run an Android application like that. You can however send an intent from the terminal using the am command, which you can use to start an activity/service/broadcast receiver.
So one possible way to do what you want would be to develop a simple android service and install it on your phone, and then start it using am startservice <intent>.


text:
Q: Capitalize words in a bash variable using sed I am totally new on shell scripting (actually three days only :) ) so don't shoot me .. !!
In my script I have a code that looks like that:
string="this-is-my-string"

and I like to modify the content of the variable, in order to become like that:
string="This Is My String"

I don't look for the regex that modify the original string into the modified version. I already have find the solution here.
What I am looking for, is how to modify the text inside the variable using the sed command. To be honest, I don't really know if that possible with sed. In case that modification it is not possible to be done with sed is there any other method to achieve the same result ?

A: string=$(sed 's/^./\u&/; s/-\(.\)/ \u\1/g' <<< $string)

Example:
sdlcb@Goofy-Gen:~/AMD$ cat File
#!/bin/bash

string="this-is-my-string"
string=$(sed 's/^./\u&/; s/-\(.\)/ \u\1/g' <<< $string)
echo "$string"

AMD$ ./File
This Is My String

s/^./\u&/ => Capitalize the first character \u for uppercase. & => the matched pattern.
s/-\(.\)/ \u\1/g => substitute - followed by character to space followed by uppercase of the character. ( ) used to group pattern and \1 => first group, in this case only 1 such group is present.

A: Yeah that's possible, try something like:
#!/bin/bash
string="this-is-my-string"
string=$(echo ${string} | sed 's/\-/ /g')
echo ${string}

A: A pure Bash (Bash≥4) solution with parameter expansions:
$ string='this-is-my-string'
$ IFS=- read -r -a ary <<< "$string"
$ string="${ary[@]^}"
$ echo "$string"
This Is My String

A: If you are interested this is quite simple in Python, from the interpreter:
>>> string = "this-is-my-string"
>>> string = ' '.join([ s.capitalize() for s in  string.split('-')])
>>> print string
This Is My String

A: You can try it like this too
 echo '"this-is-my-string"'|sed 's/-/ /g;s/\([^"]\)\(\S*\s*\)/\u\1\2/g'

or
echo "$string"|sed 's/-/ /g;s/\([^"]\)\(\S*\s*\)/\u\1\2/g'

the \S is a metacharacter that matches any character that is not a space/whitespace
and \s matches any characters that is a space

A: Here is an  awk solution:
echo "this-is-my-string" | awk -F- '{for (i=1;i<=NF;++i) $i=toupper(substr($i,1,1)) substr($i,2)}1'
This Is My String

string='this-is-my-string'
string=$(awk -F- '{for (i=1;i<=NF;++i) $i=toupper(substr($i,1,1)) substr($i,2)}1' <<< "$string")
echo "$string"
This Is My String

Here is another awk
echo "this-is-my-string" | awk -F- '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1'
This Is My String


text:
Q: "File is Locked" message for a folder with thousands of subfolders/files After transferring a massive code project to my Mac, I noticed I couldn't write anything to the files inside due to the "File is Locked" plus an access denied message.
Unlocking the root folder didn't help, chmod didn't make a difference, and granting read-write to everyone and applying to all subfiles didn't help either.
Is there a terminal command I can use to programmatically unlock all folders and files below a specific directory?

A: I found a perfect terminal set of commands buried in a forum post here: https://forums.macrumors.com/threads/how-to-batch-unlock-numerous-files-within-subfolders-folders-directory.453818/
Here's the commands I used (my project was located at /APPS/MYAPP):
export UNLOCK=/APPS/MYAPP
find $UNLOCK -type f -exec setfile -a l {} \;
find $UNLOCK -type d -exec setfile -a l {} \;

The type argument is f for files, d for directories.
The exec argument passes setfile, from the xcode developer tools (may need to be installed first), and uses lower-case L to "unlock" (bizarre command line syntax, I know)


text:
Q: System.Exception: Too many record type describes: 101 I am getting a exception
System.Exception: Too many record type describes: 101

I understand this is a governor limit exception.
There are couple of places where i am checking for record types in a If statement in the trigger.
for(Opportunity o : Trigger.new)
{
   if ( ( o.TotalOpportunityQuantity != Trigger.OldMap.get(o.Id).TotalOpportunityQuantity) && o.RecordTypeId == varRectype)
     {
                 // do something
     }

     // i am also checking in another if statement for o.RecordTypeId == varRectype with a combination of other fields.

 }

Has anybody else got this error. Any pointers on what is causing this would be of great help

A: You should open the Developer Console, and repeat the action that caused this exception.  Then look at the debug log, to see at which point this Exception is firing.  The code you listed above should not be triggering this governor limit, as it has nothing to do with "describe".
Also, do you have any managed packages installed?  The code in those could be triggering this governor limit.  Debug log would tell you more.


text:
Q: Last date by group with conditions This question is a follow-up to this question, but where each idPerson can have multiple decision == "d". There are multiple idPerson, but one suffices to explain the question. idAppt are nested into idPerson. Consider this data frame.
   idPerson idAppt decision date
 1 A             1 a        2021-09-10
 2 A             1 b        2021-09-11
 3 A             1 c        2021-09-12
 4 A             1 d        2021-09-13
 5 A             2 a        2021-09-20
 6 A             2 b        2021-09-21
 7 A             3 a        2021-09-10
 8 A             3 b        2021-09-11
 9 A             4 a        2021-09-21
10 A             4 b        2021-09-22
11 A             4 c        2021-09-23
12 A             4 d        2021-09-24
13 A             5 a        2021-09-10
14 A             5 b        2021-09-11
15 A             6 a        2021-10-10
16 A             6 b        2021-10-11

I'd like to construct a date2 column which replies to these conditions:

*

*For a given idAppt, if decision == "a" is later than any other date when decision == "d" of that same idPerson, report the latest value of date when decision == "d" for that idPerson (the closest before). For example, in group idAppt == 2, the date of decision == "a" is later than the date of decision == "d" of group idAppt == 1, so date2 should be 2021-09-13. Same applies for group idAppt == 6, but here there are two decision == "d" that are earlier (row 4 and 12). In that case, date2 should be the closest before 2021-10-10, i.e. 2021-09-23.

*When there is no decision == "d"'s date earlier than the date of decision == "a" for a given idAppt, take the earliest of the given idPerson.

Which gives the following desired output:
   idPerson idAppt decision date       date2
 1 A             1 a        2021-09-10 2021-09-10
 2 A             1 b        2021-09-11 2021-09-10
 3 A             1 c        2021-09-12 2021-09-10
 4 A             1 d        2021-09-13 2021-09-10
 5 A             2 a        2021-09-20 2021-09-13 #<- correspond to value of row 4
 6 A             2 b        2021-09-21 2021-09-13
 7 A             3 a        2021-09-10 2021-09-10
 8 A             3 b        2021-09-11 2021-09-10
 9 A             4 a        2021-09-21 2021-09-13
10 A             4 b        2021-09-22 2021-09-13
11 A             4 c        2021-09-23 2021-09-13
12 A             4 d        2021-09-24 2021-09-13
13 A             5 a        2021-09-11 2021-09-10 #<- earliest value because 2021-09-10 is earlier than 2021-09-13
14 A             5 b        2021-09-12 2021-09-10
15 A             6 a        2021-10-10 2021-09-24 #<- correspond to value of row 12
16 A             6 b        2021-10-11 2021-09-24

data
df <- structure(list(idPerson = c("A", "A", "A", "A", "A", "A", "A",
"A", "A", "A", "A", "A", "A", "A", "A", "A"), idAppt = c(1L,
1L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 6L, 6L),
    decision = c("a", "b", "c", "d", "a", "b", "a", "b", "a",
    "b", "c", "d", "a", "b", "a", "b"), date = structure(c(18880,
    18881, 18882, 18883, 18890, 18891, 18880, 18881, 18891, 18892,
    18893, 18894, 18881, 18882, 18910, 18911), class = "Date")), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -16L))

EO <- structure(list(idPerson = c("A", "A", "A", "A", "A", "A", "A",
"A", "A", "A", "A", "A", "A", "A", "A", "A"), idAppt = c(1L,
1L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 6L, 6L),
    decision = c("a", "b", "c", "d", "a", "b", "a", "b", "a",
    "b", "c", "d", "a", "b", "a", "b"), date = structure(c(18880,
    18881, 18882, 18883, 18890, 18891, 18880, 18881, 18891, 18892,
    18893, 18894, 18881, 18882, 18910, 18911), class = "Date"),
    date2 = c("2021-09-10", "2021-09-10", "2021-09-10", "2021-09-10",
    "2021-09-13", "2021-09-13", "2021-09-10", "2021-09-10", "2021-09-13",
    "2021-09-13", "2021-09-13", "2021-09-13", "2021-09-10", "2021-09-10",
    "2021-09-24", "2021-09-24")), row.names = c(NA, -16L), class = c("tbl_df",
"tbl", "data.frame"))

A: Using a data.table rolling join:
library(data.table)
setDT(df)

# rolling join between decision "d" and "a"
df[decision == "a", date2 := df[decision == "d"][.SD, on = .(idPerson, date), x.date, roll = Inf]]

# set non-matching rows for decision "a" to min(date)
df[decision == "a" & is.na(date2), date2 := min(date), by = idPerson]

# replace other NA by last observation carried forward
setnafill(df, type = "locf", cols = "date2")

    idPerson idAppt decision       date      date2
 1:        A      1        a 2021-09-10 2021-09-10
 2:        A      1        b 2021-09-11 2021-09-10
 3:        A      1        c 2021-09-12 2021-09-10
 4:        A      1        d 2021-09-13 2021-09-10
 5:        A      2        a 2021-09-20 2021-09-13
 6:        A      2        b 2021-09-21 2021-09-13
 7:        A      3        a 2021-09-10 2021-09-10
 8:        A      3        b 2021-09-11 2021-09-10
 9:        A      4        a 2021-09-21 2021-09-13
10:        A      4        b 2021-09-22 2021-09-13
11:        A      4        c 2021-09-23 2021-09-13
12:        A      4        d 2021-09-24 2021-09-13
13:        A      5        a 2021-09-11 2021-09-10
14:        A      5        b 2021-09-12 2021-09-10
15:        A      6        a 2021-10-10 2021-09-24
16:        A      6        b 2021-10-11 2021-09-24

The relevance of 'idAppt' is not entirely clear, because it seems like the comparison of dates is performed within idPerson.

A: Here's how I solved the problem, although it seems a bit convoluted:
library(dplyr)
df %>%
  group_by(idPerson) %>%
  mutate(d_date = list(date[decision == "d"]), min_date_person = min(date)) %>%
  group_by(idPerson, idAppt) %>%
  mutate(date3 = unlist(map(d_date, \(x){
          dates <- date[decision == "a"] - x
          w <- which.min(dates[dates > 0])
          ifelse(is.null(w), NA, w)
          })),
         date2 = if_else(is.na(date3), min_date_person, do.call("c", map(d_date, ~ unique(.x[date3]))))) %>%
  ungroup() %>%
  select(1:4, date2)

# A tibble: 16 × 5
   idPerson idAppt decision date       date2
   <chr>     <int> <chr>    <date>     <date>
 1 A             1 a        2021-09-10 2021-09-10
 2 A             1 b        2021-09-11 2021-09-10
 3 A             1 c        2021-09-12 2021-09-10
 4 A             1 d        2021-09-13 2021-09-10
 5 A             2 a        2021-09-20 2021-09-13
 6 A             2 b        2021-09-21 2021-09-13
 7 A             3 a        2021-09-10 2021-09-10
 8 A             3 b        2021-09-11 2021-09-10
 9 A             4 a        2021-09-21 2021-09-13
10 A             4 b        2021-09-22 2021-09-13
11 A             4 c        2021-09-23 2021-09-13
12 A             4 d        2021-09-24 2021-09-13
13 A             5 a        2021-09-11 2021-09-10
14 A             5 b        2021-09-12 2021-09-10
15 A             6 a        2021-10-10 2021-09-24
16 A             6 b        2021-10-11 2021-09-24


text:
Q: What does $- mean in Bash? I was playing around on the shell when by mistake, I typed echo $- and I got the result himBH. Immediately, I tried all other combinations of symbols along with the $ sign but with no luck.
I read this post but I didn't fully understand it. Can someone please epxlain what they mean by 'shell options' and what himBH is supposed to mean?
Much thanks!

A: $- prints The current set of  options in your current shell.
himBH means following options are enabled:

*

*H - histexpand: when history expansion is enabled

*m - monitor: when job control is enabled

*h - hashall: Locate and remember (hash) commands as they are looked up for execution

*B - braceexpand: when brace expansion is enabled

*i - interactive: when current shell is interactive


text:
Q: Gagliardo Nirenberg inequality for the laplacian It is a classical result due to Gagliardo and Nirenberg that there exists a constant C such that it holds
$$
||\nabla \psi|| _{L ^\infty (\mathbb{R}^2)} ^2
\le ||D ^2 \psi|| _{L ^\infty (\mathbb{R}^2)} ||\psi|| _{L ^\infty (\mathbb{R}^2)},
$$
for any $ \psi \in C ^2 (\mathbb{R} ^2) $.
My question would be if anyone knows if it is possible to obtain the same result or a similar one with the laplacian instead of the second derivative, namely if it holds that
$$
||\nabla \psi|| _{L ^\infty (\mathbb{R}^2)} ^2
\le ||\Delta \psi|| _{L ^\infty (\mathbb{R}^2)} ||\psi|| _{L ^\infty (\mathbb{R}^2)}.
$$
Any help or reference will be greatly appreciated!

A: By the classical regularity theory for the Poisson equation, you have
$$
 \Vert \nabla \psi \Vert_{L^\infty (B_1)} \le C \bigl(\Vert \Delta \psi \Vert_{L^\infty (B_2)} + \Vert \psi \Vert_{L^\infty (B_2)} \bigr).
$$
See for example Gilbarg and Trudinger, Elliptic partial differential equations of second order, 1983, theorem 3.9, where it is proved by the maximum principle. (An alternative would be to use a Green representation formula of the solution in a ball.)
By scaling this gives
$$ R\Vert \nabla \psi \Vert_{L^\infty (B_R)} \le C \bigl(R^2 \Vert \Delta \psi \Vert_{L^\infty (B_{2 R})} + \Vert \psi \Vert_{L^\infty (B_{2 R})} \bigr).
$$
By translating the estimate, you obtain thus for every $R > 0$,
$$ R\Vert \nabla \psi \Vert_{L^\infty (\mathbb{R}^n)} \le C \bigl(R^2 \Vert \Delta \psi \Vert_{L^\infty (\mathbb{R}^n)} + \Vert \psi \Vert_{L^\infty (\mathbb{R}^n)} \bigr).
$$
By taking $R = \sqrt{\Vert \psi \Vert_{L^\infty (\mathbb{R}^n)} / \Vert \Delta \psi \Vert_{L^\infty (\mathbb{R}^n)}}$, we conclude that
$$
\Vert \nabla \psi \Vert_{L^\infty (\mathbb{R}^n)} \le 2C \Vert \Delta \psi \Vert_{L^\infty (\mathbb{R}^n)}^{1/2} \Vert \psi \Vert_{L^\infty (\mathbb{R}^n)}^{1/2}.
$$


text:
Q: BufferUnderflowException with kafka spout in storm I configured kafka spout for storm topology.
Code for creating Spout:
    BrokerHosts hosts = new ZkHosts(PropertiesUtils.getString("zookeeper.host"));
    String topics = "Test1_TOPIC";
    SpoutConfig spoutConfig = new SpoutConfig(hosts, topics[i], "/kafka" + topics[i], "discovery");
    spoutConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
    KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);
    topologyBuilder.setSpout("kafka", kafkaSpout, 6);

I am unable to fetch any messages and the following exceptions are being thrown. The programming is getting terminated.
   java.lang.RuntimeException: java.nio.BufferUnderflowException
at org.apache.storm.kafka.KafkaUtils.fetchMessages(KafkaUtils.java:201) ~[storm-kafka-1.0.1.jar:1.0.1]
at org.apache.storm.kafka.PartitionManager.fill(PartitionManager.java:189) ~[storm-kafka-1.0.1.jar:1.0.1]
at org.apache.storm.kafka.PartitionManager.next(PartitionManager.java:138) ~[storm-kafka-1.0.1.jar:1.0.1]
at org.apache.storm.kafka.KafkaSpout.nextTuple(KafkaSpout.java:135) ~[storm-kafka-1.0.1.jar:1.0.1]
at org.apache.storm.daemon.executor$fn__7885$fn__7900$fn__7931.invoke(executor.clj:645) ~[storm-core-1.0.1.jar:1.0.1]
at org.apache.storm.util$async_loop$fn__625.invoke(util.clj:484) [storm-core-1.0.1.jar:1.0.1]
at clojure.lang.AFn.run(AFn.java:22) [clojure-1.7.0.jar:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_31]
   Caused by: java.nio.BufferUnderflowException
at java.nio.HeapByteBuffer.get(HeapByteBuffer.java:151) ~[?:1.8.0_31]
at java.nio.ByteBuffer.get(ByteBuffer.java:715) ~[?:1.8.0_31]
at kafka.api.ApiUtils$.readShortString(ApiUtils.scala:40) ~[kafka_2.11-0.10.0.0.jar:?]
at kafka.api.TopicData$.readFrom(FetchResponse.scala:96) ~[kafka_2.11-0.10.0.0.jar:?]
at kafka.api.FetchResponse$$anonfun$4.apply(FetchResponse.scala:170) ~[kafka_2.11-0.10.0.0.jar:?]
at kafka.api.FetchResponse$$anonfun$4.apply(FetchResponse.scala:169) ~[kafka_2.11-0.10.0.0.jar:?]
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241) ~[scala-library-2.11.8.jar:?]
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241) ~[scala-library-2.11.8.jar:?]
at scala.collection.immutable.Range.foreach(Range.scala:160) ~[scala-library-2.11.8.jar:?]
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:241) ~[scala-library-2.11.8.jar:?]
at scala.collection.AbstractTraversable.flatMap(Traversable.scala:104) ~[scala-library-2.11.8.jar:?]
at kafka.api.FetchResponse$.readFrom(FetchResponse.scala:169) ~[kafka_2.11-0.10.0.0.jar:?]
at kafka.consumer.SimpleConsumer.fetch(SimpleConsumer.scala:135) ~[kafka_2.11-0.10.0.0.jar:?]
at kafka.javaapi.consumer.SimpleConsumer.fetch(SimpleConsumer.scala:47) ~[kafka_2.11-0.10.0.0.jar:?]
at org.apache.storm.kafka.KafkaUtils.fetchMessages(KafkaUtils.java:191) ~[storm-kafka-1.0.1.jar:1.0.1]
... 7 more

I am using storm-core 1.0.1 version, storm-kafka 1.0.1 version and Kafka version is kafka_2.11-0.10.0.0. Are there any issues with versions compatibility.


text:
Q: Firing intents for already started activity from class B(class that works in background) someone do this code
NOTE: the activity A is already in the front, visible and running
context.startActivity(createIntent(context, A.class));

I could not get it why ?, what is the point ?
I mean this is not for starting the activity, cause the activity has been already started. Also note that without this the program it is not working. so obviously with this code there is some kind of 'refresh' made on the activity.
So my question is which methods are called on the activity when the activity is running and new intent for that activity has been fired ?
and what is the point of this kind of programming whatsoever . . .
Thanks

A: well, it depends on the intent flags and launchmode of activity A.
if A is single task, its onNewIntent would be invoked. Most likely, a new instance of activity A is being created.
if not, post the intent flags and manifest of A

A: Such intents will be received in the onNewIntent() callback of the Activity class. You can use such method when you expect the activity to be launched from multiple points. Like from a service. The activity is paused on receiving such intent.

A: I guess you are making some changes in the data or UI which are taking effect as you are restarting it ... use the Handler to update data or UI in your activity ..
you can also refer this doc:
http://developer.android.com/reference/android/os/Handler.html


text:
Q: How to access listbox item's datacontext from GroupStyle.HeaderTemplate? I have a ListBox...where the ItemSource is a CollectionViewSource
rest everything same as in this link.
What I need is to access one property from my ListBox item's (or GroupItem ?) DataContext.
How can I access it ?

A: Assuming that you want to bind some text, try the following:
<TextBlock Text={Binding DataContext.PropertyName, ElementName=YourListBoxName}" />


text:
Q: How to insert into a sorted singly linked list? I am making a sorted linked list where the user enters a number and the number is inserted into sorted position. I am currently having problems with the sort function.
  class Node
    {
    public:
        int data;
        class Node *next;

        Node(int info, Node *ptr = 0)
        {
            data = info;
            next = ptr;
        }
    };
    class Node *head = NULL;

    class stack
    {
    private:
        Node *temp;
    public:
        stack()
        {
            temp = 0;
        }
        bool isEmpty()
        {
        return temp == NULL;
    }

I decided to go with an insert function(its called sort but really it just inserts a node into the linked list) which is why i have a current pointer and a previous pointer. I guess my question is am i on the right path? I am new to this so i just want a little bit of guidance to figure this out. Any tips will be appreciated.
 void sort(int data)
    {
        class Node *born = new Node(data);
        Node* current = head;
        Node* previous = NULL;
        //the list is empty case
        if (isEmpty())
            temp = born;
        else
        {
            while (current != NULL)
            {
                if (current->data >= temp->data)
                {
                    born->next = current;
                    temp = born;
                    break;
                }
                else
                {
                    previous = current;
                    current = temp->next;
                }
            }
            if (current == head)
            {
                born->next = head;
                head = born;
            }
            else
            {
                born->next = current;
                previous->next = born;
            }

            /*else
            {

                born->next = temp;
                temp = born;
            }*/
        }

    }

    void print()
    {
        cout<<"stack from the top"<<endl;
            for(Node *top = temp; top != 0; top=top->next)
                cout << top->data << " ";
            cout << endl;
        /*while(temp != NULL)
        {

            cout<<temp->data<<" ";
            temp=temp->next;
        }
        */
    }

    int pop()
    {
        if (isEmpty())
                return -999;

            int intReturn = temp->data;
            Node *top;

            top = temp;

            temp = temp->next;

            delete top;

            return intReturn;

    }

    };
    int main(void)
    {
        int num=0;

        stack boss;
        while(num!=-1)
        {
            cout<<"Please Enter a Number"<<endl;
            cin >> num;
            if (num == -1)
                boss.print();
            else
                boss.sort(num);
        }
        cout<<endl<<endl;

        system("PAUSE");
        return 0;

    }

A: I have concerns about your code about the logical steps and/or the naming of things. I couldn't just edit your code to fix it, so I've rewritten your code based on this understanding if you agree with me:

*

*A head points to the first node, and a tail points to the last node.

*Check to see if the list is empty, then head and tail point to the new node.

*Otherwise, check to see if the new node is to be placed at the start, and do it

*Otherwise, check to see if it fits in the middle, and do it

*Otherwise, place it at the last place

In addition, my other changes include:
A. For the class stack

*

*I renamed it to LinkedList

*I put two member variables head and tail to refer to the first and last nodes

B. For the sort() method

*

*I renamed it to insert

*I explicitly wrote each of the important cases clearly (empty list, first node, middle node, last node)

I also removed the using namespace std and explicitly wrote std:: because it is a better practice. There are also some minor changes here and there.
My final code:
class Node
{
public:
  int data;
  class Node* next;

  Node(int info, Node* ptr = 0)
  {
    data = info;
    next = ptr;
  }
};

class LinkedList
{
private:
  Node* head;
  Node* tail;

public:

  LinkedList()
  {
    head = 0;
    tail = 0;
  }

  bool isEmpty()
  {
    return head == NULL;
  }

  void insert(int data)
  {
    Node* newNode = new Node(data);

    if (isEmpty())
    {
      head = newNode;
      tail = newNode;
    }
    // if node to be placed at the top
    else if (data > head->data)
    {
      newNode->next = head;
      head = newNode;
    }
    else
    {
      Node* temp = head;
      Node* previousTemp = head;

      while (temp != NULL)
      {
        // if node to be placed in the middle
        if (temp->data < data)
        {
          previousTemp->next = newNode;
          newNode->next = temp;
          break;
        }
        previousTemp = temp;
        temp = temp->next;
      }

      // if node to be placed at the end
      if (temp == NULL)
      {
        tail->next = newNode;
        tail = tail->next;
      }

    }
  }

  void print()
  {
    std::cout << "Stack from the top" << std::endl;
    Node* temp = head;
    while(temp != NULL)
    {
      std::cout << temp->data << " ";
      temp = temp->next;
    }
  }

  int pop()
  {
    if (isEmpty())
    {
      return -999;
    }

    int intReturn = head->data;
    Node *top;

    top = head;

    head = head->next;

     delete top;

     return intReturn;
  }
};

int main(void)
{
  int num = 0;
  LinkedList linkedList;

  while (num != -1)
  {
    std::cout << "Please enter a number: ";
    std::cin >> num;
    if (num == -1)
    {
      linkedList.print();
    }
    else
    {
      linkedList.insert(num);
    }
  }

  std::cout << std::endl << std::endl;

  system("PAUSE");
  return 0;
}

Does this help?


text:
Q: load event for iframe does not fire in IE I've created an iframe in my page here is it's code:
var frame = document.createElement('iframe');
frame.setAttribute('src','');
document.body.appendChild(frame);
if(document.addEventListener){
    frame.addEventListener('load', callback, false);
} else {
    frame.attachEvent('onload', callback);
}

function callback(){
    alert('test');
}

It works fine in FF but no thing alerted in IE, why?
Note that I use IE10 in win8

A: You need to move document.body.appendChild() to after the addEventListener() call
var frame = document.createElement('iframe');
frame.setAttribute('src','');
if(frame.addEventListener){
    frame.addEventListener('load', callback, true);
} else {
    frame.attachEvent('onload', callback);
}
document.body.appendChild(frame);

function callback(){
    alert('test');
}


text:
Q: ArgumentError: Wrong number of arguments in Google oauth callback I followed this tutorial to add user authentication to my rails app. The tutorial uses devise and google_oauth2.
When a user attempts to sign in with Google, the user encounters an ArgumentError after callback.
Error:

Something is broken between the user model and the callback controller, but I'm a bit too over my skis to understand what might be causing the problem.
user.rb
class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable

  devise :omniauthable, omniauth_providers: [:google_oauth2]

  def self.from_google(email:, full_name:, uid:, avatar_url:)
   create_with(uid: uid, full_name: full_name, avatar_url: avatar_url).find_or_create_by!(email: email)
  end
end

omniauth_callbacks_controller.rb
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def google_oauth2
    user = User.from_google(from_google_params)

    if user.present?
      sign_out_all_scopes
      flash[:success] = t 'devise.omniauth_callbacks.success', kind: 'Google'
      sign_in_and_redirect user, event: :authentication
    else
      flash[:alert] = t 'devise.omniauth_callbacks.failure', kind: 'Google', reason: "#{auth.info.email} is not authorized."
      redirect_to new_user_session_path
    end
  end

  protected

  def after_omniauth_failure_path_for(_scope)
    new_user_session_path
  end

  def after_sign_in_path_for(resource_or_scope)
    stored_location_for(resource_or_scope) || root_path
  end

  private

  def from_google_params
    @from_google_params ||= {
      uid: auth.uid,
      email: auth.info.email,
      full_name: auth.info.name,
      avatar_url: auth.info.image
    }
  end

  def auth
    @auth ||= request.env['omniauth.auth']
  end
end

A: I am guessing (!!) that you are running the latest version of ruby: 3.0.0, which was released in December 2020, after that tutorial was written.
There is a major, breaking change in ruby version 3: Keyword and positional arguments are now separated.
The error is very subtle, but it's happening because your code is doing this:
User.from_google(
  {
    uid: auth.uid,
    email: auth.info.email,
    full_name: auth.info.name,
    avatar_url: auth.info.image
  }
)

(i.e. Passing a Hash to the method), instead of this:
User.from_google(
  uid: auth.uid,
  email: auth.info.email,
  full_name: auth.info.name,
  avatar_url: auth.info.image
)

(i.e. Passing keyword arguments to the method.)
Fixing this problem is easy: You can use the "double-splat" operator (**) to convert a hash into keyword arguments:
user = User.from_google(**from_google_params)

If you are not comfortable making such corrections to the code when following a tutorial like this, it should also be perfectly fine to use an older ruby version (e.g. 2.7). The "fixed" version of the code I have shown above will work fine on all ruby versions.


text:
Q: How can I get a big number in non-scientific notation? I just tried
>>> 2.17 * 10**27
2.17e+27
>>> str(2.17 * 10**27)
'2.17e+27'
>>> "%i" % 2.17 * 10**27
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: cannot fit 'long' into an index-sized integer
>>> "%f" % 2.17 * 10**27
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: cannot fit 'long' into an index-sized integer
>>> "%l" % 2.17 * 10**27
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: incomplete format

Now I ran out of ideas. I want to get
2170000000000000000000000000

How can I print such big numbers? (I don't care if it's a Python 2.7+ solution or a Python 3.X solution)

A: You are getting your operator precedence wrong. You are formatting 2.17, then multiplying that by a long integer:
>>> r = "%f" % 2.17
>>> r
'2.170000'
>>> r * 10 ** 27
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: cannot fit 'long' into an index-sized integer

Put parentheses around the multiplication:
>>> "%f" % (2.17 * 10**27)
'2169999999999999971109634048.000000'

This is one of the drawbacks of overloading the modulus operator for string formatting; the newer Format String syntax used by the str.format() method and the Format Specification Mini-Language it employs (and can be used with the format() function) neatly skirt around that issue. I'd use format() for this case:
>>> format(2.17 * 10**27, 'f')
'2169999999999999971109634048.000000'


text:
Q: Soap, Jquery, Ajax and an Error Ok, here is what I am trying to do.  I have a list on another site.  I have successfully connected to the site and pulled in the list as a dropdown using soap, ajax and jquery.  However, once I try and submit the new item, it gives me an error.  Here is the code I am using,
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
$(document).ready(function() {
var soapEnv =
    "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
        <soapenv:Body> \
            <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                <listName>b9ac31cc-ea35-4df1-af50-4e3fa9e86b1c</listName> \
                <viewName>7E918A0F-631B-4B3B-81FD-B27C98586DC4</viewName> \
                    <viewFields> \
                        <ViewFields> \
                            <FieldRef Name='Title' /> \
                        </ViewFields> \
                    </viewFields> \
            </GetListItems> \
        </soapenv:Body> \
    </soapenv:Envelope>";

    $.ajax({
        url: "/sites/wellness/_vti_bin/lists.asmx",
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        complete: processResult,
        contentType: 'text/xml; charset="utf-8"'
    });

    $('#addThis').bind('click',function(){
        var choice = $('#chooseOrg').val();
        alert(choice);
        $('#ctl00_m_g_03d6c665_34ef_42f1_9e55_ae2a2560edc7_ff4_1_ctl00_ctl00_TextField').val(choice)
    });
});

function processResult(xData, status) {
    $(xData.responseXML).find("[nodeName='z:row']").each(function() {
        //$('#chooseOrg').
        $('#ctl00_m_g_83e35e85_85ae_4056_9d87_b56fe029295b_ff41_ctl00_DropDownChoice').
        append($("<option></option>").
        attr("value",$(this).attr("ows_Title")).
        text($(this).attr("ows_Title")));
    });
};
</script>

Here is the Error Screen.

If I remove the soap/ajax/and jquery it adds a new item like it is supposed to, Any Ideas??

A: I think the issue is that the options you are adding to the select don't have the same ids as the values in the source list. You're using the Title for both the option text and the value. Assuming that the DropDownChoice is a Lookup column, you need to use the right id for each option to match what would be saved if you weren't running your script.


text:
Q: Problem with N-repeating a set of commands | Katalon Chrome extension This works perfectly for a long time in the old Selenium IDE Firefox add-on but it doesn't work properly in the Katalon Chrome extension.
Basically, I'm opening a particular link, I'm writing a text in a specific field and I click on a button to submit the entered value. The first command  store | 5 | Y should result in the procedure written in the previous sentence to be executed 5 times (not simultaneously). For some reason, in the Katalon extension I only get 2 full repeats and one partial one (text entered without submitting it), after which the execution is stopped and the log says "Test case passed".
Screenshot

Thank you in advance for any solution.


text:
Q: Error message positioning on radio button JQuery Validation I have a radio button where only one should be checked. However the error message was showing on the wrong place, it is showing on the first radio button which is the "walk in". I want it to show under the choices of the radio buttons, under the radio button "under".
Here is my code
<form class="form-horizontal" id="formApplication" role="form">

          <input type="radio" name="rbtnFind" id="rbtnWalkIn" value="Walk-In"> Walk-In

           <input type="radio" name="rbtnFind" id="rbtnJobFair" value="Job Fair"> Job Fair

           <input type="radio" name="rbtnFind" id="rbtnSocialMedia" value="Social Media"> Social Media

             <input type="radio" name="rbtnFind" id="rbtnReferred" value="Referred"> Referred

              <input type="radio" name="rbtnFind" id="rbtnOther" value="Other"> Other

     <button type="submit" class="btn pull-right" id="btnContinue1">Continue</button>
  </form>

And the JQuery
$("#formApplication").submit(function(e){
     e.preventDefault();
 }).validate({
     rules:{
        rbtnFind: "required"
     },
     messages: {
        rbtnFind: "Please select an option"
     },
     highlight: function(element){
        if($(element).attr('type') == 'radio'){
             $(element.form).find("input[type=radio]").each(function(which){
                 $(element).closest('.form-group').addClass('has-error');
             });
                    }
        else {
             $(element).closest('.form-group').addClass('has-error');
        }
     },
     unhighlight: function(element){
         $(element).closest('.form-group').removeClass('has-error');
     },
     errorElement: 'span',
     errorClass: 'help-block',
     errorPlacement: function(error, element) {
         if(element.parent('.input-group').length) {
               error.insertAfter(element.parent());
         } else {
                error.insertAfter(element);
         }
      },
      submitHandler: function(form) {
           //submit code
      }
      });

Here is the code in JSFiddle.

A: Here my Fiddle - https://jsfiddle.net/skyr9999/8nm3tvph/ i hope it helps you, i made changes in js and add placeholder to html:
$("#formApplication").submit(function(e){
     e.preventDefault();
 }).validate({
     rules:{
        rbtnFind: "required"
     },
     messages: {
        rbtnFind: "Please select an option"
     },
     highlight: function(element){
        if($(element).attr('type') == 'radio'){
             $(element.form).find("input[type=radio]").each(function(which){
                 $(element).closest('.form-group').addClass('has-error');
             });
                    }
        else {
             $(element).closest('.form-group').addClass('has-error');
        }
     },
     unhighlight: function(element){
         $(element).closest('.form-group').removeClass('has-error');
     },
     errorElement: 'span',
     errorClass: 'help-block',
     errorPlacement: function(error, element) {
        $(".error_placeholder").html(error.html());
      },
        submitHandler: function(form) {
        $(".error_placeholder").html("");
           //submit code
      }
      });

A: $("#formApplication").submit(function(e) {
  e.preventDefault();
}).validate({
  rules: {
    rbtnFind: "required"
  },
  messages: {
    rbtnFind: "Please select an option"
  },
  highlight: function(element) {
    if ($(element).attr('type') == 'radio') {
      $(element.form).find("input[type=radio]").each(function(which) {
        $(element).closest('.form-group').addClass('has-error');
      });
    } else {
      $(element).closest('.form-group').addClass('has-error');
    }

    //$(element).closest('.form-group').addClass('has-error');
  },
  unhighlight: function(element) {
    $(element).closest('.form-group').removeClass('has-error');
  },
  errorElement: 'span',
  errorClass: 'help-block',
  errorPlacement: function(error, element) {
    if (element.parent('.input-group').length) {
     error.insertAfter(element.parent());
    } else {
    console.log(error);
      error.insertAfter('.has-error'); //Replace has-error with element
    }
  },
  submitHandler: function(form) {

  }
});

A: I have made some changes to your script, see if you want it that way
<form class="form-horizontal" id="formApplication" role="form">

      <input type="radio" name="rbtnFind" id="rbtnWalkIn" value="Walk-In"> Walk-In

      <input type="radio" name="rbtnFind" id="rbtnJobFair" value="Job Fair"> Job Fair

      <input type="radio" name="rbtnFind" id="rbtnSocialMedia" value="Social Media"> Social Media

      <input type="radio" name="rbtnFind" id="rbtnReferred" value="Referred"> Referred

      <input type="radio" class="errorPlacement" name="rbtnFind" id="rbtnOther" value="Other"> Other

  <button type="submit" class="btn pull-right" id="btnContinue1">Continue</button>
</form>


text:
Q: SWIFT how to sort 2D array in 2nd dimension without having to transpose is there a way to sort a 2D array such that
[[9,8,7]
 [6,1,4]]

becomes
[[7,8,9]
 [4,1,6]]

I am building a table for a graph from a structure
var graphPoints = [[Double]]()
graphPoints.append(jsonResult!.highscoreRecord.map { ($0.Date.timeIntervalSince1970) })
graphPoints.append(jsonResult!.highscoreRecord.map { Double($0.Score) })
graphPoints.append(jsonResult!.highscoreRecord.map { Double($0.avDuration) })
graphPoints.append(jsonResult!.highscoreRecord.map { Double($0.Tries) })
// var sortedGraphPoints = graphPoints.sort { ($0[0]) < ($1[0]) }
var sortedGraphPoints = graphPoints.sort { ([0]$0) < ([0]$1) }

The line marked as a comment runs, however, sorts for the 1st element of each inner array, meaning it sorts the values within each data set instead sorting all data sets by date.
The last line results in the error "Binary operator '<' cannot be applied to two '([Int], [Double])' operands"
I found some code to transpose the array. But I did not really understand the code (I am new to Swift) and I would prefer keeping the structure.

A: It's a little hard to tell from your question, but apparently you have your data already organized in a struct that looks something like this:
struct HighscoreRecord: Decodable {
    let date: Date
    let score: Int
    let avDuration: Int
    let tries: Int
}

and your jsonResult!.highscoreRecord is of type [HighscoreRecord].
If you absolutely need to convert those to your graphPoints array, you should simply do the sorting before the conversion, as it is trivially easy:
let sortedRecords = jsonResult!.highscoreRecord.sorted { $0.date < $1.date }

and then use that as the input to your map calls.
PS: Try to avoid force-unwrapping via ! if you can.


text:
Q: Share Point 2013 url resolve after web app extend I have deployed SP 2013 WA in intranet with http://abc.de.fg that is working fine,
after that I have extended that WA to https://kl.mn.op all are working fine but pictures and some html links are still pointing to old intranet url that is http
SSL is working correctly this could be alternate access mapping I have tried with many ways on AAM but problem persist.
DNS entry is also fine because I can access my site on https with right user id and password. But may be some issue that I dont know ?
Any reply will be appriciated.


text:
Q: Error in creating website on GITHUB PAGES
I have made my project with bootstrap, html and css. But the Github pages are only showing the readme file and sending me the error mail. Please help me, this project is important for me

A: First of all, index.html is missing from your repository.
If you have used only Bootstrap, CSS, and HTML, you probably don't even need npm. You can just upload your files (including those folders for images and CSS) and then go to your Repository Settings and in Github Pages, set the source. If you have an index.html, then <username>.github.io/repo-name will render it automatically after a successful build.
You might find this repository which was made using HTML, CSS, Bootstrap (and Javascript) helpful to refer to.
PS: Don't push node_modules on GitHub. You should ideally add that folder to .gitignore. These modules can be installed by the user who clones your repo using npm commands.


text:
Q: How to add shipping method in magento How to change shipping rate in magento when check out.
i have many tried to make
<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Module_CustomShippingrate>
            <module>0.0.1</module>
        </Module_CustomShippingrate>
    </modules>
    <global>
        <models>
            <module_customshippingrate>
                <class>Module_CustomShippingrate_Model</class>
            </module_customshippingrate>
        </models>
    </global>

    <default>
        <carriers>
            <module_customshippingrate>
                <active>1</active>
                <model>module_customshippingrate/carrier</model>
                <title>Shipping Rate</title>
                <sort_order>10</sort_order>
                <sallowspecific>0</sallowspecific>
            </module_customshippingrate>
        </carriers>
    </default>
</config>

Call Of Shipping method class
public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
}

A: You need lot of work  for create custom shipping method:
Missing  system.xml
<?xml version="1.0"?>
<config>
   <sections>
    <carriers>
        <groups>
            <newmodule translate="label" module="shipping">
                Carrier Name
                <frontend_type>text</frontend_type>
                <sort_order>13</sort_order>
                <show_in_default>1</show_in_default>
                <show_in_website>1</show_in_website>
                <show_in_store>1</show_in_store>
                   <fields>
                      <account translate="label">
                            Account number
                            <frontend_type>text</frontend_type>
                            <sort_order>7</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </account>
                        <active translate="label">
                            Enabled
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </active>
                        <contentdesc translate="label">
                            Package Description
                            <frontend_type>text</frontend_type>
                            <sort_order>12</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </contentdesc>

                        <free_shipping_enable translate="label">
                            Free shipping with minimum order amount
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_enabledisable</source_model>
                            <sort_order>21</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </free_shipping_enable>
                        <free_shipping_subtotal translate="label">
                            Minimum order amount for free shipping
                            <frontend_type>text</frontend_type>
                            <sort_order>22</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </free_shipping_subtotal>
                        <dutiable translate="label">
                            Shipment Dutiable
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>13</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </dutiable>
                        <gateway_url translate="label">
                            Gateway URL
                            <frontend_type>text</frontend_type>
                            <sort_order>2</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </gateway_url>
                        <handling_type translate="label">
                            Calculate Handling Fee
                            <frontend_type>select</frontend_type>
                            <source_model>shipping/source_handlingType</source_model>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </handling_type>
                        <handling_action translate="label">
                            Handling Applied
                            <frontend_type>select</frontend_type>
                            <source_model>shipping/source_handlingAction</source_model>
                            <sort_order>11</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </handling_action>
                        <handling_fee translate="label">
                            Handling fee
                            <frontend_type>text</frontend_type>
                            <sort_order>12</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </handling_fee>
                        <max_package_weight translate="label">
                            Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)
                            <frontend_type>text</frontend_type>
                            <sort_order>13</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </max_package_weight>
                        <id translate="label">
                            Access ID
                            <frontend_type>text</frontend_type>
                            <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
                            <sort_order>5</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </id>
                        <password translate="label">
                            Password
                            <frontend_type>text</frontend_type>
                            <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
                            <sort_order>6</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </password>
                        <shipping_intlkey translate="label">
                            Shipping key (International)
                            <frontend_type>text</frontend_type>
                            <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
                            <sort_order>8</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </shipping_intlkey>
                        <shipping_key translate="label">
                            Shipping key
                            <frontend_type>text</frontend_type>
                            <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
                            <sort_order>8</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </shipping_key>
                        <sort_order translate="label">
                            Sort order
                            <frontend_type>text</frontend_type>
                            <sort_order>100</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </sort_order>
                        <title translate="label">
                            Title
                            <frontend_type>text</frontend_type>
                            <sort_order>2</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </title>
                        <sallowspecific translate="label">
                            Ship to applicable countries
                            <frontend_type>select</frontend_type>
                            <sort_order>90</sort_order>
                            <frontend_class>shipping-applicable-country</frontend_class>
                            <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </sallowspecific>
                        <specificcountry translate="label">
                            Ship to Specific countries
                            <frontend_type>multiselect</frontend_type>
                            <sort_order>91</sort_order>
                            <source_model>adminhtml/system_config_source_country</source_model>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </specificcountry>
                        <showmethod translate="label">
                            Show method if not applicable
                            <frontend_type>select</frontend_type>
                            <sort_order>92</sort_order>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </showmethod>
                        <specificerrmsg translate="label">
                            Displayed Error Message
                            <frontend_type>textarea</frontend_type>
                            <sort_order>80</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </specificerrmsg>
                    </fields>
                </newmodule>
            </groups>
        </carriers>
    </sections>
</config>

Shipping class is not define properly
Every shipping method have an unique identifier in your class it missing
<?php

/**
* Our test shipping method module adapter
*/
class Module_CustomShippingrate_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract
{
  /**
   * unique internal shipping method identifier
   *
   * @var string [a-z0-9_]
   */
  protected $_code = 'newmodule';

  /**
   * Collect rates for this shipping method based on information in $request
   *
   * @param Mage_Shipping_Model_Rate_Request $data
   * @return Mage_Shipping_Model_Rate_Result
   */
  public function collectRates(Mage_Shipping_Model_Rate_Request $request)
  {
    // skip if not enabled
    if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
        return false;
    }

    /**
     * here we are retrieving shipping rates from external service
     * or using internal logic to calculate the rate from $request
     * you can see an example in Mage_Usa_Model_Shipping_Carrier_Ups::setRequest()
     */

    // get necessary configuration values
    $handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');

    // this object will be returned as result of this method
    // containing all the shipping rates of this method
    $result = Mage::getModel('shipping/rate_result');

    // $response is an array that we have
    foreach ($response as $rMethod) {
      // create new instance of method rate
      $method = Mage::getModel('shipping/rate_result_method');

      // record carrier information
      $method->setCarrier($this->_code);
      $method->setCarrierTitle(Mage::getStoreConfig('carriers/'.$this->_code.'/title'));

      // record method information
      $method->setMethod($rMethod['code']);
      $method->setMethodTitle($rMethod['title']);

      // rate cost is optional property to record how much it costs to vendor to ship
      $method->setCost($rMethod['amount']);

      // in our example handling is fixed amount that is added to cost
      // to receive price the customer will pay for shipping method.
      // it could be as well percentage:
      /// $method->setPrice($rMethod['amount']*$handling/100);
      $method->setPrice($rMethod['amount']+$handling);

      // add this rate to the result
      $result->append($method);
    }

    return $result;
  }

  /**
   * This method is used when viewing / listing Shipping Methods with Codes programmatically
   */
  public function getAllowedMethods() {
    return array($this->_code => $this->getConfigData('name'));
  }
}

See at magento tutorial.How to create custom carrier method