text:
Q: Can't get values out of dynamically added textbox Try as I might I can't get the values out of my dynamically added textboxes. I've tried enabling the ViewState in all the containing controls as well as adding the textbox values to the ViewState in the Page_Init event, but the Text property always comes up empty. Here's my code behind page...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using O2S.Components.PDF4NET;
using O2S.Components.PDF4NET.Graphics;
using O2S.Components.PDF4NET.Graphics.Fonts;
using O2S.Components.PDF4NET.Graphics.Shadings;
using O2S.Components.PDF4NET.Graphics.Shapes;

namespace PDFFormToGrid
{
    public partial class Form : System.Web.UI.Page
    {
        private static double leftMargin = 15;
        private static double rightMargin = 15;
        private static double topMargin = 20;
        private static double minBottomMargin = 20;
        private static double rowHeight = 30;
        private static double headerHeight = 30;
        private static double firstPageTopOffset = 50;
        private static double[] columnsWidth = { 120, 120, 120, 120 };
        private static string[] columnsHeader = { "Name", "Phone Number", "Address", "Company" };
        private static List<Control> panels = new List<Control>();
        private static List<TextBox> fields = new List<TextBox>();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                panels.Clear();
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            PDFDocument form = CreatePDF(this);

            Response.ContentType = "application/x-msdownload";
            Response.AddHeader("content-disposition", "attachment;filename=form.pdf");
            form.Save(Response.OutputStream);
            Response.Flush();
            Response.End();
        }

        private static PDFDocument CreatePDF(Form form)
        {
            // Create the PDF document
            PDFDocument doc = new PDFDocument();

            // Create the graphics objects
            PDFFont titleFont = new PDFFont(PDFFontFace.Helvetica, 35);
            PDFBrush purpleTitleBrush = new PDFBrush(new PDFRgbColor(19, 19,105));

            formatDoc(doc);

            // Create first page of report
            PDFPage page = doc.AddPage();

            formatPage(page, titleFont, purpleTitleBrush);

            DrawReportRows(doc, page, panels);

            return doc;
        }

        private static void formatDoc(PDFDocument doc)
        {
            doc.SerialNumber = "Serial Number Goes Here";
            doc.PageOrientation = PDFPageOrientation.Landscape;
        }

        private static void formatPage(PDFPage page, PDFFont font, PDFBrush brush)
        {
            // Draw title of report
            page.Canvas.DrawText("Applicant", font, null, brush, page.Width / 2,
                15, 0, PDFTextAlign.TopCenter);

            // Draw report header
            DrawReportHeader(page, firstPageTopOffset);
        }

        private static void DrawReportHeader(PDFPage page, double headerTopOffset)
        {
            // Create the graphics objects
            PDFFont headerFont = new PDFFont(PDFFontFace.Helvetica, 12);
            headerFont.Bold = true;
            PDFPen borderColor = new PDFPen(new PDFRgbColor(), 4);
            PDFBrush textColor = new PDFBrush(new PDFRgbColor());
            PDFBrush headerFill = new PDFBrush(new PDFRgbColor(192, 192, 193));

            // Draw the header
            page.Canvas.DrawRectangle(borderColor, headerFill, leftMargin, headerTopOffset,
                page.Width - leftMargin - rightMargin, headerHeight);

            double xOffset = leftMargin;
            // Draw the column separators
            for (int i = 0; i < columnsWidth.Length - 1; i++)
            {
                xOffset = xOffset + columnsWidth[i];
                page.Canvas.DrawLine(borderColor, xOffset, headerTopOffset,
                    xOffset, headerTopOffset + headerHeight);
            }

            xOffset = leftMargin;
            // Draw the columns header
            for (int i = 0; i < columnsWidth.Length; i++)
            {
                page.Canvas.DrawText(columnsHeader[i], headerFont, null, textColor,
                    xOffset + columnsWidth[i] / 2, headerTopOffset + headerHeight / 2, 0, PDFTextAlign.MiddleCenter);
                xOffset = xOffset + columnsWidth[i];
                xOffset = xOffset + columnsWidth[i];
            }

        }

        private static void DrawReportRows(PDFDocument doc, PDFPage page, List<Control> panels)
        {
            // Get number of forms - there's one more than count because of the initial form
            int numForms = panels.Count;

            double rowOffset = firstPageTopOffset + headerHeight;
            for (int i = 0; i < numForms; i++)
            {
                if (rowOffset + rowHeight > page.Height - minBottomMargin)
                { // not enough space to draw a new row, then create a new page,
                    // draw the header, then draw the rows.
                    page = doc.AddPage();
                    DrawReportHeader(page, topMargin);
                    rowOffset = topMargin + headerHeight;
                }
                DrawReportRow(page, rowOffset, panels[i]);
                rowOffset = rowOffset + rowHeight;
            }
        }

        private static void DrawReportRow(PDFPage page, double topOffset, Control panel)
        {
            // Create the graphic objects
            PDFFont fontText = new PDFFont(PDFFontFace.Helvetica, 12);
            PDFPen borderColor = new PDFPen(new PDFRgbColor(), 1);
            PDFBrush textColor = new PDFBrush(new PDFRgbColor());
            PDFBrush headerFill = new PDFBrush(new PDFRgbColor(192, 192, 192));

            // Draw rows borders
            PDFPoint[] points = { new PDFPoint( leftMargin, topOffset ),
                                  new PDFPoint( leftMargin, topOffset + rowHeight),
                                  new PDFPoint( page.Width - rightMargin, topOffset + rowHeight ),
                                  new PDFPoint( page.Width - rightMargin, topOffset )};
            page.Canvas.DrawLines(borderColor, points);

            double xOffset = leftMargin;
            // Draw the columns separators
            for (int i = 0; i < columnsWidth.Length - 1; i++)
            {
                xOffset = xOffset + columnsWidth[i];
                page.Canvas.DrawLine(borderColor, xOffset, topOffset,
                    xOffset, topOffset + rowHeight);
            }

            // Get all form fields from panel
            fields.Clear();
            GetFormFields(panel);

            xOffset = leftMargin;
            // Draw the columns header
            for (int i = 0; i < columnsWidth.Length; i++)
            {
                // Get ith field text
                string fieldText = fields[i].Text;
                page.Canvas.DrawText(fieldText, fontText, null, textColor,
                    xOffset + 2, topOffset + rowHeight / 2, 0, PDFTextAlign.MiddleLeft);
                xOffset = xOffset + columnsWidth[i];
            }
        }

        private static void GetFormFields(Control panelControl)
        {
            ControlCollection controls = panelControl.Controls;
            foreach (Control childControl in panelControl.Controls)
            {
                if (childControl.GetType().ToString() == "System.Web.UI.WebControls.TextBox")
                {
                    TextBox txt = childControl as TextBox;
                    fields.Add(txt);
                }
                else
                {
                    GetFormFields(childControl);
                }
            }
        }

        protected void btnAddForm_Click(object sender, EventArgs e)
        {
            // Create Labels
            Label lblName = new Label();
            lblName.Text = "NAME:";
            Label lblNumber = new Label();
            lblNumber.Text = "NUMBER:";
            Label lblAddress = new Label();
            lblAddress.Text = "ADDRESS:";
            Label lblCompany = new Label();
            lblCompany.Text = "COMPANY:";

            // Create Text Boxes
            TextBox txtName = new TextBox();
            TextBox txtNumber = new TextBox();
            TextBox txtAddress = new TextBox();
            TextBox txtCompany = new TextBox();

            // Create submit button
            Button btnSubmit = new Button();
            btnSubmit.Text = "SUBMIT";

            // Create panel and add controls
            Panel pnlForm = new Panel();
            pnlForm.EnableViewState = true;
            pnlForm.Controls.Add(lblName);
            pnlForm.Controls.Add(txtName);
            pnlForm.Controls.Add(new LiteralControl("

"));
            pnlForm.Controls.Add(lblNumber);
            pnlForm.Controls.Add(txtNumber);
            pnlForm.Controls.Add(new LiteralControl("

"));
            pnlForm.Controls.Add(lblAddress);
            pnlForm.Controls.Add(txtAddress);
            pnlForm.Controls.Add(new LiteralControl("

"));
            pnlForm.Controls.Add(lblCompany);
            pnlForm.Controls.Add(txtCompany);
            pnlForm.Controls.Add(new LiteralControl("
"));
            pnlForm.Controls.Add(new LiteralControl("

"));
            panels.Add(pnlForm);

            foreach (Control panel in panels)
            {
                phFormContent.Controls.Add(panel);
            }

        }

TextBoxes are added in the btnAddForm_Click() function, and inside of DrawReportRow() (which is itself triggered by another button click event) GetFormFields() is called, which adds all the dynamically added TextBoxes to a static List. Here's the .aspx file....
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Form.aspx.cs" Inherits="PDFFormToGrid.Form" EnableViewState="true" %>

<!DOCTYPE html>

    <title></title>

    <form id="form1" runat="server">
        <asp:PlaceHolder ID="phFormContent" runat="server" EnableViewState="true">
            <asp:Panel ID="Panel1" runat="server" EnableViewState="true">
                <asp:Label ID="lblName" runat="server" Text="NAME:"></asp:Label>
                <asp:TextBox ID="txtName" runat="server"></asp:TextBox>

                <asp:Label ID="lblNumber" runat="server" Text="NUMBER:"></asp:Label>
                <asp:TextBox ID="txtNumber" runat="server"></asp:TextBox>

                <asp:Label ID="lblAddress" runat="server" Text="ADDRESS:"></asp:Label>
                <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>

                <asp:Label ID="lblCompany" runat="server" Text="COMPANY:"></asp:Label>
                <asp:TextBox ID="txtCompany" runat="server"></asp:TextBox>

            </asp:Panel>
        </asp:PlaceHolder>

        <asp:Button ID="btnAddForm" runat="server" Text="Add Form" OnClick="btnAddForm_Click" />
        <asp:Button ID="btnSubmitForms" runat="server" Text="Submit Forms" OnClick="btnSubmit_Click" />
    </form>

A: In your btnAddForm_Click method, you want to make sure you give the fields a consistent control id such as:
// Create Text Boxes
TextBox txtName = new TextBox();
txtName.ID = "txtName";
TextBox txtNumber = new TextBox();
txtNumber.ID = "txtNumber";
TextBox txtAddress = new TextBox();
txtAddress.ID = "txtAddress";
TextBox txtCompany = new TextBox();
txtCompany.ID = "txtCompany";

Then in your btnSubmitForm_Click method, you can grab all the panels within your placeholder via Linq such as:
var panelFields = (from panel in phFormContent.Controls.OfType<Panel>()
                                let txtName = panel.FindControl<TextBox>("txtName")
                                let txtNumber = panel.FindControl<TextBox>("txtNumber")
                                let txtAddress = panel.FindControl<TextBox>("txtAddress")
                                let txtCompany = panel.FindControl<TextBox>("txtCompany")
                                select new
                                {
                                     Name = txtName.Text,
                                     Number = txtNumber.Text,
                                     Address = txtAddress.Text,
                                     Company = txtCompany.Text
                                }).ToList();

foreach (var fields in panelFields)
{
    Response.Write(string.Format("{0} {1} {2} {3}
", fields.Name, fields.Number, fields.Address, fields.Company));
}

Update
I just wanted to note this for future googlers since I misread the question and there was another issue because the page lifecycle dictates you have to recreate dynamic controls on postback:
Edit for recreating dynamic controls on postback
I'm just showing the main methods that were changed from above.
// creates 1 panel on the first load
protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        FormCount = 1;
    }
    CreatePanels();
}

// first line is added to grab the all panels in phFormContent before passing to the pdf creation routine
protected void btnSubmit_Click(object sender, EventArgs e)
{
    panels = phFormContent.Controls.OfType<Panel>().ToList();
    PDFDocument form = CreatePDF(this);

    Response.ContentType = "application/x-msdownload";
    Response.AddHeader("content-disposition", "attachment;filename=form.pdf");
    form.Save(Response.OutputStream);
    Response.Flush();
    Response.End();
}

// when adding we just inc the form counter and add a panel
protected void btnAddForm_Click(object sender, EventArgs e)
{
    FormCount = FormCount + 1;
    CreatePanel();
}

// routine to create the form panels
protected void CreatePanels()
{
    for (int i = 0; i < FormCount; i++)
    {
        CreatePanel();
    }
}
// this just creates a panel now and appends to placeholder;
protected void CreatePanel()
{
    // Create Labels
    Label lblName = new Label();
    lblName.Text = "NAME:";
    Label lblNumber = new Label();
    lblNumber.Text = "NUMBER:";
    Label lblAddress = new Label();
    lblAddress.Text = "ADDRESS:";
    Label lblCompany = new Label();
    lblCompany.Text = "COMPANY:";

    // Create Text Boxes
    TextBox txtName = new TextBox();
    TextBox txtNumber = new TextBox();
    TextBox txtAddress = new TextBox();
    TextBox txtCompany = new TextBox();

    // Create submit button
    Button btnSubmit = new Button();
    btnSubmit.Text = "SUBMIT";

    // Create panel and add controls
    Panel pnlForm = new Panel();
    pnlForm.EnableViewState = true;
    pnlForm.Controls.Add(lblName);
    pnlForm.Controls.Add(txtName);
    pnlForm.Controls.Add(new LiteralControl("

"));
    pnlForm.Controls.Add(lblNumber);
    pnlForm.Controls.Add(txtNumber);
    pnlForm.Controls.Add(new LiteralControl("

"));
    pnlForm.Controls.Add(lblAddress);
    pnlForm.Controls.Add(txtAddress);
    pnlForm.Controls.Add(new LiteralControl("

"));
    pnlForm.Controls.Add(lblCompany);
    pnlForm.Controls.Add(txtCompany);
    pnlForm.Controls.Add(new LiteralControl("
"));
    pnlForm.Controls.Add(new LiteralControl("

"));
    phFormContent.Controls.Add(pnlForm);
}

// keeps track of how many panels we need to recreate.
public int FormCount
{
    get
    {
        if (ViewState["FormCount"] != null)
        {
            return (int)ViewState["FormCount"];
        }

        return 1;
    }
    set
    {
        ViewState["FormCount"] = value;
    }
}

With all of this in place the placeholder can be empty since the first page request adds the first panel:
<asp:PlaceHolder ID="phFormContent" runat="server" EnableViewState="true"></asp:PlaceHolder>


text:
Q: Rename SQL log and master database file I am working on SQL Server 2014. I want to know how can I rename the .ldf and .mdf files of my database after creating it? If it is possible what are the steps?

A: You can't rename the files while they are in use, and don't make them "not in use" by stopping the SQL Server, it won't pick up on the change automatically.
The quickest way is as follows:

*

*Detach the database with EXEC sp_detach_db 'database_name' or the appropriate dialogue in SQL Server Management Studio.
The database must have no current connections otherwise SQL Server won't allow you to detach it - if you have trouble with this force that database into single user mode.

*Rename the files as needed

*Reattach the database which assuming you ave only a single data file and a single log files is done with EXEC sp_attach_db 'database_name', 'full_path_to_mdf', 'full_path_to_ldf', for example: EXEC sp_attach_db 'my_renamed_db', 'd:\dbs\data\my_renamed_db.mdf', 'd:\dbs\logs\my_renamed_db.ldf'
Again, the appropriate dialogue in SQL Server Management Studio can be used instead.

As you are specifying the database name in the call to sp_attach_db, this does the rename step also.
Update:
As Travis reminds me in the comments, sp_attach_db has been officially deprecated for a while and you should use the newer DDL method instead. The above example becomes:
CREATE DATABASE my_renamed_db
    ON (FILENAME = 'd:\dbs\data\my_renamed_db.mdf')
     , (FILENAME = 'd:\dbs\data\my_renamed_db.ldf')
FOR ATTACH;

Slightly safer even, you can avoid completely detaching the database at all by setting it offline and modifying the file locations instead (you still have to manually move or rename the files though):
ALTER DATABASE my_renamed_db SET OFFLINE;
ALTER DATABASE my_renamed_db MODIFY FILE (NAME='data_file_name', FILENAME='d:\dbs\data\my_renamed_db.mdf');
ALTER DATABASE my_renamed_db MODIFY FILE (NAME='log_file_name', FILENAME='d:\dbs\data\my_renamed_db.ldf');
ALTER DATABASE my_renamed_db SET ONLINE;

You can move/rename the files any time after the SET OFFLINE but before SET ONLINE.
If you don't know the logical filenames you can look them up in SSMS or via
SELECT f.name, f.physical_name
FROM   master.sys.databases d
JOIN   master.sys.master_files f
       ON d.database_id = f.database_id
WHERE  d.name = 'my_renamed_db'

If moving tempdb things are different: you can't offline it and it is recreated every time the server starts. Instead make the ALTER DATABASE MODIFY FILE calls and restart the SQL Server instance.

A: The procedure for moving system databases is documented in the SQL Server Books Online under the Move System Databases topic.
In summary:
1.Run SQL Server Configuration Manager, located in the Configuration Tools program group.
2.Right-click the instance of SQL Server (for example, SQL Server (MSSQLSERVER)) and choose Properties under the SQL Server Services node.
3.In the SQL Server Properties dialog box, click the Startup Parameters tab.
4.In the Existing parameters box, select the –d parameter to move the master data file. Click Update to save the change.
In the Specify a startup parameter box, change the parameter to the new path of the master database.
5.In the Existing parameters box, select the –l parameter to move the master log file. Click Update to save the change.
In the Specify a startup parameter box, change the parameter to the new path of the master database.
The parameter value for the data file must follow the -d parameter and the value for the log file must follow the -l parameter. The following example shows the parameter values for the default location of the master data file.
-dC:\Program Files\Microsoft SQL Server\MSSQL.MSSQLSERVER\MSSQL\DATA\master.mdf
-lC:\Program Files\Microsoft SQL Server\MSSQL.MSSQLSERVER\MSSQL\DATA\mastlog.ldf
If the planned relocation for the master data file is E:\SQLData, the parameter values would be changed as follows:
-dE:\SQLData\master_newname.mdf
-lE:\SQLData\mastlog_newname.ldf
6.Stop the instance of SQL Server by right-clicking the instance name and choosing Stop.
7.Move the master.mdf and mastlog.ldf files to the new location and rename as desired.
8.Restart the instance of SQL Server.
9.Verify the file change for the master database by running the following query.
SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID('master');

A: The procedure is simple and well documented for both user and system databases, please see here:
Moving User Databases
Moving System Databases

A: It's possible. But mostly avoid to rename of (.mdf) or (.ldf) live accessing database file.
There are some couple of steps through which you can do that through T-SQL as below mention steps:-
1) Set Database in single user mode
2)Rename the Database
3)Set Database to Multi-User Mode
4)Rename Logical File Name
5)Checking Physical name
6)Detach Database
7)Attach New Database

For ref  http://blog.codespecies.com/2013/07/rename-a-database-and-its-mdf-and-ldf-files-in-sql-server/  and
http://mediumcube.com/mctalk/2013/07/05/how-to-rename-mssql-database-mdf-and-ldf-files/.
NB:- Always consult to Database Team before Executing T-SQL file in live database in production Server. Because it's directy affect in DB.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Swift equivelent for every 'x' press of button to perform action Coming from objective-C background and just moving slowly into Swift, I can use let rather than #define however how would this statement be translated from objective-C to swift?
#define ADS_INTERSTITIAL_ON_LOBBY_FREQUENCY 5 will become let ADS_INTERSTITIAL_ON_LOBBY_FREQUENCY = 5
However, how can we translate this below to swift?
#ifdef ADS_INTERSTITIAL_ON_LOBBY_FREQUENCY

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSInteger nb_shown_lobby = [prefs integerForKey:@"nShownLobby"];
nb_shown_lobby++;
[prefs setInteger:nb_shown_lobby forKey:@"nShownLobby"];
[prefs synchronize];

if ((nb_shown_lobby % ADS_INTERSTITIAL_ON_LOBBY_FREQUENCY) == 0) {

   //My Method goes here

}

#endif

The endgame of the above method is to basically show an action on every 5th press.

A: You may want to use entirely different approach here, such as for instance bundling a plist file that tells your application which features to enable and which to skip. This would be a runtime check but it's not that terrible.
The other way would be to introduce a struct with feature flags and compile the right configuration on per-target basis, i.e:
/// FeatureFlagsAbstract.swift
protocol FeatureFlags {
    static var myFeature: Int? { get }
}

/// Target A/Features.swift
struct MyFeatureFlags: FeatureFlags {
    static var myFeature: Int? {
        return 5
    }
}

/// Target B/Features.swift
struct MyFeatureFlags: FeatureFlags {
    static var myFeature: Int? {
        return nil
    }
}

/// Class.swift
class MyClass {
    func doSomething() {
       if let value = MyFeatureFlags.myFeature {
          // branch that uses some feature
       }
    }

}

A: Unfortunately none of the provided replies gave a correct answer, I have since figured out the solution.
let ADS_INTERSTITIAL_ON_LOBBY_FREQUENCY = 5

                    let prefs = UserDefaults.standard
                    var nb_shown_lobby = prefs.integer(forKey: "nShownLobby")
                    nb_shown_lobby += 1
                    prefs.set(nb_shown_lobby, forKey: "nShownLobby")
                    prefs.synchronize()

                    if (nb_shown_lobby % ADS_INTERSTITIAL_ON_LOBBY_FREQUENCY) == 0 {
                        //Do your method here
                    }

A: Has now it is a swift constant it can be processed with swift code :
if ADS_INTERSTITIAL_ON_LOBBY_FREQUENCY > 0 { // equivalent to ifdef
…
} // équivalent to endif

To undefined ADS_INTERSTITIAL_ON_LOBBY_FREQUENCY set its value to 0
In case value 0 may be used in other context, you may use optional integer :
// let ADS_INTERSTITIAL_ON_LOBBY_FREQUENCY : Int? = 5
// -> is equivalent to #define myMacro 5
// let ADS_INTERSTITIAL_ON_LOBBY_FREQUENCY : Int? = nil
// is equivalent to not defining the macro
// uncomment the line according to what you want to achieve

usage :

if let _ = ADS_INTERSTITIAL_ON_LOBBY_FREQUENCY {
    …
    if ((nb_shown_lobby % ADS_INTERSTITIAL_ON_LOBBY_FREQUENCY!) == 0) {

   //My Method goes here

}

}


text:
Q: How I can launch Datalab via Console? I am able to create the datalab instance via Cloudshell with datalab create datalab-instance-name shell command but unable to find a way to create it via GCP console.
Is there any specific reason for not allowing to create datalab via GCP console?

A: I have reviewed the Cloud Datalab Documentation and I could confirmed that the only way to create a datalab instance is via the datalab create command. This is the only available option regardless the location/region where the datalab instance is being generated.
In case this feature doesn't cover your current needs, you can use the Send Feedback button, located at the lower left and upper right corners of the service public documentation, as well as use the Issue Tracker tool in order to raise a Datalab feature request and notify to Google about this desired functionality.


text:
Q: Pendulum datetime python library is not handling ok datetimeobjects when change of time I have a datetime object in chilean hour that I traslate to UTC:

*

*from 2022-09-04 00:00:00 to 2022-09-04 01:00:00-04:00

I do the translation by using the pytz library. The library first was not doing ok its job because in chile they change the time always the first saturday of september, but this year they did the change of time in the second saturday because of their elections. Anyway, pytz took care of this on a new version.
The problem I have now is that in a project i am working they are using also the "pendulum" library.
The problem is that it looks that the library is not working fine:

//datetime_obj=2022-09-04 01:00:00-04:00
pendulum_dt = pendulum.instance(datetime_obj)

If i print the pendulum_dt it changes the timezone i do not know why...:
Output: 2022-09-04T01:00:00-03:00
Edit:
If before doing the pendulum i check the datetime_obj.tzinfo it says "America/Santiago" so i am assuming that pendulum is still working with the old time change and because it may look at the tz_info instead to the offset, it translates the datetime_obj. Exist a new version of the library i am not seeing?


text:
Q: How to perform curl command to Secured ElasticSearch (ElasticSearch running in Openshift namespace openshift-logging) I have installed ElasticSearch in openshift-logging namespace in my openshift cluster.
I'm able to perform curl to elasticsearch using bearer token, now I want to perform curl to ElasticSearch using TLS certs.
CURL working with oc exec
oc exec elasticsearch-cdm -- curl -tlsv1.2 --insecure -H "Authorization: Bearer $(token)" "https://172.30.245.25:9200/_cat/health"
CURL working with elasticsearch service route using bearer token
curl -tlsv1.2 --cacert -H "Authorization: Bearer $(token)" https://$(esRoutes)/_cat/health
Now I want to perform curl using TLS certification, I have extracted secrets from running elasticsearch cluster and included the cert and key filename below,
Certs and Keys:
admin-ca admin-cert admin-key elasticsearch.crt elasticsearch.key logging-es.crt logging-es.key
How to perform CURL to running ElasticSearch (in openshift namespace opernshift-logging) using certs ?.

A: Hopefully this is what you are looking for:
oc exec -n openshift-logging logging-es-data-master-xxxxx-x-xxxxx -- curl -tls1.2 -s -k --cert /etc/elasticsearch/secret/admin-cert   --key /etc/elasticsearch/secret/admin-key https://localhost:9200/_cat/health

optional
oc exec -n openshift-logging logging-es-data-master-xxxxx-x-xxxxx -- curl -tls1.2 -s -k --cert /etc/elasticsearch/secret/admin-cert   --key /etc/elasticsearch/secret/admin-key https://localhost:9200/_cat/thread_pool?v

es-util version
oc exec -n openshift-logging logging-es-data-master-xxxxx-x-xxxxx -c elasticsearch -- es_util --query=_cluster/health?pretty=true


text:
Q: i cannot run my test case with robotium i have .apk file and i want to test it using robotiun and i have followed the procedure but when i run the app using junit test i am getting an error as Test run failed: Instrumentation run failed due to 'Process crashed.'
This is my androidmanifest.xml:
    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.metago.astro.test" android:versionCode="1" android:versionName="1.0">

    <uses-sdk android:minSdkVersion="15" />
    <uses-permission android:name="android.permission.RUN_INSTRUMENTATION" />>

    <instrumentation android:name="android.test.InstrumentationTestRunner"
        android:targetPackage="com.metago.astro" />

    <application android:icon="@drawable/ic_launcher"
        android:label="@string/app_name">
        <uses-library android:name="android.test.runner" />
    </application>

</manifest>

My TestActivity.java file is
        @SuppressWarnings("unchecked")
    public class TestActivity extends ActivityInstrumentationTestCase2 {
        private static final String TARGET_PACKAGE_ID = "com.metago.astro";
        private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.metago.astro.SplashActivity";
        private static Class<?> launcherActivityClass;
        static {
            try {
                launcherActivityClass = Class
                        .forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            }
        }
        public TestActivity() throws ClassNotFoundException {
            super(TARGET_PACKAGE_ID, Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME));
            }

        private Solo solo;

        @Override
        protected void setUp() throws Exception {
            solo = new Solo(getInstrumentation(), getActivity());
        }
        public void testCanOpenSettings() {
            solo.pressMenuItem(0);
        }
        @Override
        public void tearDown() throws Exception {
            solo.finishOpenedActivities();
        }
    }

My logcat is
        FATAL EXCEPTION: main
        java.lang.ExceptionInInitializerError
        at java.lang.Class.newInstanceImpl(Native Method)
        at java.lang.Class.newInstance(Class.java:1319)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4424)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.metago.astro.SplashActivity
        at com.metago.astro.TestActivity.<clinit>(TestActivity.java:19)
        ... 15 more
         Caused by: java.lang.ClassNotFoundException: com.metago.astro.SplashActivity
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:217)
        at java.lang.Class.forName(Class.java:172)
        at com.metago.astro.TestActivity.<clinit>(TestActivity.java:17)
        ... 15 more
        Caused by: java.lang.NoClassDefFoundError: com/metago/astro/SplashActivity
        Caused by: java.lang.ClassNotFoundException: com.metago.astro.SplashActivity
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
        ... 19 more

Line no 17 is .forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);

A: The package name for your test project needs to be different from the package name for the application you want to test. The package name must be a unique identifier. In your test application you should use something like package="com.metago.astro.test"
Also, you may need to add the following permission:
<uses-permission android:name="android.permission.RUN_INSTRUMENTATION" />


text:
Q: Chrome font color 'clipping' I have my links change color on hover, but the full text isnt changing and leaving clipped bits the default color making it look buggy.
Is there a way to solve this?
http://jsfiddle.net/C8K8z/
a{
    font-family:'Oleo Script';
    font-size:50px;
    color:white;
    text-decoration: none;

}
a:hover{
    color:#c41313;
    text-decoration:underline;
}

A: The issue seems to be with the Oleo Script font. It isn't 100% consistent, but some of the characters' font design (the hinting?) can cause the edges to end outside the element's box.
I would recommend using another font that doesn't have this issue, but if you're committed to Oleo, you can add padding to the left and right to work around it.
a{
    font-family:'Oleo Script';
    font-size:50px;
    color:white;
    text-decoration: none;
    padding: 0px 3px 0px 3px;
}

Also, your fiddle wasn't importing the font correctly (a problem with jsfiddle I believe), but I was able to get it to work by using the Google Font JavaScript import option instead of linking the css resource.
You can see the font problem here: http://jsfiddle.net/aYxEU/
And the fix here: http://jsfiddle.net/hFgaw/


text:
Q: Using %in% to identify if an element is in a df Here is my sample code:
DF$Owner <- ifelse (ExcelData$Brand %in% Reference$Brand, Reference$Owner, "NULL")

Basically what I'm trying to do is to identify whether there is a brand from ExcelData to Reference. If there is then I'll get its owner
Example: In the ExcelData there is a brand 'Baja', there is also a brand 'Baja' in the reference file. Now with the logic of %in% I should get the owner of brand 'Baja' which in this case is 'AMBC01' but the owner that I get when running the code is different. Now I'm thinking that maybe I need to track the row or anything in order to get the right owner for each identified brand.

A: It's better to use joins instead ofifelse and %in%. Different types of joins combine columns of 2 (or more tables) into one table. Based on your description it seems left join is feasible, please see the simulation and code below:
library(tibble)
library(tidyverse)
# Data simulation
excel_data <- tribble(~ brand, ~id,
                     "Baja", 1,
                     "Aumento", 4)
reference_data <- tribble(~brand, ~owner,
                          "Baja", "AMBC01",
                          "Aumento", "BMBC02",
                          "Azul", "CDCX03")

# Algorithm
left_join(excel_data, reference_data, by = "brand")

Output:
Joining, by = "brand"
# A tibble: 2 x 3
  brand      id owner
  <chr>   <dbl> <chr>
1 Baja        1 AMBC01
2 Aumento     4 BMBC02


text:
Q: Default language layout is showing in TYPO3 When I am hiding a layout in German language it gets contents from default language (English). Its not hiding in German language.

In the above image I have made it hidden. But when I run a page in German language the default english content is loaded for this layout
Typo3 Version : 4.7.4
Extension is Grid Element
Any idea on this?

A: The behavior you are describing is intended. When you hide a translation of the page, the default language is shown (because there is no translation). To hide the page if no translation exists, there is an option called "Hide page if no translation for current language exists" in the page properties.
If you want this behavior to be true for all your pages, you can also add this to your localconf.php in the typo3conf folder:
$TYPO3_CONF_VARS['FE']['hidePagesIfNotTranslatedByDefault'] = '1';

A: Checkout the settings for sys_language_mode. The documentation is for version 8 but it should work for version 4.7, too.
https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html#sys-language-mode


text:
Q: What is the covariance between function and its argument? For example, we have log-likelihood function $\ell(\theta)$ and maximum likelihood estimator $\hat \theta_{ML}$ obtained as $\ell(\theta)' = 0$. What would be
$$Cov(\ell(\theta), \hat \theta_{ML}) ?$$
For simplicity let's assume that MLE is unbiased.


text:
Q: iptables setting connmark but ip rule not matching I am trying to set up an Ubuntu 17.10 VM to use multiple VPN connections, and to load balance connections between them.  I am trying to do that by running multiple openvpn clients, and trying to mark connections with iptables/connmark and using mode random to mark different connections with different values, then matching these with different VPN routing tables.  However, I am having no success, so I have tried to simplify the situation to try to understand what is going wrong.
I have reduced the scenario to a single VPN connection, with all my routing logic in a dedicated routing table, and trying to mark all packets to use that routing table.
If I force all traffic to use that table, it works ok.  If I try to mark all packets and then match that mark to use the table, it doesn't work.
Here are the rules that work:

0:      from all lookup local
10:     from all lookup VPN2
32766:  from all lookup main
32767:  from all lookup default

and here are the rules that do not work:
0:      from all lookup local
10:     from all fwmark 0x14 lookup VPN2
32766:  from all lookup main
32767:  from all lookup default

And here is my iptables mangle table that should mark everything:

# iptables -nvL -t mangle
Chain PREROUTING (policy ACCEPT 6785 packets, 464K bytes)
 pkts bytes target     prot opt in     out     source               destination
 8013  545K CONNMARK   all  --  *      *       0.0.0.0/0            0.0.0.0/0            CONNMARK restore
 7981  543K MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            MARK set 0x14
 7958  541K CONNMARK   all  --  *      *       0.0.0.0/0            0.0.0.0/0            CONNMARK save

Chain INPUT (policy ACCEPT 6773 packets, 463K bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 4382 packets, 1132K bytes)
 pkts bytes target     prot opt in     out     source               destination
 4636 1159K CONNMARK   all  --  *      *       0.0.0.0/0            0.0.0.0/0            CONNMARK restore
 4516 1146K MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            MARK set 0x14
 4382 1132K CONNMARK   all  --  *      *       0.0.0.0/0            0.0.0.0/0            CONNMARK save

Chain POSTROUTING (policy ACCEPT 4151 packets, 1116K bytes)
 pkts bytes target     prot opt in     out     source               destination

I understand my rules are a bit pointless here (the restore, before marking anyway) but I have just been trying to get it to mark everything to understand where the problem is.
Like I say, if I have everything use the VPN2 routing table, it works fine - and I can see connections marked with 20 (0x14) using conntrack -L
But if I try to have the routing based on the mark, it doesn't work, and the connection attempt isn't even visible in conntrack -L, even though I see the SYN_SENT status in netstat.  I also see the source IP is not my VPN tun interface, so the table is not being used.
Any advice to debug this is greatly appreciated.
Many thanks


text:
Q: Running Hello_Osgi in ESF Emulator crashes on Eclipse EE, Kura, Ubuntu Linux I am trying to establish a toolchain for writing Java ESF/OSGI plugins. I have carefully followed the instructions given in the Eurotech ESF documentation (Development Environment Setup, Hello World Application, Deploy and Debug Applications).
Having completed my trivial Hello_Osgi project, I right-click ESF Emulator_Linux.launch in org.eclipse.jura.emulator project. I then choose Run As and then 1 ESF_Emulator_Linux.
In the Eclipse Console I do not see any output from my Hello_Osgi project being run. The first line of output is this (copied by eye):
<terminated>ESF Emulator Linux[OSGI Framework]/home/john/.p2/pool/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_15.0.2.v20210201-0955/jre/bin/java (26 May 2021, 10:32:28 - 10.32.51)

I then get pages of errors, followed by output from other projects. It appears that the ESF Emulator is crashing - but then how come the other projects run OK?
Can anyone please suggest what I am doing wrong?
The components installed are:

*

*esf-user_workspace_archive_6.2.0.zip
Java openJDK 1.8.0_292 (for Hello_Osgi project)
mtoolkit-neon.s3-website-us-east-1.amazonws.com

*Eclipse JEE-2021-03
Java OpenJDK 15.0.2 (came with Eclipse EE install)
Ubuntu Desktop 20.04

First few lines of Eclipse Console Output:
2021-05-26T10:32:32,348 [main] INFO  c.e.f.s.m.AdvancedCryptoServiceImpl - Activating... b0307191400
2021-05-26T10:32:32,977 [Start Level: Equinox Container: 78b7db4a-28f6-4896-8167-2c7fe00192eb] INFO  c.f.h.HelloWorld - Bundle com.fuelactive.hello_osgi has started OK
2021-05-26T10:32:32,978 [Start Level: Equinox Container: 78b7db4a-28f6-4896-8167-2c7fe00192eb] INFO  c.f.h.HelloWorld - Bundle com.fuelactive.hello_osgi has started OK
2021-05-26T10:32:32,978 [Start Level: Equinox Container: 78b7db4a-28f6-4896-8167-2c7fe00192eb] INFO  c.f.h.HelloWorld - Bundle com.fuelactive.hello_osgi has started OK
osgi> 2021-05-26T10:32:34,519 [Start Level: Equinox Container: 78b7db4a-28f6-4896-8167-2c7fe00192eb] INFO  o.e.j.u.log - Logging initialized @5901ms to org.eclipse.jetty.util.log.Slf4jLog
2021-05-26T10:32:34,702 [Start Level: Equinox Container: 78b7db4a-28f6-4896-8167-2c7fe00192eb] INFO  o.e.j.s.Server - jetty-9.4.19.v20190610; built: 2019-06-10T16:30:51.723Z; git: afcf563148970e98786327af5e07c261fda175d3; jvm 15.0.2+7-27
2021-05-26T10:32:34,743 [Start Level: Equinox Container: 78b7db4a-28f6-4896-8167-2c7fe00192eb] INFO  o.e.j.s.session - DefaultSessionIdManager workerName=node0
2021-05-26T10:32:34,743 [Start Level: Equinox Container: 78b7db4a-28f6-4896-8167-2c7fe00192eb] INFO  o.e.j.s.session - No SessionScavenger set, using defaults
2021-05-26T10:32:34,745 [Start Level: Equinox Container: 78b7db4a-28f6-4896-8167-2c7fe00192eb] INFO  o.e.j.s.session - node0 Scavenging every 660000ms
2021-05-26T10:32:34,783 [Start Level: Equinox Container: 78b7db4a-28f6-4896-8167-2c7fe00192eb] INFO  o.e.j.s.h.ContextHandler - Started o.e.j.s.ServletContextHandler@71939acc{/,null,AVAILABLE}
2021-05-26T10:32:34,797 [Start Level: Equinox Container: 78b7db4a-28f6-4896-8167-2c7fe00192eb] INFO  o.e.j.s.AbstractConnector - Started ServerConnector@747f84f3{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2021-05-26T10:32:34,797 [Start Level: Equinox Container: 78b7db4a-28f6-4896-8167-2c7fe00192eb] INFO  o.e.j.s.Server - Started @6181ms
Framework is running in emulation mode

A: I received a response from technical support. They tell me that the ESF 6.2.0 emulator is a problem and to deploy direct to hardware instead.
This means that the "Getting Started" documentation is useless, since it requires the reader to use the emulator.


text:
Q: mapcar with lambda and two list as input first, i would like to understand the difference, if there is any, in the following code:

  1 (setf list1 '(1 2 3))
  2 (setf list2 '(10 100))
  3
  4 (defun som(x y )
  5         (* x y))
  6
  7
  8 (print(mapcar #'(lambda(x)x)  list1))
  9 (print (mapcar #'(lambda(x)x)  list1))

which returns the following:

(1 2 3)
(1 2 3)

Then i would like to understand how to do the following:

(setf list1 '(1 2 3))
(setf list2 '(10 100))
(mapcar '#+ x y)

in order to get the following:
((11 101) (12 102) (13 103)), this is, add the first item of the first list
to every item of the second list.
Of course I could, very quickly define a function which would iterate through a list and apply a mapcar to the list. I was wondering  if there is any primitive which would do that.
Thanks, have a good night

A: Your code
(setf list1 '(1 2 3))
(setf list2 '(10 100))

(defun som(x y )
        (* x y))

(print(mapcar #'(lambda(x)x)  list1))
(print (mapcar #'(lambda(x)x)  list1))

;; This is the same between forms you do not need the space
;; but it is more readeable to write things with spcaes and tabs
so this is how I woul write the expression
(print (mapcar #'(lambda (x) x)  list1))

or you can use the function identity
(print (mapcar #'identity list1))

allways remeber that the first element of the form is a function for the evaluator
to understand this you need to get a full understanding of lambda experssions and map functions in lisp also will be useful to learn functional programming, in that case you will wirte this as quickly as you will write the iterate version
You will have other aproches, this is not one of my foavourites because the use of global variables but it should do the thick it allways remember me to the iterative version
(defparameter *list1* '(1 2 3))
(defparameter *list2* '(10 100))

(print (mapcar (lambda (x) (mapcar (lambda (y) (+ x y)) *list2*)) *list1*))


text:
Q: no any html tag working in angular js In case of printing the response from other server,which might have too much html code,and want to print in only single div how can i do it?
In jquery we can use

$("#xyz").html("
Hello World
thank yougood bye");
is there any solution to print it in anguler
I am trying to print the Hello World in h1 tag but it shows only text without any effect
This is my code
<!DOCTYPE html>

            {{kj}}

This is my output

Hello World
thank yougood bye

A: You need to use templates to build markup structure:

{{kj}}

And scope variables to put the content into templates:
$scope.kj = "Hello World";

If you want to build custom tags, use directives.

Note, you can also do something like this using ng-bind-html-unsafe (or just ng-bind-html, depending on the angular version), but it's definitely not recommended in this case:

while having:
$scope.kj="
Hello World
thank yougood bye";

This directly answers your question, but it's not really the ideal way to do things in angular.

Your updated version:

{{kj}}
{{ty}}{{gb}}

Controller
$scope.kj = "Hello World";
$scope.ty = "thank you";
$scope.gb = "good bye";


text:
Q: Import a regular WordPress blog into a MU installation I am looking for a safe way to import independent blogs into a WordPress MU installation.
The basic idea is to merge multiple blogs running on subdomains into a single wordpress installation with MU feature.
I can use the WordPress export/import feature but it would not work in my case with some of the blogs having a lot of content. I have played with this option. Not worth it. Export would time out even on localhost.
I also need the postid to remain same so that links do not break.
I have spent a lot of time looking at the options I have. Import using PHPMYADMIN seems to be the only way out. But I am not sure what would be a safe way to import using this route!
Any ideas!

A: I don't know of you like the sound of domain mapping but check out http://codex.wordpress.org/Migrating_Multiple_Blogs_into_WordPress_3.0_Multisite and check out number 6 if they are on the same server. If not import seperate install into them so that number 6 works.

A:
I can use the WordPress export/import feature but it would not work in my case with some of the blogs having a lot of content. I have played with this option. Not worth it. Export would time out even on localhost.

Have you tried increasing the php script execution timeout values in your php.ini file (or perhaps in .htaccess)? I think I'd try that route first, if possible. You probably could set max_execution_time = 180, or perhaps even higher. It's possible that you might also need to bump up the memory limit, too. Add something like this to your wp-config.php:
define('WP_MEMORY_LIMIT', '160M');

Then, on the import side, you might run into upload size limits. Another php.ini tweak:
upload_max_filesize = 96M
post_max_size = 96M

Alternately, it's possible to split the WXR file into smaller pieces. I have a perl script for this, but I wrote it for a client, and would need permission to share it. But if you're interested, I can ask.
A little-known secret of the importer is that it will skip over information that it has previously imported. So if you get past the upload size limits, but the import times out part-way through, just try importing the same file again. It will quickly skip over the data that's already in the database, then pick up again where it left off. But that makes me nervous, because it's not foolproof: If it imports a post, but times out before saving the all the post's metadata, the metadata might get skipped.

A: Another option that I've seen eliminates the WordPress export/import option and goes directly to SQL dumps. The basic procedure is to create the new domain in multisite to get the ID, tables, etc., then do a SQL dump from the original, remove some tables from the dump (options, etc.), modify the remaining table names within the dump to match the database table names in multisite, then import the SQL dump and do housekeeping (author IDs, etc.).
Step-by-step at http://www.clausconrad.com/blog/migrating-a-bunch-of-wordpress-blogs-to-a-single-wordpress-3-multi-site-installation


text:
Q: what are the roles of synchronous and asyncronuos interfaces in a GWT RPC .can anyone explain it in detail? what are the roles of synchronous and asynchronous interfaces in a GWT RPC .can anyone explain it in detail?
Thanks in advance.

A:
[The] synchronous interface is the definitive version of your service's specification. Any implementation of this service on the server-side must extend RemoteServiceServlet and implement this service interface.
[…]
It is not possible to call this version of the RPC directly from the client. You must create an asynchronous interface to all your services […]
[…]
Before you can actually attempt to make a remote call from the client, you must create another client interface, an asynchronous one, based on your original service interface.
[…]
The nature of asynchronous method calls requires the caller to pass in a callback object that can be notified when an asynchronous call completes, since by definition the caller cannot be blocked until the call completes. For the same reason, asynchronous methods do not have return types; they generally return void. Should you wish to have more control over the state of a pending request, return Request instead. After an asynchronous call is made, all communication back to the caller is via the passed-in callback object.

Source: http://www.gwtproject.org/doc/latest/DevGuideServerCommunication.html#DevGuideCreatingServices


text:
Q: Swift Animation - button with circle behind I'm trying to create de same effect than the app "Music" :

When I click on a button, there is a view behind and when the button is not focused anymore, the view is hidden. I do this with TouchUpInside and TouchDown funcs.
    @IBAction func pressed(_ sender: UIButton) {
      UIView.animate(withDuration: 0.25, animations: {
         self.backgroundMoreView.alpha = 0.0
         self.backgroundMoreView.transform = CGAffineTransform(scaleX:
            1.2, y: 1.2)
         sender.transform = CGAffineTransform.identity
      }) { (_) in
         self.backgroundMoreView.transform = CGAffineTransform.identity
         }
   }

   @IBAction func unpressed(_ sender: UIButton) {
      UIView.animate(withDuration: 0.25) {
         self.backgroundMoreView.alpha = 0.3
         sender.transform = CGAffineTransform(scaleX: 0.8, y:
            0.8)
      }
   }

The problem is that, when I click and hold focus, and then I swipe out of the button, the function unpressed() is not called and the button stay "focused".
I tried also to add touchUpOutside function but no result. I don't know how to fix it.

A: For me this works (I prefer the exit on leaving the button)
@IBAction func touchDown(_ sender: UIButton) {
    UIView.animate(withDuration: 0.25, animations: {
        self.background.alpha = 1.0
    }) { (_) in
        print("do")
    }
}

@IBAction func touchDragExit(_ sender: UIButton) {
    UIView.animate(withDuration: 0.25, animations: {
        self.background.alpha = 0.0
    }) { (_) in
        print("away")
    }
}


text:
Q: Custom Polymer element appears in the DOM, but does not give content in symfony project Element:
<link rel="import" href="../../../../bower_components/polymer/polymer.html">
<link rel="import" href="../../../../bower_components/app-layout/app-drawer-layout/app-drawer-layout.html">

<dom-module id="app-index">
    <template>

hello

        test

    </template>

</dom-module>

Twig index:
{% extends 'base.html.twig' %}

{%  block links %}
    <link rel="import" href="../../../../../bower_components/polymer/polymer.html">

    <link rel="import" href="../../../../web/js/elements/app-index.html">
{% endblock %}

{% block body %}
    <app-index></app-index>
{% endblock %}

And the base twig file is nothing exciting, just the default from starting a symfony project.
Now the issue I am having is that I can display the page without errors, but the h1 and the span from the element do not appear.  I use the chrome dev tools and see the  tag  and when I hover over it I get a size of 0x0.  I can't figure out what I am missing.

A: I suspect it's a path issue.
The link in HTML shows:
<link rel="import" href="../../../../bower_components/polymer/polymer.html">

But in your twig you have:
<link rel="import "href="../../../../../bower_components/polymer/polymer.html">

Notice the missing "../". Maybe you specified the wrong directory path somewhere?
I would suggest using FireFox to debug, I find it has much better tools available. Also in FireFox if you right-click on the page and select "inspect element", then go to the "Network" tab; then reload your page, you'll see if your scripts are loading correctly (usually an error is shown).


text:
Q: Hide table on no matches (wenzhixin's extended bootstrap table) I have a page with three tables. I put a "button formatter" on the first table, when clicked it sets the data-url for the second two.
Example:
window.actionEvents = {
     'click .edit': function (e, value, row, index) {
            $('#tabletwo').bootstrapTable('refresh', {
                url: '/api/controllerExample/' + row.id + '/exampleActionOne'
            });
            $('#tablethree').bootstrapTable('refresh', {
                url: '/api/controllerExample/' + row.id + '/exampleActionTwo'
            });
        }
    };

Now, not all row "id" rows will have any data. And such its kind of an eye-sore with two tables displaying that they have nothing to display.
The question:
Is it possible to set an actionlistener to a table such as "done loading data", and then check if table is empty, if it is perform some logic (such as setting a div to be hidden)

A: Solved my own question.
Bootstrap table supports events, so I listen on a "load-success" event, when it fires i get the data from the table and check if its no more than 2 ( "[]" ). If its two it means the table is empty.
Example:
       $('#tabletwo').on('load-success.bs.table', function () {
            if (JSON.stringify($('#tabletwo').bootstrapTable('getData')).length < 3) {
                        $('#containingDiv').hide();
                    } else {
                        $('#containingDiv').show();
                    }
        });

A:     let $msgTable = $('#bootstrapTable');
    $msgTable.on('load-success.bs.table', function (data) {
        let $tableBlock = $('#bootstrapTableBlock');
        if (data.length > 0) {
            $tableBlock.show();
        } else {
            $tableBlock.hide();
        }
    });


text:
Q: jQuery: getJSON vs get, http headers? (Twitter API) Hey all. I'm using the Twitter API via javascript and I'm firing a call to user_timeline.json. Everything seems to work fine with jQuery.getJSON but I'd really like to get the response as a string without it being converted into objects, which getJSON does. When I change my method from getJSON to get, I get the following error in Chrome:
Origin http://localhost is not allowed by Access-Control-Allow-Origin.

Which seems to be caused by the lacking of an Accept header. Am I correct? If so, how can I specify an HTTP header for the raw get method?
Thanks.

A: You can't get it as raw text, the way the whole thing works is JSONP, which creates a <script> tag, and the data that comes back is actual JavaScript, like this:
myFunc({ ...data ... });

It's not jQuery converting it to JSON here, it's actual JavaScript being called, where myFunc is your callback function...so the request is never text to deal with, it's a javascript object off the bat.

A: Only when you use JSON are you allowed to query domains different than the originating, with Ajax. (for security reasons)
See

*

*http://en.wikipedia.org/wiki/Same_origin_policy

*https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript
You will need to use a server proxy to do this.

If you want the actual JSON in string format then just re-stringify it.
Use https://github.com/douglascrockford/JSON-js and call var jsonString = JSON.stringify( yourJsonObject );


text:
Q: Index out of bounds error for initialised array I have tried all array declarations. I have tried Array<Int> and IntArray(). I have initialised the array, and stored ascii values in it. I can access it in the first loop. But if I try to access it after that, it returns out of bounds error. If I use array.first() it says that the array is empty. I can iterate through the array but cannot access it. I do not know what the error is. I am new to Kotlin.
import java.util.*;
import java.lang.*;
import java.io.*;
fun main(args:Array<String>){
    var read=Scanner(System.`in`);
    var t=read.nextInt();
    while(t>=0){
        if(read.hasNextLine()){
            var s=read.nextLine();
            var e=0;
            var a=IntArray(s.length);
            for(i in s){
                a[e]=i.toInt();
                e++;
            }
            Arrays.sort(a);
            e=0;
            if(97==a[e]) System.out.println("-1");
            else{
                for(i in a) System.out.print(i.toChar());
                System.out.println("");
            }
        }
        t--;
    }
}

A: Your problem isn't the array itself, but probably what you expected from the Scanner-calls. (Side-note that Scanner is AutoClosable, so you may want to use use with it, e.g. Scanner(System.in).use { /* your code here */ }.)
First of all, you are using Scanner.nextInt(). This means, that if you do not put a number first you will get an InputMismatchException.
So a number is a must. If you enter only a number, e.g. 1 you will then get your ArrayIndexOutOfBoundsException. The reason for it, is the following: the scanner basically reads 1\n if you press enter after the number.
Now nextInt() extracts the number and \n remains. Scanner.hasNextLine() is therefore true, because it still has a line ending. Scanner.nextLine() then reads your input upto the first new line, which is basically now an empty string.
So maybe you already want to consume the first new line after the nextInt(), i.e. calling read.nextLine() immediately after nextInt() basically discarding everything that is following your number.
Due to your comment regarding what you actually want, namely "I just want to know how to take input as an array", I will now rather concentrate on that.
You can call toCharArray() on any String. That being said, the following is a simplified version of your code that reads a String from console and sorts it based on its integer representation:
readLine()!! // yes... we know that we enter something valuable here ;-)
       .toCharArray()
       .sortedBy(Char::toInt) // well... actually .sorted() should suffice as well
       .joinToString("")

That's it. That's all you need to get the character array from a String and to sort them by their integer representation. As sortedBy returns a List you need to join it again accordingly.
There are also other variants to accomplish what you want, but I think this is the simplest one.
If you still want to ask for a number beforehand, you can still do so:
print("How often? ")
val howOften = readLine()!!.toInt()
(1..howOften).forEach {
  print("${it + 1}. input: ")
  readLine()!!.toCharArray()
              .sorted()
              .joinToString("")
              .run(::println)
}

The same using a scanner would look as follows:
Scanner(System.`in`).use { scanner ->
  print("How often? ")
  val howOften =scanner.nextInt()
  scanner.nextLine()
  (1..howOften).forEach {
    print("${it + 1}. input: ")
    scanner.nextLine().toCharArray()
                      .sorted()
                      .joinToString("")
                      .run(::println)
  }
}


text:
Q: Rest API Session ID SOAP Partner Connection I have a REST access token and would like to use that access token in my PartnerConnection ConnectionConfig to make a Bulk API call. It does not seem to work as I get an message to set my Service Endpoint. Please assist if it is possible to make a SOAP call from a REST access token?And how I can do it.

A: Yes you need to provide the service end point, if you logged in with Salesforce WSC (Web Service Connector) this is usually handled for you or returned in the LoginResult if you took the manual login route. If not you can set it manually like so.
ConnectorConfig partnerConfig = new ConnectorConfig();
partnerConfig.setServiceEndpoint("https://yourinstance.salesforce.com");
partnerConfig.setSessionId(yourSessionId);
ParnterConnection partnerConnection = Connector.newConnection(partnerConfig);

Note: Its not usually a good idea to hard code your instance name. I assume when forming the REST URL's you've already resolved this in a way that is satisfactory for your situation.

A: thanks for your advice here is the code the worked for me:

ConnectorConfig partnerConfig = new ConnectorConfig();
partnerConfig.setAuthEndpoint("https://test.salesforce.com/services/Soap/u/27.0");
partnerConfig.setServiceEndpoint("https://cs17.salesforce.com/services/Soap/u/");
partnerConfig.setSessionId(sessionProvider.getAccessToken());
new PartnerConnection(partnerConfig);


text:
Q: How should I select or display the out variable from a stored procedure call? I'm writing a pretty basic stored procedure that just takes values from the sample DB2 database and computes the standard deviation. I wrote the procedure itself just fine, and I can call it without error. But I can't figure out how to actually display my result or select it in a statement. Everything I try results in a syntax error and I haven't been able to find anyone doing this specific task in my google searches.
This is the gist of my code (snipped for brevity):
CREATE PROCEDURE SAL_STD_DEV
  (OUT std_dev real)
  LANGUAGE SQL
  BEGIN
    --do stuff
    SET std_dev = 10; --changed for simplicity
  END@

CALL SAL_STD_DEV(?)@

All this runs, but just CALL doesn't create any output. What's the syntax to SELECT the out variable? I can't put a DECLARE before the CALL because it's not in a stored procedure, and PRINT doesn't work either.
(@ is my terminal character because I'm using ; in the stored procedure)
Edit: Both the create procedure and call statements are made in the same SQL file, the database is connect to through localhost and I'm using DB2 11.1.0.1527 and developing in IBM Data Studio 4.1.2.

A: From wherever the CALL is being made, that feature might present a Result Set, despite apparently not presenting the result of an OUT parameter.  If so, then the stored procedure perhaps could be revised to return the OUT value [instead, or additionally] as a result set, so that the interface that accepts the CALL statement as input, might present that result-set.  Regardless:
In a statement processor [e.g. that is not a GUI, but] for which SELECT query output is presented, the following scripted requests should likely suffice:
create variable my_real real
;
call SAL_STD_DEV(my_real)
;
select my_real from sysibm.sysdummy1
;


text:
Q: PHP, FileSetup from LocalHost to Public Server So I was wondering about requirements regarding File-Setup to an online Server, as I'm actually using a Localhost.

*

*Document Root: I use the $_SERVER['DOCUMENT_ROOT'] / http / folder / file.php to navigate to all my files:

if I change to a Server, I do not have to make any changes regarding the path?

*file privancy: Mostly, I use classes & methods in those files.

If I upload all Files to the Server, does a user have access to them (eg. typing url/folder/file) &  isit possible to process/access them somehow as external user?
How to provent this the most easy way? (I heard about .htaccess, or using Server-rootfolder), but there is a simple php code to check if its a linked file?

*There are any other very important remarks regarding FILE setup from localhost to public Server? So, user are not able access sensitive data from Files (eg. DB Connection, datahandling, etc.)

Thank you very much for your help :)


text:
Q: How to draw the off-screen data in the framebuffer object to the QGLWidget? I use glGenFramebuffer, glBindFramebuffer and other related functions to create the Framebuffer Object(FBO) and I use the FBO to draw the off-screen data. Now my question is that I finish the mentioned steps inside QGLWidget and how can I draw the data in FBO back to QGLWidget? Thank you very much!

A: Assuming you attached a color buffer to your framebuffer using
glFramebufferTexture2D( myfboID, GL_FRAMEBUFFER, GL_TEXTURE_2D, mytexID, 0);

Change the framebuffer to the widget by
glBindFrameBuffer(GL_FRAMEBUFFER, 0);
glClear(GL_COLOR_BUFFER_BIT);

Simply render a QUAD textured with the previous texture. You can simply render a quad from [-1,-1] to [1,1] and with the above texture bound, and texture coordinates would be [0.0,0.0] - [1.0,1.0].


text:
Q: Cosmological densities when universe was/will be a different size Supposing a spatially flat, matter-dominated universe, the expression for the Hubble parameter is:
$$ H^{2}=H_{0}^{2}\left(\frac{\Omega_{m}}{a^{3}}+\Omega_{\Lambda}\right) $$
The previous equation then allows us to interpret the evolution of matter density as $ \Omega_{m}(a)=\frac{\Omega_{m}}{a^{3}}$. What I'm curious about is this - what was the value of $\Omega_{m}$ when the universe was one half its current size? What will its value be when it becomes two, ten, $n$ times its current size? Have I made an oversimplification or am I missing the point entirely?

A: You have to be very careful of the notation here, as different authors use different conventions. In the notation you use in your first equation, $\Omega_m$ is the matter density at $a=1$ relative to the critical density at $a=1$. To be explicit,
$$\Omega_m=\frac{\rho_m}{\rho_{\rm crit}}=\frac{\rho_m}{\left(\frac{3H_0^2}{8\pi G}\right)}$$
Notice in particular that the critical density is a constant with time because it is defined in terms of $H_0$. To be clearer, I'm going to denote this $\Omega_{m,0}$ instead, analogous to $H_0$ being the value of $H$ at $a=1$. Then:
$$\Omega_m(a)=\frac{\Omega_{m,0}}{a^3}$$
Once the sloppy notation is cleaned up, it's easy to see that when the (linear) size of the universe doubles, the matter density drops by a factor of $8$, if it is a quarter the size then the density is $4^3=64$ times higher, etc.


text:
Q: How to create Choropleth Map of USA states and DC with own data in Python? I have data frame which contains US states and some figures for each state. I have District of Columbia and its data which I need to plot in the map. Plotly Choropleth Map has state which does not have District of Columbia.
plotly.graph_objects..Figure(data=go.Choropleth(
locations=df['statecode'],
z=df['buyers'].astype(float),
locationmode='USA-states',
colorscale='Reds',
autocolorscale=False,
text=df['mytext'],
marker_line_color='white',
colorbar_title="Total buyers"

))
It has fips which is basically state and its counties, it creates county wise map.
    fips = USA_df['FIPS'].tolist()
    values = df['buyers'].tolist()

    plotly.figure_factory..create_choropleth(
    fips=fips, values=values,
    binning_endpoints=endpts,
    colorscale=colorscale,
    show_state_data=True,
    show_hover=True, centroid_marker={'opacity': 0},
    asp=2.9, title='',
    legend_title='Buyers'
)

So, if I use stateside, Plotly shows map with 50 states and DC is excluded. If I use fips, Plotly shows map for counties and districts.
Is there any way to create the Choropleth USA map for all states and DC?


text:
Q: Uncertain of what instance should be passed to the argument Error Message
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Patrick\Anaconda3\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
  File "<string>", line 20, in set_training_data_directory
  File "<string>", line 252, in printer
AttributeError: 'Navigate' object has no attribute 'Listbox1'

In this code, If I call the function set_training_data_directory, it should also call printer from the Toplevel1 which it does. However, as the method printer is expecting self as an argument, any instance from the Navigate class that I pass as an object says "object has no attribute 'Listbox1". I've passed self and self.main_g as an argument and so far the error I get is "object has no attribute 'Listbox1"
Module Name: All_Classes
import import_ipynb
import Navigator
import Listings
import Main_GUI

Module name: Main
from tkinter import *
import import_ipynb
import Main_GUI
root = Tk()
top = Main_GUI.Toplevel1(root)
root.mainloop()

Module name: Listings
import import_ipynb
from tkinter import filedialog
import sys
import tkinter as tk
import os
import All_Classes

class Lists:
    #Making a Navigator Object
    #List of the training data
    def get_list_of_training_data(self):
        training_data_names = []
        directory = self.get_training_dir()
        for classes in os.listdir(directory):
            for data in os.listdir(os.path.join(directory,classes)):
                print(data)
                training_data_names.append(data)
        return training_data_names

Module name: Navigator
import import_ipynb
from tkinter import filedialog
import tkinter as tk
import All_Classes

class Navigate:
    def __init__(self):
        #Global Navigation variables
        #Training data directory
        self.TRAINING_DIR = ''
        #Model directory for loading
        self.MODEL_DIR = ''
        #Sound file path for loading
        self.SOUND_FILE = ''

        self.listings = All_Classes.Listings.Lists

        #self.g = GUI.Toplevel1()
        self.main_g = All_Classes.Main_GUI.Toplevel1

    #Function for Data directory
    def set_training_data_directory(self):
        self.TRAINING_DIR = filedialog.askdirectory()
        p = self.listings.get_list_of_training_data(self)
        print(p)
        self.main_g.printer(self)

    def get_training_dir(self):
        return self.TRAINING_DIR

Module Name: Main_GUI
import import_ipynb
import All_Classes
import sys
import tkinter as tk
import tkinter.ttk as ttk
py3 = True

class Toplevel1:
    def __init__(self, top=None):
        self.nav = All_Classes.Navigator.Navigate()
        #'''This class configures and populates the toplevel window.
        #  top is the,  toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9' # X11 color: 'gray85'
        _ana1color = '#d9d9d9' # X11 color: 'gray85'
        _ana2color = '#ececec' # Closest X11 color: 'gray92'
        self.style = ttk.Style()

        top.geometry("832x674+650+150")

        self.style.configure('TNotebook.Tab', background=_bgcolor)
        self.style.configure('TNotebook.Tab', foreground=_fgcolor)
        self.style.map('TNotebook.Tab', background=
        [('selected', _compcolor), ('active',_ana2color)])
        self.TNotebook1 = ttk.Notebook(top)
        self.TNotebook1.place(relx=0.012, rely=0.0, relheight=0.895
               , relwidth=0.978)
        self.TNotebook1.configure(width=814)
        self.TNotebook1.configure(takefocus="")
        self.TNotebook1_t0 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t0, padding=3)

        self.TNotebook2 = ttk.Notebook(self.TNotebook1_t0)
        self.TNotebook2.place(relx=0.037, rely=0.113, relheight=0.461
                , relwidth=0.412)
        self.TNotebook2.configure(width=334)
        self.TNotebook2.configure(takefocus="")
        self.TNotebook2_t0 = tk.Frame(self.TNotebook2)
        self.TNotebook2.add(self.TNotebook2_t0, padding=3)
        self.TNotebook2.tab(0, text="Audio Files", compound="left", underline="-1"
                ,)
        self.TNotebook2_t0.configure(background="#d9d9d9")
        self.TNotebook2_t0.configure(highlightbackground="#d9d9d9")
        self.TNotebook2_t0.configure(highlightcolor="black")

        self.Button2 = tk.Button(self.TNotebook1_t0)
        self.Button2.place(relx=0.123, rely=0.78, height=40, width=190)
        self.Button2.configure(activebackground="#ececec")
        self.Button2.configure(activeforeground="#000000")
        self.Button2.configure(background="#d9d9d9")
        self.Button2.configure(disabledforeground="#a3a3a3")
        self.Button2.configure(foreground="#000000")
        self.Button2.configure(highlightbackground="#d9d9d9")
        self.Button2.configure(highlightcolor="black")
        self.Button2.configure(pady="0")
        self.Button2.configure(text='''Load Training Data''')
        self.Button2.configure(command= self.nav.set_training_data_directory)

        self.Listbox1 = tk.Listbox(self.TNotebook2_t0)
        self.Listbox1.place(relx=0.0, rely=0.0, relheight=1.008, relwidth=1.012)
        self.Listbox1.configure(background="white")
        self.Listbox1.configure(disabledforeground="#a3a3a3")
        self.Listbox1.configure(font="TkFixedFont")
        self.Listbox1.configure(foreground="#000000")
        self.Listbox1.configure(width=334)
        #Init Scrollbar object
        self.scroll1 = tk.Scrollbar(self.Listbox1)
        self.scroll1.configure(command=self.Listbox1.yview)
        self.Listbox1.configure(yscrollcommand = self.scroll1.set)

    def printer(self):
        print("printer Reached")

        self.Listbox1.pack()
        self.scroll1.pack(side = "right",fill = 'y')

        for i in range(20):
            self.Listbox1.insert(tk.END,i)

I am pretty new with object in python. If you happen to have an answer, I would appreciate it. Also could this be a bad way of designing?

A: Well. I had a look, and it definitely seems to be a issue with how you write and use classes. In Navigator you call the Lists class, but you don't instanciate it:
self.listings = All_Classes.Listings.Lists

To make an instance you must end the class name with parenthesis. Thus when you run the method get_list_of_training_data(self) there is no self to pass as self is the name of the instance.
Same thing with self.main_g = All_Classes.Main_GUI.Toplevel1.
From my perspective it looks like you build a complicated structure of classes when you really don't need them. To quote Jack Diederich: "The signature of this is not a class is that it has two methods, one of which is init". YouTube clip: Stop Writing Classes
On my end I'm having trouble to get it running without errors because my os.path.join() delivers dysfunctional paths, don't know why.
But: have look and see if you can make the code not so fractured and I think it will be easier to spot problems.


text:
Q: Given any sequence of real numbers $a_n$, show that there exists a subsequence $a_{n_k}$ of $a_n$.... Given any sequence of real numbers $a_n$, show that there exists a subsequence $a_{n_k}$ of $a_n$ and a real number $b$ such that $\sum\limits_{k\geq1}\mid b-\dfrac{a_{n_k}}{1+\mid a_{n_k}\mid}\mid$ is convergent.
I tried like this. For any subsequence  $a_{n_k}$ of $a_n$ , the sequence $\dfrac{a_{n_k}}{1+\mid a_{n_k}\mid}$ is always a bounded sequence. Hence it contains a convergent subsequence. Now from this I got stuck. please help

A: let $a_{n} > 0$ then $a_{n}+1 > 1$ $\Rightarrow$ $\frac{1}{a_{n}+1}<1$
$\dfrac{a_{n}}{1+\mid a_{n}\mid}=\dfrac{a_{n}}{1+a_{n}}=1-\dfrac{1}{1+a_{n}}<1$  which means it is bounded so there exists a subsequence $a_{n_k}$
$a_{n_k}$ is convergent $\Rightarrow$ $\dfrac{a_{n}}{1+\mid a_{n}\mid}$ is convergent
$\dfrac{a_{n}}{1+\mid a_{n}\mid}$ is convergent  $\Rightarrow$ $\sum\limits_{k\geq1}\mid b-\dfrac{a_{n_k}}{1+\mid a_{n_k}\mid}\mid$ is convergent
let $a_{n} < 0$ then $1-a_{n}>1$ $\Rightarrow$ $-1<\frac{1}{1-a_{n}}<0$
$\dfrac{a_{n}}{1+\mid a_{n}\mid}=\dfrac{a_{n}}{1-a_{n}}=\dfrac{1}{1-a_{n}}-1>-1$ $\Rightarrow$ $\mid \dfrac{a_{n}}{1+\mid a_{n}\mid}\mid <1$ which means it has a convergent subsequence $a_{n_k}$
$a_{n_k}$ is convergent $\Rightarrow$ $\mid \dfrac{a_{n}}{1+\mid a_{n}\mid} \mid$ is convergent
$\mid \dfrac{a_{n}}{1+\mid a_{n}\mid} \mid$ is convergent $\Rightarrow$ $\sum\limits_{k\geq1}\mid b-\dfrac{a_{n_k}}{1+\mid a_{n_k}\mid}\mid$ is convergent
NOTE: I also found  an article that may help you If $(a_n)$ is any real sequence , then $(\frac{a_n}{1+|a_n|})$ has a convergent subsequence

A: Since there is a $b$ and $(n_k)|_{k=1}^{\infty}$ such that
$\dfrac{a_{n_k}}{1+\mid a_{n_k}\mid}
\to b
$,
we can choose a subsequence
$(n_{k_m})|_{m=1}^{\infty}$ of $n_k$
such that
$\left|\dfrac{a_{n_{k_m}}}{1+\mid a_{n_{k_m}}\mid}- b\right|
\lt \dfrac1{2^m}
$,
and the sum of these converges.


text:
Q: create a mathematis matrix with python Well, I've looked a lot in the web before asking, so here's the thing.
I'm not really experienced in Python and I need to develop this Matrix Generator. Yes, it is a mathematics matrix. I'm using Tkinter and Python 3.3.
First i ask the Number of Rows and Columns and then I fill each field and the code transforms it in a notepad for other programs to read.
I used the grid method so i'm having trouble with large scale matrices. The thing is I need to apply a scrollbar. I have read that I can use frame and a friend of mine showed me a scrollbar he made using frames. Can you help me? ;D
Every time I refer to linhas is the same as rows and colunas is the same as columns.
import tkinter

class DropDown:
    def __init__(self):

        self._list_window = tkinter.Tk();

        self._row_var = tkinter.StringVar(self._list_window)
        self._col_var = tkinter.StringVar(self._list_window)
        self._row_var.set(0)
        self._col_var.set(0)

        self._rows = None
        self._columns = None

        self._row_label = tkinter.Label(
            master = self._list_window,
            text = 'Number of rows: ')

        self._row_label.grid(
            row = 0, column = 0, padx = 5, pady = 5,
            sticky = tkinter.NE)

        self._row_entry = tkinter.Entry(self._list_window, width=1)

        self._row_entry.grid(
            row = 0, column = 1, padx = 5, pady = 5,
            sticky = tkinter.EW)

        self._column_label = tkinter.Label(
            master = self._list_window,
            text = 'Number of columns: ')

        self._column_label.grid(
            row = 1, column = 0, padx = 5, pady = 5,
            sticky = tkinter.NE)

        self._column_entry = tkinter.Entry(self._list_window)

        self._column_entry.grid(
            row = 1, column = 1, padx = 5, pady = 5,
            sticky = tkinter.EW)

        self._list_window.columnconfigure(1, weight = 1)

        self._OK_button = tkinter.Button(
            master = self._list_window, text = "OK",
            command = self.get_dimensions)

        self._OK_button.grid(
            row = 2, column = 0, columnspan = 2,
            padx = 5, pady = 5)

    def get_dimensions(self):
        self._rows = self._row_entry.get()
        self._columns = self._column_entry.get()
        self._list_window.destroy()

    def show(self):
        self._list_window.mainloop()
        if self._rows != None and self._columns != None:
            return (int(self._rows), int(self._columns))
        else:
            return (None, None)

class matrix:
    def __init__(self, linhas, colunas):
        self.linhas=linhas
        self.colunas=colunas
        self.mwindow=tkinter.Tk()
        self.vars = [[] for x in range(self.linhas) ]

        for i in range(self.linhas):
            for j in range(self.colunas):
                v=tkinter.StringVar()
                self.vars[i].append(v)
                entry = tkinter.Entry(master = self.mwindow, textvariable = self.vars[i][j])
                entry.grid(row = i, column = j, padx = 10, pady = 10)

        self.botOK=tkinter.Button(master=self.mwindow, text="OK", command=self.OK)
        self.botOK.grid(row=self.linhas+1, column=(self.colunas//2)-1, columnspan=2, padx=5, pady=5)

    def Start(self):
        self.mwindow.mainloop()
        return self.lista

    def OK(self):
        self.lista = []
        for i in range(self.linhas):
            for j in range(self.colunas):
                self.lista.append(self.vars[i][j].get())

        self.mwindow.destroy()

dimensoes= DropDown().show()
#print (dimensoes)
if dimensoes[0]<dimensoes[1]:
    diag=dimensoes[0]
else:
    diag=dimensoes[1]
matriz=matrix(dimensoes[0], dimensoes[1]).Start()

with (open("notepadmatrix.txt", "w")) as arquivo:
    arquivo.write(str(dimensoes[0]*dimensoes[1])+"\n")
    arquivo.write(str(dimensoes[0])+"\n")
    arquivo.write(str(dimensoes[1])+"\n")
    arquivo.write(str(diag)+"\n")
    for i in matriz:
        arquivo.write(i+"\n")
    arquivo.write("fim")

and here goes the code he gave me to the scroll bar.
class Earnings():

    def __init__(self, Ticker, EPS, Time):
        self._root_window = tkinter.Tk()

        self.canvas = tkinter.Canvas(master = self._root_window, background = '#8989E0')
        self.canvas.config(scrollregion=[0,0,600,10000])

        self.frame = tkinter.Frame(master = self.canvas)

        self.scrollbar = tkinter.Scrollbar(master = self._root_window, orient = tkinter.VERTICAL)

        self.frame.pack(side = tkinter.LEFT, fill = tkinter.BOTH, expand = tkinter.TRUE)
        self.canvas.create_window((0,0), window=self.frame, anchor=tkinter.NW)
        self.scrollbar.pack(side = tkinter.RIGHT, fill = tkinter.BOTH, expand = tkinter.TRUE)

        self.canvas.pack(side = tkinter.TOP, fill = tkinter.BOTH, expand = tkinter.TRUE)

        self.scrollbar.config(command = self.canvas.yview)
        self.canvas.config(yscrollcommand = self.scrollbar.set)

        self.ticker = Ticker
        self.EPS = EPS
        self.time = Time

        for i in range(len(self.ticker)):

            self.TickerButton = tkinter.Button(
                master = self.frame,
                text = self.ticker[i],
                command = lambda i=i: self.search_ticker(self.ticker[i]))

            self.TickerButton.grid(row = i+1, column = 0, padx = 10, pady = 10,
                                  sticky = tkinter.W)

            self.EPSLabel = tkinter.Label(
                master = self.frame,
                text = self.EPS[i])

            self.EPSLabel.grid(row = i+1, column = 1, padx = 10, pady = 10,
                                  sticky = tkinter.W)

            self.TimeLabel = tkinter.Label(
                master = self.frame,
                text = self.time[i])

            self.TimeLabel.grid(row = i+1, column = 2, padx = 10, pady = 10,
                                  sticky = tkinter.W)

A: TkInter is long in the tooth, I'd use Kivy Grid layout instead:
http://kivy.org/docs/api-kivy.uix.gridlayout.html?highlight=grid


text:
Q: Emmet abbreviation syntax multiplication now working In VSCODE emmet element multiplication is not working....
For Example-
h1*3

Should Show results like below

But in my case it's not working.....other then this other emmet is working fine

A: the plugin for html has been deprecated,
you can install extension "Emmet Live",
you can download from here or open your visual studio code and install it from extension marketplace
after you install it press F1 on VSC and type Emmet live and enter your command,
in your case the command is h1*3 and done.


text:
Q: Preference Manager loads always default value I use Preference Manager to save some Integers and boolean values.
I have created a SettingsPreferences class :
public class SettingsPreferences {

    private Context mContext;

    public SettingsPreferences(Context context) {
        this.mContext = context;
    }

    public boolean isNull() {
        if (PreferenceManager.getDefaultSharedPreferences(mContext) == null) {
            return true;
        } else {
            return false;
        }
    }

    public void setBoolean(String name, boolean value) {
        PreferenceManager.getDefaultSharedPreferences(mContext).edit()
                .putBoolean(name, value).apply();
    }

    public void setInt(String name, int value) {
        PreferenceManager.getDefaultSharedPreferences(mContext).edit()
                .putInt(name, value).apply();
    }

    public boolean getBoolean(String name, boolean defaultValue) {
        return PreferenceManager.getDefaultSharedPreferences(mContext)
                .getBoolean(name, defaultValue);
    }

    public int getInt(String name, int defaultValue) {
        return PreferenceManager.getDefaultSharedPreferences(mContext).getInt(
                name, defaultValue);
    }}

In the onCreate method in the Main class I add the default values :
mSettingsPreferences = new SettingsPreferences(getApplicationContext());
if(mSettingsPreferences.isNull() == true) {
    mSettingsPreferences.setBoolean("MAX", 1);
    mSettingsPreferences.setBoolean("PROGRESS", 1);
}

In a fragment class I need to load that data and displayed it in a progress bar.
Here is the code :
Thread t = new Thread() {
   public void run() {
     try {
       sleep(100);
       SettingsPreferences sett = new SettingsPreferences(mContext);
       mProgBar.setMax(sett.getInt("MAX", 2));
       mProgBar.setProgress(sett.getInt("PROGRESS", 1));

     } catch (InterruptedException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
};
t.start();

The context is defined I checked him, the progressbar also, but every time it loads me the default values.
What is the problem?

A: Use this:
For initialize the preference use this:
SharedPreferences preferences = PreferenceManager
        .getDefaultSharedPreferences(context);
String string = preferences.getString(key, defValue);

Now For Storind Data:
Editor editor = preferences.edit();
editor.putString(key,value);
editor.commit();

For more information see this tutorial.
Hope you understand.

A: You have to call comit() of Editor  to apply change

A: I suppose your isNull() always returns false, because :
PreferenceManager.getDefaultSharedPreferences(mContext)

will not return null, at least I never seen such case. This way you never initialize your MAX and PROGRESS values, and in the end you read defaults.
You can use SharedPreferences.contains method to check if MAX exists, and if not then initialize it.


text:
Q: Pinterest Rich Pins Save : Truncating Title and tags I am having strange issue in my rich pin save button. Its truncating title and tags while creating new PINs into Pinterest.
I have used same OG data given in pinterest developer site.
Reference : https://developers.pinterest.com/docs/rich-pins/articles/?
Any suggestion or help on this will be much appreciated. Thanks in advance.
My code is as below.
    <head>

    <meta name="p:domain_verify" content="SITE_VERIFICATION_CODE"/>

    <meta property="og:type" content="article" />
    <meta property="og:title" content="sample title" />
    <meta property="og:description" content="sample content" />
    <meta property="og:url" content="https://www.sample.com/">
    <meta property="og:site_name" content="sample site name" />
    <meta property="og:image" content="https://live.staticflickr.com/7027/6851755809_df5b2051c9_b.jpg"  data-dynamic="true">
    <meta property="article:tag" content="tag1,tag2"  >
    <meta property="article:published_time" content="2018-08-12T00:01:56+00:00" />
    <meta property="article:author" content="Sample author" />
    <meta property="og:keywords" content="keywords1,keywords2"  >

    <script async defer src="//assets.pinterest.com/js/pinit.js"></script>
    </head>

    <body>

    <a target="_blank" style="cursor:pointer;" href="https://www.pinterest.com/pin/create/button/"
   data-pin-do="buttonBookmark"
   data-pin-custom="true">
   SHARE TO PINTEREST
   </a>
  </body>

Note : i have removed site verification code in above sample code.
Ref. https://developers.pinterest.com/docs/rich-pins/articals/?
Ref. https://developers.pinterest.com/docs/rich-pins/reference/?

A: I consulted issue with Pinterest Team and got following feedback. I hope anyone who's having same issue or having same requirements will get benefit from this.


text:
Q: Linq stored procedure with dynamic results So I'm extremely new to Linq in .Net 3.5 and have a question. I use to use a custom class that would handle the following results from a store procedure:

*

*Set 1: ID Name  Age

*Set 2: ID Address City

*Set 3: ID Product Price

With my custom class, I would have received back from the database a single DataSet with 3 DataTables inside of it with columns based on what was returned from the DB.
My question is how to I achive this with LINQ? I'm going to need to hit the database 1 time and return multiple sets with different types of data in it.
Also, how would I use LINQ to return a dynamic amount of sets depending on the parameters (could get 1 set back, could get N amount back)?
I've looked at this article, but didn't find anything explaining multiple sets (just a single set that could be dynamic or a single scalar value and a single set).
Any articles/comments will help.
Thanks

A: I believe this is what you're looking for
Linq to SQL Stored Procedures with Multiple Results - IMultipleResults

A: I'm not very familiar with LINQ myself but here is MSDN's site on LINQ Samples that might be able to help you out.

A: EDIT: I apologize, I somehow missed the title where you mentioned you wanted help using LINQ with Stored Procedures, my below answer does not address that at all and unfortunately I haven't had the need to use sprocs with LINQ so I'm unsure if my below answer will help.
LINQ to SQL is able hydrate multiple sets of data into a object graph while hitting the database once. However, I don't think LINQ is going to achieve what you ultimately want -- which as far as I can tell is a completely dynamic set of data that is defined outside of the query itself. Perhaps I am misunderstanding the question, maybe it would help if you provide some sample code that your existing application is using?
Here is a quick example of how I could hydrate a anonymous type with a single database call, maybe it will help:
var query = from p in db.Products
            select new
                       {
                           Product = p,
                           NumberOfOrders = p.Orders.Count(),
                           LastOrderDate = p.Orders.OrderByDescending().Take(1).Select(o => o.OrderDate),
                           Orders = p.Orders
                       };


text:
Q: Docky have stopped working since update I'm using the Docky ppa, and since the latest update it won't start. If I run it from the terminal, this is what I get:
[Info  09:21:19.005] Docky version: 2.1.0 bzr docky r1761 ppa
[Info  09:21:19.024] Kernel version: 2.6.35.24
[Info  09:21:19.026] CLR version: 2.0.50727.1433
[Debug 09:21:19.493] [UserArgs] BufferTime = 0
[Debug 09:21:19.494] [UserArgs] MaxSize = 2147483647
[Debug 09:21:19.494] [UserArgs] NetbookMode = False
[Debug 09:21:19.494] [UserArgs] NoPollCursor = False
[Debug 09:21:19.528] [SystemService] Using org.freedesktop.UPower for battery information
[Info  09:21:19.564] [ThemeService] Setting theme: Transparent
[Debug 09:21:19.587] [DesktopItemService] Loading remap file '/usr/share/docky/remaps.ini'.
[Debug 09:21:19.599] [DesktopItemService] Remapping 'Picasa3.exe' to 'picasa'.
[Debug 09:21:19.599] [DesktopItemService] Remapping 'nbexec' to 'netbeans'.
[Debug 09:21:19.599] [DesktopItemService] Remapping 'deja-dup-preferences' to 'deja-dup'.
[Debug 09:21:19.599] [DesktopItemService] Remapping 'VirtualBox' to 'virtualbox'.
[Warn  09:21:19.600] [DesktopItemService] Could not find remap file '/home/lasse/.local/share/docky/remaps.ini'!
[Debug 09:21:19.602] [DesktopItemService] Loading desktop item cache '/home/lasse/.cache/docky/docky.desktop.en_DK.utf8.cache'.
[Info  09:21:20.101] [DockServices] Dock services initialized.
[Debug 09:21:20.134] [DBusManager] DBus Registered: org.gnome.Docky
[Debug 09:21:20.142] [DBusManager] DBus Registered: net.launchpad.DockManager
Stacktrace:

  at (wrapper managed-to-native) System.IO.MonoIO.Read (intptr,byte[],int,int,System.IO.MonoIOError&) <IL 0x00012, 0x00062>
  at (wrapper managed-to-native) System.IO.MonoIO.Read (intptr,byte[],int,int,System.IO.MonoIOError&) <IL 0x00012, 0x00062>
  at System.IO.FileStream.ReadData (intptr,byte[],int,int) <IL 0x00009, 0x00047>
  at System.IO.FileStream.RefillBuffer () <IL 0x0001c, 0x0002b>
  at System.IO.FileStream.ReadByte () <IL 0x00079, 0x000c7>
  at Mono.Addins.Serialization.BinaryXmlReader.ReadNext () <IL 0x0000b, 0x00031>
  at Mono.Addins.Serialization.BinaryXmlReader.Skip () <IL 0x0003c, 0x00053>
  at Mono.Addins.Serialization.BinaryXmlReader.Skip () <IL 0x00047, 0x0005f>
  at Mono.Addins.Serialization.BinaryXmlReader.Skip () <IL 0x00047, 0x0005f>

And this .Skip () continues infinitely, and very fast.
I've tried cleaning the cache and reinstalling docky, but without luck.

A: It looks like you are experiencing bug #661495.
The fix is in the first comment:
Do this: rm -Rf ~/.local/share/docky/plugins

Then start Docky.


text:
Q: Intuition on simple linear regression signal plus noise model I'm currently studying linear regression on this book
"F.M. Dekking - A Modern Introduction to Probability and Statistics: Understanding Why and How" where the signal+noise model is presented:
$Y_i = \alpha\ + \beta x_i\ + U_i$
where $x_i$ are non-random, $U_i$ are independent r.v.s with $E[U_i] = 0$ and $Var(U_i) = \sigma^2$ and $Y_i$ are, therefore, independent r.v.s with $E[Y_i] = \alpha\ + \beta x_i$ and $Var(Y_i) = \sigma^2$
He writes that "$\{Y_1, ..., Y_n \}$ do not form a random sample because given that each $Y_i$ have different expectation, they have different distributions" and he writes also that "if we assume that $U_i$ are normally distributed we can use MLE to estimate $\alpha,\beta$".
Now, given this two facts, how could we use MLE on something that is not a sample? Maybe the correct interpretation is that $\{Y_1, ..., Y_n \}$ is i.n.i.d. sample, but, if it is the case, would it be ok to use MLE?

A: Check the related question asking about logistic regression. The quotes you posted sound confusing, but what they are saying is that $Y_1,Y_2,\dots,Y_n$ are independent, but not identically distributed, since they have different means
$$
Y_i \sim \mathcal{N}(\mu_i, \sigma^2)
$$
where $\mu_i$ is defined in terms of functional relationship $\mu_i = \alpha + \beta X_i$, what is equivalent of saying that
$$
\begin{align}
\varepsilon_i &\sim \mathcal{N}(0, \sigma^2) \\
Y_i &= \alpha + \beta X_i + \varepsilon_i
\end{align}
$$
so $Y_1,Y_2,\dots,Y_n$ are random samples, but they are not i.i.d. Since they are random variables, we can define a likelihood function for the model describing their joint distribution
$$
L(\alpha,\beta,\sigma^2 \mid Y) = \prod_{i=1}^n \mathcal{N}(y_i; \alpha + \beta x_i, \; \sigma^2)
$$
so we can estimate the parameters based on it (using MLE, or Bayesian estimation). You can also check the answers and comments in this thread for extended discussion and this thread for more formal discussion of somehow similar question.


text:
Q: How to use this get method from my groovy class in a GSP I'm following the template of this groovy class from the spring security plugin to maintain my many-to-many relationsips.
One of the methods is like this:
static UserEvent get(long userId, long eventId) {
    UserEvent.find 'from UserRole where user.id=:userId and event.id=:eventId',
            [userId: userId, eventId: eventId]
}

Note: This class doesn't have an ID property.
Question
How can I use this method from my GSP to verify whether its returning something or not?
I've tried this but it doesn't seem to work, it always gives me the same result:
<g:if test="${UserEvent.get(currentUserId as long, eventInstance.id as long) != null} ">
   you attended this event
</g:if>

This if seems to be true for both cases, when I have an entry in the UserEvent class or when I don't.

A: Do the work in the controller and pass the data to the view. The view should only be concerned with displaying data, not computing it and especially not doing database queries. This isn't PHP :)
Add the code to the controller action:
def yourAction() {
   // existing code

   UserEvent event = UserEvent.get(currentUserId as long, eventInstance.id as long)

   [foo: bar, ..., eventExists: event != null]
}

And then use it in the GSP:
<g:if test="${eventExists}">
   you attended this event
</g:if>

A: Does it work if you get rid of the null test, and just rely on groovy truth?
<g:if test="${UserEvent.get(currentUserId as long, eventInstance.id as long)}">