text:
Q: Can I use LastLoginDate standard field to determine users who log in to Community for the first time? I checked the documentation for the User object and didn't find any explanation on how the LastLoginDate is managed. The description was not helpful:

LastLoginDate
The date and time when the user last successfully logged in. This
  value is updated if 60 seconds have elapsed since the user's last
  login.

So my question is can I rely on the LastLoginDate field to determine when the user logs in to Community for the first time. My goal is to redirect users who log in for the first time to their profiles pages. If the value in LastLoginDate is blank it means that the user has never logged in to Community and they should be redirected to the profile page.

A: Yes, LastLoginDate works the same for community users as it does for standard users.

A: You can also use login history for all successful and failed login attempts for organizations and enabled portals.
If entry is not there, it means user has never tried for login.


text:
Q: IBM MQ (IBMMQDotnetClient) - MQRC_CONNECTION_BROKEN trying to Get message from queue I am using IBMMQDotnetClient 9.2.3 NuGet on .NET (Core) 5, SSL enabled.
There is no problem when I Put messages to queue - it works perfectly.
But when I try to Get messages from queue, sometimes it fails with CompCode: 2, Reason: 2009 (MQRC_CONNECTION_BROKEN) error.
I say sometimes, because it happens randomly - sometimes everything is fine and I get all messages successfully, other times I only manage to get first few messages and then get this error. When I run it again, it usually gets stuck on the same message it failed last time - until I run old MQ client on .NET Framework, which never fails and gets all remaining messages for me.
Message count in queue is 10 - 20 every day and size of them is 1KB - 150KB, so nothing special here.
So far the issue only occurs in production environment.
In trace files I found another error:
System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
   at System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count)
   at IBM.WMQ.Nmqi.MQProxyQueue.AddMessage(MQTSH tsh, MQASYNC_MESSAGE async)
   at IBM.WMQ.Nmqi.MQProxyQueueManager.AddMessage(MQTSH tsh)
   at IBM.WMQ.Nmqi.MQRcvThread.Run()

which is followed by CompCode: 2 Reason: 2195 and then CompCode: 2 Reason: 2009
Here is the code I use:
var options = MQC.MQOO_INPUT_SHARED + MQC.MQOO_FAIL_IF_QUIESCING;
MqQueue = MqQueueManager.AccessQueue(name, options);

var getMessageOptions = new MQGetMessageOptions();
getMessageOptions.Options += MQC.MQGMO_WAIT + MQC.MQGMO_SYNCPOINT;
getMessageOptions.WaitInterval = 100;
getMessageOptions.MatchOptions = MQC.MQMO_NONE;

var mqMessage = new MQMessage();
MqQueue.Get(mqMessage, getMessageOptions);

I've been trying to change configuration, like removing WaitInterval and setting MQC.MQGMO_NO_WAIT - then I no longer got 2009 error, but each message took 5 or even 10 minutes to get, which is just too long, so it's not an option for me.
I really don't want to get stuck in .NET Framework forever.
Is there any solution / workaround I could use in this situation?

A: I think there is an APAR opened for this issue and this is specific to .NET Core. You can try by decreasing the heartbeat interval. The data is stuck in the socket, so until the next data arrives on the socket the data isn't read.

redpajama_set_name: RedPajamaStackExchange


text:
Q: PHP: is it possible to return an array with a modified element in one line? function maybe_one_liner( array $args ) {
    $args["class"] .= " grid";
    return $args;
}

Is it possible return with a one-liner?

A: It's a bit dirty, but it works:
function maybe_one_liner( array $args ) {
    return (($args["class"] .= " grid")?$args:$args);
}

example input/output:
$x = [1,2, "class" => "foo"];
var_dump(maybe_one_liner($x));

output:
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  ["class"]=>
  string(8) "foo grid"
              //^^^^^
}

A: Union works, but order is important. For matching keys, right-hand array's value is simply dropped.
function maybe_one_liner( array $args ) {
    return $args + array( "class" => $args["class"] .= " grid" );
}


text:
Q: Change column name in postres created by JDCB Sink Connector JDBCSink Connector create db with columns name like this screenshot
What i need to do when i want have column names without class name before field name


text:
Q: FileExist not working vb.net I really can not understand why the exception is triggered.
I created this code that performs some checks for the correctness of the license.
The function isittrial occurs if the trial software is creating a hidden file, this file is then checked with File.exist.
The problem is the following:
the file is created by isittrial but for some strange reason you enable the exception of file.exist, what can I do to fix it?
I really can not understand why it does not work.
    isittrial() 'this function make the file to check

    Dim percorsoCompleto As String = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\Software\cc.txt"

    Try
        If My.Computer.FileSystem.FileExists(directory) Then
            Dim fileReader As String
            Dim dire As String = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\Software\cc.txt"
            fileReader = My.Computer.FileSystem.ReadAllText(directory,
               System.Text.Encoding.UTF32)

            Dim check = DeCryptIt(fileReader, "aspanet")
            Dim datadecripted As String = DeCryptIt(Registry.GetValue("HKEY_CURRENT_USER\Software\cc", "end", ""), "aspanet")

            If Date.Now < check And check <> datadecripted Then

                MsgBox("License not valid", MsgBoxStyle.Critical, "Attention!")
                DeActivate()
                ForceActivation()
            Else
            End If

        Else
            MsgBox("License not valid", MsgBoxStyle.Critical, "Attention!")
            DeActivate()
            ForceActivation()
        End If
    Catch ex As Exception
        MsgBox("License not valid", MsgBoxStyle.Critical, "Attention!")
        'DeActivate()
        'ForceActivation()
    End Try

A: This line
 If My.Computer.FileSystem.FileExists(directory) Then

seems to test for the existence of a file passing the name of a directory (or an empty string or whatever, we can see how this variable is initialized). In every case the result will be false.
Then your code jumps to an else block with the same error message of the exception fooling your perception of the error.
Try instead
Dim percorsoCompleto As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
percorsoCompleto = Path.Combine(percorsoCompleto, "Software", "cc.txt")
Try
    If My.Computer.FileSystem.FileExists(percorsoCompleto) Then
        Dim fileReader As String
        fileReader = My.Computer.FileSystem.ReadAllText(percorsoCompleto,
                                 System.Text.Encoding.UTF32)
        .....

Notice that I have removed the path concatenation with a more fail safe call to Path.Combine


text:
Q: Get records from one table to other table in sql server I am using sql server 2008 for my project. I have two tables named 1. Customer_Invoice 2. Orders.
and both the table have Customer_Invoice_ID column. In Customer_Invoice table as PK and in Orders table as FK.
Now my requirement is to get top 100 records from Customer_Invoice table and then for each Customer_Invoice_ID, i want all records from orders table. So i want all the records from the order table which Customer_Invoice_ID is present in Customer_Invoice table.
So first,
Select top 100 * from Customer_Invoice

and then for each Customer_Invoice_ID get records from Order table.
Can anyone guide me how to write query for the same?

A: try this
SELECT * FROM Orders WHERE Customer_Invoice_ID IN
            (Select top 100 Customer_Invoice_ID from Customer_Invoice)

A: Try this one -
SELECT t.*
FROM dbo.[Order] o
OUTER APPLY (
     SELECT TOP 100 *
     FROM dbo.Customer_Invoice
     WHERE t.Customer_Invoice_ID = o.Customer_Invoice_ID
) t


text:
Q: Oracle sql - identify and update primary and secondary rows in same table I have a scenario where i need to identify a combination of records which are duplicates and use them to mark and identify which one is primary and which is secondary and then use an additional column to update the keys. This will help me update another child table which has referential integrity. Here's an example
Table Member

ID Name Birthdt  MID
1  SK   09/1988  312
2  SK   09/1988  999
3  SL   06/1990  315
4  GK   08/1990  316
5  GK   08/1990  999

So from the above table my logic to identify duplicate is -- I do a group by on Name and Birthdate and when MID is 999 i consider that as a duplicate
so I created another temp table to capture dups.
Table member_dups
ID NAME BIRTHDT MID M_flg M_Key

1  SK   09/1988      P        1
2  SK   09/1988      S        1
4  GK   08/1990      P        4
5  GK   08/1990      S        4

For my table member_dups im able to load the duplicate records and update the flag . however I'm finding it difficult to get the right M_KEY for records marked as secondary. If i can achieve that then I can take that record and update the other table accordingly.
Thanks for any help offered.

A: If I understand your logic right the records that had MID = 999 is the secondary in member_dups.
If so you should be able to use an simple update with a join:
update member_dups
set m_key = m.id
from member_dups md
inner join Member m on m.name = mb.name and m.birthdt = mb.birthdt
where mb.m_flg = 's' and m.mid = 999

This example uses MSSQL syntax and thus isn't valid Oracle syntax, but you should get the idea, and hopefully you know Oracle better than I do. I'll try to work out the correct Oracle syntax and update the answer soon.
EDIT: I think this is the working Oracle syntax, but I haven't been able to test it:
MERGE INTO member_dups
USING
(
  SELECT id,
         name,
        birthdt
  FROM Member
  where m.mid = 999
) m ON (m.name = mb.name and m.birthdt = mb.birthdt and mb.m_flg = 's')
WHEN MATCHED THEN UPDATE
    SET member_dups.m_key  = m.id


text:
Q: The PHP code stops after the > in the if statement For some reason my html stops recognizing the code for php after the first and second >, at the point marked with the comment code stops here.
The meaning for this that I need to get a picture from the database and then show it on the website as a header. I am very new to PHP and HTML. I am using phpmyadmin and sublimetext. the database is called stickerdome with the table images. in images there are 3 columns: id, name, link.
This is my code:

<?php
//Database Connect
$connect = mysql_connect("localhost","root","");
//Database Select
$db = mysql_select_db("stickerdome",$connect);
?>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title> StickerDome </title>
<link rel="stylesheet" type="text/css" href="style.css">

    <?php
    //Query
    $query1 = mysql_query("SELECT * FROM images WHERE id = 1");
    $num = mysql_num_rows($query1);
    if ($num > 0) // code stops here right after the >
    {
        while ($output1 = mysql_fetch_assoc($query1))
        {
            $src = $output1['link'];
            echo ""; //code stops here right after the > for the second time
        }
    }
    else
    {
        echo "No picture found.";
    }
?>

This is the file in total:
<!DOCTYPE html>

<?php
//Database Connect
$connect = mysql_connect("localhost","root","");
//Database Select
$db = mysql_select_db("stickerdome",$connect);
?>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title> StickerDome </title>
<link rel="stylesheet" type="text/css" href="style.css">

    <?php
    //Query
    $query1 = mysql_query("SELECT * FROM images WHERE id = 1");
    $num = mysql_num_rows($query1);
    if ($num IS NOT NULL)
    {
        while ($output1 = mysql_fetch_assoc($query1))
        {
            $src = $output1['link'];
            echo "";
        }
    }
    else
    {
        echo "No picture found.";
    }
?>

        StickerDome

        Sample Pack

        Contact

Welcome to Stickerdome

Stickerdome is a website that gives you the best stickers you could ever imagine. It gives you

    - the best quality for every sticker

    - the best endurance that is usable outside

    - the biggest assortment

    For several years stickers started to became more popular. Everyone starting    loving stickers. You can place them almost everywhere imaginable. But there is still one thing that nobody had and that is their own stickers. Yes, your own stickers! You can design your own stickers, send them to us, and we make sure that your stickers will be on your doormat within 5 days! Every design is possible, from round to square to with a border or without. You say it we make it!

 Stickerdome 2014 | Netherlands

A: you could try a different method or debug your sql.
Since i see your dutch im providing you with a link to a tutorial which greatly helped me the first time i worked with sql. maybe if you follow it you can fix your problem.
http://www.phphulp.nl/php/tutorial/overig/pdo-verbinden-met-verschillende-databases/534/inleiding/1364/


text:
Q: Basic biographical data of contemporary mathematicians I'm writing for a broad audience about a collection of topics of math, and including the dates of birth and death of all people mentioned, just to help the reader to keep a general idea of when different things happened. I still could not manage to find the dates for Meigu Guan (who contributed with the formulation of the chinese postman problem),
for H. Peyton Young and Michel Balinski (who contributed in the area of social choice), and Chris Skinner, at Princeton. Can anyone provide the missing dates? Hopefully, they themselves could do it. Thanks for you attention.

A: I tried to find out DOB and DOD for Meigu Guan myself while preparing a biographical addendum for a book, but haven't succeeded - I hope someone will help both you and me. H. Peyton Young was born in 1945 (source: Library of Congress cataloging-in Publication Data).Michel Balinski was born in 1933 (source: A mathematical view of our world by Harold R. Parks, Roger Maurer, Lynn Trimpe), Skinner was born in 1972 (source: his CV).


text:
Q: How to match right single quotation mark character in an Apache RewriteRule I'm trying to get the following URL:
http://olddomain.com/macmillan's-st-luke-passion

Which contains the RIGHT SINGLE QUOTATION MARK character (http://www.fileformat.info/info/unicode/char/2019/index.htm)
To redirect to a new location. However, I cannot get Apache to do this.
For reference my redirect code (in a VirtualHost) is as follows:
RewriteEngine on
RewriteRule ^macmillan\xE2\x80\x99s-st-luke-passion$ http://newdomain.com/tickets/events/macmillans-st-luke-passion [R=301,L]

The file has other redirects for exact matching URLs, and one catch all redirect at the bottom of the page. This one is intended to match any remaining URLs to /events/(old url). For example, it will send olddomain.com/page-title to newdomain.com/events/page-title.
Redirect 301 / https://newdomain.com/events/

What's happening at present is Apache is ignoring the specific rule which contains the \x encoded string for the right quote character '.
And falls through to the fallback redirect that sends the URL to the wrong place.
Can anyone help with how to match a URL with a right quote character ' in an Apache RewriteRule (or RedirectMatch)?

A: Try this rule in virtual host config file:
RewriteEngine on

RewriteRule ^/?macmillan\xE2\x80\x99s-st-luke-passion$ http://newdomain.com/tickets/events/macmillans-st-luke-passion [NC,R=301,L]

Leading slash is required while matching in Apache or vhost config but not when used in htaccess. Make sure to test in a new browser to avoid old cache.


text:
Q: Golang string end character I'm a newbie in Golang, so I'm playing with some algorithms and i have a little problem.
In java for insert an end string in char array I can do like this:
String str = "Mr John Smith    ";
char[] arr = str.toCharArray();
arr[12] = '\0';

But in Golang I'm trying like this:
str := []byte("Mr John Smith    ")
str[12] = '\0'

But this code didn't work

A: That's not a valid syntax for a rune literal with a 0 value. You can use the hex escape sequence
str[12] = '\x00'

If you really need an octal value, it requires 3 digits
str[12] = '\000'

Or just assign a literal 0
str[12] = 0

You can see the valid rune literal escape sequences in the specification: https://golang.org/ref/spec#Rune_literals


text:
Q: Creating a MoreLikeThis query yields empty queries and terms I'm trying to get similar Document of another one . I'm using the Lucene.Net MoreLikeThis-Class to achieve this. For this i seperate my Documents in multiple Fields - Title and Content. Now creating the actual query results in an empty query without interesting Terms.
My could looks like this:
var queries = new List<Query>();
foreach(var docField in docFields)
   var similarSearch = new MoreLikeThis(indexReader);
   similarSearch.SetFieldNames(docField.fieldName);
   similarSearch.Analyzer = new GermanAnalyzer(Version.LUCENE_30, new HashSet<string>(StopWords));
   similarSearch.MinDocFreq = 1;
   similarSearch.MinTermFreq = 1;
   similarSearch.MinWordLen = 1;
   similarSearch.Boost = true;
   similarSearch.BoostFactor = boostFactor;
   using(var reader = new StringReader(docField.Content)){
      var searchQuery = similarSearch.Like(reader);
      // debugging purpose
      var queryString = searchQuery.ToString();  // empty
      var terms = similarSearch.RetrieveInterestingTerms(reader);  // also empty
      queries.Add(searchQuery);
   }
var booleanQuery = new BooleanQuery();
foreach(var moreLikeThisQuery in queries)
{
   booleanQuery.Add(moreLikeThisQuery, Occur.SHOULD);
}
var topDocs = indexSearcher.Search(booleanQuery, maxNumberOfResults);  // and of course no results obtained

So the question is:
 Why there are no Terms / why there is no query generated?
I hope important thing's be seen, if not please help me to make my first question better :)

A: I got it to work.
The problem was, that i worked on the false directory.
I have different Solutions for creating the index and creating the queries and had a missmatch with the index-location.
So the generall solution would be:
Is your Querygenerating-Class fully initialized? (MinDocFreq, MinTermFreq, MinWordLen, has a Analyzer, set the fieldNames)
Is your used IndexReader correctly initialized?


text:
Q: TypeORM - Creating two Foreign Keys in the same table that also reference the same PK I am utilizing TypeORM 0.3.10 with Postgres and attempting to generate and then run a Migration with ts-node-commonjs, but I am unable to do so because two FKs in the same table are referencing the same PK. This is my DB:

The two FKs inside Transactions need to reference an Account id, albeit they will reference different ones for each Transaction entry. The way I have my entities setup is the following:
Account.ts
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { Transaction } from "./Transaction";

@Entity('accounts')
export class Account {
  @PrimaryGeneratedColumn()
  id: number

  @Column({ type: 'decimal', precision: 12, scale: 2, default: 0.00 })
  balance: number

  @OneToMany(() => Transaction, (transaction) => transaction.account)
  transactions: Transaction[]
}

Transaction.ts
import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import { Account } from "./Account";

@Entity('transactions')
export class Transaction {
  @PrimaryGeneratedColumn()
  id: number

  @ManyToOne(() => Account, (account) => account.transactions)
  @JoinColumn([
    { name: 'debitedAccountId', referencedColumnName: "id" },
    { name: 'creditedAccountId', referencedColumnName: "id" }
  ])
  account: Account

  @Column({ type: 'decimal', precision: 12, scale: 2, default: 100.00 })
  value: number

  @Column({ type: 'date' })
  createdAt: Date
}

It can generate the Migration just fine with:
typeorm-ts-node-commonjs -d ./src/data-source.ts migration:generate ./src/migrations/default

But when it comes to actually running it with:
typeorm-ts-node-commonjs -d ./src/data-source.ts migration:run

Is when I get an Error.

Migration "default1668728216714" failed, error: foreign key referenced-columns list must not contain duplicates
query: ROLLBACK
Error during migration run:
QueryFailedError: foreign key referenced-columns list must not contain duplicates

I have also tried to setup @JoinColumn in a different way:
  @JoinColumn([
    { name: 'debitedAccountId', referencedColumnName: "id" },
  ])
  @JoinColumn([
    { name: 'creditedAccountId', referencedColumnName: "id" }
  ])
  account: Account

But still to no avail. I have also tried to disable Foreign Key constraints via createForeignKeyConstraints: false just like the Documentation says but it doesn't really solve my issue, unsurprisingly.
I've been combing through said documentation here as well as on the sections about Decorators proprieties, RelationsFAQ and whatnot but can't seem to find a solution for my problem. Other forum posts also always have a different setup (usually with composite PKs) that doesn't quite apply to my issue, but I have tried their suggestion regardless and nothing worked.
I believe I can make the "raw query" that generates the DB the way I want it to, but I can't get TypeORM to do it.

A: I believe I have found a solution. I was trying to declare only one OneToMany relation for two ManyToOne relations. So instead of using default decorator values, I'd need to specify which Column either side is referencing to. So in the end it will look like this:
--Account.ts
@OneToMany(() => Transaction, (transaction) => transaction.creditedAccount)
creditedAccount: Transaction[]

@OneToMany(() => Transaction, (transaction) => transaction.debitedAccount)
debitedAccount: Transaction[]

note: I am omitting the "Id" at the end of both keys because TypeORM already adds them by default. And because that's what I want I am unsure how I'd go around avoiding it for now.
-- Transaction.ts
@ManyToOne(() => Account, (account) => account.creditedAccount)
@JoinColumn([
  { referencedColumnName: "id" }
])
creditedAccount: Account

@ManyToOne(() => Account, (account) => account.debitedAccount)
@JoinColumn([
  { referencedColumnName: "id" }
])
debitedAccount: Account

I am not 100% sure this will work without a hitch because I couldn't quite find anything like this in the Documentation nor in other forum posts. Until further edit from myself, or perhaps someone else's answer with a working (or just better) solution, assume this has solved the issue.


text:
Q: angularjs update variable information on query I need to update a variable called $uservery often.
Is it the best approach to send a query to the server every x seconds (it contains userdata) or is it actually possible to send a query / update it on every other POST request I make with angularjs?
What would the best way to update it from the server be?

A: If you have the liberty to modify the API code, then best is to use signalR (for ASP.Net webAPI) or Socket.io (for node js).
Otheriwise polling with $timeout is the only option as far as I know.


text:
Q: Unable to enable Tomcat 8.0.45 log in debug mode I am starting tomcat from java code as given below.
bootstrap = new Bootstrap();
String [] a = {"-config",serverXmlPath};
bootstrap.init(a);
bootstrap.setAwait(true);
bootstrap.start();

and i want to enable tomcat logs in debug mode.
I tried changing the conf/catalina.properties but it is not reflecting any changes.
org.apache.catalina.startup.ContextConfig.level = FINE

org.apache.catalina.startup.HostConfig.level = FINE

org.apache.catalina.startup.Catalina.level = FINEST

org.apache.catalina.session.ManagerBase.level = FINE

Could you please help me to get out of this issue.


text:
Q: Foreign key with additional constraints? There is a table called Item(id, name, cost) to track Items possible and Orders(id, bill_id, item_id, units) which is created to track orders placed where same bill_id means it belongs to a single order.
How to impose an additional constraint in DB that says Item should be "Available" (at that point of time) if it needs be to added as item_id in the Order table?
My preferred schema design is to add a Type column which would have "Available" and "Unavailable" fields. But how can I check the Foreign Key constraint item_id should not only be a Primary Key in Item table, its Type should be Available as well.
Couple of answers using check constraints seems close How to make a foreign key with a constraint on the referenced table in PostgreSQL and Foreign key with additional relationship constraint.
Another schema design which I don't prefer is to have a Table called "Menu" which could have only the Items Available. The problem is that this table is going to very dynamic and transactional in nature and it keeps changing depending on the availability of items. And I am just creating a subset table out of Items depending on its state which doesn't seem to be a nice idea.
Which schema design and approach would you chose?
Use cases are like a retailer wants to make sure all his order are against items that are "Available". Ofcourse its possible to change "Available" to "Unavailable" at a later point of time. Orders can be made to maitain a constraint, but I am not sure if one track historically if it was really available or not from even this column. I don't if RDBMS can store such info.

A: AFAIK, I do not think any RDBMS allows one to provide additional constraints along with referential integrity constraints. In your scenario, you should verify if an item is currently available by executing an SQL SELECT statement on Items table and if so add the item to Orders table in a single database transaction. Of course you can have Type or Status column in Items table to check if an item is available. Or you may want to have stock column in the  table to check if an item of required quantity/units is available.
You can implement using your idea of having Type column and using check constraint but I think it is not a good idea. In this case you have to have Type column not only in Items table but also in the Orders table. Then have a check constraint on the Orders table as CHECK (Type = 'Available').
There is already a similar question  PostgreSQL check constraint for foreign key condition
This is going to solve your problems by using user defined function.


text:
Q: trouble installing ubuntu on toshiba satellite L775 i am trying to install ubuntu on an older toshiba satellite l775 that has had its hard drive completely wiped with no OS on it and when i go to install ubuntu i get an I/O error at about 30% or so it is an i3 processor and a 500 gb hard drive.

A: There is several solutions for this. You could try a USB install or take out the hard drive and put it in another system with a cd rom, floppy, USB internet connection.
If you can boot from USB your only problem is choosing a distribution. If the install fails try the live option and check the HD for errors.
Create another USB to rule out a corrupt file or USB stick.
If it is the HD check in the BIOS if the settings for the HD are correct.


text:
Q: Equivalent of C# `readonly` keyword in D? From what I understand while reading up on D, when using the immutable keyword on a variable, the value of the variable must be known at compile time, while C#'s readonly need not be, and readonly fields can be assigned in a class constructor using non-static values. Is this possible in D?

A: As there appears to be some confusion (from both the original question, and he_the_great's comment) regarding immutable, I thought I'd add an aside.
When you say immutable int i = 42, you are saying that i will not be modified, not that it the value is known at compile time. immutable is actually a type modifier, and creates a new type. immutable T is a short-hand for immutable(T). immutable(T) creates a T that can never be mutated, that is, if you read the value, then call a function, the value will be the same. Compare this to const(T) which provides the weaker guarantee that this instance of the type will not be modified, but someone may have mutable access to it else where, so if you read the value and then call a function, you cannot assume the value will be the same.
In general, immutable(T) != T. However there are certain situations where they are implicitly convertible to one another. If T is a type that is said to have no "mutable indirection", for instance. That is to say, if I pass a function an immutable(int), they receive a copy -- there is no way that that function can modify the value I passed, as it is copied -- if the type system didn't allow that, it would just be annoying with no added guarantees, so the D type system allows it. However, if I pass an immutable(int*), that can be changed by the calling function. In the case of structs, if any member has mutable indirection then the struct is said to have it as well.
So to turn away from theory and back to more practical matters, it's not true at all that immutable values have to be known at compile time, and that there's no good way to create them. However, the only mutation can occur inside the constructor. For simple scalar types, this is pretty obvious:
immutable(int) i = rand();

But what about something like an object? Well, to construct a type T we use
auto t = new T();

so to construct the type immutable(T) we use
auto t = new immutable(T)();

here's a more complete little example
class Useless
{
    int i;

    this(int i)
    {
        this.i = i;
    }
}

int main(string[] args)
{
    auto o = new immutable(Useless)(cast(int) args.length);
    //o.i = 17;  error
    return o.i;  // fine
}

As you can see, mutation can occur inside the constructor. You can read member variables, but cannot write them (immutable is transitive; that is, every member (and every member of members) becomes immutable if the parent does. You can only call methods if they're marked as const.
I apologise for the off-topic rambling, but I see that a lot of people appear to be confused regarding this topic.

A: fwend's answer is basically dead-on, but if you're looking for something a little less verbose, you could always make a mixin to automate it.  Untested code below to give the general idea:
string readOnly(string typeName, string varName) {
    // Create a private variable that prepends an _ to the name and a
    // public accessor named name.
    return "private " ~ typeName ~ " _" ~ varName ~ ";\n" ~
           "public " ~ typeName ~
           "varName() @property { return _" ~ varName ~ ";\n";
}

Usage:
class Foo {
    mixin(readOnly("int", "num"));

    void incNum() {
        _num++;
    }
}

A: I'd declare the field as private, then use a get accessor to read it

A: In D2, const member can only be initialized inside the constructor (or directly in the class declaration, but not both):
import io = std.stdio;

class A
{
    const int member;
    this(int nb)
    {
        this.member = nb;
    }
}

void main()
{
    A a = new A(12);
    io.writeln(a.member);
    //a.member = 14; //Error: can only initialize const member member inside constructor
}


text:
Q: Having trouble combining an API .JAR into my .JAR app. JAR within a JAR Disclaimer:
Before I get the standard "this has been asked 1000 times", let me say that yes, I know. I have read and read and read. Looked at JarJar and One-JAR but the problem is: I am self-taught with only a couple of months of experience under me and I am not familiar with Ant or Maven or anything other than vanilla Java. I use NetBeans as my compiler, just to add.
I have written an application for use at my job. It is just a small app that takes certain input and writes it to an Excel file. I downloaded jexcelapi (jxl.jar) and placed that appropriately. I have no trouble running the file inside of NetBeans or from within the dist/ folder after it is built. Therein lies the problem: if I move the app to, say, the Desktop, I get an error from the JVM saying "A Java Exception has occurred." I know that this is due to the fact that the main class is added to the .JAR automatically but to add another lib, I will have to make a "Class-path" statement within my Manifest. I tried that unsuccessfully. I have tried moving the actual jxl.jar file to my jdk folder and I tried calling the entire file path that points directly to the jxl.jar file into my Manifest. The closest I can get is building the .JAR in NetBeans and it adds the lib folder to the dist folder where the app .JAR is.
I want to distribute this app as just a single .JAR without having to send all the users a copy of the jexcelapi lib. It doesn't have to be a .JAR within a .JAR; it can be whatever way is easiest and simplest. As stated before, I am not familiar with Ant and One-Jar draws on that. I am still learning; can someone point me in the right direction with this? Thank you!

A: There is a better one for novice programmers.
Launch4j gives what you need, even wraps it to exe file. Yu don't need to know programming at all to use this.
OFC there are ANT task if you ant to automatise the Launch4j , but for that you must leant a bit about ANT :)

A: After hours of exhausting search, I found something that was incredibly short, sweet, and right to the point. You cannot mess it up. Here is the link.


text:
Q: Persist/Restore Scala Instance (to/from File) What is the simplest way to save/restore an instance in Scala to/from a File?
Now that scala.util.Marshal has been removed and the innovative Pickling library appears unsupported (requires the use of Scala 2.10.4).
Example:
val myObj = SortedSet(20, 10, 30)
SomeUtil.saveToFile(myObj)

//...later:
val restored: SortedSet[Int] = SomeUtil.restoreFromFile(filename)

A: This works with Scala 2.11.1, but is much more messy than what I had expected from a modern class library:
saveToFile
def saveToFile (obj: Object, filename: String) = {
  val out = new FileOutputStream(new File(filename));
  try {
    out.write(Serializer.serialize(obj))
  }
  finally {
    out.close();
  }
}

restoreFromFile
def restoreFromFile[T] (filename: String): Option[T] = {
  try {
    val file = new FileInputStream(filename)
    val in = Stream.continually(file.read).takeWhile(-1 !=).map(_.toByte).toArray
    Some(Serializer.deserialize(in).get)
  }
  catch {
    case _: Exception => None
  }
}

    object Serializer {
  def serialize[T] (obj: T): Array[Byte] = { // use instead of Marshal.dump in Scala 2.11
    val byteStream = new ByteArrayOutputStream()
    val out = new ObjectOutputStream(byteStream)
    out.writeObject(obj)
    out.close()
    byteStream.toByteArray
  }

  def deserialize[T] (data: Array[Byte]): Try[T] = { // use instead of Marshal.load in Scala 2.11
    if (data == null)
      Failure(new NullPointerException())
    else {
      val in = new ObjectInputStream(new ByteArrayInputStream(data))
      try {
        Success(in.readObject.asInstanceOf[T])
      }
      catch {
        case e: Exception => Failure(e)
      }
      finally {
        in.close()
      }
    }
  }
}

A: An even easier way is to use the Java classes: ObjectInputStream and ObjectOutputStream.
Mark your custom class with @SerialVersionUID:
@SerialVersionUID(1L)
class MyClass extends Serializable {...}

Save
val out = new ObjectOutputStream(new FileOutputStream(new File(filename)))
out.writeObject(this)
out.close

Restore
val in = new ObjectInputStream(new FileInputStream(new File(filename)))
val myInstance = in.readObject().asInstanceOf[MyClass]
in.close


text:
Q: Windows 10: Use a second mouse just for scrolling? I'm interested in using a mouse-and-trackball setup: a mouse in my right hand for pointing, and a trackball in my left hand for scrolling. Is there some method available for Windows 10 that allows me to customize the meaning of input from one particular input device?
EDIT: To clarify, this is about altering Windows' interpretations of the signals from one of the mice, such that what would be cursor axis movement from one of the mice would be received as scrolling movement, while the other mouse continues to operate normally.

A: As for the question: I think the answer is no. If you want to emulate system-wide scrolling
(mouse wheel events) using the second mouse - I think it can be done only by the driver (or some driver-like
software) - so if there is no such driver/software with such options for your trackball or mouse, then you're out of luck.
Though it is quite plausible that such software can be written or even exists already (I don't know).
As for the general problematic of scrolling, and since you've mentioned RSI:  I feel sympathetic for this problem.
Yes it is quite stressing to scroll with the mouse wheel and this is needed very often - browsers, editors, etc. So this is a real problem.
Fortunately there is an excellent and free solution for this. There is an app called Autohotkey and it can emulate scrolling in a way similar to what you describe. I have made a script which emulates dynamic scrolling with mouse movements.
I've been using it for 2 years and it's stable and well tested, and it's waaay better then the wheel! I just can't live without it now.
Here is github link with thorough description and how-to:
https://github.com/Mikhail22/Autohotkey---Mouse-scroll
It does not answer your original question, but can solve the scrolling problem. Hope this helps.

A: Even if I don't know a software approach (apart from writing your own driver), I'll just sum up a few options.
So - depending on your question and the comments below, I personally see two major ways (HW/SW) achieving a mouse that only works as a scroll wheel:

*

*Hardware approach: a mouse usually uses sensors like hall effect sensors, optical (laser) sensors or mechanically driven once (with a spinning ball inside) for the tracking of their movement. But you only need the scroll wheel, hence it could be an idea to (irreversible) cut the sensor wires so only the scroll wheel will be connected anymore.
But be aware: no input =/= no movement, as cutting the sensor off could potentially result in a floating state with unpredictable input (but this is not very likely, and if so - then pull it down with a resistor to ground

*Software approach (preferred option 1): write your own script/driver for it which only takes use of the scroll wheel axis. https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/virtual-hid-framework--vhf-

*Build your own dedicated scroll wheel - without a mouse (preferred option 2): if you take the effort to write a script just for a scroll wheel - why don't you take an hour or so more to just build a dedicated scroll wheel, so nothing else but a scroll wheel. What you will need is a rotary encoder (better as an endless potentiometer IMHO, because they have already steppings) and program it to do the same kind of work. If you will go for the track ball, you could use a ball inside a housing with a rubber roll on the bottom that spins and drives a potentiometer or so. Look on the internet for detailed instructions, search engines are your friend.
I personally don't know any other approach, e.g. altering registry keys or device properties.


text:
Q: Issue while plotting multiple graphs on single page In my code here, I am plotting 3 graphs. First one is displayed ok but the other two have shrunk in their width.
I read this article but the logic they are using is different (appending to body).
Can anyone point me in the right direftion?
jsFiddle
Code:
function defaultChartConfig(container, data, useGuideline) {
    if (useGuideline === undefined) useGuideline = true;

    nv.addGraph(function() {
        var chart;
        chart = nv.models.lineChart()
        .margin({right: 100, left: 100, bottom: 150})
        .x(function(d) { return d[0] })
        .y(function(d) { return d[1] })
        .showLegend(true)
        .color(keyColor)
        //.forceY([-1000, 1]);

        chart.xAxis.tickValues(function (d) {
            var dateSets = [];
            for (var i = 0; i < d[0]['values'].length; i++) {
                dateSets.push(d[0]['values'][i]['0'])
            }
            return dateSets;
        });

        chart.xAxis
        .showMaxMin(false)
        .axisLabel("My X-Axis")
        .tickFormat(function(d) { return d3.time.format('%x')(new Date(d)) });

        chart.yAxis
        .axisLabel("My Y-Axis")
        .tickFormat(d3.format(',.2f'));

        chart.size(80);  // datapoint circle size

        d3.select('#' + container + ' svg')
        .text('')
        .datum(data)
        .transition().duration(500).call(chart);

        // translate and rotate x-axis ticks
        var xTicks = d3.select('.nv-x.nv-axis > g').selectAll('g');

        xTicks
        .selectAll('g > .tick > text')
        .attr('transform', function(d,i,j) { return 'translate (-10, 40) rotate(-90 0,0)' });

        // move x-axis label down
        xTicks.select('.nv-axislabel')
        .attr("y", 90)
        .classed({'nv-axislabel':false});

        // add gap in between legends and chart
        d3.select(".nv-legendWrap")
        .style("float", "right")
        .attr("transform", "translate(0,-75)");

        d3.select(".nv-wrap.nv-lineChart")
        .attr("transform", "translate(100,75)");

        return chart;
    });
}

A: You had the pre-procesing of the data outside of your function. So it was only applied to the data variable, not data2.
Just move this inside defaultChartConfig:
data[0].values.forEach(function(element){
    var myDate = new Date(element[0]);
    var epochDate = myDate.getTime();
    //console.log(epochDate);
    element[0] = epochDate;
});

Updated working fiddle: jsfiddle.net/vfe2B/103/


text:
Q: How does SQL Server handles Spaces in Substring/LEFT? How does SQL Server handles Spaces in Substring/LEFT?
If there's a SPACE where at the Substring/Left cutoff, I get a different value than if there's text.
Is there documentation for this?
DECLARE @st_Spaces char(25)
DECLARE @st_NoSpaces char(25)

SET @st_Spaces = '123 56'  --One space, pos 4
SET @st_NoSpaces = REPLACE(@st_Spaces, ' ', '4') --Replace space w/ 4

SELECT LEN(LEFT(@st_Spaces, 4)), --Returns 3
LEN(LEFT(@st_NoSpaces,4)) --Returns 4

A: It's right there in the documentation for LEN.

Returns the number of characters of the specified string expression,
  excluding trailing blanks. (emphasis added)

A: LEN() excludes trailing blanks, which is where you are getting the differing length values.

A: LEN(...) does not count trailing whitespace. You can verify this by doing:
SELECT LEN('    '); -- returns 0
SELECT LEN('A   '); -- returns 1
SELECT LEN('  A '); -- returns 3


text:
Q: Why is my output blank when trying to read two standard in reverse order? I am trying to get a better understanding of variables and types. I have been given a problem to "Read two integers from the standard input, then output them in reverse." I have my code completed, but it is not printing in reverse order. Any ideas?
My Code:
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    //put your code here

    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt(3);
    int b = scanner.nextInt(2);
    System.out.print(a - b);
  }
}

A: System.out.print(a - b); will print the result of a - b subtraction. You need to create a String to display the values. You most likely don't want to use Scanner.nextInt(radix), that's not part of your problem statement. Instead just use Scanner.nextInt() which will use default radix of 10.
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
System.out.println("" + b + " - " + a);

A: You could write it using interpolated strings like this:
import java.util.Scanner

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val a = scanner.nextInt()
    val b = scanner.nextInt()
    println("$b - $a")
}


text:
Q: Transparent lies meaning After searching google for the meaning of Transparent lies, I could only find examples, but not the definition.
So, what does Transparent lies mean?

A: Maybe you should have googled transparent. :-)
transparent: easily detected or seen through :  obvious
A transparent lie is a lie that is easily detected or seen through, an obvious lie.


text:
Q: Full Screen with Microsoft's Mac OS X RDP client? I have a MacBook Air and I'm using Microsoft's RDP client (Remote Cesktop client) for OS X to remote in to Windows machines.  Is there any way to get the client to use the full screen?  There seem to be no options for this in the menu bar on on the dock icon.
If not, are there any alternative RDP clients for Mac OSX that will allow me to go full screen? (I'm not really a VNC fan, in any of its forms)  It seems a shame to waste my screen real estate, especially since I am on only a 13" screen.

A: There's also Royal TSX, which is similar to CoRD but much more powerful. It is a commercial app, but provides a shareware version that allows you to manage up to 1 document, 10 connections and 10 credentials for free.
It also offers native OS X fullscreen mode and an extended fullscreen mode that minimized the UI down to only the tab bar being visible.
Check it out at: https://www.royalapplications.com/ts/mac
Disclaimer: I'm the developer of the mentioned product.

A: In more recent version of Microsoft Remote Desktop for Mac, the combination is: Command-1 to switch between Window and Full Screen.
If you're trying to exit Full Screen, you can also hover your mouse at the top of the screen, it'll show up the menu as below.

A: I think the best option here is to use Microsoft Remote Desktop. This is different than the Remote Desktop Client you mention. It has a orangish / red icon and can be found in the app store for free.
During setup for the connection there is an option for resolution, have that selected to "native" and you should be able to take advantage of full screen.
I have also found this very useful for connecting with dual monitor applications.

A: Click View menu > Full Screen at the very top of the screen. Or press Command-2.

A: For an alternative that does full screen, try CoRD.  http://cord.sourceforge.net/

A: You can try Ericom Blaze, a software-based RDP acceleration and compression product that accelerates RDP performance by up to 10-25 times and delivers higher frame rates and reduces screen freezes and choppiness.
Ericom Blaze works with any standard RDP host, including VDI, Terminal Servers and remote physical machines.
You can read more about Blaze and download a free evaluation at:
http://www.ericom.com/Blaze
You can also check out a demo of someone using Blaze to connect from a Mac to a Windows PC:
http://ericomguy.blogspot.com/Blaze4Mac

A: Control-2 will take you back and forth from full screen to windows mode when using Microsoft RDP on a mac.  You can also configure your RDP preferences but must exit and then log back into the RDP session for them to take effect.

A: Before you type in the name of the Computer, select RDC > Preferences... (or Command + ,). This will turn on additional settings at login including a Display tab where you can change the Remote desktop size to full screen.

A: RDP 8 is Command 1 for Full Screen, Command 2 for Scaling.

A: For this remote desktop client for mac, in addition to the above preferences settings, changing the specific display settings for the current session helped it for me.
Click on edit the current session (pencil icon) and then set it like below


text:
Q: Access Point Analysis How is it possible for an AP (Access Point) to show 2 separate channels i.e. 6 and 4, when a survey is conducted.  The SSID and BSSID are the same but the channels are different.
Channel 4 appeared during a Gmon survey and 6 appeared on the network analysis card.
On dual band routers is the 5GHz band switchable so if you wanted, you could knock it back to 2.4GHz?
The BSSID identifies the AP as a TP Link product. The research is part of a Network analysis course and I'm not very clued up on this area of analysis.

A: In 2.4GHz, the channels overlap to a great degree. When the signal is strong enough, it's possible to see packets from up to 4 channels away. It may be that your network is actually on 6, but one of your scanning tools happened to see a beacon from it when the tool happened to be tuned to channel 4 at the time.


text:
Q: Page load event outside InAppBrowser I need to open an external page from my Phonegap app. I need to make it compatible with at least Android and iOS.
I have this code to open the external page
            **var ref = window.open('http://mysite.com/', '_blank', 'location=no');**
            lastPageLoaded = ref;
            ref.addEventListener('loadstop', function (event) {
                try {
                    alert('executing...');
                    var retVal = lastPageLoaded.executeScript(
                        {
                            code: "alert('got here!');"
                        }, function () {
                        });
                }
                catch (exception) {
                    alert(exception);
                }
            });

I also have this in my config.xml file:
<access origin="*" />

The code above invokes the InAppBrowser an correctly opens my external page. BUT, the InAppBrowser is not in fullscreen mode which is not good for my app.
I noticed that if I make a slight change to the bolded (that is, the text decorated with ** ) line above to this:
var ref = window.open('http://mysite.com/', **'_self'**, 'location=no');

than InAppBrowser is not invoked but the external page opens in full mode, as my entire app is, which is good!
However, adding the event listener won't work:
ref.addEventListener('loadstop', function (event)

I mean, my code never gets to execute this line:
code: "alert('got here!');"

Seems logical because now I am not running under InAppBrowser context, but I need one of two solutions:
1. Make InAppBrowser run in fullscreen mode and keep my existing event handler
2. Find a similar event to hook to so I can invoke the script on the loaded external page.
Is it possible to achieve this?


text:
Q: Differences between probability density and expectation value of position The expression $\int | \Psi\left(x\right)|^2dx$ gives the probability of finding a particle at a given position.
If wave function gives the probabilities of positions, why do we calculate "expectation value of position"?
I don't understand the conceptual difference, we already have a wave function of a position.  Expectation value is related to probabilities.
So what is the differences between them? And why do we calculate expectation value for position, although we have a function for probability of finding a particle at a given position?

A: Expectation value is a different concept from probability. In fact, you can have an expectation value of energy, angular momentum, etc., not just for position.
An expectation value of an observable for a given state $\Psi$ is the average value of a large number of measurements of that observable, assuming each measurement is made on the same state $\Psi$.  For example, if you have probability 0.5 to measure energy $E_o$ and probability 0.5 to measure $-E_o$, the expectation value is $0.5\times E_o + 0.5\times(-E_o) = 0$. As this example shows, the expectation value doesn't have to be one of the "allowed" measurements. This also shows that knowing the probabilities is a different concept than knowing the average value of a large number of measurements.
The same goes for position. You might know what the probability density is at a particular position, but you would need to do extra computations to figure out what the average value of many position measurements would be.

A: Let $\Omega\subseteq \mathbb{R}^n$; then $\int_\Omega \lvert\psi(x)\rvert^2dx$, for a normalized function $\psi\in L^2(\mathbb{R}^n)$ gives the probability that the particle is in the region of space $\Omega$, but does not give any further information on its position. If you want to obtain a quantitative information on the latter (within the limits of quantum indeterminacy), you have to calculate the expectation value $\int_{\mathbb{R}^n} x_j\lvert\psi(x)\rvert^2dx$, for each component $x_j$.

A: The expectation value (of position) represents the average value (position) for the particle (it has units of length in this case) which is different from the actual location of the particle (also units of length). For example, take an electron on a hydrogen atom; the expectation value for all energy levels is at the nucleus even though many of the energy levels have 0 probability of being there.
The wave function represents a distribution of possible values and it must become unit-less (technically, units of portion of a particle) after we square and integrate it with respect to whichever basis we're looking at. In one dimension, it has units of length$^{-1/2}$.
As important as that is, most of the quantities we calculate first (expectation value, physical space wave functions, etc...) provide a simple and intuitive introduction to the formalism and practice using different bases. More valuable (easily measurable) quantities might include the expectation value of the polarization, energy, momentum and various uncertainties.
Physicists have a horrible habit of using ad-hoc notations and Jim does a great job of explaining the notations for different physical values and the choice of basis, though apologizing to physicists for abusing notation is hilarious.

A: I have 5 bags labelled 1 to 5, and I have randomly dropped the letters A to J into the bags. You choose a letter at random and you win as many Francs as the number on the bag containing your letter.
If I have distributed the letters evenly, then there should be 2 letters in each bag, so we could say that ψ(bagnumber) = ψ = sqrt(2).
But if we want to know how many Francs we expect to win on average, then we say:
E[Francs] = [1 Franc x 2 + 2 Francs x 2 + ... ]/[2 + 2 + ... ] = 3
ψ is not the value you expect, but the distribution over the available values. Thus to find the expected average value, you have to do a weighted average using the values and the probabilities.

A: In position-space (that is, when your functions are functions of x), the function $\int|\Psi|^2$ gives the probability of finding the particle in a given range. The expectation value of x is where you'd expect to find the particle. It is often essentially the weighted average of all the positions where the probability density, $|\Psi|^2$, is the weighting function (that's not exactly what it is, but it's a useful analogy). Similarly, you can find the expectation value for any measurable quantity. In this space, the difference between the two is that the expectation value is a number that represents the expected average position of the particle over many measurements whereas the probability is a number that gives you the probability for finding the particle within the limits of integration.
However, you can use any different basis. For example, you could choose momentum-space, $\left|\Psi\right>$ is $\Psi(p)$ (quantum physicists please don't kill me for that affront to notation). In momentum space, the integral $\int|\Psi|^2$ is now the probability of the particle having a given range of momenta. However, the expectation value of x is still the average measurement of x. What, you ask, is the point? The expectation value is a number that can be found in any basis that represents the "on-average" value of a measurement. The probability found by $\int|\Psi|^2$ is the probability that a particle will be found existing within a specified range of values for the basis you are using.
$\int_{x_1}^{x_2}|\Psi|^2dx$ is "there is #% chance that the particle will be found between $x_1$ and $x_2$"
$\left<\Psi\right|x\left|\Psi\right>$ is "the expected average position of the particle over a large number of sample measurements is at $x$=#"
$|\Psi|^2(x)$ is a function "the probability per unit length of finding the particle at this position is #%"


text:
Q: Is there any better way to build this the correct semantic way? Could anybody help me and have a look at my HTML page, and explain to me if this is a correct semantic way to set-up a HTML page?
I need to learn to build a webpage with as less divs as possible, but you can use them if you want to style something specific right? like I used them in this context.
So are there any any flaws in my HTML code?

.main-club-bar-music-festival {
    overflow: auto;
}

.main-club-bar-music-festival h3 {
    margin: 0;
}

.img-club-air {
    position: relative;
}

.img-club-air img {
    width: 100%;
}

.img-club-air a:first-child {
    position: absolute;
    margin: 10px;
    width: 60px;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.img-club-air h2 {
    position: absolute;
    bottom: 0;
    font-size: 20px;
    width: 100%;
    padding: 10px;
    color: white;
    font-family: "LemonMilk"
}

#paragraph-p {
    padding: 20px;
    margin: 0;
}

.rent-a-bike {
    width: 200px;
    margin: 20px auto;
    text-align: center;
    background-color: #eb6c74;
}

.rent-a-bike p {
    margin: 0;
    padding: 10px;
    color: white;
    text-transform: capitalize;
    transform: translateX(-5%);
    overflow: hidden;
}

.rent-a-bike img {
    margin-top: 10px;
    margin-left: 5px;
    height: 38px;
    float: left;
}

.show-me-the-way {
    width: 200px;
    margin: 20px auto;
    text-align: center;
    background-color: #eb6c74;
}

.show-me-the-way p {
    margin: 0;
    padding: 10px;
    color: white;
    text-transform: capitalize;
}

.show-me-the-way img {
    height: 38px;
    float: left;
}

.info-block {
    background-color: #eb6c74;
    color: white;
    padding: 10px 20px;
    text-transform: uppercase;
    font-family: "NeueHaasGrotesk Light";
}

.address-club {
    overflow: auto;
    margin-bottom: 16px;
}

.address-club p {
    padding: 10px 20px 0 20px;
    margin-bottom: 0;
}

.address-club img {
    height: 40px;
    margin-left: 10px;
    float: left;
    margin-right: 10px;
}

.address-club a {
    line-height: 40PX;
    display: block;
    color: #3b3b3b;
    text-decoration: underline;
}

.address-club a[target=_blank] {
    padding-left: 20px;
    color: #0000EE;
}

.padding-info-club {
    padding: 20px;
}

.regular-info-left {
    float: left;
    width: 49.5%;
    text-align: center;
    color: white;
}

.regular-info-left p:nth-child(1) {
    margin: 0;
}

.regular-info-left p:nth-child(2) {
    margin: 2px 0;
}

.regular-info-left p:nth-child(3) {
    margin: 2px 0;
}

.regular-info-left p {
    background-color: #3b3b3b;
    height: 50px;
    line-height: 50px;
    text-transform: uppercase;
}

.regular-info-right {
    float: right;
    width: 49.5%;
    text-align: center;
    color: white;
}

.regular-info-right p:nth-child(1) {
    margin: 0;
}

.regular-info-right p:nth-child(2) {
    margin: 2px 0;
}

.regular-info-right p:nth-child(3) {
    margin: 2px 0;
}

.regular-info-right p {
    background-color: #3b3b3b;
    height: 50px;
    line-height: 50px;
    text-transform: uppercase;
}

#overflow-regular-info {
    overflow: auto;
}

.info-feedback-on-page {
    margin: 10px 0;
    border-top: 1px solid #eb6c74;
    border-bottom: 1px solid #eb6c74;
    padding: 0px 0px 10px 20px;
}

.info-feedback-on-page button {
    border-radius: 40%;
    background-color: transparent;
    margin-right: 10px;
}

#button-yes {
    background-color: white;
    border-radius: 28px;
    border: 2px solid #44c767;
    color: #44c767;
    font-size: 15px;
    padding: 10px 25px;
    outline: 0;
}

#button-yes:active {
    position: relative;
    top: 2px;
    outline: 0;
}

#button-no {
    background-color: white;
    border-radius: 28px;
    border: 2px solid #e35656;
    color: #e35656;
    font-size: 15px;
    padding: 10px 25px;
    outline: 0;
}

#button-no:active {
    position: relative;
    top: 2px;
    outline: 0;
}

panama

regular info

dancing

go out with mates

expensive

edm

locals/foreigners

groups

Panama chose a bit of a peculiar spot to open a nightclub. Located outside the city centre, Panama created a diversified nightclub. The nightclub holds a lot of parties varying from electronic tp 80's and 90s parties. Panama also houses HappyHappyJoyJoy, an asian shared dining restaurant

rent ov-bike

€ 3,85,-/24 hour

show me the way

average price for a drink

- € 2,30,-

entrance

- € 5,00,-

address

Panama

 Oostelijke Handelskade 4

            www.panama.nl
            020 311 86 86

opening hours

Fr - Su: 21:00 - 05:00pm

Was this information usefull for you as an international student?

            <button id="button-yes">yes</button>
            <button id="button-no">no</button>


text:
Q: PHP - Get associative array value by date range without loop I'm using the following PHP code to show a different text (just one) every week:
<?php

$items = [

[
'start' => '2020-02-03',
'end' => '2020-02-09',
'html' => 'Text #1'
],

[
'start' => '2020-02-10',
'end' => '2020-02-16',
'html' => 'Text #2'
],

[
'start' => '2020-02-17',
'end' => '2020-02-23',
'html' => 'Text #3'
],

];

$currentDate = date('Y-m-d');

foreach ($items as $item) {
   if ($currentDate >= $item[start] && $currentDate <= $item[end]) echo $item[html];
}

It works.
But is there a better (i.e. cleaner, faster) way to achieve the same result? Is loop really necessary?
Thanks.
UPDATE
Inspired by Progrock's answer (which I thank), I would modify my code as follows:
$items =
[
    '06' => 'Text #1',
    '07' => 'Text #2',
    '08' => 'Text #3',
    '09' => 'Text #4'
];

$date = new DateTime(date('Y-m-d'));
echo $items[$date->format('W')];

I think it's a better solution (for what I need).

A: https://www.php.net/manual/en/function.array-filter.php
$currentDate = date('Y-m-d');

$filteredItems = array_filter($items, function($item) use ($currentDate) {
    return $currentDate >= $item['start'] && $currentDate <= $item['end'];
});

Though, you're still going to have to loop the filtered items for output, eventually.

A: As your ranges are monday->sunday you could use ISO-8601 week numbering.  Though here the data is harder to interpret without comments.
<?php
$items =
[
    '06' => 'Text #1',
    '07' => 'Text #2',
    '08' => 'Text #3'
];
$iso_week = date('W', strtotime('2020-02-12'));
echo $items[$iso_week];

Output:
Text #2


text:
Q: Image is not show in any browser but shown in eclipse default browser in jsp page I have an program which retrieve the path of image from database. program is retrieving image successfully in eclipse browser but not retrieving in any web browser. I have 3 page 1. login.jsp
2. Index.jsp 3.LoginServlet.java
------------------------------login.jsp-------------------------------------------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"     "http://www.w3.org/TR/html4/loose.dtd">

<title>Please Login</title>

<form action="log" method="post">

        Email Id<input type="text" name="email" placeholder="Enter Email">

        Password<input type="password" name="upass" placeholder="enter password">

        <input type="submit" name="sub" value="Login" id="sub">

</form>

---------------------------------LoginServlet.java--------------------------------------------------------------

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.catalina.Session;

@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

public LoginServlet() {
    super();

}

protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException,     IOException {
    String sessionName="sessionmail";
    String getEmail=req.getParameter("email");
    String getPass=req.getParameter("upass");
    try {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection         con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","maneger");
        PreparedStatement ps=con.prepareStatement("select * from final_social where uemail=? and upass=? ");
        ps.setString(1, getEmail);
        ps.setString(2, getPass);
        ResultSet rs=ps.executeQuery();

        while(rs.next()){
            if(getEmail.equalsIgnoreCase(rs.getString(3)) && getPass.equals(rs.getString(2))){
                System.out.println("unam and pass match");
                HttpSession session=req.getSession(true);
                session.setAttribute("sessionName", getEmail);
                System.out.println(sessionName);

                String nextJSP = "/Index.jsp";
                RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
                dispatcher.forward(req,res);
            }
            else{
                System.out.println("not match");
            }
        }
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
   }
}

----------------------------------------Index.jsp------------------------------------------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="javax.xml.crypto.OctetStreamData"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.io.*"%>
<% String filename="";
 Connection con=null;
 PreparedStatement ps=null;
 ResultSet rs=null;
 %>
 <%Class.forName("oracle.jdbc.driver.OracleDriver");
  con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","maneger");
  //String sessionId=session.getAttribute("sessionName");

        ps=con.prepareStatement("select uname,photo from final_social where uemail=?");
         ps.setObject(1, session.getAttribute("sessionName"));
        rs=ps.executeQuery();

        %>
<!DOCTYPE html>

<title>Welcome</title>

<%while(rs.next())
 {
    filename=rs.getString(2);
 }
%>
<img src="file:///<%=filename %>" name="uimage" id="uimage">

A: Instead of using absolute path like file:///<%=filename %>, create a folder called 'img' inside your WebContent folder and put all your images inside it. So your folder should be something like this:
 WebContent
            |_img
                |_img1.jpg
                |_img2.jpg

and in your DB only save the image names since you already know where to find the images. So now when referencing in your jsp, do something like this:
   <img src="${pageContext.request.contextPath}/img/<%=filename %>" name="uimage" id="uimage">

PS: But you shouldn't be doing your CRUD operations from your jsps, just saying.. :)


text:
Q: Design pattern for webservice authentication Is there a best practice or design pattern on how web services should be authenticated. I am especially concerned about not having to pass the authentication data every time I hit the service.

A: I am not sure if there are names for these solutions, but I have seen two solutions for ws authentication:

*

*Preshared keys - Client and server have some preshared (hardcoded) keys. Client sends key with every request.

*Token Service - Client sends his credentials (user/pass) to special authentication service. Authentication service returns token (which is valid for specified amount of time). Token should be added to every web service call.

Communication should be encrypted in both cases.


text:
Q: Cannot find a field on 'StockBundle\Entity\KStock' that is mapped to column 'id' I have this to tables with 1:m relationship so one stock can have one or many stock_details. This is how I build the entities:
KStock.php
/**
 * @ORM\Table(name="stock")
 * @ORM\Entity(repositoryClass="StockBundle\Entity\Repository\KStockRepository")
 * @Gedmo\SoftDeleteable(fieldName="deletedAt")
 */
class KStock {

    /**
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="ProductBundle\Entity\Product", inversedBy="stocks" )
     * @ORM\JoinColumn(name="product", referencedColumnName="upc")
     */
    protected $product;

    /**
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="CompanyBundle\Entity\Company", inversedBy="companyHasStock" )
     * @ORM\JoinColumn(name="company", referencedColumnName="id")
     */
    protected $company;

    /**
     *
     * @ORM\ManyToOne(targetEntity="ProductBundle\Entity\NCondition", inversedBy="stocks" )
     * @ORM\JoinColumn(name="kcondition", referencedColumnName="id")
     */
    protected $condition;

    /**
     *
     * @ORM\ManyToOne(targetEntity="StockBundle\Entity\NStockStatus", inversedBy="stocks" )
     * @ORM\JoinColumn(name="status", referencedColumnName="id")
     */
    protected $status;

    /**
     * @ORM\Column(type="string", length=255, name="sku")
     */
    protected $sku;

    /**
     * @ORM\Column(type="string", length=255)
     */
    protected $description;

    /**
     * @ORM\ManyToOne(targetEntity="StockBundle\Entity\NUnit")
     * @ORM\JoinColumn(name="unit", referencedColumnName="id")
     */
    protected $unit;

    /**
     *
     * @ORM\Column(type="decimal", precision=4, scale=2)
     */
    protected $width;

    /**
     *
     * @ORM\Column(type="decimal", precision=4, scale=2)
     */
    protected $height;

    /**
     *
     * @ORM\Column(type="decimal", precision=4, scale=2)
     */
    protected $weight;

    /**
     *
     * @ORM\Column(type="decimal", precision=4, scale=2)
     */
    protected $length;

    /**
     * @ORM\ManyToOne(targetEntity="ProductBundle\Entity\NWeight")
     * @ORM\JoinColumn(name="nweight", referencedColumnName="id")
     */
    protected $nweight;

    /**
     * @ORM\ManyToOne(targetEntity="ProductBundle\Entity\NLength")
     * @ORM\JoinColumn(name="nlength", referencedColumnName="id")
     */
    protected $nlength;

    /**
     * @Gedmo\Timestampable(on="create")
     * @ORM\Column(name="created", type="datetime")
     */
    protected $created;

    /**
     * @Gedmo\Timestampable(on="update")
     * @ORM\Column(name="modified", type="datetime")
     */
    protected $modified;

    /**
     * @ORM\Column(name="deletedAt", type="datetime", nullable=true)
     */
    protected $deletedAt;

    /**
     * @ORM\OneToMany(targetEntity="StockBundle\Entity\StockDetail", mappedBy="stockd")
     */
    protected $sdetail;

    public function setStockDetail(\StockBundle\Entity\StockDetail $stockDetail) {
        $this->sdetail[] = $stockDetail;
    }

    public function getStockDetail() {
        return $this->sdetail;
    }

    public function setProduct(\ProductBundle\Entity\Product $param) {
        $this->product = $param;
    }

    public function getProduct() {
        return $this->product;
    }

    public function setCompany(\CompanyBundle\Entity\Company $param) {
        $this->company = $param;
    }

    public function getCompany() {
        return $this->company;
    }

    public function setCondition(\ProductBundle\Entity\NCondition $condition) {
        $this->condition = $condition;
    }

    public function getCondition() {
        return $this->condition;
    }

    public function setStatus(\StockBundle\Entity\NStockStatus $param) {
        $this->status = $param;
    }

    public function getStatus() {
        return $this->status;
    }

    public function setSku($param) {
        $this->sku = $param;
    }

    public function getSku() {
        return $this->sku;
    }

    public function setDescription($description) {
        $this->description = $description;
    }

    public function getDescription() {
        return $this->description;
    }

    public function setUnit(\StockBundle\Entity\NUnit $unit) {
        $this->unit = $unit;
    }

    public function getUnit() {
        return $this->unit;
    }

    public function setWidth($width) {
        $this->width = $width;
    }

    public function getWidth() {
        return $this->width;
    }

    public function setHeight($height) {
        $this->height = $height;
    }

    public function getHeight() {
        return $this->height;
    }

    public function setWeight($weight) {
        $this->weight = $weight;
    }

    public function getWeight() {
        return $this->weight;
    }

    public function setLength($length) {
        $this->length = $length;
    }

    public function getLength() {
        return $this->length;
    }

    public function setCreated($created) {
        $this->created = $created;
    }

    public function getCreated() {
        return $this->created;
    }

    public function setModified($modified) {
        $this->modified = $modified;
    }

    public function getModified() {
        return $this->modified;
    }

    public function getDeletedAt() {
        return $this->deletedAt;
    }

    public function setDeletedAt($deletedAt) {
        $this->deletedAt = $deletedAt;
    }

    public function setNWeight(\ProductBundle\Entity\NWeight $nweight) {
        $this->nweight = $nweight;
    }

    public function getNWeight() {
        return $this->nweight;
    }

    public function setNLength(\ProductBundle\Entity\NLength $nlength) {
        $this->nlength = $nlength;
    }

    public function getNLength() {
        return $this->nlength;
    }

    public function __toString() {
        return $this->company . ' -- ' . $this->product;
    }

}

StockDetail.php
/**
 * @ORM\Table(name="stock_detail")
 * @ORM\Entity
 * @ORM\Entity(repositoryClass="StockBundle\Entity\Repository\StockDetailRepository")
 * @Gedmo\SoftDeleteable(fieldName="deletedAt")
 */
class StockDetail {

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     */
    protected $id;

    /**
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="CompanyBundle\Entity\Company")
     * @ORM\JoinColumn(name="company", referencedColumnName="id")
     */
    protected $company;

    /**
     *
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="ProductBundle\Entity\NCondition")
     * @ORM\JoinColumn(name="kcondition", referencedColumnName="id")
     */
    protected $condition;

    /**
     *
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="ProductBundle\Entity\Product")
     * @ORM\JoinColumn(name="product", referencedColumnName="upc")
     */
    protected $product;

    /**
     *
     * @ORM\Column(type="decimal", precision=19, scale=4)
     */
    protected $price;

    /**
     * @ORM\Column(type="integer")
     */
    protected $amount;

    /**
     *
     * @ORM\Column(type="integer")
     */
    protected $availability;

    /**
     * @Gedmo\Timestampable(on="create")
     * @ORM\Column(name="created", type="datetime")
     */
    protected $created;

    /**
     * @Gedmo\Timestampable(on="update")
     * @ORM\Column(name="modified", type="datetime")
     */
    protected $modified;

    /**
     * @ORM\Column(name="deletedAt", type="datetime", nullable=true)
     */
    protected $deletedAt;

    /**
     * @ORM\ManyToOne(targetEntity="StockBundle\Entity\KStock", inversedBy = "sdetail")
     * @ORM\JoinColumn(name="stockd", referencedColumnName="id")
     */
    protected $stockd;

    public function setDetail(\StockBundle\Entity\KStock $detail) {
        $this->stockd = $detail;
    }

    public function getDetail() {
        return $this->stockd;
    }

    public function setProduct(\ProductBundle\Entity\Product $product) {
        $this->product = $product;
    }

    public function getProduct() {
        return $this->product;
    }

    public function setCompany(\CompanyBundle\Entity\Company $company) {
        $this->company = $company;
    }

    public function getCompany() {
        return $this->company;
    }

    public function setCondition(\ProductBundle\Entity\NCondition $condition) {
        $this->condition = $condition;
    }

    public function getCondition() {
        return $this->condition;
    }

    public function setAvailability($param) {
        $this->availability = $param;
    }

    public function getAvailability() {
        return $this->availability;
    }

    public function setPrice($param) {
        $this->price = $param;
    }

    public function getPrice() {
        return $this->price;
    }

    public function setAmount($amount) {
        $this->amount = $amount;
    }

    public function getAmount() {
        return $this->amount;
    }

    public function setCreated($created) {
        $this->created = $created;
    }

    public function getCreated() {
        return $this->created;
    }

    public function setModified($modified) {
        $this->modified = $modified;
    }

    public function getModified() {
        return $this->modified;
    }

    public function getDeletedAt() {
        return $this->deletedAt;
    }

    public function setDeletedAt($deletedAt) {
        $this->deletedAt = $deletedAt;
    }

}

In my view I'm trying to access this values:
{{ entity.getStockDetail.getAmount }}
{{ entity.getStockDetail.getPrice|number_format(2, '.', '') }}

But I got this error:

An exception has been thrown during the rendering of a template
  ("Cannot find a field on 'StockBundle\Entity\KStock' that is mapped to
  column 'id'. Either the field does not exist or an association exists
  but it has multiple join columns.") in
  ProductBundle:Default:index.html.twig at line 52.

What is wrong in the relations?

A: Try removing the following line from $stockd in StockDetail
 @ORM\JoinColumn(name="stockd", referencedColumnName="id")


text:
Q: Why I can't refer to class variable from nested class? In simple case I can call teacher in loh function:
class Student:
   teacher = 'Mrs. Jones'

   def __init__(self, name):
       self.name = name

def loh():
  print(Student.teacher)

loh()

### Mrs. Jones

But, If I try to do that next way, I got mistake "not defined". Why?
class Student:
  class UnderStudent:
    teacher = 'Mrs. Jones'
  def f():
    print(UnderStudent.teacher)
  f()

A: f tries to lookup UnderStudent in the global scope, but the name isn't defined there; it's only defined in the namespace of the class statement, which turns the name into a class attribute.
class Student:
    class UnderStudent:
        teacher = 'Mrs.Jones'
    def f(self):
        print(self.UnderStudent.teacher)
        # or print(Student.UnderStudent.teacher)

Nested classes are rare in Python, as there is no restriction on having multiple top-level classes in the same file as in some other languages.

A: You can't do it that way for the same reason you can't just say teacher without qualifying it with self or Student (Student.teacher is a class attribute of Student in your first example; in your second example, Student.UnderStudent is a class attribute of Student that just happens to be a class itself). UnderStudent doesn't exist at global scope, it only exists within the scope of Student, just like teacher did.
You also have to invoke f after Student is fully defined, because until you exit the scope of Student's definition, Student doesn't exist in global scope (so you can't use it to find UnderStudent). To fix, you could do:
class Student:
  class UnderStudent:
    teacher = 'Mrs. Jones'
  def f(self):
    print(Student.UnderStudent.teacher)
    # or
    print(self.UnderStudent.teacher)

Student().f()


text:
Q: Error while loading csv file to hbase using happybase Trying to load csv file to hbase and but while running getting error :
Versions used :
Happybase 0.9
Python 2.6.6
MapRDB
TypeError: expecting tuple of size 3 for list/set type args
Below is code used
import csv
import happybase

# CSV file of customer records -- change me
f = '/mapr/demo.mapr.com/project/cust.csv'

ufile = open(f)
reader = csv.DictReader(ufile)
conn = happybase.Connection('localhost')
table = conn.table('cust_table')

print "reading customer file %s" % f
i = 0
for row in reader:
    i += 1
    table.put(row['CustID'],
        {'cdata:name': row['Name'],
         'cdata:gender': row['Gender'],
         'cdata:address': row['Address'],
         'cdata:zip': row['zip'],
         'cdata:signdate': row['SignDate'],
         'cdata:status': row['Status'],
         'cdata:level': row['Level'],
         'cdata:campaign': row['Campaign'],
#         'cdata:linked_with_apps': row['LinkedWithApps']
})
print "loaded cust db with %d entries" % i

Screenshot error :

Any help would be appreciated.

A: try downgrading the thrift library.
https://github.com/wbolster/happybase/issues/154
btw, the right place for bug reports is on github, not on stackoverflow.


text:
Q: How to subset/summarize datetime column by specific intervals? Below is a subset of my dataframe. The real thing has about 3-4 months data. Basically what I'm trying to do is subset the entire thing by individual ID values (which I can do), then count how many times an individual ID is recorded in specific time intervals say every 6, 8 or 10 hours. So for example, if my study spanned a duration of 12 hours on 1/1/2019, I want to know from 1/1//2019 12:00 PM - 6:00 PM, ID 5 was recorded 10 times and ID 3 was recorded 5 times. then from 6:00 PM to 12:00 AM, ID 5 was recorded 4 times and ID 3 was recorded 8 times.
structure(list(DateTime = structure(c(1503006715, 1503006880,
1503007037, 1503007108, 1503007185, 1503007255, 1503007331, 1503007399,
1503007554, 1503007633, 1503007709, 1503007775, 1503007845, 1503007987,
1503008057, 1503008132, 1503008199, 1503008269, 1503008392, 1503008412,
1503008544, 1503008620, 1503009148, 1503009217, 1503009291, 1503009356,
1503009376, 1503009421, 1503009488, 1503009508, 1503009558, 1503009578,
1503009634, 1503009702, 1503009722, 1503009774, 1503009854, 1503009875,
1503009932, 1503010003, 1503010023, 1503010081, 1503010101, 1503010153,
1503010234, 1503010254, 1503010312, 1503010332, 1503010383, 1503010463,
1503010483, 1503010538, 1503015897, 1503015963, 1503016024, 1503016873,
1503017027, 1503017229, 1503022094, 1503022380, 1503022393, 1503022476,
1503022559, 1503022641, 1503022721, 1503022785, 1503022798, 1503022855,
1503022868, 1503022931, 1503022944, 1503023000, 1503023013, 1503023073,
1503023086, 1503023155, 1503023168, 1503023235, 1503023313, 1503023383,
1503023397, 1503023461, 1503023474, 1503023533, 1503023612, 1503023625,
1503023686, 1503023816, 1503024252, 1502754012, 1502754224, 1502754364,
1502754444, 1502754588, 1502754661, 1502754742, 1502754822, 1502758872,
1502758944, 1502758971, 1502759024, 1502759051, 1502759102, 1502759129,
1502759200, 1502759278, 1502759351, 1502759407, 1502759434, 1502759515,
1502768826, 1502768956, 1502769023, 1502769094, 1502769169, 1502769171,
1502769241, 1502769243, 1502769321, 1502769323, 1502769343, 1502769396,
1502769399, 1502769464, 1502769536, 1502772897, 1502777244, 1502755140,
1502755459, 1502755505, 1502755523, 1502755587, 1502755652, 1502755980,
1502755998, 1502756051, 1502756068, 1502756127, 1502756145, 1502756213,
1502756268, 1502756286, 1502756350, 1502756367, 1502756428, 1502756446,
1502756502, 1502756813, 1502756831, 1502756890, 1502756961, 1502756979,
1502757037, 1502757106, 1502757124, 1502757180, 1502757264, 1502771127,
1502771205, 1502771276, 1502771278, 1502771356, 1502771358, 1502771432,
1502771434, 1502771501, 1502771503, 1502771576, 1502771942, 1502775454,
1502775537, 1502775539, 1502775696, 1502775768, 1502775924, 1502775991,
1502776063, 1502780243, 1502780322, 1502780532, 1502780686, 1502780764,
1502780835, 1503275290, 1503275515, 1503275592, 1503275663, 1503275815,
1503289199, 1503289423, 1503289496, 1503289578, 1503289736, 1503290215,
1503290345, 1503291075, 1503291154, 1503291296, 1503291366, 1503295707
), class = c("POSIXct", "POSIXt"), tzone = "America/New_York"),
    Receiver = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 5L, 2L, 5L, 5L, 5L, 5L,
    5L, 5L, 2L, 5L, 5L, 2L, 5L, 2L, 5L, 5L, 2L, 5L, 5L, 2L, 5L,
    5L, 2L, 5L, 2L, 5L, 5L, 2L, 5L, 2L, 5L, 5L, 2L, 5L, 13L,
    13L, 10L, 10L, 10L, 10L, 31L, 6L, 31L, 31L, 31L, 31L, 31L,
    6L, 31L, 6L, 31L, 6L, 31L, 6L, 31L, 6L, 31L, 6L, 31L, 6L,
    6L, 6L, 31L, 6L, 31L, 6L, 6L, 31L, 6L, 6L, 6L, 2L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 15L, 15L, 8L, 15L, 8L, 15L, 8L, 8L, 8L,
    8L, 15L, 8L, 8L, 35L, 35L, 35L, 35L, 3L, 35L, 3L, 35L, 3L,
    35L, 31L, 3L, 35L, 3L, 3L, 32L, 32L, 2L, 2L, 5L, 2L, 2L,
    2L, 5L, 2L, 5L, 2L, 5L, 2L, 2L, 5L, 2L, 5L, 2L, 5L, 2L, 5L,
    5L, 2L, 5L, 5L, 2L, 5L, 5L, 2L, 5L, 5L, 35L, 35L, 3L, 35L,
    3L, 35L, 3L, 35L, 3L, 35L, 35L, 3L, 3L, 3L, 35L, 3L, 3L,
    3L, 3L, 35L, 32L, 32L, 32L, 32L, 32L, 32L, 5L, 2L, 2L, 2L,
    2L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L), .Label = c("VR2AR-546711",
    "VR2AR-546712", "VR2AR-546714", "VR2AR-546715", "VR2AR-546718",
    "VR2AR-546720", "VR2AR-546721", "VR2AR-546730", "VR2AR-546731",
    "VR2AR-546732", "VR2AR-546733", "VR2AR-546734", "VR2AR-546735",
    "VR2AR-546736", "VR2AR-546745", "VR2W-131176", "VR2W-131303",
    "VR2W-131304", "VR2W-131305", "VR2W-131306", "VR2W-131307",
    "VR2W-131308", "VR2W-131309", "VR2W-131310", "VR2W-131311",
    "VR2W-131312", "VR2W-131313", "VR2W-131314", "VR2W-131315",
    "VR2W-131316", "VR2W-131317", "VR2W-131318", "VR2W-131319",
    "VR2W-131320", "VR2W-131997"), class = "factor"), ID = c(1657L,
    1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L,
    1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L,
    1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L,
    1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L,
    1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L,
    1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L,
    1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L,
    1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L,
    1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L,
    1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1657L, 1658L, 1658L,
    1658L, 1658L, 1658L, 1658L, 1658L, 1658L, 1658L, 1658L, 1658L,
    1658L, 1658L, 1658L, 1658L, 1658L, 1658L, 1658L, 1658L, 1658L,
    1658L, 1658L, 1658L, 1658L, 1658L, 1658L, 1658L, 1658L, 1658L,
    1658L, 1658L, 1658L, 1658L, 1658L, 1658L, 1658L, 1658L, 1658L,
    1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L,
    1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L,
    1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L,
    1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L,
    1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L,
    1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L, 1659L,
    1659L, 1659L, 1660L, 1660L, 1660L, 1660L, 1660L, 1660L, 1660L,
    1660L, 1660L, 1660L, 1660L, 1660L, 1660L, 1660L, 1660L, 1660L,
    1660L)), row.names = c(NA, 200L), class = "data.frame")

EDIT:
I'd also like to add a column of the number of unique receivers in each timeframe, so the output would ideally looks something like this.
> df
# A tibble: 20 x 4
# Groups:   ID [5]
      ID DateHour                n nReceivers
   <int> <dttm>              <int>      <int>
 1  1657 2017-08-17 12:00:00     5         2
 2  1657 2017-08-17 18:00:00    47         12
 3  1657 2017-08-18 18:00:00    37         12
 4  1658 2017-08-14 18:00:00     8         11
 5  1658 2017-08-15 00:00:00     2          2
 6  1658 2017-08-15 18:00:00    28         11
 7  1659 2017-08-14 18:00:00     1         1
 8  1659 2017-08-15 00:00:00    26          9
 9  1659 2017-08-15 18:00:00    29          6
10  1660 2017-08-21 00:00:00    41         13
11  1660 2017-08-21 06:00:00    45         15
12  1660 2017-08-21 12:00:00    20         10
13  1660 2017-08-21 18:00:00     5         3
14  1661 2017-08-28 12:00:00     3         1
15  1661 2017-08-28 18:00:00    56         11
16  1661 2017-08-29 06:00:00     1         1
17  1661 2017-08-29 12:00:00   106         13
18  1661 2017-08-29 18:00:00    48         12
19  1661 2017-08-30 06:00:00    35          9
20  1661 2017-08-31 00:00:00    35         12

A: I believe the following function will do what you want.
It will group by ID and by date/hour, and count the number of rows on each group. The return value is a dataframe with 3 columns, the ID, a DateHour column with the initial hour of the period and n, the count.
library(lubridate)
library(dplyr)

countFun <- function(DF, span = 6){
  DF %>%
    group_by(ID) %>%
    mutate(DateHour = ymd_h(format(DateTime, "%Y-%m-%d %H")),
           DateHour = (hour(DateTime) %/% span)*span,
           DateHour = ymd_h(paste(as.Date(DateTime), DateHour))) %>%
    ungroup() %>%
    group_by(ID, DateHour) %>%
    summarise(n = n(),
              nReceivers = n_distinct(Receiver))
}

countFun(df1)
## A tibble: 11 x 4
## Groups:   ID [4]
#      ID DateHour                n nReceivers
#   <int> <dttm>              <int>      <int>
# 1  1657 2017-08-17 12:00:00     5          1
# 2  1657 2017-08-17 18:00:00    47          2
# 3  1657 2017-08-18 18:00:00    37          4
# 4  1658 2017-08-14 18:00:00     8          1
# 5  1658 2017-08-15 00:00:00     2          1
# 6  1658 2017-08-15 18:00:00    28          5
# 7  1659 2017-08-14 18:00:00     1          1
# 8  1659 2017-08-15 00:00:00    26          3
# 9  1659 2017-08-15 18:00:00    29          2
#10  1660 2017-08-21 00:00:00    12          1
#11  1660 2017-08-21 18:00:00     5          2

countFun(df1, 3)  # output omitted


text:
Q: Jquery get JSON data is not working I have json data, i want to get this json file in jquery, I used this code :

$.getJSON("http://somewebsite.com/service/all.json", function(json){

  alert("JSON Data: " + json[3].name);

});

but if use local url ( "data/jsdata.json" ) it works norm! I don't understand why?

A: Cross domain JSON requests are not allowed.  See this note from the getJSON documentation:
http://api.jquery.com/jQuery.getJSON/

*

*Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol.

*Script and JSONP requests are not subject to the same origin policy restrictions.

What you need to do is use JSONP, but that is something that also needs to be utilized properly by the server.
Per the getJSON documentation, you can do that by appending a callback to your url:

If the URL includes the string "callback=?" (or similar, as defined by the server-side API), the request is treated as JSONP instead. See the discussion of the jsonp data type in $.ajax() for more details.

A: If "somewebsite" is not your own site, you will not be allowed to use AJAX to get datas.
This is because the SOP Same Origin Policy.
A way avoid this is the JSONP technology. But it is not all websites that provide a jsonp API.

A: You need to implement JSONP, to get around cross-site-scripting security policies in browsers. Specifying a callback in the query string of the request is required, along with some special formatting of the response by your server.

A: You are probably trying to do a cross-domain ajax request (which is far more complicated)
Consider to use JSONP, but firstly assure yourself that you are really needing this. I personally prefer a CURL approach server-side in this cases.
Anyway for cross domain with jQuery check out THIS


text:
Q: Typescript using Omit on interface I've got an array of products with type  MyType
export type MyType =
 | { type: "one"; data: Product }
 | { type: "two"; data: Product }
 | { type: "three"; data: OtherProduct };

then I use a filter to build an array with
type one and two
Is it possible using Omit?
like
type My = Omit<MyType, '{ type: "three"; data: number }'>; (doesn't work)

A: type Product={}
type OtherProduct = {}

export type MyType =
 | { type: "one"; data: Product }
 | { type: "two"; data: Product }
 | { type: "three"; data: OtherProduct };

 type Result = Exclude<MyType,{ type: "three" }>

Use Exclude instead of Omit. Omit works on interface properties, Exclude on union types


text:
Q: docker-maven-plugin: how do I pass environment variable from `docker run ... -e ` to build or run step? I have a .jar that contains multiple public static void main(psvm)'s that I want to be able to call when I do docker run ... -e <class.path.from.env> on the image and pass an environment variable to specify the class path. Something like this:
  <plugin>
    <groupId>io.fabric8</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <configuration>
      <images>
        <image>
          <name>${project.artifactId}</name>
          <build>
            <from>java:8-jre</from>
            <tags>
              <tag>${build.environment}-latest</tag>
              <tag>${build.environment}-${build.number}</tag>
            </tags>
            <entryPoint>
              <exec>
                <arg>java</arg>
                <arg>-Duser.timezone=UTC</arg>
                <arg>-cp</arg>
                <arg>/opt/${project.artifactId}-${project.version}.jar</arg>
                <arg>${class.path.from.env}</arg>
              </exec>
            </entryPoint>
            <assembly>
              <basedir>/opt</basedir>
              <inline>
                <files>
                  <file>
                    <source>target/${project.artifactId}-${project.version}.jar</source>
                  </file>
                </files>
              </inline>
            </assembly>
          </build>
        </image>
      </images>
    </configuration>
  </plugin>

Although I read the whole documentation for docker-maven-plugin, I'm not sure how I can make this work. Basically where do I declare the environment variable class.path.from.env and how can I make sure it gets the one I pass through -e in docker run ...?

A: I think you need to declare a <run> section next to your <build> section, and add your env variable to <env>, as described here: https://dmp.fabric8.io/#misc-env
<run>
  <env>
    <CATALINA_OPTS>-Xmx32m</CATALINA_OPTS>
    <JOLOKIA_OFF/>
  </env>


text:
Q: Controlling LEDs with I2C I'm trying to connect about 4 LEDs to an MCU (SAMD21G) to power on when specific things happen, but all the pins are being used.
I was thinking that I could connect some kind of LED strip through I2C to the MCU since I can connect multiple devices to a single I2C line, but I couldn't find any LED strip like that.
Should I connect the LEDs to another IC that communicates over I2C with the MCU, or is there another way to go about this, and what are the downsides of connecting the LEDs like that?

A: What you want is an I2C GPIO expander IC.
If you're driving LEDs from one, make sure you check the maximum current allowed per pin, as well as the total maximum current for the device. If you need more current than the GPIO expander IC can handle, you can add transistors (MOSFETs or BJTs) to drive the LEDs.


text:
Q: Searching within a Request Payload in XHR request at Network tab Using the Search pane in Chrome DevTools seems to yield results only within the response's scope (Response Headers and the Response itself) for each and every recorded resource.
But when it comes to searching for a specific string/regex within the Request scope, either the Request Headers or the Request Body itself, the Search pane doesn't yield and results and outputs "No matches found.".

The official Chrome Developer documentation doesn't explicitly state the Search pane searches within the request stating:

Use the Search pane when you need to search the HTTP headers and
responses of all resources for a certain string or regular expression.

Am I missing something that is already natively integrated within the DevTools or should I just come up with a workaround like exporting the recorded resources as a HAR file, and then look it up using a Text Editor, or alternatively, as I'm looking for a way to do so on the fly, overriding the XmlHttpRequest object, logging all the request to the console and search it in there?
Just looking for a quick and easy way to find those resources by string/regex within the DevTools itself...