text:
Q: Several versions of Delphi For reasons related to customers with different applications versions i need to maintain in my laptop several versions of Delphi (7, XE 7, XE 8, XE 10.1 Berlin and XE 10.2 Tokyo). My main concern is about PATH variable and problems during compilation and linking time. There'll be any problems ? Do i need to change what ? Any suggestion is  most welcome.

A: I have all versions of Delphi from 7 thru XE8 installed in a single VM and versions 1 thru 6 in another (my Delphi "museum" :)).
The Delphi "museum" is a Windows XP VM to avoid the problems that those older versions of Delphi have with more recent Windows versions.  The Delphi 7+ VM started life as Windows 7 VM but has since been upgraded to Windows 8.x and then Windows 10 without any problem.
The two sets of VM's are kept separate in this way to avoid OS complications with those older versions and because I use 1-6 only very, very rarely and version 7+ more often.  The precise version at which the "cut-off" was made was determined by the fact that dotted unit names were also only supported from version 7 onward so a lot of the code I ever wrote for 7+ is simply not even usable with 1-6 so there's no point having them alongside each other.
In both cases the IDE/compilers (any version) have no intrinsic problems running alongside other versions.
The only real difficulty is installing Delphi 2006 on Windows Vista (or later).  Should you ever need to, this is the only one that presents any real difficulty due to a dependency on .NET which is not handled very well by the installer.  But it is do-able and not especially difficult as long as you follow the steps described in detail by Dr. Bob.
Install Locations: Minimising PATH Length/Manageability
With a large number of Delphi versions installed the overall length of the PATH variable can become a problem, but in my experience this is a problem only of manageability.  To simplify things on that score and to avoid problems with earlier versions of Delphi on more recent versions of Windows, I installed all my IDE's in a sub-folder directly off the root:
c:\delphi\<version>

Where version is each Delphi version number (e.g. 7.0, 2007, 2009, XE, XE2 etc etc).  I then have a number of other folders for shared components:
c:\delphi\bde
c:\delphi\database desktop
c:\delphi\shared files

When I setup the VM I installed each Delphi version in order and changed the installation locations for these components to these locations.  In this way there is one common installation of these shared components which is updated by each more recent version as required.
I also have a c:\delphi\common\ folder where I keep things such as pre-compiled FastMM_FullDebugMode.dll etc to be shared across all Delphi versions.
I did all this primarily for my own benefit however, to keep things organised and consistent rather than to solve any particular problem (apart from the previously mentioned issues affecting older versions if installed under Program Files).
e.g. if you simply install into default locations then you will end up with versions "scattered" across Borland, CodeGear and Embarcadero folders.  All my IDE versions are in one place.
With or without these considerations, the IDE should be perfectly happy to run all the different versions you mention without any particular configuration required, but you may need to pay attention to configuration/assumptions made by some 3rd party packages/libraries.
3rd Party Packages
Most 3rd party libraries/packages are usually fine, but there may be the occasional one that needs a bit of help.  I myself have never come across anything that couldn't be resolved but have to say that I also don't use 3rd party libraries particularly extensively so simply may not have come across any "trouble makers".
In any event, it's unfortunately difficult to give general advice on this point since it obviously depends very much on the 3rd party libraries and the particular "problems" that any particular one might have.

A: I have all Delphi versions from 6 to 10.2 installed on a computer running Windows 8.1 64 bit. It's not easy to setup, especially for the older versions. The first rule would be: Do not install to "c:\program files", use a separate directory (I use "c:\delphi" with a numerical subdirectory for each version.)
That has two effects:

*

*Older versions, that still write to the installation directory, will work.

*The path entries will not be as long (even though, they will be too long after the 5th or 6th Delphi install, see the comments to your question for possible solutions)

Why did I not use multiple VMs? I maintain GExperts for the versions mentioned above and it is too much hassle to maintain the VMs. As long as it works, I will keep all Delphi versions on my computer. If it stops working, I will probably drop GExperts suppport for some Delphi versions.
There are multiple articles on getting older Delphi versions to work on Windows 8.1. They might be useful if you try it.
They are all in the category Windows 8.1:
https://blog.dummzeuch.de/category/windows/windows-8-1/


text:
Q: Find the resolvent set of a linear operator Consider the Banach space $C([0,1])$ of continuous functions on the closed unit interval, equipped with the supremum norm $\lVert\cdot\rVert_\infty$. Let the bounded linear operator $A: C([0,1]) \to C([[0,1])$ be defined by
$$(Af)(t) = g(t)f(t), \qquad t \in [0,1],\ g \in C([0,1]).$$
How would I find the resolvent set $\rho(A)$?
My attempt at a solution:
$\rho(A)$ is the set of scalars $\lambda \in \mathbb{C}$ for which $A-\lambda I$ is invertible (where $I$ is the identity operator on $C([0,1])$). $(A-\lambda I)f(t) = Af(t) - \lambda f(t) = g(t)f(t) - \lambda f(t) = (g(t) - \lambda)(f(t))$, so to get $f(t)$ back we need to divide by $g(t)-\lambda$.
I would therefore assume that $$(A-\lambda I)^{-1}f(t) = \frac{f(t)}{g(t) - \lambda},$$
which exists whenever $g(t) \neq \lambda$ for any $t \in [0,1]$.
Beyond that I'm stuck. I think I'm close but I can't quite make the leap. Any guidance would be appreciated!

A: You are indeed very close. To proceed, it is simpler if you consider necessity and sufficiency separately.
Sufficiency: Assume first that $g(t)\ne\lambda$ for any $t\in[0,1]$. You already found a candidate for an inverse in this case. Show that it is really the inverse, and that it is bounded.
Necessity: Assume now that there is some $t_0\in[0,1]$ such that $g(t_0)=\lambda$. Show that $A-\lambda I$ cannot be onto by observing that all functions in the range  have some property in common, and give an example of a function in $C([0,1])$ which does not have this property.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How do I return a subcollection using StreamProvider? [Flutter, Firebase] I followed TheNetNinja's Flutter and Firebase tutorial but now I'm trying to display information from a subcollection.

class Menu extends StatefulWidget {
  @override
  _MenuState createState() => _MenuState();
}

class _MenuState extends State<Menu> {
  @override
  Widget build(BuildContext context) {
    return StreamProvider<List<Food>>.value(
      initialData: [],
      value: DatabaseService().food,
      child: Scaffold(
        body: Container(
          padding: EdgeInsets.symmetric(horizontal: 10),
          width: double.infinity,
          color: Colors.grey,
          child: FoodList(),
        ),
      ),
    );
  }

^menu.dart
class FoodList extends StatefulWidget {
  @override
  _FoodListState createState() => _FoodListState();
}

class _FoodListState extends State<FoodList> {
  @override
  Widget build(BuildContext context) {
    final food = Provider.of<List<Food>>(context);
    return ListView.builder(
      itemCount: food.length,
      itemBuilder: (context, index) {
        return FoodTile(food: food[index]);
      },
    );
  }
}

^food_list.dart
class FoodTile extends StatelessWidget {
  final Food food;
  FoodTile({this.food});

  @override
  Widget build(BuildContext context) {
    return foodInfoCard(context, Icons.person_outline, 'Name', food.name);
  }

  Card foodInfoCard(
      BuildContext context, IconData icon, String title, String subtitle) {
    return Card(
      margin: EdgeInsets.fromLTRB(20, 6, 20, 0),
      child: ListTile(
        leading: Icon(icon),
        title: Text(title),
        subtitle: Text(subtitle),
      ),
    );
  }
}

^food_tile.dart
class DatabaseService {
  final String uid;
  DatabaseService({this.uid});

  final CollectionReference restaurantCollection =
      FirebaseFirestore.instance.collection('restaurant');
  List<Food> _foodListFromSS(QuerySnapshot snapshot) {
    return snapshot.docs.map((doc) {
      return Food(
        name: doc.data()['name'] ?? '',
        description: doc.data()['description'] ?? '',
        oriPrice: doc.data()['oriPrice'] ?? 0.0,
        salePrice: doc.data()['salePrice'] ?? 0.0,
        pax: doc.data()['pax'] ?? 0,
      );
    }).toList();
  }

  Stream<List<Food>> get food {
    return restaurantCollection
        .doc(uid)
        .collection('food')
        .snapshots()
        .map(_foodListFromSS);
  }
}

^database.dart

I've been searching for solutions but most of them are streambuilder and not streamproviders. I've done most of it using streamproviders, so idrk how to change it. Can anyone help me? :'(

A: You need to provide the uid to the DatabaseService constructor in the Menu widget.
This:
      value: DatabaseService().food,

should change to:
      value: DatabaseService(uid).food,

Also, since the uid is a required parameter for the DatabaseService, you can mark it as @required so the analyzer can show a hint to pass that parameter. See below:
class DatabaseService {
  final String uid;

  DatabaseService({@required this.uid}); //Added the @required annotation here

  ...
}


text:
Q: Laravel - disable hashing on attempt method So, the problem i have is the following:
I have this login method. The problem is that the email and password are in an external database. The password has already the hashing done in a specific way that i can't change and because the attempt method hashes the password given in the request to compare it to the database one, it will always fail because the hashing algorithm is not the same. Can i disable that auto hashing? To make it in the way it is done in the other external database?
public function login(Request $request)
{
    //Validating the request body
    $validator = Validator::make($request->all(), [
        'email' => 'required|email',
        'password' => 'required',
    ]);

    if($validator->fails()){
        return response()->json($validator->errors()->first(), 400);
    }

    $credentials = $request->only('email', 'password');

    if ($token = $this->guard()->attempt($credentials)) {
        return $this->respondWithToken($token);
    }

    return response()->json('Invalid email or password', 401);
}

A: I think you have two options.

*

*You can create and override the hash driver in config/hashing.php

*You write some custom authentication logic in the LoginController
I think the easier approach is 2. But for long time use you might consider option 1.
Normally you would do the authentication like this:
     /**
     * Handle an authentication attempt.
     *
     * @param  \Illuminate\Http\Request $request
     *
     * @return Response
     */
    public function authenticate(Request $request)
    {
        $credentials = $request->only('email', 'password');

        if (Auth::attempt($credentials)) {
            // Authentication passed...
            return redirect()->intended('dashboard');
        }
    }

https://laravel.com/docs/7.x/authentication#authenticating-users
In your case you will need to replace the if part with some code where you look for the User and your custom hashed password in the database.

A: You want to use login from another project of laravel?
Not the smartest way, but might work.

*

*Make app.key equal on both projects.

*Create a  database.connections another connection to the first project. name it for example as auth_mysql

*Modify app/User.php and add protected $connection = 'auth_mysql';
This might cause issues if you will want to do JOINS to users table.
Perfect solution would be to do a full blown OAUTH with https://laravel.com/docs/7.x/passport#installation


text:
Q: Use of a `final` method I know that one of the uses of the final keyword on a method is forcing subclasses to use the same method implementation.  But what does it mean to say that it increases efficiency by allowing the compiler to turn calls to the method into inline java code?  I just read this but don't quite understand the idea.
To this extent, I don't understand the meaning of an inline Java code. How is a call to a final method executed?  Is there anything special that Java notifies or does during compilation of code that calls a final method?

A: The bytecodes are not significantly more or less efficient if you use final because Java bytecode compilers typically do little in the way optimization. The efficiency bonus (if any) will be in the native code produced by the JIT compiler.
In theory, using the final provides a hint to the JIT compiler that should help it optimize. In practice, recent HotSpot JIT compilers can do a better job by ignoring your hints. For instance, a modern JIT compiler typically performs a global analysis to find out if a given method call is a call to a leaf method in the context of the application's currently loaded classes. This analysis is more accurate than your final hints can be, and the runtime can even detect when a new class is loaded that invalidates the analysis ... and redo the analysis and native code generation for the affected code.
So best practice is to use final to (broadly speaking) express your design intentions, and to achieve other semantic effects that you require. (For instance using the final modifier can play an important role in implementing thread-safe immutable types.) If you use final as an optimization hint, you won't achieve much, and you will make your code harder to modify and extend.
font: link

A: When you want to know how the Java compiler handles different constructs, one good way to find out is to use javap to disassemble the class file.
Final methods may offer an opportunity for optimization because the code that will run is known at compile time. Otherwise, a lookup must be performed at run time, to determine which version (original or overridden) to run.
This is the theory... in practice, existing Java compilers don't do very aggressive optimization.


text:
Q: Key Choice When Using Cassandra's RandomPartitioner When you using the OrderPreservingPartitioner with a column family key of say an int representing YYYYMMDD you'll get hotspots on write and most of the load will hit one/two of the nodes in a cassandra ring. If you are using the RandomPartitioner will cassandra spread the load when using a key that doesn't change frequently (i.e YYYYMMDD)?
In short does the RandomPartitioner spread the load on a small discrete number of key values that do not change regularly?
Is the Partirioner choice a keyspace or cluster level setting?
To Note: So if you md5 20110902 you get 59b7841383176e942495550ecc801a9e. If I repeatably load data with the key 20110902 (i.e 59b7841383176e942495550ecc801a9e) will that not just allocate data to one single node that has the 59b78413.... assigned to it. Is there something else Cassandra is doing to spread the load

A: If you are using RandomPartitioner the load will be evenly distributed. Each key will be md5ed, and the value of the md5 hash will decide where your data will be stored.
The configuration is per cluster

A: No, the RandomPartitioner cannot spread the load if you keep reusing the same keys.  It spreads the load by assigning different keys to different nodes, but inserts on the same key will always go to the same node(s).
Cassandra does spread the load through the replication factor, so for example if you use RF=3, there are three nodes that a key could live on.  However if you keep using key 20110902, it will be the same three nodes every time.
In short load balancing happens at the key level.  To spread the load, you need to choose different keys.


text:
Q: Want to set cron job for wordpress (Backwpup plugin) This is my first contact with cron jobs, so I'm sorry if my question sounds dumb.
BackWPup is for making a back up automatically after some period of time, but its own cron job does not work correctly. It starts only when I sign into wp-admin. So I decided to use the server's cron jobs, but I don't know how to. It says:

If you would use the cron job of your hoster you must point it to the
  url: http://example.com/wp-cron.php

Also, I want to know how to remove a job.
Note: I have only ssh access, there is no hosting control panel. OS: CentOS.

A: I guess you should add the command
wget http://example.com/wp-cron.php >> /path/to/my/wp-cron.log 2>&1

to the crontab. Of course you can use any other CLI http-tool instead of wget, but it's the most simple I know and I think is sufficient here.
Call
crontab -e

then add a line like
0 * * * * wget http://example.com/wp-cron.php >> /path/to/my/wp-cron.log 2>&1

This will call this command every hour. For further information see man crontab.


text:
Q: Refine my T-SQL query to increase performance Created a SQL query to summarize some data. It is slow, so I thought I'd ask for some help.
Table is a log table that has :
loc, tag, entrytime, exittime, visits, entrywt, exitwt

My test log has 700,000 records in it. The entrytime and exittime are epoch values.
I know my query is inefficient as it rips through the table 4 times.
select
    loc, edate, tag,
    (select COUNT(*) from mylog as ml
     where mvlog.loc = ml.loc
       and mvlog.edate = CONVERT(date, DATEADD(ss, ml.entrytime, '19700101'))
       and mvlog.tag = ml.tag) as visits,
    (select SUM(entrywt - exitwt) from mylog as ml2
     where mvlog.loc = ml2.loc
       and mvlog.edate = CONVERT(date, DATEADD(ss, ml2.entrytime, '19700101'))
       and mvlog.tag = ml2.tag) as consumed,
    (select SUM(exittime - entrytime) from mylog as ml3
     where mvlog.loc = ml3.loc
       and mvlog.edate = CONVERT(date, DATEADD(ss, ml3.entrytime, '19700101'))
       and mvlog.tag = ml3.tag) as occupancy
from
    eventlogV as mvlog with (INDEX(pt_index))

Index pt_index is made up of columns tag and loc.
When I run this query, it completes in roughly 30 seconds. Since my query is inefficient, I am sure it can be better.
Any ideas appreciated.

A: Seems like you can just LEFT JOIN mylog  to eventlogV  once and get the same results.
SELECT  mvlog.loc,
        mvlog.edate,
        mvlog.tag,
        COUNT(ml.loc) AS visits,
        SUM(entrywt - exitwt) AS consumed,
        SUM(exittime - entrytime) AS occupancy
FROM    eventlogV AS mvlog
        LEFT OUTER JOIN mylog ml ON mvlog.loc = ml.loc
                                    AND mvlog.edate = CONVERT(DATE,DATEADD(ss,ml.entrytime,'19700101'))
                                    AND mvlog.tag = ml.tag
GROUP BY mvlog.loc,
        mvlog.edate,
        mvlog.tag


text:
Q: Postfix + Dovecot: Create send-only email account I've got a nice little mail server setup (running Ubuntu Server 16.04) that works a treat. It uses postfix as SMTP, which uses dovecot (IMAP) as an authentication source for virtual mailbox users.
It's been working fine, but now I have a second server in another location (with a dynamic IP address), which I'd like to be able to send mail through my main mail server. I've seen a guide on setting it up in authenticated-relay mode, and am part-way through the process, but then I realised that I'd need a send-only email account for it to authenticate against, as I don't want it to be able to receive mail and fill up the server's hard drive (I won't check the inbox!).
How can I create a new email account in my virtual users setup that doesn't have a mailbox, but can still connect via SMTP and send emails?

A: The easiest solution would be to add the user just like any other user, but  restrict recipient. This will give an error during RCPT TO regardless whether the user actually exists or not.
For example, if a web page of a company might send some emails using websiteuser@example.com as a sender address, while no-one should read that address but only their first.last@example.com addresses, and the server has mydestination = example.com that would normally deliver to that user, I'd simply add (without removing what there already is in smtpd_recipient_restrictions):
smtpd_recipient_restrictions =
    . . .
    check_recipient_access hash:/etc/postfix/access/denied_recipients,
    . . .

check_recipient_access type:table
Search the specified access(5)
  database for the resolved RCPT TO address, domain, parent domains, or
  localpart@, and execute the corresponding action.

Then add the unallowed addresses there with a friendly and human readable reason for the reject:
websiteuser@example.com    REJECT    Visit the web site for correct contact information.
helpdesksite@example.com   REJECT    Please log in and use the helpdesk contact form.

That should work what ever is the reason you don't want to accept mail for an address. Remember to postmap /etc/postfix/access/denied_recipients as the lookup table is a hash type Berkeley DB.


text:
Q: Does the series $\frac{\arctan(n)}{n}$ converge? We have the series $\sum ^\infty _7 \frac{\arctan(n)}{n}$. Does it converge(absolutely)? I've tried the comparison test because $|\arctan(n)|\leq \frac{\pi}{2}$, but I can't get further. Because $\lim_{n\rightarrow \infty} \frac{\arctan(n)}{n} =0$, it must be convergent, but is it absolutely convergent? And how do you prove that?

A: You have $${\arctan(n)\over n}\sim {\pi\over 2n}$$
as $n\to\infty$


text:
Q: How to Extract the Three First Letters of Current Month in French without Accented Characters? Is there a way to extract the 3 first letters of the current month in French but WITHOUT acented characters AND with the first letter capitalized - e.g. Fev for Février (February in english) - AND with 2 exceptions: Juillet = Jul and Juin = Jun (the third letter in the abbreviation correspond in reality to the fourth letter of the month for these 2 exceptions)?
So, for all 12 month I would like to obtain the following results: Jan,Fev,Mar,Avr,Mai,Jun,Jul,Aou,Sep,Oct,Nov,Dec.
It would be nice to have something like a \currentMonthAbbreviated command wich directly output the corresponding abreviation to the current month.
Is there a way to do it with datetime2 package or something else?

A: Brute force:
\documentclass{article}

\newcommand{\frabbmonth}{\ifcase\month What?\or
    Jan\or Fev\or Mar\or Avr\or Mai\or Jun\or Jul\or
    Aou\or Sep\or Oct\or Nov\or Dec\else What?\fi}

\begin{document}

\frabbmonth

\end{document}

Explanation: \month contains the current month number in the range 1...12. So the \ifcase will select the correct abbreviation for the existing months, and give out "What?" if the number is out of range.

A: The datetime2 package provides \DTMfrenchshortMonthname, but defines it by
\newcommand*{\DTMfrenchMonthname}[1]{%
  \ifcase#1
  \or
  Janvier%
  \or
  F\protect\'evrier%
  \or
  Mars%
  \or
  Avril%
  \or
  Mai%
  \or
  Juin%
  \or
  Juillet%
  \or
  Ao\protect\^ut%
  \or
  Septembre%
  \or
  Octobre%
  \or
  Novembre%
  \or
  D\protect\'ecembre%
  \fi
}

and what you have to do is to redefine it according to your wish:
\renewcommand*{\DTMfrenchshortMonthname}[1]{%
  \ifcase#1\or
  Jan\or Fev\or Mar\or Avr\or Mai\or Jun\or
  Jul\or Aou\or Sep\or Oct\or Nov\or Dec\fi
}

On the other hand this can be completely independent of datetime2. You can define your own command
\ExplSyntaxOn
\NewExpandableDocumentCommand{\shortfrenchmonth}{m}
 {
  \int_case:nnF { #1 }
   {
    {1}{Jan}{2}{Fev}{3}{Mar}{4}{Avr}{5}{Mai}{6}{Jun}
    {7}{Jul}{8}{Aou}{9}{Sep}{10}{Oct}{11}{Nov}{12}{Dec}
   }
   {BAD MONTH NUMBER}
 }
\ExplSyntaxOff

Complete example:
\documentclass{article}

\ExplSyntaxOn
\NewExpandableDocumentCommand{\shortfrenchmonth}{m}
 {
  \int_case:nnF { #1 }
   {
    {1}{Jan}{2}{Fev}{3}{Mar}{4}{Avr}{5}{Mai}{6}{Jun}
    {7}{Jul}{8}{Aou}{9}{Sep}{10}{Oct}{11}{Nov}{12}{Dec}
   }
   {BAD MONTH NUMBER}
 }
\ExplSyntaxOff

\begin{document}

\shortfrenchmonth{\month}

\shortfrenchmonth{7}

\end{document}


text:
Q: Draw samples of defined size until list is empty. Size of last draw I have a list of numbers mylist and want to draw from this list samples of size pair_size. The drawing of sample continues until mylist is empty.

My challenge is ensuring that the last sample can also only be of size pair_size

My code works but is rather lengthy and complicated.
So my question is: How can I improve my solution to make it (i) more readable and (ii) also work for non consecutive pair_size?
import random

mylist = list(range(10000))
pair_size = [5,6,7]
pairs = []

while len(mylist) > (pair_size[0] + pair_size[-1]):

    n = random.choice(pair_size)
    pairs.append(mylist[:n])
    mylist = mylist[n:]

    if len(mylist) in pair_size:

         pairs.append(mylist)

    else:

        if (len(mylist) - pair_size[0]) in pair_size:
            l1,l2 = mylist[:pair_size[0]], mylist[pair_size[0]:]
            pairs.append(l1)
            pairs.append(l2)
        elif (len(mylist) - pair_size[-1]) in pair_size:
            l1,l2 = mylist[:pair_size[-1]], mylist[pair_size[-1]:]
            pairs.append(l1)
            pairs.append(l2)
        elif (len(mylist) - pair_size[1]) in pair_size:
            l1,l2 = mylist[:pair_size[1]], mylist[pair_size[1]:]
            pairs.append(l1)
            pairs.append(l2)
        else:
            raise ValueError("Pair_size must contain consecutive numbers")

A: import random

mylist = list(range(20))
pair_size = [5,6,7]
pairs = []
min_size = min(pair_size)

while len(mylist) >= min_size:
    n = random.choice(pair_size)
    if len(mylist) >= n:
        pairs.append(mylist[:n])
        mylist = mylist[n:]
pairs.append(mylist) # optional

print(pairs)


text:
Q: Restoring .trn files on a regular basis to a backed-up database We have been given a .bak file of a database from our vendor on a completely different network. They are placing their .trn files every 15 minutes on a sftp for us to pickup and write to the .bak file they sent us. This way we will have data up-to-date every 15 minutes or so.
What I have done is restored their backup WITH NORECOVERY. Then I restored all 800 .trn files WITH NORECOVERY, setting the last restore to WITH RECOVERY. Now that it is out of NO RECOVERY we can read from the DB.
Now that we are up-to-date, what is the process for restoring the new .trn files that they send us?
I apologize for the ignorance, I am new to the DBA game.

A: You should only issue WITH RECOVERY when it's the last backup to restore or when you are sure that is the point where you want to go. After that there's no way to restore any more backups.
Now you will need to restore everything again to keep the same log chain.
If you need to "open" the db without break the log chain, you must use WITH STANDBY = 'path/file'. This will open the DB in READ ONLY mode and when you need to restore more files, SQL Server will use the 'path/file' you create to allow the DB to continue restore the log chain.
You may take a look to this option here:
https://learn.microsoft.com/en-us/sql/t-sql/statements/restore-statements-arguments-transact-sql?view=sql-server-2017


text:
Q: Mouse wait to click action How I can mouse wait on the button for one second to select this button ?
I have 5 button and when the user want to select one of them must wait for 1 second to select

A: I don't know any built in method. You need to figure Your own solution - there are few i Think. For exmaple: Make this buttons disabled at start and use MouseEnter Event to enable it after one second(1000 milisecond).
MouseEnter_handler(object sender, EventArgs e)
{
    Button MyButton = sender as Button;
    StopWatch sw = new StopWatch();
    sw.Start();
    while (sw.ElapsedMilliseconds < 1000)
    {}
    MyButton.Enabled = true;
}

Bind this method to all buttons, since there is a sender parameter - You don't need to copy that all the time.


text:
Q: Best practice for end to end testing whole systems End to end testing means exercising an application from the outer boundaries to verify its behavior. This far I've only done written tests for a single executable artifact. How should I test systems made up of multiple artifacts that is deployed on different hosts?
I see two alternatives.

*

*The tests set up the whole system and exercise it from the very outer edges.

*Each artifact is end to end tested in isolation, relying on the test content to enforce the protocol between them.

Is there a clear case for only adhering to one of these, or are one of them preferred, or are they interchangeable? If interchangeable, then what are some advantages and disadvantages between them?

A: Even though I think it depends on the context, I prefer the first alternative. Here are my random thoughts:
I like my tests to be as closely mapped to use cases as possible (BDD style) (with the disclaimer that I misuse the term use case). These use cases may span several applications and sub-systems.
Example: A back office administrator can view a transaction made by a user from the public interface.
Here, the back office admin interface and the public interface are different applications, but they are included in the same use case.
Mapping these thoughts to your problem where you have sub-systems deployed on different hosts, I would say it depends on how it is used, from the user/actor perspective. Do the use cases span several sub-systems?
Also, perhaps the fact that the system is deployed on several hosts isn't important to the tests. You could replace the inter-process communication with method calls in your tests and have the whole system within the same process during tests, reducing the complexity. Supplement this with tests that only verify the inter-process communication.
Edit:
I realise that I forgot to include why I prefer to test the whole system.
Your asset is features, that is, behaviour, while the code is a liability. Therefore you'd like to test the behaviour, not the code (BDD style).
If you are testing each sub-system separately you are testing the code, not the features. Why? When you divided your system into sub-systems you did so based on some technical reasons. When you learn more you might discover that the chosen seam is sub-optimal and would like to move some responsibility from one sub-system to another. And you would have to modify test and production code at the same time, leaving you without a safety net. That's a typical symptom of testing implementation details.
That said, these kind of tests are too blunt to test everything. So you need to have complementary tests for details as well, where necessary.

A: Testing each artifact end-to-end separately would be highly desiderable in any case.  This will ensure that every artifact is sound.
In addition, you might want to test a composition of artifacts.  That would catch problems in the interactions between artifacts.  I don't know about your situation, but one thing that is important to have is a test environment that is a copy of production.  Testing the system in the test environment is a very good idea.  You might also want to test the system in the production environment; this might be feasible or not.  For instance, if your system processes credit card payments, you may want to avoid test payments on the production system.
In any case, testing each system separately is imho more important than testing the composition.  Once you know that your artifacts are sound in isolation, catching interaction tests will be much easier.  If you only have the end-to-end test of the whole system, it's much more difficult to understand where is the error when the tests fail.


text:
Q: Execute complex shell command from makefile I have the following command line that works from the Linux command prompt:
vi /tmp/test.txt -s <( echo ":1 s/^\/\/ VERSION: .*$/\/\/VERSION: $(date)/g" )

It creates a temporary file (using Process Substitution) that contains the following vim command:
:1 s/^\/\/ VERSION: .*$/\/\/ VERSION: $(date)/g

It opens file /tmp/test.txt for editing and executes the command from the previously created temporary file. It finds line 1 and replaces the line with a current time stamp. It looks a bit like this:
// VERSION: Fri Apr 12 21:20:03 CEST 2013
...
...

Next I can do any required editing and only when I decide to save the file, all changes are commited to disk. It is not an option to first change the file on disk, then start the editor, as the file will have a different timestamp while the contents itself didn't change.
So far it works as designed / intended.
Now I'm trying to move this vi command line into a make file and that is where I fail. I tried a $(shell .....) construction, but make is throwing errors at me.
edit:
        $(shell vi $(src).cpp -s <( echo ":1 s/^\/\/ VERSION: .*$/\/\/VERSION: $(date)/g" )

I'm trying to figure out how the line in the Makefile should read fiddling with extra quotes and parentheses, but I haven't solved it yet.
I am running Ubuntu Linux 12.10 and GNU Make 3.81
vi project.cpp -s <( echo ":1 s/^\/\/ VERSION: .*$/\/\/VERSION: $(date)/g" )
Make doesn't seem to like the "Process Substitution" construction <( command ). I do not want to use an extra (real) file.
€ make edit
vi project.cpp -s <( echo ":1 s/^\/\/ VERSION: .*$/\/\/VERSION: $(date)/g" )
/bin/sh: 1: Syntax error: "(" unexpected
make: *** [edit] Error 2

A: Using $(shell ...) inside of a make recipe is virtually never correct.  You're already in a shell... just type the commands you want directly.  Trying to use the make $(shell ...) function just adds confusion.  You will have to escape $ by writing $$.
You have another problem: make always invokes its scripts using /bin/sh and you're using a bash-specific construct (<(...)).
Of course, the bigger question is why you're using vi, which is a visual editor, to do automated changes like this instead of, for example, sed which is designed for it.  I'd rewrite it as something like:
edit:
        sed -i "1 s,^// VERSION: .*,// VERSION: $$(date)," $(src).cpp

If you really want to use vi, you'll have to do something like:
SHELL := /bin/bash

edit:
        vi '$(src).cpp' -s <( echo ":1 s/^\/\/ VERSION: .*$$/\/\/VERSION: $$(date)/g" )


text:
Q: Bad Behavior after upsizing MDB to SQL Server (no upsize_ts in Table) maybe you could help, i didn't find any proper solution for my problem:
Working Environment:
Access 2003
SQL Server 2008 R2 Express
Database (based on Access 2003) containing a few dozens of Tables, related to each other:

 - Table "Customers" FOREIGNKEY CustomerID
 - Table "Invoice-Header" FOREIGNKEY InvoiceID, with Relationship to Customers-->CustomerID with DELETE/UPDATE Trigger inside MDB
 - Table "Invoice-Detail" FOREIGNKEY CNT, with Relationship to Invoice-Header->InvoiceID with DELETE/UPDATE Trigger inside MDB
 - Table "Delivery-Header" FOREIGNKEY DeliveryID, with Relationship to Customers-->CustomerID with DELETE/UPDATE Trigger inside MDB
 - Table "Delivery-Detail" FOREIGNKEY CNT, with Relationship to Delivery-Header->DeliveryID with DELETE/UPDATE Trigger inside MDB

Why i ask? :
Well, i upsized this Database many times (with Entries from our Customers) to a SQL Server Database without any problem, the database is from our software we deliver, but getting filled with informations of the customer who's using our software (creating Customers, creating Invoices, creating Delivery Notes), but this time a Customer of us gave us the Database for upsizing to a SQL Server Database and it would not work:
What i did --> what happend:
Attempt #1: Upsized as Usual --> Delivery-Header / Delivery-Detail has no upsize_ts but Invoice-Header / Invoice-Detail had (Normally all Tables had upsize_ts field after Upsizing)

Attempt #2: Upsized again after fixing missing Customers in Customers Database --> Delivery-Header / Delivery-Detail has upsize_ts but not Invoice-Header / Invoice-Detail

Attempt #3: Upsized again after copying everything into our Base of this Database (fresh created) --> Delivery-Header / Delivery-Detail has no upsize_ts but Invoice-Header / Invoice-Detail

What could cause such behavior that upsize_ts Field is not created inside the SQL Database without aborting Upsize-Assistant? Normally, every Table had a "upsize_ts" Field (when checked in Upsize-Assistant, and that was checked, since a few Tables had upsize_ts but some not)
Normally, the Upsize-Assistant will abort if theres an error with the Database but this time it converts all Tables from Database without throwing an error but missing upsize_ts fields.
If you'll need further informations please write to me, its driving me nuts that this time i've got deep trouble to convert with Access 2003 to SQL Server.


text:
Q: Run action when iOS device is near some map point I have the mobile app that uses user's location when the app is running to show some places on a map (now it is Google Map).
I want to add a new feature - App in the background should notify the user when the device is near some map point or entering the predefined area.

*

*How can it be done? Are there different approaches?

*Where to start from?

*What if my points stored on the server - should I save them on the device first and what if can't do it and new map points can be added when the app is not in memory?

*What will be the most challenging in creating such feature?

p.s. I know about Ray's geofencing tutorial but I want to know - are there any different approaches and also about pitfalls of such feature

A: First of all you must enable location updates and remote notifications in background modes(Your Target->Capabilities), then you must write in your location update function some code to detect that user is close to some location exapmle:
   func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
            if let userLocation = locations.first {
                if location.coordinate.langtitude <= <some value> ||
                   location.coordinate.langtitude >= <some value> || ... {
                      runAction()
                    }
              }
    }

    func runAction() {
      //show local notification here
    }


text:
Q: Firebase Reference not returned after add I do something like this:
 var temp = $scope.names.$add({"firstname" : $scope.firstname, "lastname" : $scope.lastname, "school" : $scope.selectedSchool});

I get a returned object, but when I try
$log.log(temp.toString());

I get just the object, whereas the documentation for firebase says I should see the path to the string of my new firebase URL. I also tried
$log.log(temp.name());

And same result, is this related to the implementation of those "functions" in angularfire, or to actual firebase itself?
I'm trying to syncronize adding "names" to a names portion of my json object, and then following it up with creating a section in my json object where I can get more details of the individual and so I want to match up the key's
kinda like this JSON Data structure resulting in the least passed data from database
I don't see how to get the above to work, and I saw (at one point, can't find the link now), that firebase was recommending using transaction not the "once" operation, so I was hoping I would get the individuals key, then pass that into creating a new firebase "subobject?" that matched it.


text:
Q: left join query in MVC I have added this code in my controller where I am left joining on 2 tables to stored result in lettergroup variable.
var lettergroup = (from e in opsdb.Queue2
                   join a in opsdb.QIncidents on e.QID equals a.QID into ps
                   from ad in ps.DefaultIfEmpty()
                   select new { ad.IncidentID, ad.TaxTypeID, ad.TaxPeriod, ad.StateID, ad.IncidentDate, e.CustomerID, e.DocumentID }).ToList();

I get this error:

The cast to value type 'System.Int32' failed because the materialized  value is null. Either the result type's generic parameter or the query must use a nullable type.

Please help me out with left join query in ASP.NET MVC

A: try this
var lettergroup = (from e in opsdb.Queue2
                   join a in opsdb.QIncidents on e.QID equals a.QID into ps
                   from a in ps.DefaultIfEmpty()
select new { IncidentId= a.IncidentID, TaxTypeID=a.TaxTypeID,
TaxPeriod= a.TaxPeriod, StateID= a.StateID, IncidentDate= a.IncidentDate,
CustomerID=e.CustomerID,DocumentID =e.DocumentID }).ToList();


text:
Q: JSTL - Unable to access property of the object stored as session variable I'm following the standard MVC architecture.
In my Controller I have the following code,
userDetailsBean = userDetailsDAO.getUserDetailsFromEmail(loginEmail);
session.setAttribute("userDetails", userDetailsBean);

The object userDetailsBean contains different methods like getFName(), getLName() etc. I'm accessing this object from the View file as follows,
<c:choose>
     <c:when test="${sessionScope.userDetails != null}">

                    ${sessionScope.userDetails.getFName()}

     </c:when>
     <c:otherwise>

               Log in/Register

     </c:otherwise>
</c:choose>

I'm getting the following error from the above code,
HTTP Status 500 - /header.jsp(22,38) The function getFName must be used with a prefix when a default namespace is not specified

I searched a lot on the internet and tried many different suggestions like,
${sessionScope.userDetails.fName}
${sessionScope.userDetails.get(0).fName}

but none of it worked,
I'm using Tomacat 6 with JSTL 1.2 and Netbeans as IDE.
Any help is appreciated, thanks in advance!

A: You could read the JavaBean Specification. For links to it, look at the answer at Where is the JavaBean property naming convention defined?
Look at sections 8.3 and 8.8.
You should make your life easy and just use conventional names for your fields. But, if you choose not to do that, then consider the following bean.
package test;
public class BeanTest implements java.io.Serializable {
    private String bHours = "ten";
    private String RICK = "me";
    private String Joe = "hello";

    public BeanTest(){
    }
    public void setbHours(String bHours){
       this.bHours = bHours;
    }
    public String getbHours(){
       return bHours;
    }
    public void setRICK(String str){
                         RICK = str;
    }
    public String getRICK(){
       return RICK;
    }
    public void setJoe(String str){
                         Joe = str;
    }
    public String getJoe(){
       return Joe;
    }
}

In a JSP you can use the following to access the data in the bean.
<jsp:useBean id="myBean" class="test.BeanTest" />
${myBean.RICK}
${myBean.joe}
${myBean.bHours}
<%=myBean.getbHours()%>


text:
Q: How to set a click count to display an object? I thought I got this working but I haven't. Basically I am counting the number of clicks the user is doing and as a test I want to state for every three clicks (the number of clicks divides by 3), then display an interstitial advert.
The problem I have realised is for the first three clicks or the first number that divides into 3, it shows the advert. However if I continue with the clicks then the advert never appears again.
What am I doing wrong and how can I get the advert to constantly appear based on my number of clicks condition?
public class Content extends AppCompatActivity {

    Button selectAnotherButton;
    TextView clickCountText;
    int getClickCountInt;

    private InterstitialAd mInterstitialAd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_content);

        MobileAds.initialize(Content.this, "ca-app-pub-...");
        mInterstitialAd = new InterstitialAd(Content.this);
        mInterstitialAd.setAdUnitId("ca-app-pub-.../...");
        mInterstitialAd.loadAd(new AdRequest.Builder().build());

        final SharedPreferencesManager prefManager = SharedPreferencesManager.getInstance(Content.this);
        clickCountText = findViewById(R.id.click_count);
        clickCountText.setText(Integer.toString(prefManager.getClicks()));
        getClickCountInt = Integer.parseInt(clickCountText.getText().toString());

        selectAnotherButton = findViewById(R.id.button_select_another);

        selectAnotherButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getClickCountInt++;
                clickCountText.setText(Integer.toString(prefManager.increaseClickCount()));

                if(getClickCountInt % 3 == 0){

                    if (mInterstitialAd.isLoaded()) {
                        mInterstitialAd.show();
                    } else {
                        Log.d("ADVERT", "The interstitial wasn't loaded yet.");
                    }
                }

            }
        });

    }

}

A: private void showAd() {
    MobileAds.initialize(Content.this, "your key");
    mInterstitialAd = new InterstitialAd(Content.this);
    mInterstitialAd.setAdUnitId("your key");
    mInterstitialAd.loadAd(new AdRequest.Builder().build());
    mInterstitialAd.show();
}

....
if(getClickCountInt % 3 == 0)
    showAd();

Can you try like this? By the way you shouldn't post here your actual key.


text:
Q: How design user point system database? In my application ,there is two pointing system. coffeepoints and sandwich points. I am looking best approach to design database.
Coffee points :-  When user purchase coffee, he will earn coffee points
sandwich points :- When user purchase sandwich he will earn in sandwich points
1 method :-  Create a table, point_types to store points name such as coffe points and sandwitch points

2 method :- use coffe_points and sandwitch points as field_name wherever points data stored.

Which one is best approach?

A: In a pure conceptual modelisation point of view the first solution is the way to go.
It gives your model flexibility and answer to the case without breaking normal forms.
I wouldn't implement the second solution, till you would have to work on several sql query if your fonctionnality ever evolve (10% chance)


text:
Q: ASP.NET MVC 4 : How to get selected dropdown values in controller action? I have a view as given below. I have two submit buttons; one for find new car and another for find used car. How can I can get the value of selected dropdown in controller ?
And how can I find out which of the 2 buttons have been pressed by the user?
@{
        ViewBag.Title = "Home Page";
    }
    @using (Html.BeginForm("Home", "home"))
    {

                        Find New car

                                <select id="ddlBrand" name="ddlbrand" style="width: 200px;">
                                    <option value="0">---Select Brand---</option>
                                    <option value="1">---b1---</option>
                                </select>

                                <select id="ddlModel" name="ddlModel" style="width: 200px;">
                                    <option value="0">---Select Model---</option>
                                </select>

                                <select id="ddlFuelType" name="ddlFuelType" style="width: 200px;">
                                    <option value="0">---Select Fuel Type---</option>
                                </select>

                                <select id="ddlBudget" name="ddlBudget" style="width: 200px;">
                                    <option value="0">---Select Your Budget---</option>
                                </select>

                                <input type="button" name="FindNewCar" value="GO"  />

                        Find used car

                                            <select id="ddlBrand1" name="ddlbrand" style="width: 200px;">
                                                <option value="0">---Select Brand---</option>
                                            </select>

                                            <select id="ddlModel2" name="ddlModel" style="width: 200px;">
                                                <option value="0">---Select Model---</option>
                                            </select>

                                            <select id="ddlFuelType2" name="ddlFuelType" style="width: 200px;">
                                                <option value="0">---Select Fuel Type---</option>
                                            </select>

                                            <select id="ddlCity" name="ddlCity" style="width: 200px;">
                                                <option value="0">---Select City---</option>
                                            </select>

                                            <input type="button" name="FindNewCar" value="GO" />

                                                Sell Car

                                            Sell your car faster, at right price ... Sell Car»

                    aaaaaaaaaaa

    }

A: You should setup two action methods inside of your controller and use the Html.ActionLink method to help create your form.
Example:
public ActionResult FindNewCar(string ddlbrand, string ddlModel, string ddlFuelType, string ddlBudget)
{
     // Do something here.
}

public ActionResult FindUsedCar(string ddlbrand2, string ddlModel2, string ddlFuelType2, ddlCity)
{
     // Do something here.
}

View
@using (Html.BeginForm("Home", "home"))
{
     @Html.ActionLink(...)
}

EDIT
See changes above


text:
Q: SecurityError when rendering textures in Three.js with phonegap/cordova on iOS WKWebView I get a SecurityError: DOM Exception 18 when rendering textures in Three.js (gl.texImage2D.apply(gl,arguments) ) and the material appears black. I use phonegap 6.2.9 (cordova 6.1.1), Three.js (r78) on iOS WKWebView (platform version 4.1.1).
All worked fine as long as I build the app directly with a WKWebView component, based on this project.
After switching to phonagap I ran into this issue. I supposed it's caused by the Content-Security-Policy, but couldn't solve it this way. Taking images as base64 png is working, but I have multiple large images and the file size is not practical.
Now I fear it's the same issue as with local XmlHttpRequests.
But loading an image from an external Url also causes the SecurityError. And I can't follow, why there is a problem with phonegap/cordova and not with the naked WKWebView component (see above).
I have no idea furthermore and strongly need help please.
Thanks in advance.

A: You should probably look into CORS if you plan on serving the assets over http.
You need to set a Access-Control-Allow-Origin HTTP header for your assets, see this wiki article for more info:
https://en.wikipedia.org/wiki/Cross-origin_resource_sharing


text:
Q: Shall we capitalize the word after colon? Shall we capitalize the word after colon?
For example:

The question is: S/shall we capitalize "s" in "shall"?

Another example, https://stats.stackexchange.com/q/91024/1005

For example:

*

*E/every marginal distribution of a multivariate normal distribution must be a univariate normal distribution.

*S/so it is for the multinomial distribution (which is the multivariate generalization of binomial distribution).

*S/so it is for Dirichlet distribution (which is the multivariate generalization of beta distribution)

*N/not sure  for multivariate t distribution.

(In other words, should each of those individual bullets be capitalized, or not?)

A: It depends on what follows the colon.

*

*Is it a list of items? Leave the first item in lower case.

*Is it more than one sentence? Capitalize all of them.

*Is it one sentence? It's your option. I'm more prone to use upper-case depending if I want a sharper demarcation between what precedes and follows the colon, and a lower case if I want a smoother flow.

This pretty much echoes the guidance given by sites such as Grammar Girl, CCCF, GrammarBook, UNC Writing Center.
Examples:

*

*These three things remain: faith, hope, and love. [list]

*Everybody wanted to know: What would happen next? Would Batman be saved? [two sentences]

*All of the clues led to one conclusion: The butler was the one who did it. [single sentence, upper case]

*The librarian warned the rowdy students: excessive noise would not be tolerated. [single sentence, lower case]

I like the practical guidance one person wrote at the Q-and-A site for the Chicago Manual of Style:

Rules can't cover every instance. Don't waste time overthinking: if it's that hard to determine, it probably doesn't matter.

A: In some cases, a list such as this punctuated as one sentence, despite the bullet points. This means that every point starts with a lowercase letter, and every line finishes with a comma / semicolon, apart from the final line, which ends with a full stop (or period, as Americans would say).
When writing less formally, or in general, you would forget the layout described above, and every point would start with a capital, and every line would finish with a full stop (period, as Americans would say).
I would say that it mostly comes down to preference. It is likely there is a rule defining how such lists should be formatted, but very few people still consider them relevant. There is no longer a 'right' or 'wrong' way, and it is more likely that the capitalisation would happen.


text:
Q: Liquibase ERROR: Column has unsupported type "serial" when creating a Redshift auto increment int column in XML When creating a table in XML to be deployed to Redshift database using Liquibase
       <createTable schemaName= "staging" tableName="tempauto">
            <column name="key" type="integer" autoIncrement="true">
                <constraints nullable="false"/>
            </column>

ERROR: Column "key" has unsupported type "serial"
I expected the column key to be created as an int like SQL and to auto-increment.
However Liquibase converts the auto-increment column to type 'serial' which is not supported in Redshift.


text:
Q: how to make my own distro I want to make my own ubuntu based distro which contain some moste usable software. and I want to it be bootable and I can give it to my friends to install it on their pcs!
but I don't know how do this.
and I checked the website of remistersys but it doesn't load.
what I have to do?

A:
Ubuntu Customization Kit is a tool that helps you customizing official
  Ubuntu Live CDs (including Kubuntu/Xubuntu and Edubuntu) to your
  needs. You can add any package to the live system, for example
  language packs, or applications.1

To download and more info see UCK.
Also may also find some good information on how to create your own distro here.

A: You can use the graphical tool Ubuntu Customization Kit to create your own custom Ubuntu Live CDs:

Why customize LiveCDs?
You may wish to customise the Ubuntu Desktop LiveCd to:

*

*make your own Linux / Ubuntu distribution

*[...]

Read more of the documentation and step-by-step process at:

*

*Ubuntu Help: LiveCD Customization

*How to customize Ubuntu Live CD?


text:
Q: Dynamic selection of node parameter I'm using Jenkins to run tests. I have many test suits (a string parameter) and many nodes. Particular test suits can be run only on specific nodes, for example:

*

*test_suite_1 can be run only on node_1, node_2 or node_3

*test_suite_2 can be run only on node_4 or node_5.

To run a test I have to select a test suite and a Node/Nodes, which is great and I still want to use this functionality.
What i want?
When I select only a test suite - and no Node will be selected by user - the Node will be selected dynamically by script/plugin - it should depend on selected test suite and depend of availability of node (for example I've selected test_suite_1 and node_1 is busy, then node_2 or node_3 should be selected by this script).
I know that NodeLabel parameter have a default Node - but as I mentioned before, particular test suits can be run only on specific nodes so it's not possible to set a default Node for every test suite.
How to automate selecting Node in NodeLabel parameter plugin?
I found Groovy Label Assignment plugin but when I have Node parameter and at the same time Label parameter - no matter what is in Label, value from Node parameter have higher priority.

A: Your prior question was closed as a being too broad. My  reply to that was deleted as being not having sufficient context, so let's try answer this again...
(ps: you may wish to rephrase your question with the details you added in the comments make it more clear)
You have 2 tests and 5 nodes, broken into 2 groups.
Create a label (eg: GROUP_A) on nodes 1, 2, and 3:
Jenkins | Manage Nodes | [pick a Node] | Configure
 Under "Labels", add "GROUP_A", Save
Do similar (ie: GROUP_B) for nodes 4, 5
For test_suite_1, Configure, under General
[ X ] Restrict where this project can be run
Label Expression: "GROUP_A"
Do similar for test_suite_2.
Now, test_suite_1 will run on any of nodes in GROUP_A and test_suite_2 will only run on any nodes in GROUP_B. This is what Node labels are for. Usage example here.
Normally, Jenkins jobs are sticky, so they stick to the last node they ran on, unless it's down. You can change this behavior to run on the least busy node using the Least Load Plugin (wiki).

From the description: By default Jenkins tries to allocate a jobs to
  the last node is was executed on. This can result in nodes being left
  idle while other nodes are overloaded. This plugin overrides the
  default behavior and assigns jobs to nodes with the least load.

I don't know that you can have it default to group if no option is specified AND have it run on a specific node if you supply a parameter, but I also don't know you need to. You could investigate the use of "Node and Label parameter" plugin. Perhaps a regex of (GROUP_A)||(${SELECTEDNODE}) where SELECTEDNODE is supplied from the choice option
We don't use the Node and Label plugin, but I don't think you can have your job run simultaneously on all nodes ("1) select several nodes to run a test", "I can select several nodes at once"), unless you change to a multi-configuration project, despite the option to select multiple nodes; is it a "one of the selected" option? You'd have to test that.


text:
Q: Git: How can I modify server's commit? I have already push some commits on my git server on EC2 , not on github.
How can I modify those commits on the git server?
Operation like
remove commit, like rebasing,
change commit message
Is it possible?
Thanks so much.

A: You can do just about everything with a forced push. Change your local tree to exactly what you want and git push -f and it will replace the tree on the server with what you have locally. It's worth noting that this will cause trouble with any other repos that have pulled the tree you just replaced.

A: If you want to edit a remote branch's history destructively (e.g. rebase/amend), make your changes locally and then do git push --force. Sometimes it does not work (repository administrators can disable this feature); in that case, you can try deleting the remote branch with git push origin :my_branch and then pushing it again with git push origin my_branch. Otherwise you can use git revert, which is the recommended way if you work in a team (the rule of thumb is that published history should not be modified).
Here's an example (using this Github repository):
$ touch SOMETHING
$ emacs SOMETHING
$ git add SOMETHING
$ git ci -m SOMETHING
[master d14aaa0] SOMETHING
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 SOMETHING
$ git push
Counting objects: 8, done.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 611 bytes, done.
Total 6 (delta 3), reused 0 (delta 0)
To git@github.com:23Skidoo/ghc-parmake.git
   53f836a..d14aaa0  master -> master
$ git reset --hard "HEAD~"
HEAD is now at 7b2dc96 TODO update.
$ git push --force
Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:23Skidoo/ghc-parmake.git
 + d14aaa0...7b2dc96 master -> master (forced update)

Looking at the commit history, you can see that commit d14aaa0 is absent.


text:
Q: Hbase several puts with identical row keys and identifier I am working on a multithreaded application..
my application can run put command based on row key value..therefore, the put command can be executed for an identical key value several times. does this cause an exception in habse?

A: No, it does not. Hbase operations are atomic on a single rowkey. So multiple updates on a key will be executed one by one. If you put same rowkey+column family+column key with different values, it will override values until last one. Also if you enable versioning on column family, you can store every update value.


text:
Q: Why can't we implicitly convert a noconst-elements array to a full-const-elements array? Here is an example of what I mean (I am using VS 2022 with C++11):
// Printing function: does not modify any array member, so everything should be const
void PrintArray(int const*const (&ct)[3])
{
    printf("ct: x%p, {%u, %u, %u}\n",
           &ct, ct[0] ? *ct[0] : 0, ct[1] ? *ct[1] : 0, ct[2] ? *ct[2] : 0);
}

int main(int argc, unsigned short* argv[])
{
    // At some point: declare (and use) a modifiable array
    int a = 1, b = 2, c = 3;
    int* t[3] = {&a, &b, &c};

    // At some later point: want to use the array without modifying it,
    // then lets try some conversions
    int* (&u)[3] = t;           // OK - Same type conversion
    int*const (&v)[3] = t;      // OK - adding first constness on array elements
    int const*const (&w)[3] = t;    // FAIL: adding both constnesses on elements:
                        // error C2440 "cannot convert from 'int *[3]' to
                                        //'const int *const (&)[3]"  (ON VS 2022 C++ 11)
    int const*const (&x)[3] = const_cast<int const*const(&)[3]>(t);
                                        // FAIL: same error C2440
    int const*const (&y)[3] = reinterpret_cast<int const*const(&)[3]>(t);
                                        // OK - but annoyingly verbose and source of casting
                                        // errors

    // Of course the same problem happens for passing through functions call
    PrintArray(t);                      // FAIL
    PrintArray(reinterpret_cast<int const*const(&)[3]>(t));     // OK... but still annoying !

    return 0;
}

OK, we know that reinterpret_cast is working, so I have a workaround here. So my question is more theoritical about C++ language:

*

*Does someone know if the implicit conversion compiles on other compilers, like gcc ?

*Does someone know if the C++ standard forbid this failing implicit conversion ?

*And mostly, if the standard does forbid it, WHY ??? I KNOW that const conversions can lead to const/unconst inconsistencies sometimes. E.g. would have been the case if converting t to int const* (&)[3] because we could have added a const int into an array that is not const at the begining. But, in my example above, everything is const so I cannot find any weakness. Does someone see one ? Or is it just because it was too complex at the time for compilers to assert the rightness of the conversion ?

*(Additional question for the braves: why cons_cast is failing here while it is only a constness casting ?)

These questions are for my C++ culture, I am open to all your analysis :)
Kind regards to everybody.


text:
Q: How to compute the correlation coefficient? The question is:
One package of potatoes contains 10 potatoes and weighs exactly 500 grams.
Denote by $X_{1}, \dots, X_{10}$ the weights of each potato.
Are the random variables $X_{1}, \dots, X_{10}$ independent?
Compute the correlation coefficient of $\rho(X, Y)$ where $X=X_{1}$ and $Y = \sum_{i=2}^{10} X_{i}$
I know this formula $\rho=\frac{cov(X,Y)}{\sigma_{X} \sigma_{Y}}$ and that $cov(X,Y)=E[XY] - E[X]E[Y]$
So it seems that it is just to plug in the right values and compute. But Im not sure how to calculate $E[X]$ and $E[Y]$..
I think it is something along with: I know that $E[X]=xf(x)$ and here $x=X_{1}$ and $f(x) = 1$ soo this equals $X_{1}$? This is true (since this set only contains this potato so therefore we must always get it when we choose). But the answer should be a number, not a random variable...
The same goes for $E[Y]$.
I know from the solutions that the answer is: $\rho(X,Y)=-1$ and thus they are in correlation.

A: Define:
$$\sum_{i = 2}^{10}X_{i} = Y$$
We know that:
$$500 = X_{1} + Y \Rightarrow Y = 500 - X_{1}$$
from which:
$$Cov(X_{1}, Y) = Cov(X_{1}, 500 - X_{1}) = Cov(X_{1}, -X_{1}) = -Var(X_{1})$$
using the follwing covariance properties:
$$Cov(a + X, b + Y) = Cov(X, Y); \ Cov(aX, bY) = abCov(X, Y); \ Cov(X,X) = Var(X)$$
Moreover:
$$Var(Y) = Var(500 - X_{1}) = Var(X_{1})$$
also using $Var(a + X)$ $=$ $Var(X)$ and $Var(-X)$ = $Var(X)$, from which we finally have:
$$\sqrt{Var(X_{1})}\sqrt{Var(Y)} = \sqrt{Var(X_{1})}\sqrt{Var(X_{1})} = Var(X_{1})$$
implying $\rho(X_{1}, Y)$ $=$ $-1$


text:
Q: Why we write this, form = StudentForm(request.POST) in django? This is my views function,
def studentcreate(request):
    reg = StudentForm()
    string = "Give Information"

    if request.method == "POST":
        reg = StudentForm(request.POST)
        string = "Not Currect Information"

        if reg.is_valid():
            reg.save()
            return render('http://localhost:8000/accounts/login/')

    context = {
        'form':reg,
        'string': string,
    }

    return render(request, 'student.html', context)

Here first we store form in reg variable then also we write reg = StudentForm(request.POST) why?
acutally why we write this?

A: I can't tell you why you are writing this. Maybe only you know. It does not make much sense. I would recommend reading the Django documentation on this at https://docs.djangoproject.com/en/4.0/topics/forms/#the-view
from django.http import HttpResponseRedirect
from django.shortcuts import render

from .forms import NameForm

def get_name(request):
    # if this is a POST request we need to process the form data
    if request.method == 'POST':
        # create a form instance and populate it with data from the request:
        form = NameForm(request.POST)
        # check whether it's valid:
        if form.is_valid():
            # process the data in form.cleaned_data as required
            # ...
            # redirect to a new URL:
            return HttpResponseRedirect('/thanks/')

    # if a GET (or any other method) we'll create a blank form
    else:
        form = NameForm()

    return render(request, 'name.html', {'form': form})

You read from data if the request is a POST. Otherwise, return an empty form.

A: You could think of the "request.POST" as a parameter passed onto the form in the view. This tells the view that the form mentioned has POST data from the form in name.html. Otherwise it is just an empty form.


text:
Q: "error: type mismatch" in Spark with same found and required datatypes I am using spark-shell for running my code. In my code, I have defined a function and I call that function with its parameters.
The problem is that I get the below error when I call the function.
error: type mismatch;

found   : org.apache.spark.graphx.Graph[VertexProperty(in class $iwC)(in class $iwC)(in class $iwC)(in class $iwC),String]

required: org.apache.spark.graphx.Graph[VertexProperty(in class $iwC)(in class $iwC)(in class $iwC)(in class $iwC),String]

What is the reason behind this error? Has it got anything to do with Graph datatype in Spark?
Code : This is the part of my code which involves the definition and call of the function "countpermissions".
class VertexProperty(val id:Long) extends Serializable
case class User(val userId:Long, val userCode:String, val Name:String, val Surname:String) extends VertexProperty(userId)
case class Entitlement(val entitlementId:Long, val name:String) extends VertexProperty(entitlementId)

def countpermissions(es:String, sg:Graph[VertexProperty,String]):Long = {
    return 0
}

val triplets = graph.triplets
val temp = triplets.map(t => t.attr)
val distinct_edge_string = temp.distinct
var bcast_graph = sc.broadcast(graph)
val edge_string_subgraph = distinct_edge_string.map(es => es -> bcast_graph.value.subgraph(epred = t => t.attr == es))
val temp1 = edge_string_subgraph.map(t => t._1 -> countpermissions(t._1, t._2))

The code runs without errors until the last line, where it gets the above mentioned error.

A: Here is the trick. Lets open the REPL and define a class:
scala> case class Foo(i: Int)
defined class Foo

and a simple function which operates on this class:
scala> def fooToInt(foo: Foo) = foo.i
fooToInt: (foo: Foo)Int

redefine the class:
scala> case class Foo(i: Int)
defined class Foo

and create an instance:
scala> val foo = Foo(1)
foo: Foo = Foo(1)

All whats left is to call fooToInt:
scala> fooToInt(foo)
<console>:34: error: type mismatch;
 found   : Foo(in class $iwC)(in class $iwC)(in class $iwC)(in class $iwC)
 required: Foo(in class $iwC)(in class $iwC)(in class $iwC)(in class $iwC)
          fooToInt(foo)

Does it look familiar? Yet another trick to get a better idea what is going on:
scala> case class Foo(i: Int)
defined class Foo

scala> val foo = Foo(1)
foo: Foo = Foo(1)

scala> case class Foo(i: Int)
defined class Foo

scala> def fooToInt(foo: Foo) = foo.i
<console>:31: error: reference to Foo is ambiguous;
it is imported twice in the same scope by
import INSTANCE.Foo
and import INSTANCE.Foo
         def fooToInt(foo: Foo) = foo.i

So long story short this is an expected, although slightly confusing, behavior which arises from ambiguous definitions existing in the same scope.
Unless you want to periodically :reset REPL state you should keep track of entities you create and if types definitions change make sure that no ambiguous definitions persist (overwrite things if needed) before you proceed.


text:
Q: How do you separate test queues and real queues when testing Resque (with rspec and rails?) I would like to test some resque workers, and the actions that enqueue jobs with these workers. I am using rspec and rails.
Currently I have a model, let's call it Article.rb, that has a before_save method called updates_related_categories that checks if a job with CategoriesSorter needs to be enqueued. If so, it enqueues a job with that worker, with the argument of the category id that the article is related to.
In test, however, these jobs are sent to the same queue as the development server sends jobs to. (i check using the resque server that you can tie into your server at root/redis/overview)
I want to know:
1) How can I send test jobs to a different queue than the development jobs?
If this is possible, any other advice on testing resque is also welcome.
I have seen some related questions that suggest resque-unit and resque-spec but these are pretty undeveloped, and I couldn't get them to a useful working state. Also, I have heard of using Resque.inline but I don't know if that is relevant in this case, as resque isn't called in test specs, it's called from the article model on save of objects created in test.
Sample Code:
Article.rb:
 before_save :update_related_categories
 def update_related_categories
     #some if statements/checks to see if a related category needs updating
         Resque.enqueue(CategoriesWorker, [category_id])
     end
 end

CategoriesSorter:
 class CategoriesSorter
     @queue=:sorting_queue
     def self.perform(ids)
        ids.each do |id|
           #some code
        end
      end
 end

Specs:
 it "should do something" do
     @article = #set something to enqueue a job
     @article.save
     #can i check if a job is enqueued? can i send this job NOT to the development queue but a different one?
 end

A: As I see it, you don't want to test whether enqueueing the job results in perform being called - we trust Resque does what it should.
However, you can test that 1. calling update_related_categories enqueues the job. Then you can test, separately, whether 2. a worker calling perform results in the desired behavior.
For testing Resque in general, a combination of resque-spec and simulating a worker can accomplish the above two goals.
For 1, with resque-spec, you can simulate a worker calling the perform method on your class, and then check that it has been enqueued correctly:
describe "Calling update_related_categories " do
  before(:each) do
    ResqueSpec.reset!
  end

  it "should enqueue the job" do
    Article.update_related_categories
    CategoriesSorter.should have_queue_size_of(1)
  end
end

For 2, you can create a Job (and specify a separate queue name than your development queue), a Resque::Worker and then assign the Worker to the Job:
def run_worker_simulation
  # see Resque::Job api for setting the args you want
  Resque::Job.create('test_queue_name', 'class_name', 'type', 'id')

  worker = Resque::Worker.new('test_queue_name')
  worker.very_verbose = true

  job = worker.reserve
  worker.perform(job)
end

Hope that gives you some ideas.

A: You shouldn't test resque, that's the resque development team job, your application should only test that your perfom method does what it have to do. You can also test that your model Article.rb enqueues the job as you want. Sending real jobs to resque is useless, your test will end and the reque queue will be full of useless jobs.
Do something like:
describe 'Article' do
  before(:each) do
    Resque.stub!(:enqueue)
  end

  it 'enqueues the job' do
    cat_id = 1
    Resque.should_receive(:enqueue).once.with(CategoriesWorker, [cat_id])
    Article.create(:category_id => cat_id)
  end
end

describe 'CategoriesSorter' do
  it 'sorts the categories' do
    result = CategoriesSorter.perform([1,4,6,3,2])
    result.should == [1,2,3,4,6]
  end
end

stub or mock unneeded methods/classes
EDIT: also, as you test Article, it's good that you set a before(:each) filter to stub resque so your spec never send jobs to the real queue, i've edited my answer

A: I have
Resque.inline = ENV['RAILS_ENV'] == "test"

This makes all the resque tasks as inline in test environment.
For testing each Job class , I have separate specs to test perform method of each job separately.


text:
Q: The little eye on the right hand side when logging in passwords I just finished reading an answer to this question - but why is this happening? I had someone come out to fix my internet explorer - which was running super slow due to a recent install of HP printer software - and now I have the little black eye.  Could my tech person have put in spy ware to capture all of our passwords?
Thanks, Suzanne

A: This is new on Windows I think since Windows 8 was launched. Anyways the 'Eye' Symbol is present there so that you can see what you typed in the password field. So, do not click on it when someone is looking.
If you want to remove it, just follow the simple steps:

*

*Open Run Prompt (Win + R)

*Enter gpedit.msc.

*Local Group Policy editor will open

*Go to Computer Configuration Expand Administrative Templates–>Windows Components–>Credential User Interface

*Open Do not display the password reveal button and click on Enabled option

*The option is disabled.


text:
Q: Finding an earlier version to downgrade to On my Debian server, I upgraded the SQLite package to version 3.7.7 but discovered that it contains a critical bug that breaks several things including my Subversion repository. So, I would like to downgrade back to the previous version I was using. But:

*

*I have no idea what that version was (I assume it was 3.7.6.3, but I'm not certain).

*The only other version I find available for the SQLite package in aptitude is 3.5.9.6 which is too early for the Subversion package I'm using (it requires at least 3.6).

How can I identify and downgrade to the version of SQLite I was using, and which might still be in a cache on my computer? Or, failing that, how can I tell aptitude where to download intermediate versions of that package?

A: The APT cache lives in /var/cache/apt/archives. If you have a suitable version of the package there, you can install it with dpkg -i /var/cache/apt/archives/sqlite3-VERSION.deb.
If you don't have it, testing currently has 3.7.6.3-1 (downloadable from any Debian mirror) and stable currently has 3.7.3-1; or you can find (almost) any version that's ever been in Debian on snapshot.debian.org. Since this is a punctual need, it'll be easiest to download the package manually and install with dpkg (but you can also define a particular snapshot date as an APT source, as explained on the snapshot.d.o home page).
You can find out what version used to be installed by looking through the dpkg logs in /var/log/dpkg.log or the APT logs in /var/log/apt or the Aptitude logs in /var/log/aptitude.
In Aptitude, mark the buggy version as forbidden to install: F key in the interactive UI or aptitude forbid-version interactively. If the bug isn't fixed in the next release, mark the package as "on hold" to prevent automatic upgrades until further notice (= key or aptitude hold command).

A: the file /var/log/dpkg.log has the change history. Please do a grep on this to find your answer.


text:
Q: install gnu command I have the command split installed. However I need the '--filter'argument, which is supported by gnu's split command. SO I need to install gnu split. How do I do that on my mac?
I tried
$ brew install coreutils

but its already up to date. Then I tried doing
$ brew install split
$ brew install gnu-split

It says the command is not available:
Error: No available formula for gnu-split

How can I install any specific gnu command, on mac os (and linux as well)?

A: From https://apple.stackexchange.com/questions/69223/how-to-replace-mac-os-x-utilities-with-gnu-core-utilities
Brew install coreutils

your commands will be accessible with g préfix so call gsplit


text:
Q: Is it possible to define off-shell spinors? For the sake of concreteness, let us consider the Dirac spinor $u_s(\boldsymbol p)$. Is it possible to covariantly extend this to a function $u_s(p)$, such that it matches $u_s(\boldsymbol p)$ on the hyperboloid $p^2=m^2$?
I'm not sure what properties I would like $u_s(p)$ to have, so I leave it a bit arbitrary. For example, we may want to ask
$$
D(R)u(p)=u(Rp)
$$
for all $p\in\mathbb R^4$ and $R$ a rotation matrix (which may include space inversion?). We could even perhaps extend this to boosts as well as rotations, but the former mix the $s$ components and so I guess this gets trickier.
We want $u(p)$ to be a solution of $(\not p-m)u(p)=0$ whenever $p$ is on-shell (but not for general $p$, because $\text{det}(\not p-m)=(p^2-m^2)^2$, which means that for off-shell momenta, there are no non-trivial solutions).
Finally, I'm not sure if we could ask for $u_s(p)$ to be an helicity eigenstate $hu_\pm(p)=\pm \frac12 u_\pm(p)$, because for off-shell momenta, I don't think $h=\boldsymbol p\cdot\boldsymbol J/m$ is well-defined (and/or covariant).

Moreover, can we say something about higher spin polarisation vectors?

A: The most natural extension of $u_s(p)$ off the mass shell is to define this object as the solution of
$$
\left(\not p+\sqrt{p\cdot p\vphantom{A}}\,1_{4\times4}\right)u_s(p)=0 \tag{1}
$$
which clearly has at least one solution, because
$$
\det\left(\not p+\sqrt{p\cdot p\vphantom{A}}\,1_{4\times4}\right)=0\tag{2}
$$
In fact, it is not difficult to show that
$$
\mathrm{rank} \left(\not p+\sqrt{p\cdot p\vphantom{A}}\,1_{4\times4}\right)=2\tag{3}
$$
and therefore $(1)$ has exactly two (orthogonal) solutions. The equation $(1)$ is covariant, and therefore its solutions depend covariantly on $p^\mu$, and agree with the standard definition of the Dirac spinors by letting $m^2\equiv p^2$ with $m>0$.
We note that this definition of $u_s(p)$ is no more nor less general than the standard definition: here $u$ depends on the four components $p^\mu$, while in the standard case it depends on $\boldsymbol p$, but also implicitly on $m$, and therefore both objects are actually the same thing (the former case emphasises the dependence on $p^0$, while the latter emphasises the dependence on $m$, but the relation $p^0=p^0(m)$ can always be inverted to yield $m=m(p^0)$ and viceversa).
One very important remark is that this "extension" of $u$ off the mass-shell has nothing to do with what Weinberg does to define the off-shell propagator. In particular, Weinberg's approach is based on the extension
$$
\sqrt{\boldsymbol p^2+m^2}\to p^0\tag{4}
$$
or, equivalently, at the level of the spin sums,
$$
\sum_s u(\boldsymbol p)\bar u_s(\boldsymbol p)\to \not p-m\tag{5}
$$
with $p^0$ an off-shell Fourier variable.
Weinberg's extension, and the one that we are considering here, are completely unrelated. My "extension" above is not to be used in any practical application. It is not the polarisation vector of an off-shell particle. It is not a part of an off-shell propagator. As I said in the OP, I just wanted a spinor (in the abstract, algebraic sense) that depends on the four variables $p^\mu$. I didn't have any particular motivation for this question; rather, I just wanted to have a simple spinor to play around with. In my opinion, this answer addresses precisely that, and nothing else. If someone thinks that this answer is wrong, then it is because they didn't understand what I was trying to ask in the OP (of course, I am to blame: I should have been more clear about what I had in mind). As far as I'm concerned, this post answers my original question.
Again, and to reiterate: in this answer I did not extend the propagator off the mass-shell (and in the OP I didn't ask that). My "extension" has no usefulness for actual computations in QFT.


text:
Q: swf to Illustrator friendly format (vector) So I'm making a drawing app that uses flash. I want to be able to export my drawing into an illustrator friendly format.
I'm thinking I will need to record the shapes drawn with a "history" and then export those either via text/xml/bytearray.
Have any fellow overflowers heard of tool to make my life easier? Thanks!

A: Install a PDF printer driver like this one http://www.pdf995.com/ (it's free with a few annoying ads)
Export your FLA > SWF
Open SWF and right click on the SWF window > Print
Choose the PDF printer driver and print to file
Open the resulting PDF in Illustrator CC
Vectors are preserved!

A: Joshua Davis used to save/print it as a pdf/PostScript file, and then open it in Illustrator...
[EDIT]
And it seems that it is still possible.
I installed a PostScript printer that prints to file (kb2.adobe.com/cps/404/kb404883.html), I am running windows vista and installed a Canon PS-NX5000.
I've tried 2 different swfs in the standalone player, one which draws rectangles and another which draws lines.
Right-Click>Print...>Canon PS-NX5000>Print.
Enter a file name with a .ai extension. Open in Illustrator. Select all and ungroup/break apart. Assets are vectors. Job Done!

A: If you want to export to something that Illustrator can import as defined shapes and paths then use SVG.  You can generate the SVG from Flash (not automatically, manually) and then Illustrator can import it.
One technique I've seen is to create a wrapper for the underlying Graphics instance on the DisplayObject you're drawing to.  Override all the primitive drawing calls (moveTo, lineTo, etc) with your own that record what was done and then call the originals.  This way you can have a full history to write out to SVG.

A: I use this online tool http://iiistudio.com/convert2svg/
It works the best and save the result in SVG format you can directly open with Adobe Illustrator, and it's made in flash application. You can download the swf file and it could work locally without server backend anyway as I guessed it has php or js!
As I tried to import the swf file I exported from Toon Boom Harmony to Adobe Flash, it's into the stage but the vector curves are zig-zagged not what I want. Ans I also tried print the swf to PDF with variety of virtual PDF printer such as Foxit PDF printer, PDF Factory Pro and the results is bad as well, not the original shapes at all.
results are so different in PDF, Flash and swf2svg:
https://i.stack.imgur.com/7bJnf.jpg


text:
Q: phpspreadsheet syntax error, unexpected 'require_once' (T_REQUIRE_ONCE), expecting function (T_FUNCTION) I am getting this error when I put it in the class controller. It works fine if I remove the class controller. How do I fix it?

Parse error: syntax error, unexpected 'require_once' (T_REQUIRE_ONCE),
  expecting function (T_FUNCTION) in
  D:\xampp\htdocs\m2302\admin\controller\tool\import_export.php on line
  9 expecting function

class ControllerToolImportExport extends Controller {

//$dir = (strcmp(VERSION,'3.0.0.0')>=0) ? 'library/export_import' : 'spreadsheet';
//chdir( DIR_SYSTEM.$dir );
//require_once('src/PhpSpreadsheet/Spreadsheet.php');

*require_once('D:/xampp/htdocs/m2302/system/spreadsheet/autoload.php');*

//include the classes needed to create and write .xlsx file
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

//object of the Spreadsheet class to create the excel data
$spreadsheet = new Spreadsheet();

//add some data in excel cells
$spreadsheet->setActiveSheetIndex(0)
 ->setCellValue('A1', 'Domain')
 ->setCellValue('B1', 'Category')
 ->setCellValue('C1', 'Nr. Pages');

A: You code is all just "loose" in the class.
It should be in a method (function) instead e.g.:
class ControllerToolImportExport extends Controller {
    function index() {
        // Put your code here.
    }
}


text:
Q: Why can't I directly access table.AutoFilter.filters.Item(1).On and set it to False? Normally when trying to figure out how to access a value or attribute of an object in VBA, I can open the Locals Window and look through the children of the object in question and drill down until i find the value I'm looking for.  For instance, if I wanted to get the second cell/column of a named listrow a simple search through the Local Window reveals that something like
selectedRow.Range.Value2(1, 2)

should get me the answer.
So all that being true, why doesn't a statement like the following work?
table.AutoFilter.Filters.Item(1).On = False

Assuming i wanted to remove the filter from just the first column of a set table object, the previous statement should work, at least according to the Locals Window and Excel VBA documenation.  Or something like:
table.AutoFilter.Filters.Item(3).Criteria1 = "SearchString"

Should let me update the Criteria for the third column in my table.  Its clearly marked with the values populated in the Locals Window, the VBA editor happily offers each level in the auto complete while typing it out and yet every level after 'AutoFilter' throws an error when attempting to run.
So why are these attributes provided/suggested if you can't use them? What am I missing?

A: For Excel 2010 and 2013 the AutoFilter.Filter.Ttem.On property is read-only. So that answers your first question.
http://msdn.microsoft.com/en-us/library/office/ff197843%28v=office.15%29.aspx
The same is true for the AutoFilter.Filter.Ttem.Criteria1 property. Which answers the second one.
(I didn't know either of these things before now, so thanks for asking.)


text:
Q: juju bootstrap fails with connection timed out errors This is a follow up question to my earlier question. Back then, juju was hanging trying to connect to the MAAS node. God knows what happened, it went ahead and is now failing with Connection timed out error while trying to download tools from the canonical website. The exact error is -
curl: (7) Failed to connect to streams.canonical.com port 443: Connection timed out

tools from https://streams.canonical.com/juju/tools/releases/juju-1.18.4-trusty-amd64.tgz downloaded: HTTP 000; time 126.330s; size 0 bytes; speed 0.000 bytes/s

2014-10-16 23:32:08  ERROR juju.provider.common bootstrap.go:123 bootstrap failed: rc: 1

The link from where juju is trying to download stuff is a perfectly valid one.
I saw people having similar problems in connecting to https://streams.canonical.com  but there the problem was juju was unable to resolve the hostname but I don't think thats the case with our problem
Any hints are welcome.
EDIT: While juju hangs trying to connect to canonical before giving up, I ran juju -status from another terminal. It shows this error
ERROR state/api: websocket.Dial wss://slot13.maas:17070/: dial tcp 10.10.10.102:17070: connection refused
10.10.10.102 is the private IP of our remote node. On one terminal juju says its trying download tools to deploy the node and on the other node, it says that remote node is refusing connection. Quite paradoxical!

A: If, in maas, 10.10.10.102 is set as your gateway, this would be expected behavior.  At least it would be by me, having been bitten by this king of thing. I renamed the machine I was use for juju bootstrap to jujuBS, so try this, which bring everything you need local to the maas server:
mkdir ~./.juju/sync-tools
juju sync-tools –e maas –destination="~/.juju/sync-tools"
juju bootstrap –e maas –-upload-tools=true –-metadata-source=".juju/sync-tools" -–to jujuBS.local
mkdir –p ~/.juju/charms/trusty
juju charm get juju-gui .juju/charms/trusty
juju deploy –repository="~/.juju/charms" local:juju-gui

A: I've had the same error on my environment and I've resolved that run the following command:
$: juju bootstrap -e maas --to JujuGui.maas  --upload-tools --debug

below the result of the debug:
http://paste.ubuntu.com/14696174/
after that I installed juju-gui
$: juju status -e maas
environment: maas
machines:
  "0":
    agent-state: started
    agent-version: 1.25.3.1
    dns-name: JujuGui.maas
    instance-id: /MAAS/api/1.0/nodes/node-0672fb10-c53d-11e5-a26c-525400c4a170/
    series: trusty
    hardware: arch=amd64 cpu-cores=1 mem=1024M
    state-server-member-status: has-vote
services: {}

$: juju deploy juju-gui --to 0

running this command obtain this error
ERROR cannot retrieve charm "cs:trusty/juju-gui-44": cannot get archive: Get https://api.jujucharms.com/charmstore/v4/trusty/juju-gui-44/archive: dial tcp 162.213.33.122:443: connection refused

why?


text:
Q: Problem with installing SAP NETWEAVER on Linux I'm having trouble installing SAP Netweaver 7.50 SP2, I'm installing on Linux openSUSE 15.0 on a VM. After the commands for installation:
sudo ./install.sh

it accuses the following error:
The hostname you have chosen is either configured on a loopback device
or not active on this server, please check your configuration and hostname
selection. If you are confident about your choice of hostname, start the
install script with -s flag to skip the hostname check.

Has anyone ever had this problem solved?

A: If you're following this 7.50 SP2 installation procedure, did you follow the indicated prerequisites or use one of the 4 install options, and if not can you explain why?
Moreover, why don't you install the more recent 7.52 SP1 which doesn't have these prerequisites and install options?
All the next lines are taken from the 7.50 SP2 guide :
[prerequisite 1] Network configuration of the SAP host operating system:

*

*The officially supported setup requires a static IP address for the hostname used for the SAP installation. Using DHCP is possible for this developer edition, but be aware of potential consequences. If our installation cannot ping the hostname specified when installing, the installation and startup of the SAP system will fail. Make sure that the hostname specified during installation fulfills SAP requirements, most importantly that it does not exceed 13 characters length and also needs to survive subsequent reboots.

[prerequisite 2] Firewall:

*

*Deactivate the firewall.

We provide you with several installation options:

*

*./install.sh – installs the Developer Edition in dark mode, the installer will configure the SAP system for usage of the physical hostname

*./install.sh -g– will present you a SAPINST GUI allowing you to modify certain system parameters

*./install.sh -h – allows you to specify your own hostname to be used by the SAP system

*./install.sh -s – allows you to skip the hostname check


text:
Q: AngularJs scope attributes and promises I have this code:
var geocode = function(value) {
 var request;
 .....
 var dResult = Q.defer();
 geocoder.geocode(request, function (results) {
   dResult.resolve(results);
 });
 return dResult.promise;
};

var cancelWatch;
$scope.$watch('value', function (value) {
 $timeout.cancel(update);
 update = $timeout(function () {
   $scope.geocodedResult = geocode(value);
 }, 300);
});

in line 15 $scope.geocodedResult is a promise that sooner or later will become the result value and the scope should refresh. This unfortunately does not happen.
The code works if I do
geocode(value).then(function(result) {
 $scope.geocodedResult = result;
 $scope.$digest();
});

What am I doing wrong?
UPDATE:
I'm now trying to use only $q but I cannot get it to work:
this.getCurrentPosition = function () {
    var dCurrentPosition = $q.defer();
    if (currentPosition) {
        dCurrentPosition.resolve(currentPosition);
    } else {
        navigator.geolocation.getCurrentPosition(function (cp) {
            currentPosition = cp;
            dCurrentPosition.resolve(currentPosition);
        });
    }
    return dCurrentPosition.promise;
};
this.getCurrentLoc = function () {
    return self.getCurrentPosition().then(function (currentPosition) {
        return [currentPosition.coords.longitude, currentPosition.coords.latitude];
    });
};

a breakpoint in
return [currentPosition.coords.longitude, currentPosition.coords.latitude];

will never get triggered while it works fine with Q

A: If you use Angular's $q instead of Q, it should work:
var dResult = $q.defer();

$q promises are recognized by the templating engine in angular, which means that in templates you can treat promises attached to a scope as if they were the resulting values. -- $q docs

So $scope.geocodedResult can be set to the $q promise, and when the promise is resolved, the scope property will automatically update.


text:
Q: How to let the diagram drawed by canvas produce onclick event I have an imageView and I draw the diagram in imageView according to the coordinate array. Every diagram has an onclick event.
Activity.java
package com.example.floorexhibitiontest;
import com.floor.DrawView;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
public class HallActivity extends Activity {@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.hall);
    }

    float[][][] points = new float[][][] {
        {
            {213,264},
            {247,232},
            {345,338},
            {310,371}
        },
        {
            {171,305},
            {205,272},
            {302,373},
            {267,406}
        },
        {
            {571,320},
            {606,320},
            {606,428},
            {571,428}
        }
    };

    LinearLayout layout = (LinearLayout)findViewById(R.id.root);
    final DrawView draw = new DrawView(this,points);
    layout.addView(draw);
}

DrawView.java
package com.floor;
import com.example.floorexhibitiontest.R;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Path;
import android.graphics.Paint.Style;
import android.graphics.Shader.TileMode;
import android.graphics.Shader;
import android.util.DisplayMetrics;
import android.view.View;

public class DrawView extends View{
    private float[][][] points = null;
    DisplayMetrics metric = new DisplayMetrics();

    public DrawView(Context context,float[][][] p) {
        super(context);
        metric = context.getApplicationContext().getResources().getDisplayMetrics();
        points = p;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        float density=metric.density;

        for(int i = 0; i < points.length; i++){
            Paint p = new Paint();
            p.setAntiAlias(true);
            p.setColor(Color.BLUE);
            Path path=new Path();
            path.moveTo(points[i][0][0] / density, points[i][0][1] / density);
            path.lineTo(points[i][1][0] / density, points[i][1][1] / density);
            path.lineTo(points[i][2][0] / density, points[i][2][1] / density);
            path.lineTo(points[i][3][0] / density, points[i][3][1] / density);

            path.close();
            p.setStyle(Style.STROKE);
            canvas.drawPath(path, p);
        }
    }
}

At present effect:

*

*How to let each rectangular drawed produce their own onclick event?

*There is an ImageView in Layout file. My purpose is to put the graphics paint on the ImageView. But the result is ImageView can display. The painted graphics can not display. If I hide
ImageView, the image can display.

Ask everyone's help. Thanks in advice.

A: Try smth like this:
public boolean onTouch(View v, MotionEvent event) {
   if((event.getX(0)>=x_coord) &&
      (event.getY(0)>=y_coord) &&
     ( event.getX(0)<=x_coord + your_rectangle_width) &&
      (event.getY(0)<=y_coord + your_rectangle_heigth))
      {
          //rectangle selected
      }
   return true;
}

Or use in onTouch() your actual coordinates from points[] array