text:
Q: Trying to autologin in webpage through VBS Login page

HTML code

Username:<input tabindex="1" type="text" autocapitalize="off" autocorrect="off" style="font-family: sans-serif; font-size: 12px; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255); border: 1px solid rgb(51, 51, 51); margin: 0px; padding: 1px; opacity: 0.99;">

Password:<input tabindex="2" type="password" style="font-family: sans-serif; font-size: 12px; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255); border: 1px solid rgb(51, 51, 51); margin: 0px; padding: 1px; opacity: 0.99;">

<input type="checkbox" style="width: 20px; border-width: 0px; opacity: 0.99;">Remember my login (uses cookie)

This is code for a login page in which the username and password are given but are linked with input tag. That tag also does not have id so I need to go to class "login_screen_mask" and search for the input tag for username and passoword. I'm able to search everything but not able to insert value in that input box. Please help!

A: *

*Set objIE = MyBrowser.document

*For Each ELEMENT In objIE.getElementsByClassName("login_screen_mask")

*If ELEMENT.className = "login_screen_mask" Then

*MsgBox (ELEMENT.innerHTML)

*For Each ELEMENT1 In ELEMENT.all

*If ELEMENT1.tagName = "INPUT" Then

*ELEMENT1.setAttribute //// What value should i put

*MsgBox (ELEMENT1.outerHTML)enter code here


text:
Q: How to install and use additional voices in SpeechSynthesizer()? I need to use male voice in SpeechSynthesizer in addition to default Anna voice. I installed some files from Microsoft, and GetInstalledVoices() method says now I have Microsoft Anna, Microsoft Mary, Microsoft Mike and Sample TTS Voice.
After I'm trying to set voice
speaker.SelectVoice("Microsoft Mike");

my program throws exception: Cannot set voice. No matching voice is installed or the voice was disabled.
What should I exactly install and how to enable Mike's voice? System is Windows7.

A: After trying many suggestions from web found working solution:
 - install Microsoft Speech Platform SDK (x64) v11.0.
 - install Runtime Languages (Version 11) you need.
 - do registry changes from the end of this this thread.
 - install Microsoft Server Speech Platform Runtime (x64) (! - this is what i was missing).
 - and you have to set platform target in build to x64 to use new voices like Helen or ZiraPro

A: You can get a lot of additional voices from Cepstral:
http://www.cepstral.com/en/personal/download
It appears that available voices are the same as CereProc has on offer: https://www.cereproc.com/en/storesapi.
When you download their software you get selected voice registered in Windows, so you can use it with SpeechSynthesizer.

redpajama_set_name: RedPajamaStackExchange


text:
Q: get the term id from the url in views module I have a portfolio view; the portfolio displays all the nodes of the portfolio content type in a grid and, basing on the selected term of the tags above, shows the associated content in images and titles and some description.
I'm adding the view block of the portfolio in the Tags page (taxonomy-term.tpl.php).
How can I get the term from the URL and make the view show only the child terms of that term?

A: Yes, you can: In your block-view's admin page, look at the Advanced section; click to add a new "Content: Has taxonomy term ID" contextual argument. From the section "When the filter value is NOT in the URL," choose "Provide default value "; then, select "Taxonomy term ID from URL."
This should do the trick.


text:
Q: How did this integral inequality come to be? I've seen this result $$ \int\limits_0^\pi e^{-R\sin\theta}d\theta \le \frac{\pi}{R}\left(1-e^{-R}\right) $$
with $R>0$, where the source said to have derived this inequality using Jordan's inequality, which is that for $\theta\in [0,\pi/2]$, $\frac{2}{\pi}\theta\le\sin\theta\le \theta$.
Here are my comments regarding this inequality:

*

*Not so while ago, I derived this inequality, but now I cannot remember how (I probably made an error somewhere at that time, that's why things don't seem to add up now).

*How would you use Jordan's inequality to derive the inequality above?

A: Since
\begin{align}
-\frac{2R}{\pi} x\geq -R\sin  x \geq -Rx
\end{align}
for $x\in [0, \pi/2]$, then we see that
\begin{align}
\int^{\pi/2}_0 e^{-R\sin x}\ dx \leq \int^{\pi/2}_0 e^{-\frac{2R}{\pi} x}\ dx = \frac{\pi}{2R}\left(1-e^{-R} \right).
\end{align}
Do the same type of estimate for $x \in [\pi/2, \pi]$.

A: Jordan's inequality can be obtained by noting the values of the corresponding differentials and the initial values of the functions.
For the second part, note that the integral is same in [0,90] and [90,180].
Split the interval and use the left part of Jordan's Inequality.


text:
Q: How to select text from a multiline textbox with the line breaks in Jquery? <textarea style="height: 300px;"  class="jqueryFindBody" cols="20" rows="2">
1
2
3
</textarea>

In the asp.net textbox above, if I replace its text with its own text, the line breaks get lost
 $('.jqueryFindBody').text($('.jqueryFindBody').text());

I tried using html instead of text, but the line breaks are always lost. How do I preserve the line breaks?

A: How about using .val()? http://api.jquery.com/val
$('.jqueryFindBody').val($('.jqueryFindBody').val());

Here is a demo: http://jsfiddle.net/tXnaj/
Update
If you want to display the value of the textarea element in HTML then you'll need to parse the endline characters into
 tags. You can do this with a simple RegExp:
$('.jqueryFindBody').val().replace(/\r|\n/g, '
');

This finds all the \n and \r characters and replaces then with
 tags.
Here is a demo: http://jsfiddle.net/tXnaj/2/

A: Newlines in text boxes are represented as \n and \r (newline and carriage return)
The topic is also discussed here: jQuery convert line breaks to br (nl2br equivalent)


text:
Q: Warning in PL/SQL after function I wrote a PL/SQL function that checks if a string is actually number or not, and the execution code.
But when I excute the function, I get the follwing warning:
Warning: execution completed with warning
FUNCTION is_number Compiled.
13/1           PLS-00103: Encountered the symbol "BEGIN"

Here is my PL/SQL code with the function:
CREATE OR REPLACE FUNCTION is_number (p_string IN VARCHAR2)
   RETURN INT
IS
   v_new_num NUMBER;
BEGIN
   v_new_num := TO_NUMBER(p_string);
   RETURN 1;
EXCEPTION
WHEN VALUE_ERROR THEN
   RETURN 0;
END is_number;

BEGIN
  dbms_output.put_line(is_number('93'));
END;
/

Normally, the console should return '1', but it doesn't.
Where is the error please?

A: Following this line:
END is_number;

You should add a slash in order to execute the CREATE FUNCTION statement.
Without that, the parser continues to read the following lines as part of that statement, but since you have already ended the function, they are invalid.

A: The only problem is that you executed those two SEPARATE PL/SQL Blocks as a single statement.
Solution: execute them separately (add /)
CREATE OR REPLACE FUNCTION is_number (p_string IN VARCHAR2)
   RETURN INT
IS
   v_new_num NUMBER;
BEGIN
   v_new_num := TO_NUMBER(p_string);
   RETURN 1;
EXCEPTION
WHEN VALUE_ERROR THEN
   RETURN 0;
END is_number;
/

BEGIN
  dbms_output.put_line(is_number('93'));
END;
/

This works perfectly fine:


text:
Q: Cordova OverrideUserAgent preference not working I'm building hybrid mobile apps using cordova and quasar framework.
I used the following user agent to change the default user agent.
<preference name="OverrideUserAgent" value="Mozilla/5.0 Google" />

in config.xml for both ios and android preferences
its working fine for iOS but
not working for android (giving null value in OverrideUserAgent preference in generated code)
cordova-lib@9.0.1
platforms list :
android@8.1.0 and ios@4.5.5
How do i make it work for android ?

A: Have you tried using AppendUserAgent instead?

If set, the value will replace the old UserAgent of webview. It is
helpful to identify the request from app/browser when requesting
remote pages. Use with caution, this may causes compitiable issue with
web servers. For most cases, use AppendUserAgent instead.


text:
Q: Lat / Lng to create a Marker on Google Map V3 I have my Lat and Lng in my database, when I try to combine them to create a Marker on a map, it doesn't work. Attributes data-lat and lng are from my html codes, which represent the real lat and lng from my database.
Lat :10.432548 and Lng : 32.4972830002 .
Really appreciate it if you look at my codes and help me to fix it . Thanks
    var marker;
    var Gmap = new google.maps.Map($('#map_canvas').get(0),mapOptions);
    var lat= $(this).attr('data-lat');
    var lng= $(this).attr('data-lng');
    var newLocation= lat+', '+lng;

    if(lat!=0 || lng!=0){

            if (marker) {
                marker.setPosition(newLocation);
            }else{
                marker = new google.maps.Marker({
                    position: newLocation,
                    map: Gmap
                });
            }

    }

A: Sorry, I just fixed it ....
var newLocation = new google.maps.LatLng(lat,lng);


text:
Q: what's the better deal? 0.32oz for \$23 or 0.21oz for \$14 just want somebody to check if I'm doing this right
my process is to divide cost/weight
23/0.32 = 71.88
and
14/0.21 = 66.67
so the 2nd option is a better deal because I'm spending ~66 for 1 oz rather than ~71 for 1oz
is that correct?

A: It may be easier to compare the amount you get for a certain amount of money, so "one dollar buys three ounces". That way you choose the option where the number comes out larger.
In that case you want to divide the weight you get by the dollars, so weight divided by cost gives you amount per dollar. If you get 0.32 ounces for 23 cents, you get 1.39 ounces per dollar, and if you get 0.21 ounces for 14 cents, you get is 1.5 ounces per dollar, so the 0.21 ounces for 14 cents gives you more return for one dollar.
What you've calculated is what supermarkets usually display, the "unit cost", the cost for one pound, one ounce, one kilogram, one can, one package, etc. In that case you would choose whichever is the lowest price for one unit of the thing.

A: You asked a question that is not mathematical.
I assume that your prices are for buying a quantity of some substance S, which can be bought in two specific quantities at certain prices.
If you require a certain amount of S and want to pay the lowest possible price, you have an optimisation problem. The solution is obvious if you need up to 0.21, 0.32, 0.42, or 0.53 ounces. For larger quantities it is likely that some mix of the two quantities is optimal, say for 10 or 20 ounces. You solve this as an integer linear programming problem.
Alternatively, you might get some value from S, which probably doesn't grow linear. For example, two burgers might be twice as nice for you as one if you like to eat a lot, but 10 are not. Now if you have a group of 6 people, 10 burgers might actually be quite bad because you get arguments who will only get one. 12 burgers may have much more than 20% higher value.
Again you have an optimisation problem that may require considerable effort creating a mathematical model before you can find an optimal answer.
After reading the comments, a third case. Assume you run a restaurant that offers free sachets of mustard (mustard might come in these tiny portions). If the portions are large, people take one sachet. If you use smaller sachets, some percentage of customers take two. To find the best product to pay, it's best to experiment and find how many sachets and therefore how much of your money customers take depending on the size, and then you choose the optimal size.


text:
Q: How to download a file via the Google Drive API? I'm working to download a file via the Google Drive API using the gem google-api-client.
x = Google::Apis::DriveV2
drive = x::DriveService.new
drive.authorization = auth

files = drive.list_files
files.items.each_with_index do |file, index|
    url_to_index = file.export_links.select { |k, v| v if k == 'text/plain' }
    file_content =  open(url_to_index["text/plain"]).read
end

The problem is file_content is returning the Google login screen not the file in text/plain format. It appears that when my Rails app opens the URL it does not have access to the text file.
What's the right way to enable my Rails app to grab the file in the text format?

A: Stated in Download Files

Depending on the type of download you'd like to perform — a file, a Google Document, or a content link — you'll use one of the following URLs:

*

*Download a file — files.get with alt=media file resource

*Download and export a Google Doc — files.export

*Link a user to a file — webContentLink from the file resource

Downloading the file requires the user to have at least read access. Additionally, your app must be authorized with a scope that allows reading of file content.

You may go through the documentation for more information and examples.

A: See the log output: Two factor autentifications need to you permit access from you app to your google drive account.
In log you will see needed info to do this: link and secret_key.
tail -f log/*.log

A: I just realize that mimetype for download is different from the file meta.
Please check this url for available mimetype :  https://developers.google.com/drive/api/v3/integrate-open
for example mimeType : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
'


text:
Q: Calippo, toothpaste and milk .. packing This post was posing the question "The Calippo™ popsicle has a specific shape ... Does this shape have an official name?", and the accepted answer was that it is a Right Conoid which in fact is much resembling.
However,  a conoid is not developable and so cannot be economically made out of a cardboard sheet.
Now, a cardboard cylinder, pinched and sealed at one end, will look like a toothpaste tube, and the
pinched end will  be larger than the mouth diameter (by $\pi /2 $).
That does not fit to the calippo's look,
whose tube is in fact fabricated from a cone (made from a plane circular sector) pinched at one end (and reinforced at the opposite circular rim).
And a related subject is that,  a cylinder with both ends  pinched at  90° relative to each other make up
a tetrahedral "milk carton" (berlingot in French).
In this Mathcurve page  after stating that
"le berlingot est la surface réglée non développable .. ",
referring to a picture of a real tetrahedral milk carton is noted:
"Attention, un berlingot comme ci-dessus fabriqué avec du papier
est une surface développable, fabriquée avec un patron de tétraèdre en arrondissant les arêtes... "
Also refer to the Coin Conic page.
Suppose that the material is inextensible, and that a grid of directrices and orthogonal circles is marked on the cone/cylinder,
then it is clear that upon pinching the directrices will not appear straight.
Since a developable surface implies that it be ruled, then either the ruling lines have moved, or the surface has undergone some deformation.
Therefore the question is:
Can the calippo (and bottom of toothpaste, and milk) package be a ruled developable surface , in case, admitting that the shape of the pinched edge be not exactly linear ?
or is some deformation of the material demanded ?
---- P.S:  -----
Thanks to the answer, with expressive sketch, received by Rahul, complemented with that provided by C.Blatter to the previous post, we can conclude that such a surface is a plausible model.
So, scaling all the dimensions to have the base circle of radius $1$, height $=h$ and length of the pitch $=2c$

we can parametrise the surface as
$$
\eqalign{
  & {\bf q} = \left( {sc,\;0,h} \right) - \left( {\cos \alpha ,\;\sin \alpha ,0} \right) = \left( {sc - \cos \alpha ,\; - \sin \alpha ,h} \right)  \cr
  & {\bf p} = \left( {\cos \alpha ,\;\sin \alpha ,0} \right) + t\,{\bf q} \cr}
$$
where
$$
\left\{ \matrix{
  \alpha  =  - \pi /2\quad  - 1 < s < 1\quad 0 \le t \le 1 \hfill \cr
   - \pi /2 < \alpha  < \pi /2\quad s = 1\quad 0 \le t \le 1 \hfill \cr
  \alpha  = \pi /2\quad  - 1 <  - s < 1\quad 0 \le t \le 1 \hfill \cr
  \pi /2 < \alpha  < 3\pi /2\quad s =  - 1\quad 0 \le t \le 1 \hfill \cr}  \right.
$$
Then we can develop half of the surface as indicated, by putting for the flattened conic part that
$$
q(\alpha )d\beta (\alpha ) = d\alpha \quad \left| \matrix{
  \,q = \left| {\bf q} \right| \hfill \cr
  \,s = 1 \hfill \cr}  \right.
$$

A: The convex hull of a circle and a line segment is developable. I don't know if this is the unique developable surface with the given boundaries.

(Ignore the extra chords drawn in the circle.)
I'm fairly sure that if you start with a cylinder and pinch it flat at both ends, a perfectly flat tetrahedron is the only developable surface you can get. The curved nature of the real-world milk cartons is because the material is slightly extensible (it has a coating of plastic to make it liquid-proof). Better intuition can be gained by trying the experiment with a sheet of plain paper instead.


text:
Q: how to make a circular indicator widget as dots as a widget in my flutter app? I am looking to create an indicator widget for my pageview app, that means that It will be inside my widget tree.
What I have remarked is that When I use
PageViewIndicator class, it's automatically placed either in bottom or centre but when I place it in the center, for example, it hides my fields thing that I don't want, so what do you think?
I have used This
PageIndicatorContainer(
  pageView: PageView(
    children: customWidgetLists,
    controller: controller,
  ),
  align: IndicatorAlign.Center,
  length: 4,
  indicatorSpace: 20.0,
  padding: const EdgeInsets.all(10),
  indicatorColor: Colors.white,
  indicatorSelectorColor: Colors.blue,
  shape: IndicatorShape.circle(size: 12),
  // shape: IndicatorShape.roundRectangleShape(size: Size.square(12),cornerSize: Size.square(3)),
  // shape: IndicatorShape.oval(size: Size(12, 8)),
}

Everything works fine, just I want the dots to be in the centre of the screen and not cover the other widgets because it did.


text:
Q: Vertically center rotated divs in viewport (window height) I have two fixed divs, one on either side of the page.
I've rotated them 90 degrees and managed to get them to the sides.
However I can't get them to vertically center.
Also, I had to define width for the div to get the text to stay on one line, although I'd rather not have a set width because I don't have control of the text content..

.nav-previous, .nav-next {
  position:fixed;
  top: 0; bottom: 0;
}

.nav-previous { left: 0px; }
.nav-next { right: 0px; }

.nav-previous a, .nav-next a {
  display: inline-block;
  position: absolute;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  width: 300px;
  font-size: 1.25em;
  color: #383838;
  margin: 0; padding: 20px;
}

.nav-previous a {
  right: 0;
  transform-origin: top right;
  transform:rotate(-90deg);
}

.nav-next a {
  left: 0;
  transform-origin: top left;
  transform:rotate(90deg);
}

previous

next

jsFiddle: https://jsfiddle.net/azizn/3hq6xgL4/

A: How's this - I have used translate to center the text:

/* this vertically centres the containers */
.navigation .nav-previous,
.navigation .nav-next {
  display:inline-block;
  position:fixed;
  top: 50%;
  transform: translateY(-50%);
}

/*this moves the links onto the screen (after the translating and rotating is done*/
.navigation .nav-previous { left: 20px; }
.navigation .nav-next { right: 20px; }

.navigation .nav-previous a,
.navigation .nav-next a {
  display: inline-block;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 1.25em;
  color: #383838;
  margin: 0;
  padding: 20px;
  transform-origin: center;
}

.navigation .nav-previous a{
  transform: translate(-50%, 0) rotate(90deg); /* move left 50% before rotating*/
}
.navigation .nav-next a {
  transform: translate(50%, 0) rotate(90deg); /* move right 50% before rotating*/
}

/* styles below to show it is centered */
html,
body {height:100%; padding:0; margin:0;}
body:after {content:''; height:50%; background:blue; display:block;}

previous

next


text:
Q: Sending a file from Flask using send_file to a React frontend returns a string of weird characters In my current program, the user selects a file in react, which is sent to flask as such
return axios
        .post(`http://localhost:5000/time`, data, {
            headers: {
                'Content-Type': 'multipart/form-data',
            },
        })
        .then(res => {
            this.onReturnProcessed(res);
            return res
    });
  }

and recieves data from flask as such
onReturnProcessed = res =>{
    console.log((res.data))
    this.setState({img:res.data})
    this.setState({ImgReturned:true})

  }

The Flask backend takes these files, and makes them a numpy array, and then a PIL Image object. It then saves the Image object to the Flask folder as such
img = Image.fromarray((np.uint8(cm(img)*255)))
img.save("./thenewimg.png")

Flask then sends the file to the react frontend
return send_file('./thenewimg.png',mimetype = 'image/png',as_attatchment=True)

The problem is that when React renders the file sent by flask
render(){

}

it is unable to interpret the file, and displays nothing except the file icon in the corner. When the file sent by flask is logged, it outputs many characters like ���}>�{���o��n�_����|��t����Jm~�\Ӳ���. I'm not sure how to change the file on the python backend so that react can interpret it and display it. Otherwise, I'm not sure how to change the frontend to display an image made in python.
This worked
@app.route('/img/<filename>',methods = ['GET'])
def give(filename):
    filen = './UPLOADS/'+filename+'.png'
    return send_file(filen)

A: I believe what is happening here is you are assigning res.data to your img variable. res.data is not the image itself that is assigned to var, but instead its base64 representation. This is why you are seeing the weird characters instead of the actual image.
An easier way to accomplish what you want might be to send back the URL of the image, not the image itself. This way you can store the image URL in your string, and then present the image like so:

console.log(this.state.img); // <-- this now returns 'https://whateveryourapiaddris.com/img/ID'

...

This means that you will need to create a separate flask route that will ingest the image ID that you assign to the image, and return the corresponding image using send_file at that end point.

Related questions:

*

*How to get the image response from a Flask api server and then display it in a react application

*https://www.reddit.com/r/reactjs/comments/bifsrt/display_image_from_flask_send_file_function/


text:
Q: Shift a tikz-cd diagram up when wrapping text around it I want to include a tikz-cd diagram alongside text, wrapped around it. To do this, I am using the package wrapfig. The code looks like this:
\documentclass[psamsfonts]{amsart}

\usepackage{quiver}
\usepackage{tikz-cd}
\usepackage{wrapfig}
\tikzcdset{scale cd/.style={every label/.append style={scale=#1},
    cells={nodes={scale=#1}}}}

\title{}
\author{}
\date{}
\begin{document}

\begin{abstract}
...
\end{abstract}
\maketitle
\tableofcontents

\begin{wrapfigure}{r}{5cm}
\begin{tikzcd}[column sep=9pt, scale cd=0.9]
\end{tikzcd}
\end{wrapfigure}
Given a short exact sequence of cochain complexes...

\end{document}

The output looks like this:

There is lots of whitespace above the diagram, and the amount of whitespace increases as I add text to the left. How can I shift only the diagram up?
The full, compilable code:
\documentclass[psamsfonts]{amsart}

\usepackage{quiver}
\usepackage{tikz-cd}
\usepackage{wrapfig}
\usepackage{lipsum}
\tikzcdset{scale cd/.style={every label/.append style={scale=#1},
    cells={nodes={scale=#1}}}}

\title{}
\author{}
\date{}
\begin{document}

\begin{abstract}
...
\end{abstract}
\maketitle
\tableofcontents

\begin{wrapfigure}{r}{5cm}
\begin{tikzcd}[column sep=9pt, scale cd=0.9]
    && \vdots && \vdots && \vdots \\
    \\
    0 && {A^{k+1}} && {B^{k+1}} && {C^{k+1}} && 0 \\
    \\
    0 && {A^{k}} && {B^k} && {C^{k}} && 0 \\
    \\
    0 && {A^{k-1}} && {B^{k-1}} && {C^{k-1}} && 0 \\
    \\
    && \vdots && \vdots && \vdots
    \arrow[from=5-7, to=5-9]
    \arrow["j", from=5-5, to=5-7]
    \arrow["i", from=5-3, to=5-5]
    \arrow[from=5-1, to=5-3]
    \arrow[from=7-1, to=7-3]
    \arrow["i", from=7-3, to=7-5]
    \arrow["j", from=7-5, to=7-7]
    \arrow[from=7-7, to=7-9]
    \arrow["d_A", shorten <=3pt, shorten >=3pt, from=5-3, to=3-3]
    \arrow["d_B", shorten <=3pt, shorten >=3pt, from=5-5, to=3-5]
    \arrow["d_C", shorten <=3pt, shorten >=3pt, from=5-7, to=3-7]
    \arrow["d_C", shorten <=3pt, shorten >=3pt, from=7-7, to=5-7]
    \arrow["d_B", shorten <=3pt, shorten >=3pt, from=7-5, to=5-5]
    \arrow["d_A", shorten <=3pt, shorten >=3pt, from=7-3, to=5-3]
    \arrow[from=9-3, to=7-3]
    \arrow[from=9-5, to=7-5]
    \arrow[from=9-7, to=7-7]
    \arrow[from=3-7, to=3-9]
    \arrow["j", from=3-5, to=3-7]
    \arrow["i", from=3-3, to=3-5]
    \arrow[from=3-1, to=3-3]
    \arrow[from=3-3, to=1-3]
    \arrow[from=3-5, to=1-5]
    \arrow[from=3-7, to=1-7]
\end{tikzcd}
\end{wrapfigure}
\lipsum

\end{document}

A:
\documentclass[psamsfonts]{amsart}

% \usepackage{quiver}
\usepackage{tikz-cd}
\usepackage{wrapfig}
\usepackage{lipsum}
\tikzcdset{scale cd/.style={every label/.append style={scale=#1},
    cells={nodes={scale=#1}}}}

\title{}
\author{}
\date{}
\setlength\intextsep{0pt}
\begin{document}

\begin{abstract}
...
\end{abstract}
\maketitle
\tableofcontents

\begin{wrapfigure}{r}{6.5cm}
\begin{tikzcd}[column sep=9pt, scale cd=0.9]
    && \vdots && \vdots && \vdots \\
    \\
    0 && {A^{k+1}} && {B^{k+1}} && {C^{k+1}} && 0 \\
    \\
    0 && {A^{k}} && {B^k} && {C^{k}} && 0 \\
    \\
    0 && {A^{k-1}} && {B^{k-1}} && {C^{k-1}} && 0 \\
    \\
    && \vdots && \vdots && \vdots
    \arrow[from=5-7, to=5-9]
    \arrow["j", from=5-5, to=5-7]
    \arrow["i", from=5-3, to=5-5]
    \arrow[from=5-1, to=5-3]
    \arrow[from=7-1, to=7-3]
    \arrow["i", from=7-3, to=7-5]
    \arrow["j", from=7-5, to=7-7]
    \arrow[from=7-7, to=7-9]
    \arrow["d_A", shorten <=3pt, shorten >=3pt, from=5-3, to=3-3]
    \arrow["d_B", shorten <=3pt, shorten >=3pt, from=5-5, to=3-5]
    \arrow["d_C", shorten <=3pt, shorten >=3pt, from=5-7, to=3-7]
    \arrow["d_C", shorten <=3pt, shorten >=3pt, from=7-7, to=5-7]
    \arrow["d_B", shorten <=3pt, shorten >=3pt, from=7-5, to=5-5]
    \arrow["d_A", shorten <=3pt, shorten >=3pt, from=7-3, to=5-3]
    \arrow[from=9-3, to=7-3]
    \arrow[from=9-5, to=7-5]
    \arrow[from=9-7, to=7-7]
    \arrow[from=3-7, to=3-9]
    \arrow["j", from=3-5, to=3-7]
    \arrow["i", from=3-3, to=3-5]
    \arrow[from=3-1, to=3-3]
    \arrow[from=3-3, to=1-3]
    \arrow[from=3-5, to=1-5]
    \arrow[from=3-7, to=1-7]
\end{tikzcd}
\end{wrapfigure}
\lipsum

\end{document}

A: *

*The tikz-cd diagram is redrawn into far more simple and short form.

*vertical size of the vdots on top of diagram are reduced by use of \smash command

*For wrapfigure is explicit reserved vertical space.

\documentclass[psamsfonts]{amsart}
\usepackage{tikz-cd}
\usepackage{wrapfig}
\usepackage{lipsum}

\title{}
\author{}
\date{}
\begin{document}

\begin{abstract}
Summary of article
\end{abstract}
\maketitle
\tableofcontents

\section{Introduction}
\begin{wrapfigure}[18]{r}{6.4cm}
    \centering
\begin{tikzcd}[column sep=2em,
               row sep=7ex,
                cells={nodes={inner xsep=2pt}},
               font=\footnotesize]
        & \vdots
            & \vdots
                & \vdots
                    & ~     \\
0 \rar  & A^{k+1} \uar \rar["i"]
            & B^{k+1} \uar \rar["j"]
                & C^{k+1} \uar \rar
                    & 0     \\
0 \rar  & A^{k} \uar["d_A"] \rar["i"]
            & B^{k} \uar["d_B"] \rar["j"]
                & C^{k} \uar["d_C"] \rar
                    & 0     \\
0 \rar  & A^{k-1} \uar["d_A"] \rar["i"]
            & B^{k-1} \uar["d_B"] \rar["j"]
                & C^{k-1} \uar["d_C"] \rar
                    & 0     \\
        & \vdots \uar
            & \vdots \uar
                & \vdots \uar
                    &       \\
    \end{tikzcd}
\end{wrapfigure}
\lipsum[1-2]

\end{document}

Note:
In generally you can remove additional vertical space in vrapfigure by adding in preamble the following
\usepackage{etoolbox}
\BeforeBeginEnvironment{wrapfigure}{\setlength\intextsep{0pt}}

however, in this particular case this seems not to be (visually) sufficient due to position of \vdots in cells, i.e above it is small empty space. If this is not a problem, than you can use this settings for \intextsep and remove \smash from above image code.

A: You don't need to guess the width of the diagram: let TeX compute it.
I also simplified the coding for the diagram: there's no need to double the number of rows and columns and also for counting the positions: just place the arrows in the source cell.
\documentclass{amsart}

%\usepackage{quiver}
\usepackage{tikz-cd}
\usepackage{wrapfig}
\usepackage{lipsum}

\tikzcdset{
  scale cd/.style={
    every label/.append style={scale=#1},
    cells={nodes={scale=#1}}
  },
}
\newcommand{\svdots}{\smash{\vdots}\mathstrut}
\setlength{\intextsep}{0pt}
\newsavebox{\tikzcdbox}

\begin{document}

\begin{lrbox}{\tikzcdbox}
\begin{tikzcd}[
  scale cd=0.9,
  row sep=2.5em,
  column sep=2em,
  short/.style={shorten <=3pt, shorten >=3pt},
]
& \svdots & \svdots & \svdots \\
0 \arrow[r] &
A^{k+1} \arrow[r,"i"] \arrow[u,short] &
B^{k+1} \arrow[r,"j"] \arrow[u,short] &
C^{k+1} \arrow[r]     \arrow[u,short] &
0
\\
0 \arrow[r] &
A^{k} \arrow[r,"i"] \arrow[u,"d_A", short] &
B^{k} \arrow[r,"j"] \arrow[u,"d_B", short] &
C^{k} \arrow[r]     \arrow[u,"d_C", short] &
0
\\
0 \arrow[r] &
A^{k-1} \arrow[r,"i"] \arrow[u,"d_A", short] &
B^{k-1} \arrow[r,"j"] \arrow[u,"d_B", short] &
C^{k-1} \arrow[r]     \arrow[u,"d_C", short] &
0
\\
& \svdots \arrow[u,short] & \svdots \arrow[u,short] & \svdots \arrow[u,short]
\end{tikzcd}
\end{lrbox}
\begin{wrapfigure}{r}{\wd\tikzcdbox}
\usebox{\tikzcdbox}
\end{wrapfigure}

\lipsum

\end{document}

The psamsfonts option is obsolete and only exists for compatibility with 20+ year old documents.


text:
Q: Problem with request.request_uri when forwarding from AJAX partial - Rails In my Rails logging in functionality I use
session[:return_to] = request.request_uri

and then in the logging functionality I use:
redirect_to session[:return_to]

Which works fine except when I render a partial with AJAX. What happens is that the request.uri is for the AJAX request which screws up and doesn't render what's expected.
You know how I can go around this?
Thanks,
Tam

A: This may do what you want:
redirect_to :back

A: request.request_uri will indeed be for the AJAX URI. The only solution I've found is to make your AJAX requests (or at least, the ones that may cause a redirect to the login page) include the URI of the whole page, e.g.
form_remote_for ... do |f|
    hidden_field_tag :this_page, request.request_uri
    # only works if this view itself is not loaded over AJAX!

or for a more universal approach:
form_remote_for :html => {:onsubmit => '$("this_page").value = window.location'}, ... do |f|
    hidden_field_tag :this_page, request.request_uri
    # non-JS clients just end up with the value given here

Combine either of these with
# in the login action
session[:return_to] = params[:this_page]


text:
Q: events concept in yii2 I have gone throught the guide from :
http://www.yiiframework.com/doc-2.0/guide-concept-events.html
but I have simple confusion here is that:
// this handler is a static class method
$foo->on(Foo::EVENT_HELLO, ['app\components\Bar', 'methodName']);
the above event will be fired on the execution of method : 'methodName' of class 'app\components\Bar' ?
OR
method : 'methodName' of class 'app\components\Bar' will be fired on the call of above event ?

A: method : 'methodName' of class 'app\components\Bar' will be fired on the call of above event.
To fire event on execution of method you must triggering event - http://www.yiiframework.com/doc-2.0/guide-concept-events.html#triggering-events


text:
Q: PHP not using full URL? This is my code:
<?php
$url = "https://api.datamarket.azure.com/opendata.rdw/VRTG.Open.Data/v1/KENT_VRTG_O_DAT?$filter=Kenteken%20eq%20%2701GBB1%27";
$xml =  simplexml_load_file($url);
?>

Im trying to get this .XML file into my $url. The problem is that its using
https://api.datamarket.azure.com/opendata.rdw/VRTG.Open.Data/v1/KENT_VRTG_O_DAT and not the one with the filter:
https://api.datamarket.azure.com/opendata.rdw/VRTG.Open.Data/v1/KENT_VRTG_O_DAT?$filter=Kenteken%20eq%20%2701GBB1%27
Why is it not taking the URL i entered there? When i open the URL in my browser i get the filtered one but when i run the code itll give me the other .XML.
I hope someone can help me.

A: You are using double quotes, so php will interpret $filter as a (probably undefined...) variable.
You can avoid that using single quotes:
$url = 'https://api.datamarket.azure.com/opendata.rdw/VRTG.Open.Data/v1/KENT_VRTG_O_DAT?$filter=Kenteken%20eq%20%2701GBB1%27';

A: Use single quotes.
Then re-read the docs

A: Have you tried this?
<?php
$url='https://api.datamarket.azure.com/opendata.rdw/VRTG.Open.Data/v1/KENT_VRTG_O_DAT?    $filter=Kenteken%20eq%20%2701GBB1%27';

$xml = new SimpleXMLElement(file_get_contents($url));
?>


text:
Q: Does this graph algorithm have a name? Let $\Gamma=(V,E)$ be a graph with vertices $V$ and edges $E$.
Let $f_0: V \rightarrow \mathbb{R}_{\geq 0}$ be a function that assigns a non-negative number to each vertex.
Assume that $f_0$ is not identically zero.
Execute the following algorithm:

*

*Given $f_i$, define $\overline{f_i}$ as $\overline{f_i}(v):=\frac{f_i(v)}{\sum_{w \in V} f_i(w)}$, i.e. make $\overline{f_i}$ sum up to $1$.

*Given $\overline{f_i}$, define $f_{i+1}$ via $f_{i+1}(v):=\overline{f}_i(v)+\sum_{(v,w) \in E} \overline{f}_i(w)$, i.e. $f_{i+1}$ is given up by summing up the values of $\overline{f_i}$ in a $1$-neighbourhood.

I think this converges in the sense that $\overline{f_i}(v) \rightarrow \frac{deg(v)+1}{deg(\Gamma)+|V|}$ as $i \rightarrow \infty$ for all $v \in V$, where $deg(\Gamma)$ denotes the total degree of $\Gamma$.
This formula is just a guess, it may very well be wrong.

Question 1: does this algorithm have a name?

Question 2: by altering the definition of $\overline{f_i}$, can we get more interesting limits of $\overline{f_i}$, for example eigenfunctions of the Laplacian?


text:
Q: Opening a link and a div at the same time Few days ago I tried to create a system that jQuery will enable me to display a link and a div when you click, everything about
Link to project: http://jsfiddle.net/HCAfz/
A main condition is that when you click on a link opened up and changed the status of only one div, and not all on the page.
I'm such a div in each category with 40 and the creation of separate classes in the css div again, misses the point.
What can my project completed in jquery? any suggestions

A: You could do something like this, using next:
http://jsfiddle.net/HCAfz/2/
$('a.yourLink').click(function(event) {
        event.preventDefault();
        event.stopPropagation();
        $(this).next('.hiddenDiv').show();
        window.open(this.href, '_blank');
 });

A: If you're trying to change the content of a div in particular call it by an ID. Just set the property id='something' and call it with JQuery: $('#something').html('Add this HTML to div')
It's very alike when you work with CSS. Just e specify a ID or class and set your style rule by it.

A: You could use a more generic procedure.
Click here

    Your link has opened in a new window

and javascript
$('a.opens-a-link-and-shows-a-div').click(function(event) {
      event.preventDefault();
      event.stopPropagation();
      var div_name = '#div-to-show-when-%-clicked'
          .split('%').join($(this).attr('id'));
      $(div_name).show();
      window.open(this.href, '_blank');
 });

(See my fork)

A: If I understand your question correctly, an expanded version of your HTML would look like this:

    Click here

Your link has opened in a new window

Your 2nd link has opened in a new window

Your 3rd link has opened in a new window

Your 4th link has opened in a new window

You could use this jQuery to open only the div after the link and not the others with the same class:

    $('a#yourId').click(function(event) {
          event.preventDefault();
          event.stopPropagation();
          $(this).next('.hiddenDiv').show();
     });


text:
Q: Where's unminified version of Bootstrap 3 docs.min.js I would like to check the original version of this file : https://github.com/twbs/bootstrap/blob/master/docs/assets/js/docs.min.js . Tried to search through project but seems no luck.

A: The docs/assets/js/docs.min.js is built from docs/assets/js/_vendor/holder.js and docs/assets/js/_src/application.js. See Gruntfile.js.


text:
Q: How to load module at specific address and execute it in ubuntu? I have some x86_64 code, that needs to be loaded at address 0x7ff022234100 and execute it. If this module is loaded and executed correctly it will output in stdout text and I will see the message: "Module was loaded correctly".
How can I do this ? please, help me, I researched everywhere and didn't find solution yet.
I saw something, that I should use -Wl,-Ttext-segment,0x8000000 (my address), but what command should I use in general ?


text:
Q: CMIS explorer webapp CMIS is a recently approved standard for accessing ECM repositories.
My idea is to create a repository explorer using CMIS, under the form of an open source Java/Java EE Web Application.
The main interest would probably be for integrators, using it as a framework on which to quickly build repository access intranet/extranet applications.
Of course, if such an open source project already exists, I would rather contribute to it rather than start a competing effort.
So, does such an application/framework already exist? As open source?

A: *

*spring-cmis-application-browser, based on Spring Surf, usable as a desktop-like file explorer.

*Struts2CmisExplorer, based on Struts2 and designed for integration into portals.

*chemistry-opencmis-test-browser, a minimalistic explorer webapp.

A: DITA CMIS Explorer http://ditalabs.com

A: WeWebU OpenWorkdesk is an application suite (not just a CMIS browser!) for Enterprise Content Management (ECM) with an intuitive Web 2.0 front-end.
OpenWorkdesk applications are future-proof and protect your investments because the user interface and the application layer have been separated from the underlying ECM system. This separation allows you to continue using your applications without laborious modifications even after an upgrade or change of the ECM platform. OpenWorkdesk Community Edition is available for all CMIS-compliant ECM systems such as Alfresco ECM, IBM FileNet P8, Nuxeo and EMC Documentum. Therefore, it provides a very cost-efficient but nevertheless fully professional way of managing and retrieving documents.
Even users who do not have any ECM system experience can use state-of-the-art ECM functionalities with minimal training. Its user-friendly navigation with "Windows-like" shortcuts and right mouse button menus, and not at least its innovative Web 2.0 technologies assist users perfectly in dealing with their daily tasks.
(description above is taken from their website)


text:
Q: Difference between cross product (cross join, Cartesian product) and natural join While writing in SQL, how would I know if I should use cross product (cross join, Cartesian product) or natural join?

A: CROSS JOIN creates all possible pairings of rows from two tables, whether they match or not. You don't use any join condition for a cross product, because the condition would always be true for any pairing.
An example of using CROSS JOIN: you have tables of ShoeColors and ShoeSizes, and you want to know how many possible combinations there are. SELECT COUNT(*) FROM ShoeColors CROSS JOIN ShoeSizes;
NATURAL JOIN is just like an INNER JOIN, but it assumes the condition is equality and applies for all columns names that appear in both tables. I never use NATURAL JOIN, because I can't assume that just because columns have the same name, that they should be related. That would require a very strict column naming convention, and practically no real-world project has such discipline.

A: In simple words,cross join performed a cartesian product among the rows of two different tables..where the columns name may or may not be matched......but in natural join its mandatory that in order to perform join operation columns name of two tables must be matched

A: Natural join is a cross join with where condition being on columns with same name from both tables.
Let's assume that you have two tables: A and B
>>select * from A;

            col1 col2 col3
            ---------------
            1     2    1
            1     4    0
>>select * from B;
            col1 col2
            ---------
            1     2

            1     3

>>select * from A cross join B;

    col1 col2 col3 col1_2 col2_2
    -----------------------------
    1     2    1    1      2
    1     2    1    1      3
    1     4    0    1      2
    1     4    0    1      3

>>select * from A natural join B;

    col1 col2 col3
    ---------------
    1     2    1
    1     2    1

For further details visit my post. https://eduit.nuxaavi.com.mx/2021/10/16/producto-cartesiano-sql/


text:
Q: SQL Case Statement Based on Column value The 'patient' table needs to be updated from the 'history' table. The patient table has all of the history in a single row while the history table has one type of history per row. How can I use a conditional something like below (my best attempt) to update the right column based on the history_code value which indicates what type of history data it is.
Any help would be appreciated
UPDATE AUS.dbo.patient SET

    CASE
    WHEN history_code = 'surgery' THEN surh = smh.condition
    WHEN history_code = 'social' THEN soch = smh.condition
    WHEN history_code = 'medical' THEN medh = smh.condition
    WHEN history_code = 'family' THEN famh = smh.condition
    WHEN history_code = 'ocular' THEN obsh = smh.condition
    END

FROM history AS smh
LEFT JOIN patient AS sp
    ON smh.patient_id = sp.patient_id
LEFT JOIN AUS.dbo.u_master AS um
    ON sp.old_patient_id = um.filenumber COLLATE Latin1_General_CS_AS
WHERE patient.fk_master_masterid = um.masterID```

A: CASE is an expression not a statement and as such can only return a scalar value, not conditionally run a statement. Instead you need one CASE per column you wish to update, either modifying the value or leaving it the same as per your conditions. Here is one column:
surh =
    CASE
    WHEN history_code = 'surgery' THEN smh.condition
    ELSE surh
    END

I highly recommend reading the documentation when unsure about some functionality.


text:
Q: Gradle WAR plugin: how to find destination for files to copy I've been working on having Gradle generate an IntelliJ WAR artifact definition as part of the 'idea' task as per this blog post. This has worked pretty successfully so far although my code is quite dirty so I'm trying to clean it up.
As far as I'm concerned, the war task should contain all the information required to create the necessary tags in the IntelliJ. For example, given a Gradle Project object, say gradleProject, I can do something like:
def artifactManager = project.component.find { it.@name == 'ArtifactManager' } as Node
if (artifactManager) {
  Node artifact = artifactManager.artifact.find { it.@type == 'exploded-war' }
  if (artifact) {
    artifactManager.remove(artifact)
  }
} else {
  artifactManager = project.appendNode('component', [name: 'ArtifactManager']);
}
def builder = new NodeBuilder();
def artifact = builder.artifact(type: 'exploded-war', name: "${gradleProject.name} exploded war") {
  'output-path'("${gradleProject.buildDir}/${gradleProject.name}-exploded.war")
  root(id: 'root') {
    element(id: 'directory', name: 'WEB-INF') {
      // copy web.xml
      element(id: 'file-copy', path: gradleProject.war.webXml)
      Set<String> excludeJars = [] as Set
      element(id: 'directory', name: 'classes') {
        // copy classes
        element(id: 'module-output', name: gradleProject.name)
        // copy depending projects module output (classes)
        gradleProject.configurations.runtime.allDependencies.each {
          if (it.hasProperty('dependencyProject')) { // TODO: make it functional?!?
            if (it.dependencyProject.hasProperty('jar'))
              excludeJars.add(it.dependencyProject.jar.archiveName)
            element(id: 'module-output', name: it.dependencyProject.name)
          }
        }
      }
      // copy dependency jars excluding possible existing module jars (not sure it's necessary)
      element(id: 'directory', name: 'lib') {
        // TODO: this should handle ALL kinds of dependencies
        gradleProject.configurations.runtime.each {
          if (!excludeJars.contains(it.name))
            element(id: 'file-copy', path: it)
        }
      }
    }
  }
}
artifactManager.append artifact

to modify or create my IntelliJ .ipr file.
Now I have added some files to my WAR artifact in the Gradle script as in:
war{
  from project(':rest').file('resource/some.properties')
  from project(':some_project').fileTree('some_folder')
  metaInf {
    from parent.file('build/config/website/' + environment + '/context.xml')
  }
}

and I'd like to add some Groovy code to pick up those files and create the correct XML tags to have IntelliJ copy them in the right locations.
What's the simplest way to do this? I tried playing with the following:
gradleProject.war.source.each { // ... create tags etc.  }

but the list of source files includes all the files, regardless of their destination (all libs, web.xml, classes, etc.).
How can I achieve what I'm trying to do?

A: I finally figured it out with the help of Gradle docs and a little trial and error. I got the desired result using the following code:
def artifactManager = project.component.find { it.@name == 'ArtifactManager' } as Node
if (artifactManager) {
  Node artifact = artifactManager.artifact.find { it.@type == 'exploded-war' }
  if (artifact) {
    artifactManager.remove(artifact)
  }
} else {
  artifactManager = project.appendNode('component', [name: 'ArtifactManager']);
}
def builder = new NodeBuilder();
def artifact = builder.artifact(type: 'exploded-war', name: "${gradleProject.name} exploded war") {
  'output-path'("${gradleProject.buildDir}/${gradleProject.name}-exploded.war")
  root(id: 'root') {
    println "Adding files to root"
    gradleProject.war.rootSpec.children.each {
      if (it.destPath.pathString.equals("")) {
        add(builder, it, "")
      }
    }
    println "Adding files to META-INF"
    element(id: 'directory', name: 'META-INF') {
      gradleProject.war.rootSpec.children.each {
        if (it.destPath.pathString.equals("META-INF")) {
          add(builder, it, "META-INF")
        }
      }
    }
    println "Adding files to WEB-INF"
    element(id: 'directory', name: 'WEB-INF') {
      element(id: 'file-copy', path: gradleProject.war.webXml)
      gradleProject.war.rootSpec.children.each {
        if (it.destPath.pathString.equals("WEB-INF")) {
          add(builder, it, "WEB-INF")
        }
      }
      Set<String> excludeJars = [] as Set
      element(id: 'directory', name: 'classes') {
        element(id: 'module-output', name: gradleProject.name)
        gradleProject.configurations.runtime.allDependencies.each {
          if (it.hasProperty('dependencyProject')) {
            if (it.dependencyProject.hasProperty('jar'))
              excludeJars.add(it.dependencyProject.jar.archiveName)
            element(id: 'module-output', name: it.dependencyProject.name)
          }
        }
      }
      element(id: 'directory', name: 'lib') {
        gradleProject.configurations.runtime.each {
          if (!excludeJars.contains(it.name))
            element(id: 'file-copy', path: it)
        }
      }
    }
  }
}
artifactManager.append artifact

with the add function defined as:
def add(NodeBuilder builder, Object s, String dest, String prefix = "") {
  println(prefix + "current destination: [" + dest + "]")
  if (s instanceof File) {
    println(prefix + "-- file " + s.toString())
    builder.element(id: 'file-copy', path: s)
  } else if (s instanceof FileTree) {
    println(prefix + "-- folder " + s.dir.toString())
    builder.element(id: 'dir-copy', path: s.dir)
  } else if (s instanceof CopySpecInternal) {
    print(prefix + "-- copy spec " + s.toString() + " with destination path: [" + s.destPath.pathString + "]; ")
    if (dest.equals(s.destPath.pathString)) {
      println("destination matches current folder")
      s.sourcePaths.each { path ->
          add(builder, path, dest, prefix + "  ")
      }
      s.children.each { child -> add(builder, child, dest, prefix + "  ") }
    } else {
      println("")
      if (s.destPath.segments != null && s.destPath.segments.length > 0 && s.destPath.segments[0].equals(dest)) {
        String relDest = new RelativePath(false, Arrays.copyOfRange(s.destPath.segments, 1, s.destPath.segments.length)).pathString
        builder.element(id: 'directory', name: relDest) {
          s.sourcePaths.each { path ->
            add(builder, path, relDest, prefix + "  ")
          }
          s.children.each { child -> add(builder, child, relDest, prefix + "  ") }
        }
      } else {
        println(prefix + "!! destination path is not relative to [" + dest + "]: [" + s.destPath.pathString + "]")
      }
    }
  } else println(prefix + "?? unknown " + s.toString())
}

I basically reverse engineered the war task properties and dug into the tree of files to copy. As far as I can tell, this task doesn't expose an interface to do this kind of things so I had to resort to a 'hacky' solution, which is not my favorite. I'd be happy if anyone can chip in with some cleaner code.


text:
Q: How to record mouse and keyboard movement simultaneously, and store it as a variable that could be placed in a function or loop with Python? So I want to start a project that records my keyboard input and mouse movement for a sandbox PC games. I love farming, however whether I'm tired, and taking a short break to make a coffee or have a phone call. When I come back my farm gets annihilated.
I tried and made this one, but it seems not to work. Any way to make it better with the possibility to implement the recorded inputs in a loop function?
import pyautogui

def record_movement():
    # Initialize variables to store mouse and keyboard events
    mouse_events = []
    keyboard_events = []

    # Start recording mouse and keyboard events
    pyautogui.PAUSE = 0.001 # Set a small pause to record events more accurately
    pyautogui.FAILSAFE = False # Disable failsafe feature to allow for recording
    recording = True
    while recording:
        event = pyautogui.getEvent()
        if event.event_type == 'MouseMove':
            mouse_events.append(event)
        elif event.event_type == 'KeyDown':
            keyboard_events.append(event)
        elif event.event_type == 'KeyUp':
            keyboard_events.append(event)
        elif event.event_type == 'Quit':
            recording = False
    return mouse_events, keyboard_events

def replay_movement(mouse_events, keyboard_events):
    # Replay recorded mouse and keyboard events
    for event in mouse_events:
        pyautogui.moveTo(event.x, event.y)
    for event in keyboard_events:
        if event.event_type == 'KeyDown':
            pyautogui.press(event.name)
        elif event.event_type == 'KeyUp':
            pyautogui.keyUp(event.name)

# Test:
mouse_events, keyboard_events = record_movement()
replay_movement(mouse_events, keyboard_events)


text:
Q: WordPress Gutenberg - White Screen on page edit screen using custom block category in template I'm attempting to setup a template and use a block that is contained within a custom category. The blocks word a-ok when used normally in the Gutenberg editor.
I create the category as such:
add_filter( 'block_categories', function( $categories, $post ) {
 return array_merge(
   $categories,
   array(
     array(
       'slug'  => 'mycustomcat',
       'title' => 'My Custom Category',
     ),
   )
 );
}, 10, 2 );

And make an (ACF) block:
    acf_register_block_type(array(
        'name'              => 'column-text',
        'title'             => __('Column Text'),
        'render_template'   => 'template-parts/blocks/column-text-block.php',
        'category'          => 'mycustomcat',
        'icon'              => 'menu-alt2',
        'keywords'          => array( 'column', 'text' ),
        'post_types'        => $supportedPostTypes,
        'mode'              => 'auto',
        'supports'          => array( 'align' => false ),
    ));

All is good until we get here:
function myplugin_register_template() {
   $post_type_object = get_post_type_object( 'page' );
   $post_type_object->template = array(
       array( 'mycustomcat/column-text' ),
   );
}
add_action( 'init', 'myplugin_register_template' );

Then, when creating new page in the WordPress admin I get a blank white screen. The only error found is in console:
Uncaught (in promise) TypeError: Cannot read property 'attributes' of undefined
    at Te (blocks.min.js?ver=6.7.2:2)
    at blocks.min.js?ver=6.7.2:2
    at c (lodash.min.js?ver=4.17.15:6)
    at ru (lodash.min.js?ver=4.17.15:67)
    at pn (blocks.min.js?ver=6.7.2:2)
    at editor.min.js?ver=9.7.5:11
    at u (editor.min.js?ver=9.7.5:11)
    at Generator._invoke (editor.min.js?ver=9.7.5:11)
    at Generator.forEach.e.<computed> [as next] (editor.min.js?ver=9.7.5:11)
    at redux-routine.min.js?ver=3.6.2:1

A: For others having the same problem. The Acf block names have to be namespaced with acf/blockname.
In this case array( 'mycustomcat/column-text' ) should be array( 'acf/column-text' ).


text:
Q: Writing data to text file then changing half way I am trying to write data into next file but then half way down, change one value of the column going forward that has is constant for the first set of lines. This is my code:
import random
import time

start_time = time.time() #time measurement
numpoints = 512
L = 20
d = 1
points = set()

# Open f and write
with open("question2.xyz","w") as f:
    f.write("%d\ncomment goes here\n" % numpoints) #this is for the 2nd line in my xyz
    while len(points) < numpoints:
        p = (random.randint(0, L), random.randint(0, L), random.randint(0, L))
        if p not in points:
            points.add(p)
            f.write('H %f %f %f\n' % p)

My code currently produces an XYZ file in this format
512 #number of
comment goes here
H 6.000000 19.000000 14.000000
H 11.000000 2.000000 7.000000
H 15.000000 20.000000 16.000000

Thanks for the help in advance!
Edit, woops sorry, this is what I want to achieve
512 #number of
comment goes here
H 6.000000 19.000000 14.000000
H 11.000000 2.000000 7.000000
H 15.000000 20.000000 16.000000
O 6.000000 19.000000 14.000000
O 11.000000 2.000000 7.000000
O 15.000000 20.000000 16.000000

Right now my code puts in H for the first value for all 512 lines, starting in line 256, I need that changed to an O

A: You could use a generator for point generation, and two for loops:
def pointgen(used):
    while True:
        p = (random.randint(0, L), random.randint(0, L), random.randint(0, L))
        if p not in used:
            used.add(p)
            yield p

# Open f and write
with open("question2.xyz","w") as f:
    f.write("%d\ncomment goes here\n" % numpoints) #this is for the 2nd line in my xyz
    pg = pointgen(points)
    for i in xrange(numpoints // 2):
        f.write('H %f %f %f\n' % pg.next())
    for i in xrange(numpoints // 2):
        f.write('O %f %f %f\n' % pg.next())


text:
Q: Bogus data in ResultSet I'm having some issues with my ResultSet using JDBC.
Here's my relation:
create table person (
person_id   number(5) generated always as identity
            minvalue 1
            maxvalue 99999
            increment by 1 start with 1
            cycle
            cache 10,
firstname   varchar(10) not null,
lastname    varchar(10) not null,
);

I'm trying to insert a (firstname, lastname) into the tuple and then get the person_id that comes out of it. Here's my JDBC code:
//connection is taken care of beforehand and is named con
prep = con.prepareStatement("insert into person (firstname, lastname) values (?, ?)", Statement.RETURN_GENERATED_KEYS);
        prep.setString(1, firstname);
        prep.setString(2, lastname);
        prep.execute();
        ResultSet generated = prep.getGeneratedKeys();
        if (generated.next()) {
            String key = generated.getString("0");
            System.out.println(key);
        }

This works all fine. But my problem is that the key should be an integer, not a String. Every time I run this, I get a ResultSet that contains a string of "AAA3vaAAGAAAFwbAAG", or something along those lines. I want to get the person_id so I can use it later in my Java program.
Is there something I'm doing wrong in regards to searching through the ResultSet or the execution of the statement itself?

A: tl;dr
int id = generated.getInt( 1 ) ;

Details
Your Question seems confused.
There are two forms of each get… method on ResultSet.

*

*Pass a column number (an int)

*Pass a column name (a String)

You seem to have combined the two into this:

String key = generated.getString( "0" ) ;

I doubt that you have a column named with a single digit zero. Besides being a poor choice of name, standard SQL forbids starting an identifier with a digit.
So that line makes no sense. Perhaps you meant the first column by using a zero 0 and mistakenly wrapped it in quotes, thereby transforming your intended int into an actual String.
Even that intention would be wrong. The ResultSet::getString documentation incorrectly describes the int as an "columnIndex". Usually "index" means a zero-based counting offset. But actually ResultSet::getString( int ) requires you pass an ordinal number with counting starting at one. So getString( 0 ) is never valid.
So if you want to retrieve the value of your result set's first column as text, do this:
String key = generated.getString( 1 ) ; // Retrieve first column of result set as text.

Yet again, this would be wrong in the context of your code. You are apparently attempting to retrieve the primary key values being generated during the INSERT. Your primary key column person_id is defined as number(5) which is not a textual type. So retrieving as a String is not appropriate.
NUMBER(5) is not standard SQL. If you happen to be using Oracle database, the doc says that would be an integer type with a precision of five, meaning numbers with up to five digits. So retrieve that as a integer type in Java by calling ResultSet::getInt.
int id = generated.getInt( 1 ) ;  // Retrieve the new row's ID from the first column of the result set of generated key values returned by the `INSERT` prepared statement.

My comments above are for databases in general. But for Oracle specifically, see the Answer by Mark Rotteveel explaining that Oracle database does not return the generated sequence number when calling getGeneratedKeys. Instead it returns ROWID pseudo-column.

A: Your problem is that Oracle by default returns the ROWID of the inserted record, and not the generated identifier. From Oracle JDBC Developer's Guide: Retrieval of Auto-Generated Keys:

If key columns are not explicitly indicated, then Oracle JDBC drivers
  cannot identify which columns need to be retrieved. When a column name
  or column index array is used, Oracle JDBC drivers can identify which
  columns contain auto-generated keys that you want to retrieve.
  However, when the Statement.RETURN_GENERATED_KEYS integer flag is
  used, Oracle JDBC drivers cannot identify these columns. When the
  integer flag is used to indicate that auto-generated keys are to be
  returned, the ROWID pseudo column is returned as key. The ROWID
  can be then fetched from the ResultSet object and can be used to
  retrieve other columns.

So, if you use Statement.RETURN_GENERATED_KEYS, you'll get the ROWID, and you can then use that ROWID to select the inserted row to obtain the other values (including the generated identifier).
If you want to specifically retrieve the generated id, for Oracle you'll need to explicitly ask for that column as follows:
String[] columns = { "PERSON_ID" }
prep = con.prepareStatement(
        "insert into person (firstname, lastname) values (?, ?)", columns);
prep.setString(1, firstname);
prep.setString(2, lastname);
prep.executeUpdate();
ResultSet generated = prep.getGeneratedKeys();
if (generated.next()) {
    int key = generated.getInt("PERSON_ID");
    System.out.println(key);
}


text:
Q: Is it possible to keep using my current apps and their data on a different iPod? I have an iPod 5 but I want the front and back camera, so for my upcoming birthday in April I'm planning an upgrade.
Can I use the same Apple ID and start at the same level on the Apps I have on this iPod?

A: Simply create a backup, but sync all applications first to your PC else you have to do extra work. Syncing to iCloud is possible, but if you want to restore all your applications back on the new iPod it's much easier to make an iTunes backup as you can sync back all applications on the new iPod.
If you make the backup Encrypted, it will also save all your passwords etc, making setting up of the new device much easier. [Don't forget the encryption password!]
Restore the backup you make from the current iPod on your new iPod!
Sync all apps back on and you're done - even the settings etc are now on your new iPod.


text:
Q: MSBuild.exe gives errors about Nuget package conflicts, what does it mean? Working in VS2017 I have a C# project .Net 4.6 using several Nuget packages. On my dev machine from within VS it builds just fine, I've tested it will restore Nuget packages from completely clean and build correctly.
On our build machine it is build using MSBuild.exe and now everything is going wrong.

Build>"C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" ".sln"
/p:Configuration="Release" /p:Platform="Any CPU" /p:version=4.2.0.3230
/m "  Microsoft (R) Build Engine version 15.7.179.6572 for .NET
Framework Copyright (C) Microsoft Corporation. All rights reserved.

I can see the /packages sub-dir is getting populated as expected with packages but then I get errors like:

Encountered conflict between 'Reference:System.Numerics.Vectors,
Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL' and
'Platform:System.Numerics.Vectors.dll'.  Could not determine winner
because 'Reference:System.Numerics.Vectors, Version=4.1.4.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL' does not exist.
Encountered conflict between 'Platform:System.Numerics.Vectors.dll' and
'Reference:System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL'.  Could
not determine winner because 'Reference:System.Numerics.Vectors,
Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL' does not exist.

My project file looks like:
    <Reference Include="System.Numerics" />
    <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
    </Reference>

C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5):
warning MSB3245: Could not resolve this reference. Could not locate
the assembly "log4net, Version=2.0.8.0, Culture=neutral,
PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL". Check to
make sure the assembly exists on disk. If this reference is required
by your code, you may get compilation errors.
[]
For SearchPath "{HintPathFromItem}".
Considered "packages\log4net.2.0.8\lib\net45-full\log4net.dll", but it didn't
exist.

I mean, here it is:

<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
  <HintPath>packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
</Reference>

Every build is a completely clean build (it's wiped between) so I can clearly see Nuget has downloaded log4net.dll
I am getting loads of these and I cannot see any explanation why, or where to start looking for a solution. Everything looks to be where it should be

A: You can try changing a binding redirect in your config file to 2.8.0 of log4net
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.8.0" newVersion="2.0.8.0" />


text:
Q: openGL Creating texture atlas at run time? So I've set up my framework in a neat little system to wrap SDL, openGL and box2D all together for a 2D game.
Now how it works is that I create an object of "GameObject" class, specify a "source PNG", and then it automatically creates an openGL texture and a box2d body of the same dimensions.
Now I am worried about if I start needing to render many different textures on screen.
Is it possible to load in all my sprite sheets at run time, and then group them all together into one texture? If so, how? And what would be a good way to implement it (so that I wouldn't have to manually be specifying any parameters or anything).
The reason I want to do it at run time and not pre-done is so that I can easily load together all (or most) of the tiles, enemies etc.. of a certain level into this one texture, because every level won't have the same enemies. It'd also make the whole creating art process easier.

A: There are likely some libraries that already exist for creating texture atlases (optimal packing is a nontrivial problem) and converting old texture coordinates to the new ones.
However, if you want to do it yourself, you probably would do something like this:

*

*Load all textures from disk (your "source PNG") and retrieve the raw pixel data buffer,

*If necessary, convert all source textures into the same pixel format,

*Create a new texture big enough to hold all the existing textures, along with a corresponding buffer to hold the pixel data

*"Blit" the pixel data from the source images into the new buffer at a given offset (see below)

*Create a texture as normal using the new buffer's data.

*While doing this, determine the mapping from "old" texture coordinates into the "new" texture coordinates (should be a simple matter of recording the offsets for each element of the texture atlas and doing a quick transform). It would probably also be pretty easy to do it inside a pixel shader, but some profiling would be required to see if the overhead of passing the extra parameters is worth it.

Obviously you also want to check to make sure you are not doing something silly like loading the same texture into the atlas twice, but that's a concern that's outside this procedure.

To "blit" (copy) from the source image to the target image you'd do something like this (assuming you're copying a 128x128 texture into a 512x512 atlas texture, starting at (128, 0) on the target):
unsigned char* source = new unsigned char[ 128 * 128 * 4 ]; // in reality, comes from your texture loader
unsigned char* target = new unsigned char[ 512 * 512 * 4 ];

int targetX = 128;
int targetY = 0;

for(int sourceY = 0; sourceY < 128; ++sourceY) {
    for(int sourceX = 0; sourceX < 128; ++sourceX) {
        int from = (sourceY * 128 * 4) + (sourceX * 4); // 4 bytes per pixel (assuming RGBA)
        int to = ((targetY + sourceY) * 512 * 4) + ((targetX + sourceX) * 4); // same format as source

        for(int channel = 0; channel < 4; ++channel) {
            target[to + channel] = source[from + channel];
        }
    }
}

This is a very simple brute force implementation: there are much faster, more succinct and more clever ways to copy an array, but the idea is that you are basically copying the contents of the source texture into the target texture at a given X and Y offset. In the end, you will have created a new texture which contains the old textures in it.
If the indexing math doesn't make sense to you, think about how a 2D array is actually indexed inside a 1D space (such as computer memory).
Please forgive any bugs. This isn't production code but instead something I wrote without checking if it compiles or runs.

Since you're using SDL, I should mention that it has a nice function that might be able to help you: SDL_BlitSurface. You can create an SDL_Surface entirely within SDL and simply use SDL_BlitSurface to copy your source surfaces into it, then convert the atlas surface into a GL texture.
It will take care of all the math, and can also do a format conversion for you on the fly.


text:
Q: JS: Reorganize objects inside an array based on value of a particular key (reduce?) This is a follow-up question of this one, although both are unrelated in term of operation

Starting with this kind of structure:
[ [{ field: "field1", term: "val1"},
   { field: "field2", term: "val2"}
  ],
  [{ field: "field3", term: "val3"},
   { field: "field3", term: "val4"},
   { field: "field4", term: "val5"}
  ],
  [{ field: "field3", term: "val6"},
   { field: "field2", term: "val7"},
   { field: "field3", term: "val8"},
   { field: "field1", term: "val9"},
   { field: "field2", term: "val10"}
  ]
]

I need to iterate through each child arrays, and for each object inside, aggregate the values of the key term into an array when the key field is the same; And by the same occasion wrap all values of key term in an array, for simplicity later. End result would be like so:
[ [{ field: "field1", term: ["val1"]},
   { field: "field2", term: ["val2"]}
  ],
  [{ field: "field3", term: ["val3", "val4"},
   { field: "field4", term: ["val5"]}
  ],
  [{ field: "field3", term: ["val6", "val8"]},
   { field: "field2", term: ["val7", "val10"]},
   { field: "field1", term: ["val9"]}
  ]
]

I've tried playing with _.reduce for each objects, got relatively close but never quite there. Not mastering this pattern at all, I am not convinced reduce is the way to go either
Any ideas or pointers? Been trying to wrap this one for 2 days ... :S
Thanks

A: Well, you can create for each array a new object that's got "field" values as keys, and "term" arrays as values. Then you can transform that back into objects in your original form.
var newArray = array.map(function( subArray ) {
  var obj = subArray.reduce(function(m, o) {
    if (o.field in m)
      m[o.field].push(o.term);
    else
      m[o.field] = [o.term];
    return m;
  }, {});

  return Object.keys(obj).map(function(field) {
    return { field: field, term: obj[field] };
  });
});


text:
Q: How do I make the shape created a circle? from PIL import Image
import time
start = time.time()
import random as r
x = int(input("Enter the preferred width of your image:"))
y = int(input("Enter the preferred length of your image:"))
suggested = (x*y)
print("We suggest you use:",suggested,"pixels")
amount = int(input("How many pixels do you want to generate?"))
while amount > suggested:
    amount = int(input("Please choose the number suggested or smaller.     How many pixels do you want to generate?"))
numbers = []
numbs = (r.randint(0,255),r.randint(0,255),r.randint(0,255))
while len(numbers)<(amount):
    numbers.append(numbs)
    numbs = (r.randint(0,255),r.randint(0,255),r.randint(0,255))
print(numbers)
print('It took', time.time()-start, 'seconds')
im2 = Image.new('RGB', (x,y))
im2.putdata(numbers)
im2.show()
im2.save("out.png")

The code I have used puts three random numbers into one tuple, and then puts that tuple into a list. Each tuple is a pixel. The dimensions that the user enters will always make a straight shape x wide and y long, I want to make the shape round and have curved edges. How? Thanks.

A: I played with your code and was able to add an open green circle and a blue filled circle.  Try it out:
from PIL import Image, ImageDraw
import time
import math
#
start = time.time()
import random as r
#x = int(input("Enter the preferred width of your image:"))
x = 100
#y = int(input("Enter the preferred length of your image:"))
y = 150
suggested = (x*y)
print("We suggest you use:",suggested,"pixels")
#amount = int(input("How many pixels do you want to generate?"))
amount = 15000
while amount > suggested:
    amount = int(input("Please choose the number suggested or smaller.     How many pixels do you want to generate?"))
numbers = []
numbs = (r.randint(0,255),r.randint(0,255),r.randint(0,255))
while len(numbers)<(amount):
    numbers.append(numbs)
    numbs = (r.randint(0,255),r.randint(0,255),r.randint(0,255))
print(numbers)
#
print('It took', time.time()-start, 'seconds')
im2 = Image.new('RGB', (x,y))
im2.putdata(numbers)
#-----------------------------------------------------------
numb_test = (255,0,0) # red circle
numb_test = (0,255,0) # green circle
radius_test = min(x,y) * 0.4
print "radius_test = " + str(radius_test)
x_center = x/2
y_center = y/2
angle_test = 0
print "pi = " + str(math.pi)
while angle_test < 360:
    angle_rads = angle_test * math.pi/180.0
    x_test = int(radius_test * math.cos(angle_rads)) + x_center
    y_test = int(radius_test * math.sin(angle_rads)) + y_center
    #print "x_test, y_test = " + str(x_test) + ", " + str(y_test)
    im2.putpixel((x_test, y_test),numb_test)
    angle_test += 1
#
draw = ImageDraw.Draw(im2)
draw.ellipse((20, 20, 40, 40), fill = 'blue', outline ='blue')
#-----------------------------------------------------------
im2.show()
im2.save("out.png")

Note that ImageDraw was also imported from PIL and math was imported.
I found the method to draw an ellipse described here:
http://effbot.org/imagingbook/imagedraw.htm


text:
Q: mysql, php , how to count results that are the same? i have a table that has users and the pages that they visited.
i might have user user1 that visited pages: index.php 3 times and 'test.php' 4 times.
then user user2 that visited pages: index.php 6 times and 'test.php' 10 times.
what i want to do is to display the most visited pages by user in order.
any ideas?
thanks
edit: table schema. table name findme
talentnum | page_name
user1     | test.php
user1     | test.php
user1     | index.php
user2     | test.php
user3     | index.php

A: Something like this:
SELECT
  TALENTNUM,
  PAGE_NAME,
  COUNT(*) AS CNT
FROM FINDME
GROUP BY TALENTNUM, PAGE_NAME
ORDER BY CNT DESC

A: w/o knowing your table schema:
SELECT user, page, count(*)
FROM users u
JOIN page p
ON u.user_id = p.user_id
GROUP BY user, page
ORDER BY user, page DESC;

A: Whenever a user loads a page insert a row into the table to record his ID and the Page visited. You can then run an SQL query
SELECT talentnum,page_name,COUNT(page_name) FROM findme
GROUP BY talentnum,page_name
ORDER BY COUNT(page_name) DESC


text:
Q: Put an image in a render_to_response Django I´m developing an project in Django and I have a view that generate a chart as am image and return it to me as a web page into a HttpResponse(). And it already works, but that´s the thing, I need to put some more informacion on the page and buttons....
So how can I return this image in a render_to_response()? Cuz in this I can tell wich templeta use and place my stuff there. Or how can I place html stuff on the HttpResponse() with the image?
Here it is my code that I wanna transform in a render_to_response(), it´s a function that generate a multiple line chart:
def chart(request):
    if 'checks[]' in request.GET and request.GET['checks[]']:
        #getting id's of selected tags
        chosen = request.GET.getlist('checks[]')
        tags = Tag.objects.filter(id__in = chosen)
        fig=Figure()
        ax=fig.add_subplot(111)
        strIdTags = ""
        #getting all values of all selected tags
        for tag in tags:
            if Values.objects.filter(tag = tag.id).count > 0:
                #values of one tag
                values = Values.objects.filter(tag = tag.id)
                strIdTags+=str(tag.id)
                strIdTags+="; "
                x = []
                y = []
                #all values of one tag
                for value in values:
                    y.append(value.value)
                    x.append(value.datetime)
                    #ax.plot_date(value.value, value.datetime, '-')
                ax.plot_date(x, y, '-')
                ax.annotate("Tag "+str(tag.id), (x[0],y[0]),
                arrowprops=dict(facecolor='black', shrink=0.05))
        ax.xaxis.set_major_formatter(DateFormatter('%d/%m/%Y - %H:%M:%S'))
        ax.set_title("Values of Tags: "+strIdTags)
        ax.set_xlabel("Date-Time")
        ax.set_ylabel("Values")
        fig.autofmt_xdate()
        canvas=FigureCanvas(fig)
        response=HttpResponse(content_type='image/png')
        canvas.print_png(response)
        return response

A: You need a different view instead, that returns a rendered template:
def chart_view(request):
    return render(request, 'templates/chart_template.html')

In that template, define all the HTML you need, including an <img> tag with a link to the view that you've defined in your original post that returns the image:
<html>
...etc...

<img src='{% url 'chart' %}?checks=...' />

The HTML template will be returned to the user as an HTML page (complete with all the buttons etc you want), and the chart image will be embedded in it just like any other image.


text:
Q: Delaunay link distance I have a Delaunay mesh region. To start with, I give a simple example here:
pts = RandomReal[{-1, 1}, {50, 2}];
R = DelaunayMesh[pts];

The next step I want to do is to calculate every link length in Delaunay mesh. As I don't need to associate every length to its related points, I have tried to calculate nearest points length to every point, and collect them. But it is too slow because I have thousands of points and each length is calculated twice.
Is there a faster way to get all the link length directly?


text:
Q: Parallel file uploading using azure blob storage javascript library (v12) How to upload multiple files parallelly to Azure Storage account using azure javascript library(v12) ?

A: If you want to know what methods support parallel uploading, in the library for JavaScript description, there functions only available in Node.js:Features, interfaces, classes or functions only available in Node.js.
Parallel uploading and downloading

*

*BlockBlobClient.uploadFile()

*BlockBlobClient.uploadStream()

If you wanna a sample you could refer to here:https://github.com/Azure/azure-sdk-for-js/blob/112c8e28a3876b1a47bc688b7756150113a0e8a0/sdk/storage/storage-blob/samples/javascript/advanced.js#L59.


text:
Q: Go win64 api permission denied I am using this Windows API wrapper to try and get bitlocker status.
My code is:
test, err := wapi.GetBitLockerConversionStatus()

I am getting the following error:
err wmi.Connect: permission denied: Exception occurred. (Access denied )

When I'm logged with the same user I can get results with C# code:
IShellProperty prop = ShellObject.FromParsingName("C:").Properties.GetProperty("System.Volume.BitLockerProtection");

I have tried to call other functions in the Go wrapper such as wapi.ProcessList() and it works, so the permission issue seems to be specific to the BitLocker function and not the whole package or anything else.
My question is why does it require special permission in Go but not in C# and is there a way to get that information without elevated permission?


text:
Q: Bootswatch/Bootstrap CSS/Theme Breaks Page in IE7 & IE8 I am trying to use http://bootswatch.com/cerulean/bootstrap.min.css in my page. I've just tried using http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css as well. However it seems to break the page as follows. The navbar at the top loses its links and the main content goes full width. I am basing it on this example http://getbootstrap.com/examples/sticky-footer-navbar/

However things start to get better when I use bootstrap.min.css from https://github.com/twbs/bootstrap/releases/download/v3.0.0/bootstrap-3.0.0-dist.zip

Any ideas what's happening at all? I've just compared http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css against my local copy and it's exactly the same! So I downloaded it, saved in and referenced it and now it works.
[UPDATE] It seems that IE8 is playing ball but still no luck with IE7 even using https://github.com/coliff/bootstrap-ie7

A: IE8 and below don't support the responsive media queries that Bootstrap uses. Have you included https://github.com/scottjehl/Respond (Respond.js) to enable media query support? The bootstrap website states here that you need to include it for IE8 or anything under it


text:
Q: Greedy Algorithms and append function - how to create a new array? Okay, so I have an array coin and I want to create a new array which is the same length as array, but with the amount of coins from the array 'coins' needed for input m.
coin = [200,100,50,20,10,5,2,1]

So far, I have the following. What should be in for loop for me to return what I want?
def coinSplitGD2(m):

    coin = [200,100,50,20,10,5,2,1]

    if m==0:
        return 0
    for i in range(len(coin)):
        if coin...

So if m is 143, it will return [0, 1, 0, 2, 0, 0, 1, 1] meaning no 200-coins, one 100-coin, no
50-coins, two 20-coins, no 10-coins, no 5-coins, one 2-coin and one 1-coin

A: coin = [200,100,50,20,10,5,2,1]
def coinSplitGD2(m):
    a = []
    for c in coin:
        a.append(m // c)
        m %= c
    return a

so that:
coinSplitGD2(143)

returns:
[0, 1, 0, 2, 0, 0, 1, 1]


text:
Q: A Bound based on Jensen's Inequality Consider:
$$X \sim \text{Gamma}(\alpha, \beta)$$
$$Y = \frac{1}{X+c}, \ c > 0$$
I am interested in $E(Y)$, which I'm pretty sure is intractable...
$$E(Y) = \frac{\beta^\alpha}{\Gamma(\alpha)}\int_0^\infty \frac{x^{\alpha-1}e^{-\beta x}}{x+c} dx $$
If an exact analytic answer is unavailable, I would like to approximate this in terms of $\alpha$, $\beta$ and $c$.

By Jensen's Inequality, we have:
$$E\left[\frac{1}{X+c}\right] \geq \frac{1}{E(X) + c}$$
Or equivalently, for some $\epsilon(\alpha, \beta, c) > 0$:
$$E(Y) = \frac{1}{E(X) + c} + \epsilon(\alpha, \beta, c)$$
Can we say anything about the magnitude of $\epsilon(\alpha, \beta, c)$. If not, is there a better way to approach this problem?
Thanks in advance!

A: According to Rockower (Integral Identities for Random Variables, $\it{The \ American \ Statistician}$, February 1988, Vol. 42, No. 1), the expectation is given by $$E \left[ \frac{1}{X+c} \right] =\int_0^{\infty} e^{-cs} \cal{L}(s)ds,$$ where $\cal{L} (s)$ is the Laplace transform of the pdf of the random variable $X$.
From a table of Laplace transforms we find $$\cal{L} \left( x^{\alpha-1} e^{-x/{\beta}} \right)=\frac{\Gamma \left( \alpha \right)}{\left(s+\frac{1}{\beta} \right)^{\alpha} } $$
So for the Laplace transform of the pdf we get $$\cal{L} \left( \frac{x^{\alpha-1} e^{-x/{\beta}}}{\beta^{\alpha} \ \Gamma  \left( \alpha \right)  }\right)=\frac{1}{\beta^{\alpha} \left(s+\frac{1}{\beta} \right)^{\alpha} } $$
Then $$E \left[ \frac{1}{X+c} \right] =\int_0^{\infty} \frac{e^{-cs}}{\beta^{\alpha} \left( s + \frac{1}{\beta} \right)^{\alpha}} ds=\int_0^{\infty} \frac{e^{-cs}}{ \left( \beta s + 1 \right)^{\alpha}} ds$$
Now make the substitution $q=\beta s + 1.$ The result is
$$E \left[ \frac{1}{X+c} \right] =\int_1^{\infty} \frac{e^{-c \left( \frac{q-1}{\beta} \right)}}{\beta \ q ^{\alpha}} dq=\frac{1}{\beta}e^{c/{\beta}}\int_1^{\infty} \frac{e^ { - \left( {\frac{c}{\beta}} \right) q } }{  q^{\alpha}} dq$$
From the definition for the generalized exponential integral function given in the comment by wolfies, we have finally
$$ E \left[ \frac{1}{X+c} \right]= \frac{e^{c/{\beta}}}{\beta} E_{\alpha} \left( \frac{c}{\beta} \right), $$
which agrees with his answer using the computer algebra system.


text:
Q: Create deep hash mapping in perl Below is my Code with the Hash
#!/usr/bin/perl
use warnings;
use JSON::PP; # Just 'use JSON;' on most systems
my %name = (
          'sl' => {
                    'fsd' => {
                               'conf' => {
                                           'ul' => '/sl/fsd/conf/ul',
                                           'si' => '/sl/fsd/conf/si',
                                           'ho1' => '/sl/fsd/conf/ho1'
                                         }
                             }
                  },
          're' => {
                    'fsd' => {
                               'cron' => {
                                           'README' => '/re/fsd/cron/README'
                                         },
                               'bin' => {
                                          'db' => {
                                                    'smart.p_add_tag' => '/re/fsd/bin/db/smart.p_add_tag',
                                                    'smart.p_tag_partition' => '/re/fsd/bin/db/smart.p_tag_partition',
                                                    'smart.p_add_tag_type' => '/re/fsd/bin/db/smart.p_add_tag_type'
                                                  }
                                        },
                               'doc' => {
                                          'SMART' => '/re/fsd/doc/SMART',
                                          'README' => '/re/fsd/doc/README'
                                        },
                               'data' => {
                                           'README' => '/re/fsd/data/README'
                                         },
                               'conf' => {
                                           'al1' => '/re/fsd/conf/al1',
                                           'file' => '/re/fsd/conf/file',
                                           'ho' => '/re/fsd/conf/ho',
                                           'al3' => '/re/fsd/conf/al3',
                                           'hst' => '/re/fsd/conf/hst',
                                           'us' => '/re/fsd/conf/us',
                                           'README' => '/re/fsd/conf/README',
                                           'al2' => '/re/fsd/conf/al2'
                                         }
                             }
                  }
        );

(my $root) = keys %name;

my %nodes = ();
my %tree  = ();
my @queue = ($root);

list_children(\%name, \@queue, \%nodes) while @queue;

my $tree = build_tree($root, \%nodes);

my $json = JSON::PP->new->pretty; # prettify for human consumption

print $json->encode($tree);

sub list_children {
  my $adjac = shift;
  my $queue  = shift;
  my $nodes  = shift;

  my $node = shift @$queue;

  my @children = keys %{$adjac->{$node}};

  @children = grep { ! exists $nodes->{$_}} @children;

  $nodes->{$node} = \@children;

  push @$queue, @children;
}

sub build_tree {
  my $root  = shift;
  my $nodes = shift;

  my @children;
  for my $child (@{$nodes->{$root}}) {
    push @children, build_tree($child, $nodes);
  }

  my %h = ('text'     => $root,
           'children' => \@children);

  return \%h;
}

I'm trying to output JSONified hash, but it is only traversing upto two levels. whereas i need it to traverse all upto the last child node of each parent. Can someone please help to achieve this.
Below is current output
{
   "text" : "sl",
   "children" : [
      {
         "text" : "fsd",
         "children" : []
      }
   ]
}

A: Normally, transforming the hash, and then json-ing is not the most efficient idea, because you're going to make one traversal to transform the hash and JSON's going to make one to json-ify it, and JSON is a type of transform of a hash.
However, JSON is usually done with XS, which means that the second traversal is faster, at least. That and JSON behavior is standardized.
use 5.016;
use strict;
use warnings;
use Data::Dumper ();
use JSON;

my $hash
    =  {
  'Foods' => {
    'fruits' => {
      'orange' => '1',
      'apple' => '2',
    },
    'Vegetables' => {
      'tomato' => '3',
      'carrot' => '1',
      'cabbage' => '2',
    }
  }
};

sub descend {
    my ( $structure, $block ) = @_;
    my $res;
    while ( my ( $k, $v ) = each %$structure ) {
        $block->( $structure, $k, $v );
        if ( ref( $v ) eq 'HASH' ) {
            $res = descend( $v, $block );
        }
    }
    return $res;
}

my $new  = {};
my $curr = $new;

descend( $hash => sub {
    my ( $lvl, $k, $v ) = @_;
    my $node = { text => $k };
    $curr->{children} //= [];
    push $curr->{children}, $node;

    if ( ref( $v ) eq 'HASH' ) {
        $curr = $node;
    }
    else {
        $node->{children} = { text => $v };
    }
});

# allow for the root-level special case, and retrieve the first child.
$new = $new->{children}[0];

say Data::Dumper->Dump( [ $new ], [ '$new' ] );
say JSON->new->encode( $new );


text:
Q: PHP Can I define a variable protected variable inside class? In my class I want to declare a protected variable:
protected $subject = "Thank you for registering";

So far, so good. But when I want to include a variable I get an error:
protected $subject = "Thank you for registering on " . $nameOfWebsite;
protected $subject = $someVariable;
protected $subject = "Concated " . "String";

All return the same error, syntax error, unexpected '.', expecting ',' or ';'. Am I not allowed to do this? Why not?
Is there another way to make my protected variable variable?
Thanks!