text:
Q: Gooey css effects with contrast parent I'm trying to create gooey effect with CSS only (without svg).
Everything goes right but my parent container has a contrast filter and I can't use colors on my child elements (the contrast filter changes the colors).
Does someone know of a basic way to make this effect with only CSS or reverse the contrast filter to get my right colors on the child elements?
My code:

body{
  background: #fff;
}

.blobs {
  position:absolute;
  top:0;
  left:0;
  bottom:0;
  right:0;
  background: #fff;
  width:400px;
  height:200px;
  margin:auto;
  filter:contrast(20);
  -webkit-filter:contrast(20);
}

.blob {
  background:black;
  width:100px;
  height:100px;
  position:absolute;
  left:50%;
  top:50%;
  margin-top:-50px;
  margin-left:-50px;
  border-radius:100%;
  transition: cubic-bezier(0.82, 0.1, 0.24, 0.99) 2.5s;
  -webkit-transition: cubic-bezier(0.82, 0.1, 0.24, 0.99) 2.5s;
  box-shadow: 0 0 30px 10px black;
}

.blobs:hover .blob:first-child {
  transform:translateX(-70px);
}

.blobs:hover .blob:last-child {
  transform:translateX(70px);
}

When I'm coloring the child elements:

body{
  background: #fff;
}

.blobs {
  position:absolute;
  top:0;
  left:0;
  bottom:0;
  right:0;
  background: #fff;
  width:400px;
  height:200px;
  margin:auto;
  filter:contrast(20);
  -webkit-filter:contrast(20);
}

.blob {
  background: rgb(255, 113, 93);
  width:100px;
  height:100px;
  position:absolute;
  left:50%;
  top:50%;
  margin-top:-50px;
  margin-left:-50px;
  border-radius:100%;
  transition: cubic-bezier(0.82, 0.1, 0.24, 0.99) 2.5s;
  -webkit-transition: cubic-bezier(0.82, 0.1, 0.24, 0.99) 2.5s;
  box-shadow: 0 0 30px 10px rgb(255, 113, 93);
}

.blobs:hover .blob:first-child {
  transform:translateX(-70px);
}

.blobs:hover .blob:last-child {
  transform:translateX(70px);
}

.original-color {
  height: 100px;
  background: rgb(255, 113, 93);
}

My fiddle

A: For this answer, I only had to make a change to the filter property
contrast(15) contrast(.5) sepia(1) brightness(1.85) hue-rotate(319deg) saturate(3.45)

*

*First, we set the contrast to 15 (20 made the edges a little too hard, if you ask me)

*Then we set it back to .5 (Yes, you can stack these things)

So now we have a lightgray background and darkgray blobs

*

*Apply sepia (which gives it a color)

*Add 1.85 brightness (now the background is white again, and we have colored blobs)

*hue-rotate to get to the right hue

*saturate to give it its saturation

The last three properties in the list are essential for getting the right color. Your goal is rgb(255, 113, 93). With this line applied, the colors are rgb(255, 115, 94)
You can see it work in this Fiddle
As a sidenote. You can also stack transforms, which means that if you want to center the blobs, you won't have to use negative margins, but use the translate(-50%, -50%) trick. Then when you hover over them, you can simply stack the transforms like this translate(-50%, -50%) translateX(-70px)

A: I have taken your effect. On the container, I have set a pseudo element that covers it, with whatever color you want.
And with a mix-blend-mode, I can set this color where the container is black, keeping the remaining white:
(By the way, a very nice effect !)

body{
  background: #fff;
}

.blobs {
  position:absolute;
  top:0;
  left:0;
  bottom:0;
  right:0;
  background: #fff;
  width:400px;
  height:200px;
  margin:auto;
  filter:contrast(20);
  -webkit-filter:contrast(20);
}

.blobs:after {
  content: "";
  position: absolute;
  top:0;
  left:0;
  bottom:0;
  right:0;
  background-color: coral;
  mix-blend-mode: lighten;
}

.blob {
  background:black;
  width:100px;
  height:100px;
  position:absolute;
  left:50%;
  top:50%;
  margin-top:-50px;
  margin-left:-50px;
  border-radius:100%;
  transition: cubic-bezier(0.82, 0.1, 0.24, 0.99) 1.5s;
  box-shadow: 0 0 30px 10px black;
}

.blobs:hover .blob:first-child {
  transform:translateX(-70px);
}

.blobs:hover .blob:last-child {
  transform:translateX(70px);
}

Added another way to get your request. This is harder to set up, but will work on Edge, where filter is available but blend modes do not.
This snippet involves using 2 of your previous setting, and a different primary color for each. (You could already achieve primary colors with your original setting).
To get a particular color, you set different alphas to the 2 settings, and somehow you can achieve any color that you want (even though the process is not easy)

body{
  background: #fff;
}

.blobs {
  position:absolute;
  top:0;
  left:0;
  bottom:0;
  right:0;
  background: #fff;
  width:400px;
  height:200px;
  margin:auto;
  filter:contrast(20);
  -webkit-filter:contrast(20);
  opacity: 0.99;
}

.blob {
  width:100px;
  height:100px;
  position:absolute;
  left:50%;
  top:50%;
  margin-top:-50px;
  margin-left:-50px;
  border-radius:100%;
  transition: cubic-bezier(0.82, 0.1, 0.24, 0.99) 2.5s;
}

.blobs:hover .blob:first-child,
.blobs:hover ~ .blobs .blob:first-child {
  transform:translateX(-70px);
}
.blobs:hover .blob:last-child,
.blobs:hover ~ .blobs .blob:last-child {
  transform:translateX(70px);
}
.blobs:nth-child(1)  {
  opacity: 0.57;
}
.blobs:nth-child(1) .blob {
  background: red;
  box-shadow: 0 0 30px 10px red;
}
.blobs:nth-child(2)  {
  pointer-events: none;
  opacity: 0.08;
}
.blobs:nth-child(2) .blob {
  background: yellow;
  box-shadow: 0 0 30px 10px yellow;
}
.test {
    width: 100px;
  height: 100px;
  position: absolute;
  left: 0px;
  background-color: rgb(255, 113, 93);
}

Another try, this time with a more complex filter.
The color is achieved with a hue-rotate

body {
  background: #fff;
}
.blobs {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: #fff;
  width: 400px;
  height: 200px;
  margin: auto;
  -webkit-filter: contrast(20) hue-rotate(-25deg);
  filter: contrast(20) hue-rotate(-25deg);
}
.blob {
  background: red;
  width: 100px;
  height: 100px;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-top: -50px;
  margin-left: -50px;
  border-radius: 100%;
  transition: cubic-bezier(0.82, 0.1, 0.24, 0.99) 1.5s;
  box-shadow: 0 0 30px 10px red;
}
.blobs:hover .blob:first-child {
  transform: translateX(-70px);
}
.blobs:hover .blob:last-child {
  transform: translateX(70px);
}

Another try, this time a single div ....

.test {
  border: 1px solid black;
  width: 600px;
  height: 400px;
  background-color: white;
  background-image: radial-gradient(circle, red 100px, transparent 140px), radial-gradient(circle, red 100px, transparent 140px);
  background-position: -150px 0px, 150px 0px;
  background-repeat: no-repeat;
  -webkit-filter: contrast(20) hue-rotate(35deg);
  filter: contrast(20) hue-rotate(35deg);
  transition: background-position 2s;
  animation: crazy 13s infinite steps(12);
}
.test:hover {
  background-position: 0px 0px, 0px 0px;
}
@keyframes crazy {
  from {
    filter: contrast(20) hue-rotate(0deg);
  }
  to {
    filter: contrast(20) hue-rotate(360deg);
  }
}

Trying to get a solution that works cross-browser .
Added javascript to check blend-mode availiabily.
Just click the button to run the function.

function check () {
  if('CSS' in window && 'supports' in window.CSS) {
    var support = window.CSS.supports('mix-blend-mode','lighten');
    if ( ! support) {
      var element = document.getElementById('blobs');
      element.classList.add('compat');
    }
}
}
body{
  background: #fff;
}

.blobs {
  position:absolute;
  top:0;
  left:0;
  bottom:0;
  right:0;
  background: #fff;
  width:400px;
  height:200px;
  margin:auto;
  filter:contrast(20);
  -webkit-filter:contrast(20);
}

.blobs:after {
  content: "";
  position: absolute;
  top:0;
  left:0;
  bottom:0;
  right:0;
  background-color: coral;
  mix-blend-mode: lighten;
}

.blob {
  background:black;
  box-shadow: 0 0 30px 10px black;
  width:100px;
  height:100px;
  position:absolute;
  left:50%;
  top:50%;
  margin-top:-50px;
  margin-left:-50px;
  border-radius:100%;
  transition: cubic-bezier(0.82, 0.1, 0.24, 0.99) 1.5s;
}

.blobs:hover .blob:first-child {
  transform:translateX(-70px);
}

.blobs:hover .blob:last-child {
  transform:translateX(70px);
}

/* compatibility */

.blobs.compat {
  -webkit-filter:contrast(20)  hue-rotate(-25deg);
  filter:contrast(20)   hue-rotate(-25deg);
}
.blobs.compat:after {
  content: none;
}

.compat .blob {
  background: red;
  box-shadow: 0 0 30px 10px red;
}

<button onclick="check()">Check</button>


text:
Q: Adobe-sponsored tags Whoa! Very cool. A welcome and smart way to bring users and company together in a way that benefits everyone involved - exactly the kind of advertising we need more of.

Is this something that'll be open to any company who owns the product(s) behind an SO topic? Or only ones with Adobe's weight/checkbook?

A: It would be better in black and white. As said in another answer:

IT DRAWS MY ATTENTION AWAY from more important things.

Think about it

A: Disclaimer: I may not be an adobe fan.
Sponsored tags are not OK.  Advertising is OK, just don't f**k with the content.
Jeff, I'm sure I don't need to remind you that StackOverFlow is all about the content.  And that content is only valuable when it has a perceived credibility.
If I posted a question like "Flex, blah blah blah?", I was reasonably confident that the answers I got were genuine on SO.  However, an answer with a sponored tag?  Not so sure anymore.  What might happen to an answer like "Flex is a pile of shit in that scenario.  Here's why...".?  A sly downvote because it might piss off the tag sponsor?
Surely, there are smarter ways to monertise this site without destroying the only value you have?

A: A few months ago, the excellent CBC Radio Show Age of Persuasion did a particularly good show called Breaking the Contract. It explores the idea (from David Ogilvy) that advertising is bound by a social contract with the audience -- if I see an ad, I should benefit from it.
These Adobe ads are a blight. They distract from the content, especially the other tags. They stick out like a sore thumb, like a row of billboards along the highway. They add absolutely no value. They look tacky.
Jeff, Joel, et al., I beg all of you to reconsider these advertisements.
(Or at least provide a way to have "text-only" tags -- perhaps at a certain level of reputation)

A: I don't mind the Adobe icon in my "interested" tags or within the context of a single question. However, it makes going through search results simply too difficult because there are so many of them on the screen and each one and every one of them is screaming for attention.
I am going to suggest limiting the number of sponsor icons visible on a given page.

A: I'm fine with the idea of sponsored tags. The Woot badge works for me (essentially the same thing from a UI/aesthetics perspective), but the Adobe one is ugly and doesn't fit the SO scheme at all... Maybe if it matched the blue tag background it wouldn't be so jarring.

A:  It's clever-ish, and no doubt very effective, but it is kind of visually jarring. It also gives Stack Overflow a distinctive Adobe feel, as if they're more than just a tag sponsor. What I mean is that I went to the main page this morning, and there were several instances of Adobe-sponsored tags on the first page that stood out from all the other, non-sponsored tags. Clicking one (I mean, what else can you do?) you have to click the Adobe tags) took me to a page with even more Adobe paraphernalia. Now, don't get me wrong, I use and like Adobe products, but if this continues I can see three possible results:

*

*Stack Overflow will look like it's run by Adobe (as it does today) or MS or whoever buys the tags

*when a new user goes to Stack Overflow, it's possible a subconscious question develops around "Can I ask non-Adobe questions here?"

*or, with more sponsorships, it ends up looking like a NASCAR product.

Capitalism is great and Stack Overflow is great and all that. Ooo-rah. I'm just suggesting that care be taken. Today, Stack Overflow looks like Adobe is slightly more than just a sponsor.
(EDIT: The tag sponsorship concept is interesting, and I love the blatant business angle. It has a kernel of genius. My only beef is the  unintended "Made by Adobe" feel StackO verflow just took on, and where this is going. So, do it, just think harder about how you do it.)
(EDIT: Seriously, no problem whatsoever making a living or selling tag sponsorships or ads or whatever. I'm just saying be careful about the vibe that's given off. When it looked like an Adobe site this morning, I did a double-take, and the thought briefly crossed my mind that maybe they were running something now.)

A: The Advertising on top of a tag is perfectly fine. However, the little icon in the tag itself could be problematic, because you are giving away part of your branding to an external company and could give the impression that Adobe is the owner of StackOverflow as they are also the only tag-sponsor so far.
But the idea itself has potential if you have more sponsors, because they draw attention. A Flash developer can easily spot Adobe-Related tags. But for me as a non-flash developer, it looks like Christmas Decoration.

A: I didn't even realize the Woot! badge was an advertisement until now.

A: My biggest concern is what happens to the tags that don't have lots of money behind them?
Python, PHP, Apache, Perl, and so many others... their tags would eventually be drowned out by the eye-catching nature of the sponsored tags.
I like the little Adobe logo, but I don't want free software to get left out in the cold.

A: I hate it, as it draws my attention away from more important things.
Please give me a preference to make it go away. And fix ignore, it seems to be broken w.r.t. these tags.
Edit: After thinking about if for a while, it might be clever to attach the logo only to "interesting" tags. I think I'd actually like it if it helps me find the things I'm interested in.
Edit 2: No, scrap that. Please keep content and advertisements separated.

A: This doesn't warrant a full question, but I thought I'd ask it where it's appropriate.  Are you guys tracking stats on the tags (more specifically sponsored-tags) added to "Ignored Tags" before/after the adobe campaign?
It would be interesting to see what the community response is to the tags in an empirical way.

A: I dislike the sponsored the links at the top of those tag pages. I would pay to get rid of them.

A: Thank you for the positive feedback. Mutually beneficial was our goal in developing this.

Is this something that'll be open to any company who owns the product(s) behind an SO topic? Or only ones with Adobe's weight/checkbook.

Tag sponsorship is available to all sponsors (big or small)... and it really comes down to how dominant of a sponsor they are on the tag. Getting 100% of the ads for a particular tag will most certainly get you the tag sponsorship... but 1%, not so much.

A: The logo in the tag background is a nice method, not unlike the woot! badge. That is indeed a cool way to bring the tag-based advertising on board.
Could open it up to all sorts of tag sponsorship...

Cue those who will decry any and all advertising on the internet as demon's blood soaking the denim of acid-wash jeans.
At least the questions disappear if you've got them on your ignored and hidden list.

A: I think this is a great way to fund the site. Props to Alex and Adobe for trying this. The UI is a little jarring with so many adobe logos on the page but I am sure that will be changed in future iterations.
My only concern about this is that it could lead to censorship. If there are postings in an adobe sponsored tag which adobe doesn't approve of, they could put pressure on SO to remove questions and answers. It would be re assuring if it was explicit that this can't happen. Otherwise a bad question could get removed by the community (for being a bad question) and a user will complain that it is commercial pressure that got it removed.

A: Sponsored tags suck.
You're half a step away from having flashing animated gifs, scrolling marquees and those terrible 'Free Forever' ads.  (Oh, and to all those people whose knickers just got in a knot, it's called hyperbole ;b)
I think it comes across as visually jarring, seems like a clumsy grab-for-cash, add zero value to the question/answer and hinders usability by breaking the consistency rule.
It's actually a bit disappointing Jeff because in the past you have had quite a strong and honourable stance when it comes to advertising (See How To Advertise on Your Blog Without (Completely) Selling Out).   I don't know what your motivations are for expanding the SO family advertising in such a way, but in my opinion, the credibility, design and usability are all suffering as a result.
Please keep the advertising out of the content, our eyes will thank you for it.
Update:
@Jeff:  It's your site and you can do whatever you want with it and I sincerely (for real) hope that you and Joel (and Geoff and Jarrod) make bucket loads of money out of it.  I consider SO to be the best programming site out there and I consider you to be 'the good guys'.
But the content on the site comes from us, the users, so we do feel as if we have some right to at least comment and provide feedback on the direction of the site.
You don't have to heed the feedback, but due to the source of the content on the site, at least listening to the feedback (without getting cranky and sarcastic) seems like the right thing for you to do.
Yes, we can go to some other site if we don't like this one, but we DO like this one, and it sucks when it moves in a direction that makes us like it less.
And this is why I think this style of advertising has caused such a reaction amongst your users.   It is pushing the boundaries (which are grey and muddy by the way), and we are just letting you know that.

A: I dislike the sponsored tags because they still draw my attention to this colorful tags despite they are in my ignored tag list.. Successful advertisement, I agree, but annoying.

A: Wouldn't work with Windows - Imagine a Microsoft designed tag icon

(source: invisiblecompany.com)

A: I like this approach to advertising. One suggestion would be, though, to make the icon blend more with the site colors. Right now it stands out too much. A softer, more SO-compatible hue would make it much more pleasing.
More careful control of the colors will be increasingly important if this approach becomes popular among other tags.

A: I hate to point out that I just installed the FIRST adblock rule I've ever manually written in over 3 years... On Stack Overflow of all places.  Up until now I had even white listed ad blocking on the League of Justice sites based on your advertising policies.  All because this company I'll never care about now has a RED 'A' to make its questions stand out to the eye MORE than the questions I actually care to read.
I'm taking Jeff's advice and adding an adblock for it, but I just lost a little faith in the 'above ground' advertising policies you had.
I think the problems I have with this would be solved if either (preferably both) of these things happened:

*

*the logo was 'colored' in the same blue hue as the tag boxes - Tell me which tag you see first: http://img197.imageshack.us/img197/368/tagsr.jpg

*there were more tags that had these logos, perhaps some tags like rss/html/etc (which I hope you don't plan on selling to the highest bidder) could pick up generic icons. (Maybe throw in a jQuery one as a donation to the project since you use it)

A: I think that if there were logos on more things (but no "sponsor" banner on the tag), then this would be significantly better than if just the adobe icon is there, in bright red.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Detect keypress but only once. Keyboard module isn't working this way I want to detect a keypress and when it happands i want to do something once. If i use the keyboard module for this it does te statement a few times.
I have tried other modules but i can't figure it out.
import turtle
import keyboard

count_a = 5

#screen
wn = turtle.Screen()
wn.bgcolor("black")
wn.setup(width=800, height=600)
wn.tracer(0)

#pen
pen= turtle.Turtle()
pen.speed(0)
pen.color("white")
pen.penup()
pen.hideturtle()
pen.write(count_a, align="center", font=("courier", 24, "normal"))

#main
while True:
    wn.update()

    if keyboard.is_pressed('a'):
        count_a -= 1
        pen.clear()
        pen.write(count_a, align="center", font=("courier", 24, "normal"))

If you press "a" in my program the count goes a lot lower then -1. I just wnt the count to be 4 if you've pressed it once.

A: If you want to stop the loop from running after a press occurs, you may want to add break:
while True:
    wn.update()

    if keyboard.is_pressed('a'):
        count_a -= 1
        pen.clear()
        pen.write(count_a, align="center", font=("courier", 24, "normal"))

        break # <-

Though, this will stop the loop. Although, if you want it to stop your code from executing inside the if loop and only have one run of the statement, you could add a flag that stops after it is pressed the first time.
If you want to stop your code from executing after the first run of if
#main
waitingForA = True
while True:
    wn.update()

    if keyboard.is_pressed('a') and waitingForA: # <-
        count_a -= 1
        pen.clear()
        pen.write(count_a, align="center", font=("courier", 24, "normal"))

        waitingForA = False # <-

Notice how I added the waitForA variabiel, then set it to False after we got our first press, this will then stop the if statement from running a second time since our if statement resolves to True and False, which obviously won't run in an and statement.


text:
Q: How to interpolate the first and the last values using pandas.DataFrame.interpolate? I know that this question has been asked before, but the suggested solutions that I found to not work for me. Maybe I am trying to do something that is simply not possible, but let me explain.
I have a time-series data that has some values of 0. I would like to interpolate the zeros in data using pandas.DataFrame.interpolate.
The code:
import pandas as pd
import numpy as np

data = [0, -1.31527, -2.25448, -0.965348, -1.11168, -0.0506046, -0.605522,
        2.01337, 0, 0, 2.41931, 0.821425, 0.402411, 0]

df = pd.DataFrame(data=data) # Data to pandas dataframe
df.replace(to_replace=0, value=np.nan, inplace=True) # Replace 0 by nan
ip = df.interpolate(method="nearest", order=3, limit=None,
                    limit_direction=None)
print(ip)

The result of print(ip):
           0
0        NaN
1  -1.315270
2  -2.254480
3  -0.965348
4  -1.111680
5  -0.050605
6  -0.605522
7   2.013370
8   2.013370
9   2.419310
10  2.419310
11  0.821425
12  0.402411
13       NaN

The problem: Pandas does not interpolate the first and last value of data, but leaves them as zeros. I tried all options of pandas.DataFrame.interpolate out forward and back, but it does not seem to work interpolating the first and last zero of data. Is this simply impossible via Pandas or am I doing something wrong?

A: What you want is an extrapolation, you need to decide on how to do this.
You can ffill/bfill:
ip = (df.interpolate(method="nearest", order=3, limit=None,
                     limit_direction='both')
        .ffill().bfill()
     )

Output:
           0
0  -1.315270
1  -1.315270
2  -2.254480
3  -0.965348
4  -1.111680
5  -0.050605
6  -0.605522
7   2.013370
8   2.013370
9   2.419310
10  2.419310
11  0.821425
12  0.402411
13  0.402411

Or use a spline:
ip = (df.interpolate(method="nearest", order=3, limit=None,
                     limit_direction=None)
        .fillna(
      df.interpolate(method="spline", order=3, limit=None,
                     limit_direction='both')
        )
     )

Output:
           0
0  -0.585237
1  -1.315270
2  -2.254480
3  -0.965348
4  -1.111680
5  -0.050605
6  -0.605522
7   2.013370
8   2.013370
9   2.419310
10  2.419310
11  0.821425
12  0.402411
13 -1.951716

Output:


text:
Q: aligning left and right in same line dynamically asp.net I am Displaying Picture dynamically in gallery ,below picture i displayed product name,product weight , product color, product quality,origin and quantity.It is currently displayed in 6 lines,each item per line...
I want to display two items in each line and 6 item in 3 lines.First item should align left , second item on right on first line and so on.how can i do it? this is my code.

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class jewellery : System.Web.UI.Page
{
    public void select_data()
    {
        //String con_str = @"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\asim\bootstrap1 (1)\App_Data\Database.mdf;Integrated Security=True;User Instance=True";
        String con_str = @"Data Source=KHAN-PC\SQLEXPRESS;Initial Catalog=D:\ASIM\BOOTSTRAP1 (1)\APP_DATA\DATABASE.MDF;Integrated Security=True";
        //string con_str = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\project\App_Data\Database.mdf;Integrated Security=True";
        SqlConnection con = new SqlConnection(con_str);
        con.Open();
        string query = "select * from jewellery1";
        SqlCommand cmd = new SqlCommand(query, con);
        SqlDataReader reader = cmd.ExecuteReader();
        int n = 1;
        String id = "Image";
        while (reader.Read())
        {
            System.Web.UI.HtmlControls.HtmlGenericControl section = new System.Web.UI.HtmlControls.HtmlGenericControl("section");
            section.ID = "portfolio";
            section.Attributes["class"] = "bg-light-gray";
            System.Web.UI.HtmlControls.HtmlGenericControl row = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
            row.Attributes["class"] = "row";
            Byte[] bytes = (Byte[])reader["item_image"];
            String item_name = (String)reader["item_name"];
            String color = (String)reader["item_color"];
            String weight = (String)reader["item_weight"];
            String quality = (String)reader["item_quality"];
            String clarity = (String)reader["item_clarity"];
            String origin = (String)reader["item_origin"];

            System.Web.UI.HtmlControls.HtmlGenericControl createDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
            createDiv.ID = "createDiv" + n + 11;
            System.Web.UI.HtmlControls.HtmlGenericControl createDiv1 =
      new System.Web.UI.HtmlControls.HtmlGenericControl("div");
            System.Web.UI.HtmlControls.HtmlGenericControl hover = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
            hover.Attributes["class"] = "portfolio-hover";
            System.Web.UI.HtmlControls.HtmlGenericControl hover_content = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
            hover_content.Attributes["class"] = "portfolio-hover-content";
            System.Web.UI.HtmlControls.HtmlGenericControl i = new System.Web.UI.HtmlControls.HtmlGenericControl("i");
            i.Attributes["class"] = "fa fa-2x";
            createDiv1.ID = "createDiv" + n + 12;
            createDiv1.Attributes["class"] = "col-md-4 col-sm-6 portfolio-item  zoomIn animated";
            createDiv1.Attributes["data-wow-duration"] = "1500ms";
            createDiv1.Attributes["data-wow-delay"] = "100ms";
            createDiv.Attributes["class"] = "portfolio-caption";
            LinkButton a = new LinkButton();
            a.Attributes["class"] = "portfolio-link";
            a.Attributes["data-toggle"] = "modal";
            a.Click += new EventHandler(test);
            a.CommandArgument = item_name;
            /* System.Web.UI.HtmlControls.HtmlGenericControl a = new System.Web.UI.HtmlControls.HtmlGenericControl("a");
             a.Attributes["class"] = "portfolio-link";
             a.Attributes["data-toggle"] = "modal";*/
            System.Web.UI.HtmlControls.HtmlGenericControl h1 = new System.Web.UI.HtmlControls.HtmlGenericControl("h4");
            System.Web.UI.HtmlControls.HtmlGenericControl h2 = new System.Web.UI.HtmlControls.HtmlGenericControl("h4");
            System.Web.UI.HtmlControls.HtmlGenericControl h3 = new System.Web.UI.HtmlControls.HtmlGenericControl("h4");
            System.Web.UI.HtmlControls.HtmlGenericControl h4 = new System.Web.UI.HtmlControls.HtmlGenericControl("h4");
            System.Web.UI.HtmlControls.HtmlGenericControl h5 = new System.Web.UI.HtmlControls.HtmlGenericControl("h4");
            System.Web.UI.HtmlControls.HtmlGenericControl h6 = new System.Web.UI.HtmlControls.HtmlGenericControl("h4");

                h1.Attributes["align"] = "LEFT";
                h1.Attributes["style"] = "color:black";
                h1.InnerHtml = "Name &nbsp &nbsp :&nbsp &nbsp  " + item_name;
                h2.Attributes["align"] = "RIGHT";
                h2.Attributes["style"] = "color:black";
                h2.InnerHtml = "color  &nbsp &nbsp  &nbsp  &nbsp :&nbsp &nbsp " + color;

            h3.Attributes["align"] = "LEFT";
            h3.Attributes["style"] = "color:black";
            h3.InnerHtml = "Weight &nbsp &nbsp: &nbsp &nbsp " + weight;
            h4.Attributes["align"] = "LEFT";
            h4.Attributes["style"] = "color:black";
            h4.InnerHtml = "Quality   &nbsp&nbsp: &nbsp  " + quality;
            h5.Attributes["align"] = "LEFT";
            h5.Attributes["style"] = "color:black";
            h5.InnerHtml = "Clarity   &nbsp&nbsp: &nbsp  " + clarity;
            h6.Attributes["align"] = "LEFT";
            h6.Attributes["style"] = "color:black";
            h6.InnerHtml = "Origin   &nbsp&nbsp: &nbsp  " + origin;

            System.Web.UI.HtmlControls.HtmlGenericControl hyp = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
            hyp.Attributes["class"] = "portfolio-link";

            System.Web.UI.WebControls.Image tb = new System.Web.UI.WebControls.Image() { ID = "Image" + n + 10 };
            tb.Height = 250;
            tb.Width = 500;
            tb.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(bytes);
            hover_content.Controls.Add(i);
            a.Controls.Add(hover);
            a.Controls.Add(hover_content);
            a.Controls.Add(tb);
            createDiv.Controls.Add(h1);
            createDiv.Controls.Add(h2);
            createDiv.Controls.Add(h3);
            createDiv.Controls.Add(h4);
            createDiv.Controls.Add(h5);
            createDiv.Controls.Add(h6);
            createDiv1.Controls.Add(a);
            createDiv1.Controls.Add(createDiv);
            // row.Controls.Add(createDiv1);
            //section.Controls.Add(row);

            divid1.Controls.Add(createDiv1);
            Console.WriteLine("{0}\t{1}", reader.GetInt32(0),
                reader.GetString(1));
            n++;
        }
    }
    protected void test(object sender, EventArgs e)
    {
        String wagerId = ((LinkButton)sender).CommandArgument;
        Response.Redirect("awesome.aspx?eid=" + wagerId);

    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            select_data();
        }

    }

    protected void Button1_Click(object sender, EventArgs e)
    {

    }
}

Updated Code
Bro your code didn't work. I tried this way,its working somehow fine . It displays H1  on left ,H2  on right.thats fine but it also displays h3 in center,as it should be on next line.how can I resolve it.

 h1.Attributes["class"] = "links left";
                h1.Attributes["style"] = "color:black";
                h1.InnerHtml = "Name &nbsp &nbsp :&nbsp &nbsp  " + item_name;
                h2.Attributes["class"] = "links right";
                h2.Attributes["style"] = "color:black";
                h2.InnerHtml = "color  &nbsp &nbsp  &nbsp  &nbsp :&nbsp &nbsp " + color;

            h3.Attributes["class"] = "links right";
            h3.Attributes["style"] = "color:black";
            h3.InnerHtml = "Weight &nbsp &nbsp: &nbsp &nbsp " + weight;
            h4.Attributes["align"] = "LEFT";
            h4.Attributes["style"] = "color:black";
            h4.InnerHtml = "Quality   &nbsp&nbsp: &nbsp  " + quality;

  <style>
.mainlinks
    {
    text-align:right;
    margin-top:3px;
    margin-right:10px;
    margin-bottom:0px;
    padding:0px;
    }

 a.links:link {
    color: #FF0000; text-decoration: none;
    text-align:left;
    margin-left:8px;
    margin-top:300px;
    margin-bottom:0px;
    padding:2px;
    font-family:Arial, Helvetica, sans-serif;
    font-size: 14px;
    }

.right { float: right }
.left { float: left }

</style>

A: Use the following code. I've removed Attributes["align"] = "LEFT" part and added float: left;width: 50%;. Adjust the width percentage according to your needs.
h1.Attributes["style"] = "color:black;float: left;width: 50%; ";
 h1.InnerHtml = "Name &nbsp &nbsp :&nbsp &nbsp  " + item_name;

 h2.Attributes["style"] = "color:black;float: left;width: 50%; ";
 h2.InnerHtml = "color  &nbsp &nbsp  &nbsp  &nbsp :&nbsp &nbsp " + color;

 h3.Attributes["style"] = "color:black;float: left;width: 50%; ";
 h3.InnerHtml = "Weight &nbsp &nbsp: &nbsp &nbsp " + weight;

 h4.Attributes["style"] = "color:black;float: left;width: 50%; ";
 h4.InnerHtml = "Quality   &nbsp&nbsp: &nbsp  " + quality;

 h5.Attributes["style"] = "color:black;float: left;width: 50%; ";
 h5.InnerHtml = "Clarity   &nbsp&nbsp: &nbsp  " + clarity;

 h6.Attributes["style"] = "color:black;float: left;width: 50%; ";
 h6.InnerHtml = "Origin   &nbsp&nbsp: &nbsp  " + origin;

UPDATE (Commented out the variables for adjusting in my VS)
var n = 1;
            while(n < 5) {
                System.Web.UI.HtmlControls.HtmlGenericControl createDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                createDiv.ID = "createDiv" + n + 11;
                System.Web.UI.HtmlControls.HtmlGenericControl createDiv1 =
          new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                System.Web.UI.HtmlControls.HtmlGenericControl hover = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
                hover.Attributes["class"] = "portfolio-hover";
                System.Web.UI.HtmlControls.HtmlGenericControl hover_content = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
                hover_content.Attributes["class"] = "portfolio-hover-content";
                System.Web.UI.HtmlControls.HtmlGenericControl i = new System.Web.UI.HtmlControls.HtmlGenericControl("i");
                i.Attributes["class"] = "fa fa-2x";
                createDiv1.ID = "createDiv" + n + 12;
                createDiv1.Attributes["class"] = "col-md-4 col-sm-6 portfolio-item  zoomIn animated";
                createDiv1.Attributes["data-wow-duration"] = "1500ms";
                createDiv1.Attributes["data-wow-delay"] = "100ms";
                createDiv.Attributes["class"] = "portfolio-caption";
                LinkButton a = new LinkButton();
                a.Attributes["class"] = "portfolio-link";
                a.Attributes["data-toggle"] = "modal";
                //a.Click += new EventHandler(test);
                //a.CommandArgument = item_name;
                /* System.Web.UI.HtmlControls.HtmlGenericControl a = new System.Web.UI.HtmlControls.HtmlGenericControl("a");
                 a.Attributes["class"] = "portfolio-link";
                 a.Attributes["data-toggle"] = "modal";*/
                System.Web.UI.HtmlControls.HtmlGenericControl h1 = new System.Web.UI.HtmlControls.HtmlGenericControl("h4");
                System.Web.UI.HtmlControls.HtmlGenericControl h2 = new System.Web.UI.HtmlControls.HtmlGenericControl("h4");
                System.Web.UI.HtmlControls.HtmlGenericControl h3 = new System.Web.UI.HtmlControls.HtmlGenericControl("h4");
                System.Web.UI.HtmlControls.HtmlGenericControl h4 = new System.Web.UI.HtmlControls.HtmlGenericControl("h4");
                System.Web.UI.HtmlControls.HtmlGenericControl h5 = new System.Web.UI.HtmlControls.HtmlGenericControl("h4");
                System.Web.UI.HtmlControls.HtmlGenericControl h6 = new System.Web.UI.HtmlControls.HtmlGenericControl("h4");

                h1.Attributes["style"] = "color:black;float: left;width: 50%; ";
                    h1.InnerHtml = "Name &nbsp &nbsp :&nbsp &nbsp  " + "item_name";

                h2.Attributes["style"] = "color:black;float: left;width: 50%; ";
                    h2.InnerHtml = "color  &nbsp &nbsp  &nbsp  &nbsp :&nbsp &nbsp " + "color";

                h3.Attributes["style"] = "color:black;float: left;width: 50%; ";
                    h3.InnerHtml = "Weight &nbsp &nbsp: &nbsp &nbsp " + "weight";

                h4.Attributes["style"] = "color:black;float: left;width: 50%; ";
                    h4.InnerHtml = "Quality   &nbsp&nbsp: &nbsp  " + "quality";

                h5.Attributes["style"] = "color:black;float: left;width: 50%; ";
                    h5.InnerHtml = "Clarity   &nbsp&nbsp: &nbsp  " + "clarity";

                h6.Attributes["style"] = "color:black;float: left;width: 50%; ";
                    h6.InnerHtml = "Origin   &nbsp&nbsp: &nbsp  " + "origin";

                System.Web.UI.HtmlControls.HtmlGenericControl hyp = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
                hyp.Attributes["class"] = "portfolio-link";

                System.Web.UI.WebControls.Image tb = new System.Web.UI.WebControls.Image() { ID = "Image" + n + 10 };
                tb.Height = 250;
                tb.Width = 500;
                tb.ImageUrl = "data:image/png;base64," /*+ Convert.ToBase64String(bytes)*/;
                hover_content.Controls.Add(i);
                a.Controls.Add(hover);
                a.Controls.Add(hover_content);
                a.Controls.Add(tb);
                createDiv.Controls.Add(h1);
                createDiv.Controls.Add(h2);
                createDiv.Controls.Add(h3);
                createDiv.Controls.Add(h4);
                createDiv.Controls.Add(h5);
                createDiv.Controls.Add(h6);
                createDiv1.Controls.Add(a);
                createDiv1.Controls.Add(createDiv);
                // row.Controls.Add(createDiv1);
                //section.Controls.Add(row);

                divid1.Controls.Add(createDiv1);
                n++;
            }


text:
Q: missing a step ? what needs to be filled in the argument of loadLibrary() These are the incomplete steps that i have followed to call a native function from a java program.

*

*Wrote a java program and then compiled to the .class file

*From the command javah - jni i generated a header file with the same name as .class file.

*After that i opened a Microsoft Visual C++ Express , started a new project and set my application type to dll.

This is the java program that calls the native c method.
class HelloWorld {

private native void print();

public static void main( String args[] ) {
  new HelloWorld().print();
}

static {
  System.loadLibrary("??"); // what should i write here ?
}

}
And this is the c program
#include <jni.h>
#include <stdio.h>
#include "HelloWorld.h"

JNIEXPORT void JNICALL
Java_HelloWorld_print( JNIEnv *env , jobject obj) {
  printf("Hello World!\n");
  return;
}

I kept the project name as jni tester and the c file name is HelloWorld.c
In the statement System.loadLibrary(??) What should be the name of the library in the argument ? (Or is there any step that i am missing before i can fill the argument of loadLibrary)
If so what is that i am missing ?

A: From that function's documentation
System.loadLibrary:

Parameters:
libname - the name of the library.

You pass it the name of your DLL. (That is, the DLL's filename without the .dll extension. On Unix-like systems, it would be the shared object name without the lib prefix or the .so (or .o for some platforms) extension.)
Make sure your JVM can find the DLL in its library path. To change the library path, you can use the java.library.path system property like this:
java -Djava.library.path=directory_where_your_dll_resides ...

[Doing this and dropping the extension from the library name keeps the java side of your code as portable as possible. You'll be able to move it as-is to another platform, only needing to rebuild the JNI part for that target.]

A: The library name is the name of the DLL file, without its .dll extension. The DLL must be in one of the directories of the windows PATH environment variable to be loaded.

A: Pass the name of the library. You may omit the .dll extension, or you may include it.
If you specify just a filename with no path component, then the library search path will be used to search for the library.
Alternatively, you may prefer to specify the full path to the file which you can do. This latter approach is often preferable because it allows you to have precise control over where the library is loaded from.


text:
Q: QGIS on UHD screen I've got a new laptop that came with a 4k UHD screen. The GUI on QGIS doesn't scale well making most of the menu elements too small to easily see.
Is there a way to change the scale of the gui?

A: As @Dave Pitman points out in his answer, that a user, Stu Smith, got the manifest hack to work.
I actually got it to work too. Follow the instructions using the link:
http://www.danantonielli.com/adobe-app-scaling-on-high-dpi-displays-fix/
Once the manifest.txt file is downloaded, copy it to the QGIS bin folder. In my case:
C:\Program Files\QGIS 2.18\bin

and rename it to 'qgis-bin.exe.manifest'.
Additionally, you'll need to ensure display scaling is disabled.
To do this, you'll need a shortcut to 'QGIS Desktop', for example, by pinning it to the Windows taskbar.
Right click the QGIS icon, then right click 'QGIS Desktop 2.18.3' in my case, and select 'Properties'.
Click the 'Compatibility' tab, and uncheck 'Disable display scaling on high DPI settings'.
There's a minor niggle that the text and icons are not as sharp as they would be otherwise, apart from that the hack works pretty well.
Update:
For the Windows 10 Creators update, in the 'Compatibility' tab, check 'Override high DPI scaling behaviour. Scaling performed by:', and then select 'System' from the drop-down menu.

A: I've tried all of the scaling remedies I could find and so far,  QGIS is not workable on an UHD Windows 10.
For other applications with similar issues,  the "manifest" hack has worked pretty well.
http://www.danantonielli.com/adobe-app-scaling-on-high-dpi-displays-fix/
This is working acceptably.  The manifest file must be spelled perfectly  'qgis-bin.exe.manifest'.

A: Go to Settings >>> Options >> General Menu > Icon Size
Check this below:
http://docs.qgis.org/2.2/en/docs/user_manual/introduction/qgis_configuration.html

A: This is a screenshot of the settings area where you change icon size.

A: I want to highlight the update from @ccoder83 because I think this is the best and simplest solution for Windows 10 Creators update (and later). It deserves its own answer, IMO. I missed the update until after i messed around in the registry and manifest file.
Right click on qgis-bin.exe and go to properties. In the 'Compatibility' tab, check 'Override high DPI scaling behaviour. Scaling performed by:', and then select 'System' from the drop-down menu.
If using OSGEO4W, qgis-bin is mostly likely at "C:\OSGeo4W64\bin"

A: Here a batch code to create regedit key and auto generate manifest file.
Put this code to a .bat file and execute it as administrator.
@echo off
chcp 65001
setLocal EnableDelayedExpansion

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide" /v PreferExternalManifest /t REG_DWORD /d 0x00000001 /f

set /p path="Please, enter full path to the .exe file: "

echo "%path%"

>"%path%.manifest" (
    echo:^<?xml version=^"1.0^" encoding=^"UTF-8^" standalone=^"yes^"?^>
    echo:
    echo:^<assembly xmlns=^"urn:schemas-microsoft-com:asm.v1^" manifestVersion=^"1.0^" xmlns:asmv3=^"urn:schemas-microsoft-com:asm.v3^"^>
    echo:
    echo:^<dependency^>
    echo:  ^<dependentAssembly^>
    echo:    ^<assemblyIdentity
    echo:      type=^"win32^"
    echo:      name=^"Microsoft.Windows.Common-Controls^"
    echo:      version=^"6.0.0.0^" processorArchitecture=^"*^"
    echo:      publicKeyToken=^"6595b64144ccf1df^"
    echo:      language=^"*^"^>
    echo:    ^</assemblyIdentity^>
    echo:  ^</dependentAssembly^>
    echo:^</dependency^>
    echo:
    echo:^<dependency^>
    echo:  ^<dependentAssembly^>
    echo:    ^<assemblyIdentity
    echo:      type=^"win32^"
    echo:      name=^"Microsoft.VC90.CRT^"
    echo:      version=^"9.0.21022.8^"
    echo:      processorArchitecture=^"amd64^"
    echo:      publicKeyToken=^"1fc8b3b9a1e18e3b^"^>
    echo:    ^</assemblyIdentity^>
    echo:  ^</dependentAssembly^>
    echo:^</dependency^>
    echo:
    echo:^<trustInfo xmlns=^"urn:schemas-microsoft-com:asm.v3^"^>
    echo:  ^<security^>
    echo:    ^<requestedPrivileges^>
    echo:      ^<requestedExecutionLevel
    echo:        level=^"asInvoker^"
    echo:        uiAccess=^"false^"/^>
    echo:    ^</requestedPrivileges^>
    echo:  ^</security^>
    echo:^</trustInfo^>
    echo:
    echo:^<asmv3:application^>
    echo:  ^<asmv3:windowsSettings xmlns=^"http://schemas.microsoft.com/SMI/2005/WindowsSettings^"^>
    echo:    ^<ms_windowsSettings:dpiAware xmlns:ms_windowsSettings=^"http://schemas.microsoft.com/SMI/2005/WindowsSettings^"^>false^</ms_windowsSettings:dpiAware^>
    echo:  ^</asmv3:windowsSettings^>
    echo:^</asmv3:application^>
    echo:
    echo:^</assembly^>
)

echo "manifest file generated !"

pause >nul


text:
Q: Why is Bash not recognising my variable as a string? I've made a bash script. Let's call it "runner.sh". Inside it I'm running omxplayer with some flags.
omxplayer $TARGETFOLDER/*.mp4

This works fine. Now let's resize and position the video.
omxplayer —win "0 0 640 480" $TARGETFOLDER/*.mp4

This too works fine. Now let's try to put the "win flag" in a variable. I'm escaping the quote.
SizeAndPosition="—win \"0 0 640 480\""

Allright, now I'm trying it out.
omxplayer $SizeAndPosition $TARGETFOLDER/*.mp4

Nope, doesn't work. I get the error File "0" not found. Just to be sure, I print the whole command to the screen.
echo "omxplayer $SizeAndPosition $TARGETFOLDER/*.mp4"

… and I get the output…
omxplayer —win "0 0 640 480" /homefolder/*.mp4

Why doesn't it recognise my variable as any other string in the command? Can I do something about it?
EDIT: Sorry about the confusion. The question is about SizeAndPosition, why is it not treated as an argument?

A: Instead of storing the command arguments in a variable, use an array:
SizeAndPosition=(-win '0 0 640 480')
omxplayer "${SizeAndPosition[@]}" "$TARGETFOLDER"/*.mp4


text:
Q: Strategy pattern in domain model I am encountering an example where the strategy pattern in a domain model should be used. I have a User class representing users of the system. Each user may receive requests while using the system. Upon reception of a request, some processing logics are possible:

*

*Automatically remove the requests

*Notify the user about the received request

*etc...

In this case, it seems that the strategy pattern is adapted. I have an interface called RequestReceivedPolicy with multiple classes that implement this interface (i.e. one class per processing logic). The User class holds a reference on one instance of the class corresponding to the selected policy.
This seems right on the object side. My question concerns the persistence side which, in my case, is a relational database. A user selects a policy through the a management interface. I want to persist this choice so that next time the user login, this information is saved. I thought about persisting the instance hold by the User class but I don't think it's the right way, since this instance is more about logic than data.
Thanks

EDIT:
public RequestReceivedPolicy {
    public boolean processRequest();
}

public IgnoreRequestPolicy implements RequestReceivedPolicy {
    public boolean processRequest(){
       //ignore logic
    }
}

public CustomRequestPolicy {
    private int someData1;
    private String someData2;

    public boolean processRequest(){
       //custom logic that uses someData1 and someData2
    }
}

A: The location of the policy choice persistance depends on where/how that policy gets passed in or configured into your User class, and you didn't really ellaborate that.
If, for example, your User class has something like this:
class User
{
   // policy is passed in during ctor
   public User(object otherArgs, RequestReceivedPolicy policy)
   {
   }
}

...then the class responsible for creating the User would likely have to maintain that preference external to User.
Similarly, if the User object simple holds the RequestReceivedPolicy reference like this:
class User
{
   public User(object otherArgs)
   {
   }

   public void setPolicy(RequestReceivedPolicy policy)
   {
      _currPolicy = policy;
   }

   public RequestReceivedPolicy getPolicy()
   {
      return _currPolicy;
   }

}

...and the User class has no way to set its own Policy object then, again, you have to rely on an external entity to persist the policy choice.
If instead the policy selection is "pulled" into the User class like this:
class User
{
   public User(object otherArgs, RequestReceivedPolicyProvider policyProvider)
   {
   }

   public void someStimulii(object criteria, ...)
   {
      _currPolicy = _policyProvider.getPolicy(criteria);
   }

}

...or this...
class User
{
   public User(object otherArgs)
   {
   }

   public void someStimulii(object criteria, ...)
   {
      _currPolicy = PolicyProvider.getInstance().getPolicy(criteria);
   }

}

...then the User object should persist its selection so that it can pull that policy object when it is recreated/constructed again later.  In this case, it is the "criteria" that would need to be persisted, and it might be helpful if the RequestReceivedPolicy had an additional method to return that criteria:
RequestReceivedPolicyConfig policyConfig =  _currPolicy.getConfiguration();

The RequestReceivedPolicyConfig object should be opaque to the User object, but internally perhaps be  simple dictionary that supports persistance.  Then the User can pass it to the persistence layer without knowing much about it.  When pulling it from the persistence layer, it is used to reinstall the RequestReceivedPolicy using the provider.  At a minumum, each RequestReceivedPolicyConfig object would contain the class identity of the  RequestReceivedPolicy.
It is possible to have a hybrid, where the Policy is pushed via set/get but the User object can also pull in a new policy via  something like the above PolicyProvider.getInstance().getPolicy(criteria) then you still allow the User object to take advantage of the RequestReceivedPolicyConfig based approach or keep persistence external.


text:
Q: Advice on using crontab with bash I want to make a cron job that checks if a folder exists, and it if does to delete all the contents of that folder. For example, I know that the following will delete the contents of my folder in using cron:
0 * * * * cd home/docs/reports/;rm -r *

However, I realized that if the folder is removed (or the wrong file path is given) instead of the contents of that folder being deleted, cd fails and all files are deleted on my operating system. To prevent this from happening (again) I want to check for the existence of the folder first, and then to delete the contents. I want to do something like the following, but I'm not sure how to use a bash script with cron.
if [ -d "home/docs/reports/" ]; then
    cd home/docs/reports/;rm -r *
fi

I'm new to bash and cron (in case it is not obvious).

A: I think cron uses /bin/sh to execute commands.  sh is typically a subset of bash, and you're not doing anything bash-specific.
Execute the rm command only if the cd command succeeds:
0 * * * * cd home/docs/reports/ && rm -r *

NOTE Please wait a few minutes while I test this.  If this note is gone, I've tried it and it works.
Yes, it works.  (Note that testing whether the directory exists is less reliable; it's possible that the directory exists but you can't cd into it, or it might cease to exist between the test and the cd command.)
But actually you don't need to use a compound command like that:
 0 * * * * rm -r home/docs/reports/*

Still the && trick, and the corresponding || operator to execute a second command only if the first one fails, can be very useful for more complicated operations.
(Did you mean /home/docs rather than home/docs?  The latter will be interpreted relative to your home directory.)
Though this worked ok when I tried it, use it at your own risk.  Any time you combine rm -r with wildcards, there's a risk.  If possible, test in a directory you're sure you don't care about.  And you might consider using rm -rf if you want to be as sure as possible that everything is deleted.  Finally, keep in mind that the * wildcard doesn't match files or directories whose names start with ..
#include <stddisclaimer.h>

EDIT :
The comments have given me a better understanding of what you're trying to do.  These are files that users are going to download shortly after they're created (right?), so you don't want to delete anything less than, say, 5 minutes old.
Assuming you have GNU findutils, you can do something like this:
0 * * * *  find /home/docs/reports/* -cmin +5 -delete 2>/dev/null

Using the -delete option to find means you're deleting files and/or directories one at a time, not deleting entire subtrees; the main difference is that an old directory with a new file in it will not be deleted.  Applying -delete to a non-empty directory will fail with an error message.
Read the GNU find documentation (info find) for more information on the -cmin and -delete options.  Note that -ctime operates on the time of the last status change of the file, not its creation time (Unix doesn't record file creation times).  For your situation, it's likely to be the same.
(If you omit the /* on the path, it will delete the reports directory itself.)

A: Wrap your entire command (including the if logic) into a script.sh.
Specify #!/bin/bash at the top of your script.
Make it executable:
chmod +x script.sh

Then specify the full path of the script in your cron job.

A: Easiest thing by far is to do SHELL=/bin/bash at the top of your crontab.  Works for me.


text:
Q: WebLogic cluster, determine node from JSESSIONID cookie We are running a WebLogic 10.3.4 cluster with three managed servers (nodes). We do not use session stickyness, but session replication across the cluster and everything is working fine. When trying to test our web application however, we regularly try to figure out on which node the user currently is (in order to find the correct log files).
The JSESSIONID cookie has the format:
sessionid!primary_server_id!secondary_server_id

as specified in the official WLS Cluster Documentation.
Is there any way to determine the current cluster node given the server IDs from the session cookie?
I know there are alternatives like
* log aggregation
* rendering a hash inside our page templates which allows identification
and possibly others. But I would like to find a minimally invasive solution if possible since any change in software setup and application code may prove difficult.

A: Not directly in Weblogic, AFAIK.
If you have an Apache web server (or a similar proxy) fronting the Weblogic cluster, it does log the individual server HASH and map it to the Managed server, and is able to send it to the same weblogic managed server as the previous request.
As described by an old BEA page, you can enable debug logging:
Debug ALL
DebugConfigInfo ON
WLLogFile /tmp/wlproxy.log

Sample log content:
Mon May 10 13:14:40 2004 getpreferredServersFromCookie: -2032354160!-457294087
Mon May 10 13:14:40 2004 GET Primary JVMID1: -2032354160
Mon May 10 13:14:40 2004 GET Secondary JVMID2: -457294087
Mon May 10 13:14:40 2004 [Found Primary]: 172.18.137.50:38625:65535
Mon May 10 13:14:40 2004 list[0].jvmid: -2032354160
Mon May 10 13:14:40 2004 secondary str: -457294087
Mon May 10 13:14:40 2004 list[1].jvmid: -457294087
Mon May 10 13:14:40 2004 secondary str: -457294087
Mon May 10 13:14:40 2004 [Found Secondary]: 172.18.137.54:38625:65535
Mon May 10 13:14:40 2004 Found 2 servers

This info is also available on MOS; search for document 780007.1.


text:
Q: EXCEL - Error while opening excel workbook I have Office 2007.
Each time I launch Excel, or open an existing file, it tries to access some old file and I get the following error pop up:
'E:\xyz.txt' could not be found. Check the spelling of the file name, and verify that the file location is correct.
If you are trying to open the file from your list of most recently used files, make sure that the file has not been renamed, moved, or deleted.
Please help on this.
Thanks in advance!

A: Maybe you have an old add-in still active?
Developer > Add-Ins
if you see any custom add-ins, deactivate them and see if the problem remains.
Alternatively you could check in the VBA window what xla / xlam files are active and see if the file you mention is hiding somewhere in the code thereof


text:
Q: QGIS Proportional Circles I'm having a bit of an issue with the proportional circle plugin for QGIS. I want to be able to adjust the start size of the circle but for the life of me I can not figure it out but I was able to do it on a previous map that I worked on. I'm on a Mac using QGIS 2.8.4. I also need to label the circle with a numerical value which I have been about to do but I need to reduce the starting size of the circle.

A: I don't use the proportional circles plugin bu can suggest an alternative method which will give you the control you need (and without creating another layer):

*

*In your polygon style, add another symbol layer

*Change the symbol layer from 'simple fill' to 'centroid fill'

*Select the new 'simple marker' (you may need to expand down from 'Centroid Fill' in the symbol layers window) and set the size to be proportional by clicking the Data Defined Override button at the right hand end of the size box.  Select Edit from the Expression section of the popup menu and create a formula.  To define a start size simple begin you formula with a numeric value (or field value).  So for hectares you could have an expression something like: 10 + (area/10000).

*Style the resultant markers to taste for transparency etc (you'll be able to make them identical to the ones in your image)

*Control the overall size of the markers by tweaking the formula and/or switching between millimeter or pixels etc.


text:
Q: get data from 2 mysql tables with php I have 2 tables, contacts and contacts_group. contacts has (id, name, lastname, email,), contacts_group has (id, owner, mail, group_name). How can i select this together with php.

A: You should have a foreign key in contacts which refers to id in contacts_group, then you can do something like this:
SELECT * FROM contacts_group cg JOIN contacts c ON c.id_group = cg.id

You should read about relationships in MySQL ;)

A: Hans, you could use two different queries:
$contactsquery = "SELECT * FROM contacts";
$contacts_group_query = "SELECT * FROM contacts_group";

Of course you would need a DB Connection on top:
define("DB_SERVER","localhost");
define("DB_USER","chatApp");
define("DB_PASS","ibmpass");
define("DB_NAME","chatApp");

$connection = mysqli_connect(DB_SERVER,DB_USER,DB_PASS,DB_NAME);

And to perform them you would use
$result_1 = mysqli_query($connection, $contactsquery);
$result_2 = mysqli_query($connection, $contacts_group_query);

Or you could create a foreign key on the contacts_group to keep track of the contacts, and then join them in code as:
SELECT * FROM contacts_group cg JOIN contacts c ON c.id_group = cg.id

But I would highly recommend you to read this basic introduction to PHP & Queries before getting deeper, as you will have many doubts about it.


text:
Q: how to use $timeout in ng-click markup I want to wait some time after click, then processed.
i tried:
<button ng-click="$timeout(save,500);">Save<button>

controller
$scope.save = function() {
      // save.
}

no error in console.
what i doing wrong?

A: As 'Paolo Moretti' said, the way to use $timeout in ng-click markup is attach the $timeout service to $scope.
HTML
<button ng-click="$timeout(save,500);">Save<button>

Javascript
$scope.$timeout = $timeout; // must be injected in controller.
$scope.save = function() {
      // save.
}

A: Move the code to your controller:
<button ng-click="clickHandler()">DO-IT<button>

$scope.clickHandler = function() {
   $timeout($scope.save, 500);
}

$scope.save = function() {
   // save
}


text:
Q: Python ProgressBar & GUI frozen while calculation for plot is going on Can somebody help me out with threading in python and getting a progress bar working?
Even research gives quite a lot results, i cannot get it working.
I never did threading before and i cannot tell where to put things correctly.
For testing purposes i prepared a simple GUI with a button and a progress bar:

After clicking the button a simple 3d plot will pop-up.
Such plotting may take some computation time and while a user need to wait, id like to have the GUI not frozen and the progressbar animated.
At the moment the GUI freezes until the plot will show up. And after that the progress bar start the animation.
I have read a lot about threading and to put calculations and gui to different threads?
But im just to noobish to get it working.
Is somebody able to explain me more, direct me to similar problems or documentations?
Or maybe, in case is quickly solved, overtake the simple code and correct it the way it should be?
Thanks in advance for any kind of help.
Python script so far:
from time import sleep
from tkinter import EW
import ttkbootstrap as ttk
import numpy as np
import matplotlib.pyplot as plt

def main():

    def plot_sample():

        sleep(5) # simulate calculation times
        x = np.outer(np.linspace(-2, 2, 30), np.ones(30))
        y = x.copy().T # transpose
        z = np.cos(x ** 2 + y ** 2)

        fig = plt.figure()
        ax = plt.axes(projection='3d')

        ax.plot_surface(x, y, z,cmap='viridis', edgecolor='none')
        ax.set_title('Surface plot')
        plt.show()

    def progressbar_start():
        progressbar.grid(row=1, column=0, sticky=EW, padx=10, pady=10) # let progressbar appear in GUI
        progressbar.start(interval=10)

    def progressbar_stop():
        progressbar.stop()
        progressbar.grid_forget() # hide progressbar when not needed

    def button_clicked():
        progressbar_start()  # start progressbar before computation begins
        plot_sample() # plotting
        progressbar_stop()  # stop progressbar after plot is done

    # GUI
    # window size and settings
    root = ttk.Window()

    # Basic settings for the main window
    root.title('Test progressbar')
    root.minsize(300, 200)
    root.resizable(True, True)
    root.configure(bg='white')

    # grid settings for the main window in which LabelFrames are sitting in
    root.columnconfigure(0, weight=1)
    root.rowconfigure(0, weight=1)
    root.rowconfigure(1, weight=1)

    # Button fto show 3d-plot
    button_calc_3dplot = ttk.Button(root, text='Calculate 3D Plot', command=button_clicked)
    button_calc_3dplot.grid(row=0, column=0, padx=5, pady=5)

    progressbar = ttk.Progressbar(style='success-striped', mode='indeterminate')

    # end of GUI
    root.mainloop()

if __name__ == "__main__":
    main()

A: I have one solution. The main problem is, that You can't run the plt.show() function in a Thread. From this follows, that you can't run the window and the plt.show function at the same time.
from time import sleep
from tkinter import EW
import ttkbootstrap as ttk
import numpy as np
import matplotlib.pyplot as plt
from threading import Thread

x, y, z = None, None, None

def main():
    def calculate_xyz():
        sleep(5)  # simulate calculation times
        global x, y, z
        x = np.outer(np.linspace(-2, 2, 30), np.ones(30))
        y = x.copy().T  # transpose
        z = np.cos(x ** 2 + y ** 2)

    def progressbar_start():
        progressbar.grid(row=1, column=0, sticky=EW, padx=10, pady=10)  # let progressbar appear in GUI
    progressbar.start(interval=10)

    def progressbar_stop():
        progressbar.stop()
        progressbar.grid_forget()  # hide progressbar when not needed

    def button_clicked():
        progressbar_start()  # start progressbar before computation begins
        calculate_xyz_thread = Thread(target=calculate_xyz)
        calculate_xyz_thread.start()  # calculate x, y and z
        root.after(500, wait_for_plotting)  # wait for plotting and stop animation after finishing

    def wait_for_plotting():
        if x is None or y is None or z is None:
            root.after(500, wait_for_plotting)  # run self again
            return  # wait for calculation
        # calculation is finished
        progressbar_stop()  # stop progressbar "after" plot is done
        ax = plt.axes(projection='3d')
        ax.plot_surface(x, y, z, cmap='viridis', edgecolor='none')
        ax.set_title('Surface plot')
        root.after(500, plot_3d)

    def plot_3d():
        plt.show()

    # GUI
    # window size and settings
    root = ttk.Window()

    # Basic settings for the main window
    root.title('Test progressbar')
    root.minsize(300, 200)
    root.resizable(True, True)
    root.configure(bg='white')

    # grid settings for the main window in which LabelFrames are sitting in
    root.columnconfigure(0, weight=1)
    root.rowconfigure(0, weight=1)
    root.rowconfigure(1, weight=1)

    # Button fto show 3d-plot
    button_calc_3dplot = ttk.Button(root, text='Calculate 3D Plot', command=button_clicked)
    button_calc_3dplot.grid(row=0, column=0, padx=5, pady=5)

    progressbar = ttk.Progressbar(style='success-striped', mode='indeterminate')

    # end of GUI
    root.mainloop()

if __name__ == "__main__":
    main()


text:
Q: Why I can not get checkbox length while using it differently? Here is my code:
HTML:
<form name="frm1">
    <input type="checkbox" id="chk1" name="chk1[]"  value="1"/>
    <input type="checkbox" id="chk1" name="chk1[]"  value="2"/>
</form>
<button class="test1">Test 1</button>

<form name="frm2">
    <input type="checkbox" id="chk2" name="chk2[]"  value="1"/>
    <!--<input type="checkbox" id="chk2" name="chk2[]"  value="2"/>-->
</form>
<button class="test2">Test 2</button>

<form name="frm3">
    <input type="checkbox" name="chk3[]"  value="1"/>
    <input type="checkbox" name="chk3[]"  value="2"/>
</form>
<button class="test3">Test 3</button>

SCRIPT:
$('button.test3').click(function (){
    alert(document.frm3.chk3.length);// Gives error: document.frm3.chk3 is undefined
});

$('button.test2').click(function (){
    alert(document.frm2.chk2.length);// Outputs: undefined
});

$('button.test1').click(function (){
    alert(document.frm1.chk1.length);// Gives 2 as expected
});

Fiddle: http://jsfiddle.net/mgsvy/
If I can access a form by name and its elements then the why the above will give unexpected results?

A: You need to use alert(document.frm3["chk3[]"].length);
document.frm3 uses name property to identify the elements, in your case the name of the check box is chk3[] so you need to use document.frm3["chk3[]"]
Demo: Fiddle

A: You can use document.frm3['chk3[]'].length or document.getElementsByName property
like this,
document.getElementsByName('chk1[]').length

document.getElementsByName('chk2[]').length

document.getElementsByName('chk3[]').length

Live DEMO

A: The waterproof way to do it, is here: http://jsfiddle.net/mgsvy/2/
I removed the id's on the checkboxes, because you used the same id on multiple elements, which is why you got inconsistent behaviour. Because of the brackets in the name, you would have to use bracket notation to reference to that specific name.
If there is only one element with that name, it is stored as a node instead of a nodelist, which does not have a length property and undefined is returned.  The || 1 makes sure that you still get a proper output.
alert(document.frm2['chk2[]'].length || 1);


text:
Q: Command '['git', 'rev-parse', 'HEAD^1']' returned non-zero exit status 128 I am a beginner in embedded programming and trying to set up a workflow where the code sizes are automatically put in database and compared with the previous revision. Beginner on Github as well obviously.
I am trying to have a python script called by a Github Action.
So here is the action:
- name: Stamp revision
        working-directory: cobrax
        continue-on-error: True
        run: |
          pip install psycopg2-binary
          pip install click
          pip install prettytable
          python3 codesizes.py stamp build/zephyr/zephyr.elf

And here is the problematic line in the python code, where I am trying to fetch the parent revision:
    revision = subprocess.check_output(
        ["git", "rev-parse", "{}".format(revision)], encoding="UTF-8"
    ).strip()
    parent_revision = subprocess.check_output(
        ["git", "rev-parse", "{}^1".format(revision)], encoding="UTF-8"
    ).strip()

Now, for revision that works perfectly. But, just because of the '^1' for parent revision, I keep getting the following error message from the github action:
subprocess.CalledProcessError: Command '...' returned non-zero exit status 128

So, I tried a few things, notably:
["git", "rev-parse", "{}^".format(revision)], encoding="UTF-8"
    ).strip()

["git", "rev-list", "--parents", "-n", "1", revision, "|", "cut", "-d'", "'", "-f2-"], encoding="UTF-8"

But, the error comes from elsewhere. As I am a beginner, I wish someone would explain it to me because that obviously comes the virtual environment thing for github actions because on my ubuntu VM in the repo I don't have that problem.
Thank you for your help.

A: After some research, it turns out that the actions/checkout@v2 that I use defaults to a shallow --depth=1 clone. This allows me to use HEAD but NOT HEAD^
With my workflow configured as such:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 2

Everything works !


text:
Q: How to avoid ConcurrentModificationExceptions when using EJB3.1 @Asynchronous [My Setup: Java EE 6 application, with EJB3.1, CDI/Weld, JSF2 running on Glassfish 3.0.1]
I read some articles about the new @Asynchronous methods in EJB3.1, but none of them mentioned the dangers of asynchronous methods and what you really have to care about.
In my app i'm having an @Asynchronous E-Mail service, sending lots of mails. I'm calling this Service from a CDI/Weld Bean. During my tests, i often experienced ConcurrentModificationExceptions, but until now i don't really understand where and why it crashes sometimes.
Just to show how my Beans roughly  look like, the important parts:
@Stateful @LocalBean
public class EmailEJB {
  //... Injections

  @Asynchronous
  public Future<Integer> sendEmails(User user, Message message) {
    // ... send mails
    return new AsyncResult<Integer>(1);
  }
}

In my CDI-Bean, i'm using this EJB like this (exposing progress to JSF2):
@Named @SessionScoped
public class MessageManager {
  @EJB
  public EmailEJB emailEJB;

  public FutureEJB<Integer> progress;

  public Integer getProgress() {
    if (progress == null) return 0;
    else {
      return progress.get();
    }
  }

  public String sendMessage() {
    (...)
    progress = emailEJB.sendEmails(user, message);
    (...)
  }
}

I just wanted to ask in general: am i doing something completely wrong here (Scopes, injections, using Future)? What do i have to care for when using @Asynchronous methods, to avoid ConcurrentModificationExceptions?
I'm injecting the Email as an EJB. Will it be better to make the whole EmailEJB Asynchronous and inject it with @Inject @Asynchronous? What would be the difference?
Any hints welcome!

A: Your usage of the asynchronous method should have been fine, though I wonder if you really want it to be @Stateful.  Sounds like state inside the @Stateful bean is being modified (or iterated over) in another thread when the @Asynchronous method is being invoked.  This can happen if the @Stateful bean has say a List field and a reference to that list is passed outside of the @Stateful bean and used.  If the caller thread and the async thread both used the list, it would be a very bad thing unless you change it to a concurrent list of some sort.
If you do have state in the @Stateful bean, you might be better off extracting it into a value object that has final (immutable) fields and passing it to an  @Asynchronous @Singleton method -- possibly with @Lock(READ) if the async method doesn't update any state in the @Singleton.

A: My biggest failure was to use the Session Scope for my CDI bean. This allows only one instance of the asynchronous EJB at once - propably resulting in the ConcurrentModificationException (i think its at a point where i re-assign a Future value).
So @Asynchronous methods/classes seem to be an ideal candidate for the ConversationScope. Changed my CDI bean accordingly, no exceptions so far.


text:
Q: MySQL field of type (byte) how to show it and "click to open" i have inserted and can retrieve the file (pdf, xls, png etc) with no problems but, i also wanted to show the "file" in a way that i could click on it to open (some component maybe). That is one thing.
Other is i also need to update a record that have this file in a column, for this part i have no solution yet but retrieve the file to insert it again.
So any suggestions would be very welcome.
I'm using MySQL, netbeans, the details of the records are displayed in a JTable.
 private void jBsalvarArquivoActionPerformed(java.awt.event.ActionEvent evt) {
    JFileChooser file = new JFileChooser();
    file.setFileSelectionMode(JFileChooser.FILES_ONLY);
    int i = file.showSaveDialog(null);
    if (i == 1) {

    } else {
        File arquivo = file.getSelectedFile();
        JtextFieldLocalArquivo.setText(arquivo.getPath());
         String path = arquivo.getPath();
    }

    }
here is when i insert the file along with the rest of the details
try {
        String newPath = path;
        FileInputStream input = null;

        File theFile = new File(newPath);

        input = new FileInputStream(theFile);

        byte[] bytes = IOUtils.toByteArray(input);
        condutorInfracao.setAnexoAuto(bytes);

    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "File Not Loaded!");

    }

Update code (part of it):
   try {
        stmt = con.prepareStatement("Select * From responsabilidade where respons_descr = '" + (String) jCResponsabilidadeDescr.getSelectedItem() + "'");
        ResultSet r = null;
        r = stmt.executeQuery();
        List<Responsabilidade> objList = new ArrayList<Responsabilidade>();

        if (r.next()) {
            Responsabilidade obj = new Responsabilidade();
            obj.setResponsId(r.getInt("respons_id"));
            obj.setResponsDescr(r.getString("respons_descr"));

            objList.add(obj);
            condutorInfracao.setResponsabilidade(obj);
            r.close();
            stmt.close();
        }
    } catch (Exception ex) {
        System.out.println(ex);
    }

i do it for all the fields then i have a DAO that does the update
 public void update() {
    try {
        transacao = sessao.beginTransaction();
        sessao.update(param_set);
        transacao.commit();
    } catch (HibernateException erro) {
        JOptionPane.showConfirmDialog(null, "Error!" +erro.getMessage());
        transacao.rollback();
    }

}


text:
Q: "report a concern" link on my iphone application review page? Someone did bad comments on my application on app store.and that really i hated.I know they are my competitors.
Is there any way to get user's email address or rather i can send them email directly?
I am confused ,for what purpose "report a concern" link is for?
Thanks in advance.

A: No, you can't get such details or have a message sent. It's all fairly anonymous, and for good reason. Data protection laws exist for a reason!

A: your competitors (plural) care enough about your app to write false reviews? Congratulation, this means your are quite successful with what you are doing.
So you should have at least ten comments in the range between "so lala" and "awesome" for each comment of your competitors.
If this is not the case I would reread the comments instead of accusing competitors.
Maybe whatever the comments say is true.
The best way to deal with bad comments is to check if you can remove the reason for the comment. And if they don't mention a reason (aka "the app is crap") then you should ignore them.
Everybody gets those comments. And even worse (at least for me) are comments from users who are to lazy or stupid to read the description. "I don't know what the app does, so I give it one star".
I would love if a competitor would give my app a bad review. But they don't care who I am or what I do. :'-(

A: 'Report a concern' link IMHO might be there for you to highlight any offensive language being used in the review or something. If Apple was to give out every email address linked to a bad review, then there'd be an ongoing war among the application developers and the application users.


text:
Q: 3d interpolation between two xyz coordinates I need to find the x and y coordinate on a known z coordinate based on two known xyz coordinates.  In more detail: I have a csv-file with x y and z values and I need to find the place where the 0, z value is crossed.
The data looks like this:
z,x,y
0.822,174269.8332,608470.8717
0.692,174269.5191,608480.8668
0.502,174269.205,608490.8618
0.382,174268.8909,608500.8569
0.272,174268.5768,608510.852
0.172,174268.2627,608520.847
0.022,174267.9486,608530.8421
-0.262,174267.6345,608540.8372
-0.772,174267.3203,608550.8322
-1.052,174267.0062,608560.8273
-0.792,174266.6921,608570.8224
-0.382,174266.378,608580.8174

The (very basic...) illustration below illustrates what I mean. The green and the red lines are the known points and the blue line between those points is a slope that I could calculate I suspect. The yellow point with the circle around t is the x and y coordinate that I have to find:

I have been looking at scipy.interpolate.interp2d but that returns the error:
Traceback (most recent call last):
  File "D:\ARNO\JarkusPython\ARNO\Create_Data\createStraightData.py", line 50, in <module>
    some = scipy.interpolate.interp2d(xx, yy, zz)
  File "C:\Python27\ArcGIS10.5\lib\site-packages\scipy\interpolate\interpolate.py", line 229, in __init__
    self.tck = fitpack.bisplrep(x, y, z, kx=kx, ky=ky, s=0.0)
  File "C:\Python27\ArcGIS10.5\lib\site-packages\scipy\interpolate\fitpack.py", line 929, in bisplrep
    raise TypeError('m >= (kx+1)(ky+1) must hold')
TypeError: m >= (kx+1)(ky+1) must hold

Which means (I believe) something as that there's not enough coordinates. Also, I think I have to feed the function the x and y and not the z value. Is this the mathematical problem that I run into?
And does anybody know a solution to this?

A: You can interpolate the two axes independently like:
Code
def find_xy(p1, p2, z):

    x1, y1, z1 = p1
    x2, y2, z2 = p2
    if z2 < z1:
        return find_xy(p2, p1, z)

    x = np.interp(z, (z1, z2), (x1, x2))
    y = np.interp(z, (z1, z2), (y1, y2))

    return x, y

Test Code:
import numpy as np

# arbitrary z
z1, x1, y1 = 0.822, 174269.8332, 608470.8717
z2, x2, y2 = 0.692, 174269.5191, 608480.8668

print(find_xy((x1, y1, z1), (x2, y2, z2), .7))
print(find_xy((x1, y1, z1), (x2, y2, z2), .8))

# z = 0
z1, x1, y1 = 0.022, 174267.9486, 608530.8421
z2, x2, y2 = -0.262, 174267.6345, 608540.8372

print(find_xy((x1, y1, z1), (x2, y2, z2), 0))

Results:
(174269.53842923077, 608480.2517169231)
(174269.78004461539, 608472.5631784615)

(174267.92426830987, 608531.6163683098)


text:
Q: Cross comparing two arrays I am trying to figure out how to achieve something.  I have an Object, and if I do the following
let str = JSON.stringify(this.data, null, 4);
console.log(str);

The output I receive is this (I have removed a lot of elements, just displaying one in each.
{
    "links": [
        {
            "id": 12,
            "source": "0",
            "target": "5",
            "value": "123",
        }
    ],
    "nodes": [
        {
            "id": 93,
            "node": "0",
            "name": "pizza",
        }
    ]
}

I am trying to push this data onto an Array, as such I am doing
Object.entries(this.data.links).forEach(([key, val]) => {
    this.newArray.push([val.source, val.target, parseInt(val.value)]);
});

Now obviously this is only pushing the links onto my array, which is what I need.  This is doing something like the following
0: (3) ["0", "5", 123, __ob__: Observer]

Now although this is the structure I require, instead of it being 0 and 5, I need it to use the name element which matches the correct node. So the above should be
0: (3) ["pizza", "pie", 123, __ob__: Observer]

As node 0 in the nodes array is pizza and node 5 is pie (although I dont have it displayed above).
So how can I cross check the source and target from the links with the node in nodes, and then use the name as the value?
Thanks

A: You can easily convert the nodes array such that it returns you the name by providing it with index.
nodes = [];
data.nodes.forEach(node=>nodes[node.node] = node.name);

Then in your forEach
// this might give you undefined at some places, so make sure you have all the values, or put in some necessory checks.
Object.entries(this.data.links).forEach(([key, val]) => {
    this.newArray.push([nodes[val.source], nodes[val.target], parseInt(val.value)]);
});


text:
Q: Share Gamepad over Network I'm trying to use my laptop as a USB Receiver for a VM on my server. I have found a few USB Sharing programs, VirtualHere USB looked the most promising, but it seems my Xbox 360 Wireless Receiver and/or Gamepad don't show up as USB Devices and can't be shared. I also tried sharing over RDP, but I guess they aren't PnP devices.
Any suggestions? I will/would also like to share BT Wiimotes over the Network if you have any ideas, but that might be a separate question also might not be possible, I didn't see many results in google.
Goal: Plug in Xbox 360 Wireless Receiver and connect Xbox 360 Controller to laptop, which passes input to a VM over some form of connection, be it RDP, TeamViewer, non desktop sharing software etc.

A: So I was already trying to do this, but apparently its much more difficult in Windows 10 (Got to love "updates")...
Anyway, what I ended up using since its free (There are probably better alternatives that are paid like Flixehub) is using RemoteFX USB Redirection over Windows RDP.
To enable in windows 10:
Do on both Physical Windows Machine and Remote Host
All Edits are under the following:
Computer Configuration \ Administrative Templates \ Windows Components \ Remote Desktop Services \ >>

GPEdits:
Remote Desktop Connection Client \ RemoteFX USB Device Redirection \ All RDP Redirection (Enable)

Remote Desktop Session Host \ Remote Session Environment \ RemoteFX for Windows Server 2008 R2 \ Configure RemoteFX (Enable)

Remote Desktop Session Host \ Connections \ Allow users to connect remotely using Remote Desktop Services (Enable)

Remote Desktop Session Host \ Device and Resource Redirection\ Do not allow supported Plug and Play device redirection (Disable)

gpupdate /force in elevated CMD Prompt and reboot

Source: >> https://stackoverflow.com/questions/33719489/how-to-enable-usb-redirection-in-windows-10/46628854#46628854
Note: This also enabled me to share my BT, but I didn't test it yet
Using the Feautre in RDP:
Open RDP >> Show Options >> Local Resources >> More >> Other Supported RemoteFX USB Devices >> (Enable Device to share)

Then Connect and go under "Devices and Printers", it should be listed, perhaps have to install drivers.


text:
Q: Apache POI XWPF Paragraph on Same Page I have a paragraph which contains some text , image and and some text . All these 3 sections are present on a new line .How do i ensure that the paragraph should be rendered on the same page only when  there is not enough space on the current page .If the space is there on the current page then it should get rendered on the same page. I have used :
    XWPFParagraph p11 = doc.createParagraph();
    p11.setAlignment(ParagraphAlignment.LEFT);
    XWPFRun r11 = p11.createRun();
    p11.setPageBreak(true);

But this does not help as p11 paragraph is rendered on  new page every time even if there is space on the existing page .

A: XWPFParagraph p11 = doc.createParagraph();
p11.setAlignment(ParagraphAlignment.LEFT);
XWPFRun r11 = p11.createRun();
p11.setPageBreak(true);
XWPFParagraph p12 = doc.addParagraph();
XWPFParagraph p13 = doc.addParagraph();
XWPFParagraph p14 = doc.addParagraph();


text:
Q: how to add scrolling ability i have created textviews which took the whole page and now the rest are down and to see them i have to add scrolling ability can anybody tell me how can i do it? im sorry for any disturbance im just a beginner as you may know
this is my code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right"
android:orientation="vertical"
tools:context=".LinearLayout" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="قال (عليه السلام): (من كرمت عليه نفسه هانت عليه الدنيا)"
                    android:paddingTop="10sp"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="قال (عليه السلام): (الخير كله في صيانة الإنسان نفسه)"
                    android:paddingTop="10sp"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="قال (عليه السلام): (ما أحب المؤمن معافى في الدنيا، وفي نفسه وماله، ولا يصاب بشيء من المصائب)"
                    android:paddingTop="10sp"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text=" قال (عليه السلام): (ضل من ليس له حليم يرشده، وذل من ليس له سفيه يعضده..)"
                    android:paddingTop="10sp"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="قال (عليه السلام): (ويل لمن غلبت آحاده أعشاره)"
                    android:paddingTop="10sp"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="قال (عليه السلام): (اللئيم يأكل ماله الأعداء، والذي خبث لا يخرج إلا نكداً..)"
                    android:paddingTop="10sp"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="قال (عليه السلام): (إن الجسد إذا لم يمرض يأشر ولا خير في جسد يأشر..)"
                    android:paddingTop="10sp"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="قال (عليه السلام): (عليكم بأداء الأمانة، فوالذي بعث محمداً بالحق نبياً لو أن قاتل أبي الحسين بن علي ائتمنني على السيف الذي قتله به لأديته إليه..)"
                    android:paddingTop="10sp"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="قال (عليه السلام): (أفضل الأعمال عند الله ما عمل بالسنة)"
                    android:paddingTop="10sp"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="قال (عليه السلام): (لقد استرقك بالود من سبقك بالشكر..)"
                    android:paddingTop="10sp"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="قال (عليه السلام): (لا يكون الصديق صديقاً حتى يقطع لأخيه المؤمن قطعة من دينه يرقعها بالاستغفار..)"
                    android:paddingTop="10sp"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="قال (عليه السلام): (ضمنت على ربي أنه لا يسال أحد من غير حاجة إلا اضطرته المسألة يوماً إلى أن يسأل من حاجة..)"
                    android:paddingTop="10sp"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="قال (عليه السلام): (إياك، وما تعتذر منه)"
                    android:paddingTop="10sp"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="قال (عليه السلام): (إن الله جل جلاله يقول: وعزتي وعظمتي وجمالي، وبهائي، وعلوي، وارتفاع مكان لا يؤثر عبد هواي على هواه إلا جعلت همه في آخرته، وغناه في قلبه، كففت عنه ضيعته، وضمنت السماوات والأرض رزقه، وأتته الدنيا وهي راغمة)"
                    android:paddingTop="10sp"/>

    </LinearLayout>

A: You need to wrap them in a ScrollView. Here is an example.


text:
Q: Multiple passwords for simple password protected page I have a super simple page that uses a PHP password script to allow users access. It works like a charm, but I need to add a second password for another user. Does anyone know how to solve this?
Thank you!
/A
PHP:
<?php

// Define your password
$password = "xxx";

if ($_POST['txtPassword'] != $password) {

?>

HTML:
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

Enter Password

<input type="password" name="txtPassword" style="width: 400px;">
</form>

A: $passwords = array('xxx', 'zzz', 'yyy');

if (!in_array($_POST['txtPassword'], $passwords, true)) {

}


text:
Q: Google Sheets Using Results from one query to return results in another (Nest or Join) I've created a spreadsheet to track my trades using data exported from my brokerage. my spreadsheet has the following simplified format:

Date
Time
Symbol
Quantity
Amount
Starting Balance
Ending Balance
Trade No.

07/1/2022
07:00
ABCD
+1
-$50
$100
$50
1

07/15/2022
11:00
EFGH
+1
-$25
$50
$25
2

07/15/2022
13:00
EFGH
-1
$50
$25
$75
2

07/15/2022
11:00
ABCD
-1
$75
$75
$150
1

08/1/2022
06:00
EFGH
+1
-$25
$150
$125
3

08/1/2022
11:00
EFGH
-1
+$50
$125
$175
3

What I'm trying to do is get the starting and ending balance for each month/year. This might not be the correct way to do it but I've resorted to using the QUERY method since my pivot table didn't work. I have an initial query that gets the MIN and MAX ROW for each month/year combination:
=QUERY({ARRAYFORMULA(CONCAT(ARRAYFORMULA(YEAR(Daily_Trades!A5:A))&"-", ARRAYFORMULA(MONTH(Daily_Trades!A5:A)))), ARRAYFORMULA(ROW(Daily_Trades!A5:A)), Daily_Trades!Q5:Q}, "SELECT Col1, MIN(Col2), MAX(Col2) WHERE Col1 <> '1899-12' GROUP BY Col1 LABEL Col1 'Year-Month', MIN(Col2) 'Min Row Index', MAX(Col2) 'Max Row Index'" )

Now I'm trying to take the results from the query above which look like this:

Year-Month
Min Row Index
Max Row Index

2022-7
1
4

2022-8
4
5

My desired output is the table below with the Starting and Ending Balances for the month/year based on the row indexes. However, since I can't use INDEX in an ARRAYFORMULA and I can't use VLOOKUP because that's based on a cell value I'm not sure how to do this. I was hoping for nested or joined queries but not sure if that's possible either.

Year-Month
Starting Balance
Ending Balance

2022-7
100
150

2022-8
150
175

A: try:
=QUERY({SORTN({TEXT(A2:A, "e-m"), F2:F}, 9^9, 2, 1, 1),
 INDEX(SORTN(SORT({TEXT(A2:A, "e-m"), G2:G}, 1, 1, 2, 0), 9^9, 2, 1, 1),,2)},
 "where Col3 is not null", )

update:
=QUERY({"Year-Month", "Starting Balance", "Ending Balance";
 SORTN({TEXT(A2:A, "e-m"), F2:F}, 9^9, 2, 1, 1),
 INDEX(SORTN(SORT({TEXT(A2:A, "e-m"), F2:F}, ROW(F2:F), 0), 9^9, 2, 1, 1),,2)},
 "where Col3 is not null", 1)


text:
Q: Assinging and Object to Array in Java, It is returning null I have created a program and assigning customer object to customers array, but when I try to get the object in array it returns null. I am new to Java, please help me out where I am going wrong.
public class Customer {

    private String firstname,lastname;

    public Customer(String f,String l){
        this.firstname = f;
        this.lastname = l;
    }

    public String getFirstName(){
        return firstname;
    }

    public String getLastName(){
        return lastname;
    }
}

public class Bank {

    private Customer [] customers;
    private int numberofCustomers;

    public Bank(){
        customers = new Customer [5];
        numberofCustomers = 0;

    }

    public void addCustomer(String f,String l){
        int i = numberofCustomers++;
        customers[i] = new Customer(f,l);
    }

    public int getNumberofCustomer(){
        return numberofCustomers;
    }

    public Customer getCustomerMethod(int index){
        return customers[index];
    }
}

public class TestAccount {

public static void main (String [] args){

        Bank b = new Bank();
        b.addCustomer("Test", "LastName");
        System.out.print(b.getNumberofCustomer());
        System.out.print(b.getCustomerMethod(1));

    }
}

A: Array indexes start with zero. You have added a customer at index 0 first element in your array and you should use the same index to get the element. currently there is nothing at index 1 thus your code returns null;
System.out.print(b.getCustomerMethod(0));

Say array size is 5, thus its indexs would be 0,1,2,3,4
where 0 is the first index and 4 is the last index.
After this line b.addCustomer("Test", "LastName"); your array will be :
Array: [Customer("Test", "LastName") , null , null, null, null]
Index:                0             ,  1   ,  2  ,   3 ,  4

and when you try ' System.out.print(b.getCustomerMethod(1));' It returns null. as you can see that your array has null at index 1.

A: You added one customer and then you are asking for the second one. Arrays indices are zero-based.

A: There are three problems with your code:

*

*Indexes start with 0

*You are using post increment operator to assign value to i. int i = noOfCustomers++; will result in value of i as 0.
So you are adding the customer at index 0 and fetching from index 1. So you get null

*Bank should be using ArrayList


text:
Q: Change quantity of product using jquery ajax I have a shopping cart and a page that shows all products in a table. I am able to remove products, but I want to be able to change their quantity as well.
My table consists of an input field that you can change the quantity in, when clicking on an 'update' cart button below, I am sending the productname and the quantity to my PHP script. The problem is, it always posts the first product.
Probably because all have the same classname, how can I fix that?
This is what my table looks like:

Uw Winkelmand

Bent u niets vergeten?

               Verwijder
               Afbeelding
               Product
               Prijs
               Aantal
               Totaal

               ×

                  Bad 13

               € 1500

                     <input type="number" step="1" min="0" name="quantity" id="Bad 13" value="1" title="Qty" class="input-text qty quantityclass text" size="4">

               € 1500

               ×

                  Bad 14

               € 800

                     <input type="number" step="1" min="0" name="quantity" id="Bad 14" value="1" title="Qty" class="input-text qty quantityclass text" size="4">

               € 800

               ×

                  Bad 1

               € 1000

                     <input type="number" step="1" min="0" name="quantity" id="Bad 1" value="1" title="Qty" class="input-text qty quantityclass text" size="4">

               € 1000

      <input type="submit" class="button updatebutton" name="update_cart" value="Wijzig winkelmand">

And this is my jquery script that fires an ajax post.
//Wijzig winkelmand met het aantal producten
tpj('.cartsection').on('click', '.updatebutton', function(event) {
  var $edit = tpj('.quantityclass').attr('id'),
  $aantal = tpj('.quantity').find( "input[name='quantity']" ).val(),
  url = 'includes/cartoverzicht.php';

  var posting = tpj.post( url, { edit: $edit, aantal: $aantal} );

  posting.done(function( data ) {
    var content = tpj( data );
    tpj( "#cartresult" ).empty().append( content );
  });
});

The problem is, when I look in network this is always posted no matter what product I clicked:
edit:Bad 13
aantal:1

How can I fix that?
Can I maybe post all quantities to my php script? What would be the best solution?

A: The issue is here:
var $edit = tpj('.quantityclass').attr('id'),

you are using a class selector to get the value, it always return the first element value. Instead use this
See this example:

$(document).ready(function(){
  $('.list').click(function(){
    console.log( $('.list').html() );
  });

  $('.listing').click(function(){
    console.log( $(this).html() );
  });
});

First list (It always return the first element value)

One

Two

Three

Another List (It always return the clicked element value)

One

Two

Three

A: You are hitting problems because you are only ever grabbing the first selector. You have also designed your API to only send one update when it looks like you want to send the whole updated set.
Below is the way to go if you want to update the quantities for the whole cart.
$('.updatebutton').on('click', function(event) {
    var elements = $('.quantity input[name="quantity"]'),
        url = 'includes/cartoverzicht.php',
        postBody = [];
    for (var i=0; i<elements.length; i++) {
        var element = $(elements[i]);
        postBody.push({
            edit: element.attr('id'),
            aantal: element.val()
        })
    }
    var posting = $.post( url, JSON.stringify(postBody) );
    posting.done(function( data ) {
        var content = $( data );
        $( "#cartresult" ).empty().append( content );
    });
});