text:
Q: How do you make content inside the body tag of a website completely scalable? Demo: https://codepen.io/anon/pen/MbWxGX
Basically when the website scales I want all the content inside the body tag (border included) to scale similarly to how an svg file would. The body content should stay in the center of the page no matter what the resolution is. Is there any way this is possible?
CSS:

/*
 ------------------------------------------------------------------------------------------------------------
|   Written and designed by -redacted- for -redacted-, trying to be as low-impact and minimal as possible.  |
|   Some stuff WILL NOT work in older IE browsers - impossible to develop for anyway so it hardly matters.   |
 ------------------------------------------------------------------------------------------------------------
*/

/* Makes the page wrap to the center to ensure the house style is kept to and content is actually viewable. */
#page-wrap {
     width: 900px;
     margin: 0 auto;
}

html {
    background-color: white;
    resize: both;
    overflow: auto;
}

body {
    position: absolute;
    margin: 0;
    top: 30%;
    left: 25%;
    right: 25%;

    transform: translate(-50%, -50%)
    border-color: white;
    color: white;
    font-family: Arial;
    background-color:rgba(0, 0, 0, 0.5);
    padding:3px 30px 30px 30px;
    border-style: solid;
    border-width: 2px;
    text-align:center;

    /* CSS for the fade-in effect */
    opacity: 1;
    transition: 1s opacity;
}
h1 {
    margin-top: 20px;
    margin-bottom: 5px;
    font-family: Porter Bold;
    font-size: 75px
}

ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #dce3ef;
}

li {
    width: 105%;
    align-content: center
}

li a {
    color: black;
    font-family: Porter Bold;
    display: block;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    width: 23.8%;
    float: left;
}

/*
All of the a:hover CSS is cool webkit stuff for making glowing edges around things
          I've implemented it for glowing fancy looking hyperlinks.
*/
li a:hover {
    background-color: #8b8f96;
    text-shadow: -1px 1px 20px #ffc, 1px -1px 20px #fff;

    -webkit-transition: text-shadow 250ms linear 0s;
    -moz-transition: text-shadow 250ms linear 0s;
    -o-transition: text-shadow 250ms linear 0s;
    transition: text-shadow 250ms linear 0s;
}

h3 a:hover {
    color:darkorange;
    text-shadow: -1px 1px 20px #ffc, 1px -1px 20px #fff;

    -webkit-transition: text-shadow 250ms linear 0s;
    -moz-transition: text-shadow 250ms linear 0s;
    -o-transition: text-shadow 250ms linear 0s;
    transition: text-shadow 250ms linear 0s;
}

footer a:link {
    color: orange;
}

footer a:hover {
    color:darkorange;
    text-shadow: -1px 1px 20px #ffc, 1px -1px 20px #fff;

    -webkit-transition: text-shadow 250ms linear 0s;
    -moz-transition: text-shadow 250ms linear 0s;
    -o-transition: text-shadow 250ms linear 0s;
    transition: text-shadow 250ms linear 0s;
}
footer {
    margin-top: 20px;
    text-align: center;
    font-size: 14px
}

/*
        CSS3 Fade-in text because I'm too lazy to implement jQuery,
and it's more lightweight and multifuctional than any jQuery solution anyway.
*/

/*  ----------------------------------------------------- Beginning of Fade-in -----------------------------------------------------  */
.fadeintext {
    -webkit-animation: fadein 2s;
    /* Safari, Chrome and Opera > 12.1 */

    -moz-animation: fadein 2s;
    /* Firefox < 16 */

    -ms-animation: fadein 2s;
    /* Internet Explorer */

    -o-animation: fadein 2s;
    /* Opera < 12.1 */

    animation: fadein 2s;
}
@keyframes fadein {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
/* Firefox < 16 */

@-moz-keyframes fadein {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
/* Safari, Chrome and Opera > 12.1 */

@-webkit-keyframes fadein {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
/* Internet Explorer */

@-ms-keyframes fadein {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
/* Opera < 12.1 */

@-o-keyframes fadein {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/*  ----------------------------------------------------- End of Fade-in -----------------------------------------------------  */

/* Fullscreen non-interactable YouTube CSS to create the video background for the site. */
/*  ----------------------------------------------------- Beginning of YouTube CSS -----------------------------------------------------  */
* { box-sizing: border-box; }
.video-background {
  background: #000;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: -99;
}
.video-foreground,
.video-background iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@media (min-aspect-ratio: 16/9) {
  .video-foreground { height: 300%; top: -100%; }
}
@media (max-aspect-ratio: 16/9) {
  .video-foreground { width: 300%; left: -100%; }
}
@media all and (max-width: 600px) {
.vid-info { width: 50%; padding: .5rem; }
.vid-info h1 { margin-bottom: .2rem; }
}
@media all and (max-width: 500px) {
.vid-info .acronym { display: none; }
}

/*  ----------------------------------------------------- End of YouTube CSS -----------------------------------------------------  */

/* Importing Font .ttf files to be used in the site (used for h1 and h3). */
@font-face {
    font-family:"Porter Bold";
    src: url("Porter Bold.ttf");
}

HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

        <link rel="stylesheet" type="text/css" href="main.css">
        <title> -redacted- - Basic Website</title>

Basic Website

Hello world! This webpage is an ongoing project which is part of -redacted-.

Home

About Me

Images

Contact

This is a test for the YouTube background pure CSS method I've been developing.

If it works, a video should be playing in the background of this webpage, the video itself is also forced to be played at 1080p.

Please keep in the mind that the video background is a direct stream from YouTube, so codec issues and corruption is nothing to do with the code. Refresh the page if quality does not improve.

-----------------------------------------------------------------------------------------

        This website was made by -redacted- for -redacted-.

A: You placed your div wrapper outside the body tag, which is not how it works. All your divs need to be inside your body tag. Try the following
css
#page-wrap {
     width: 80%
     margin: 0 auto;
}

html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

        <link rel="stylesheet" type="text/css" href="main.css">
        <title> -redacted- - Basic Website</title>

Basic Website

Hello world! This webpage is an ongoing project which is part of -redacted-.

Home

About Me

Images

Contact

This is a test for the YouTube background pure CSS method I've been developing.

If it works, a video should be playing in the background of this webpage, the video itself is also forced to be played at 1080p.

Please keep in the mind that the video background is a direct stream from YouTube, so codec issues and corruption is nothing to do with the code. Refresh the page if quality does not improve.

-----------------------------------------------------------------------------------------

        This website was made by -redacted- for -redacted-.

https://codepen.io/anon/pen/eBYowJ
All I have changed is placing your div wrapper inside your body tags and changing the width of the wrapper to 80% of the view width (parent container in this case, the body).
For responsive design, I would suggest using a framework because it makes the job a lot easier. Try looking into Bootstrap or Zurb Foundation.


text:
Q: How to save an instance of a custom class in onSaveInstanceState? I created an instance of a custom class RestaurantList to hold my data (a list of restaurant data received from a web service as json data).
How can I save it in onSaveInstanceState?

A: Custom objects can be saved inside a Bundle when they implement the interface Parcelable.
Then they can be saved via:
    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putParcelable("key", myObject);
    }

Basically the following methods must be implemented in the class file:
 public class MyParcelable implements Parcelable {
     private int mData;

     public int describeContents() {
         return 0;
     }

     /** save object in parcel */
     public void writeToParcel(Parcel out, int flags) {
         out.writeInt(mData);
     }

     public static final Parcelable.Creator<MyParcelable> CREATOR
             = new Parcelable.Creator<MyParcelable>() {
         public MyParcelable createFromParcel(Parcel in) {
             return new MyParcelable(in);
         }

         public MyParcelable[] newArray(int size) {
             return new MyParcelable[size];
         }
     };

     /** recreate object from parcel */
     private MyParcelable(Parcel in) {
         mData = in.readInt();
     }
 }

A: I know "that this case is cold", but because i found this thread first, when I was searching for exactly the same thing (and found an answer by now):
Imagine Bundle as an XML file.
If you create a new <BUNDLE name="InstanceName" type="ClassName">
you can freely add elements and attributes in a fresh and empty namespace.
When onSaveInstance(Bundle outState) of your MainActivity is called (you can also force this in onPause), you can create a new: Bundle b = new Bundle();
Then call your (probably not inherited and not overriden) custom Method onSaveInstance(Bundle b) in your own class with your newly created Bundle b.
Then (in onSaveInstance(Bundle outState)) of your MainActivity, call outState.putBundle("StringClassAndInstanceName", b);
When you find this string in onCreate, you can either use a switch/case to recreate this object or (better) have a factory function in your custom class to work with Bundle and "StringClassAndInstanceName".

A: Kotlin Solution:
For custom class save in onSaveInstanceState you can be converted your class to JSON string and restore it with Gson convertion. The following example is for Fragment and Activity:
For Activity:
For put class in saveInstanceState:
override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
        val gson = Gson()
        val json = gson.toJson(your_custom_class)
        outState.putString("CUSTOM_CLASS", json)
    }

Restore class:
 override fun onRestoreInstanceState(savedInstanceState: Bundle) {
    super.onRestoreInstanceState(savedInstanceState)
    val json = savedInstanceState?.getString("CUSTOM_CLASS")
    if (!json!!.isEmpty()) {
        val gson = Gson()
        testBundle = gson.fromJson(json, Session::class.java)
    }
 }

You can restore it on Activity onCreate also.
For fragment:
For put class in saveInstanceState:
 override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
        val gson = Gson()
        val json = gson.toJson(customClass)
        outState.putString("CUSTOM_CLASS", json)
    }

Restore class:
 override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        if (savedInstanceState != null) {
            val json = savedInstanceState.getString("CUSTOM_CLASS")
            if (!json!!.isEmpty()) {
                val gson = Gson()
                val customClass: CustomClass = gson.fromJson(json, CustomClass::class.java)
            }
        }
    }

A: Custom objects can be saved inside a Bundle when they implement the interface Serializable
Then they can be saved via:
override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
        outState.putSerializable("key", myObject)
}

Suppose myObject is object of class CustomClass and CustomClass implement the interface Serializable
Since the expected value in outState.putSerializable will be of type Serializable, you can pass myObject (you can send object of child class where parent class object is expected)
Then they can be used via:
override fun onCreate(savedInstanceState: Bundle?) {
    if (savedInstanceState != null) {
        myObject = savedInstanceState.getSerializable("key") as CustomClass
    }
}

A: Check this answer.
Basically you have to save it inside a Bundle.

A: Custom class objects can be converted to JSON and stored in the bundle as a string. The following example is for Fragments.
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Gson gson = new Gson();
    String json= gson.toJson(customClass);
    outState.putString("CUSTOM_CLASS", json);
}

public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if(savedInstanceState != null) {
        String json= savedInstanceState.getString("CUSTOM_CLASS");
        if(!json.isEmpty()) {
        Gson gson = new Gson();
            CustomClass customClass = gson.fromJson(json, CustomClass.class);
        }
    }
}

For Activities, override onRestoreInstanceState method instead.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Mail not being send when PHP script is called using Ajax I am trying to send an email inside a php script using PHPmailer, so I need the PHPmailer class which I included at the top of my page, I am 100% sure everything is correctly uploaded on my server.
My structure is like this:
root
 - includes/addreviewscript.php
 - phpMailer/class.phpmailer.php

I post data to that script using below jQuery ajax code:
  // Post review
  $("body").on("click",".add_review",function(){
    event.preventDefault();
    $reviewform = $(".addreview").serializeArray();
    url = 'includes/addreviewscript.php';

    var posting = $.post( url, { reviewarray: $reviewform} );

    posting.done(function( data ) {
      var content = $( $.parseHTML(data) );
      $('[name="beoordeling"]').hide();
      $('[name="submitreview"]').hide();
      $('.beoordeeltekst').hide();
      $( ".reviewresponse" ).empty().append( content ).slideDown();
    });
  });

That works, but in my addreviewscript.php I then add this to the top:
include '../phpMailer/class.phpmailer.php';

And further down I add:
$mail = new PHPMailer;
$mail->From = 'info@mymail.nl';
$mail->FromName = 'website';
$mail->addAddress('twan@mymail.nl');     // Add a recipient
$mail->isHTML(true);           // Set email format to HTML
$mail->Subject = 'Er is een review geplaatst op website';
$texts = 'Hier komt de reviewtekst';
$mail->send();

But no mail is send and no error_log is generated. What could be the issue?


text:
Q: React JS: With state, dynamically update an attribute (e.g., type) of an input that is a value in an object I have a state called fields, which is an array of objects. Each object has its html form, as you can see here:
fields: [
    {
        field: <input />,
        inputType: 'number'
    }
]

What I want to do is add a type attribute to the input that will update with the vale of inputType, upon a user interaction somewhere else on the app.
(I already have functions set up for the user interaction part. Basically, a user selects from a dropdown list, what they want the type to be. This drop list includes basic HTML input types, such as text, input, etc. Upon selecting a type, it will automatically update the value of inputType. I already have functions set up for that part.)
A few things I've tried, but was unsuccessful:
Idea 1:
fields: [
    {
        field: <input type={this.inputType} />,
        inputType: 'number'
    }
]

Idea 2:
fields: [
    {
        field: <input type={`this.inputType`} />,
        inputType: 'number'
    }
]

Idea 3:
fields: [
    {
        field: <input type={inputType} />,
        inputType: 'number'
    }
]

Am I wrong to think that the this keyword would work within an attribute in an HTML form type as a value in an object?
Thanks in advance, and let me know if any of this needs clarification.


text:
Q: I have issue in creating admin user for Voyager Admin panel package in Laravel 5.4 after voyage package installation with this command :
php artisan voyager:install

I needed to create admin user with this command :
php artisan voyager:admin your@email.com --create

and then entering the name and the password
The problem is after entering the username and the password it's returning this error

General error: 1364 Field 'employee_name' doesn't have a default value
  (SQL: insert into employee (email) values (admin@admin.com))

and I have already a database but with different naming convention for example:
the users table I call it employee and the name field called employee_name
My question is , is there any way to map the expected fields in voyager with my actual fields in my database because I can't change them ?
Thanks in advance .

A: Since you altered the normal structure of the User model and will likely run into similar issues with other packages that try to add users, you could create a boot() method in the user model to set this->employee_name to this->name and then unset this->name so that when records from other packages try to use the name attribute you correct it to the employee_name attribute.
This is off the top of my head based on memory so it may involve a bit more 'logic' but I think if you look into the boot method you will see that you can do this type of thing. I have used it to autofill columns with dynamically based values.
HTH

A: When you're executing this command, Voyager creates a new user for you using the mass assignment feature.
So, add $fillable to the User model:
protected $fillable = ['name', 'email', 'password'];

A:
General error: 1364 Field 'employee_name' doesn't have a default value

You can set default value to null in your database this solves the problem

A: Use Mutator to refer any attempt to add data to 'name' column to 'employee_name'.
For your case:
App\User.php
public function setNameAttribute($value)
{
    $this->attributes['employee_name'] = $value;
}


text:
Q: Use "with" with an R6 object I'm trying to use a construct such as "with" to allow easier (lazier ?) manipulation of an R6 object. Consider the following (minimal) example:
library(R6)
ToyClass<-R6Class(classname = "ToyClass",
                   public = list(
                     data=data.frame(x=c(1,2,3),y=c(4,5,6)),
                     color = "red",
                     symbol = 16,

                     initialize=function(mult){
                       self$data$x <- self$data * mult
                     }
                   )
)

foo <- ToyClass$new(2)

I can, obviously, plot the data in my object with
plot(foo$data$x,foo$data$y,col=foo$color,pch=foo$symbol)

However, being lazy (and since I have a lot of such objects to plot, so copy/paste/edit is time-consuming and prone to errors) I'd like to do
with(foo,
     plot(data$x,data$y,col=color,pch=symbol)
)

Which does not work:
Error in plot(data$x, data$y, col = color, pch = symbol) :
  could not find function "plot"

I understand why (foo behaves as an environment, in which plot() is not defined), but I cannot find a solution. How can I look for function names, I presume, in the global environment ?

A: Why not just add a plot method:
ToyClass2<-R6Class(classname = "ToyClass2",
                  public = list(
                    data=data.frame(x=c(1,2,3),y=c(4,5,6)),
                    color = "red",
                    symbol = 16,
                    plot = function() {
                      plot(self$data$x,self$data$y,col=self$color,pch=self$symbol)
                    },

                    initialize=function(mult){
                      self$data$x <- self$data * mult
                    }
                  )
)

foo2 <- ToyClass2$new(2)

plot(foo2)

If that's no good, another approach would be to set a parent environment as follows:
parent.env(foo) <- .GlobalEnv
with(foo, plot(data$x, data$y, col=color, pch=symbol))
parent.env(foo) <- emptyenv() # removes the parent environment

This can even be wrapped up in a function to get a more with-like feel:
with_global <- function(object, task_expr) {
  task_expr <- substitute(task_expr)
  parent.env(object) <- current_env()
  with(object, eval(task_expr))
}
with_global(foo, plot(data$x, data$y, col=color, pch=symbol))


text:
Q: Is it good to call setContent from shouldKeepOnScreen? I'm trying to implement a splash screen via SplashScreen compat library. Also, I use Jetpack Compose to implement UI and Jetpack Compose Navigation to implement navigation.
I have two screens: a login screen, a content screen. When a user opens application I should show:

*

*The content screen if the user is already logged in.

*Otherwise, the login screen.

I have the following idea:
    class MainActivity : ComponentActivity() {
        private var job: Job? = null
        private var keep = true

        override fun onCreate(savedInstanceState: Bundle?) {
            installSplashScreen().setKeepOnScreenCondition {
                if (job != null && keep) {
                    return@setKeepOnScreenCondition true
                }
                if (!keep) {
                    return@setKeepOnScreenCondition false
                }
                job = lifecycleScope.launch {
                    val startDestination = if (isUserLoggedIn()) { //Let us imagine that it is a long operation, so it's a suspend method
                        "content"
                    } else {
                        "login"
                    }
                    setContent {
                        NavHost(..., startDestination = startDestination) {
                            composable(route = "login") { ... }
                            composable(route = "content") { ... }
                        }
                    }
                    keep = false
                }

                return@setKeepOnScreenCondition keep
            }

            super.onCreate(savedInstanceState)
        }
    }

Question: is it safe to call setContent from setKeepOnScreenCondition like this?


text: Q: Making a formidable form to validate submission only after payment on razorpay? [NOOB] I am trying to make a form that shows the submit button upon completing the payment on razorpay.. what script to use ? give me step by step approach please.


text:
Q: How do I create a circle packing algorithm for circles with unequal sizes in iOS? I am trying to pack a bunch of round UIViews in a hexagonal pattern.
They all have different sizes.
First I randomly generate the UIViews and put them on the screen as shown:

Then I have an algorithm that arranges the views in a circular pattern around the center. This is the algorithm:
func arrangeViews()
    {
        let viewCenter = self.view.center
        let radius: Double = 50?? <- What do I put here? All the views has different radius?
        var currentDistFromCenter: Double = (radius * 2)
        var numMoved = 0
        let amountOfViews = views.count

        numMoved += 1

        while numMoved < amountOfViews {
            var numberToFit = Double(M_PI / asin(radius / currentDistFromCenter))

            if numberToFit > Double(amountOfViews - numMoved) {
                numberToFit = Double(amountOfViews - numMoved)
            }

            for i in 0 ..< Int(numberToFit) {
                let currentView = views[numMoved]
                let angle = Double(M_PI * 2.0 * Double(i) / numberToFit)
                let x = Double(viewCenter.x) + cos(angle) * currentDistFromCenter
                let y = Double(viewCenter.y) + sin(angle) * currentDistFromCenter
                var newPoint = CGPoint(x: CGFloat(x), y: CGFloat(y))

                views.first?.center = self.view.center

                if newPoint.x != currentView.frame.origin.x || newPoint.y != currentView.frame.origin.y {
                    UIView.animate(withDuration: 0.3, animations: {
                        currentView.center = newPoint
                    })
                    numMoved += 1
                }
            }
            currentDistFromCenter += radius * 2
        }
    }

Here is my result after I run this function:

Now this algorithm is for circles (views) with the same size. You see that they don't lie next to each other as they would if they all had the same size. As shown here:

Is there anyone out there that has any form of clue as to what I could change in the algorithm so I can pack views with different sizes?
Here are some links that I've encountered during my research, but they haven't gotten me very far because Maths isn't my strongest side:

http://www.optimization-online.org/DB_FILE/2008/06/1999.pdf

Packing different sized circles into rectangle - d3.js

http://jsfiddle.net/TDzVE/

Thank you in advance and happy programming!

A: As per the result needed, I would prefer firstly to draw all 7 circles at same center.
Suppose the red colored center circle is of size (x, y, W, H)
then
1st (Top left)         - (x-W/2, y-(H+H/2), W, H)
2nd (Top right)        - (x+W/2, y-(H+H/2), W, H)
3rd (Right)            - (x+W, y, W, H)
4th (Bottom right)     - (x+W/2, y+(H+H/2), W, H)
5th (Bottom left)      - (x-W/2, y+(H+H/2), W, H)
6th (Left)             - (x-W, y, W, H)

This will be applied in all cases of hexagonal part, just W/H will change for each circle like
1st (Top left)         - (x-W/2, y-(H+H/2), W1, H1)
2nd (Top right)        - (x+W/2, y-(H+H/2), W2, H2)
3rd (Right)            - (x+W, y, W3, H3)
4th (Bottom right)     - (x+W/2, y+(H+H/2), W4, H4)
5th (Bottom left)      - (x-W/2, y+(H+H/2), W5, H5)
6th (Left)             - (x-W, y, W6, H6)


text:
Q: Symfony using Doctrine and MySQL For schema.yml to work with relations, do you have to InnoDB? Here is my schema:
BuybackStatus:
  connection: doctrine
  tableName: buyback_statuses
  columns:
    id:
      type: integer(4)
      fixed: false
      unsigned: true
      primary: true
      autoincrement: true
    label:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    BuybackStatus:
      local: id
      foreign: status_id
      type: one
Country:
  connection: doctrine
  tableName: countries
  columns:
    id:
      type: integer(4)
      fixed: false
      unsigned: true
      primary: true
      autoincrement: true
    label:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    code:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    StateCountry:
      local: id
      foreign: state_id
      type: one
    UserCountry:
      local: id
      foreign: state_id
      type: one
Manufacture:
  connection: doctrine
  tableName: manufactures
  columns:
    id:
      type: integer(4)
      fixed: false
      unsigned: true
      primary: true
      autoincrement: true
    label:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    PhoneModelManufacture:
      local: id
      foreign: manufacture_id
      type: one
PhoneModel:
  connection: doctrine
  tableName: phone_models
  columns:
    id:
      type: integer(4)
      fixed: false
      unsigned: true
      primary: true
      autoincrement: true
    manufacture_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    label:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    buyback_price:
      type: 'decimal(6, 2)'
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    PhoneModelManufacture:
      onDelete: CASCADE
      local: manufacture_id
      foreign: id
    BuybackModel:
      local: id
      foreign: model_id
      type: one
Quality:
  connection: doctrine
  tableName: qualities
  columns:
    id:
      type: integer(4)
      fixed: false
      unsigned: true
      primary: true
      autoincrement: true
    label:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    percent:
      type: 'decimal(6, 2)'
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    BuybackQuality:
      local: id
      foreign: quality_id
      type: one
State:
  connection: doctrine
  tableName: states
  columns:
    id:
      type: integer(4)
      fixed: false
      unsigned: true
      primary: true
      autoincrement: true
    label:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    code:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    country_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    StateCountry:
      onDelete: CASCADE
      local: country_id
      foreign: id
      foreignAlias: StateCountries
    UserState:
      local: id
      foreign: state_id
      type: one
User:
  connection: doctrine
  tableName: users
  columns:
    id:
      type: integer(4)
      fixed: false
      unsigned: true
      primary: true
      autoincrement: true
    fname:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    lname:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    phone:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    email:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    password:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    street:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    city:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    state_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    country_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    UserState:
      onDelete: CASCADE
      local: state_id
      foreign: id
      type: one
    UserCountry:
      onDelete: CASCADE
      local: country_id
      foreign: id
      type: one
    BuybackUser:
      local: id
      foreign: user_id
      type: many
BuybackPhone:
  connection: doctrine
  tableName: buyback_phones
  columns:
    id:
      type: integer(4)
      fixed: false
      unsigned: true
      primary: true
      autoincrement: true
    user_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    model_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    quality_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    buyback_status_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    amount_quoted:
      type: 'decimal(6, 2)'
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    amount_paid:
      type: 'decimal(6, 2)'
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    makes_calls:
      type: integer(1)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    water_damage:
      type: integer(1)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    has_charger:
      type: integer(1)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    has_battery:
      type: integer(1)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    BuybackUser:
      onDelete: CASCADE
      local: user_id
      foreign: id
      type: one
    BuybackModel:
      onDelete: CASCADE
      local: model_id
      foreign: id
      type: one
    BuybackQuality:
      onDelete: CASCADE
      local: quality_id
      foreign: id
      type: one
    BuybackStatus:
      onDelete: CASCADE
      local: buyback_status_id
      foreign: id
      type: one

But the database is MyISAM. So when I run:  php symfony doctrine:build --model I get a bunch of these:
Notice: Undefined index:  class in /home/kacie/cellphone/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Import/Builder.php on line 672

I am brand new to Symfony, so I could be screwing up the schema, please check.
Here is what it does actually load:
>> tokens    /home/kacie/cellphone/lib/model/doctrine/PhoneModel.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/PhoneModelTable.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/BuybackStatus.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/BuybackPhoneTable.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/Manufacture.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/CountryTable.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/Country.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/ManufactureTable.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/UserTable.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/Quality.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/BuybackPhone.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/BuybackStatusTable.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/User.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/State.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/StateTable.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/QualityTable.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/base/BaseState.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/base/BaseBuybackStatus.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/base/BaseUser.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/base/BaseBuybackPhone.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/base/BaseManufacture.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/base/BasePhoneModel.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/base/BaseQuality.class.php
>> tokens    /home/kacie/cellphone/lib/model/doctrine/base/BaseCountry.class.php
>> autoload  Resetting application autoloaders
>> file-     /home/kacie/cellphone/cache/frontend/prod/config/config_autoload.yml.php

But before this there are a bunch of Undefined Index Notices, I don't want to go any further, I have scrapped the application a few times now and tried a lot of things, but I thought this schema would work. The guy who controls the database creation around here has his heart set on MyISAM, so I don't want to try and make him change it if there is something I can do to work around it. The sad thing is, I have scripts to create the database, but when I generate the schema off of my already in place structure it leaves out the relations, and since I am new to symfony, I want everything as automated as possible.

A: I think the problem is that you are using the same Relations name twice.
I found at least three: "UserState", "BuyBackModel", "BuyBackQuality" which are used twice in your schema.yml
Try to make sure all your relations are unique, and try generating the model again.
EDIT
Another thing you should try, is adding class names to your Relations.
<...>
Relations:
   class: foo
<...>

A: I ran into this problem. None of these ideas worked because I think it's another problem.
./symfony doctrine:build-schema
keeps putting old relations that no longer exist, into my schema. So either Symfony has some obscure place it has cached old relations, or MySQL is reporting relations that no longer exist.
I think Symfony is pulling in the relations from other sources like forms or filters. I am going to try clearing out the base directories for forms and filters.
Hmm. Found it. The foreign keys aren't getting deleted in MySQL, in my GUI, in WorkBench. You have to deleted the indexes too.
Best solution. Backup your database structure and content. And recreate the database if your GUI tool for MySQL is having problems.


text:
Q: how to use tfrecord by keras in tf2.x when i using tfrecord with keras in tf2.x, it only read the first batch for training ,how can i read the remainder tfrecord data
def get_dataset(self,
                    tfrecord_dataset,
                    num_parallel=4,
                    batch_size=16,
                    n_epoch=1,
                    buffer_size=10000,
                    _parse_function=_default_parser):
        dataset = tfrecord_dataset \
            .map(lambda x: (_parse_function(self, x), num_parallel)) \
            .shuffle(buffer_size=buffer_size) \
            .batch(batch_size) \
            .repeat(n_epoch)
        print(dataset)
        iterator = tf.compat.v1.data.make_one_shot_iterator(dataset)
        next_element = iterator.get_next()
        return next_element[0]

A: I don't understand why you use  tf.compat.v1.data.make_one_shot_iterator wrapped the dataset around.In tf2 ,you can use model.fit(dataset) directly  to train the model.


text:
Q: Surface Integral Proof QUESTION:
Set $B_r = \{x^2 + y^2 + z^2 \leq r\}$, $\mathbb{S}_r = \{x^2 + y^2 + z^2 = r^2\}$, $\forall r >0$ and denote $\omega(r)$ to be the area of $\mathbb{S}^2_r, \forall r>0$.
Suppose $u\in C^1(B_1)$, set $I_u(r) = \frac{1}{\omega(r)}\int\int_{\mathbb{S^2_r}}udS, \forall r>0$, show that
$$ \frac{d}{dr}I_u(r) = \frac{1}{\omega(r)}\iint_{\mathbb{S^2_r}}\nabla
   u\cdot d\vec{S}, \forall 1>r>0. $$
ANSWER:
First parametrize $\mathbb{S}^2_r$ as:
$$ x = r\cos\theta\sin\phi,\ \
   y = r\sin\theta\sin\phi, \ \
   z = r\cos\phi $$
$$ 0\leq\theta\leq2\pi\ \text{and}\ 0\leq\phi\leq\pi,\ \ \ \
   dS=r^2\sin\phi $$
Since we are in 3-D, the surface area of $\mathbb{S}^2_r$ is simply $\omega(r) = 4\pi r^2$.
Now,
$$ I_u(r) = \frac{1}{4\pi
r^2}\int_0^\pi\int_0^{2\pi}u\big(r\cos\theta\sin\phi,r\sin\theta\sin\phi, \cos\phi\big)r^2\sin\phi\ d\theta\ d\phi $$
Then by the Chain Rule,
$$ \frac{d}{dr}I_u(r) = \frac{1}{4\pi r^2}\int_0^\pi\int_0^{2\pi}\big(u_x\cos\theta\sin\phi + u_y\sin\theta\sin\phi + u_z\cos\phi\big)r^2\sin\phi\ d\theta\ d\phi $$
$$ \frac{d}{dr}I_u(r) = \frac{1}{4\pi r^2}\int_0^\pi\int_0^{2\pi}(u_x, u_y, u_z) \cdot (\cos\theta\sin\phi,\sin\theta\sin\phi,\cos\phi)r^2\sin\phi\ d\theta\ d\phi $$
Note that on $\mathbb{S}^2_r$, the outer normal is $\vec{n} = \frac{(x,y,z)}{r}$ therefore,
$$ \frac{d}{dr}I_u(r) = \frac{1}{4\pi r^2}\int_0^\pi\int_0^{2\pi} (\nabla u \cdot \vec{n})r^2\sin\phi\ d\theta\ d\phi $$
$$ \frac{d}{dr}I_u(r) = \frac{1}{4\pi r^2}\iint_{\mathbb{S}_r} \nabla u \cdot \vec{n}\ dS $$
$$ \frac{d}{dr}I_u(r) = \frac{1}{\omega(r)}\iint_{\mathbb{S}_r} \nabla u \cdot d\vec{S} $$


text:
Q: How to Show/Hide Table Object Columns I am working in iReport 5.6.0.  I am creating a report base utilizing a table and would like to build one or more options to hide a series of columns; effectively creating a master report which will allow users to have multiple report views based on a simple parameter selection.  In theory, this should work.   However, I am having a problem passing a parameter from the main report it the table (where I am would use it to activate the Column Print When property.
To be clear.  I have created an outer parameter and an inner parameter.  I have also successfully mapped the parameters.  I know that the mapping is working as I have added a column to my table and placed the parameter within the data row so that I can visually evaluate it--this too, works.  However, when I set the Column Print When property  as
$P{parameter1_1}.equals("y")

or even
$P{parameter1_1}.equals('y')

and then preview the report, I receive the following error:
Parameter not found:  Description: parameter1_1   Object:  fx $P{parameter1_1}.equals("y")


text:
Q: How to load formated data in gridview? For example, I have a source(Id, Name) with some records. I want to bind it to GridView. But, I want to format each record before add it to GridView, for example, I want to write prefix "test" to all the record where field is "Name". I heared that I need to use onRowDataBound event, but I cant understand how.

A: First if you want to make little format on the data you are displaying, you can do this easily  in your .aspx using Eval function
to search on Google use this asp.net eval format
Second for your example check this question : Add prefix of http:// or https:// with Eval value

A: Use the DataFormatString in your gridview column. Ex:
<asp:BoundField DataField="name" DataFormatString="test_{0}" HeaderText="name"
                    HtmlEncode="False" SortExpression="name" />

This will result in:
test_YourData

A: Well you can do that by capturing the binding event.
YourGrid.DataBound += YourGrid_RowDataBound

void YourGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
  if (e.Row.RowType == DataControlRowType.DataRow)
  {
      e.Row.Cells[1].Text = "test_" + e.Row.Cells[1].Text;
  }
}


text:
Q: Ordering by additional data in Elasticsearch. Is it possible? I want search all results in list --
# [ [num, pk], [1, 34], [2, 3147] ...]
# num = [0, 1, 2, ... 7]
pks = [34, 3147,..., 1264]

I want search where related__in=pks, but like this.
First .filter(related=pk[0]), then .filter(related=pk[1])... And concatenate results to single query.
SO:
Can I add some filed/data to searchqueryset to sort by it later?
Or maybe concatenate many searchquerysets to one?

A: What you are describing is a Haystack MultiValueField that allow for search engines to query ManyToMany relations like you are hinting at in your answer.
This is demonstrated in the documentation like so:
class NoteIndex(SearchIndex, indexes.Indexable):
    text = CharField(document=True, use_template=True)
    author = CharField(model_attr='user')
    categories = MultiValueField()

For details on how to efficiently query this field, see this related question.


text:
Q: Nagios not sending emails Nagios is not sending emails. I see the logs that it shows alerts but no emails are going out. Any suggestions to debug the issue?
/var/log/maillog doesn't show any log entry. Manually sending emails through command line do reach my inbox.
Log and config:
[1549711074] SERVICE FLAPPING ALERT: host001;Disk Space - /boot;STARTED; Service appears to have started flapping (21.6% change >= 20.0% threshold)
[1549711074] SERVICE FLAPPING ALERT: host001;Disk Space Warn Only - /boot;STARTED; Service appears to have started flapping (21.6% change >= 20.0% threshold)
[1549711194] SERVICE ALERT: host001;Disk Space - /boot;CRITICAL;SOFT;1;/boot: 100%used(98MB/99MB) (>90%) : CRITICAL
[1549711194] SERVICE ALERT: host001;Disk Space Warn Only - /boot;CRITICAL;SOFT;1;/boot: 100%used(98MB/99MB) (>90%) : CRITICAL
[1549711254] SERVICE ALERT: host001;Disk Space - /boot;CRITICAL;SOFT;2;/boot: 100%used(98MB/99MB) (>90%) : CRITICAL
[1549711254] SERVICE ALERT: host001;Disk Space Warn Only - /boot;CRITICAL;SOFT;2;/boot: 100%used(98MB/99MB) (>90%) : CRITICAL
[1549711314] SERVICE ALERT: host001;Disk Space - /boot;CRITICAL;HARD;3;/boot: 100%used(98MB/99MB) (>90%) : CRITICAL
[1549711314] SERVICE ALERT: host001;Disk Space Warn Only - /boot;CRITICAL;HARD;3;/boot: 100%used(98MB/99MB) (>90%) : CRITICAL
[1549711387] Caught SIGTERM, shutting down...
[1549711387] Successfully shutdown... (PID=28697)
[1549711387] Warning: aggregate_status_updates directive ignored.  All status file updates are now aggregated.
[1549711387] Nagios 3.0.6 starting... (PID=29699)
[1549711387] Local time is Sat Feb 09 03:23:07 PST 2019
[1549711387] LOG VERSION: 2.0
[1549711387] Finished daemonizing... (New PID=29700)
[1549711387] SERVICE FLAPPING ALERT: host001;Disk Space - /boot;STARTED; Service appears to have started flapping (27.3% change >= 20.0% threshold)
[1549711387] SERVICE FLAPPING ALERT: host001;Disk Space Warn Only - /boot;STARTED; Service appears to have started flapping (27.3% change >= 20.0% threshold)
[1549712107] SERVICE ALERT: mysql-db03;eth0 status;UNKNOWN;SOFT;1;ERROR: No snmp response from 10.49.64.62 (alarm)
[1549712107] SERVICE ALERT: mysql-db03;eth1 status;UNKNOWN;HARD;3;ERROR: No snmp response from 10.49.64.62 (alarm)
[1549712157] SERVICE ALERT: mysql-db03;eth0 status;OK;SOFT;2;OK: Interface eth0 (index 2) is up.
[1549712277] SERVICE ALERT: mysql-db03;eth1 status;CRITICAL;HARD;3;CRITICAL: Interface eth1 (index 3) is administratively down.
[1549712277] SERVICE NOTIFICATION: rt;mysql-db03;eth1 status;CRITICAL;ngmail;CRITICAL: Interface eth1 (index 3) is administratively down.
[1549712292] SERVICE NOTIFICATION: 724_shift11;mysql-db03;eth1 status;CRITICAL;ngmail;CRITICAL: Interface eth1 (index 3) is administratively down.
[1549712307] SERVICE NOTIFICATION: skytel1;mysql-db03;eth1 status;CRITICAL;ngmail;CRITICAL: Interface eth1 (index 3) is administratively down.
[1549712322] SERVICE NOTIFICATION: skytel2;mysql-db03;eth1 status;CRITICAL;ngmail;CRITICAL: Interface eth1 (index 3) is administratively down.
[1549712337] SERVICE NOTIFICATION: skytel4;mysql-db03;eth1 status;CRITICAL;ngmail;CRITICAL: Interface eth1 (index 3) is administratively down.
[1549712352] SERVICE NOTIFICATION: skytel6;mysql-db03;eth1 status;CRITICAL;ngmail;CRITICAL: Interface eth1 (index 3) is administratively down.
[1549712367] SERVICE NOTIFICATION: skytel7;mysql-db03;eth1 status;CRITICAL;ngmail;CRITICAL: Interface eth1 (index 3) is administratively down.
[1549712382] SERVICE NOTIFICATION: pubfolders;mysql-db03;eth1 status;CRITICAL;notify-by-email;CRITICAL: Interface eth1 (index 3) is administratively down.

and notification config:
# 'notify-by-email' command definition
define command{
        command_name    notify-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nNotification Number : $NOTIFICATIONNUMBER$\nProblem Duration: $SERVICEDURATION$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $SHORTDATETIME$\n\nAdditional Info:\n$SERVICEOUTPUT$\n\n" | /bin/mail -r $ADMINEMAIL$ -s "**$NOTIFICATIONTYPE$ alert #$NOTIFICATIONNUMBER$ - $HOSTALIAS$:$SERVICEDESC$ is $SERVICESTATE$**" $CONTACTEMAIL$
        }

# 'host-notify-by-email' command definition
define command{
        command_name    host-notify-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nNotification Number : $NOTIFICATIONNUMBER$\nProblem Duration: $HOSTDURATION$\n\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nDate/Time: $SHORTDATETIME$\n\nAdditional Info: \n$HOSTOUTPUT$\n\n" | /bin/mail -r $ADMINEMAIL$ -s "HOST DOWN alert #$NOTIFICATIONNUMBER$ - $HOSTNAME$ is $HOSTSTATE$" $CONTACTEMAIL$

Contacts.cfg
define contact{
    contact_name                    ops
    alias                           Ops Email
    service_notification_period     24x7
    host_notification_period        24x7
    service_notification_options    w,u,c,r
    host_notification_options       d,u,r
    service_notification_commands   notify-by-email
    host_notification_commands      host-notify-by-email
    email                           user@domain.com

    }

A: When I stopped the nrpe service it sent the alert. It seems the contact.cfg only was set to send Down, Unreachable and Recovery alert.


text:
Q: Why is the differential operator equal to an integer in the case of trignometric equations? In this website, http://www.codecogs.com/library/maths/calculus/differential/the-d-operator.php, the following problem and solution is given:
Problem:

Find the Particular Integral of
  $$\frac{d^2y}{dx^2} - 5\,\frac{dy}{dx} + 6y = \sin\,2x$$

Solution:

This can be re-written as
  $$\tag1
y = \frac{1}{D^2 - 5D + 6}\sin\,2x
$$
Using equation 1 we can put $D^2 = -4$
Therefore:
  $$y = \frac{1}{-\,4\;-\,5D + 6}\sin\,2x
=\frac{1}{2 - 5D}\sin\,2x$$
If we multiply the top and bottom of this equation by 2 + 5D
$$y =\frac{2 + 5D}{4 - 25D^2}\sin\,2x$$
But $D^2=-4$
Therefore
  $$ y =\frac{2 + 5D}{104}\sin\,2x = \frac{1}{104}\left(2\sin\,2x + 5D\sin\,2x \right)$$
  But since $D\sin\,2x = 2\cos\,2x$
  $$y = \frac{1}{104}\left(2\sin\,2x + 10\cos\,2x \right) $$

The biggest problem I have with this is the line, $D^2 = -4$.
So far as I understand, $D$ is an operator on functions, and $D^2$ represents the double application of that operator. So how, can it be equal to -4? How can an operator on functions be equal to an integer? They're two things of fundamentally different types, how can they be equal?

A: You can interpret $D^2=-4$ as $D^2=-4I$, where $I$ is the identity operator; that's no big deal. If anything, you should be more worried about "dividing" by an operator.
To expand a bit about what's going on in that solution, the author knows that the solution will be a linear combination of $\sin(2x)$ and $\cos(2x)$. For those two functions (and their linear combinations), $D^2=-4I$.
Note that guessing all those manipulations is harder than postulating that the particular solution is of the form $\alpha\sin(2x)+\beta\cos(2x)$ and substitute in the equation to find $\alpha$ and $\beta$ (what is usually known as Undetermined Coefficients).


text:
Q: I get the following message The uploaded file could not be moved to /home/reascom/public_html/wp-content/uploads/2012/07 The uploaded file could not be moved to /home/reascom/public_html/wp-content/uploads/2012/07.
This is the message I get when I try to load anything to my existing web site.  images and themes get this message.
What should i do?

A: Check the permissions in your wp-content/uploads folder (and subfolders) - the web server needs to be able to write to it.


text:
Q: java.lang.StackOverFlowError in computing Stirling number of the second kind while using BigInteger My main goal is to compute the Stirling number of the second kind with an input of 1 to 500. Without using the BigInteger option/import, the code works flawlessly but the moment I use the said import, I encounter java.lang.StackOverFlowError because of BigInteger k (I tried converting it to d out of desperation).
Hope someone can help. And if possible, please point out other errors if you will spot any. Thank you!
import java.util.*;
import java.math.*;
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
try{
System.out.print("Please enter the r: ");
BigInteger n = sc.nextBigInteger();
System.out.print("Please enter the n: ");
BigInteger k = sc.nextBigInteger();

BigInteger constant= new BigInteger("0");
BigInteger result = new BigInteger("1");
BigInteger result2 = new BigInteger("500");

    int result3 = n.compareTo(result);
    int result4 = n.compareTo(result2);
    int result5 = k.compareTo(result);
    int result6 = k.compareTo(result2);
    int result7 = n.compareTo(constant);
    int result8 = k.compareTo(constant);

if (result3 == -1 || result4==1){
    System.out.println("n must be 1 to 500");
}
if (result5 ==-1 || result6 == 1){
    System.out.println("k must be 1 to 500");
}
else if (result7 == 1 && result4 == -1 && result8 == 1 && result6 == -1){
System.out.println("The answer is: " + StirlingFunction(n, k));
}
}

catch(InputMismatchException a){
    System.out.println("The input must be an integer.");
}
}

public static BigInteger StirlingFunction(BigInteger n, BigInteger k){
   BigInteger d= new BigInteger("0").add(k);
   BigInteger a = BigInteger.ONE;
   if (k.compareTo(BigInteger.ONE) == 0 || k == n){
      return BigInteger.ONE;
   }

   else{
    BigInteger x = (StirlingFunction(n.subtract(a), d));
    BigInteger y = (StirlingFunction(n.subtract(a), k.subtract(a)));

   return k.multiply(x).add(y);

    }
}

}

This is the result/output

A: Revised to answer what was wrong.
k==n

is never true because they are different objects, so your code never hit its base case. Changing it to
`k.equals(n)`

made your code give the right answer quickly, with no error.
The following translated from the post at Recursive functions for partitions, stirling numbers, and chebyshev polynomials of the first may or may not be helpful. I tried to keep things as close to that and as simple as possible, while pretty much emulating your code.
public static BigInteger StirlingFunction(BigInteger n, BigInteger k){
   if (BigInteger.ZERO.equals(n) && BigInteger.ZERO.equals(k)){
       return BigInteger.ONE;
   }
   //still here, not both zero
   if (BigInteger.ZERO.equals(n) || BigInteger.ZERO.equals(k)){
       return BigInteger.ZERO;
   }
   BigInteger x = StirlingFunction(n.subtract(BigInteger.ONE), k);
   BigInteger y = StirlingFunction(n.subtract(BigInteger.ONE), k.subtract(BigInteger.ONE));
   //S2(n, k) = k * S2(n - 1, k) + S2(n - 1, k - 1)
   return k.multiply(x).add(y);

    }


text:
Q: Play an audio file every X seconds Y times even when changing apps My app is supposed to receive time in seconds that determines how audio is played.
Example: Play audio file x(length about 2 seconds) every 2 minutes all in all 16 times.
It would work great if android didn't enjoy closing foreign apps and services so frequently, once you move to another app.
My structure is like this:
MainActivity starts a new MainActivityService via intent.
gintent = new Intent(MainActivity.this,MainActivityService.class);
gintent.putExtra(...);
gintent.putExtra(...);
...
startService(gintent);

Then this service runs the mentioned time being given to it by putExtra.
The point is, android has all kinds of mechanisms to kill services and apps. So I have been trying to keep it up by using onSaveInstanceState in MainActivity
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
savedInstanceState.putBoolean(...);
savedInstanceState.putInt(...);
...
}

onRestoreInstanceState, isMyServiceRunning(MainActivityService.class) and so forth, but I lost track with all the onResume and whatnot. And in the end, the service was still killed.
I don't want to debug this back and forth. I want to know the gold standard how to do this.

A: Android treats nonforegrounded services as ripe for killing. You'll need to make your Service flag itself as a foreground service. This will lower the chance the OS will kill that process.

A foreground service is a service that the user is actively aware of and is not a candidate for the system to kill when low on memory.... To request that your service run in the foreground, call startForeground().

Intent notificationIntent = new Intent(this, ExampleActivity.class);
PendingIntent pendingIntent =
        PendingIntent.getActivity(this, 0, notificationIntent, 0);

Notification notification =
          new Notification.Builder(this, CHANNEL_DEFAULT_IMPORTANCE)
    .setContentTitle(getText(R.string.notification_title))
    .setContentText(getText(R.string.notification_message))
    .setSmallIcon(R.drawable.icon)
    .setContentIntent(pendingIntent)
    .setTicker(getText(R.string.ticker_text))
    .build();

startForeground(ONGOING_NOTIFICATION_ID, notification);

See: Running a service in the foreground


text:
Q: How to match ALL instances of a word and return each full row as array (as formula, not VB) I have a Google Sheet that is updated with Job issues. Depending on the Issue the job is allocated to a various different team (each team in it's own tab).
Note. Each issue has a "Category" that has to be selected when filling out the job issue form.
I'm trying to write a formula that looks through the list of job issues and splits out different categories to different tabs (teams).
Here's the link to the Google Sheet to see what i've already done.
You can see my formula in E1 & L1 of "Team 1 tab"
https://docs.google.com/spreadsheets/d/1wKOMIM0JKf_jicYLeEy_Btu1atjpaGwyDlTMU2otlkc/edit?usp=sharing
See attached URL for code: You can see my formula in E1 & L1 of "Team 1 tab"
Lists all the matches in their own tab or area inside the tab.

A: You can do this simply with the FILTER function (although you can also use something like QUERY, it's not necessary for your application).
In your sheet, put this formula on the top-left of where you want data to begin:
=FILTER('Form responses 1'!$A:$E,'Form responses 1'!$C:$C="Can't access a topic?")
This should return all records in the range 'Form responses 1'!$A:$E that match "Can't access a topic?".
You can see the documentation for the FILTER function here: https://support.google.com/docs/answer/3093197?hl=en.


text:
Q: Special Character in Azure appsettings Am hosting the API project in azure devops. I have set the connectionstring in the keyvault, passing the value to Appsettings. In the password,'&' character is present. Hence i set the password in connectionstring as 'Test&test', but upon fetching the value, connection string is breaking, and it is not taking '&' in password properly. I have been using YAML file for deploying the project.

A: You should escape any special characters like the ampersand. To escape the & character, use & instead of &. Your connection string should be
Test&test


text:
Q: How to turn off the pop up notification in 12.04?
Possible Duplicate:
How can I customize/disable notification bubbles?

How can I turn off the pop up notification that comes at the top right corner each time when I get connected to the internet/wi-fi or when the songs in vlc playlist changes?
I'm using Ubuntu 12.04, Gnome classic.


text:
Q: Error ... requires that 'Self.Key' conform to 'Hashable' The code fragment below (nothing else in the playground) creates errors I cannot fathom. Any assistance would be appreciated.
protocol p: ExpressibleByDictionaryLiteral {
    associatedtype T
    var entries: [Int: T] {get set}
    mutating func add( id:Int, e:T )->Bool
}

extension p {

    init(dictionaryLiteral elements: (Int, T)...) {
        self.init(initializeFrom: elements.reduce(into: [Key: Value](),
            { (result, tuple) in result[tuple.0] = tuple.1 } ))
    }

    init(initializeFrom: [Key: Value]) {
        entries = initializeFrom
    }
}

A: It looks like you want to constrain Key to be an Int and Value to be T.
Key and Value are already associated types on ExpressibleByDictionaryLiteral: https://developer.apple.com/documentation/swift/expressiblebydictionaryliteral
protocol p: ExpressibleByDictionaryLiteral where Key == Int, Value == T { // <-- Here
    associatedtype T
    var entries: [Int: T] {get set}
    mutating func add( id:Int, e:T )->Bool
}

extension p {
    init(dictionaryLiteral elements: (Int, T)...) {
        self.init(initializeFrom: elements.reduce(into: [Int: T](),
            { (result, tuple) in result[tuple.0] = tuple.1 } ))
    }

    init(initializeFrom: [Key: Value]) {
        self.init()
        entries = initializeFrom
    }
}

The final error in your screenshot is just a typo.


text:
Q: How to connect jquery chained to html or txt data I got question beacuse i novice in Jquery . I have this code :
<!DOCTYPE>

<select id="mark" name="mark">
  <option value="">--</option>
  <option value="Ciezarowe">Ciezarowe</option>
  <option value="Autobusy">Autobusy</option>
  <option value="Maszyny">Maszyny</option>
  <option value="Indywidualne">Indywidualne</option>
</select>
<select id="series" name="series">
  <option value="">--</option>
  <option value="Ford" class="Ciezarowe">Ford</option>
  <option value="Mercedes" class="Ciezarowe">Mercedes</option>
  <option value="Peugeot" class="Ciezarowe">Peugeot</option>
  <option value="Ikar" class="Autobusy">Ikar</option>
  <option value="Iveco" class="Autobusy">Iveco</option>
  <option value="Man" class="Autobusy">Man</option>
  <option value="Komatsu" class="Maszyny">Komatsu</option>
  <option value="Nissan" class="Maszyny">Nissan</option>
  <option value="Still" class="Maszyny">Still</option>
  <option value="Pojedyncze" class="Indywidualne">Pojedyncze</option>
  <option value="Grupowe" class="Indywidualne">Grupowe</option>
  <option value="Firmowe" class="Indywidualne">Firmowe</option>
</select>
<select id="model" name="model">
  <option value="">--</option>
  <option value="F1" class="Ford">F1</option>
  <option value="F2" class="Ford">F2</option>
  <option value="F3" class="Ford">F3</option>
  <option value="S1" class="Mercedes">S1</option>
  <option value="S2" class="Mercedes">S2</option>
  <option value="S3" class="Mercedes">S3</option>
  <option value="P1" class="Peugeot">P1</option>
  <option value="P2" class="Peugeot">P2</option>
  <option value="P3" class="Peugeot">P3</option>
  <option value="I1" class="Ikar">I1</option>
  <option value="I2" class="Ikar">I2</option>
  <option value="I3" class="Ikar">I3</option>
  <option value="V1" class="Iveco">V1</option>
  <option value="V2" class="Iveco">V2</option>
  <option value="V3" class="Iveco">V3</option>
  <option value="M1" class="Man">M1</option>
  <option value="M2" class="Man">M2</option>
  <option value="M3" class="Mano">M3</option>
  <option value="K1" class="Komatsu">K1</option>
  <option value="K2" class="Komatsu">K2</option>
  <option value="K3" class="Komatsu">K3</option>
  <option value="N1" class="Nissan">N1</option>
  <option value="N2" class="Nissan">N2</option>
  <option value="N3" class="Nissan">N3</option>
  <option value="S1" class="Still">S1</option>
  <option value="S2" class="Still">S2</option>
  <option value="S3" class="Still">S3</option>
  <option value="P1" class="Pojedyncze">P1</option>
  <option value="P2" class="Pojedyncze">P2</option>
  <option value="P3" class="Pojedyncze">P3</option>
  <option value="G1" class="Grupowe">G1</option>
  <option value="G2" class="Grupowe">G2</option>
  <option value="G3" class="Grupowe">G3</option>
  <option value="F1" class="Firmowe">F1</option>
  <option value="F2" class="Firmowe">F2</option>
  <option value="F3" class="Firmowe">F3</option>
</select>
 <button id="button" type="submit">Wyszukaj</button>

My question is How can i connect jquery chained to html data or txt data ...
I want to make this data in table and describe choose option from select and show result in div below ?
Can you give me some advice or tip how to do it?

A: I'm not entirely sure what you're asking but if you'd like to display content based on their selection you could use jquery as such.
$(function(){
    $('#model').on('change', function(event){
        // $('.result').append("Mark: "+$('mark').val());
        // or...
        // $.ajax({});
    });
)};


text:
Q: PHP "or" operator within conditional statement - newb question! Forgive me if this has been covered before, I searched to no avail.
I have a script that looks into a directory to find the files inside.  There is a conditional line that only looks for files with a certain extension:
if(strtolower(substr($file, -3)) == "mp4"){...

So that will only look for files with an 'mp4' extension.
I need to add some "or" operators to add two more extension types.   I tried the following but it didn't work:
if(strtolower(substr($file, -3)) == "mp4" || == "mov" || == "flv"){...

Now the line seems to be ignored and it gets every file in the directory.
If anyone could help me out, I'd be very grateful!
I know this is probably as basic as it gets, but my grasp of PHP is extremely limited (although I do see its beauty!!!)
Thanks in advance.

A: The problem is that PHP does not automatically know that you want to compare to strtolower(substr($file, -3)) in each "or" section. You need to explicitly state this:
if(strtolower(substr($file, -3)) == "mp4" || strtolower(substr($file, -3)) == "mov" || strtolower(substr($file, -3)) == "flv"){...

Note that it would probably be neater to do something like:
$tmp = strtolower(substr($file, -3));

if($tmp == "mp4" || $tmp == "mov" || $tmp == "flv"){...

A:  $ext = strtolower(substr($file, -3));

 if($ext == "mp4" || $ext == "mov" || $ext == "flv"){...

A: Another way to do it :
if ( in_array(strtolower(substr($file, -3))),  array('mp4', 'mov', 'flv') ) {
    // do something
}

A: The way you tried it does not work because the comparison operator == is a binary operator and expects two operands, i.e. operand1 == operand2. The same applies to the logical OR operator that is also a binary operator, i.e. operand1 || operand2.
That means you would need to write something like this:
$ext = strtolower(substr($file, -3));
if ($ext == "mp4" || $ext == "mov" || $ext == "flv")

Here $ext is just used to avoid repeated call of strtolower(substr($file, -3)). In this case each binary operator has two operands:
((($ext == "mp4") || ($ext == "mov")) || ($ext == "flv"))
   \__/    \___/
     \__==___/        \__/    \___/
         \              \__==___/
          \_______||_______/
                   \                      \__/    \___/
                    \                       \__==___/
                     \________________||_______/

(I added parentheses to highlight the order in which the expression is evaluated.)
So this is how you would have to write it.
But you could also use an array and in_array:
in_array(strtolower(substr($file, -3)), array("mp4","mov","flv"))

And pathinfo is probably better to get the file name extension, so:
in_array(pathinfo($file, PATHINFO_EXTENSION), array("mp4","mov","flv"))

A: A more concise way:
if ( preg_match('/(mp4|mov|flv)$/', $file) ) { ...

A: If you want to match only specific filenames in a directory, you can use glob
$files = glob('/path/to/dir/*.{mp4,mov,flv}', GLOB_BRACE);

to return an array of matching file paths.
Or you use fnmatch to match a filename against a pattern.
In addition, if you want to make sure the images are really images, consider checking against the MimeType instead of or in addition to the extension

A: if you want to compare using ||, here's the syntax:
if(strtolower(substr($file, -3)) == "mp4" || strtolower(substr($file, -3)) == "mov" || strtolower(substr($file, -3)) == "flv"){...

of course to make it a bit faster, fill strtolower(substr($file, -3)) in a variable so php doesn't execute those functions more than once:
$extension=strtolower(substr($file, -3));
if($extension == "mp4" || $extension == "mov" || $extension == "flv"){...

The other good news is, PHP got a builtin function to search whether a value exists in an array of values (in_array):
if(in_array(strtolower(substr($file, -3)), array('mp4', 'mov', 'flv')))

One last thing, if you have simple strings like those, ones who you don't want php to expand variables and stuff inside, use single qutations instead of doubles, that is a good practice and saves some execution time (of course barely noticed with a string or two, but it's a good practice on the long range).

A: $ext = strtolower(substr($file, -3));
switch ( $ext )
{
   case 'mp4':
   case 'mov':
   case 'flv':
      /// some operation
      break;
}


text:
Q: Highchart with dynamic scale for both series Question is related to this one.
Problem : Currently I have chart with 2 series - one serie with positive and one with negative values. By default each serie has dynamic scaling but they are not relating (I mean if 20 for first serie is MAX value and 5 for second serie is MAX, then it looks on graph like the same). When I set max and min values to yAxis, it solve problem, but adds to much empty space, that for some cases column is too small. Can I update chart setting to have dynamic scalling but one for both series?
Here is my example with setted MAX and MIN values for yAxis http://jsfiddle.net/futw5e8k/6/
Highcharts.chart('container', {

chart: {
    type: 'column'
},

title: {
    text: null
},

xAxis: {
    categories: ['13-17', '18-24', '25-34', '35-44', '45-54', '55-64', '65+'],
    offset: -150,
    lineWidth: 0,
    tickWidth: 0
},

yAxis: [{
    title: {
        text: null,
    },

    top: 50,
    height: 124,
    min: 0,
    max: 100,
    gridLineColor: 'transparent',
    gridLineWidth: 0,
        minorGridLineWidth: 0,
    labels: {
        enabled: false
    }
},{
        title: {
        text: null
    },
    top: 200,
    height: 150,
    offset: 0,
    min: -100,
    max: 0,
    gridLineColor: 'transparent',
    gridLineWidth: 0,
        minorGridLineWidth: 0,
    labels: {
        enabled: false
    }
}],

plotOptions: {
        column: {
            dataLabels: {
                enabled: true,
                crop: false,
                overflow: 'none',
                formatter: function() {
                        return Math.abs(this.y);
                        }
            }
        }
    },
    tooltip: {
    formatter: function() {
        return this.x + '<br/>' + this.series.name + ': ' + Math.abs(this.y);
    }
},
series: [{
    name: 'John',
    data: [1, 13, 20, 19, 15, 7, 2]
}, {
    name: 'Joe',
    yAxis: 1,
    data: [-0.35, -6, -9, -16, -3, -1.5, -0.25]
}]

});

A: On load event you can find the maximum of your data and dynamically update axes' max - see Axis.update().
  chart: {
type: 'column',
events: {
  load: function() {
    const max = Math.max(this.series[0].dataMax, this.series[1].dataMax);

    this.yAxis[0].update({
      max: max,
    }, false);

    this.yAxis[1].update({
      max: max,
      top: 130
    }, false);

    this.redraw(false);
  }
}
},

example: http://jsfiddle.net/futw5e8k/7/


text:
Q: How do i filter movielist javascript https://jsfiddle.net/mf553ccL/
I want to choose the select the genre and then filter the movie list so only the movies with that genre is showed.

        <select id="selection">
        </select>

I have tried using:
if (selection.value == data.movie.categories) {
  classList.add('hidden');
}

But I am getting data.movie.categories.
TypeError: data is undefined

This is my Javascript so you can see the code:
window.addEventListener("load", setup);
function setup() {
    var xhr = new XMLHttpRequest();
    xhr.open('GET', 'data/data.json', true);

    xhr.onreadystatechange = function() {
        if (this.readyState === 4 && this.status === 200) {
            var data = JSON.parse(this.responseText);
            var output = '';
            var genre = '<option> ' + "-- Select Genre --" + ' </option>';

            for (var i = 0; i < data.movies.length && data.categories.length; i++) {
                if (i < data.categories.length) {
                    genre += '<option> ' + data.categories[i] + ' </option>';
                }
                output += '
' +
                    '
 Title: ' + data.movies[i].title + '
' +
                    '
 Category: ' + data.movies[i].categories + '
' +
                    '
';
            }
            document.getElementById('output').innerHTML = output;
            document.getElementById('selection').innerHTML = genre;

        }
        console.log(data.movies.categories);
    }
    xhr.onerror = function() {
        console.log("req")
    }
    xhr.send();
}

My data object is in a JSON file:
 {
        "movies": [{
            "title": "Mad Max",
            "categories": "action"
        }, {
            "title": "Willow",
            "categories": "action,fantasy"
        }, {
            "title": "Alien",
            "categories": "action,sci-fi"
        }, {
            "title": "Silence of the lambs",
            "categories": "thriller"
        }, {
            "title": "The Ring",
            "categories": "horror"
        }, {
            "title": "Gone with the wind",
            "categories": "drama"
        }, {
            "title": "Lion King",
            "categories": "animation, family"
        }, {
            "title": "Jumanji",
            "categories": "action,fantasy, family"
        }, {
            "title": "Heat",
            "categories": "action,thriller"
        }, {
            "title": "Blade runner",
            "categories": "action,sci-fi"
        }],
        "categories": ["action", "sci-fi", "drama", "thriller", "horror", "fantasy", "family", "animation"]
    }


text:
Q: Is there any C# API available to query Stack Overflow? Well, I am new in this arena. I want to know about any C# API available to query Stack Overflow to get the information like Questions, Answers, Reputation, Votes, Tags across different Users, etc.
There is one application available for mobile with the name Stack Remote, but that is still offering limited features.
I would appreciate if you can let me know about any application already built to provide such customized information or any valuable directions in this regard?

A: You can use the library tag on Stack Apps to find wrappers around the API in various languages.  StacMan - .NET client for Stack Exchange API v2 seems to be the one you want.


text:
Q: Simple debug-level Python logging fails? Here's a bit of code I'm running under Python 3.3.2:
import logging

logger = logging.getLogger("test.logger")

logging.getLogger().setLevel(logging.DEBUG) # Shouldn't be needed
logger.setLevel(logging.DEBUG)

print("Effective logging level is {}".format(logger.getEffectiveLevel()))
logger.debug("This is a debug-level message.")

And here's the output:
Effective logging level is 10

So the debug message didn't get written, despite the fact that the logger's level appears to be correct. I don't see anything in the Python doc or on this site that suggests I'm missing anything. What's going on here? Thanks.
EDIT: If I exercise the root logger by adding this line ...
logging.debug("Try this")

... then both messages come out. (Note the use of logging instead of logger.) Curiouser and curiouser.

A: The debug message is getting written, you just never added an actual log output method (either via .basicConfig() or via adding a Handler instance).
So no log messages will be displayed anywhere because you haven't told the logger where to display them.

A: Amber's answer is correct. I can tell you why you're seeing messages for WARNING or higher, but not INFO or DEBUG.
From the documentation for 3.2:

logging.lastResort - A "handler of last resort" is available through
  this attribute. This is a StreamHandler writing to sys.stderr
  with a level of WARNING, and is used to handle logging events in the
  absence of any logging configuration. The end result is to just print
  the message to sys.stderr. This replaces the earlier error message
  saying that "no handlers could be found for logger XYZ". If you need
  the earlier behaviour for some reason, lastResort can be set to
  None.

Note the section in bold above - that's the reason why you're not seeing messages below WARNING. Just add a line
logger.addHandler(logging.StreamHandler())

before the logger.debug(...) line, and you'll see the DEBUG message appear.
When you call logging.debug(...), this adds a StreamHandler to the root logger if there's no handler for it (as documented in the note just below here), which is why both messages appear.

A: If you happen to be testing an application for Google App Engine, then this problem is solved by adding --log_level=debug in the dev_apperver.py parameters


text:
Q: Work-around for PHP5's PDO rowCount MySQL issue I've recently started work on a new project using PHP5 and want to use their PDO classes for it. The problem is that the MySQL PDO Driver doesn't support rowCount() so there's no way to run a query and then get the number of affected rows, or rows returned, which is a pretty big issue as far as I'm concerned. I was wondering if anyone else has dealt with this before and what you've done to work around it. Having to do a fetch() or fetchAll() to check if any rows were affected or returned seems like a hack to me, I'd rather just do $stmt->numRows() or something similar.

A: You can issue a SELECT FOUND_ROWS() query right after the original SELECT query to get row count.
$pdo->query("SELECT * FROM users");
$foundRows = $pdo->query("SELECT FOUND_ROWS()")->fetchColumn();

See also: MySQL Docs on FOUND_ROWS()

A: For those of you who are using MySQL stored procedures, this solution isn't really feasible.  What I would suggest that you do is have your stored procedure create two rowsets.  The first one will contain one row and one column, containing the number of records. The second will be the recordset you will use for fetching that number of rows.
The number of unlimited rows can be a SELECT COUNT(*) with the exact same WHERE clause as the second rowset without the LIMIT/OFFSET clauses.
Another idea could be to create a temporary table.  Use your SELECT statement to populate the temporary table.  Then you can use SELECT COUNT(*) FROM tmpTable for your first rowset and SELECT * FROM tmpTable for your second.

A: This question is based on several false assumptions and one outdated statement.
First of all, do not confuse number of affected and selected rows. PDO supported the former even back in '09.
Speaking of number of rows returned by SELECT statement - you just don't need that number. The data you have is enough.
And yeah, nowadays  rowCount() supports number of rows selected from mysql as well. But again - you don't need that number in an average web-application anyway.


text:
Q: calling C# from c++ com add-in I have a COM add-in written in C++ (not C++ / CLI). I want to call a C# library objects/methods from this C++ com library.
I guess the CCW comes into picture here, which i am currently reading about.
Are there any quick pointers to this stuff from your experience?
Also, i have a method in my Com add-in that i would like my C# library code to call - i.e. a method pointer invocation.
Can you help telling me how i can do this please - i.e. how do i go about passing the method pointer to the C# code so it can call on it later.
Thanks.

A: I have this links for you:
COM Interop Part 1 Sample
Create DCOM application from within .Net environment: Part V
C++ to C# call


text:
Q: How to position a menubar above TextBox in Silverlight? I want to add the menubar to TextBox control in Silverlight 4. (I will create a new reusable control.) The menubar will consists of a few image buttons. The idea is that it will normally stay hidden and will show up only when the user puts his/her mouse cursor to the TextBox area. If used in a multiline textbox, whole menubar can fit inside it, this should be easy. (I hope. :-))
But how to solve situation when TextBox is in single line mode? I'd like to put the menubar above the TextBox. But I don't have a clue how to do it. Can somebody help? I need to let all other controls in a form to stay in their positions, and only add my menubar above my textbox. (So the menubar will NOT hide the textbox. Instead, it will hide other controls residing right above the textbox.) It should work in all arrangements of form, like Grid, StackPanel, Canvas etc. In the fact it would be similar to a classic right-click context menu, but not modal. (Right-click context menu is modal, i.e. while it is shown you cannot use other controls, and it automatically hides when you click anywhere else. I want my menubar to stay visible as long as user heeps mouse cursor over the textbox or the menubar.)
Example: Coordinates of textbox are top=100,left=20,bottom=115,right=120. So my menubar's coordinates should be bottom=100,left=20, right & top are based on size of menubar.
If many textboxes will be used on a single page, each single one should have its own menubar. (Of course.)

A: You can create your own control (custom control or UserControl, whichever you like should work) which has the TextBox, and the visual for the menu bar.
If the TextBox is single-line, you could display the menu bar in a Popup which you position just above the TextBox whenever the mouse is over it.
If the TextBox is multi-line, you'd simply use a StackPanel or Grid or whatever to do layout like normal, if I am understanding what you want.

A: No coding required if you use this menu:
http://sl4popupmenu.codeplex.com
To achieve this behavior you will need to set its IsPinned property to true.


text:
Q: Executing an exe in server from the client side in vb6 I have a terminal server that is connected to development server.
In my development server there is a shared folder that many ".exe" files contained.
What i want is any terminal on my terminal server that has permission to that shared folder should be able to start the ".exe" files.
But these ".exe" files cannot work on the terminal server. These ".exe" files required to work in my development server.
For that reason im trying to create an executer that will execute the ".exe" files i defined in my development server. How can i achive this in vb6?

A: If I understand your question, I think you'd want code that looks something like this
Sub Main()

    Dim objWSShell As Object
    Set objWSShell = CreateObject("Wscript.Shell")
    objWSShell.Run Command$, 0, True

End Sub

And you'd call your exe with the exe you want to run as a parameter:
MyAppRunner MyAppToRun.exe

A: If the programs need to run on the second "development" server you need to RDP to that server if you want interaction.
About the only other thing you can do is break them into a client and a server, and run the client on the Terminal server.  These clients would use DCOM, Web Services, etc. as the glue between the two pieces.
An exception might be programs written as command line or UI-less batch programs, fairly rare in most VB6 usage.  These might be run by Telnetting to the second server or by remote execution.  No point in elaborating on this though since it is even less likely to meet your needs.  If you really do mean batch/non-interactive programs look into Remote Scripting with WSH.


text:
Q: Распарсить Json файл с несколькими массивами Есть json файл такой структуры:
{
  "kitchen": {
    "traditional": [
      {
        "title": "Блюдо 1",
        "ingredients": "Что-то",
        "description": "Что-то",
        "image": "none",
        "favorites": "0",
        "category": "Традиционные блюда"
      },
      {
        "title": "Блюдо 2",
        "ingredients": "Что-то",
        "description": "Что-то",
        "image": "none",
        "favorites": "0",
        "category": "Традиционные блюда"
      }
    ],
    "sladkoe": [
      {
        "title": "Пирог 1",
        "ingredients": "Что-то",
        "description": "Что-то",
        "image": "none",
        "favorites": "0",
        "category": "Сладкое"
      },
      {
        "title": "Пирог 2",
        "ingredients": "Что-то",
        "description": "Что-то",
        "image": "none",
        "favorites": "0",
        "category": "Сладкое"
      }
    ],
    "napitki": [
      {
        "title": "Напиток 1",
        "ingredients": "Что-то",
        "description": "Что-то",
        "image": "none",
        "favorites": "0",
        "category": "Напитки"
      },
      {
        "title": "Напиток 2",
        "ingredients": "Что-то",
        "description": "Что-то",
        "image": "none",
        "favorites": "0",
        "category": "Напитки"
      }
    ]
  }
}

Как распарсить его? Пытался сделать так, но не получается.
public String loadJSONFromAsset() {
    String resultJson = null;
    try {
        InputStream is = getAssets().open("kitchen.json");
        int size = is.available();
        byte[] buffer = new byte[size];
        is.read(buffer);
        is.close();
        resultJson = new String(buffer, "UTF-8");
    } catch (IOException ex) {
        ex.printStackTrace();
        return null;
    }
    return resultJson;
}

//Класс парсит JSON и извлекает данные из него
private class ParseTask extends AsyncTask<Void, Void, String> {
    String resultJson = "";

    @Override
    protected String doInBackground(Void... params) {
        return loadJSONFromAsset();
    }

    @Override
    protected void onPostExecute(String strJson) {
        super.onPostExecute(strJson);

        JSONObject dataJsonObj = null;

        try {
            dataJsonObj = new JSONObject(strJson);
            JSONArray traditionalArray = dataJsonObj.getJSONArray("traditional");

            for (int i = 0; i < traditionalArray.length(); i++) {
                JSONObject titleObject = traditionalArray.getJSONObject(i);

                String title = titleObject.optString("title");
                traditionalDishesArray.add(title);
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }

    }
}

В итоге, мне нужно каждую группы Традиционные блюда, Сладкое, Напитки из них вытащить title.

A: Для сериализации и десериализации java объектов в JSON используйте библиотеку Gson от Google.
Тогда работа с ArrayList<> получается что то вроде List<GoodsItem> listItemsDes = new Gson().fromJson(jsonStr,itemsListType);
Статьи, которые помогут подробнее разобраться:
http://developer.alexanderklimov.ru/android/library/gson.php
http://www.javenue.info/post/gson-json-api
https://habrahabr.ru/post/253266/

A: Прежде чем вытаскивать массив, нужно вытащить объект JSON с ключом "kitchen". Попробуйте так:
...
dataJsonObj = new JSONObject(strJson);
JSONObject innerJSONObject = dataJsonObj.getJSONObject("kitchen");
JSONArray traditionalArray = innerJSONObject.getJSONArray("traditional");
...


text:
Q: How to make a variable name dependant on input in python? I need to create multiple variables based on int input so that if input is 5 then variables are created like: worker1, worker2, worker3, etc.
Is there any way in which I could generate variables like these and then add points to them dependant on the number chosen by the user?
Example:
How many workers?
10
-Choose worker
4
-added 1 point to worker4

A: Instead of using multiple variables, you can use a dictionary. Using multiple variables is less Pythonic than using a dictionary and can prove cumbersome with large data. In your example, you could use a dictionary to store each worker and their number of points.
Documentation for dictionaries can be found here
For example:
#recieve a valid input for the number of workers
while True:
    num = input("How many workers would you like to create?\n") # accepts an int
    try:
        num = int(num)
    except ValueError:
        print("Must input an integer")
    else:
        break

#create a dictionary with the workers and their scores (0 by default)
workers = {'worker'+str(i+1) : 0 for i in range(num)}

# get the user to choose a worker, and add 1 to their score
while True:
    worker = input("Which worker would you like to add a point to?\n") #accepts worker e.g worker1 or worker5
    if worker in workers:
        workers[worker] += 1
        print(f"Added one point to {worker}")
        break
    else:
        print("That is not a worker")

print(workers)

This code gets a user input to create a certain number of workers. It then gets user input to add a point to one of the workers. You can change this to add multiple points to different workers, but this is just a basic example, and it depends on what you want to do with it.


text:
Q: dnf install completion not working with zsh, yet working with bash In bash, if I type dnf install java<tab>, I get a bunch of suggestions of packages to install. However, if I do this in zsh, nothing happens. I've played around with /etc/bashrc and discovered that bash_completion allows this to work in bash, but I can't figure out how to make this work in zsh.

A: ZSH ships with completions in $fpath; these change over time especially for new and exciting programs that old and decrepit ZSH installs may know nothing about. The usual steps should be:

*

*update your ZSH to the latest version and see if a completion script now exists—print $fpath[-1]/_dnf though for some commands the completion may exist in some other file under a compdef line.

*check if the software ships with a ZSH completion script that has not be contributed to the e.g. zsh-workers mailing list (rare, but if so, perhaps submit that completion code to the ZSH folks so they can include it.

*check whether some other ZSH completion repository contains completion code e.g. https://github.com/zsh-users/zsh-completions/

*write your own completion script for the program. This typically requires studying the existing completion scripts, the zshall(1) docs on e.g. _arguments and so forth, and the usual fiddling and testing of things.

A handy command to glob the files in $fpath is
% print -l ${^fpath}/_pgrep(N)
/Users/jdoe/.zsh/functions/darwin/_pgrep
/opt/local/share/zsh/5.3.1/functions/_pgrep
%

which shows that on my Mac I have a custom completion for pgrep in addition to the upstream one.


text:
Q: Extract symbol characters from docx I'm developing a JAVA program  which processes the XML content of docx files and converts it to a specific format. It's working quite well, but I have problems if the Word file contains Symbol characters e.g. greek letters. In this case I see only little squares.
I checked the source and see something like this:
<w:r w:rsidRPr="008E65F6"><w:rPr><w:rFonts w:ascii="Symbol" w:hAnsi="Symbol"/></w:rPr><w:t>ďˇ</w:t></w:r>

Or if I set the encoding to UTF-8:
<w:r w:rsidRPr="008E65F6"><w:rPr><w:rFonts w:ascii="Symbol" w:hAnsi="Symbol"/></w:rPr><w:t></w:t></w:r>

When I view as Hexa, it seems that the greek characters are encoded as EF 81 A1 for alpha, EF 81 A2 for beta and so on.
I also tried val.getBytes(Charset.forName("utf8")) where val is the value of the <w:t> tag. The result is e.g. [-17, -127, -95]. The negative values are quite surprising for me.
So my question is, what is a safe and reliable way to covert these symbols to regular UTF-8 characters?

A: Meanwhile, I have found the solution, so I add it as answer for future reference.
I checked the Symbol font with a glyph viewer software and I realized that it uses the Private Use Area of Unicode for its characters. Other fonts like Times New Roman store the concerned characters (e.g. greek letters) in normal Unicode range.
So the solution is to map the Symbol glyphs with standard Unicode glyphs. I have created a conversion table by hand for the greek letters (upper/lower case), punctuations, numbers and mathematical symbols available in the Symbol font. Note that even the order of the characters in variuos ranges differ from each other, e.g. the greek alphabet is not in the same order in Symbol and Unicode. So I had to check the character codes one by one.
When I had the conversion table, I stored it in a txt file. When my application finds a segment (run) in the Word file which is formatted with Symbol font (<w:rFonts> tag in the example), it calls the conversion method. In this method, I parse the txt file to a HashMap, and change the characters one by one from Symbol code to Unicode:
public String convert(String symbolString)  {
    StringBuilder sb = new StringBuilder();

    for(int k=0; k<symbolString.length(); k++){
        int origCode = Character.codePointAt(symbolString, k);
        Integer replaceCode = conversionTable.get(origCode);
        if(replaceCode != null) {
            sb.append(Character.toChars(replaceCode));
        } else {
            sb.append("?");
        }
    }

    return sb.toString();
}

Where conversionTable is the HashMap object containing the replace codes as hex values.


text:
Q: Rest operator with Variable reference I can't understand why these two codes don't work the same:
function sum(...array) {
return array.reduce((total, element) => {
    return total += element;
})};

let total = sum(1, 2, 3, 4);
console.log(total);

This one works as expected and returns the sum of ...array (10)
But when I try to do the same by calling the function with a variable reference:
function sum(...array) {
return array.reduce((total, element) => {
    return total += element;
})
}

let myValues = (1, 2, 3, 4)

let total = sum(myValues);
console.log(total)

The output is 4.
Why the function works differently in the two situations?

A: Parenthesis are expressions that JS evaluates. Similar to how:
let a = (1 + 2) // a = 3

let b = (10 || 5) + 1 // b = 11. 10 is truthy so (10 || 5) evaluates to 10

let c = (null || 6) + 1 // c = 7. (null || 6) evaluates to 6

In this case, (1,2,3,4) evaluates to 4. If you want to use variables, you can add the numbers to an array and spread ... that array when calling the function:

function sum(...array) {
return array.reduce((total, element) => {
    return total += element;
})
}

let myValues = [1, 2, 3, 4]

let total = sum(...myValues);
console.log(total) // 10

A: In the second example array looks like this: [4] instead of [1, 2, 3, 4].
There are not tuples in JavaScript, you can't wrap items with () you have to use [].
Also, your function expect each item separately, so you should spread first
const myValues = [1, 2, 3, 4]
sum(...myValues)

A: when you write
let total = sum(1, 2, 3, 4)
this means that you are passing 4 arguments to function so it will pass 4 values and sum it to 10. but in your code,
let myValues = (1, 2, 3, 4)
you have redefined myValues four times to 4 only so when the final function will execute it will just have one value 4 for sum . so the final output is 4.


text:
Q: SpriteMaterial without sizeAttenuation in Three.js i need a (nameplate) sprite without sizeAttenuation in Three.js and it should looks like this example:

//load image with 256x128px 32bit png

var spriteMap = new THREE.TextureLoader().load("tex/plates/mytest.png");
var spriteMat = new THREE.SpriteMaterial({map:spriteMap, transparent:true, sizeAttenuation:false});
var sprite = new THREE.Sprite(spriteMat);
...
spriteMat.map.minFilter = THREE.NearestFilter;

The result is not blurry, but its not correctly and hav some artefacts what i dont want:

Here is my second try with (THREE.LinearFilter), also not what i want cos its too blurry:

Renderer size: 1200x800px (not full window)
So, i dont know if its a problem with the filter, position or scaling. The first example seems like a bitmap text, but i really dont know how i can solve this problem. I also dont need a 2d sprite in screenspace. I need the nameplate in 3d worldspace behind other objects. I have really no idea how i can solve this, pls anyone can help me with this problem?


text:
Q: Use OS-specific file dialog to relink layer when file moves? When I move a file out from under QGIS, of course I have to tell the program where it moved to.
If you close a QGIS project and then move or rename a layer source file, you get a prompt when you reopen the project asking where you moved the file, and you can use a OS-native (in my case, MacOS-native) open-file dialog to indicate where the source file moved to.
However, when I move a source file while QGIS is open, I can't figure out how to get an open-file dialog to link it to the changed source file. All I get is a clunky built-in file navigator which is not intuitive to use.
My default now is to just close the QGIS project and reopen it when I move layer source files, but is there a better way?


text:
Q: Probability and Measure Theory by Ash Has anyone used the textbook above? If so how does it compare with billingsley, Chung and similar such books in terms of rigor, coverage, and ease if use for self study?

A: I've been using Ash to self-study some more advanced probability theory on my own. I've found the experience to be fairly decent, and it covers most of what I'm looking to learn (basic probability, conditional probability, martingales, limit theorems, and ergodic theory). I have not looked through Chung, but I find it is more or less similar to Billingsley and Durrett. The Ash book has fairly detailed answers to select exercises in the book. Billingsley has that too, although they are not as detailed IMO.