text:
Q: Right-to-Left in Yiddish in Pages for Mac Pages for mac now supports Hebrew, which is written from right to left. However, Pages does not seem to support custom keyboard layouts other than the system's Hebrew layout(s). I am using Shoshke's Yiddish Kayboard Layout for mac (I don't have enought "reputation" to post the link here, but it is actually not that important) on Yosemite, by the way, which allows me to type Yiddish with punctuation extremely effeciently.
When writing in Pages using the system's native Hebrew layout, this is what I get:

However, when writing with my custom Yiddish keyboard (which was most probably created using Ukelele), I get this:

As you can see, the period is on the right, while it should be on the left (at the end of the sentence). This is just an obvious example, but when mixing Yiddish and English in the same sentence the result is even worse.
Unfortunately, Pages' paragraph direction controls do not solve the problem. Pages obviously recognizes the input language and implements the right-to-left correcly only for languages it recognizes from the system's native keyboard layouts (e.g. "Hebrew").
Writing Yiddish with the native Hebrew keyboard is possible, but is much much slower for me. Therefore, I am looking for a way to still use the Yiddish keyboard in Pages, which seems very stable and rebust in comparison to other available word processors (not to mention that it was shipped for free with my new mac).
I see 4 ways to go about it:

*

*Editing the native Hebrew keyboard layout, adapting it to my needs (so far I could only find information about creating new custom keyboard layouts, not about changing the system's existing ones; this solution would actually be the best one - as there is absolutely no advanatge of the Hebrew native keyboard over the Yiddish one).

*Somehow making Yosemite believe that my custom Yiddish keyboard is a sort of "Hebrew" (currently it puts it under "Others" when installing it from the Keyboard preference pane, which explains why Pages does not identify it as an RTL language).

*Somehow making Pages believe that my Yiddish keyboard is a sort of "Hebrew".

*Programming keyboard-shortcuts for Pages that would immitate the custom keyboard's behaviour (so far I was only able to find ways to program keyboard-shortcuts for the app's menu items; maybe there is a third-party application that can program such shortcuts?)

I looked for answers online and tried to open the package contents of the Pages app and was just unable to discover how to achieve any of the four solutions... I would truly appreciate if anyone could help me out (and maybe there is another solution?)
Thank you very much!

A: Pages 5 does have paragraph direction controls. See
https://support.apple.com/kb/PH15331
Regarding 4, you can make text replacement sequences in system prefs/keyboard/text
Regarding 1 and 2, you might ask in the group devoted to Ukelele
https://groups.google.com/forum/#!forum/ukelele-users
In that group they suggested opening the layout with the latest version of Ukelele and setting the Language to Hebrew.  I tried that and saved as a bundle and it did the trick:  The layout appears under Hebrew instead of Others and periods go in the right place.

A: I was able to solve this problem with Ukelele. The said keyboard layout was created with a previous version of Ukelele. Opening the .keylayout file with the newest version (3.0b2) was possible, but it was not possible to access the language setting (through "Keyboard -> Set Keyboard Language..."). Instead, I switched to my Yiddish custom keyboard and then, in Ukelele, "File -> New From Current Input Source." I could then change the language settings to Hebrew (note that you should only change where it says "Language (required)", and certainly not "Script (optional)". doing that mysteriously prevents the system from classifying the keyboard layout under "Hebrew", and puts it instead in "Others"). I could then save the keyboard layout as a .bundle package, move it to Library/Keyboard Layouts, and add it through "System Preferences -> Keyboard -> Input Sources -> +". This it, it appeared under "Hebrew", and not under "Others". After a system restart, Pages is now able to treat my updated Yiddish keyboard layout as if it were Hebrew, that is with correct right-to-left functionality!
Thank you Tom for referring me the Ukelele Google Group. They were able to put me on the right track!


text:
Q: Inject a p namespace attribute using spring annotations I have a bean defined similar to below in my spring.xml. I am converting all my beans into annotation based. How can I inject the attributes in the below listed bean?
<bean
        id = "dataPropDao"
        class = "com.service.ref.DataPropDaoImpl"
        p:dataSource-ref = "data.dataSource"
        p:sql = "PROFILE_PKG.GetProfileByCode"
        p:function = "true"/>

A: "p" namespace is used to set bean properties using setters. Equivalent of your code in Java config would be similar to:
@Configuration
class MyConfig {
    @Bean
    DataPropDaoImpl dataPropDao(DataSource datasource) {
        DataPropDaoImpl dao = new DataPropDaoImpl();
        dao.setDataSource(datasource);
        dao.setSql("PROFILE_PKG.GetProfileByCode");
        dao.setFunction(true);
        return dao;
    }
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Handling API Calls in React Native? I am new to react native and trying to interact with an API helper I've made in one of my screen files, I'm sure this is a syntax error but I'm also interested if the architecture of it is correct as I come form iOS development.
The function with the error:
  handleLoginPress = () => {
    ApiHelper.loginDriver(this.state.email, this.state.password)
      .then((result) => {
        console.log(result);
    }).catch((error) => {
        console.log("error is " + error);
    });
  };

Error is:

Property 'then' does not exist on type 'void'

The function its calling:
static loginDriver(username: string, password: string) {
    fetch('http://localhost:8080/drivers/login', {
         method: 'POST',
    headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({
        uername: username,
        password: password,
    }),
    });
}

My thought is there needs to be some specification as to the return type on the apis login function?

A: return is missing from your loginDriver function, add a return statement to return the data.
static loginDriver(username: string, password: string) {
  return fetch('http://localhost:8080/drivers/login', {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      uername: username,
      password: password
    })
  });
}


text:
Q: python wouldn't scrape the texts but gives me an empty white space I'm trying to web scrape some customer reviews from Trip Advisor website.
For some of the reviews, I could scrape without any problem but for the others, I couldn't scrape properly. It just gives me an empty white space.
Could anyone help with this?
Below is my simplified code.
from urllib.request import urlopen
from bs4 import BeautifulSoup
import re

b_link="https://www.tripadvisor.com/ShowUserReviews-g60607-d1468361-r460991443-Ohana_House_Volcano_s_Popular_Rainforest_Retreat-Volcano_Island_of_Hawaii_Hawaii.html"

links_open_b=urlopen(b_link)
soup_b=BeautifulSoup(links_open_b,"html.parser")
first_text_b=soup_b.find_all("div", class_="entry vrReviewText")
actual_text_b=first_text_b[0].text
actual_text_b=re.sub('\s+',' ',actual_text_b)
print (actual_text_b)

What I can get:
Just an empty white space.

What I want to get:
The Ohana house at Volcano was an absolutely perfect match for our family and our 5 day stay on the Big Island.
...
we had a great time in every aspect of our visit, and would highly recommend this house for anyone who wants to explore the eastern side of the Big Island.

A: The review is actually loaded via
https://www.tripadvisor.com/UserReviewController?a=fullTrans&r=460991443

To get the review, you can use the requests module:
import requests

URL = "https://www.tripadvisor.com/UserReviewController?a=fullTrans&r=460991443"

response = requests.get(URL).json()

print(response[0]["body"])

Output:
The Ohana house at Volcano ... side of the Big Island.


text:
Q: Sections with number ranges I've been working on an assignment, and two of the questions are very similar and it's easier to write about them both in the same section. The problem with this is it screws the numbering up:
1 Section Title
(Question 1)
2 Section Title
(Question 2 and 3)
3 Section Title
(Question 4)

My current approach is:
1 Section Title
(Question 1)
2 Section Title
(Question 2 and 3)
\setcounter{section}{3}
4 Section Title
(Question 4)

Ideally, what I'd like to do is:
1 Section Title
(Question 1)
2-3 Section Title
(Question 2 and 3)
4 Section Title
(Question 4)

Is this possible? I understand that the section counters are based on integers, but is there a way to override their visual representation?

A: The visual representation of the section counter is specified by macro \thesection, which can be redefined:
\section{Section Title}
(Question 1)

\let\savedthesection\thesection
\renewcommand*{\thesection}{%
  \arabic{section}--\the\numexpr\value{section}+1\relax
}
\section{Section Title}
\stepcounter{section}
\let\thesection\savedthesection
(Question 2 and 3)

\section{Section Title}
(Question 4)

Full example including patch for the table of contents to increase the spacing for the sections.
\documentclass{article}

% Patch section entries in table of contents to get
% more space for the section numbers
\usepackage{etoolbox}
\makeatletter
\patchcmd\l@section{1.5em}{2.5em}{}{%
  \errmessage{\noexpand\l@section could not be patched}%
}
\makeatother

\begin{document}

\tableofcontents

\section{First question}

\let\savedthesection\thesection
\renewcommand*{\thesection}{%
  \arabic{section}--\the\numexpr\value{section}+1\relax
}
\section{Second and third question}
\stepcounter{section}
\let\thesection\savedthesection

\section{Fourth question}

\end{document}

Macro \rangesection
The following example defines \rangesection with the following arguments:
\rangesection{<number of additional sections>}[<toc entry>]{<section title>}

Also different number schemes are supported.
\documentclass{article}

% Patch section entries in table of contents to get
% more space for the section numbers
\usepackage{etoolbox}
\makeatletter
\patchcmd\l@section{1.5em}{2.5em}{}{%
  \errmessage{\noexpand\l@section could not be patched}%
}

\newcommand*{\rangesection}[1]{%
  \@dblarg{\@rangesection{#1}}%
}
\def\@rangesection#1[#2]#3{%
  \let\saved@thesection\thesection
  \stepcounter{section}%
  \protected@edef\from@thesection{\thesection}%
  \addtocounter{section}{#1}%
  \protected@edef\to@thesection{\thesection}%
  \addtocounter{section}{-1}%
  \renewcommand*{\thesection}{%
    \from@thesection--\to@thesection
  }%
  \section[{#2}]{#3}%
  \let\thesection\saved@thesection
}
\makeatother

\begin{document}

\tableofcontents

\noindent\dotfill

\section{First question}

\rangesection{1}{Second and third question}

\section{Fourth question}

\renewcommand*{\thesection}{\Alph{section}}
\setcounter{section}{0}

\section{First appendix question}

\rangesection{4}{Second to sixth appendix question}

\section{Seventh appendix question}

\end{document}


text:
Q: Debug Python using PDB on Windows Anyone know how to debug Python using PDB in Windows XP?
My system has some deadlock. I want to use PDB to track my system.
My Config: VC 2005, Python2.7

A: I would recommend using the Winpdb GUI debugger, which works great on Windows (and other OSes too--the name is misleading) and can attach to processes after launch. There's a great tutorial that gets you all the basics, which has been enough for me every time I've needed it, at least. Good luck!

A: I think the following page will help you. It's pydev with Eclipse.
http://pydev.org/manual_adv_remote_debugger.html


text:
Q: On the rigorous definition of the sum or a function of two random variables Edit: In some sense the questions have been solved. The issue is actually about independence. Please see comments.
Suppose that we toss a coin and the outcome is either head or tail. So the sample space is $\Omega=\{H,T\}$ and the probability measure is given by $\mathbb{P}(H)=\mathbb{P}(T)=\frac{1}{2}$. Now define a random variable $X_1$ by $X_1(H)=0,  X_1(T)=1$ Now suppose that we toss the coin again and get a random variable $X_2$, which is defined in the same way as $X_1$. Then by common sense that the random variable $$X_1+X_2$$ can attain value 1 by firstly the head is up and then the tail is the up side.
However, the first method of defining the sum of two random variables would be $$(X_1+X_2)(\omega)=X_1(\omega)+X_2(\omega)$$ and by this method the sum would not attain value 1 and this contradicts the common sense in the example above.
The second method is to construct product of the sample space. Let $\Omega_2$ be defined in the same way as $\Omega$, and $\Omega_2$ represents that we toss the coin again. Let $\Omega_0$ be the Cartesian product of $\Omega$ and $\Omega_2$ so $\Omega_0=\{HH,HT,TH,TT\}$. The probability measure on the $\Omega_0$ is defined by $\mathbb{P}(E_0)=\mathbb{P}(E)*\mathbb{P}(E_2)$ for any events ie. subsets of sample space. We can view the random variable $X_1$ to be defined on the $\Omega$ and the random variable $X_2$ to be defined on the $\Omega_2$. Then let $X_i$ to be extended to random variables on $\Omega_0$ by the natural projections to the first and second coordinates of Cartesian product, respectively. Now they are defined on the same space so we can add them up by the first method. For example, if we use this second method, $$(X_1+X_2) (TH) = X_1(T)+X_2(H)=1$$ and this agrees with the common sense in the example.
Questions:

*

*Does the linearity property of expectation, namely $E(X+Y)=E(X)+E(Y)$, holds for the first or second or both methods of adding two random variables?

*I understand that this topic of the rigorous definition of the sum of two random variables is explained in reference to the MSE answer by Brent Kerby, but is there a textbook reference? Or in general the definition of a function of two random variables.

*Which definition do people usually mean when they say the sum of two random variables?
I'm a novice in probability theory. Thank you.


text:
Q: Is there some way to get a string description of CFStreamError? I am using an API which has handed me a CFStreamError (which is supposedly deprecated, but Apple themselves obviously don't care.)
I know some of the values and I could certainly write multiple nested switch statements to convert all the values I know into strings, but there will be values I don't know.
Isn't there some convenient way to get an error message out? I don't care whether it's localised or not because it will only end up in our logs anyway.

A: The 'old', pre-NSError way of handling errors usually involved return codes that were supposed to be used internally by the application (i.e. the developer) and not for presenting to the user.
With newer APIs the NSError returned actually contains information that an be presented to the user (if appropriate).
As for the CFStreamError -
There's an entry on CocoaDev on making CFStreamError human-readable:
http://cocoadev.com/CFStreamErrorCodes
Basically it involves manually checking the various error domains from CFStream Error Domain Constants.
A bit more information from Developer Technical Support can be found in this post on the Macnetworkprog mailing list.

A: This works for POSIX domain errors:
            if (err.domain == kCFStreamErrorDomainPOSIX) {
                DLog("POSIX err: %s", strerror(err.error));
            } else {
                DLog("domain: %d, value: %d", err.domain, err.error);
            }

E.g.:

2020-01-31 09:58:02.996603-0800 blah void CFWriteStreamCB(CFWriteStreamRef _Null_unspecified, CFStreamEventType, void * _Null_unspecified):26 POSIX err: Operation timed out


text:
Q: UnauthorizedAccessException when trying to open serial port in C# I'm using .NET 4.5.2. In one of my ViewModels, I need to access serial port COM8, which is connected to my device, a sensor that provides a continuous stream of data. I can access and send commands to the serial port via Tera Term, Windows Command Prompt, and a LabView application, so the port is not occupied by another process - I know that is usually the case with these posts, but I'm very sure that is not the case here. I've tried sending a command to the port via C# using the Process() class, but that does not work, so it seems to be something with C#.
I saw this post: Force a COM port to close, but that does not seem to be the issue either.
Other things I've tried:

*

*Uninstalling the COM8 device via Device Manager.

*Running the application in "Release" mode via Visual Studio.

*Running Visual Studio in Administrator mode.

*Switching to .NET 4.5.2.

And a few other things that I'm not recalling right now. Any advice about this situation would be appreciated! I'm happy to provide any more information you may need.
Code to open the port:
if (port == null)
{
    port = new SerialPort(location, baudRate);
    port.ReadBufferSize = 16384;
}
if (!port.IsOpen)
{
    port.Open();
}

Update:
If I copy the above code into the startup method, it works fine. It just doesn't seem to work where it is in my ViewModel. I thought it was a threading issue, but I was able to call the code in the main thread and it did not work. Hopefully this will get me closer to a solution!
Update 2:
The code above also works fine in the codebehind of my login method, but in no other codebehind. Super confused right now.


text:
Q: Install new most recent python package in ubuntu? I could really do with installing matplotlib 1.1.0 on my ubunutu 11.10 system.
The current ubuntu package is at 1.0.1, how do I use the new one?

A: The simplest way is:

*

*Uninstall the current mathplotlib package that you have installed.

*Download source from the distribution site

*Compile and install


text:
Q: Why should I not use collect() in my Python Transforms? TL;DR: I hear rumors that certain PySpark functions aren't advisable in Transforms, but I'm not sure what functions are wrong and why they are so?
Why can't I just collect() my data in certain circumstances to a list and iterate over the rows?

A: There's a lot of pieces here one needs to understand to arrive at the final conclusion, namely that collect() and other functions are inefficient uses of Spark.
Local vs. Distributed
First, let's cover the difference between local vs. distributed computation. In Spark, the pyspark.sql.functions and pyspark.sql.DataFrame operations you typically execute, such as join(), or groupBy() will delegate execution of these operations to the underlying Spark libraries for maximum possible performance. Think of this as using Python simply as a more convenient language on top of SQL where you are lazily describing the operations you want Spark to go do for you.
In this way, when you stick to SQL operations in PySpark, you can expect highly scalable performance, but only for things you can express in SQL. This is where people can typically take a lazy approach and implement their transformations using for loops instead of thinking about the best possible tactics.
Let's consider the case where you want to simply add a single value to an integer column in your DataFrame. You'll find on Stack Overflow and other places plenty of examples in some more subtle cases where they suggest using a collect() to bring the data into a Python list, looping over every row, and pushing the data back into a DataFrame when finished, which is one tactic you could do here. Let's think about what it means in practice, however: you are bringing your data which is hosted in Spark back to the driver of your build, for looping using a single thread in Python over each row, and adding a constant value to each row one at a time. If we instead found the (obvious in this case) SQL equivalent to this operation, Spark could take your data and in massively parallel add the value to individual rows. Namely, if you have 64 executors (instances of workers available to do the work of your job), then you'll have 64 'cores' (this isn't a perfect analogy but is close) to get the data split and sent to each for adding the value to the column. This will let you dramatically more quickly perform the end result operation you wanted.
Doing work on the driver is what I refer to as 'local' computation, and work in executors as 'parallel'.
This may be an obvious example here, but it often times is tough to remember this difference when dealing with more difficult transformations such as advanced windowing operations or linear algebra computations. Spark has libraries available to do matrix multiplications and manipulations in a distributed fashion, as well as some pretty advanced operations on Windows that require a bit more thinking about your problem first.
Lazy evaluation
The most effective way to use PySpark is to dispatch your 'instructions' on how to build your DataFrame all at once, so that Spark can figure out the best way to materialize this data. In this way, functions that force the computation of a DataFrame so you can inspect it at some point in your code should be avoided if at all possible; they mean Spark is working extra to satisfy your print() statement or other method call instead of working towards writing out your data.
Python in Java in Scala
The Python runtime is actually executing inside a JVM that is in turn talking to the Spark runtime, which is written in Scala. So, for every call to collect() where you wish to materialize your data in Python, Spark must materialize your data into a single, locally-available DataFrame, then synthesize this from Scala to its Java equivalent, then finally pass from the JVM to the Python equivalents before it is available to iterate over. This is an incredibly inefficient process that isn't possible to parallelize.
This results in operations that render your data to Python being highly advisable to avoid.
Functions to avoid
So, what functions should you avoid?

*

*collect

*head

*take

*first

*show

Each of these methods will force execution on the DataFrame and bring the results back to the Python runtime for display / use. This means Spark won't have the opportunity to lazily figure out the most efficient way to compute upon your data and will instead be forced to bring back the data requested before proceeding with any other execution.


text:
Q: ob for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details Hello i am settting my django app and i got the following error
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

when I run this command "systemctl status nginx.service"
I got this
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2021-06-08 08:44:51 UTC; 1min 36s ago
       Docs: man:nginx(8)
    Process: 1878 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

and when I run "journalctl -xe"
i got following message
--
-- The job identifier is 1.
Jun 08 08:27:55 ubuntu-s-1vcpu-1gb-blr1-01 systemd[886]: Startup finished in 133ms.
-- Subject: User manager start-up is now complete
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The user manager instance for user 1000 has been started. All services queued
-- for starting have been started. Note that other services might still be starting
-- up or be started at any later time.
--
-- Startup of the manager took 133459 microseconds.
Jun 08 08:28:40 ubuntu-s-1vcpu-1gb-blr1-01 systemd[886]: Started D-Bus User Message Bus.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit UNIT has finished successfully.
--
-- The job identifier is 16.
Jun 08 08:28:40 ubuntu-s-1vcpu-1gb-blr1-01 dbus-daemon[1019]: [session uid=1000 pid=1019] AppArmor D-Bus mediation is enabled
Jun 08 08:31:39 ubuntu-s-1vcpu-1gb-blr1-01 sudo[1308]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
Jun 08 08:31:44 ubuntu-s-1vcpu-1gb-blr1-01 sudo[1308]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
Jun 08 08:40:07 ubuntu-s-1vcpu-1gb-blr1-01 sshd[979]: Received disconnect from 47.15.4.238 port 54700:11: disconnected by user
Jun 08 08:40:07 ubuntu-s-1vcpu-1gb-blr1-01 sshd[979]: Disconnected from user yash 47.15.4.238 port 54700
Jun 08 08:40:48 ubuntu-s-1vcpu-1gb-blr1-01 sudo[1707]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
Jun 08 08:40:53 ubuntu-s-1vcpu-1gb-blr1-01 sudo[1707]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
Jun 08 08:44:47 ubuntu-s-1vcpu-1gb-blr1-01 sudo[1875]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
Jun 08 08:44:51 ubuntu-s-1vcpu-1gb-blr1-01 sudo[1875]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
~
~
~
~

can anyone help me
~


text:
Q: Standard Error is of Population Total We have the following data and we are required to obtain the standard error of unbiased estimate of the population total:
$N=160,n=64,\sigma^2=4$
My approach
We know that:
$SE(\bar{X})=\frac{\sigma}{\sqrt{n}}$
So, it can be written as:
$SE(\frac{Total}{n})=\frac{\sigma}{\sqrt{n}}$
Which in turn will be equal to:
$SE(Total)=(\sigma)(\sqrt{n})$.
In the above formula, after plugging in values, I am getting $SE=(2)(8)=16$
But this is not correct. The correct answer is $40$. Am I doing it incorrectly? I am not sure.
Any help?

A: The correct answer is obtained by multiplying the standard error with the total population.
S.E.$~=\frac{2}{8}\times160
   =40$


text:
Q: Magento model save method updating a record instead of inserting I have an array of image IDs and I am iterating on it to insert them in the database table 'slider_images'. Below is code snippet:
        try {
            $sliderImages= Mage::getModel('gallery/sliderImage')->getCollection()
                ->addFieldToFilter('slider_id', array('eq' => $sliderId));

            $sliderImageIds = array_column($sliderImages->getData(), 'gallery_image_id');

            $addImageIds = array_diff($galleryImageIds,$sliderImageIds);
            $deleteImageIds = array_diff($sliderImageIds, $galleryImageIds);

            foreach ($addImageIds as $addImageId) {
                $sliderImageData = array();
                $sliderImageModel = Mage::getModel('gallery/sliderImage');

                $sliderImageData['slider_id'] = $sliderId;
                $sliderImageData['gallery_image_id'] = $addImageId;

                $sliderImageModel->addData($sliderImageData)->save();
            }

            foreach ($deleteImageIds as $deleteImageId) {
                $deleteSliderImageModel = Mage::getModel('gallery/sliderImage');
                $deleteSliderImageModel->setGalleryImageId($deleteImageId)->delete();
            }

            $this->_getSession()->addSuccess(
                $this->__('Total of %d record(s) were successfully updated', count($galleryImageIds))
            );
        }catch (Exception $e) {
            $this->_getSession()->addError($e->getMessage());
        }

Here $addImageIds is an array of image ids:
Array ( [0] => 1 [2] => 2 )

Problem:  Here it is updating a record, instead of inserting a new one. If I checked a query log
UPDATE `slider_images` SET `gallery_image_id` = '1' WHERE (slider_id='11')

UPDATE `slider_images` SET `gallery_image_id` = '2' WHERE (slider_id='11')

and table schema is like below

I want insert those values instead of update.
Any help appreciated.

A: Call $sliderImageModel->unsetData(); After save method in loop.
Update
change code like below:
unset($sliderImages);
foreach ($addImageIds as $addImageId) {
    $sliderImageData = array();
    $sliderImageModel = Mage::getModel('gallery/sliderImage');

    $sliderImageData['slider_id'] = $sliderId;
    $sliderImageData['gallery_image_id'] = $addImageId;

    $sliderImageModel->addData($sliderImageData)->save();
    $sliderImageModel->unsetData();
    unset($sliderImageModel);
}

A: Place in your resource model gallery/sliderImage
protected $_isPkAutoIncrement = false;


text:
Q: Does repeating the same function in a formula increase calculation time? I'll give you an example:
=IF(SUMIF(A1:A500,TRUE,B1:B500)=250,"EXACT",SUMIF(A1:A500,TRUE,B1:B500))

Part SUMIF(A1:A500,TRUE,B1:B500) repeats twice in this formula.
What I wanted to understand is:

*

*Does Excel calculate SUMIF twice in this case?

*Does Excel calculate 2nd SUMIF occurence when IF evaluates to TRUE?

*If the next cell contains the exact same formula, does excel recalculate it anyway?

Thanks in advance!

A: Taking them in order:

*

*Only if the first part evaluates to False.

*No, see 1.

*Yes.

A: First part:

SUMIF will be calculated twice if it doesn't equal 250. If it equals 250 then it will calculate only once.

Second part:

Formula calculation will be repeated per cell even if both cells have identical formula.


text:
Q: Rigorous proof about homothetic figures Take a point $P$ in the 2D plane. If you're given two line segments $AB$ and $CD$ such that $PM$ and $PN$ are perpendicular bisectors where $M$ and $N$ are the midpoints of $AB$ and $CD$ (respectively).
This doesn't mean that they are homothetic. They can or can not be rotationally homothetic.
But when it's mentioned that $AC=BD$, they tend to become rotationally homothetic .
Can I get a rigorous proof?
I can't prove it with similarity.
This is not any problem. I am trying to understand the reason behind this. Just that.

A: To show that there's a rotational homothety centered at $P$ taking $AB$ to $CD$, we'll let $O$ be the center of the unique rotational homothety taking $AB$ to $CD$ (which almost always exists), and prove $O=P$.
A key fact about rotational homothety is that in this setting, there is always a second rotational homothety, also centered at $O$, which takes $AC$ to $BD$. But $AC = BD$. So this second rotational homothety is in fact just a rotation. This means that $A$ and $B$ lie on a circle centered at $O$, and $C$ and $D$ lie on another circle centered at $O$.
But then the perpendicular bisectors of $AB$ and $CD$ are perpendicular bisectors of chords in circles with center $O$. So they both pass through $O$. Almost always the two perpendicular bisectors have a unique intersection point. But we are told that $PM$ and $PN$ are perpendicular bisectors of $AB$ and $CD$. So $O=P$, and we are done.

The question says "When it's mentioned that $AC=BD$ they tend to become rotationally homothetic" I assume for the same reason that I said "almost always" twice in the proof above: this doesn't always work. There are two exceptional cases.
First, it's possible that there is no rotational homothety taking $AB$ to $CD$. This happens when $ABDC$ is a parallelogram (so this case does satisfy $AC = BD$).
Second, it's possible that the perpendicular bisectors of $AB$ and $CD$ coincide. In that case, just because $O$ lies on both and $P$ also lies on both doesn't mean that $O=P$. In this case, there are many candidate points for $P$, but only one of them is the center of a rotational homothety (actually, just a homothety) taking $AB$ to $CD$.


text:
Q: Stack columns in pandas dataframe to achieve record format I have a dataframe with the first column being country name, and the next 12 columns as annual gdp figures (with column headers '1999', '2000', '2001', etc):
import pandas as pd
gdp = pd.read_csv('gdp.csv')
gdp.head()
  Country Name        1999        2000        2001         2002         2003  \
0        Aruba  1722798883  1873452514  1920262570   1941094972   2021301676
1      Andorra  1239840270  1401694156  1484004617   1717563533   2373836214
2  Afghanistan         NaN         NaN  2461666315   4128818042   4583648922
3       Angola  6152936539  9129634978  8936063723  15285594828  17812704825
4      Albania  3414760915  3632043908  4060758804   4435078648   5746945913

         2004         2005         2006         2007         2008  \
0  2228279330   2331005587   2421474860   2623726257   2791960894
1  2916913449   3248134607   3536451646   4010785102   4001349340
2  5285461999   6275076016   7057598407   9843842455  10190529882
3 23552047248  36970918699  52381006892  65266452081  88538611205
4  7314865176   8158548717   8992642349  10701011896  12881352688

         2009         2010
0  2498932961   2467703911
1  3649863493   3346317329
2 12486943506  15936800636
3 73157893410  83369475451
4 12044212904  11926953259

How would I stack the table such that I have one column for country name, one column for year, and one column for gdp figures? This is my code so far:
gdp_s = gdp.stack()
gdp_s.head(20)

which results in:
0  Country Name           Aruba
   1999            1.722799e+09
   2000            1.873453e+09
   2001            1.920263e+09
   2002            1.941095e+09
   2003            2.021302e+09
   2004            2.228279e+09
   2005            2.331006e+09
   2006            2.421475e+09
   2007            2.623726e+09
   2008            2.791961e+09
   2009            2.498933e+09
   2010            2.467704e+09
1  Country Name         Andorra
   1999             1.23984e+09
   2000            1.401694e+09
   2001            1.484005e+09
   2002            1.717564e+09
   2003            2.373836e+09
   2004            2.916913e+09
dtype: object

Ultimately I'm looking for something like this:
Country Name    Year    GDP
Aruba           1999    1.722799e+09
Aruba           2000    1.873453e+09
Aruba           2001    1.920263e+09
Aruba           2002    1.941095e+09
etc...

Clearly I am new to python and pandas. Any help would be appreciated.

A: You could use pd.melt and then sort_values:
>>> d2 = pd.melt(df, id_vars="Country Name", var_name="Year", value_name="GDP")
>>> d2 = d2.sort_values(["Country Name", "Year"]).reset_index(drop=True)
>>> d2.head(10)
  Country Name  Year         GDP
0  Afghanistan  1999         NaN
1  Afghanistan  2000         NaN
2  Afghanistan  2001  2461666315
3  Afghanistan  2002  4128818042
4  Afghanistan  2003  4583648922
5      Albania  1999  3414760915
6      Albania  2000  3632043908
7      Albania  2001  4060758804
8      Albania  2002  4435078648
9      Albania  2003  5746945913


text:
Q: Why does the error of this command not end in the given file? ls -yz 2>&1 >> command.log This page (http://tldp.org/LDP/abs/html/io-redirection.html) explains (towards the end) why this command:
ls -yz 2>&1 >> command.log
does not output the errors into the command.log file.
However, it still isn't clear for me. If 2>&1 is redirecting stderr to stdout then doesn't >> just take the results of stdout and append them to command.log?

A: First of all, note that >log is a short-hand for 1>log.
The N>M syntax translates to pointer reassignments.
Let's call the pointer to standard output fd1, and the pointer to standard error fd2. That is:

*

*fd1 is a pointer to stdout

*fd2 is a pointer to stderr
When you execute cmd 2>&1 >log, it changes the pointers like this:

*

*make fd2 point to what fd1 points to, which is stdout

*make fd1 point to a file

*=> as a result, fd2 points to stdout and fd1 points to a file

When you execute cmd >log 2>&1, it changes the pointers like this:

*

*make fd1 point to a file

*make fd2 point to what fd1 points to, which is the file

*=> as a result, both fd1 and fd2 point to the same file

That is, based on the ordering of the pointer reassignments, the outcome will be different. In one case both pointers will be pointing at the same thing, or they will be pointing at different things.
Instead of using ls -yz as the example command cmd, I find a more suitable example to explain this is ls yes nonexistent, where yes is a file that exists, and nonexistent is a file that doesn't. With this example, there will be something printed on both stdout and stderr, and by playing with the ordering of N>M, you can observe more clearly where each ended up. (With ls -yz, there is only stderr, while stdout is empty.)

A: With redirections, order matters.  Do it the other way around.
ls -yz >>command.log 2>&1

Redirections work by "copying file descriptors".  If you try redirecting stderr first (before redirecting stdout), then stderr will be sent to where stdout is currently going, which is the terminal.  When you later redirect stdout to your file, this does not go back to redirect stderr once more.

A: By default both stdout & stderr are directed to the terminal.  In the command in your question, 2>&1 tells shell to send stderr to the same place as stdout. It's like a no-op because stdout at that point is still going to the terminal, same place as stderr.  >> command.log gets parsed after that and ends up sending only stdout to that file.  The order matters, as @Fred rightly says.
Shorter way to do this is:
ls -yz &>> command.log


text:
Q: Importing AccessDB and Oracle directly into MongoDB I am receiving .dmp and .mdb files from a customer & need to get that data into MongoDB.
Is there any way to straight import these file types into Mongo?
The goal is to programmatically ingest these into mongo in any way I can. The only rule is that customer will not change their method of data delivery, meaning I'm stuck with the .dmp and .mdb files as a source.
Any assistance would be greatly appreciated.

A: Here are a few options/ideas:

*

*Convert mdb to csv, then use mongoimport --type csv to import into MongoDB.

*Use an ETL tool, e.g. Pentaho, Informatica, etc. This will give you much more flexibility for doing any necessary transformation/conversion of data.

*Write a custom ETL tool, using libraries that know how to read mdb and dmp files.

You don't mention how you plan to use this data, how many tables are in the database, and how normalized the tables are. Depending on the specifics of your use case, it's very possible that loading the data from Access "as is" will not be a good choice since normalized schemas are not a good fit for MongoDB and MongoDB does not natively support joins. This is where an ETL tool can help, by extracting the source data and transforming it into an appropriate JSON structure.

A: MongoDB has released ODBC drivers. Go Here MongoDB ODBC Drivers connect MSAccess directly to MongoDB through ODBC. Voila!


text:
Q: What happens when stripe billing cycle anchor is on 31st or leap year? We are setting up stripe to manage monthly billing subscriptions for our site. As per
Stripe Documents
we will be using 'billing cycle anchor' to default to the date when the user subscribed to the service. From the document it states the client will be billed monthly on this date. Eg plan starting on the 15th, will always be billed on the 15th.
The question I have what happens if the monthly plan started on 31st or leap year ie Feb 29th?
How does stripe manage the monthly payment in this instance? ie what date monthly anchor date does it default too?
I am unable to find any information in stripe but if someone let me know the protocol and where stripe has documented it would be much appreciated.

A: If a plan starts/is anchored on the 31st, it will then bill on the last day of the month each month. If a plan starts on leap day, it will bill on the 29th of each the month going forward, and then the 28th next February.
From https://stripe.com/docs/billing/subscriptions/billing-cycle

If a month does not have the anchor day, the subscription will be billed on the last day of the month. For example, a subscription starting on January 31 bills on February 28 (or February 29 in a leap year), then March 31, April 30, and so on.


text:
Q: Why does f[set_]:=AppendTo[set,5] not work when applying f to a set? The following code works
ccc = {};

AppendTo[ccc, 5];
ccc

and gives the output {5}
However, the following code does not work:
ccc={};
cc[emptySet_] := AppendTo[emptySet, 5]
cc[ccc]

Instead giving the error "AppendTo: {} is not a variable with a value, so its value cannot be changed."
Why does the second way not work?

*

*From the error I'm guessing the definition of ccc is being substituted for for ccc, which is not a variable.

*I imagine this is probably me just defining the function incorrectly, with some trivial error (maybe I need a hold or a condition something)

A: To expand upon my comment, in order to pass by reference you can use Hold. So for instance:
In[1]:= foo[Hold[x_], val_] := AppendTo[x, val];

In[5]:= x = {};

In[6]:= foo[Hold@x, 2]

Out[6]= {2}

In[7]:= x

Out[7]= {2}

If you pass a held variable, this has the effect of passing by reference as opposed to by value, so we have access to the variable x rather than the data that x holds.

A: According to AppendTo documentation:

AppendTo[x,elem] is equivalent to x=Append[x,elem].

When you use AppendTo[{}, 1] Mathematica can't evaluate {}=Append[{},1]. The solution is to give the variable's name to AppendTo and it'll figure it out. That's why Mathematica has something like Hold_sth.
The code below will raise error because when you write f[l1], Mathematica will replace variable's name with it's value and that makes the problem:
l1 = {};
f1[l_] := AppendTo[l, 1]
f1[l1]

(*Out: ERROR *)

Solution
You can do it in different ways, one natural way is to say to your function don't replace names with values:
l2 = {};
f2[l_] := AppendTo[l, 1]
SetAttributes[f2, HoldAll];
f2[l2]

(*Out: {1} *)


text:
Q: Does Azure site recovery support vmware vsphere 5.0 Just reading the document here
https://learn.microsoft.com/en-us/azure/site-recovery/site-recovery-vmware-to-azure
It does not mention support for vsphere 5.0, does ASR support vsphere 5.0 ?

A: The supported versions are listed in the documentation. Based on the information below taken from that page then vSphere 5.0 is not supported.

You need one or more vMware vSphere ESX/ESXi hypervisors managing your VMware virtual machines, running ESX/ESXi version 6.0, 5.5 or 5.1 with the latest updates.


text:
Q: Scaling Kafka Connect to handle 10K S3 buckets I want to load data from various S3 buckets (more than 10,000 buckets and each file is around 20-50MB) into Apache Kafka. The list of buckets is dynamic - buckets are added and removed at runtime. Ideally, each bucket configuration should have its own polling interval (how often to scan for new files - at-least 60 seconds, but might be much more) and priority (number of concurrent files being processed).
Note that setting up notifications from each of the S3 buckets to SQS/SNS/Lambda is not an option due to various IT policies in the organizations of each of the bucket owners.
Kafka Connect seems to be most commonly used tool for such tasks, and its pluggable architecture will make it easier to add new sources in the future, so it fits well. Configuring each S3 bucket as its own connector will let me set a different number of tasks (which maps to priorities) and polling interval for each one. And building a Java custom Kafka Connect source task for my expected file format sounds reasonable.
However, the Kafka Connect code indicates that each running task is assigned its own thread for the lifetime of the task. So if I have 10K buckets, each configured with its own connector and with a single task, I will have 10K threads running in my Kafka Connect distributed worker pool. That's a lot of threads that are mostly just sleep()-ing.
What is the correct approach to scaling the number of tasks/connectors in Kafka Connect?

A: Kafka Connect is distributed framework which could work as stand-alone mode or distributed,  as distributed framework you are creating cluster of kafka connect from several commodity servers each one hosts kafka connect instance and can execute connector's tasks , if you need more power you can add more servers hosting connect instances ,
Reading the S3 Source Connector documents I did not find a way to "whitelist" / "regex" to get it read from multiple buckets...


text:
Q: How can I do a line break (line continuation) in a .KV file? Simple question that must have a simple answer.
I have a long line of code that determines the background color of a spinner in Kivy. I simply want to line break and continue below. I have tried wrapping it in parentheses and using backslashes but it still doesn't recognise the continuation.
Spinner
    background_color: (root.nws if self.text == 'News' else root.brk if self.text == "Breaking" else root.spt if self.text == "Sports" else root.wth if self.text == "Weather" else root.ctc)

Any break I attempt returns the error "Invalid property name"

A: Solution:
background_color:
    root.nws if self.text == 'News' else root.brk if self.text == "Breaking" else root.spt if \
    self.text == "Sports" else root.wth if self.text == "Weather" else root.ctc

My mistake was with the indentation, and not breaking immediately after "background_color:"
Thank you, Ronald


text:
Q: Keybd_event underscore provide wrong output I had create a little program that simulate keyboard event that I used for filled data in Oracle but when I use keybd_event for introduce the character underscore, the output is wrong
If _ is not the last character, when the program simulate the next character add automatically the character -
Example
I need to tape 09_80
For underscore I use combination of VK_RSHIFT with VK_OEM_MINUS
the output is 09_-80
Could someone help me?
I had try also with InputSimulator but it run properly just with Windows 8
Here below some lines of codes from my program,
Thanks in advance
Best regards
//KEYBOARD ACTIONS
    [DllImport("user32.dll", SetLastError = true)]
    public static extern void keybd_event(int bVk, int bScan, int dwFlags, int dwExtraInfo);

    [DllImport("user32.dll")]
    public static extern int MapVirtualKey(int uCode, int uMapType);

    [DllImport("user32.dll", CharSet = CharSet.Unicode)]
    public static extern short VkKeyScan(char ch);

    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    public static extern string SendMessage(IntPtr hWnd, int msg, string wParam, IntPtr lParam);

    public const int KEYEVENTF_EXTENDEDKEY = 0x0001;

    public const int KEYEVENTF_KEYUP = 0x0002;

//SEND CHAR
    public static void SendChar(char c)
    {
        if (bw.CancellationPending)
        {
            return;
        }
        if(c=='_')
        {

            keysPress(VK_RSHIFT,VK_OEM_MINUS)
        }

        int vk = VkKeyScan(c);
        int sc = MapVirtualKey(vk, 0);
        PressKeyDn(vk, sc);
        ReleaseKeyUp(vk, sc);

    }

    //SEND STRING
    public static void SendString(string s)
    {

            foreach (char c in s)
            {
                SendChar(c);
            }

    }

    //PRESS KEY DOWN
    public static void PressKeyDn(int VK_Code, int SC_Code)
    {
        keybd_event(VK_Code, SC_Code, 0, 0);
    }

    //RELEASE KEY UP
    public static void ReleaseKeyUp(int VK_Code, int SC_Code)
    {
        keybd_event(VK_Code, SC_Code, KEYEVENTF_KEYUP, 0);
    }

    //Press Special Key
    public static void keyPress(int VK_key)
    {
        if (bw.CancellationPending)
        {
            return;
        }
        int sc = MapVirtualKey(VK_key, 0);
        PressKeyDn(VK_key, sc);
        ReleaseKeyUp(VK_key, sc);

    }

    //Press Special Key Combination 2 keys
    public static void keysPress(int VK_Key1,int VK_Key2)
    {
        if (bw.CancellationPending)
        {
            return;
        }
        int sc1 = MapVirtualKey(VK_Key1, 0);
        int sc2 = MapVirtualKey(VK_Key2, 0);
        PressKeyDn(VK_Key1, sc1);
        PressKeyDn(VK_Key2, sc2);
        ReleaseKeyUp(VK_Key2, sc2);
        ReleaseKeyUp(VK_Key1, sc1);

    }

    //Press Special Key Combination 3 keys
    public static void keysPress(int VK_Key1, int VK_Key2,int VK_Key3)
    {
        if (bw.CancellationPending)
        {
            return;
        }
        int sc1 = MapVirtualKey(VK_Key1, 0);
        int sc2 = MapVirtualKey(VK_Key2, 0);
        int sc3 = MapVirtualKey(VK_Key3, 0);
        PressKeyDn(VK_Key1, sc1);
        PressKeyDn(VK_Key2, sc2);
        PressKeyDn(VK_Key3, sc3);
        ReleaseKeyUp(VK_Key3, sc3);
        ReleaseKeyUp(VK_Key2, sc2);
        ReleaseKeyUp(VK_Key1, sc1);
    }

A: OK, after some test I had found where is the problem and I had fixed it.
_ (underscore) means a continuation of a statement on a second line, for this reason the next char taped start with -.
I had fixed this problem excluding the next char from the method in this way.
public static void SendChar(char c)
    {
        bool und = false;
        if (c == '_')
        {
            und = true;
        }
        int vk = BMDLCommands.VkKeyScan(c);
        int sc = BMDLCommands.MapVirtualKey(vk, 0);
        if(und)
        {
            keysPress(VK_SHIFT, VK_OEM_MINUS);
            MethodInvoker met = delegate
            {
                keyPress(vk);
            };
        }
        else
        {
            BMDLCommands.PressKeyDn(vk, sc);
            BMDLCommands.ReleaseKeyUp(vk, sc);
        }
    }

now the output is totally correct.
Thanks a lot for the help


text:
Q: Bad 3d performance of intel ironlake I'm using ubuntu 13.04 and got VERY bad 3d performance with intel ironlake comparing with a windows installation.
Is there any way I can improve this?
I already tried various paramaters of the i915 kernel module, but that didn't help much...
SNA is already enabled.

A: Add the following option in grub file
i915.semaphores=1

Then
 sudo update-grub

Mine is
 GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.lvds_downclock=1 drm.vblankoffdelay=1  i915.semaphores=1"

Try adding this to /etc/environment
 CLUTTER_PAINT=disable-clipped-redraws:disable-culling

[RESOLVED] Poor performance on Ironlake compared to old Intel GPU
Intel Ironlake OpenGL Performance On Mesa 9.1

A: Download and install the official graphics drivers for all intel processors. I had some minor problems with some games but this solved that issue.
https://01.org/linuxgraphics/
These drivers are given by Intel Open Source Technology Center and are always updated. Don't forget to add their source in your source list, to always get the updated drivers.


text:
Q: Continued Issues with NPM Install I've been at this for over an hour and all I have managed to conclude is that I need help.
I'm on a new computer where I haven't been doing SharePoint Framework development, but now a bug has come up with one of the web parts and I need to get back at it.  I tried to do an npm install of my cloned code when I started getting a series of failures/errors.
npm ERR! code 1
npm ERR! path C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe C:\Users\ls2527\OneDrive - Stowers Institute for Medical Research\Desktop\helixpublicationsv2\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli   'C:\\Users\\ls2527\\OneDrive - SIMR\\Desktop\\helixpublicationsv2\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@18.14.2 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:207:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:207:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python C:\Python311\python.EXE
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: C:\Python311\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
npm ERR! gyp ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:419:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! gyp ERR! System Windows_NT 10.0.22621
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ls2527\\OneDrive - SIMR\\Desktop\\helixpublicationsv2\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Users\ls2527\OneDrive - SIMR\Desktop\helixpublicationsv2\node_modules\node-sass
npm ERR! gyp ERR! node -v v18.14.2
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ls2527\AppData\Local\npm-cache\_logs\2023-03-03T22_36_29_981Z-debug-0.log

I'm not a full-time dev and I have gone months without doing any SPFx coding, clearly, so please be gentle.  Thanks in advance for any help that you can provide in getting my dev environment back up and running.


text:
Q: How to use a single QLineEdit multiple times in qt for editing a different label each time? I am new to qt. I want to edit 10 labels based on the 10 given inputs from a single QLineEdit, one after the other.
Initially, when I enter some text in the line-edit, label1 should be edited as given text. Similarly, the second time when I enter some text, only label2 should be edited as given text and so on.
I have tried the following:
void MainWindow::on_lineEdit_returnPressed() {
int change=0;
QString input1,input2,input3;
switch(change) {
case 0:  input1 = ui->lineEdit->text();
         ui->label_11->setText(input1);
         change=1;
         break;
case  1: input2 = ui->lineEdit->text();
         ui->label_12->setText(input2);
         change=2;
         break;
case  2: input3 = ui->lineEdit->text();
         ui->label_13->setText(input3);
         change=3;
         break; }

}
Here, every time i enter some input through the QLineEdit, only label_11 is getting updated.
My question remains: How can I use a single QLineEdit multiple times to edit different labels each time?

A: Your variable "change" is local in function. It is turned to 0 every time slot engages. You should make this variable a class member to store it's value.

A: you should move "change" variable to mainwindow.h and make it global variable  instate of local variable
mainwindow.h
public:
    int change ;

mainwindow.cpp
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
    ...
    change = 0;
}

by this changes, the amount of variable will be save in every call in    on_lineEdit_returnPressed


text:
Q: Thumbnail close button is not working in Javascript I am trying to upload multiple images using a form. Selecting multiple images, all the image Thumbnails are displayed with close icon. If I click the close icon, the Thumbnail disappears but the number of selected images did not decreases.
Suppose, I select 5 images, 5 image Thumbnails are displayed with a close icon. When I click the close icon, 4 Thumbnails are displayed but the number of selected images still remains 5.
I have submitted my script and HTML code below.
thank you all...
HTML

          Select Images
          <input name="image_mul[]" type="file" class="form-control upload__inputfile" id="" multiple accept="image/*">

Javascript


text:
Q: A way to change the colors of the NetLogo interface controls or the plot border? I'm trying to adjust the colors of the NetLogo interface for images which will go into a book. The light purple or aqua colors of the controls and the beige-ish border of the plot are not ideal, as they will be grey in black and white and make the text harder to read. I've checked the NetLogo documentation for some way to edit these, and I can't find anything about this.
Is there any way to change the color on these?


text:
Q: Deployment issue after setting GOOGLE_APPLICATION_CREDENTIALS=[PATH] My app engine application deployed fine before setting this variable. Now when I deploy the application the build is looking for this local file. Can i set this as a relative path or can I remove this variable and use new logger({ projectId, relative/path/to/json }) in my logger utils?
const {Logging} = require('@google-cloud/logging');

export const gCloudLogging = new Logging({ ... make this change here });
export const logName = 'API';
export const log = gCloudLogging.log(logName);
export const resource = {
    "type": "global",
    "displayName": "...",
    "description": "..."
};

export const severity = {
    DEFAULT: 'DEFAULT', //(0) The log entry has no assigned severity level.
    DEBUG: 'DEBUG', //(100) Debug or trace information.
    INFO: 'INFO', //(200) Routine information, such as ongoing status or performance.
    NOTICE: 'NOTICE', //(300) Normal but significant events, such as start up, shut down, or a configuration change.
    WARNING: 'WARNING', //(400) Warning events might cause problems.
    ERROR: 'ERROR', //(500) Error events are likely to cause problems.
    CRITICAL: 'CRITICAL', //(600) Critical events cause more severe problems or outages.
    ALERT: 'ALERT', //(700) A person must take an action immediately.
    EMERGENCY: 'EMERGENCY', //(800) One or more systems are unusable.
};

export const writeLog = (severity: string, text: string): void => {
    const metaData = {
        resource,
        severity
    };
    const entry = log.entry(metaData, text);
    log.write(entry);
}

A: You can remove the environment variable from your App Engine deployment. As you can see in this documentation Google Client libraries support Application Default Credentials (ADC).
This means that the libraries will attempt to find credentials for you automatically. The Client libraries can then use the environment variable to find the service account to be used on local environment and automatically use the App Engine Default Service Account when deployed.


text:
Q: Express-generator is not working after installing globally I install express generator globally by running
npm install express-generator -g

after successful installation, I tried to test it by running
express -h

I got an error saying
Cannot find module 'commander' Require stack: - /usr/lib/nodejs/express-generator/bin/express

See a screenshot:

A: Just do npm i
 -g commander to install commander


text:
Q: Instance variables in python, affected by the values of another instance class State:
'defines the state of the class'

_state = []

"""pawn = 1     rook = 2    knight = 3    bishop = 4    queen = 5    king = 6    none = 7    whiteSq = 0    blackSq = 1    whiteCol = 0    blackCol = 1"""

def __init__( self, value ):
    'constructor call with value 0 to load intial pos, and with 1 to load blank board'

    if(value == 1):
        for i in range(8):
            self._state.append([])
            for j in range(8):
                self._state[i].append([])
                self._state[i][j].append( (i+j)%2 , 7 , 7 )

    elif(value == 0):

        for i in range(8):
            self._state.append([])

            if(i==0):
                self._state[i].append( [ 0 , 1 , 2] )
                self._state[i].append( [ 1 , 1 , 3] )
                self._state[i].append( [ 0 , 1 , 4] )
                self._state[i].append( [ 1 , 1 , 5] )
                self._state[i].append( [ 0 , 1 , 6] )
                self._state[i].append( [ 1 , 1 , 4] )
                self._state[i].append( [ 0 , 1 , 3] )
                self._state[i].append( [ 1 , 1 , 2] )

            elif(i==1):
                for j in range(8):
                    self._state[i].append( [(i+j)%2 , 1 , 1] )

            elif(i==6):
                for j in range(8):
                    self._state[i].append( [(i+j)%2 , 0 , 1] )

            elif(i==7):
                self._state[i].append( [ 1 , 0 , 2] )
                self._state[i].append( [ 0 , 0 , 3] )
                self._state[i].append( [ 1 , 0 , 4] )
                self._state[i].append( [ 0 , 0 , 5] )
                self._state[i].append( [ 1 , 0 , 6] )
                self._state[i].append( [ 0 , 0 , 4] )
                self._state[i].append( [ 1 , 0 , 3] )
                self._state[i].append( [ 0 , 0 , 2] )

            else:
                for j in range(8):
                    self._state[i].append( [(i+j)%2 , 7 , 7] )

def printState(self):
    for i in range(8):
        print( self._state[i] )

I cant understand this output
c=State(0);c.printState()
[[0, 1, 2], [1, 1, 3], [0, 1, 4], [1, 1, 5], [0, 1, 6], [1, 1, 4], [0, 1, 3], [1, 1, 2]]
[[1, 1, 1], [0, 1, 1], [1, 1, 1], [0, 1, 1], [1, 1, 1], [0, 1, 1], [1, 1, 1], [0, 1, 1]]
[[0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7]]
[[1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7]]
[[0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7]]
[[1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7]]
[[0, 0, 1], [1, 0, 1], [0, 0, 1], [1, 0, 1], [0, 0, 1], [1, 0, 1], [0, 0, 1], [1, 0, 1]]
[[1, 0, 2], [0, 0, 3], [1, 0, 4], [0, 0, 5], [1, 0, 6], [0, 0, 4], [1, 0, 3], [0, 0, 2]]

>>> a=State(0);a.printState()

[[0, 1, 2], [1, 1, 3], [0, 1, 4], [1, 1, 5], [0, 1, 6], [1, 1, 4], [0, 1, 3], [1, 1, 2], [0, 1, 2], [1, 1, 3], [0, 1, 4], [1, 1, 5], [0, 1, 6], [1, 1, 4], [0, 1, 3], [1, 1, 2]]
[[1, 1, 1], [0, 1, 1], [1, 1, 1], [0, 1, 1], [1, 1, 1], [0, 1, 1], [1, 1, 1], [0, 1, 1], [1, 1, 1], [0, 1, 1], [1, 1, 1], [0, 1, 1], [1, 1, 1], [0, 1, 1], [1, 1, 1], [0, 1, 1]]
[[0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7]]
[[1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7]]
[[0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7]]
[[1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7], [1, 7, 7], [0, 7, 7]]
[[0, 0, 1], [1, 0, 1], [0, 0, 1], [1, 0, 1], [0, 0, 1], [1, 0, 1], [0, 0, 1], [1, 0, 1], [0, 0, 1], [1, 0, 1], [0, 0, 1], [1, 0, 1], [0, 0, 1], [1, 0, 1], [0, 0, 1], [1, 0, 1]]
[[1, 0, 2], [0, 0, 3], [1, 0, 4], [0, 0, 5], [1, 0, 6], [0, 0, 4], [1, 0, 3], [0, 0, 2], [1, 0, 2], [0, 0, 3], [1, 0, 4], [0, 0, 5], [1, 0, 6], [0, 0, 4], [1, 0, 3], [0, 0, 2]]

Doesn't a=State(0) create a new instance of the class ?
If so why is the result so !
Isn't _state a data member of the class which would be different for each instance of the class?
What am I doing wrong !

A: Read some documentation, and figured it out.
Defining any variable under the class definition will make it a 'static data member', a class variable instead of an instance variable. One has to define all instance variables in the constructor!
class Stae:

def __init__( self, value ):
        'constructor call with value 0 to load intial pos, and with 1 to load blank board'
        self._state = []


text:
Q: Migrate entity framework core db first sql server to oracle I have a .net core project where i am using entity framework db first connecting to sql server which is working fine, now i have similar set of tables in oracle can i just run the project by changing connection string and provider to oracle? Or any major rework is needed to make this work?

A: You need to regenerate the DbContext mappings using reverse engineering


text:
Q: Unstaged changes show file as deleted even though it exists A file in my repository causes me quite a headache. git status shows it under "Changes not staged for commit" as "deleted" and it also shows the exact same file under "Untracked files"! The file exists quite definitely on my disk and also on the remote repository. If I delete the file, the entry in "Untracked files" disappears but the other one stays.
Now for my questions: How does this make any sense? And how do I fix it?
$ git checkout -- .

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add/rm ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)

    deleted:    solution02/exercise02.txt

Untracked files:
  (use "git add ..." to include in what will be committed)

    solution02/exercise02.txt

no changes added to commit (use "git add" and/or "git commit -a")

$ git status --short
 D "solution02/exercise02.txt "
?? solution02/exercise02.txt

$ rm solution02/exercise02.txt

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add/rm ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)

    deleted:    solution02/exercise02.txt

no changes added to commit (use "git add" and/or "git commit -a")

$ git status --short
 D "solution02/exercise02.txt "

Just to clarify: The first git status is the one which does not make any sense to me, because it lists the file as "deleted" under "Changes not staged for commit". But the file is not deleted. It exists.

A: This happens when the file was subtly renamed, i. e. When is name on disk doesn't match the name in the Git repository, even thought both names visually match. For example :

*

*If the name contains non ascii characters (accented letters), there can be several encodings for the same character. There were known issues with old versions of Git under Mac OS X due to UTF-8 normalization for example.

*There may be whitespace-only changes (e. g. a trailing space) in one of the names. git status --short will display more details about the file name (double quotes around the name if needed, ...) and may help here.
A solution is to rename the file back to the Git name. Doing an exact cut and paste of the "deleted" name may help.
EDIT: after your update in the actual output of commands, it turns out it's the second option: there's a trailing whitespace after "exercise02.txt " in the name of the file tracked by Git.

A: If you deleted the file manually it will show as untracked file in git status. But if you deleted the file using git rm filename it will be staged for commit automatically and when you run git status after this it will show as file deleted. So to summarize the below 2 commands
  rm filename
  git add filename

is equivalent to one line command
git rm filename
commit your changes  before you checkout to any other branch since it will show as files changed unless you commit changes even if you checkout to a different branch


text:
Q: Could not Create "Run Configuration" for a Javascript Project Installed Javascript eclipse (Indigo). Installed Node.js and protractor. Have created a JavaScript project. Added sample.js file. Tried to create a Run configuration. But could not find "Node Js Application" configuration in "Run configurations" tab. How to get the Node js configuration in the list.
tried installing javascript plugins from "Help->Install new software" and from market
Actual Result:
Getting below list of configurations in "Run configuration" dialog.
HTTP Preview,
Java Applet,
Java Application,
XSL
Expected Result:
Require other run configurations like:
Node.js application

A: Installing "eclipse-javascript-oxygen-3-win32" on my windows 7 32 bit.
It fixed the issue.


text:
Q: Asterisk1.6 no such command originate I installed Asteisk1.6
I tried to use "originate" and I got the no such command error.
I typed "core show help" then no have "origiante" command in list
How can I solve this? or I missing something at the config.
Please tell me.
Thanks.

A: In the Asterisk console, type "manager show commands". You should see it in there. Also, try using "Originate" instead of "originate". It is case sensitive.

A: In this thread, within the comments, a fellow says that Originate wasn't added until 1.6.2.
How to Dial to Originate a Call from Within the Dialplan?


text:
Q: Javascript loop in Array method When I have objects in Array like
    var bookIndex =  [{
      id: '1',
      title: 'First title',
      description: 'This is my first title'
    }, {
      id: '2',
      title: 'Second title',
      description: 'This is my second title'
    }];

then loop through array using for()
    function getBook(bookId){
      for (var i = 0; i < bookIndex.length; i++) {
        if (bookIndex[i].id === bookId) {
          return bookIndex[i];
        }
       }
       return undefined;
     };

I wonder how to use other loop method, to get same result. Ex. forEach.
I try to use something like this but it couldn't get return object I want.
    function getBook(bookId) {
      bookIndex.forEach(function () {
        if (bookId === bookIndex.id) {
          return bookId;
        }
        return undefined;
      });
    };

A: You'd use .find():
function getBook(bookId) {
  return bookIndex.find(function(book) { return book.id === bookId; });
}

The callback to .find() should return true when the criteria are satisfied. When that happens, .find() returns that element of the array. If no elements match, it returns undefined.
The .forEach() function is useful, but it really is for situations when you actually do want to perform some operation on each element of the array.

A: You could use Array#some()

The some() method tests whether some element in the array passes the test implemented by the provided function.

function getBook(bookId) {  // returns true or false if the book exists
    return bookIndex.some(function (book) {
        return bookId === book.id;
    });
};

For returning the book object, then you might use
function getBook(bookId) {  // returns the book with the index
    var book;
    bookIndex.some(function (b) {
        if (bookId === b.id) {
           book = b;
           return true;
        }
    });
    return book;
};

A: You can use filter and return object with that id.

var bookIndex = [{
   id: '1',
   title: 'First title',
   description: 'This is my first title'
 }, {
   id: '2',
   title: 'Second title',
   description: 'This is my second title'
 }];

 function getBook(bookId) {
    return bookIndex.filter((e) => { return parseInt(e.id) == parseInt(bookId)})[0];
 };

 console.log(getBook(2))

A: i tought you where wondering how could you for loop and then return, and since every one witch answered you didn't used for each i desided to show you a foreach solution, hoping that this is what you had expected
var bookIndex = [
    {
        id: '1',
        title: 'First title',
        description: 'This is my first title'
    }, {
        id: '2',
        title: 'Second title',
        description: 'This is my second title'
    }];
function getBook(bookId) {
    bookIndex.forEach( function (el) {
        if (el.id === bookId) {
          getBook1(el);
        }
    });
}
getBook('2');
function getBook1(el) {
 var element = el;
    console.log(element);
}

In the bookIndex.forEach( function (el)you need to pass an argument to the function (the callback), witch you use for the forEach method. And this was your main mistake. This elment that i have passed called el is basically every element in your array witch isn't undefined or null. And since you can't just return something from the foreach, cause it returns in to the callback, not to the parrent function, in your case function getBook(index), i had to call another functuion in witch i can store the variable


text:
Q: Changes to be done in Android application to put it in Galaxy tab I have to put my Android application in a Galaxy tab. When I installed the app, the resolution of the UI of my application changed. But it's looking good in emulator and other Android 2.2 phones. But in Galaxy tab, the resolution is changed. Please help.

A: The Galaxy Tab has a pixel density of about 170. That isn't all that different from an mdpi device. (However, Android market apparently classifies it as an hdpi device.)
Are you sure that the problem is with the resolution? It's an extra large screen; perhaps that's causing problems?

A: I suggest getting device's (Samsung Galaxy Tab) height-width then optimise your resources according to them. Try to find out whether they lie in hdpi/mdpi or ldpi range
You may be required to use new set of graphics for them.


text:
Q: Replace master with a branch I need to replace the contents of master with the contents of a branch. I can find details on how to do this in Git, but nothing for Mercurial.
Example Q for Git
Replacing master with another branch
My setup is

*

*master

*newbranch

I want the 'master' to be identical to 'newbranch

A: The basic choice you have is "rebase or merge": https://blog.sourcetreeapp.com/2012/08/21/merge-or-rebase/
Here on SO, a helpful Q&A is at:
Make another branch default?
The remainder of this response borrows from that page.
If you want to close the "feature-branch":
$ hg checkout default
$ hg merge feature-branch
$ hg commit
$ hg checkout feature-branch
$ hg commit --close-branch

The simplicity of the revert/commit approach mentioned there also has much to recommend it:
hg revert --all --rev ${1}
hg commit -m "Restoring branch ${1} as default"

where ${1} is (for example) the name of the relevant branch.

A: Doesn't the first approach assume there are no conflicts between the "default" and "feature branch"?  When you desire to replace code, the assumption is that there ARE conflicts, and all should be resolved treating the "feature branch" as authoritative.


text:
Q: Any way to make DataContractJsonSerializer serialize Dictionaries properly? The DataContractJsonSerializer is not able to serialize Dictionaries properly.
Whereas JavaScriptSerializer serializes Dictionaries as {"abc":"xyz","def":42}
for example,
the DataContractJsonSerializer gives [{"Key":"abc","Value":"xyz"},{"Key":"def","Value":42}] instead.
This is really problematic and I want to know how can I serialize Dictionary objects correctly in my WCF service. I am looking for a solution that would require least amount of effort.
ref: http://msdn.microsoft.com/en-us/library/bb412170.aspx
This is the workaround I finally used to serilize dictionaries properly in WCF: http://social.msdn.microsoft.com/forums/en-US/wcf/thread/765f1569-0422-4471-8ec2-1d03b2026771

A: DataContractJsonSerializerSettings has the UseSimpleDictionaryFormat property now and it serializes dictionaries the way you'd expect.

A: Using DataContractJsonSerializerSettings (available since .NET 4.5) can do this for you:
var serializer = new DataContractJsonSerializer(typeOfObj, new DataContractJsonSerializerSettings()
{
    UseSimpleDictionaryFormat = true
});

A: Unfortunately this appears to be by-design, according to the section "Collections, Dictionaries, and Arrays" at http://msdn.microsoft.com/en-us/library/bb412170.aspx

All collections, dictionaries, and arrays are represented in JSON as arrays.

A: Although this will in most cases cause a major rewrite and thus not be feasible you can let your WCF service interface accept and return Stream in which case you can take full control of serialization. This way you can use JavaScriptSerializer, JSON.NET or ServiceStack.JSON to perform the actual serialization and these serializers actually deals with a dictionaries in a more sensible way.


text:
Q: What can make unmounted volumes SHA512 hashes differ while mounted volumes content SHA512 hashes are identical? I am trying to configure Raspberry Pi OS to be read-only.
In theory, both / and /boot are read-only. That being said, I am experiencing a strange discrepancy and can't figure out what is happening.
I create clones of /boot using dd before and after discrepancy occurs to find what changed.
Using diff, apparently nothing has… puzzled.
$ sudo openssl dgst -sha512 /Users/sunknudsen/Desktop/boot-clean.img
SHA512(/Users/sunknudsen/Desktop/boot-clean.img)= ce87ce4b05149a85d286b62528776c010ddae4d25c5eaa1e79275be118125d66396645587f084073cbf87e36d6627f8d96ad02688a20ede898152df95fa88686

$ sudo openssl dgst -sha512 /Users/sunknudsen/Desktop/boot-changed.img
SHA512(/Users/sunknudsen/Desktop/boot-changed.img)= 62e9727727c2307ef452a8f029617c7e7369c8b9c797027d8088a53ed0ada988dbfc128b389d35a729cc8fb00d4214fa4c2f1decd285e5e0f33553a8b63a29da

$ diff /Users/sunknudsen/Desktop/boot-clean.img  /Users/sunknudsen/Desktop/boot-changed.img
Binary files /Users/sunknudsen/Desktop/boot-clean.img and /Users/sunknudsen/Desktop/boot-changed.img differ

$ hdiutil attach -nomount /Users/sunknudsen/Desktop/boot-clean.img

$ mount -o ro -t msdos /dev/disk2 ~/Desktop/boot-clean

$ sudo openssl dgst -sha512 /Users/sunknudsen/Desktop/boot-clean
SHA512(/Users/sunknudsen/Desktop/boot-clean)= 27d3b8c676879d944e148384e78dc6b77fc2d5a67c195bdbedf8157a57ff6e7f317e53e10fe2e030d154d8102f55710ec28a701582da04246edc541e600e12a3

$ hdiutil attach -nomount /Users/sunknudsen/Desktop/boot-changed.img

$ mount -o ro -t msdos /dev/disk3 ~/Desktop/boot-changed

$ SHA512(/Users/sunknudsen/Desktop/boot-changed)= 27d3b8c676879d944e148384e78dc6b77fc2d5a67c195bdbedf8157a57ff6e7f317e53e10fe2e030d154d8102f55710ec28a701582da04246edc541e600e12a3

$ diff --brief --recursive /Users/sunknudsen/Desktop/boot-clean /Users/sunknudsen/Desktop/boot-changed


text:
Q: Remove oem.inf files corresponding to hardware id I'm installing my driver using dpinst.exe. But before installing my driver I wish to delete all the oem files from inf directory corresponding to my hardware ID.
I want to do this programatically. Please suggest me a way to do this.
**Update :**

I want to do this without device connected as I may pre-install the driver before connecting the device. My device is PNP device.

A: *

*Use SetupDiEnumDeviceInfo and SetupDiGetDeviceRegistryProperty to match your hardware ID

*Use SetupDiOpenDevRegKey and RegQueryValueEx to read the corresponding InfPath

*Call SetupUninstallOEMInf

A: PhilMY has already posted an excellent answer, which is still relevant. However, it is more than ten years old now, so I wanted to update it with more recent/recommended APIs:

*

*Use SetupDiEnumDeviceInfo() and SetupDiGetDeviceRegistryProperty() to match your hardware ID

*To get the OEM INF path, SetupDiGetDriverInfoDetail() can be used instead of reading the registry directly

*Call DiUninstallDriver() on the resulting INF path (Microsoft recommends using it instead of SetupUninstallOEMInf(). In addition, it returns the needReboot flag, which may be useful in some scenarios.)

#2 is a little tricky as it requires SP_DRVINFO_DATA on input. To acquire it, one typically needs to call SetupDiBuildDriverInfoList() and SetupDiEnumDriverInfo() to iterate through all installed drivers for a particular device (use SPDIT_COMPATDRIVER flag to enumerate 3rd-party drivers).
It has a significant advantage in scenarios when multiple drivers are suitable for the given device, and this approach allows one to choose exactly which driver to uninstall.


text:
Q: IOS 10,What's the current syntax for JSQMessagesAvatarImageFactory.avatarImage(Unknow parameters) i am following an IOS chat tutorial, but the tutorial is a little outdated,
in the tutorial the instructor's syntax was:
JSQMessagesAvatarImageFactory.avatarImageWithImage(UIImage(named: "pictureNameWithoutExtention"), diameter: 30)

but this method has been replaced to:
JSQMessagesAvatarImageFactory.avatarImage(thisIsSomeCodeBlock<#T##JSQMessagesAvatarImageFactory#>EndSomecodeBlock)

i tried below codes and some others, none of them worked:
JSQMessagesAvatarImageFactory.avatarImage(UIImage(named: "pictureNameWithoutExtention"), diameter: 30)

JSQMessagesAvatarImageFactory.avatarImage(with image: UIImage(named:"pictureNameWithoutExtention"), diameter: 30)

what is the current syntax for this method? what parameters does it take?
also when i command+click i get this documentation but still don't understand:
/**
 *  Creates and returns a `JSQMessagesAvatarImage` object with the specified image that is
 *  cropped to a circle of the given diameter and used for the `avatarImage` and `avatarPlaceholderImage` properties
 *  of the returned `JSQMessagesAvatarImage` object. This image is then copied and has a transparent black mask applied to it,
 *  which is used for the `avatarHighlightedImage` property of the returned `JSQMessagesAvatarImage` object.
 *
 *  @param image    An image object that represents an avatar image. This value must not be `nil`.
 *
 *  @return An initialized `JSQMessagesAvatarImage` object.
 */
open func avatarImage(with image: UIImage) -> JSQMessagesAvatarImage

i googled a lot about this, none of the documentation has Example or Demonstration about this method, i mean the documentations are not even written in plain english......why does everyone else seems to have no problem understand them, are there any tricks?

A: The best example to look at is in the "JSQMessagesViewContoller" it is located in the project
https://github.com/jessesquires/JSQMessagesViewController/tree/develop/SwiftExample
It has been recently updated to the Swift3. If you look at the demoConversation it is implimented in a few ways.
let AvatarLeonard = JSQMessagesAvatarImageFactory().avatarImage(withUserInitials: "DL", backgroundColor: UIColor.jsq_messageBubbleGreen(), textColor: UIColor.white, font: UIFont.systemFont(ofSize: 12))

This is how you would make an avatar for someone that does not have a picture. This creates a circle with initials in it and makes the image not nil.
// Create avatar with Placeholder Image
let AvatarJobs = JSQMessagesAvatarImageFactory().avatarImage(withPlaceholder: UIImage(named:"demo_avatar_jobs")!)

As to your question on why the documentation is so difficult to understand is that is difficult to show you everything that is possible with the library especially not knowing everyone's background or experience. So Documentation try's to outline everything that could be possible and 90% of the things you will not need it is a feature that someone added for a certain use case.
Also if a perimeter is optional then it does not have to be passed in the function. So it can become difficult to understand what you absolutely need and what can be omitted. This will come with time as you gain more exsperience and understand what is happening.
Now for your question on neither of the methods working that may not have to do with your function. Looking at the chatViewController in the example project has these lines up at the top
collectionView?.collectionViewLayout.incomingAvatarViewSize = CGSize(width: kJSQMessagesCollectionViewAvatarSizeDefault, height:kJSQMessagesCollectionViewAvatarSizeDefault )
collectionView?.collectionViewLayout.outgoingAvatarViewSize = CGSize(width: kJSQMessagesCollectionViewAvatarSizeDefault, height:kJSQMessagesCollectionViewAvatarSizeDefault )

These set the size of the avatar for the CollectionViewLayout. It may seem confusing because you can pass the size of the avatar in the JSQImageFactory method but the collectionViewLayout handles shifting things around based on the size of other components in the view. So by adding these lines the Collection view knows to shif the message bubbles over to make room and make the avatars appear in the correct place.
I hope that I was able to communicate clear enough. If you have more questions don't hesitate to ask.  Good luck.

A: Try using this, seems like the function does not accept radius though.
JSQMessagesAvatarImageFactory.avatarImage(with: UIImage(named:"pictureNameWithoutExtention")!)

p.s.: it might be better if you check unwrap the optional before using the function.


text:
Q: Color of text in Android Studio After update Android studio, the color of text in the following situation changes automatically...
I just cannot find the option in the Setting>Editor>Colors&Fronts.

Does anyone know where to set the text color back to white?
Any response will be helpful!

A: Android Studio have two themes built in, Default and Dracula.
Setting>Editor>Colors & Fonts > Choose Default, and if you want more style you can get at Color Themes.


text:
Q: Grabbing all frames of a base64 video in javascript If I have the base64 of a video file, is there any way I can grab all the frames in javascript without having to play through the entire video or sending the video back to the server?
I am working on a webpage that takes a video, converts it into ascii-art, and plays it. At first, I thought the best way would be to upload the video to the server, decode and convert it there, and then respond with the converted video; however, since I don't compress the output "video" (actually just a huge blob of text) the response is huge and takes a large amount of time to transfer.
I know I can do something like this if I parse the video on the front-end (not sure if this code is missing some things, but it conveys the general idea):
var frames = [];
var context = document.getElementById('canvas').getContext('2d');
var video = document.createElement('video');
video.src = base64Value;

function callback() {
  context.drawImage(video, 0, 0);
  frames.push(grabFrameFromCanvasContext(context));
  if (video.currentTime < video.duration) {
    setTimeout(callback, 50);
  }
}

callWhenVideoStartsPlaying(callback);

But it takes however long the video is to parse. This makes sense for most cases since the browser would be streaming the video from somewhere, but since the source of the video is base64, is there a better way to do this?


text:
Q: Why does CFFile.ServerFile return the folder path when using Amazon S3? I am uploading files to Amazon S3 like so:
<cffile action="upload" accept="image/jpeg, image/pjpeg" destination="s3://accessKeyID:awsSecretKey@bucket/X/Y/sample.jpg" filefield="ImageField" />

The above works fine and the sample.jpg file is in my S3 bucket located as https://bucket.s3.amazonaws.com/X/Y/sample.jpg
In the rest of my code I use CFFILE.ServerFile to get the name of the file uploaded which should just be sample.jpg (I tested it and it is just sample.jpg when upload locally to the server). However when uploading to S3 like in the code above, CFFile.ServerFile returns X/Y/sample.jpg as the name of the file which is wrong.
If I check the contents of CFFILE.ServerFileExt then that returns jpg correctly when uploaded locally or to S3.
Am I missing something?


text:
Q: SQL Query that selects a column in table 1 and uses that to select sum in table 2 I have 2 tables 1 with a list of employees and the group and 1 with the sales of each employee, Table 2 does not have the group number but has a list of employee names. i need to select by group number and display Name results and the total sales by name.
Table 1:
Name|Group
*John|1*
*Mary|2*
*Will|1*
*Jane|2*

Table 2
Name| Sale
*Will|20*
*John|10*
*Mary|10*
*Jane|20*
*John|20*
*Will|20*
*Mary|20*

I need the result to select group 1 and sum results by name, result should look like.
Result Table
Name|Sum(Sale)
*John|30*
*Will|40*

A: This is a pretty basic JOIN and GROUP BY:
select t2.name, sum(t2.sale)
from table2 t2 join
     table1 t1
     on t2.name = t1.name
where t1.group = 1
group by t2.name

A: You can use IN and GROUP BY as follows:
select t2.name, sum(t2.sale)
  from table2 t2
 Where t2.name IN
     (Select t1.name from table1 t1
       where t1.group = 1)
group by t2.name


text:
Q: Cryptkeeper File Lost I screwed up, and I need your help.
I maintained an encrypted folder on my secondary hard drive (created with cryptkeeper) which housed a lot of my personal financial data, official documents, etc. I forgot about the file when I did a clean install of kubuntu, and now I can't access the folder. Is there a way to regain access to it, or am I SOL?


text:
Q: How can I draw colored pixels reading from bitmap file? Put a bitmap file in the same directory of this code. Name this file "a.bmp"
Code =>
#include<GL/glut.h>
#include<stdio.h>
#include<stdlib.h>

typedef struct __attribute__((__packed__)) {
    unsigned short type;
    unsigned long size;
    unsigned short reserved1;
    unsigned short reserved2;
    unsigned long offsetbits;
} BITMAPFILEHEADER1;

typedef struct __attribute__((__packed__)) {
    unsigned long size;
    unsigned long width;
    unsigned long height;
    unsigned short planes;
    unsigned short bitcount;
    unsigned long compression;
    unsigned long sizeimage;
    long xpelspermeter;
    long ypelspermeter;
    unsigned long colorsused;
    unsigned long colorsimportant;
} BITMAPINFOHEADER1;

typedef struct {
    unsigned char blue;
    unsigned char green;
    unsigned char red;
} SINGLE_PIXEL1;

void display()
{
    FILE *fp;
    unsigned char p;
    int x=0,y=0,c=0;
    float r,g,b;

    BITMAPFILEHEADER1 bitmp;
    BITMAPINFOHEADER1 bitm;

    glClearColor(1.0,1.0,1.0,0.0);
    glClear(GL_COLOR_BUFFER_BIT);

    fp = fopen("a.bmp","rb");//Filename is given

    fread(&bitmp,14,1,fp);

    fread(&bitm,40,1,fp);

    gluOrtho2D(0.0,bitm.width,0.0,bitm.height);
    glMatrixMode(GL_PROJECTION);

    glLoadIdentity();
    glViewport(0,0,bitm.width,bitm.height);
    glBegin(GL_POINTS);
    int cnt=0;

    int bi,gi,ri;
    unsigned char tp1,tp2,tp3;
    while(!feof(fp))
    {
        fread(&p,1,1,fp);
        //b = p/255.0;
        tp1=p;
        fread(&p,1,1,fp);
        //g = p/255.0;
        tp2=p;
        fread(&p,1,1,fp);
        //r = p/255.0;
        tp3=p;
        //glColor3f(r,g,b);
        glColor3ub(tp1,tp2,tp3);
        glVertex2i(x++,y);
        if(x == bitm.width)
        {
            x = 0;
            y++;
        }
    }
    glEnd();
    glFlush();
    fclose(fp);
}
int main(int argc, char* argv[])
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_RGB);
    glutInitWindowSize(800,800);
    glutInitWindowPosition(100,150);
    glutCreateWindow("BITMAP");
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}

Put the code in a file named "bit.cpp".
Then compile this "bit.cpp" file:
g++ bit.cpp -o bit -lglut -lGL -lGLU

And run:
./bit

You will see black and white(gray) image in glut window.
How can i draw colored pixels? glColor3ub(tp1,tp2,tp3); this should set color for vertex. Shouldn't it? But it's not drawing colored pixels, why?
How can I get colored image in glut window?
Any answer will be highly appreciated.
Thanks in advance.