text:
Q: The image draws itself again So I am working on a project, and I am currently on the finishing touches in the Image Part. But here comes the problem. When I clicked the checkbox for flipping the image, it flips.
Like this:

But when I click the "Accept" Button (this is for saving the image into a collection of objects), this happens:

I used Visual Studio's debugger and what I think the problem is that, the onPaint of the pictureBox is being called numerous time again so is the method for Image Drawing. So my question is, how do I prevent that from happening?
Image Drawing Method
public LayerClass ImageDrawing(LayerClass.Type img, Bitmap bm, RectangleF imgRect, String filepath, int angle, PaintEventArgs e, PointF location, bool flip)
    {
        bm = (Bitmap)Image.FromFile(filepath);
        bm = new Bitmap(bm, (int)imgRect.Width, (int)imgRect.Height);  //Scaling Image
        bm = ImageClass.GrayscaleImage(bm);             //Grayscale
        bm = MakeTransparentImage(bm);                //Transparent
        bm = RotateImage(bm, angle);
        if (flip)
            bm.RotateFlip(RotateFlipType.RotateNoneFlipX);
        e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
        e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
        e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
        e.Graphics.CompositingQuality = CompositingQuality.HighSpeed;
        imgRect.Size = new SizeF(bm.Width, bm.Height);
        e.Graphics.DrawImage(bm, imgRect.X - (bm.Width / 2), imgRect.Y - (bm.Height / 2));
        this.imageBitmap = bm;
        this.filePath = filePath;
        this.rotationAngle = angle;
        this.location = location;
        this.imageRect = imgRect;
        this.flipped = flip;
        return new LayerClass(LayerClass.Type.Image, this, filePath, imgRect, location, flip);
    }

A: Your problem is, that you draw your image on your canvas, but you are not erasing the previously drawn image.
Think about it like this: If you draw something on a piece of paper and then want to draw something new, but you don't use a fresh piece, you end up with your old drawing beneath your new one.
Your code works just like this right now.
So instead, before you draw your flipped image, you first have to erase your old image.
The easiest way to do this is to call
e.Graphics.Clear(this.Background); //Use any color you want.

before you call
e.Graphics.DrawImage


text:
Q: WPF ComboBox DropDown using PlacementTarget I have a ContentControl comprised from left to right of a Button, partition and a ComboBox. I want the ComboBox dropdown to line up with the left side of the control as opposed to the left side of the ComboBox.  I received a method in code but I was wondering whether if it could be accomplished in xaml.
This gives me the name of the control:
ToolTip="{Binding Path=Name, RelativeSource={RelativeSource FindAncestor, AncestorLevel=2, AncestorType={x:Type Control}}}"

But I would like a reference to the control:
Placement="Bottom" PlacementTarget="{Binding ElementName=[Fancy-Smancy xaml goes here!]}"

Any thoughts?

A: Turns out that a RelativeSource works fine if you specify the AncestorLevel and the AncestorType :
Placement="Bottom"

PlacementTarget="{Binding RelativeSource={RelativeSource FindAncestor, AncestorLevel=2, AncestorType={x:Type Grid}}}"

redpajama_set_name: RedPajamaStackExchange


text:
Q: Typescript interface from array type I need to force an array to have a specific set of values that should be then the keys of my interface.
I can force the array with
type SomeProperties = ['prop1', 'prop2', 'prop3'];

but I don't know how to force an interface to have those properties. I tried something like
type MyInterface = {
  [key in keyof SomeProperties]: string;
}

but obviously the keys of an array are just numbers so my interface become
interface MyInterface {
  0: string;
  1: string;
  2: string;
}

instead of the wanted interface
interface MyInterface {
  prop1: string;
  prop2: string;
  prop3: string;
}

Do you know if there is a way to achieve this in Typescript?
It would be useful because I need to iterate on some properties to "clone" an object and I also need to access to those properties easily.
Repeating the properties in both type and interface is a bit fragile for me.

A: As you note, the strings you're trying to access aren't the keys of SomeProperties, but the elements of SomeProperties.
You can use the indexed access operator here:  if K is a key (or a union of keys) of T, then T[K] is the property type (or union of property types) corresponding to accessing the K key(s) of T.
Tuples and arrays accept number as a key type, so you want to use SomeProperties[number] to give you the union "prop1"|"prop2"|"prop3":
type SomeProperties = ['prop1', 'prop2', 'prop3'];

type MyInterface = {
  [key in SomeProperties[number]]: string;
}

const myInterface: MyInterface = {
  prop1: 'this',
  prop2: 'works',
  prop3: 'now'
}

Hope that helps; good luck!

A: Worth noting: You can't iterate an tuple type in TypeScript
Actually, you can! Since TypeScript 3.1 you can safely use tuple types in mapped types like objects.
These sorts of operations can only be applied to types, not interfaces.
type SomeProperties = 'prop1' | 'prop2' | 'prop3';

type MyType = Record<SomeProperties, string>;

// equivalent to
// type MyType = {
//   [key in SomeProperties]: string
// }

Types and interface are the same from the perspective of the consumer (when you ask for a MyType, you don't care if it's an interface or a type, they're the same at that point)

A: Update to Madara's answer for future readers.

These sorts of operations can only be applied to types, not
interfaces.

I don't know since when, but nowadays you can do this with interfaces too.
type SomeProperties = 'prop1' | 'prop2' | 'prop3';

interface MyType extends Record<SomeProperties, string> {
   // other properties
}

It is equivalent to the following:
type SomeProperties = 'prop1' | 'prop2' | 'prop3';

type MyType = Record<SomeProperties, string>;


text:
Q: How do I compare multiple vector of structs for similar names efficiently? I am writing a program for my wife to help us try to decide which medical schools that she should apply for. However, I have run into a problem where I am trying to extract schools that show up in the top 20 results in 4 different cases.
For example, in one of those cases I take the median income of the city, and divide it by the average house price in the city. That returns a double, and then I create a new vector and then sort that vector based on that number from highest to lowest. And I do similar actions to the 3 other vectors in my pool with different cases applied.
I know I can just brute force this and extract the names with nested for loops, but I am curious to know if there is a way to do it quickly and efficiently. This is my attempt so far. (Note, this is just an example, my actual code has 30 schools in it).
#include <algorithm>
#include <iterator>
#include <iostream>
#include <memory>
#include <string>
#include <vector>

struct Schools
{
    Schools(std::string n = "", double h = 0.0, double t = 0.0, int r = 0, int w = 0) : name(n), housing(h), tuition(t), rank(r), weight(w){};
    std::string name;
    double housing;
    double tuition;
    int rank;
    int weight;
};

void load(std::vector<std::shared_ptr<Schools>> &v, std::string n, double h, double t, int r, int w)
{
    auto newSchool = std::make_shared<Schools>(n,h,t,r,w);
    v.emplace_back(newSchool);
}

void init(std::vector<std::shared_ptr<Schools>> &schools)
{
    load(schools,"School1",40.3,20.0,3,6);
    load(schools,"School2",10.3,10.4,5,1);
    load(schools,"School3",33.3,23.5,1,2);
    load(schools,"School4",8.5,15.5,4,8);
}

auto findIntersection(auto &a, auto &b)
{
    std::vector<std::shared_ptr<Schools>> in;
    std::set_intersection(begin(a),end(a),begin(b),end(b),std::back_inserter(in));
    return in;
}

auto findCommon(auto &housing, auto &tuition, auto &rank, auto &weight)
{
    std::vector<std::shared_ptr<Schools>> inCommon;
    inCommon = findIntersection(housing,tuition);
    inCommon = findIntersection(inCommon,rank);
    inCommon = findIntersection(inCommon,weight);
    return inCommon;
}

bool compareHM(const std::shared_ptr<Schools> &a, const std::shared_ptr<Schools> &b)
{
    return a->housing < b->housing;
}

bool compareT(const std::shared_ptr<Schools> &a, const std::shared_ptr<Schools> &b)
{
    return a->tuition < b->tuition;
}

bool compareRank(const std::shared_ptr<Schools> &a, const std::shared_ptr<Schools> &b)
{
    return a->rank > b->rank;
}

bool compareWeight(const std::shared_ptr<Schools> &a, const std::shared_ptr<Schools> &b)
{
    return a->weight > b->weight;
}

int main()
{
    std::vector<std::shared_ptr<Schools>> schools;
    init(schools);
    std::vector<std::shared_ptr<Schools>> sortByHousing = schools;
    std::vector<std::shared_ptr<Schools>> sortByTuition = schools;
    std::vector<std::shared_ptr<Schools>> sortByRank = schools;
    std::vector<std::shared_ptr<Schools>> sortByWeight = schools;

    std::sort(begin(sortByHousing),end(sortByHousing), compareHM);
    std::sort(begin(sortByTuition),end(sortByTuition), compareT);
    std::sort(begin(sortByRank),end(sortByRank), compareRank);
    std::sort(begin(sortByWeight),end(sortByWeight), compareWeight);

    std::vector<std::shared_ptr<Schools>> commonSchools = findCommon(sortByHousing,sortByTuition,sortByRank,sortByWeight);

    for (auto && e: commonSchools)
    {
        std::cout << e->name << std::endl;
    }
}

I run into a problem when I try to use std::set_intersection, and then I quickly realized that I cannot do something like begin(a)->name. Again, I am trying to extract common names that show up in each of the 4 cases that I have. How do I go about implementing this? Is my idea of std::set_intersection not too far off?
Thanks!
EDIT:
This is an example of one of my functionThatCompares
bool compareTuition(const std::shared_ptr<Schools> &a, const std::shared_ptr<Schools> &b)
{
    return a->tuition < b->tuition;
}

EDIT 2: Example Output
The top 20 sorted by Median/House are:
Name of Institution                               Median/House Price  Tuition Over 8 Years     Has Space Industry? Score

University of Alabama                             0.463577            0.722279                 1                   0.641825
University of Maryland                            0.38124             0.722617                 1                   0.527583
Johns Hopkins Univerty School of Medicine         0.38124             0.606103                 1                   0.629002
Indiana University                                0.335939            0.501944                 0                   0.669276
Ohio State University                             0.32499             0.610704                 1                   0.532156
Perelman School of Medicine                       0.26908             0.653143                 1                   0.411977
Duke University School of Medicine                0.246991            0.66683                  1                   0.370395
University of Wisconsin                           0.226581            0.64686                  0                   0.350278
Chicago Medical School                            0.221883            0.648157                 0                   0.342329
Northwestern University                           0.221883            0.677341                 0                   0.32758
Case Western Reserve                              0.211817            0.536384                 1                   0.394898
Emory University                                  0.206169            0.576814                 1                   0.357427
Geisel School of Medicine                         0.205529            0.71526                  0                   0.287349
University of Massachusetts                       0.19562             0.64686                  1                   0.302414
Medical University of SC                          0.185816            0.354728                 0                   0.523827
University of North Carolina                      0.176684            0.6637                   0                   0.26621
University of Michigan Medical School             0.158465            0.637237                 1                   0.248675
Rutgers New Jersey Medical School                 0.140412            0.722115                 0                   0.194446
University of Utah                                0.140142            0.311285                 0                   0.450205
Georgetown University                             0.128883            0.604001                 1                   0.213382

The top 20 sorted by Tuition are:
Name of Institution                               Median/House Price  Tuition Over 8 Years     Has Space Industry? Score

University of Utah                                0.140142            0.311285                 0                   0.450205
Medical University of SC                          0.185816            0.354728                 0                   0.523827
University of California, LA                      0.07633             0.47547                  1                   0.160536
Indiana University                                0.335939            0.501944                 0                   0.669276
University of California, SD                      0.109214            0.531397                 1                   0.205523
Case Western Reserve                              0.211817            0.536384                 1                   0.394898
Emory University                                  0.206169            0.576814                 1                   0.357427
Icahn School of Medicine                          0.0822029           0.585946                 1                   0.140291
Georgetown University                             0.128883            0.604001                 1                   0.213382
Johns Hopkins Univerty School of Medicine         0.38124             0.606103                 1                   0.629002
Ohio State University                             0.32499             0.610704                 1                   0.532156
University of Virgina School of Medicine          0.123755            0.630067                 1                   0.196415
University of Michigan Medical School             0.158465            0.637237                 1                   0.248675
NY University School of Medicine                  0.0822029           0.642516                 1                   0.127939
Tufts University School of Medicine               0.100302            0.644314                 1                   0.155672
University of Massachusetts                       0.19562             0.64686                  1                   0.302414
University of Wisconsin                           0.226581            0.64686                  0                   0.350278
Chicago Medical School                            0.221883            0.648157                 0                   0.342329
Perelman School of Medicine                       0.26908             0.653143                 1                   0.411977
Standford University School of Medicine           0.0780054           0.656658                 1                   0.118791

The top 20 sorted by Median/House and Loweset Tution are:
Name of Institution                               Median/House Price  Tuition Over 8 Years     Has Space Industry? Score

University of Maryland                            0.38124             0.722617                 1                   0.527583
Chicago Medical School                            0.221883            0.648157                 0                   0.342329
University Of Washington                          0.0973689           0.761413                 1                   0.127879
University of Alabama                             0.463577            0.722279                 1                   0.641825
Rutgers New Jersey Medical School                 0.140412            0.722115                 0                   0.194446
Geisel School of Medicine                         0.205529            0.71526                  0                   0.287349
Ohio State University                             0.32499             0.610704                 1                   0.532156
Harvard Medical School                            0.100302            0.710787                 1                   0.141114
Duke University School of Medicine                0.246991            0.66683                  1                   0.370395
Boston University School of Medicine              0.100302            0.710787                 1                   0.141114
Perelman School of Medicine                       0.26908             0.653143                 1                   0.411977
University of Wisconsin                           0.226581            0.64686                  0                   0.350278
University of North Carolina                      0.176684            0.6637                   0                   0.26621
Standford University School of Medicine           0.0780054           0.656658                 1                   0.118791
Johns Hopkins Univerty School of Medicine         0.38124             0.606103                 1                   0.629002
Northwestern University                           0.221883            0.677341                 0                   0.32758
Indiana University                                0.335939            0.501944                 0                   0.669276
Case Western Reserve                              0.211817            0.536384                 1                   0.394898
Emory University                                  0.206169            0.576814                 1                   0.357427
University of Massachusetts                       0.19562             0.64686                  1                   0.302414

The top 20 sorted by Score (Median/House * Tuition/Salary) are:
Name of Institution                               Median/House Price  Tuition Over 8 Years     Has Space Industry? Score

Indiana University                                0.335939            0.501944                 0                   0.669276
University of Alabama                             0.463577            0.722279                 1                   0.641825
Johns Hopkins Univerty School of Medicine         0.38124             0.606103                 1                   0.629002
Ohio State University                             0.32499             0.610704                 1                   0.532156
University of Maryland                            0.38124             0.722617                 1                   0.527583
Medical University of SC                          0.185816            0.354728                 0                   0.523827
University of Utah                                0.140142            0.311285                 0                   0.450205
Perelman School of Medicine                       0.26908             0.653143                 1                   0.411977
Case Western Reserve                              0.211817            0.536384                 1                   0.394898
Duke University School of Medicine                0.246991            0.66683                  1                   0.370395
Emory University                                  0.206169            0.576814                 1                   0.357427
University of Wisconsin                           0.226581            0.64686                  0                   0.350278
Chicago Medical School                            0.221883            0.648157                 0                   0.342329
Northwestern University                           0.221883            0.677341                 0                   0.32758
University of Massachusetts                       0.19562             0.64686                  1                   0.302414
Geisel School of Medicine                         0.205529            0.71526                  0                   0.287349
University of North Carolina                      0.176684            0.6637                   0                   0.26621
University of Michigan Medical School             0.158465            0.637237                 1                   0.248675
Georgetown University                             0.128883            0.604001                 1                   0.213382
University of California, SD                      0.109214            0.531397                 1                   0.205523

EDIT 3:
I Greatly Apologize for those who tried to compile this program. It now compiles and runs.

A: When you do something like a sort or a set_intersection, you can specify how comparison should be done. If you don't specify anything, operator< for the type will be used (if it's defined).
In this case, it seems like you probably want to use partial_sort_copy instead of sort. This will let you get (for example) the top 10 schools by each sorting.
Then you'll have to re-sort those by name to do the set_intersection.
Then you'll do the set_intersection to get the schools that are common between those collections.
Here's some demo code:
#include <iostream>
#include <algorithm>
#include <vector>
#include <memory>

struct School
{
    std::string name;
    double housing;
    double tuition;
    int rank;
    int weight;

    // default comparison to use if nothing else is specified:
    bool operator<(School const &other) const { return name < other.name; }
};

int main()
{
    std::vector<School> schools{
        {"School1", 40.3, 20.0, 3, 6},
        {"School2", 10.3, 10.4, 5, 1},
        {"School3", 33.3, 23.5, 1, 2},
        {"School4", 8.5, 15.5, 4, 8}
    };

    // We specify the size of each of these as 3, so when we do the
    // partial_sort_copy, it'll fill in the top 3 for that category.
    std::vector<School> byHousing(3);
    std::vector<School> byRank(3);
    std::vector<School> byWeight(3);

    std::partial_sort_copy(schools.begin(), schools.end(), byHousing.begin(), byHousing.end(),
                           [](School const &a, School const &b) { return a.housing < b.housing; });

    std::partial_sort_copy(schools.begin(), schools.end(), byRank.begin(), byRank.end(),
                           [](School const &a, School const &b) { return a.rank < b.rank; });

    std::partial_sort_copy(schools.begin(), schools.end(), byWeight.begin(), byWeight.end(),
                           [](School const &a, School const &b) { return a.weight < b.weight; });

    std::sort(byHousing.begin(), byHousing.end());
    std::sort(byRank.begin(), byRank.end());
    std::sort(byWeight.begin(), byWeight.end());

    std::vector<School> temp, commonSchools;

    std::set_intersection(byHousing.begin(), byHousing.end(), byRank.begin(), byRank.end(),
                          std::back_inserter(temp));

    std::set_intersection(temp.begin(), temp.end(), byWeight.begin(), byWeight.end(),
                          std::back_inserter(commonSchools));

    std::cout << "Common Schools\n";
    for (auto const & e: commonSchools)
    {
        std::cout << e.name << "\n";
    }
}

Result:
Common Schools
School3

As an aside, it looked to me like making code using shared_ptr was going to add some extra work (and probably not gain enough to care about) so I didn't bother. I also left out the screening/sorting by tuition--it's pretty much just more of the same.

A: As stated in documentation for std::set_intersection

3) Elements are compared using the given binary comparison function comp and the ranges must be sorted with respect to the same.

(emphasis is mine) so you cannot use it with your vectors immediately, you would need to resort them all with one common criteria, for example using name, before you apply std::set_intersection to them and supply the same comparator to std::set_intersection itself
I would create a weight for each school and make it grow exponentially depends on index in each vector, then sum them together and sort based on that value. Ones with smallest win. You can also add a coefficient for increasing/decreasing weight of some criteria in sorting decision:
std::unordered_map<std::shared_ptr<Schools>,double> weights;
size_t count = 0;
auto weightCalc = [&weights, &count]( std::shared_ptr<Schools> s ) {
    weights[s] += std::exp( count++ );
};
std::for_each( sortByHousing.begin(), sortByHousing.end(), weightCalc );
count = 0;
std::for_each( sortByTuition.begin(), sortByTuition.end(), weightCalc );
count = 0;
std::for_each( sortByRank.begin(), sortByRank.end(), weightCalc );
count = 0;
std::for_each( sortByWeight.begin(), sortByWeight.end(), weightCalc );

std::multimap<double,std::shared_ptr<Schools>> sortedSchools;
std::copy( weights.begin(), weights.end(), std::inserter( sortedSchools ), []( const auto &p ) { return std::make_pair( p.second, p.first ); } );

Then use first n schools from sortedSchools


text:
Q: Random number generator global to a class I would like to generate uniformly distributed numbers on [0,1] in C++. I know that the following code would to the job
     std::random_device  rand_dev;
     std::mt19937  generator(rand_dev());
     std::uniform_real_distribution<double>  uni(0,1);
     std::cout << uni(generator);

But my issue is that I want to generate these numbers inside a class scope. And I don't want to initalize a new random number generator everytime I call a function of this class as I will need to call this function very often. Can I somehow use the same number generator for the entire class? I tried
class test{
      private:
        std::random_device  rand_dev;
        std::mt19937  generator(rand_dev());
        std::uniform_real_distribution<double>  uni(0,1);

      public:
        void somefunction();
  };
test::somefunction(){std::cout << uni(generator);}

But this doesn't seem to work.

A: Daniel Langr's comment:

Class member variables are initialized in constructors. By the way, you don't need to store std::random_device inside your class, if it will be used only once during initialization. Try to add a constructor like test() : generator(std::random_device{}()), uni(0, 1) { }

class test{
      private:
        std::mt19937  generator;
        std::uniform_real_distribution<double>  uni;
      public:
        test() : generator(std::random_device{}()), uni(0, 1) { }
  };


text:
Q: Location of a permission I am making an AAR for licensing functionality. I plan to use it in multiple applications.
As per documentation, licensing implementation needs a permission in manifest file: "com.android.vending.CHECK_LICENSE"
I am not sure where should this permission be kept,in application's manifest file or library project's manifest file.

A: All your library related permissions/metadata/activities relevant info should be declared in your library manifest file


text:
Q: Removing hover features and auto loading from site So I'm trying to remove all hover features and auto loading from my site so I commented out all the code that is related to the :hover feature in my site but there is still hovering available.
I'm also trying to remove all the available auto load features like the loader transform and animations. I did but I still see both hovering and some animations.
Is there something that I could be missing?
Like this hover and transform features below I removed them
.cateogory ul li a:hover:before {
transform: scale3d(1, 1, 1);
transform-origin: 0 50%;
}

.category-2 {
  transition: all 0.4s ease;
}

A: In your code it looks like there is a typo
cateogory

.category ul li a:hover:before {
transform: scale3d(1, 1, 1);
transform-origin: 0 50%;
}

.category-2 {
  transition: all 0.4s ease;
}

If that does not solve You may create another class and copy all inside and change its classname with javascript
<!-- language: lang-css -->
.category ul li a:hover:before {
transform: scale3d(1, 1, 1);
transform-origin: 0 50%;
}

.category-nohover ul li a:hover:before {

}

.category-2 {
  transition: all 0.4s ease;
}


text:
Q: Text alignment with html-css I am styling a website according to the design I laid out. But my text are starting from the extreme right. I want to be somewhat in the middle with no much spacing after the text. Using margin-inline-start and margin-inline-end does not seem to do the trick.
What I have now:

What I want to achieve:

The HTML css style:
p .welcome-text1 .welcome-text2 {
    font-family: 'Montserrat';
    font-size: 10px;
    text-align: center;
    font-weight: bold;
    margin-inline-start: 40px;
    margin-inline-end: 40px;
}

A: you can use container class of Bootstrap
First get the CDN copied from the bootstrap's website and add it in your html file before the head tag.
Now put all of your contents in the 'container' class using:

    your content

A: Try add this:
p .welcome-text1 .welcome-text2 {
    display: block;
    margin: 0% 10%;
}

You  can change the second parameter in margin. that's the margin from left and right side. First is top and bottom.
Hope, that's help!

A: Here you go, let me know if you need any adjustments made. Only change you should have to do is add in your border.

<!doctype html>

    <title>Title</title>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

Welcome To The Data Science

And Machine Learning Platform

            That provides the tools that allow you to explore your data seemlessly and get insights into your data and allows
            you to easily apply Machine learning to make predictions with your data.


text:
Q: How to jump to a function under the cursor in emacs I have two files: A.el and B.el
Under my cursor in A.el is a function defined in B.el. How do I jump to the function in B.el?

A: M-x find-function does that.

Finds the source file containing the definition of the function
near point (selected by 'function-called-at-point') in a buffer and
places point before the definition.

You seem to be asking specifically about native Emacs Lisp; you need to have loaded the function into Emacs for this to work.
In the general case, this depends on the mode of the file, but the traditional solution is to use etags.
A somewhat more modern replacement called xref was introduced in Emacs 25; try M-.


text:
Q: Tic Tac Toe Expected Primary Expression Before I'm learning c++ right now and my assignment was to create a tic tac toe game that reads the moves off a .txt file that would look something like this:
2 3
1 3
2 2
3 2
etc.
So this is the code I built:
#include <iostream>
#include <fstream>
using namespace std;

char my_board[3][3]{0,0,0,
                    0,0,0,
                    0,0,0,};

int i = 0, j = 0;
int line = 0;
int X = 0, O = 0, N = 0;

void loadSquaresFromStream(int my_board[3][3], int i, int j);
void getgameStatus (int X, int O, int N, int i, int j, int my_board[3][3]);
void displayTotals(int X, int O, int N);

int main(){

  cout << loadSquaresFromStream(int my_board[3][3], int i, int j) << endl;

return 0;
}

void loadSquaresFromStream(int my_board[3][3], int i, int j){
 ifstream inputStream;
   inputStream.open("games.txt");
//take all numbers from txt and input into an array
   int moves[] = inputStream;
   for (moves[i] != 0 && moves[j] != 0 ){
    switch(line){
      case %2:
        my_board[i][j] = x;
        i++; j++;
        break;
      case %1:
        my_board[i][j] = o;
        i++; j++;
        break;
    }
   }
   else if ((moves[i] == 0) && (moves[j] == 0)){
    cout << getgameStatus(X, O, N, i,j, my_board[3][3]) << endl;
   }
   else{
    cout << displayTotals(X, O, N) << endl;
   }
}

void getgameStatus (int X, int O, int N, int i, int j, int my_board[3][3]){
  if (my_board[1][1] == x && my_board[1][2] == x && my_board[1][3] == x){ //All possible games where x wins
    cout << "x wins" << endl;
    X++;
  }
  else if (my_board[2][1] == x && my_board[2][2] == x && my_board[2][3] == x){
    cout << "x wins" << endl;
    X++;
  }
  else if (my_board[3][1] == x && my_board[3][2] == x && my_board[3][3] == x){
    cout << "x wins" << endl;
    X++;
  }
  else if (my_board[1][1] == x && my_board[2][1] == x && my_board[3][1] == x){
    cout << "x wins" << endl;
    X++;
  }if (my_board[1][1] == x && my_board[1][2] == x && my_board[1][3] == x){
    cout << "x wins" << endl;
    X++;
  }
  else if (my_board[2][1] == x && my_board[2][2] == x && my_board[2][3] == x){
    cout << "x wins" << endl;
    X++;
  }
  else if (my_board[3][1] == x && my_board[3][2] == x && my_board[3][3] == x){
    cout << "x wins" << endl;
    X++;
  }
  else if (my_board[1][1] == x && my_board[2][1] == x && my_board[3][1] == x){
    cout << "x wins" << endl;
    X++;
  }
    else if (my_board[1][2] == x && my_board[2][2] == x && my_board[3][2] == x){
    cout << "x wins" << endl;
    X++;
  }
    else if (my_board[1][3] == x && my_board[2][3] == x && my_board[3][3] == x){
    cout << "x wins" << endl;
    X++;
  }
    else if (my_board[1][1] == x && my_board[2][2] == x && my_board[3][3] == x){cout << "Total games won by x: " << X << endl;

}
    cout << "x wins" << endl;
    X++;
  }
    else if (my_board[1][3] == x && my_board[2][2] == x && my_board[3][1] == x){
    cout << "x wins" << endl;
    X++;
  }
    else if (my_board[1][2] == x && my_board[2][2] == x && my_board[3][2] == x){
    cout << "x wins" << endl;
    X++;
  }void displayTotals(X, O, N)
    else if (my_board[1][3] == x && my_board[2][3] == x && my_board[3][3] == x){
    cout << "x wins" << endl;
    X++;
  }
    else if (my_board[1][1] == x && my_board[2][2] == x && my_board[3][3] == x){
    cout << "x wins" << endl;
    X++;
  }
    else if (my_board[1][3] == x && my_board[2][2] == x && my_board[3][1] == x){
    cout << "x wins" << endl;
    X++;
  }
    else if (my_board[1][1] == o && my_board[1][2] == o && my_board[1][3] == o){ //All possible games where o wins
    cout << "o wins" << endl;
    O++;
  }
    else if (my_board[2][1] == o && my_board[2][2] == o && my_board[2][3] == o){
    cout << "o wins" << endl;
    O++;
  }displayTotals(X, O, N)
    else if (my_board[3][1] == o && my_board[3][2] == o && my_board[3][3] == o){
    cout << "o wins" << endl;
    O++;
  }
    else if (my_board[1][1] == o && my_board[2][1] == o && my_board[3][1] == o){
    cout << "o wins" << endl;
    O++;cout << "Total games won by x: " << X << endl;

}
  }
    else if (my_board[1][2] == o && my_board[2][2] == o && my_board[3][2] == o){
    cout << "o wins" << endl;
    O++;
  }
    else if (my_board[1][3] == o && my_board[2][3] == o && my_board[3][3] == o){
    cout << "o wins" << endl;
    O++;
  }
    else if (my_board[1][1] == o && my_board[2][2] == o && my_board[3][3] == o){
    cout << "o wins" << endl;
    O++;
  }
    else if (my_board[1][3] == o && my_board[2][2] == o && my_board[3][1] == o){
    cout << "o wins" << endl;
    O++;
  }

    else{
    cout << "game incomplete" << endl; //All incomplete games
    N++;
  }
}

void displayTotals(int X, int O, int N){
  cout << "Total games won by x: " << X << endl;
  cout << "Total games won by o: " << O << endl;
  cout << "Total games incomplete: " << N << endl;

}

And I have several of the same "expected primary expression before..." errors throughout. I can't figure out what's causing them. I'm new to this, so sorry if it's verbose. Thanks for any help you guys have.

A: Ok there are several things wrong with the code you've posted.
For starters, you should know that C++ is a case sensitive language. In multiple places you've done the following:
if (my_board[1][1] == x && my_board[1][2] == x && my_board[1][3] == x)

The problem is your variables are named X and O not x and o. Change those.
You're also trying to stream the return value of functions with a void return type. You simply cannot do that. void as its name implies is nothing, so you're trying to stream nothing to the console.
For your switch statement, you wrote:
case %2:

That is simply invalid. I'm not sure what you were trying to do there, so I can't really point you in the right direction.
Finally I noticed you have global variables that have the same name and type as your function parameters. There's really no point in having both. Either you have global variables to avoid passing them around (this is not good practice, don't do that) or you have function parameters; don't do both.


text:
Q: what is the difference if i return "YES" or "NO" when i call textFieldShouldReturn This is the text field delegate method  but i have doubt about return type
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
  [textField resignFirstResponder];

   return NO;
}

and this is the same method with different return type
-(BOOL)textFieldShouldReturn:(UITextField *)textField
 {
   [textField resignFirstResponder];

   return YES;
 }

by both we can hide key board in i phone . but what is the meaning of return type "YES" or "NO". I am not seeing any difference.

A: In addition to the other answers here (which essentially confirm there's no major difference, no auto-resigning of the first responder by returning YES, etc.), I've discovered a strange occurrence completely dependent on the return value, specifically for a UITextField with autocorrection.
Assume the following scenario:

*

*You have a UITextField with autocorrection enabled

*You've implemented the delegate method something like this (where the text field gets resigned):

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (textField == self.myAutocorrectingTextField) {
        [self.myAutocorrectingTextField resignFirstResponder];
    }
    return YES;
}

*You run the app, type "Cable" into the text field, then press the return key, resigning it as first responder.
The outcome when returning YES:

*

*The text field's text will have been changed from "Cable" to "Cables"!

I have tested a handful of other words that respond similarly:

*

*"Stuff" changed to "Stuffs"

*"Ten" to "Tens"

*And, one time "Car" changed to "Carl", another time "Car" changed to "Carp"

The outcome when returning NO:
Normal. The text field's text will not have been changed.
In Summary...
When returning YES, the text field may autocorrect already-correct words. It does not, however, present one of those "autocorrect text bubbles", because these are legitimate words.
When returning NO, the text field will not autocorrect already-correct words.
Note:
In both cases, incorrectly-spelled words will always be corrected. For example:

*

*If you were to type "Wev", an "autocorrection text bubble" should appear with the text "Web". If you hit the Return key, regardless of the delegate's return value, the text will be replaced with the correction.

A: One difference that I see based on personal experience is that if you return YES, auto correction and auto capitalization are triggered, if you return NO, they are not. There might be other things done, but that's all I could notice so far.
That's what they mean by "default behavior".

A: The most important difference I've found is that if the text field emits the control event UIControlEventEditingDidEndOnExit, this will cause the text field to resign first responder unless textFieldShouldReturn is implemented to return NO.

A: The textFieldShouldReturn is a place where you can handle the Return button on the keyboard.
textFieldShouldReturn asks the delegate if the text field should process the pressing of the return button.
If you implement your own code to process the return button you should return NO, or return YES for it to be handled in the default way.
The IOS Docs state:
The text field calls this method whenever the user taps the return button. You can use this method to implement any custom behavior when the button is tapped.
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITextFieldDelegate_Protocol/UITextFieldDelegate/UITextFieldDelegate.html


text:
Q: Parse html according to jquery with Php DOMDocument With jQuery i can fetch the required content from html.
var description =  $(".singlePostDescription .description > p:eq(0)").text();
var download_link = $(".row.video-bg .post-title p span:eq(2) a").attr("href");

I'm attempting to do the same thing with PHP DOMDocument.
 $dom = new DOMDocument();
 $dom->loadHTML($returned_content);
 $xpath = new DOMXPath($dom);

$description = $xpath->query('//div[@class="singlePostDescription"]/div[@class="description"]/p[1]');
$download_link = $xpath->query('//div[@class="video-bg"]/div[@class="description"]/p/span[3]/a');

How do i get the text() for description and href for download_link?


text:
Q: I cant get my code to open my .txt file and read if it has names in it In my code, it asks what is your name and if your name is in the file then say welcome back then their name if their name is not in it then ask if they want for Cora to remember it if yes then write their name into the file.
def AI():
    names = open("\\\\ph-fss1\\Students\\S39055\\Desktop\\names.txt","w")
    name = raw_input("Hello and welcome to the Creative, Orginal, Reactive, A.I, Cora. What is your name? ")
    file.read(names)
    if name in names:
        print "Welcome back " + name
    if name not in names:
      print "You are a new user would you like to me to remember your name?"
      name_yes = raw_input("Yes/No: ").lower()
      if name_yes == "yes":
          file.wright(name)
          file.close()

A: The issue was that you never actual read the contents of the file in order to check if the name existed. Try this:
name = raw_input("Hello and welcome to the Creative, Orginal, Reactive, A.I, Cora. What is your name? ")

if name in open("\\\\ph-fss1\\Students\\S39055\\Desktop\\names.txt").read():
     print "Welcome back " + name
else:
  print "You are a new user would you like to me to remember your name?"
  name_yes = raw_input("Yes/No: ").lower()
  if name_yes == "yes":
      with open("\\\\ph-fss1\\Students\\S39055\\Desktop\\names.txt", "a") as myfile:
          myfile.write(name)

A: Lets take a look at a few improvements. Since you use raw_input() i'll assume Python 2.x:
def AI():
    # you can use r'' to specify a raw string and avoid using '\\' to escape '\'
    fpath = r'\\ph-fss1\Students\S39055\Desktop\names.txt'

    # this is called a 'context manager'
    # when you are done with your operations, the file will close automatically
    # the 'r+' mode opens for reading and writing
    with open(fpath, 'r+') as f:

        # this is list comprehension and I assume each name is on a new line
        # a set is a container for unique values
        # assuming that you will not have multiple of the same names
        # if so, how do you plan to account for them?
        names = set([line for line in f])

        print "Hello and welcome to the Creative, Orginal, Reactive, A.I, Cora."
        name = raw_input("What is your name? ")
        if name in names:
            print "Welcome back " + name
        else:
            print "You are a new user, would you like to me to remember your name?"

            # this is fine, but what happens I just put in 'y' or 'n'?
            # look for methods to handle invalid input
            choice = raw_input("Yes/No: ").lower()
            if choice == "yes":

                # because we opened the file in 'r+', we seek(0) which puts us at the top
                # then when we writelines(list(names)) we overwrite the entire file
                # and store the original data with the new name as well
                file.seek(0)
                names.add(name)

                # writelines() just writes an iterable versus a string
                file.writelines(list(names))

There are some design choices you have to make here. But if you have any questions, ask away.


text:
Q: Django: reverse for REST framework login route not working I am pretty new to Django. Now I try to using Django Rest Framework.
I have my custom login template, and I want to POST my login form to the Rest Framework's login route (/api-auth/login by default).
In my main urls.py I have:
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))

So, in my template I'm trying to fetch url by namespace (rest_framework) and name (login):
<form id="loginForm" method="POST" action="{% url 'rest_framework:login' as login_url %}" name="loginForm">

But as a result I have empty action attribute in my form.
Can someone explain me, what I'm doing wrong?

A: Take the as login_url out of your action tag:
<form id="loginForm" method="POST" action="{% url 'rest_framework:login' %}" name="loginForm">


text:
Q: Laravel: why form::model not work with section -> yield? In edit.blade.php I have:
@section('additionalInputs')
    {!! Form::select('gender') !!}
@stop

@section('content')
    @include('backend.admin.user.form', ['formRoute' => ['backend.admin.user.update', $user->id], 'formMethod' => 'PUT'])
@stop

In backend.admin.user.form.blade.php I have:
{!! Form::model($user, ['route' => $formRoute, 'method' => $formMethod, 'class'=>'no-inline-edit']) !!}
    {!! Form::text('first_name') !!}
    {!! Form::text('last_name') !!}
    @yield('additionalInputs')
{!! Form::close() !!}

first_name and last_name are filled with data, why gender is not populated ?
If I put like this:
{!! Form::model($user, ['route' => $formRoute, 'method' => $formMethod, 'class'=>'no-inline-edit']) !!}
    {!! Form::text('first_name') !!}
    {!! Form::text('last_name') !!}
    {!! Form::select('gender') !!}
    @yield('additionalInputs')
{!! Form::close() !!}

first gender is populated, second is not...

A: The 1st argument of a Form::select is the input's name.
For a select input to be generated you need to provide array of data like the example below.
{!! Form::select('gender', [
     'male' => 'Male',
     'female' => 'Female'
      ])
!!}

or pass a $genders var through your controller to your view
{!! Form::select('gender', $genders) !!}


text:
Q: How can I put a newline in my zsh prompt without causing terminal redraw issues? I'm trying to fix a minor (but annoying) issue with my zsh prompt. The problem I'm seeing is that when I'm using a terminal in a GUI OS environment (for example, Terminal.app or iTerm 2 on OS X 10.7.2) and resize the terminal window, the terminal is redrawn with extra prompts.
I've reproduced the issue on a clean .zshrc that contains the following:
export PROMPT=">
"

To be clear, that's a two-line file. There is a literal newline in the string, which I've read in several (admittedly old) places is the way to go. This works until I resize the terminal window, at which point I end up with duplicate prompt strings. For example if I open a new window, I see (* being used a placeholder for my cursor):
Last login: Wed Jan 25 19:05:06 on ttys000
>
*

Then when I resize the window, making it shorter, I end up with:
Last login: Wed Jan 25 19:05:06 on ttys000
>
>
>
>
*

The number of extra prompt printouts seems roughly proportional to how much I change the window size -- usually vertically. If I remove the newline from the prompt string, the problem goes away.
I've tried various things, like $(print ">\n"), or trying to wrap the newline in %{%}. I'm assuming this has to do with the fact that newline confuses whatever is drawing w.r.t how long the prompt string actually is, or something. Is this problem fixable or do I just have to live with it?

A: How about something like this:
NEWLINE=$'\n'
PROMPT="Line1${NEWLINE}LINE2"

A: This problem is due to how ZSH reprints the promt on resize events and has also annoyed me before. The solution is to make $PROMPT single-line and print the first line of the prompt using a precmd.
So in your example that would simply be:
precmd() { print ">" }
export PROMPT=""

or for a more sophisticated example with prompt expansion in the print statement use the -rP parameters:
precmd() { print -rP "%~" }
export PROMPT="%# "

If you have more than one precmd registered you need to use add-zsh-hook precmd (see man zshcontrib).


text:
Q: Excel VBA .Filter on Access Recordset with single quotes in the filter string I have records in a Microsoft Access table. I'm trying to filter them with Excel VBA.
I can query the table fine and create a recordset. In the table there's a field "Row_Label". I want to see if the recordset contains a value "Tim's Roofing" in that column. I know I need to escape it somehow but every method for doing that is failing.
This is the .Filter expression
dim str as string
str = "[Row_Label] = """ & "Tim's Roofing" & """"
accessRSExistLabels.Filter = str

when I run this code, I get the error

Run-time error '3001':
Arguments are of the wrong type, are out of acceptable range, or are
in conflict with one another.

When I change the code to
str = "[Row_Label]='Test'"
accessRSExistLabels.Filter = str

It works fine, so I (think) this is an escaping issue and I'm doing it wrong, but I can't get .Filter to work.
Thanks for your help

A: You can use my CSql function:
str = "[Row_Label] = " & CSql("Tim's Roofing")
' xstr -> [Row_Label] =  'Tim''s Roofing'

' Converts a value of any type to its string representation.
' The function can be concatenated into an SQL expression as is
' without any delimiters or leading/trailing white-space.
'
' Examples:
'   SQL = "Select * From TableTest Where [Amount]>" & CSql(12.5) & "And [DueDate]<" & CSql(Date) & ""
'   SQL -> Select * From TableTest Where [Amount]> 12.5 And [DueDate]< #2016/01/30 00:00:00#
'
'   SQL = "Insert Into TableTest ( [Street] ) Values (" & CSql(" ") & ")"
'   SQL -> Insert Into TableTest ( [Street] ) Values ( Null )
'
' Trims text variables for leading/trailing Space and secures single quotes.
' Replaces zero length strings with Null.
' Formats date/time variables as safe string expressions.
' Uses Str to format decimal values to string expressions.
' Returns Null for values that cannot be expressed with a string expression.
'
' 2021-06-05. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function CSql( _
    ByVal Value As Variant) _
    As String

    Const TypeLongLong  As Long = 20
    Const SqlNull       As String = " Null"

    Dim Sql             As String

    #If Win64 Then
        ' VBA.VarType.vbLongLong exists.
    #Else
        Dim vbLongLong  As Integer
        vbLongLong = TypeLongLong
    #End If

    Select Case VarType(Value)
        Case vbEmpty            '    0  Empty (uninitialized).
            Sql = SqlNull
        Case vbNull             '    1  Null (no valid data).
            Sql = SqlNull
        Case vbInteger          '    2  Integer.
            Sql = Str(Value)
        Case vbLong             '    3  Long integer.
            Sql = Str(Value)
        Case vbSingle           '    4  Single-precision floating-point number.
            Sql = Str(Value)
        Case vbDouble           '    5  Double-precision floating-point number.
            Sql = Str(Value)
        Case vbCurrency         '    6  Currency.
            Sql = Str(Value)
        Case vbDate             '    7  Date.
            Sql = Format(Value, " \#yyyy\/mm\/dd hh\:nn\:ss\#")
        Case vbString           '    8  String.
            Sql = Replace(Replace(Trim(Value), "'", "''"), """", """""")
            If Sql = "" Then
                Sql = SqlNull
            Else
                Sql = " '" & Sql & "'"
            End If
        Case vbObject           '    9  Object.
            Sql = SqlNull
        Case vbError            '   10  Error.
            Sql = SqlNull
        Case vbBoolean          '   11  Boolean.
            Sql = Str(Abs(Value))
        Case vbVariant          '   12  Variant (used only with arrays of variants).
            Sql = SqlNull
        Case vbDataObject       '   13  A data access object.
            Sql = SqlNull
        Case vbDecimal          '   14  Decimal.
            Sql = Str(Value)
        Case vbByte             '   17  Byte.
            Sql = Str(Value)
        Case vbLongLong         '   20  LongLong integer (Relevant on 64-bit platforms only).
            Sql = Str(Value)
        Case vbUserDefinedType  '   36  Variants that contain user-defined types.
            Sql = SqlNull
        Case vbArray            ' 8192  Array.
            Sql = SqlNull
        Case Else               '       Should not happen.
            Sql = SqlNull
    End Select

    CSql = Sql & " "

End Function

A: Try:
str = "[Row_Label] = '" & "Tim''s Roofing" & "'"

Single ' need to be doubled-up


text:
Q: Is this class structurally correct? I use in final class this switch case:
$class = get_class($exception);

    switch ($class) {
        case \Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class:
            return self::fail(
                'page not found'
            );
        case \Illuminate\Database\Eloquent\ModelNotFoundException::class:
            return self::fail(
                'entity not found'
            );
        case \Illuminate\Database\QueryException::class:
            return self::fail(
                Str::contains($exception->getMessage(), 'Duplicate') ? 'duplicate error' : 'query error' // Check Query Exception Error
            );
        case \TypeError::class:
            return self::fail(
                'type error'
            );
        case ServiceException::class:
            /** @var ServiceException $exception */
            return self::fail(
                $exception->getMessage(),
                $exception->getErrors()
            );
        default:
            return self::fail(
                $exception->getMessage()
            );
    }

when i use phpinsights package for check code, I see this line:
Havingclasseswith more than 5 cyclomatic complexity is prohibited - Consider refactoring:
how refactor my code?

A: You could refactor them to separate classes, use the strategy pattern. However, I think for such a simple implementation, that is unnecessary.
Perhaps a more suitable approach, is creating a lookup table using an array. The key of the array is the class name of the exception, the value is a Closure that you should replace by your "fail" implementation.
I find that Refactoring Guru provides a lot of valuable information about this.
Example refactor:
$exceptionLookupTable = [

   NotFoundHttpException::class => function() {
       return 'HTTP error stuff';
   },

   ModelNotFoundException::class => function() {
       return 'Model error stuff';
   },

  TypeError::class => function() {
      return 'Type error stuff';
  },

  ServiceException::class => function() {
      return 'Service error stuff';
  },

];

$exception = new TypeError; // create example type error

$class = get_class($exception);

$handler = $exceptionLookupTable[$class] ?? function() {
    return 'do stuff'; // this is the default case
};

$handler(); // returns "Type error stuff"

Any new errors can simply be added to the exception lookup table.


text:
Q: Not able to install anything in Ubuntu 12.04 Software Center As displayed in below image, I am having trouble in installing any software in ubuntu 12.04 software center. I am not able to cancel the 1st process ("searching"), though I have many times clicked to cancel it. And because of that process, I am not able to install any other packages.
If I try to install anything from the terminal I get
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
How can I get rid of this situation??

A: try sudo apt-get install command from the terminal, it might help

A: You can check whether apt-get is running with
ps ax | grep apt-get

If it runs you can kill it with
sudo kill -9 [pid]

If it still doesn't work and you are sure all processes that use this lock are closed (softwarecenter, any apt-get in consoles) you can delete the lock as a last resort
sudo rm /var/lib/dpkg/lock

You might also need to remove the chache lock
sudo rm /var/cache/apt/archives/lock

After that you might have to run
sudo dpkg --configure -a

Note that if something is still updating packages in the background (forgotten apt-get or softwarecenter) this can cause troubles


text:
Q: jQuery droppable hover event not firing on first attempt I'm having an issue where droppable areas are not accepting draggable items on the first attempt. Subsequent attempts seem to work just fine.
Please see this code - http://jsfiddle.net/grimmus/Pp9Qf/
//binding droppable property to generated columns
$("#contents").delegate('li', 'mouseover', function () {
    $(this).droppable({
        activeClass: "ui-state-active",
        hoverClass: "ui-state-hover",
        accept: ".ui-draggable",
        drop: function (event, ui) {
            $("").text(ui.draggable.text()).appendTo(this);
        }
    });
});

You create a panel by selecting a number from the dropdown in the right area and pressing add.
The boxes in the created panel are all droppable. Then, choose employee from the 'select a model' dropdown.
The droppable areas should display a dashed border when an acceptable drag item hovers over it. This doesnt seem to happen the first time i try. If i redrag the item again the hover class appears and the item is accepted.
Any ideas what might be going wrong ? Seems something isn't getting initialized properly
Tested in Chrome and Firefox.
Thanks


text:
Q: IncrediBuild compile some projects of Visual Studio 2010/2012 solution in one thread We try to upgrade our VS2008 solution consist of ~20 projects to VS2010, but there is a problem with building some of them. I tried different versions of VS(2010, 2012, 2013. even with vc90 compiler version) / IncrediBuild(4.61, 5.0, 6.1) / Windows(7, 8) but nothing helps. All possible options of projects and Incredi were changed too. Custom build rules and steps doesn't set for these projects. Please, tell me someone what can I do to solve the problem.
I couldn't load images yet, so this is a link to build graph screenshot.
Upd: I've tried to compile solution in VS2013 without IncrediBuild, but with /MP option, and have got identically the same - some files of project were compiled sequentiallly and in the same order, so Incredi is innocent and the problem only in our project and how the VS works with it.

A: The latest public version of IncrediBuild introduced a feature which is exactly what you are asking for - truly out-of-order \ optimized parallelization.
This new feature, allows IncrediBuild to execute Visual Studio tasks in parallel even in scenarios where Visual Studio does not know how to do that. Meaning that with IncrediBuild, every task that is not REALLY dependent on a previous task, will be executed in parallel to it.
So in a scenario as described above, although filling the fixed output object file names results in Visual Studio (and MSBuild) compiling these files in a sequential manner, IncrediBuild will compile them in parallel.
In addition to that, in a scenario where project B depends on project A, Visual Studio will only compile sources from project B AFTER linking of A is done (although most of the time Project B compilations don't depend on project A compilations, only the link steps of these projects depend upon each other), IncrediBuild will be able to compile both project A and project B in parallel, following by a link of A and a link for B.
Hope this shed some light on the topic.
Disclaimer: the writer is CTO at IncrediBuild

A: So, the problem was that some of cpp-files had fixed output object file names. When these parameters were cleared compilation for them begun parallel. But in VS2008 everything was fine even with such parameters properties


text:
Q: a function calling itself periodically until condition, but loops quickly to crash I am attempting to build a function that checks periodically an indefinite number of variables, and if they are all false, does something.
The function should "return" when the conditions are met, and call itself otherwise every x ms.
Here I use a setTimeout for the function to call itself, with a long delay to attempt to avoid quick loop and crash. But for some reason the function calls itself right away. It does so many times, crashing the browser (and actually my OS a few times).
I seem to be in lack of some basic understanding of how the nesting function progresses.
As it is now, the function loops and crashes, beware.
The offending line is at the end of function checkIf(), there is the setTimeout that calls the function itself again.
The variables the function looks for are "users[i].listening", if you want to simulate meeting the conditions, change them both to false.
// *****DO NOT RUN THIS CODE, IT LOOPS/CRASHES BROWSERS
// *****************************************************

users = [{user:"11", listening: "true"},{user:"22", listening:"false"}];

function checkIf(){
    var falses = 0; // We assume there are no users with listening = "false" yet
    for (var i = 0; i < users.length; i++) { // for each user
          if(users[i].listening == "false"){ // if its listening is "false"
              falses++; //+1 to var falses
              if (falses == users.length){ // && if all user's listening are false
                  userDo(); // launch the action
                  return true; // get out of checkIf()
              }
          }
     }

     //THIS SEEMS TO BE WHAT CAUSES THE LOOP/CRASH >>>>
     setTimeout(checkIf(), 4000); //otherwise repeat every 4 seconds
}

function userDo(){ //this function makes those users do stuff
    for (var i = 0; i < users.length; i++) {
        console.log("user " + users[i].user +" do this or that");
    }
}

checkIf(); //launch the checking function for the first time

Here the fiddle (with some console.log for debugging)
https://jsfiddle.net/r1jo84jm/1/
Thanks for reading, and your help.


text:
Q: Laravel 4 resource controller show($id) method problems Does it have to be the 'id' column in database table which works fine for
show($id), edit($id) method in controller?
I want to replace $id with the value of 'post_id' column in database table, but it throws error: ModelNotFoundException
How can I fix it?
sample code:
database table:

id(int), post_id(varchar32), post_title(varchar32), post_content(text)

routes:

Route::resource('posts', 'PostsController');

PostsController:

public function show($id)
      {
          return View::make('posts.show');
      }

When I visit http://localhost/posts/1
it should return the view of post which has id 1 in the table.
What if I what to return the view based on post_id value in the table?
Does it have to replace the parameter in show() or ?

A: In your PostsController you need to access the Post model to get the data from the db.
like this:
    //PostsController
public function show($id) {
$post = Post::where('post_id', $id)->first();

return View::make('posts.show', compact('post'));
}

A: you can also use find
public function show($id) {
$post = Post::find($id);
return View::make('posts.show', compact('post'));
}


text:
Q: android studio maps occasionally not working I have an app that, at first start, downloads some coordinates from the internet, save them in a database, add markers on the map, and zoom in on them.
The app works fine the first time, and the second time I run it. But on the third(and sometimes the forth) it stops adding the markers and zooming in on the map. I get no errors and even when I hard-code the coordinates that the map will zoom in on, it doesn't do it. I created a "Log.i" right before the movecamera, and one right after and they both prints to logcat, but the map doesn't zoom.
Sometimes I can hold the "home"-button exit all apps, restart my app, and it works again. But sometimes it doesn't work when I do that either.
My friend works on the same app but she doesn't have that problem on her phone, but I have the problem on both my phones. She has a higher sdk-version, can that be the reason why it works for her?
Any idea where to look for a solution?


text:
Q: Minimal Silverlight example What is the really minimal example of Silverlight application?
For example, I made the following example with IronPython:
from System.Windows import Application
from System.Windows.Controls import Canvas, TextBlock

canvas = Canvas()
textblock = TextBlock()
textblock.FontSize = 24
textblock.Text = 'Hello!'
canvas.Children.Add(textblock)

Application.Current.RootVisual = canvas

Then I used chiron and it created a .xap file. No (explicit) XAML, no nothing. Is it possible to do the same in, say, C#? One source file which I could compile from command line? If so, what would the source code be?
My motivation is to try and create silverlight app with unconventional languages, right now I am stuck at Boo...

A: using System;
using System.Windows;
using System.Windows.Controls;

namespace MimimalSilverlightApp
{
    public class App : Application
    {
        public App()
        {
            this.Startup += this.Application_Startup;
        }

        private void Application_Startup(object sender, StartupEventArgs e)
        {
            var canvas = new Canvas();

            var textblock = new TextBlock();
            textblock.FontSize = 24;
            textblock.Text = "Hello!";
            canvas.Children.Add(textblock);

            this.RootVisual = canvas;
        }
    }
}

A: Found an F# example here.
Made a Boo example based on it. The source code:
namespace Hello
import System
import System.Windows
import System.Windows.Controls

class MyPage(UserControl):
    def constructor():
        canvas = Canvas()
        textblock = TextBlock()
        textblock.FontSize = 24
        textblock.Text = "Hello!"
        canvas.Children.Add(textblock)

        self.Content = canvas

class MyApp(Application):

    def constructor():
        Startup += onStartup

    def onStartup(sender, e):

        self.RootVisual = MyPage()

Built with:
booc -nostdlib -target:library -lib:"C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies","C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client" -r:System.Windows.dll -r:System.Windows.Controls.dll Hello.boo

The AppManifest.xaml:
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            EntryPointAssembly="Hello"
            EntryPointType="Hello.MyApp" RuntimeVersion="2.0.31005.0">
  <Deployment.Parts>
    <AssemblyPart x:Name="Hello" Source="Hello.dll" />
    <AssemblyPart x:Name="Boo.Lang" Source="Boo.Lang.dll" />
  </Deployment.Parts>
</Deployment>

Then made an ordinary .zip file containing AppManifest.xaml, Hello.dll and Boo.Lang.dll (one of Boo libraries from it's directory) and renamed it into hello.xap.
An html to look at it:

<object id="SilverlightPlugin" data="data:application/x-silverlight,"
 type="application/x-silverlight-2" width="450" height="540">
  <param name="source" value="hello.xap"/>

</object>

The resulting hello.xap is 43 KB, which is much better than 1.5 MB that I got with IronPython and DLR.


text:
Q: Converting cURL to Python Requests I need to convert the following cURL command to python requests.
curl 'https://test.com/api/v1/courses/xx/discussion_topics/xx/entries.json' \
 -F 'message=<message>' \
 -H "Authorization: Bearer <token>"

So far I have requests.post("https://test.com/api/v1/courses/xx/discussion_topics/xx/entries")
but how do I add the message and auth?

A:  requests.post("https://test.com/api/v1/courses/xx/discussion_topics/xx/entries.json, data=json.dumps({"message": "<message>"}), headers={"Authorization": "Bearer <token>"})


text:
Q: Add custom attributes to link in Gutenberg Is it possible to add custom attributes to link in Gutenberg editor? Please don't tell me to add those attributes from Edit as HTML view. Probably, there can add a new field in the link editor popup for adding the new attributes.
Is it possible to add a new field in the Gutenberg link editor popup? See the link editor below.


text:
Q: Which books should I read to gather practical and useful electronic design skills? I need some guideance from the experienced users here, I need to know where to focus my studies:
Ive been reading several electronic books, and they are quite different, I decided I want to re-learn from scratch most about semiconductors, so I have 3 books: "Electronic Design" by Savant, Roden and Carpenter, "Electronic Devices" by Floyd, and the classic "Electronic devices and Circuit Theory" by Boylestad.
Floyd's book is very easy to read and understand but sometimes I think it lacks going deeper into the subject, yet its very practical. Savant's book is more math/theory oriented similar to Sedra/Smith but a bit lighter, and Boylestad's is somewhere in the middle.
While im very fond of math, some math/theory or physicist oriented books like Savant "Electronic Design" or Sedra/Smith "Microelectronic devices" lack the practicality of Floyds book, and focus mostly on stuff that I find to be completely useless (at least so far). For example, Ive been reading about the diode, and both books give a lengthy explanation on how the diode works, and all the math around it. They end up presenting the following formula (among many others derived from it):

I have no doubt in my mind that the formula above is a great model to describe the exponential behavior of a diode. The only problem is that any way I try to apply it to a real world scenario I find it to be completely useless and completely far off from the aproximate value calculated by just stating that Vf=0.7V.
Also, a lot of the excercises in such books are also very abstract, for instance they'll use instantenous voltage equations to represent an AC signal, in which the results are expressed in sine or cosine equations rather than round numbers.
Are any of the before mentioned equations useful in a daily life scenario?
So my question is: Should I dump the heavy theory books and focus mainly on the ones which give practical applications? and is it worth knowing those sort of ideal mathematical model equations, or should I keep on doing what im doing now, which is basically reading the same chapters from all the books trying to get out whats best from each one of them? my only fear is that by using this method I will only get more confused, since some books use slightly different methods, name the same variable with different names, etc...
Several engineers have told me I need to know a lot of theory if i want to be a good designer, and some others tell me I should focus on the stuff that works.

A: The Art of Electronics by Paul Horowitz, Winfield Hill is very readable.

A: For a real beginner I would recommend:
How to Diagnose and Fix Everything Electronic by Michael Geier
and
Make: Electronics (Learning by Discovery) by Charles Platt


text:
Q: Create a list of types and access a static member of each type? I have a number of child classes which all have a static type_id field. What I am trying to do is save a list of types (which from searching around, I know that's a touchy subject) and then access the type_id of the types in my type list. Here's an example
// Example program
#include <iostream>
#include <tuple>

struct base_type
{
    static const uint64_t type_id = 0;
};

struct A : public base_type
{
    static const uint64_t type_id = 1;
};

struct B : public base_type
{
    static const uint64_t type_id = 2;
};

struct C : public base_type
{
    static const uint64_t type_id = 3;
};

template <class... Args>
struct type_list
{
    template <std::size_t N>
    using type = typename std::tuple_element<N, std::tuple<Args...>>::type;
};

int main()
{
  using my_types = type_list<base_type, A, B, C>;
  std::cout << my_types::type<1>.type_id << std::endl;
}

And then hopefully that would print out 1. However, if you try to compile this it won't work. Is there any way to achieve something like this?

Edit: The solution was so simple I'm ashamed. Just needed my_types::type<1>::type_id instead of my_types::type<1>.type_id

A: Access of static member from type uses :: not .:
my_types::type<1>::type_id


text:
Q: Is there a way to insert permissions using google drive api to a folder containing subfolders? Google has recently changed the permission propagation for drive.file scope. If you try to give permission to a folder containing subfolder(s) the following error occurs:
Google.Apis.Requests. RequestError: The authenticated user may not have granted the app xxx write access to all of the children of file yyy [403]

I tried to firstly insert permissions to all subfolders and then to the parent folder. Inserting permissions to subfolders succeeds but inserting permissions to the parent folder gives again the same error. I can confirm this is not an issue in the general drive scope. Any solution?


text:
Q: Android Studio KT NullPointerException error I added a few button functions to the main activivty.kt in my android studio project, and as far as I know, I initialized and called the variables.

package com.dev.afp

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.animation.AnimationUtils
import android.widget.Toast
import android.widget.Toast.makeText
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.splashscreen.*
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val images = listOf(
            R.drawable.thumbnail_image001,
            R.drawable.image00,
            R.drawable.image01,
            R.drawable.image03,
            R.drawable.image04,
            R.drawable.image10,
            R.drawable.image13
        )

        val adapter = ViewPagerAdapter(images)
        viewPager.adapter = adapter

        TabLayoutMediator(tabLayout, viewPager) { tab, position ->
            tab.text = "${position + 1}"
        }.attach()

        tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
            override fun onTabSelected(tab: TabLayout.Tab?) {
                makeText(
                    this@MainActivity,
                    "Reselected Tool Segment ${tab?.text}",
                    Toast.LENGTH_SHORT
                ).show()
            }

            override fun onTabUnselected(tab: TabLayout.Tab?) {
                makeText(
                    this@MainActivity,
                    "Unselected Tool Segment ${tab?.text}",
                    Toast.LENGTH_SHORT
                ).show()
            }

            override fun onTabReselected(tab: TabLayout.Tab?) {
                makeText(
                    this@MainActivity,
                    "Selected Tool Segment ${tab?.text}",
                    Toast.LENGTH_SHORT
                ).show()
            }
        })
        btnZoomIn.setOnClickListener {
            val animation = AnimationUtils.loadAnimation(this,R.anim.zoom_in)
            textView.startAnimation(animation)
            makeText(this@MainActivity, "Zoomed In", Toast.LENGTH_SHORT).show()
        }
        btnZoomOut.setOnClickListener {
            val animation = AnimationUtils.loadAnimation(this,R.anim.zoom_out)
            textView.startAnimation(animation)
            makeText(this@MainActivity, "Zoomed Out", Toast.LENGTH_SHORT).show()
        }
        slide_down.setOnClickListener {
            val animation = AnimationUtils.loadAnimation(this,R.anim.slide_down)
            textView.startAnimation(animation)
            makeText(this@MainActivity, "Moving Down", Toast.LENGTH_SHORT).show()
        }
        slide_up.setOnClickListener {
            val animation = AnimationUtils.loadAnimation(this,R.anim.slide_up)
            textView.startAnimation(animation)
            makeText(this@MainActivity, "Moving Up", Toast.LENGTH_SHORT).show()
        }

This is the error that is given when I click the buttons in the emulator.
    Process: com.dev.afp, PID: 13840
    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.startAnimation(android.view.animation.Animation)' on a null object reference
        at com.dev.afp.MainActivity$onCreate$1.onClick(MainActivity.kt:21)
        at android.view.View.performClick(View.java:7448)
        at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:992)
        at android.view.View.performClickInternal(View.java:7425)
        at android.view.View.access$3600(View.java:810)
        at android.view.View$PerformClick.run(View.java:28305)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Everything is imported, and there are no problems there. I understand the NullPointerException is telling me the object I am calling is null, but i'm not sure where I went wrong. Help is appreciated.
Okay: i'm adding the xml files.
activitymain xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/red"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/slide_up"
        android:layout_width="100dp"
        android:layout_height="60dp"
        android:layout_marginTop="4dp"
        android:layout_weight="1"
        android:baselineAligned="false"
        android:background="#000000"
        android:text="Slide Up"
        app:layout_constraintStart_toEndOf="@+id/btnZoomOut"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/btnZoomIn"
        android:layout_width="100dp"
        android:layout_height="60dp"
        android:layout_marginStart="4dp"
        android:layout_marginLeft="4dp"
        android:layout_marginTop="4dp"
        android:text="Zoom In"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        android:background="@color/red"
        app:layout_constraintTop_toBottomOf="@+id/btnZoomIn" />

    <Button
        android:id="@+id/btnZoomOut"
        android:layout_width="100dp"
        android:layout_height="60dp"
        android:layout_marginTop="4dp"
        android:text="@string/zoom_out"
        app:layout_constraintStart_toEndOf="@+id/btnZoomIn"
        android:background="#000000"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/slide_down"
        android:layout_width="100dp"
        android:layout_height="60dp"
        android:layout_marginStart="100dp"
        android:layout_marginLeft="100dp"
        android:layout_marginTop="4dp"
        android:text="@string/slide_down"
        android:background="#000000"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.971"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.viewpager2.widget.ViewPager2
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:layout_editor_absoluteX="25dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

Viewpager

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/ivImage"
        android:layout_width="384dp"
        android:layout_height="395dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

A: The NPE is happening on a textView that you reference within the OnClickListener, but it seems it is not included in the layout file that you are referring to. Please verify the view you would like to animate, or the layout file.

A: I believe you are wanting to start animation on click of the buttons. You will first have to initialize these buttons and then go forth and start Animation on them. Example to start animation on one of your buttons
val btnZoomIn = findViewById<Button>(R.id.btnZoomIn)
btnZoomIn.setOnClickListener {
            val animation = AnimationUtils.loadAnimation(this,R.anim.zoom_in)
            btnZoomIn.startAnimation(animation)
            makeText(this@MainActivity, "Zoomed In", Toast.LENGTH_SHORT).show()
        }


text:
Q: How to update order total amount after attaching order id to the order item execute api ? (odoo12.0) I want to create an order using odoo-xml-rpc using node js. Write now i created order first and then I am creating the order item as mentioned in the following url :- https://stackoverflow.com/a/40595869/363661
odoo.execute_kw('pos.order', 'create', params, function (err, value) { //first creating order
    if (err) { return console.log(err); }
    console.log(value)
        var inParams = [];
        inParams.push({
            'order_id' : value //passing previous executed order_id to order item
    })
        var params = [];
        params.push(inParams);
        odoo.execute_kw('pos.order.line', 'create', params, function (err, value) { // then create order item with that order id
            if (err) { return console.log(err); }
            res.send('order item created')
        });

});

The logic here is first we create an order and pass that order id to the line item creating api. But the problem here is "amount_total" is mandatory when creating order and after attaching order id to order item the order amount is not updating . How can we manage order subtotal using api? ( I am using nodejs xml-rpc)


text:
Q: Evaluating $\lim_{x \to 0^-} \frac{e^{\frac{1}{x}}}{x}$ how can one evaluate the limit below?
$$\lim_{x \to 0^-} \frac{e^{\frac{1}{x}}}{x}$$
Using L'Hôpital's rule seems to provide no progress: as x approaches zero from the left, $\frac{1}{x}$ approaches $-\infty$, so we have an indeterminate form $\frac{0}{0}$. Deriving both equations,
$$\lim_{x \to 0^-} \frac{e^{\frac{1}{x}}}{x} = \lim_{x \to 0^-} \frac{e^{\frac{1}{x}} \cdot \left[\frac{1}{x} \right]'}{1} = - \lim_{x \to 0^-} \frac{e^{\frac{1}{x}}}{x^2}$$
$$$$
Thank you.

A: Set $-\dfrac1x=y$ to get $$\lim_{y\to+\infty}\dfrac y{e^y}=\lim_{y\to+\infty}\dfrac1{e^y}=\cdots$$


text:
Q: How to generate an automatic bash/script I'm new to terminal and unix like systems. I'm searching a way to automatically create a batch file.
Let's say I have a bunch of files in a folder, and I want to change the creation dates. As it is now, I have to touch -t 201704011215.00 Desktop/Old_cam_vids_converted_from_avi_to_mp4/file0001.mp34 for each file. What I would like to do is something like this: ls -lT /Desktop/Old_avi_to_conv/*.avi and have the date and time for each file as time-date parameter for the touch command.
How can I accomplish this?
Edit:
I hope the explanation makes it clearer. This is the scenario:

*

*Two folders on the desktop containing video files.

*one (folder_1) contains the original files (.avi)

*the second (folder_2) contains converted files (.mp4)

*all the files in the second folder have a newer sequential date, since the conversion tool made worked through a list of files.

*I need to take the date/time stamp from the original file, in the first folder and assign it to the converted file in the second folder.

*each file in the first folder has a different date, possibly days and months apart.

*the files in the second folder have the same names than the ones in the first folder, except for the file suffix, e.g.:
folder_1/CIMG_0001.avi is the original of folder_2/CIMG_0001.mp4
folder_1/PIC_0003.avi is the original of folder_2/PIC_0003.mp4
folder_1/PIC_0015.avi is the original of folder_2/PIC_0015.mp4
folder_1/CIMG_003.avi id the original of folder_2/CIMG_0003.mp4

A: You need to process each mp4 file individually:
cd folder_2
for m in *.mp4; do
    a="${m%.mp4}".avi
    if [[ -r "/path/to/folder_1/$a" ]]; then
         echo touch -r "/path/to/folder_1/$a" "$m"
    fi
done

Run once to verify that the generated output makes sense, then remove the echo and rerun.
PS: This assumes that the names of the video files don't contain the string ".mp4" as such.


text:
Q: Two NavigationBar Items appears twice in the second current view I have a current SwiftUI View with a Navigation Bar item . I created a Back Button on this current view so that the title is not inherited from the previous view (NEWSview)  with list of news websites to navigate to the current view  and clicking on the back button returns me to the previous view. This is sample code of the previous view screen how i did:
struct ContentView: View {

    @ObservedObject var networkManager = NetworkManager()
    var body: some View {

        NavigationView {
            List (networkManager.posts) { post in
                NavigationLink (destination: DetailView(url: post.url) ) {
                    HStack {
                        Text(String(post.points))
                        Text(post.title)
                    }
                }
            }
            .navigationBarTitle("News")

        }
        .onAppear {
            DispatchQueue.main.async {
                self.networkManager.fetchData()
            }
        }

    }
}

This is the current screen view that is having the two buttons:
struct DetailView: View {
    let url : String?
    @Environment(\.presentationMode) private var mode
    var body: some View {
        WebView(urlString: url)
            .navigationBarItems(leading:
                                    Button(action: {
                                        self.mode.wrappedValue.dismiss()
                                    }, label: {
                                        HStack(spacing: 10) {
                                            Image(systemName: "chevron.left")
                                                .resizable()
                                                .frame(width: 10.0, height: 19.0)
                                                .font(.headline)
                                            Text("Back")

                                        }
                                    })
            )
    }
}

Now the issue is : The current screen NavBar has two buttons like this : one with news title and the back button (Picture attached) . I want only to remain with the Back Button on the current view that on click will navigate back to the previous root view . I thought what i did is right but missing something . If remove the entire code with the button in the current view , i will only see the "NEWS" navigation that on click will return me to the News View but i want a back title that should not be inherited from the news view .


text:
Q: Implement Google Analytics 4 in a .pug file I'm struggling to incorporate Google Analytics 4 to a .pug template file. (I'm new to Google Analytics and web development in general so there may be an obvious mistake I've made, but I can't find it.) I found this old thread from several years ago, and tried to use the solution with the title "2019 GTag Update" posted on August 19, 2016, but doing so did not activate GA. (I continued getting the message in my Google Analytics property that data collection wasn't active.) This is confusing because when I load the site and inspect the HTML, it appears to match up perfectly with the tagging instructions from Google Analytics.
Any help is greatly appreciated! Thanks!
  head
    // Google tag (gtag.js)
script(async='' src='https://www.googletagmanager.com/gtag/js?id=G-**********')
script.
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-**********');
title= title


text:
Q: SQL total row count I need to select the number of rows:
select
    int_re_usu as Qtd_Respostas
from
    tb_questionario_voar_resposta
group by
    int_re_usu

It  returns:
1- 687
2- 375076
3- 339012
4 -314083
5 -52741
6 -339977
7- 276041
8- 373304
9 - 339476
10- 51095
11- 270365
12 - 6
13 - 308670
14 -305232
15 - 85868
16 - 9893
17 -300598
18 - 300572
19 - 275889
20 - 6092
21 - 80092
22 - 307104
23 -273393

I want to select instead the number 23,which is the total row_count.
Any ideias?

A: Use @@RowCount
select int_re_usu as Qtd_Respostas from tb_questionario_voar_resposta  group by int_re_usu
Select @@RowCount

OR
Use a Derived Table
Select Count(*) from
(select int_re_usu as Qtd_Respostas from tb_questionario_voar_resposta  group by int_re_usu) q1

A: Use COUNT():
select COUNT(*) FROM (
    SELECT int_re_usu as Qtd_Respostas
    from tb_questionario_voar_resposta
    group by int_re_usu
)

A: Instead of GROUP BY, you can use DISTINCT:
SELECT COUNT(DISTINCT int_re_usu)
FROM tb_questionario_voar_resposta

A: select count(*) from
( select int_re_usu as Qtd_Respostas from tb_questionario_voar_resposta  group by int_re_usu ) as a

A: You can use the count(*) function.
select count(*)
from table_name
group by column_name

A: With temp as
( select int_re_usu as Qtd_Respostas
  from tb_questionario_voar_resposta
  group by int_re_usu )

Select count(*) from temp


text:
Q: What is the best way in SQL to swap the direction of a one-to-many relationship? Okay, so for whatever reason I have ended up with a situation where the key is pointing the wrong way in a one-to-many.  It was obviously never used as a one-to-many, only as a one-to-one, and now there is a need to expand one of those to be many, and the way the key was stored this turned out to be backwards.
The images table has a target_id, target_type and target_column, three pieces of information which identify it with any number of content tables.  The target_type just references the table name of the piece of content that is associated to the image.  target_column is the name of a virtual column (not actually in the content table) that is used to look up the image.  This enables any arbitrary piece of content to have several associated images, each by a different name.
When you have a piece of content and want to find what image is associated to a particular name, you do a
select * from images where target_id = content.id
    and target_type = "content"
    and target_column = "image";

All of these pieces of information are available when you have a reference to a particular piece of content.
What I want to do instead is REVERSE all of these, so that the images table knows nothing about the particular pieces of content that reference it, and instead that burden is carried by each of the content tables.
So far I know I can add a column to the content table and then select the information I need from the images table:
select id, target_id from images where target_type = "content";

What I want to do is use this as a subquery and do a mass update of the content table.  Is something like this possible?
update content set image_id =
    (select id from images where target_type = "content") as image_ids where id =
    (select target_id from images where target_type = "content") as content_ids;

I know this fails, but I want to do some kind of mass assignment of target_ids back to image_ids.  Is this madness?  How do I do this?

A: you might want to use the Mysql multiple-table update mechanism. (cf http://dev.mysql.com/doc/refman/5.0/en/update.html)
in your case, this would be
update
    content,
    images
set
    content.image_id = images.id
where
    images.target_id = content.id
    and images.target_type = 'content'
    and images.target_column = 'images'

I hope this will help you
Jerome Wagner

A: You can join in the images table to do the update:
update content inner join images on images.target_id = content.id and
    images.target_type = 'content' and images.target_column = 'images'
set content.image_id = images.id