text:
Q: Why does akka-stream's Source.groupedWithin not respect the duration? With akka-streams 2.4.17 Scala API, I'm trying to use Source.groupedWithin(size, duration) and specifying a duration. From the documentation and what I've seen in the source code, the grouping should proceed downward if either the group size or timeout is exceeded; whichever comes first.
When I run a simple workflow in fuzed mode (non-asynchronous), the duration doesn't appear to have any effect. However, when I put .async before or after the groupedWithin call, the timeout works.
Not Working Version
Source.fromIterator(() => aFiniteIterator)
  .map(aLongOperation(_))
  .groupedWithin(1000, 5.seconds) // keeps waiting beyond 5 seconds
  .map(somethingWithGroup(_))
  .runWith(Sink.fold(0)(_ + _))

Working Version
Source.fromIterator(() => aFiniteIterator)
  .map(aLongOperation(_))
  .async
  .groupedWithin(1000, 5.seconds) // now respects 5 seconds without full batch
  .map(somethingWithGroup(_))
  .runWith(Sink.fold(0)(_ + _))

Why is this? Is it possible the non-async version doesn't recognize downstream demand? Or is something else at play?
Update - Full Code Example with Output
For those who want to see the gory details, here is the full code I'm running. The context is that I'm experimenting with throttling throughout to avoid OOM exceptions.
case class Foo(id: String, value: String)

object Main {
  implicit val system = ActorSystem("akka-streams-oom")
  implicit val materializer = ActorMaterializer()

  def main(args: Array[String]): Unit = {
    println("starting tests...")
    val attempt = Try(forceOOM)

    attempt match {
      case Success(_) => println("all tests passed successfully")
      case Failure(e) => println(s"exception: e.getMessage")
    }

    println("terminating system...")
    system.terminate
    println("system terminated")
    println("done with tests...")
  }

  private def forceOOM: Unit = {
    println("executing forceOOM...")
    val sink = Sink.fold[Int, Int](0)(_ + _)

    val future =
      bigSource
        .map(logEmit)
        .via(slowSubscriber)
        .runWith(sink)

    val finalResult = Await.result(future, Duration.Inf)
    println(s"forceOOM result: $finalResult")
  }

  private def bigSource = {
    val largeIterator = () =>
      Iterator
        .from(0,1000000000)
        .map(_ => generateLargeFoo)

    Source.fromIterator(largeIterator)
  }

  private def slowSubscriber =
    Flow[Foo]
      .map { foo =>
        println(s"allocating memory for ${foo.id} at ${time}")
        Foo(foo.id, bloat)
      }
      .async  // if i remove this, the 5 second window below doesn't seem to work
      .groupedWithin(100, 5.seconds)
      .map(foldFoos)

  private def logEmit(x: Foo): Foo = {
    println(s"emitting next record: ${x.id} at ${time}")
    x
  }

  private def foldFoos(x: Seq[Foo]): Int = {
    println(s"folding records                                            at ${time}")
    x.map(_.value.length).fold(0)(_ + _)
  }

  private def time: String = LocalDateTime.now.toLocalTime.toString

  private def bloat: String = {
    (0 to 10)
      .map(_ => generateLargeFoo.value)
      .fold("")(_ + _)
  }

  private def generateLargeFoo: Foo = {
    Foo(java.util.UUID.randomUUID.toString, (0 to 1000000).mkString)
  }
}

Output Without Async (Extends Beyond Timeout)
[info] emitting next record: 5016fea4-f076-45dd-b95b-1d24f71a25b4 at 09:34:25.826
[info] allocating memory for 5016fea4-f076-45dd-b95b-1d24f71a25b4 at 09:34:25.868
[info] emitting next record: ab6e298b-0152-4af5-b685-bb4ed6c5b9de at 09:34:27.572
[info] allocating memory for ab6e298b-0152-4af5-b685-bb4ed6c5b9de at 09:34:27.572
[info] emitting next record: 6f5c1b75-5aaf-44e6-ac62-a6074735c057 at 09:34:28.957
[info] allocating memory for 6f5c1b75-5aaf-44e6-ac62-a6074735c057 at 09:34:28.958
[info] emitting next record: 313ce2b5-f669-4c59-b2ec-eafdae85ded6 at 09:34:30.378
[info] allocating memory for 313ce2b5-f669-4c59-b2ec-eafdae85ded6 at 09:34:30.378
[info] emitting next record: 91a8a95b-b3cc-4e27-8d3f-3400fa9c7a9f at 09:34:31.802
[info] allocating memory for 91a8a95b-b3cc-4e27-8d3f-3400fa9c7a9f at 09:34:31.802
[info] emitting next record: 0220e75a-029b-4d35-8494-690bed6938aa at 09:34:33.173
[info] allocating memory for 0220e75a-029b-4d35-8494-690bed6938aa at 09:34:33.174
[info] emitting next record: faa16b80-cfb1-4ea4-b3ba-c1d270caf865 at 09:34:34.409
[info] allocating memory for faa16b80-cfb1-4ea4-b3ba-c1d270caf865 at 09:34:34.409
[info] emitting next record: 8956d710-ad55-4dee-b4f3-82b8cf313a85 at 09:34:35.656
[info] allocating memory for 8956d710-ad55-4dee-b4f3-82b8cf313a85 at 09:34:35.656
[info] emitting next record: 1b989c56-6580-44f0-b8d9-46d5241046cc at 09:34:36.944
[info] allocating memory for 1b989c56-6580-44f0-b8d9-46d5241046cc at 09:34:36.945
[info] emitting next record: 66a766c7-29e0-40ca-b997-54985aad75d6 at 09:34:38.272
[info] allocating memory for 66a766c7-29e0-40ca-b997-54985aad75d6 at 09:34:38.272
[info] emitting next record: b8d29dad-bd44-4843-936e-5eb5df3bb594 at 09:34:39.530
[info] allocating memory for b8d29dad-bd44-4843-936e-5eb5df3bb594 at 09:34:39.530
[info] emitting next record: 8c7999cf-7796-427e-a155-c28d7fc4a934 at 09:34:40.987
[info] allocating memory for 8c7999cf-7796-427e-a155-c28d7fc4a934 at 09:34:40.988
[info] emitting next record: eda79635-4559-4c92-a5b7-83bbfc2e85b2 at 09:34:42.382
[info] allocating memory for eda79635-4559-4c92-a5b7-83bbfc2e85b2 at 09:34:42.382
[info] emitting next record: 8fa5d744-70e8-4261-9c3f-427737233e13 at 09:34:43.593
[info] allocating memory for 8fa5d744-70e8-4261-9c3f-427737233e13 at 09:34:43.593
[info] emitting next record: cc621484-c70d-4092-8dc6-2e39acc1f0b3 at 09:34:44.983
[info] allocating memory for cc621484-c70d-4092-8dc6-2e39acc1f0b3 at 09:34:44.983
[info] emitting next record: fbc03c9c-1ea8-4d4d-9a80-13118324140d at 09:34:46.244
[info] allocating memory for fbc03c9c-1ea8-4d4d-9a80-13118324140d at 09:34:46.244
[info] emitting next record: 96374d33-e117-4f48-b3be-79b8cb1e0fda at 09:34:47.953
[info] allocating memory for 96374d33-e117-4f48-b3be-79b8cb1e0fda at 09:34:47.953
[info] emitting next record: 1c210d73-35d3-41b9-ade6-9310783589a3 at 09:34:49.303
[info] allocating memory for 1c210d73-35d3-41b9-ade6-9310783589a3 at 09:34:49.303
[info] emitting next record: 3872c382-17a9-484a-861c-6f66a0c7d0ca at 09:34:50.620
[info] allocating memory for 3872c382-17a9-484a-861c-6f66a0c7d0ca at 09:34:50.620
[info] emitting next record: c34ba954-a9ff-45d1-910c-316c6eb9c85d at 09:34:52.597
[info] allocating memory for c34ba954-a9ff-45d1-910c-316c6eb9c85d at 09:34:52.597
[info] emitting next record: 8e5f804e-5e75-4eac-937f-651d45e3745d at 09:34:54.145
[info] allocating memory for 8e5f804e-5e75-4eac-937f-651d45e3745d at 09:34:54.145
[info] emitting next record: 1caf82cc-7b41-4730-bcc1-ca61ee7780e0 at 09:34:56.454
[info] allocating memory for 1caf82cc-7b41-4730-bcc1-ca61ee7780e0 at 09:34:56.455
[info] emitting next record: 9364d386-408a-4b63-80b5-0ed34473ba45 at 09:34:58.706
[info] allocating memory for 9364d386-408a-4b63-80b5-0ed34473ba45 at 09:34:58.706
[info] emitting next record: c43baaba-961e-4877-9835-7eeee538f0af at 09:35:00.822
[info] allocating memory for c43baaba-961e-4877-9835-7eeee538f0af at 09:35:00.822
[info] #
[info] # java.lang.OutOfMemoryError: Java heap space
[info] # -XX:OnOutOfMemoryError="kill -9 %p"
[info] #   Executing "kill -9 96871"...
java.lang.RuntimeException: Nonzero exit code returned from runner: 137
    at scala.sys.package$.error(package.scala:27)

Output With Async (Timeout Works)
[info] emitting next record: 668d6f9f-43cc-45a6-99b3-d8e8ab2b9cae at 09:28:48.188
[info] allocating memory for 668d6f9f-43cc-45a6-99b3-d8e8ab2b9cae at 09:28:48.231
[info] emitting next record: 6c50b3e1-d3ec-422e-b41a-fe3d92df15a9 at 09:28:48.333
[info] emitting next record: 20b659f9-73e1-4c67-b251-2b224eec4d24 at 09:28:48.421
[info] emitting next record: 9af08f07-8246-498b-9f64-b56982cf3536 at 09:28:48.497
[info] emitting next record: 14cdf3b4-d14f-4953-8609-24c7a1996a12 at 09:28:48.569
[info] emitting next record: 571002f3-7301-4afa-8bc9-3fb8a9e84db2 at 09:28:48.665
[info] emitting next record: 5e88a51b-b56c-40fe-84a3-2fcf18b90e3f at 09:28:48.787
[info] emitting next record: e66b29f3-1690-4645-a048-19049e92303a at 09:28:48.846
[info] emitting next record: 66c16074-b200-4808-a990-13abadc66e43 at 09:28:48.943
[info] emitting next record: 1de8caca-fa48-4777-90a7-1449bd6722bb at 09:28:49.003
[info] emitting next record: bc3859b6-94ab-4262-b4cd-fa757e8f3f1f at 09:28:49.064
[info] emitting next record: 988216a7-5944-4aa5-98f6-b36542d8e7a8 at 09:28:49.172
[info] emitting next record: e6ab4ef6-1fd2-471b-8866-2f8422346df5 at 09:28:49.325
[info] emitting next record: c86b3116-70c8-453e-9ddf-bd8d9e144caf at 09:28:49.384
[info] emitting next record: 78c68185-cdd1-4fde-aa39-e03b37b5f449 at 09:28:49.603
[info] emitting next record: 7ed11952-ceba-47f5-9ba4-25d1e9dceea0 at 09:28:49.671
[info] allocating memory for 6c50b3e1-d3ec-422e-b41a-fe3d92df15a9 at 09:28:50.164
[info] allocating memory for 20b659f9-73e1-4c67-b251-2b224eec4d24 at 09:28:51.459
[info] allocating memory for 9af08f07-8246-498b-9f64-b56982cf3536 at 09:28:52.752
[info] folding records                                            at 09:28:53.106
[info] allocating memory for 14cdf3b4-d14f-4953-8609-24c7a1996a12 at 09:28:53.969
[info] allocating memory for 571002f3-7301-4afa-8bc9-3fb8a9e84db2 at 09:28:55.234
[info] allocating memory for 5e88a51b-b56c-40fe-84a3-2fcf18b90e3f at 09:28:56.422
...

A: I suspect you are simulating aLongOperation using a Thread.sleep or some other blocking operation.
If this is the case, without forcing an async boundary the whole of your graph would share the same actor - and therefore the same thread. Blocking that thread causes the underlying dispatching infrastructure to starve (see docs).
Try to simulate your long operation in a non-blocking fashion (e.g. using the after pattern).
See also the following issue that was raised on the subject.


text:
Q: jQuery .on("click"...) with dynamically created elements not working So I am having some troubling results with jQuery ".on" function and a dynamically created element, the code I am using is this:
this is called in a function sometime random during runtime:
$(".activity-feed").append('
\

\

\

\

\

\

\
            '+username+' \
                \
                    \
                        '+$(".comment-box").html()+'\
                    \
                \

\
                '+time+'\

\

\

');

and then this function should allow for comment deletion (its defined at the bottom of the page, not after document ready)
$(".delete").on("click", function() {
    alert('test....');
});

however, I click on the "ucomment-delete" button, and nothing happens :(, however if I click the comments that were there on load, it works
Why is this? What am I doing wrong?

A: try event delegation
$(document).on("click", ".delete", function() {
 alert();
});

A: You need to bind it to an element that already exists on the page and then can specify a selector for elements that may not yet exist on the page:
$(".activity-feed").on("click",".delete", function() {
    alert('test....');
});

See this fiddle for an example:
http://jsfiddle.net/G4MGZ/

A: if on is not working then your jquery version is older try delegate
$('body').delegate('.delete','click',function(){
 //stuff
});

A: The .on() HAS to be wrapped in a document.ready(), even if it's at the end of the file. And I think what @John Koemer says is true, too.

redpajama_set_name: RedPajamaStackExchange


text:
Q: getting python in Jupyter notebook I've already installed python3 on my computer.
when I started a new Jupyter notebook I selected python 3
but now on the notebook, it is saying it isn't there
when I run this:
print(python_version())
i get this error:
NameError                                 Traceback (most recent call last)
 in
----> 1 print(python_version())
NameError: name 'python_version' is not defined

A: python_version() function is from platform module; So you have to import it first:
import platform
print(platform.python_version())

Another way to check python version is sys module:
import sys
print(sys.version)


text:
Q: C# EF Core: How to map One-to-Zero with multiple properties (with Attributes only) [With Workaround]? Community,
I tried my first Entity Framework Core project. Now I am unable to map the properties in my models, these are NOT One-to-One relations, I would call it "One-to-Zero":
public class ContactDetails
{
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }

    [ForeignKey("CreatedById")]
    public User CreatedBy { get; set; }

    [ForeignKey("UpdatedById")]
    public User UpdatedBy { get; set; }

    [ForeignKey("DeletedById")]
    public User DeletedBy { get; set; }

    // foreign keys
    public int? CreatedById { get; set; }
    public int? UpdatedById { get; set; }
    public int? DeletedById { get; set; }
}

public class User
{
    public int Id { get; set; }
    public string MailAdress { get; set; }
    public string Password { get; set; }

    [ForeignKey("ContactDetailsByUserId")]
    public ContactDetails ContactDetailsByUser { get; set; }
    [ForeignKey("ContactDetailsByAdminId")]
    public ContactDetails ContactDetailsByAdmin { get; set; }

    // foreign keys
    public int? ContactDetailsByUserId { get; set; }
    public int? ContactDetailsByAdminId { get; set; }
}

So ContactDetails can have three different Users.
Usercan have two different ContactDetails.
If I try to create a migration for this, I get this error:

Unable to determine the relationship represented by navigation property 'ContactDetails.CreatedBy' of type 'User'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

I really want to do this with Attributes only, if this is possible, anyway with the Fluent-API this works:
protected override void OnModelCreating(ModelBuilder builder)
{
    builder.Entity<ContactDetails>().HasOne(c => c.CreatedBy).WithOne().HasForeignKey<ContactDetails>(c => c.CreatedById).OnDelete(DeleteBehavior.ClientSetNull);
    builder.Entity<ContactDetails>().HasIndex(c => c.CreatedById).IsUnique(false);

    builder.Entity<ContactDetails>().HasOne(c => c.UpdatedBy).WithOne().HasForeignKey<ContactDetails>(c => c.UpdatedById).OnDelete(DeleteBehavior.ClientSetNull);
    builder.Entity<ContactDetails>().HasIndex(c => c.UpdatedById).IsUnique(false);

    builder.Entity<ContactDetails>().HasOne(c => c.DeletedBy).WithOne().HasForeignKey<ContactDetails>(c => c.DeletedById).OnDelete(DeleteBehavior.ClientSetNull);
    builder.Entity<ContactDetails>().HasIndex(c => c.DeletedById).IsUnique(false);

    builder.Entity<User>().HasOne(u => u.ContactDetailsByUser).WithOne().HasForeignKey<User>(u => u.ContactDetailsByUserId).OnDelete(DeleteBehavior.ClientSetNull);
    builder.Entity<User>().HasIndex(u => u.ContactDetailsByUserId).IsUnique(false);

    builder.Entity<User>().HasOne(u => u.ContactDetailsByAdmin).WithOne().HasForeignKey<User>(u => u.ContactDetailsByAdminId).OnDelete(DeleteBehavior.ClientSetNull);
    builder.Entity<User>().HasIndex(u => u.ContactDetailsByAdminId).IsUnique(false);
}

Maybe the Fluent thing will help someone, but is it possible to do this with Attributes only?
Thanks for your time.
Best Regards
Stewie


text:
Q: Scrolling past the end in IDEA Is there a way to enable being able to scroll past the last line in IntelliJ IDEA?
It's a nice feature that exists in some editors, as it lets you keep your eyes at the middle of the screen, rather than have to stare at the bottom of it
Is there any way to enable something like this? Either through the standard settings or via plugin?

A: File -> Settings -> Editor -> General -> Check Show virtual space at file bottom

A: Short way:
You could also hit shift key twice to open menu and write "show virtual space" and then just click on the option to toggle it on/off.

A: Mac: IntelliJ IDEA -> Preferences -> Editor -> General -> Check: Show virtual space at file bottom
PC: File -> Settings -> Editor -> Check: Show virtual space at file bottom


text:
Q: R data table select rows to update column I am trying to update a column for a selection of rows based on the value of the same column. this column contains characters from '1','2',....'10','11'. what I want to do is to combine 11 categories into 3. So my code look like
library(data.table)
DT <- data.table(col = as.character(1:11))
DT[col %in% c('1','2','3'), col := '3']
DT[col %in% c('4','5','6','7','8'), col := '2']
DT[col %in% c('9','10','11'), col := '1']

weirdly, the last line doesn't work. the '10' and '11' are not updated. when I change 'c' to list (below code), it seems to work. but i don't know why this is the case.
DT[col %in% list('9','10','11'), col := '1']

Any help will be much appreciated.


text:
Q: Availability of Cassandra I am running into an issue "me.prettyprint.hector.api.exceptions.HUnavailableException: : May not be enough replicas present to handle consistency level." when I have RF=1, Read Consistency Level = 1 and one of the nodes in 6 node ring/ cluster is down. All of my reads are failing with this exception. Any idea? Ideally only reads that are looking for data in the  node which is down should fail and all other reads should be successful?

A: There could be a few possibilities:

*

*You're running a multi-row query (get_range, get_indexed_slices, multiget, or the cql equivalents) that requires multiple nodes to be up

*Your cluster is unbalanced, with the down node owning most of the ring; a bad multi-dc configuration could also produce something similar

*Your cluster wasn't in a good state to begin with, where some nodes don't see others. Make sure nodetool ring shows the same output when run against each node in the cluster

If none of those are the cause, double check that you're specifying the consistency level correctly with Hector and cqlsh.

A: I've seen something similar when I mis-configured my replication settings, specifically I had the wrong datacenters named om the replication strategy.  Double check what your DCs are (assuming you're using NetworkTopologyStrategy).
If you don't already know your DC names, in a shell on one of the nodes run:
$ nodetool -h localhost ring
Address         DC          Rack        Status State   Load            Owns    Token
                                                                               141784319550391000000000000000000000000
172.26.233.135  Cassandra   rack1       Up     Normal  25.75 MB        16.67%  0
172.26.233.136  Cassandra   rack1       Up     Normal  26.03 MB        16.67%  28356863910078200000000000000000000000
172.26.233.137  Cassandra   rack1       Up     Normal  27.19 MB        16.67%  56713727820156400000000000000000000000
172.26.233.138  Cassandra   rack1       Up     Normal  26.78 MB        16.67%  85070591730234600000000000000000000000
172.26.233.139  Solr        rack1       Up     Normal  24.47 MB        16.67%  113427455640313000000000000000000000000
172.26.233.140  Solr        rack1       Up     Normal  26.66 MB        16.67%  141784319550391000000000000000000000000

You can see we have two DCs, Cassandra and Solr (this is a DSE cluster).
In cassandra-cli:
use Keyspace1;
describe;

CLI will print the strategy options:
Keyspace: Catalog:
  Replication Strategy: org.apache.cassandra.locator.NetworkTopologyStrategy
  Durable Writes: true
    Options: [DC1:3]
...

We have a mis-match.  Cassandra is looking for a datacenter named DC1 hence the UnavailableException.  We need to update the replication options to match the actual DCs in our cluster.  In CLI, update the strategy options for your keyspace using the data center names:
update keyspace Keyspace1 with strategy_options = {Cassandra:3,Solr:2};


text:
Q: PhoneGap CLI "cordova build ios" failed i have created a new hello world project using the following command,
cordova create hello com.example.hello HelloWorld

the project is created successfully, then i add the ios platform by
cordova platform add ios

and to verify i have it added correctly, i type
cordova platform list

the iOS platform is shown in the list. so at this point, according to the PhoneGap tutorial, i can use the command
cordova build ios

to build the iOS version of the project. however, i encounter the following error:
Generating config.xml from defaults for platform "ios"
Preparing ios project
Compiling app on platform "ios" via command "/Users/Aldour/PhoneGap/hello/platforms/ios/cordova/build"

/usr/local/lib/node_modules/cordova/node_modules/q/q.js:126
                    throw e;
                      ^
Error: An error occurred while building the ios project.
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cordova/src/compile.js:65:22)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

the results that i have googled are mostly concerning the android version, talking about the invalid environment path setting. i dont know if it is related since i can create and build a PhoneGap project targeting the android platform without problem.
here is my $PATH:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/bin/node:/usr/local/bin/npm:/Developer/SDKs/android-sdk-macosx/platform-tools:/Developer/SDKs/android-sdk-macosx/tools

EDIT:
problem solved by re-installing xcode from app store

A: I had the same problem in Android platform, and it was solved with the commands:
cordova platform rm android
cordova platform add android
cordova build android

in Node.Js console. try it in ios.
If you get an error with 'cordova platform add android', you may need to manually remove any android folders in your project folder hierarchy.

A: This resolved my issue:
cordova platform remove ios
cordova platform add ios
cordova build ios

A: If you run the build with --verbose, you will probably see some permission issues.  By default, XCode creates a folder of the build in ~/Developer, if you haven't changed it.  There probably is a permissions issue when creating that folder.  Just execute the following command:  sudo cordova bulid ios
That should fix your issue.


text:
Q: Why JSON not deserialized to NameValueCollection I have JSON object on client side like following:
    var myObject = {
      data1: 1,
      data2: 5,
      .......
    }

I am passing it to PageMethod and expecting that it will be deserialized as Dictionary<string, object>. It is working right. But when I replacing Dictionary in PageMethod signature with NameValueCollection deserialization failed. Why?

A: Because the JavaScriptSerializer that is used by page methods is not able to deserialize this JSON structure to a weakly typed NameValueCollection. Why would you want to do that instead of working with a strongly typed dictionary anyway?

A: NameValueCollection cannot be serialized like Dictionary because it does not implement IDictionary.
You can convert it to a dictionary and then try serializing.

A: You can try "mapping". In code you can use property Coll as NameValueCollection, but serialization/deserialization works with CollDictionary.
public NameValueCollection Coll
{
    get
    {
        var nvc = new NameValueCollection();
        CollDictionary.Keys.ToList().ForEach(a => nvc.Add(a, CollDictionary[a]));
        return nvc;
    }
    set
    {
        CollDictionary = value.AllKeys.ToDictionary(k => k, k => value[k]);
    }
}

[JsonProperty(PropertyName = "Coll")]
public Dictionary<string, string> CollDictionary { get; set; }


text:
Q: Angular Service to Share string from App component to other compooents How do I send the string from app.component.ts to the service and have the service send the string to the component.
I am using the Amplify Authentication and get the authstatus string to let me know if a user is signed in. I want to share this status with other components. This my attempt at creating a service, but need help.  I am sending the string from app.component.ts and forwarding it from the service to auth.component and others.
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';

@Injectable({
  providedIn: 'root'
})
export class AuthStatusService {

  authStatus: string;

  authStatusChange: Subject<string> = new Subject<string>();

  constructor()  {
      this.authStatusChange.subscribe((value) => {
          this.authStatus = value
      });
  }

}```

A: Simple solution will be using service as store for storing AuthStatus.
Please find below solution:
In your service declare one private variable and write getters and setters for it in service as below:
private authStatus :string;

//this method will be called for updating value of authstatus
setAuthStatus(value : string){
this.authStatus = value;
}

//you can fetch this method from any compononent to get the value of authstatus
getAuthStatus(){
return this.authStatus;
}

In your case,
in app.component.ts call setAuthStatus method and set value
this.service.setAuthStatus("your value");

in other components call getAuthStatus method and fetch the value
let authStatus = this.service.getAuthStatus();

A: You need to push the value to the observable. authStatus variable is negligible. Try the following
AuthStatusService
export class AuthStatusService {
  authStatusChange: Subject<string> = new Subject<string>();

  constructor() { }

  public getAuthStatus(): Observable<string> {
    return this.authStatusChange.asObservable();
  }

  public setAuthStatus(status: string) {
    this.authStatusChange.next(status);
  }
}

app.component.ts
login() {
  this.service.login().subscribe(
    response => {
      // handle login
      this.authStatusService.setAuthStatus(response.status);
    },
    error => {
      // handle error
    }
}

child.component.ts
ngOnInit() {
  this.authStatusService.getAuthStatus().subscribe(
    status => {
      // got login status
    }
  );
}

This way every child component will get the login status whenever a new login status is pushed in from the app component.


text:
Q: 5v/12vdc inputs and only one of those as outputs using PIC18fxxxx Hey all I am trying to find an IC that can accommodate having 2 inputs but only one output depending on what I send via a PIC18fxxxx micro controller. This sounds like it would be a DPST but I can't really find anything like that I can control from a PIC to choose what output needs to be on.
The 5vdc and 12vdc will be to power a PC FAN. The 5 and 12vdc will be coming from the PC PSU.
A 12vdc fan is around 0.25A ~4W
A 5vdc fan is around 0.18A ~2W

So something like so:
                |------|
---5vdc-in----->|  IC  |
---12vdc-in---->|  ?   |-----5 or 12vdc-out-->
---PIC pin-in-->|      |
                |------|

Or better visually is this:

The PIC pin would control the IC to let it know which voltage to output.
Does anyone know if this type of IC exists? I'll need to be able to do 10 outputs all together.

A: Look for an SPDT (or 1 Form C) relay.  If you want it to be an IC, you could look at a solid state relay.  Or, you could build something like this with complementary power switches (i.e., one is active high and the other active low).  Depending upon how much current you intend to put through it, you might also use an analog switch/mux.


text:
Q: I want to build a PDF doc, using Glen K. Peterson's Pdf Layout Manager, but I'm stuck at building a table I've decided to use Glen K Peterson's Pdf Layout Manager available on GitHub(https://github.com/GlenKPeterson/PdfLayoutManager) to generate PDF documents with my app, I've imported the source files and the pom.xml dependencies and everything, it's working just fine.
The problem is, I'm trying to build a table in one of the documents I want to generate with a button click. I have no idea how to extract(use) the TableBuilder, as I'm getting the error message inside my JDeveloper IDE, that the class has private access.
Here's my code:
private void jBtnSalvareVerMetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnSalvareVerMetActionPerformed
    // TODO add your handling code here:
    PDDocument document = new PDDocument();
    try {
        PDPage page = new PDPage();
        document.addPage(page);
        PDFont font = PDType1Font.COURIER;
        PDPageContentStream contents = new PDPageContentStream(document, page);
        contents.beginText();
        contents.setFont(font, 14);
        contents.newLineAtOffset(50, 500);
        Coord coordinate = new Coord(10, 700);
        PdfLayoutMgr pageMgr = PdfLayoutMgr.newRgbPageMgr();
        LogicalPage locatieTabel = pageMgr.logicalPageStart();
        TableBuilder tabel = new TableBuilder(locatieTabel, coordinate); // Getting the error at this point
        contents.newLineAtOffset(10, 700);
        contents.showText(tabel.toString());
        contents.endText();
        contents.close();
    } catch (IOException ex) {
        java.util.logging.Logger.getLogger(MeniuTaburi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } finally {
        try {
            document.close();
        } catch (IOException ex) {
            java.util.logging.Logger.getLogger(MeniuTaburi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
    }
    jLabelAverstismenteVerMet.setText("Datele au fost salvate cu succes!");
}//GEN-LAST:event_jBtnSalvareVerMetActionPerformed

I thought of changing the type of access permission from private to public, for the TableBuilder, but I don't think, that's the way it's actually supposed to work...
Is there any other way, I can build the table I need, without resorting to changing the access modifier, inside the TableBuilder class??

A: You try to use
TableBuilder tabel = new TableBuilder(locatieTabel, coordinate); // Getting the error at this point

But that constructor is private
    private TableBuilder(LogicalPage lp, Coord tl) {
        logicalPage = lp; topLeft = tl;
    }

I.e. you are not meant to use it. Unfortunately there also is no JavaDoc indicating what you should use instead. But looking at the TableBuilder source a bit beyond that constructor, you'll find immediately following this:
    public static TableBuilder of(LogicalPage lp, Coord tl) {
        return new TableBuilder(lp, tl);
    }

Thus, instead of your direct constructor call you should use this factory method:
TableBuilder tabel = TableBuilder.of(locatieTabel, coordinate);


text:
Q: How to keep preferences saved even on un-installing app? I want my app to remember the preferences.we wont keep our app on play store.every time after reinstalling(next version) the app preferences are getting deleted.how can i resolve this?

A: From Data save for an android app after it uninstall or force data clear from settings, you can use a Google Backup. You can also try to create an external file that saves data.
https://developer.android.com/training/data-storage/files.html (choose external for saving)
However, the user can delete the files.


text:
Q: How to use Json library in web application I am working on a web application in JAVA, and I used org.json. in the project for some computation, but I get the following error message when I run the application from localhost.
   java.lang.NoClassDefFoundError: org/json/JSONObject

I specified the dependency in pom.xml
   <?xml version="1.0" encoding="UTF-8"?>

   <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org      /2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.cloudera.oryx</groupId>
   <artifactId>projectname</artifactId>
   <version>0.5.0-SNAPSHOT</version>
   <packaging>pom</packaging>

   <dependencyManagement>
     <dependencies>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
            <version>1.9</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-apache-client</artifactId>
            <version>1.9</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20140107</version>
        </dependency>
    </dependencies>
</dependencyManagement>

EDITED: Full Pom.xml content
What other thing should be done to get this to running? Thanks.

A: There may be various reasons, you get NoClassDefFoundError even after adding the dependency
The following are the checks you can do to get.

*

*Add the dependency in <dependencies> section of your main pom.xml. If you feel like I dont require JSON library in service layer in an application like Rest --> service --> DAO, then add in <dependencyManagement> section and add the dependency with out version - in which ever module you want.

*You need to make sure that your settings.xml is configured right enough to get the jar files downloaded for you.

*Another possibility is refresh your workspace if you are using some IDE - eclipse, IntelliJ to get the dependencies updated.

*You can check .m2 --> repository --> org --> json --> <version> folder is available or not. This confirms that the jar is downloaded and you can tick point 2 as confirmed.

*You can unarchive the war file and check in the libraries whether the json jar file is added to your end packaging or not. This is the final place to check.

*You can use mvn -U clean install to update the dependencies.

A: I think the problem is your POM's "packaging"
The normal way to build a webapp is to specify the packaging as "war" so that Maven will build a WAR file containing your code and the dependent JARs.  You then deploy the WAR file to the web container.
But you are using packaging "pom".

*

*I'm assuming that means you've got another (child) POM file to build your application JAR.

*I'm also guessing that you are using "jar" as the packaging in that POM.

*I'm also assuming that you are then deploying the JAR to web container; e.g. by hand or using some IDE integration thingy.
I think that the problem here is that while you are deploying your JAR file to the web container, and you don't need to deploy the Jersey dependencies ('cos they are already there!!), you are NOT deploying the "json.org" JAR file.
At any rate, the reason that you are getting the exception is that the web container classloader cannot find that JAR file.  If you are deploying without using a WAR, something has to copy the file to the place where the web container's classloader is going to look.


text:
Q: what does two slashes in jQuery mean Could someone explain this line of jQuery? I'm not sure what the slashes mean:
var age=$('#main\\:mainForm\\:months').val();

A: It's the escape character, so it means to use the literal : value, so look for an element with id="main:mainForm:months"
See http://api.jquery.com/category/selectors/ for more information

A: as they're backslashes, the first backslash escapes the second backslash, so the actual contents of the string evaluates to:
#main\:mainForm\:months

The : character has special meaning in selections. It allows for custom expressions such as :nth-child(). using the \ character to escape the : allows you to select an element with an [id] attribute of #main:mainForm:months

A: From the documentation:

To use any of the meta-characters ( such as
  !"#$%&'()*+,./:;<=>?@[\]^`{|}~ ) as a literal part of a name, it must
  be escaped with with two backslashes: \\.


text:
Q: Select string after word in JS regex Is there any way to select a string after a specified word?
I found many examples how to select with classic regex:
(?<=^License:\W)(\w.*)$

...but JS regex is not supporting positive look behind.
I would like to match string after word "License:":
License: 1234-YXCMD-12XMDM-XXXCC

Is there any solution? I would like to use it on http://integromat.com, which supports only JS regex format.

A: Here's a good doc from MDN:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Assertions#Types
So here's something you can do:

let str = "License: 1234-YXCMD-12XMDM-XXXCC"
let regexp = /(?<=License: ).*/
console.log(str.match(regexp)[0]) // get 1234-YXCMD-12XMDM-XXXCC

EDIT: This only works in the newest version of Google Chrome as pointed out by @the fourth bird


text:
Q: Kentico 7 How to access new product type fields using API I have created a new product document type in Kentico in site manager / document types.  I added new fields such as size and color.  In the ecommerce tab I selected "Document type represents a product type".  This created a new table for my new document type in the database with the custom fields.
I am able to add a new content item of this type in my products section in cms desk / content.  But in my code, I am not sure how best to use the API in order to access the custom fields I created for this document type.  When it was just a product I would use the following:
CMS.Ecommerce.SKUInfoProvider.GetInfoById(PredefinedObjectType.SKU, id)
I can still get the sku info for my new product type using this method, but I do not see how I can access the custom fields I created for my new product type.
Also, I am not sure how Kentico is tying the new table with my custom fields for this product type to the COM_SKU table

A: I suggest to look at API examples, which you can find in Site manager - Support - Api Examples - Ecommerce. I belive for your situation you have to use document API. Custom fields are accessed by GetValue and SetValue methods.
For your case you should use something like this example:
private bool GetAndUpdateProductDocument()
{
    TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

    // Get the product document
    TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/MyNewProduct", null, true);

    if (node != null)
    {
        // Set the properties
        node.SetValue("ProductDescription", "Product was updated.");
        node.DocumentName = node.DocumentName.ToLowerCSafe();

        // Update the product document
        DocumentHelper.UpdateDocument(node, tree);

        return true;
    }

    return false;
}

A: The way Kentico ties the CMS to the EMS(E-Commerce management system) is not instantly obvious.
It tries to keep them relatively separate. When you create a product instance in the tree, Kentico does two things:

*

*Stores it's ecommerce-relevant data as in a new row COM_SKU table (accessible in code as the SKUInfo object)

*Creates a new CMS_Tree row (as well as a matching CMS_Document row) of document type Product (or your document type inherited from product)
The database only holds one piece of info to link the two tables - the CMS_Tree.SKUNodeID, which is null for documents that aren't also SKU products.
Either of these tables lets you add custom fields via the Kentico Site Manager CMS. You can create custom fields within the Document Type for the product, or as custom fields for the SKU (within SiteManager->Development->System Tables->COM_SKU).
Depending on whether your information is relevant to the EMS or not should decide where you store it.
Looking at your question, you've already defined the custom fields within the Document part of the object, so would access them using:
TreeNode productTreeNode = TreeHelper.SelectSingleNode("/Home/TreeNode/Path/To/Product");
object customValue = productTreeNode.GetValue("[your_custom_field_name]");

However, If you needed to access custom fields you'd defined within the ecommerce part (the SKUInfo object), it's slightly more difficult. If you have access to the skuID:
SKUInfo skuObject = SKUInfoProvider.getSKUInfo(skuID);
skuObject.GetValue("[your_custom_field_name]");

If you have access to the TreeNode of the product, it should be castable as a SKUTreeNode, and the SKUInfo object (as well as its skuID) accessed from there:
SKUTreeNode skuNode = CurrentDocument as SKUTreeNode;
if( skuNode != null ) {
    skuNode.SKU.SKUID;
}

Also note:
There can be multiple tree nodes that are assigned a single SKU product. You can also create a product in the tree without also creating a matching SKU object. (There should be a checkbox when creating the instance within the CMS)


text:
Q: How to convert Date November 8 2019 to 11/08/19 Can you please let me know how do I convert November 8 2019 to 11/08/19 in Oracle SQL Statement

A: The Oracle DATE type is stored internally as a numeric value (not to be confused with the NUMBER type).  Consequently, an Oracle DATE has no format and it does not make sense to talk about converting a DATE from one format to another.
So, what you are asking about is how to convert a string representation of a particular date from one format to another.  The answer is to first convert the input string to a DATE using the input string's format and then convert the resulting DATE back to a string using the desired output format.
Like this:
select to_char(to_date('November 8 2019','MONTH DD YYYY'),'MM/DD/YY') from dual;


text:
Q: How to get the client IP address after got connection lost in twisted I know we can get the client (host) IP after connection has been established because at that time we will have transport attribute:
self.transport.getPeer()

but how do I get the IP address of the client in twisted TCP server when it lost connection to the server, as in after it got disconnected.

A: While this has already been answered, i thought i would quickly add mine so i do not forget this in the future... As we know, the docs for Twisted are .. well twisted...
def connectionLost(self):
    ip, port = self.transport.client
    print ip
    print port

By using the above, you can then simply match the ip/port against what ever database or means you have of keeping track of clients.
I ended up finding by using print vars(self.transport) and seeing the client object in the output/console... using classic php debugging here

A: Its a little late for that. I suggest you save this information when you have it. For example:
class YourProtocol(protocol.Protocol):

    def connectionMade(self):
        self._peer = self.transport.getPeer()

    def connectionLost(self):
        print 'Lost connection from', self._peer


text:
Q: Why doesn't this command work as an alias? I've been using the following command to list the ten largest files, at any depth, under the current directory:
find -type f -size +10M -exec ls -gGsSh1 {} + | awk 'NR<=10 {print $0}'

(I use awk instead of head to prevent a broken pipe error when the list is too long)
It works well, but it's evidently hard to remember and type every time. I tried putting this in .bash_aliases, but it doesn't work then (it prints 10 empty lines).
If I use less instead of awk, the output is presented correctly, but that means showing the whole list of files bigger than 10MB (my lower threshold), sorted by size, rather than only the top ones.
So, what's making awk choke as part of an aliased command here (assuming that's indeed the problem), and what can I do to fix it?

A: When using this command as an alias, $0 is no more protected by the single quotes so is converted to your shell name. These commands demonstrate it:
$ alias F="echo '$0'"
$ F
bash

The shell name (presumably bash) happen to be an unset awk variable name, leading to the empty lines.
One way to protect $0 from shell expansion would be to use something like:
alias F="find -type f -size +1k -exec ls -gGsSh1 {} + | awk 'NR<=10 {print \$0}'"

However, as this $0 is useless, you can just remove it from the awk statement.
find -type f -size +10M -exec ls -gGsSh1 {} + | awk 'NR<=10 {print}'

You can go further and remove the whole block as printing the selected line is awk default behavior anyway:
find -type f -size +10M -exec ls -gGsSh1 {} + | awk 'NR<=10'

Alternatively, you can just keep using head and discard the error message:
find -type f -size +10M -exec ls -gGsSh1 {} + 2>&1 | head


text:
Q: read event never triggered, using libevent I just write an echo server using libevent, but it seems that the read event is never triggered. The code is:
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <netinet/tcp.h>
#include <event.h>
#include <event2/event.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <arpa/inet.h>

static short ListenPort = 19999;
static long ListenAddr = INADDR_ANY;//任意地址,值就是0
static int   MaxConnections = 1024;

static int ServerSocket;
static struct event ServerEvent;

int SetNonblock(int fd)
{
    int flags;
    if ((flags = fcntl(fd, F_GETFL)) == -1) {
            return -1;
    }

    if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) {
            return -1;
    }
    return 0;
}

void ServerRead(int fd, short ev, void *arg)
{
    //1)when telnet on 1999 and send a string,this never prints,help!
    printf("client readble\n");
    fflush(stdout);
            struct client *client = (struct client *)arg;
    u_char buf[8196];
    int len, wlen;

    len = read(fd, buf, sizeof(buf));
    if (len == 0) {
            printf("disconnected\n");
            close(fd);
            event_del(&ServerEvent);
            free(client);
            return;
    } else if (len < 0) {
            printf("socket fail %s\n", strerror(errno));
            close(fd);
            event_del(&ServerEvent);
            free(client);
            return;
    }

    wlen = write(fd, buf, len);//1)client str never echo back
    if (wlen < len) {
            printf("not all data write back to client\n");
    }
}

void ServerWrite(int fd, short ev, void *arg)
{
//2)to be simple,let writer do nothing
/*  if(!arg)
    {
            printf("ServerWrite err!arg null\n");
            return;
    }
    int len=strlen(arg);
    if(len <= 0)
    {
            printf("ServerWrite err!len:%d\n",len);
            return;
    }
            int wlen = write(fd, arg, len);
        if (wlen<len) {
                printf("not all data write back to client!wlen:%d len:%d \n",wlen,len);
        }
*/
    return;
}

void ServerAccept(int fd, short ev, void *arg)
{
    int cfd;
    struct sockaddr_in addr;
    socklen_t addrlen = sizeof(addr);
    int yes = 1;

    cfd = accept(fd, (struct sockaddr *)&addr, &addrlen);
    if (cfd == -1) {
    //3)this prints ok
            printf("accept(): can not accept client connection");
            return;
    }
    if (SetNonblock(cfd) == -1) {
            close(cfd);
            return;
    }

    if (setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes)) == -1) {
            printf("setsockopt(): TCP_NODELAY %s\n", strerror(errno));
            close(cfd);
            return;
    }

    event_set(&ServerEvent, cfd, EV_READ | EV_PERSIST, ServerRead, NULL);
    event_set(&ServerEvent, cfd, EV_WRITE| EV_PERSIST, ServerWrite,NULL);
    event_add(&ServerEvent, NULL);

    printf("Accepted connection from %s \n", (char *)inet_ntoa(addr.sin_addr));
}
int NewSocket(void)
{
    struct sockaddr_in sa;

    ServerSocket = socket(AF_INET, SOCK_STREAM, 0);
    if (ServerSocket == -1) {
            printf("socket(): can not create server socket\n");
            return -1;
    }
    if (SetNonblock(ServerSocket) == -1) {
            return -1;
    }

    memset(&sa, 0, sizeof(sa));
    sa.sin_family = AF_INET;
    sa.sin_port = htons(ListenPort);
    sa.sin_addr.s_addr = htonl(ListenAddr);

    if (bind(ServerSocket, (struct sockaddr*)&sa, sizeof(sa)) == -1) {
            close(ServerSocket);
            printf("bind(): can not bind server socket");
            return -1;
    }

    if (listen(ServerSocket, MaxConnections) == -1) {
            printf("listen(): can not listen server socket");
            close(ServerSocket);
            return -1;
    }
    event_set(&ServerEvent, ServerSocket, EV_READ | EV_PERSIST, ServerAccept, NULL);
    if (event_add(&ServerEvent, 0) == -1) {
            printf("event_add(): can not add accept event into libevent");
            close(ServerSocket);
            return -1;
    }
    return 0;
}

int main(int argc, char *argv[])
{
    int retval;
    event_init();
    retval = NewSocket();
    if (retval == -1) {
       exit(-1);
    }
    event_dispatch();
    return 0;
}

The server is tested using Telnet, but the client receives nothing.
The question details are posted as comments in the code above, at 1)、2)、3).
Can someone help me find out why the read event is never triggered?

A: basically you should not set the accepted socket as EV_WRITE until you actually want to write to the socket. You are telling libevent "let me know when I can write to this socket", which is pretty much always. So ServerWrite is being called in a tight loop. In practice the only time you need EV_WRITE is if you are writing a buffer but all of the bytes are not written. You then need to save the unwritten portion of the buffer and use EV_WRITE to signal when the socket can be written to again.


text:
Q: Append New Slides from Sheets Data in Google Apps Script I have set up a Google Apps Script to generate new templated slides from data contained in a spreadsheet. This data would be updated regularly. I plan to set a project trigger to generate new slides on a regular basis.
Right now, I avoid the problem of duplicating slides during triggered updates by simply removing previously generated slides (see code example below) but I would love to simply append new slides rather than deleting and regenerating (to preserve any edits to previously generated slides).
Any tips and tricks from more experienced Javascript developers for this wayward R coder on how to approach this problem?
function myFunction() {
  var dataSpreadsheetUrl = "https://docs.google.com/spreadsheets/d/1RjA4BJ4IKyjlh_l6vNaC7Q8wgUet1eNBo4_KJiF1pbQ/edit";
  var ss = SpreadsheetApp.openByUrl(dataSpreadsheetUrl);
  var deck = SlidesApp.getActivePresentation();
  var sheet = ss.getSheetByName('test');
  var values = sheet.getRange(2, 1, sheet.getLastRow(), sheet.getLastColumn()).getValues();
  var slides = deck.getSlides();
  var templateSlide = slides[1];
  var presLength = slides.length;

  // remove previously generated slides
  // TODO: figure out how to append rather than delete and regenerate
  for (var i = 2; i < slides.length; i++){
    slides[i].remove()
  }

  values.forEach(function(page){
  if(page[0]){

   templateSlide.duplicate();
   slides = deck.getSlides();
   newSlide = slides[2];

   var shapes = (newSlide.getShapes());
     shapes.forEach(function(shape){
       shape.getText().replaceAllText('{{name}}',page[0]);
       shape.getText().replaceAllText('{{value1}}',page[1]);
       shape.getText().replaceAllText('{{value2}}',page[2]);
       shape.getText().replaceAllText('{{value3}}',page[3]);
       shape.getText().replaceAllText('{{value4}}',page[4]);
       shape.getText().replaceAllText('{{value5}}',page[5]);
       shape.getText().replaceAllText('{{value6}}',page[6]);
       shape.getText().replaceAllText('{{value7}}',page[7]);
       shape.getText().replaceAllText('{{value8}}',page[8]);
       shape.getText().replaceAllText('{{value9}}',page[9]);
       shape.getText().replaceAllText('{{value10}}',page[10]);
    });
   presLength = slides.length;
   newSlide.move(presLength);
  }
  });
}

A: Figured it out by updating the starting row by checking against presentation length!
function myFunction() {
  var dataSpreadsheetUrl = "https://docs.google.com/spreadsheets/d/1RjA4BJ4IKyjlh_l6vNaC7Q8wgUet1eNBo4_KJiF1pbQ/edit";
  var ss = SpreadsheetApp.openByUrl(dataSpreadsheetUrl);
  var deck = SlidesApp.getActivePresentation();
  var sheet = ss.getSheetByName('test');
  var slides = deck.getSlides();
  var templateSlide = slides[1];
  var presLength = slides.length;

  // new data update //
  var rowLength = sheet.getLastRow();
  var startRow = 2;
  // update startRow when not initial run
  if(presLength != 2){
    startRow = presLength;
  }
  // save newly generated data range
  var values = sheet.getRange(startRow, 1, sheet.getLastRow(), sheet.getLastColumn()).getValues();

  values.forEach(function(page){
  if(page[0]){

   templateSlide.duplicate();
   slides = deck.getSlides();
   newSlide = slides[2];

   var shapes = (newSlide.getShapes());
     shapes.forEach(function(shape){
       shape.getText().replaceAllText('{{name}}',page[0]);
       shape.getText().replaceAllText('{{value1}}',page[1]);
       shape.getText().replaceAllText('{{value2}}',page[2]);
       shape.getText().replaceAllText('{{value3}}',page[3]);
       shape.getText().replaceAllText('{{value4}}',page[4]);
       shape.getText().replaceAllText('{{value5}}',page[5]);
       shape.getText().replaceAllText('{{value6}}',page[6]);
       shape.getText().replaceAllText('{{value7}}',page[7]);
       shape.getText().replaceAllText('{{value8}}',page[8]);
       shape.getText().replaceAllText('{{value9}}',page[9]);
       shape.getText().replaceAllText('{{value10}}',page[10]);
    });
   presLength = slides.length;
   newSlide.move(presLength);
  }
  });
}


text:
Q: MySQL vs SQL Server Express (Compare Free DBMS) I am searching for a comparison table between MySQL and SQL Server Express.
Comparisons should include...

*

*Usage limit

*Tools (management/dev/backup/monitoring/...)

*"simultaneous connection"

It's for my company, I need to know what should I install.
It's for migrating from access db
if you have opinion, suggestions,....
Thank you

A: Microsoft provides a comparison between MySQL, SQL Server Express, and SQL Server Enterprise. Just go to http://www.microsoft.com/sqlserver/en/us/product-info/competitor-compare.aspx and pick MySQL in the dropdown box. Take it with a grain of salt, as the information is provided by Microsoft, the maker of SQL Server.
If you go to http://www.microsoft.com/sqlserver/en/us/product-info/compare.aspx and click on SQL Server Express, you will see just how restrictive the limitations are:
Express will run only using one CPU, will only use up to 1 GB of RAM, and will allow you to have a database up to 10 GB only.
If you do not want to face all those restrictions you should go with MySQL. MySQL provides InnoDB engine which is fully ACID compliant, you can have online backups by using mysqldump with correct options with InnoDB tables or by using Xtrabackup from Percona. I would recommend going with Linux for MySQL as it is usually a more stable platform and gives you more flexibility since many tools for MySQL are written for Linux. MySQL has replication and high availability if you go with MySQL Cluster.

A: Comparison of relational database management systems wiki contains feature comparisons for many RDBMSs.
Although SQL Server Express is not listed in the wiki, SQL Server is. You will have to look up Microsoft's comparison of what is different between SQL Server and SQL Server Express.

A: I will be totally honest with you. While MySQL works fine in Windows, I would not recommend it for any Enterprise use in Windows.
You should go with SQL Server Express because you will have a database that works great in Windows for Free. Should your company fully commit to Enterprise Database usage, you could simply upgrade to SQL Server (different advanced versions).
If you are going for moderate budget, go with MySQL, BUT SWITCH TO Linux. High Availability solutions fit Linux and Unix, not Windows.


text:
Q: Can you define namespace-less extension methods compatible with C#? I know you can define empty namespace extension methods in c#, can you define the same methods in F# for consumption by C#? I followed this general post on getting C# compatible extension methods, but I'm not having any luck figuring out the final step for a 1-1 conversion.
this is not a duplicate, I'm looking for the way to define extension methods that are in the global namespace as far as C# is concerned, not how to define regular extension methods in F# that C# can see.

A: You definitely can create such extension methods in F#. This may be achieved via Global Namespace exploiting the feature that an F# module declared outside of any namespace gets into this default global namespace as in the snippets below:
// Tested under Visual Studio 2013 Premium/F# 3.1:

// F# library module
[<System.Runtime.CompilerServices.Extension>]
module Extension
    [<System.Runtime.CompilerServices.Extension>]
    let Superb(s: System.String) = "Superb!!!"

and
// Use extension method on System.String from C# console app:
class Test
{
    static void Main(string[] args)
    {
        System.Console.WriteLine("abc".Superb());
    }
}


text:
Q: Text object gets deleted in Adobe Reader 11 In adobe acrobat x i was inserting text objects and when it is opened in adobe reader 10 it was opening properly.but in adobe reader 11 when i click on that pdf file text objects gets deleted.why this happens? How to solve it?
The source pdf file click here
The pdf file which has problem when double clicking on it in adobe reader 11.
click here

A: In a nutshell:
You try to change the contents of a free text annotation by changing its normal appearance stream.
This is insufficient: A compliant PDF viewer may ignore this entry and provide their own appearances. So it's mere luck that older Adobe Reader versions chose to not ignore your change.
Thus, you also need to change the information a PDF viewer is expected to create their own appearance from, i.e. foremost the rich text value of RC (in the free text annotation dictionary) that shall be used to generate the appearance of the annotation, and also the Contents value which is the Text that shall be displayed for the annotation.
Furthermore there are defects in your PDFs:

*

*the cross reference table in your first attempt result.pdf was broken;

*the intent (IT value) of the free text annotation in your source files is spelled incorrectly.

In detail:
Your result.pdf is broken. Different PDF viewers may display broken PDFs differently.
Some details:
It has been created based on your Src.pdf in append mode but additionally the following change in the original revision has been made to its /Pages object:
In the source:
6 0 obj
<</Count 6
/Type /Pages
/Kids [ 7 0 R 8 0 R 9 0 R 10 0 R 11 0 R 12 0 R ]
>>
endobj

In the result:
6 0 obj
<</Count 3
/Type /Pages
/Kids [ 7 0 R 8 0 R 9 0 R 12 0 R 11 0 R 10 0 R ]
>>
endobj

So the order of the last three pages was changed (which is ok) and the /Count was reduced from 6 to 3. This is inconsistent as there still are 6 child objects but according to the PDF specification ISO 32000-1, Count is

The number of leaf nodes (page objects) that are descendants of this node within the page tree.

Furthermore the cross reference stream of the appended revision is broken.
xref
0 1
0000000000 65535 f
24 1
0001465240 00000 n
57 1
0001466075 00000 n
66 1
0001466909 00000 n
73 1
0001467744 00000 n
93 1
0001473484 00000 n
131 1
0001478703 00000 n

The entries are 19 bytes long including their respectively ending single byte newline character According to the spec, though,

Each entry shall be exactly 20 bytes long, including the end-of-line marker.
The format of an in-use entry shall be: nnnnnnnnnn ggggg n eol
where [...] eol shall be a 2-character end-of-line sequence

There may be more errors in the PDF but you may want to start fixing these.
EDIT
Now with the new PDF Pay-in.pdf with a proper cross reference at hand, let's look at it more in-depth.
Adobe Preflight complains about many occurances of:
[...]
An unexpected value is associated with the key
    Key: IT
    Value: /FreeTextTypewriter
    Type: CosName
    Formal Representation: Annot.AnnotFreeText
    Cos ID: 86
    Traversal Path: ->Pages->Kids->[0]->Annots->[13]
[...]

Ok, let's look at that object 86:
86 0 obj
<<  /P 8 0 R
    /Type /Annot
    /CreationDate (D:20130219194939+05'30')
    /T (winman)
    /NM (0f202782-2274-44b8-9081-af4010be86d4)
    /Subj (Typewritten Text)
    /M (D:20130219195100+05'30')
    /F 4
    /Rect [ 53.2308 33.488 552.088 826.019 ]
    /DS (font: Helv 12.0pt;font-stretch:Normal; text-align:left; color:#000000 )
    /AP <</N 107 0 R >>
    /Contents (wwww)
    /IT /FreeTextTypewriter
    /BS 108 0 R
    /Subtype /FreeText
    /Rotate 90
    /DA (16.25 TL /Cour 12 Tf)
    /RC (<?xml version="1.0"?>

             wwww

         )
>>
endobj

Preflight stated that it is unhappy about the line /IT /FreeTextTypewriter. Looking at the PDF specification again uncovers for annotations with /Subtype /FreeText, i.e. Free Text Annotations specified in section 12.5.6.6:

IT name
  (Optional; PDF 1.6) A name describing the intent of the free text annotation (see also the IT entry in Table 170). The following values shall be valid:
FreeText The annotation is intended to function as a plain free-text annotation. A plain free-text annotation is also known as a text box comment.
FreeTextCallout The annotation is intended to function as a callout. The callout is associated with an area on the page through the callout line specified in CL.
FreeTextTypeWriter The annotation is intended to function as a click-to-type or typewriter object and no callout line is drawn.
Default value: FreeText

Thus, your value FreeTextTypewriter is invalid (remember, PDF names are case sensitive!). Therefore, the annotation is (slightly) broken which may already result in all kinds of problems.
But there are other important entries here, too, to understand your issue: All you do in your appended changes is to replace the appearance stream in object 107 (as per /AP <</N 107 0 R >>) of this annotation by a different one. But this annotation contains an RC value, too, which according to the specification is

A rich text string (see 12.7.3.4, "Rich Text Strings") that shall be used to generate the appearance of the annotation.

Thus, any PDF viewer may regenerate the appearance from that rich text description, especially as the specification in section 12.5.2 says about the content of the AP dictionary

Individual annotation handlers may ignore this entry and provide their own appearances.

Thus, simply replacing the normal appearance stream does not suffice to permanently change the appearance of that annotation, you have to change the appearance dictionary and at least remove any alternative source for the appearance.
Furthermore the entry /Contents (wwww) is not replaced by your appended changes either. So a PDF viewer trying to decide whether to use the appearance stream or not will feel tempted to somehow create a new appearance as your appearance stream in no way represents that value.
Especially when starting to manipulate the free text (e.g. when clicking into the PDF in your case), the PDF viewer knows it eventually will have to create a new appearance anyways, and unless the current appearance is as it would have created it anyway, the viewer may prefer to begin anew starting with an appearance derived from the rich text or even the contents value.


text:
Q: User-Friendly Automated File Organization I once used DropIt on Windows 10. Unfortunately, it's not compatible with Ubuntu. I've tried Dolphin as an alternative, but it can't do what I need.
I need either a way to install DropIt to make it work on Ubuntu without a great amount of technical knowledge, or a substitute that can do what DropIt does.
For the former: something which only requires a few copy-and-paste commands into the command line, direct installs, or Applmage/Snap downloads would do.
For latter, I need the following functions and features:

*

*User-friendly interface with minimum code (e.g., Boolean logic filter parameters, not Linux queries)

*Set multi-factor parameters (e.g., <5 KB, text type, within Video Games folder, does not contain "Incomplete" or "Scraps" in title)

*Can see inside file contents for the sake of filtering files and sending files to a specified destination (e.g., "Within Video Games folder, send to "Pokemon" subfolder if file content contains "Charizard")

*Filter many files at a time (Easy File Organizer has a limit of 30)

I am running Cinnamon on the latest version of Ubuntu, re-configured to look like Windows Vista, and I have installed Wine. (DropIt isn't even mentioned on Wine's website, in case you're wondering.)
It seems someone asked a similar question before, but it wasn't answered.


text:
Q: Need some ideas for writing automated tests I am writing some unit tests in VS 2010 using Selenium and C#. I have a couple of test cases. For instance, some of my test cases are:

*

*Launch the website: http://localhost:8080. Verify the Sign on page is present. Enter Username and Password, and Log in.

*Check to see if Search tab is present. Click on Search tab. Verify the tabs Search Books, Search Images, and Search Web are present.

*Click on Search Books. Type "C-Sharp for Dummies". Click Search. Verify appropriate results are returned.
Now, my question is: Is it a better idea to create separate classes for each of the above test cases or is it better to combine them to one class, and just have separate methods?
All three test cases are related to one another. By this I mean, executing #2 requires #1 to be complete first, and #3 requires #2 to complete first. If I make separate classes, I believe I will need to call the method in #1 in the class #2, and call methods in #1 and #2 in the class #3.
I am not so sure what would be a good idea for this. Thanks in advance.

A: If the tests are related, I would keep them in one file, but this is under the assumption on how many tests you have, because I would not want to have just one file with tons of tests, so I would logically put related tests in separate files.  I wouldn't get too boggled down on this especially if you don't have too many tests right now.
You can also try WatiN as an alternative to Selenium.

A: If you use something like NUnit to control your selenium testing then point 1 can be inside a SetUp as we can assume that all (or most) of your tests will need to log in to do anything. Since all your tests will fail if this fails it doesn't really need independent testing.
If you consider the interaction between point 2 and 3 there is some cross over and there is some independent testing.
If you consider the crossover testing (clicking the Search Books link) point 3 depends on point 2 to run before it is run, thus there is no point having two separate tests, if test 2 fails then test 3 will always fail.
In point 2 you are testing that three links appear, but in test 3 you are only clicking one of them thus point 2 could fail but point 3 succeed, thus they should be separate tests., however point 3 does not depend entirely on point 2.
Personally you have two options, if you are also going to test "Search Images" and "Search Web" then you should not have point 2 at all. The assertion of the visibility of the link and the clicking of the link should all be melded into point 3.
If you are not going to test "Search Images" and "Search Web" then it is fine to have point 2. However test 3 should not call point 2's method as it tests extra functionality that point 3 does not care about. It should assume the "Search Books" link is there and click it independently of point 2.


text:
Q: Does the Multiverse exist in the MCU? In Doctor Strange (2016), the Ancient One refers to the 'Multiverse'. But she only talks about the different dimensions inside one universe (Earth-199999 or the MCU) and not the actual Multiverse.
Since the Living Tribunal was also introduced in the movie, the Multiverse does exist. Does this mean that the Ancient One (or even Agamotto) doesn't know about the Multiverse?
I haven't read any comics but I love the new movies by Marvel Studios. I just saw Doctor Strange and read this article.

A: Yes, the Multiverse does exist in the MCU and it is stated as such in Doctor Strange as you mention.

The Ancient One: Learning of an infinite multiverse included learning of infinite dangers. And if I told you everything else that you don't already know, you'd run from here in terror.
Doctor Strange

It is worth noting though that there are other mentions of the Multiverse in Dcotor Strange, however, most of them appear to talk about the other dimensions rather than other universes. And so these mentions of the Multiverse are not actually talking about the Multiverse itself.

The Ancient One: The language of the mystic arts is as old as civilization. The sorcerers of antiquity called the use of this language "spells". But if that word offends your modern sensibilities, you can call it "program". The source code that shapes reality. We harness energy drawn from other dimensions of the multiverse, to cast spells, conjure shields and weapons to make magic.
Doctor Strange

Whilst we're on the note of false positives we should explore some things like the Multiverse but aren't actually it:

*

*Dimensions - as previously mentioned different dimensions, Astral, dark, etc., aren't actually different universes or part of the Multiverse and these are what we see throughout Doctor Strange.

*Alternate timelines - A major plot of Avengers: Endgame is the Time Heist which creates different timelines. These alternate timelines can be created and erased by removing something from the "past" or putting it back but these aren't the Multiverse.

*Mysterio - In Spider-Man: Far From Home Mysterio tells everyone he is from Earth, just not ours. He even gives the Earth's numbers , 833 for his and 616 for ours. However, he was lying and it was all an elaborate story and so this isn't the Multiverse and the numbers weren't real.

*The Nine Realms - These are the Realms, Asgard, Midgard, etc., and aren't the Multiverse.
We have no current further confirmation of a Multiverse as far as I am aware in the MCU. However, it is important to note that the Doctor Strange squeal is to be titled Doctor Strange in the Multiverse of Madness which would indicate that yes the Multiverse does exist in the MCU. However, until the film is out we do not know for sure.

From an out of universe perspective it is of course worth noting that the MCU is part of the "normal" Marvel Multiverse with it being listed as Earth-199999 and the main comics continuity is Earth-616. It's just that currently no other universe has interacted with the MCU yet.

A: The MCU is one universe that is part of the Multiverse. It is parallel to the universe of Howard the Duck (who was in Guardians of the Galaxy). It is also parallel to the main comics universe, the X-Men movie universe, the X-Men cartoon, universe (and basically all the others in the Marvel wiki).
Parallel universes exist independently of each other. Remember, the Infinity Stones came from some other part of the Multiverse.
They introduced the idea in Doctor Strange so viewers will have at least a clue of what's going on if they reboot the whole franchise, or for example, they get the mutant characters film rights back, the X-Men stories have a lot of internal history, so if they get the rights back, they could either have the beginnings of mutants showing up, causing a lot of changes to backstories like Magneto, who've been doing their very public thing for decades.
Otherwise, they'd have to explain how no one had even heard of the millions of mutant characters, so I'd bet they'd either reset the whole universe so there were mutants all along, or they'd remind their viewers of the multiverse, and have the existing mutants come on over from their current Fox-owned universe, even played by the same actors.


text:
Q: How do I redirect someone from one action to another in ASP.NET MVC when an action has completed? In my webapp (work in progress) I now try to allow new customers register to my webapp. I am deploying in Azure btw.
The idea I am working on:
www.[mysite].com/Register
This register page allows the "new" user to register his a new tenant.
customer.[mysite].com/Register
This pretty much looks as follows in code
    public ActionResult Register()
    {
        var url = Request.ServerVariables["HTTP_HOST"];
        var tenantNameParser = new TenantNameParser(url);

        if (!TenantRepository.Exists(tenantNameParser.TenantName))
        {
            return RedirectToAction("NewCustomer");
        }

        return View();
    }

In the above snippet I check if tenant exists, if not, redirect to new customer.
    [HttpPost]
    public ActionResult NewCustomer(Customer model)
    {
        if (ModelState.IsValid)
        {
            var tenant = new Tenant
                {
                    Name = model.TenantName,
                    Guid = Guid.NewGuid().ToString()
                };

            TenantRepository.Add(tenant);
            // TODO create a new user new tenant repository to do this stuff as 1 atomic action

            if (!UserRepository.Exists(model.AccountableEmailAddress))
            {
                // Attempt to register the user
                var createStatus = MembershipService.CreateUser(
                    model.AccountableUser,
                    model.Password,
                    model.AccountableEmailAddress);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsService.SignIn(model.AccountableUser, false);
                    return RedirectToAction("Index", "Home");
                }

                throw new Exception("crappy implemenation, improve");
            }
            FormsService.SignIn(model.AccountableUser, false);

            // TODO figure out how to redirect to tenant.site.com
            return RedirectToAction("Index", "Home");
        }

        return View(model);
    }

The code above creates a new customer, and in the end my //todo is what this question is about. How to redirect to an URL that includes the actual tenant in the form of tenant.domain.com?
I don't know if this "way of handling tenants" is a bad practice, if so please feel free to say so.
Question: How to redirect to a tenant URL ([tenantname.[mysite].com/Index/Home). Something like:
Redirect("tenantname", "Index", "Home") would be great, but of course doesn't exist. I google'd it for a bit, but didn't run into helpful links (that's mainly the reason why I think I am designing "the wrong thing").
Advice would be awesome! Thx a lot for your considerations in advance!
If I need to rephrase stuff because it's unclear what I ask for then please let me know.

A: To accomplish this, you need to look at Domain Routing for ASP .NET MVC.

A: Just my 2 cents, please correct me if it's wrong.
My understanding is, you cannot control the tenant name in [tenant name].yoursite.com in your code, as it's out of the scope of ASP.NET MVC. It's a CNAME of the domain yoursite.com. So some thoughts from my end below.

*

*I guess you need a program-able domain provider, which means you can create CNAME from your code. Then when a new customer registered, the actual URL might be yoursite.com/[tenant name]/. Then you map it to a new CNAME [tenant name].yoursite.com.

*I'm not sure an URL Rewrite can help you. Which means you create a new rule and if the incoming URL was [tenant name].yoursite.com, you map it to yoursite.com/[tenant name]/


text:
Q: How is an $O$-graph different from a directed graph? - Category Theory I'm reading Category Theory by Mac Lane and I'm trying to understand the paragraphs in the pictures included below.
What is the difference between a directed graph and an $O$-graph?
Why is the picture in the blue box considered an $O$-graph?
The blue box picture looks like two parallel morphisms between two digraphs both called $O$, and not an $O$-graph which is defined as a single digraph.
What does it mean by both functions domain and range the identity?

A:
What is the difference between a directed graph and an $O$−graph?

An $O$-graph is a directed graph where $O$ is the set of vertices (although the category of $O$-graphs differs substantially from the category of directed graphs—see Alex Kruckman's comment below). For example, this graph (public domain image from Wikimedia Commons, created by Wikimedia user     Booyabazooka) is a $\{1, 2, 3, 4\}$-graph:

Why is the picture in the blue box considered an $O$−graph?

The way MacLane defines a graph is as four pieces of information:

*

*A set $A$ of arrows

*A set $O$ of verticies

*A function $\partial_0: A \rightarrow O$, which defines the tail of each arrow

*A function $\partial_1: A \rightarrow O$, which defines the head of each arrow

For example, for the graph in the image above:

*

*$A$ is a set with 6 elements, which could be $\{e_1, e_2, \dots, e_6\}$.

*$O = \{1, 2, 3, 4\}$

*If $e_1$ is the top horizontal arrow from $1$ to $2$, then $\partial_0(e_1) = 1$ and $\partial_1(e_1) = 2$.

MacLane uses the shorthand $A \rightrightarrows O$ for the two functions $\partial_0: A \rightarrow O$ and $\partial_1: A \rightarrow O$.
The graph $O \rightrightarrows O$ means a graph where each element of $O$ is regarded as both a vertex and an arrow. By saying that $\partial_0$ and $\partial_1$ are both identity functions, he's saying that each element of $x \in O$, when regarded as an arrow, is a loop from the vertex $x$ to itself.

A: The directed graph has $A$ for arrows and $O$ for vertices. The $O$-graph has $O$ for its vertices. The $O$ just seems to be an explicit mention of the underlying set, whereas a graph can have any set of vertices.
I believe that they mean that the "simplest example" of an $O$-graph is the one where both of the arrows $O\to O$ are the identity.


text:
Q: Repeated references with multibib I am trying to cite multiple references, sorted by reference type (journal vs. conference). Some of the journal references cite the corresponding conference paper where the results originally appeared.
However, when I cite the conference paper in the journal reference, the conference paper bibliographic details re-appear in the journal bibliography, like so:
[J1] Blah blah. Journal paper. Extended version of [C1].
[J2] Blah blah. Conference paper.
[C1] Blah blah. Conference paper.
I only want the citation (eg. [C1]) and not the repeated reference (eg. [J2]).
Below is a MWE of my document code.
.tex file
% !TEX TS-program = pdflatexmk
\documentclass{article}

\usepackage[resetlabels, labeled]{multibib}

\newcites{%
    J,%
    C%
    }%
    {%
    Journal Articles,%
    Conference Articles%
    }

\begin{document}

\nociteJ{DoeKnuthJournal}
\nociteC{DoeKnuthConference}

\bibliographystyleJ{unsrt}
\bibliographystyleC{unsrt}

\bibliographyJ{./Publications}
\bibliographyC{./Publications}

\end{document}

.bib file
@article{
    DoeKnuthJournal,
    author  =   "Doe, John and Knuth, Donald",
    title   =   "A really good paper",
    journal =   "Journal of Good Papers",
    note    =   "Extended version of GP 2000 article \cite{DoeKnuthConference}",
}

@inproceedings{
    DoeKnuthConference,
    author  =   "Doe, John and Knuth, Donald",
    title   =   "A really good paper",
    booktitle = "Proceedings of Good Papers (GP 2000)",
}

A: Try splitting the bib file into two files, one for journals and one for conferences:
.tex file:
\documentclass{article}

\usepackage[resetlabels, labeled]{multibib}

\newcites{%
    J,%
    C%
    }%
    {%
    Journal Articles,%
    Conference Articles%
    }

\begin{document}

\nociteJ{DoeKnuthJournal}
\nociteC{DoeKnuthConference}

\bibliographystyleJ{unsrt}
\bibliographystyleC{unsrt}

\bibliographyJ{PublicationsJ}
\bibliographyC{PublicationsC}

\end{document}

PublicationsJ.bib:
@article{
    DoeKnuthJournal,
    author  =   "Doe, John and Knuth, Donald",
    title   =   "A really good paper",
    journal =   "Journal of Good Papers",
    note    =   "Extended version of GP 2000 article \cite{DoeKnuthConference}",
}

PublicationsC.bib:
@inproceedings{
    DoeKnuthConference,
    author  =   "Doe, John and Knuth, Donald",
    title   =   "A really good paper",
    booktitle = "Proceedings of Good Papers (GP 2000)",
}

This is somewhat unsatisfying, because it would be nice if you can leave all the references in the same bib file, but this seems to be a known limitation of multibib; see Section 1.3 of the documentation.


text:
Q: When using back button AJAX results have been lost So I've set up a pagination system similar to Twitter's where where 20 results are shown and the user can click a link to show the next twenty or all results. The number of results shown can be controlled by a parameter at the end of the URL however, this isn't updated with AJAX so if the user clicks on one of the results and then chooses to go back they have to start back at only 20 results.
One thought I've had is if I update the URL when while I'm pulling in the results with AJAX it should—I hope—enable users to move back and forth without losing how many results are shown.
Is this actually possible or have I got things completely wrong?
Also, how would I go about changing the URL? I have a way to edit the URL with javascript and have it be a variable but I'm not sure how to apply that variable to the URL.
Any help here would be great!
A side note: I'm using jQuery's load() function to do all my AJAX.

A: Not mentioned in the duplicate threads, but useful nonetheless: Really Simple History (RSH).

A: This would be the answer I would put here:
Browser back button and dynamic elements

A: You can't actually change the url of the page from javascript without reloading the page.
You may wish to consider using cookies instead. By setting a client cookie you could "remember" how many results that user likes to see.
A good page on javascript cookies.

A: The answer for this question will be more or less the same as my answers for these questions:

*

*How to show Ajax requests in URL?

*How does Gmail handle back/forward in rich JavaScript?
In summary, two projects that you'll probably want to look at which explain the whole hashchange process and using it with ajax are:

*

*jQuery History (using hashes to manage your pages state and bind to changes to update your page).

*jQuery Ajaxy (ajax extension for jQuery History, to allow for complete ajax websites while being completely unobtrusive and gracefully degradable).

A: First 3 results google returns:
first
second
third
I'll eat my shorts if none of them are useful. ^^
And yeah - you can't change URL through JS.


text:
Q: password using adduser --system while setting up OpenERP I followed the guide for installing OpenERP here and did this:
 sudo adduser --system --home=/opt/openerp --group openerp

Can somebody tell me what the password for this is?
I'm pretty sure I didn't set a password for this but the system prompts me for openerp password at certain stages in the installation.
I've already tried my root password and it doesn't work !


text:
Q: What is the recommended practice for creating tab view with multiple tabs in Cocoa desktop application What is the recommended practice for creating tab view with multiple tabs. Should I use single XIB file for all the views or have different XIB per views? my preference is to use multiple controllers for each view in the tab view and hence different xib files. How can I achieve it?
Is it possible to have multiple views in a single xib file for each tab view, each having different controllers?

A: Are the tabs always the same, or are they dynamic? If they're always the same, I tend to use a single xib file, just because it's easy. You can still use multiple controller objects — just make them subclasses of NSObject, and drop them all into the same xib.
I did do a quick Google to see if there was an easy way to use NSViewControllers with tab views, and I found this thread. That contains some sample code for how to use them, which would give you a separate controller class and xib per tab. Obviously, I haven't tried that code, so I can't vouch for it, but it might be a good enough start. (In that sample code, it instantiates a new view controller each time you switch tabs, which probably isn't what you want — if it were me, I'd instantiate them the first time a tab was swapped to, and then keep them in a dictionary in the window controller, and on subsequent switches then just pull out the respective view controller that already exists.)

A: The optimal approach depends on the complexity of your tabs. However, a XIB will soon get messy and cluttered when you add multiple views to them. Also you run the risk of a bloated controller.
I would say the best approach is to have a view and a controller per tab. This will make future extensions to your app much easier to implement.
You'll have a main controller (window or view) that handles the view (or window) that holds your tab view. This controller acts as the delegate for your NSTabView (see NSTabViewDelegate).
Once your controller receives the tabView:didSelectTabViewItem: message, you can create the sub controller that manages that specific tab. This controller will instantiate its associated view (initWithNib) and add it to the view hierarchy. You can repeat this process for each tab in your tab view. You can set things up in such a way that the main (top level) controller maintains a list of each sub controller so you need to create them only once.


text:
Q: How to make a form page element load its innerText before evaluating the page response using Puppeteer? I have a Puppeteer project that fills out a form input field, presses a button, then extracts the result that appears in a second form field ('#texta').
I expect the result to be the string that appears in the second field ('#texta') after it populates. I actually get an empty string. This suggests to me that page.evaluate() is being called before the form server returns the response triggered by pressing the run button.
How to I get Puppeteer to wait until the target form field populates? What am I doing wrong?

puppeteer.js

const waitUntilLoad = {
  waitUntil: 'load',
};

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto( url, waitUntilLoad, );
await page.click( listCheckboxSelector, );
await page.type( formInputSelector, targetList, );
await page.click( runButtonSelector, );

// this is the problematic section
// how to I make it wait for '#texta' element to populate its innerText?
const result = await page.evaluate( () =>
  document.querySelector('#txta') && document.querySelector('#txta').innerText.trim()
, waitUntilLoad, );

console.log( 'result\n', result, ); // expected: content, actual: null
console.log( 'result type: ', typeof result, ); // expected: string, actual: string
console.log( 'result length: ', result.length, ); // expected: number > 0, actual: 0

await browser.close();

A: You can wait for any complex scenario with page.waitFor passing it a function (or just use page.waitForFunction):
await page.waitFor( () =>  document.querySelector('#txta').innerText.trim() !== "")

As soon as the passed function returns a truthy value, the wait is over and the script continues.


text:
Q: Permission failure when pulling from gcr.io I have 2 VMs running on Google Compute Engine. They are identical except for the fact that they are running under different service accounts.
Both of those service accounts have (as far as I can tell) identical permissions on the buckets used by gcr.io

The init script that runs when the VM starts up pulls a docker container from gcr.io, on the VM running as data-dev-dp@project-id.iam.gserviceaccount.com the pull succeeds:
Unable to find image 'gcr.io/project-id/gdp/jupyterlab-py2-spark-notebook:1.9' locally
1.9: Pulling from project-id/gdp/jupyterlab-py2-spark-notebook
bc51dd8edc1b: Pulling fs layer
b56e3f6802e3: Pulling fs layer

on the VM running as data-dev-cmp@project-id.iam.gserviceaccount.com the pull fails:
Unable to find image 'gcr.io/project-id/gdp/jupyterlab-py2-spark-notebook:1.9' locally
/usr/bin/docker: Error response from daemon: pull access denied for gcr.io/project-id/gdp/jupyterlab-py2-spark-notebook, repository does not exist or may require 'docker login': denied: Permission denied for "1.9" from request "/v2/project-id/gdp/jupyterlab-py2-spark-notebook/manifests/1.9"

I was under the impression that having identical permissions on the bucket should be sufficient hence I'm wondering what other permissions are required in order to make this work. Could anyone suggest something?

UPDATE. I used toolbox (https://cloud.google.com/container-optimized-os/docs/how-to/toolbox) to verify that the permissions on the bucket are not the same for those two accounts:
# gsutil ls gs://artifacts.project-id.appspot.com
gs://artifacts.project-id.appspot.com/containers/

# gsutil ls gs://artifacts.project-id.appspot.com
AccessDeniedException: 403 data-dev-cmp@project-id.iam.gserviceaccount.com does not have storage.objects.list access to artifacts.project-id.appspot.com.

Clearly that's the cause of the issue, though I find it very strange that my screenshots above from the GCP Console suggest different. I am continuing to investigate.

A: This turned out to be a problem that is all too familiar to us because we are constantly creating infrastructure, tearing it down, and standing it up again. When doing so, particularly when those operations don't occur cleanly (as was the case today), we can find ourselves in a position whereby roles are assigned to an old instance of a service account. The console will tell you that the account has roles assigned to it but that's actually not the case. We encounter this problem often.
The solution on this occasion was to tear down all the infrastructure cleanly then recreate it again, including the service account that was exhibiting the problem.


text:
Q: Delphi 10.1 sem SQLConnection, ADOConnection, IBDatabase I'm new to Delphi, and I'm trying to find an componnent to connect with a SQL Server database. In Delphi XE I used ADOConnection, but I can't find any component that serves to this propose.

A: You're using the Starter Edition, which does not include database access components according to the Delphi Product Editions matrix. In order to connect to databases, you'll need to upgrade to a higher SKU (edition).
Most third-party alternatives won't work with Standard either, because the underlying classes they would need to use don't exist in the Standard SKU.


text:
Q: memory management in nested blocks References to local variables (including ivars) inside blocks are automatically retained to make sure it remains valid throughout the execution of the block.
That said, would this code lead to a premature deallocation of self.message, since the first block does not reference it, even though the second block does? Or is it smart enough to know it should be retained?
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    /* snip */
    dispatch_async(dispatch_get_main_queue(), ^{
        if ([self.message.ID isEqualToString:@"foobar"]) {
            /* snip */
        }
    });
});

A: A block captures all variables inside it, including nested blocks. In short: it does the "right" thing.
In this particular case, note that it's self that's being captured, not self.message.


text:
Q: Color-code plotly bars fill and border by factors I'm trying to produce a bar chart using R's plotly for these data:
df <- data.frame(name = c(paste0("B.",1:3),paste0("C.",1:3)),
                 x = 0:5, y = 0.2, width = 0.75,
                 group = c(rep("B",3),rep("C",3)),
                 class = c(rep("P",2),rep("X",2),rep("P",2)),
                 stringsAsFactors=F)

As you can see each name in df is associated with a group and a class.
I would like the bar fill colors for class P to obey their group and for class X to be transparent (or gray), but have the border colors of both class X and P to obey their group.
Here's how I'm producing the plot so far, only coloring by group:
df$group <- factor(df$group)
library(plotly)
library(dplyr)

plotly::plot_ly(df,showlegend=T) %>%
  plotly::add_bars(x=~x,y=~y,width=~width,color=~group) %>%
  plotly::layout(legend=list(x=1,y=0)) %>%
  plotly::layout(xaxis=list(title=NA,zeroline=F,tickangle=45,range=x.range,tickvals=df$x,ticktext=df$name),yaxis=list(title=NA,zeroline=F,showgrid=F,range=c(0,1),showticklabels=F))

Which gives:

Any idea?


text:
Q: I am creating a cygwin silent install, howeer, the "make" package will not install I am creating a cygwin silent install,  howeer, the  "make" package will not install.
I only need the following:
"%CD%\setup-x86.exe" ^
--no-shortcuts ^
--no-desktop ^
--quiet-mode ^
--root "C:\cygwin" ^
--arch x86 ^
--local-install ^
--local-package-dir "%CD%\https_3a_2f_2fcygwin.osuosl.org_2f" ^
--verbose ^
--prune-install ^
--packages make,gcc-g++,gdb
No matter what combination of packages I list, "Make" will not install.
Please advise


text:
Q: How to Phpstorm reindent if(not) if(!true){
   return 'wrong';
}

How to set reindent become to likes below ? psr
if(! true){
   return 'wrong';
}

A: *

*Settings/Preferences | Editor | Code Style | PHP

*Spaces tab

*Other | After unary Not(!) option


text:
Q: No files matching the pattern were found with STYLELINT I just installed STYLELINT and I'm following the documentation, but I encountered the following problem:
$ npx stylelint --config ./stylelintrc './**/*.tsx'
Error: No files matching the pattern "'./src/**/*.tsx'" were found.
    at standalone (C:\Users\thiag\OneDrive\Documentos\PROJETOS\sugar\node_modules\stylelint\lib\standalone.js:273:43)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
error Command failed with exit code 1.

Here's my hierarchy:

Here's my code .stylelintrc:
{
    "processors": ["stylelint-processor-styled-components"],
    "extends": ["stylelint-config-recommended", "stylelint-config-styled-components"],
    "customSyntax": "postcss-scss",
    "rules": { // BAR }
}

Package code:
{
    "scripts": {
        "start": "expo start",
        "android": "expo start --android",
        "ios": "expo start --ios",
        "web": "expo start --web",
        "eject": "expo eject",
        "stylelint:check": "stylelint-config-prettier-check",
        "stylelint:css": "npx stylelint './**/*.{tsx, ts}'",
        "prepare": "husky install"
    },
    "dependencies": {
        "expo": "~44.0.0",
        "expo-status-bar": "~1.2.0",
        "react": "17.0.1",
        "react-dom": "17.0.1",
        "react-native": "0.64.3",
        "react-native-web": "0.17.1",
        "styled-components": "^5.3.5"
    },
    "devDependencies": {
        "@babel/core": "^7.12.9",
        "@stylelint/postcss-css-in-js": "^0.37.2",
        "@types/react": "~17.0.21",
        "@types/react-native": "~0.64.12",
        "@types/styled-components": "^5.1.25",
        "@types/styled-components-react-native": "^5.1.3",
        "@typescript-eslint/eslint-plugin": "^5.19.0",
        "@typescript-eslint/parser": "^5.19.0",
        "eslint": "8.2.0",
        "eslint-config-airbnb": "19.0.4",
        "eslint-config-prettier": "^8.5.0",
        "eslint-plugin-import": "2.25.3",
        "eslint-plugin-jsx-a11y": "6.5.1",
        "eslint-plugin-prettier": "^4.0.0",
        "eslint-plugin-react": "7.28.0",
        "eslint-plugin-react-hooks": "4.3.0",
        "husky": "^7.0.4",
        "lint-staged": "^12.3.7",
        "postcss-scss": "^4.0.3",
        "postcss-syntax": "^0.36.2",
        "prettier": "^2.6.2",
        "stylelint": "^14.6.1",
        "stylelint-config-prettier": "^9.0.3",
        "stylelint-config-recommended": "^7.0.0",
        "stylelint-config-styled-components": "^0.1.1",
        "stylelint-processor-styled-components": "^1.10.0",
        "typescript": "~4.3.5"
    }
}

What is happening here? I've tried everything with these paths and nothing works. I'm using it in a project with EXPO + STYLED-COMPONENTS.

A: Stylelint is throwing the following error because there is no src folder in your hierarchy and therefore no .tsx files to lint:

Error: No files matching the pattern "'./src/**/*.tsx'" were found.

The error will go away once you create a .tsx file in a src folder. Alternatively, you can use the --allow-empty-input flag, like so:
npx stylelint './**/*.tsx' --allow-empty-input

Additionally, you don't need the --config flag as Stylelint will find a .stylelintrc file automatically.


text:
Q: Changing input fields I got a situation in which, I am validating input type using jquery.
I have html drop down list which contains different parameters("select:first-child").
I am trying validating input box based on these parameters for this I have written following code in jquery.
For example-
If I select "Quantity" then input box should take only numbers.
If I select "TradeDate" then input box should take date.
Now problem is ,when I select parameter which has type date , datepicker appears to select date.
But when I select any other parameter having type numbers ,input still showing datepicker.
So, Where I am wrong ,I want each time this validation
Here var type[1] contains type of parameter eg. float,date,char etc.
 $("#cond_div").children("select:first-child").change(function(event){
            var temp = $(this).val();
            var type = temp.split("_");

            $("#cond_div").children("input").on("keypress keyup", function () {

                if (type[1].localeCompare("date") == 0) {
                    $(this).datepicker();
                }
                else if (type[1].localeCompare("float") == 0) {
                    $(this).val($(this).val().replace(/[^0-9\.]/g, ''));
                    if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) {
                        event.preventDefault();
                    }
                }
                else if (type[1].localeCompare("int") == 0) {
                    $(this).val($(this).val().replace(/[^0-9\.]/g, ''));
                    if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) {
                        event.preventDefault();
                    }
                }
            });
        });

A: Once you've transformed an input with the .datepicker() creator, it stays that way until you destroy it by calling .datepicker("destroy") function.

A: SOLVED...
Instead of going with tricky logic ,found a simple way
$(document).ready(function () {
    $("#cond_div").children("select:first-child").change(function (event) {
        var temp = $(this).val();
        var type = temp.split("_");
        console.log("->" + temp);
        console.log("->" + type);

        $("#cond_div").children("input").val("");
        $("#cond_div").children("input").datepicker("destroy");

        if (type[1].localeCompare("date") === 0) {
            console.log(type[1]);
            $("#cond_div").children("input").datepicker();
        } else if (type[1].localeCompare("char") === 0) {
            console.log(type[1]);
            $("#cond_div").children("input").attr("type", "text");
        } else if (type[1].localeCompare("float") === 0) {
            console.log(type[1]);
            $("#cond_div").children("input").attr("type", "number");

        } else if (type[1].localeCompare("int") === 0) {
            console.log(type[1]);
            $("#cond_div").children("input").attr("type", "number");
        }
    });
});