text:
Q: Checklist towards optimal performance in a database import application I am facing an application designed to import huge amounts of data into a Microsoft SQL Server 2000 database. The application seems to take an awful long time to complete and I suspect the application design is flawed. Someone asked me to dig into the application to find and fix serious bottlenecks, if any. I would like a structured approach to this job and have decided to prepare a checklist of potential problems to look for. I have some experience with SQL databases and have so far written down some things to look for.
But it would be very helpful with some outside inspiration as well. Can any of you point me to some good resources on checklists for good database schema design and good database application design?
I plan on developing checklists for the following main topics:

*

*Database hardware - First thing is to establish proof that the server hardware is appropriate?

*Database configuration - Next step is to ensure the database is configured for optimal performance?

*Database schema - Does the database schema have a sound design?

*Database application - does the application incorporate sound algorithms?

A: Three items I would add to the list:

*

*Bulk insert - Are you importing the data using a bulk provider (i.e. BCP or SqlBulkCopy) or via individual INSERT/UPDATE statements?

*Indexes - Do you have indexes on your target tables?  Can they be dropped prior to import and then rebuilt after?

*Locking - Is there any contention occurring while you are trying to import data?

A: Good start.  Here are the recommended priorities.
First Principle.  Import should do little or no processing other than source file reads and SQL Inserts.  Other processing must be done prior to the load.

*

*Application Design is #1.  Do the apps do as much as possible on the flat files before attempting to load?  This is the secret sauce in large data warehouse loads: prepare offline and then bulk load the rows.

*Database Schema is #2.  Do you have the right tables and the right indexes?  A load doesn't require any indexes.  Mostly you want to drop and rebuild the indexes.
A load had best not require any triggers.  All that triggered processing can be done off-line to prepare the file for a load.
A load had best not be done as a stored procedure.  You want to be using a simple utility program from Microsoft to bulk load rows.

*Configuration.  Matters, but much, much less than schema design and application design.

*Hardware.  Unless you have money to burn, you're not going far here.  If -- after everything else -- you can prove that hardware is the bottleneck, then spend money.

A: You have left out the first place I would start looking: the technique used to import the data.
If the application is inserting single rows, is there a reason for that?  Is it using DTS or BULK INSERT or BCP?  Is it loading to a staging table or a table with triggers?  Is it loading in batches or attempting to load and commit the entire batch?  Is there extensive transformation or data type conversion of rows on their way in?  Is there extensive transformation of data into a different schema or model?
I wouldn't worry about 1 and 2 until I saw if the ETL techniques used were sound, and if they are importing data into an existing schema, then you aren't going to have much room to change anything to do with 3.  With regard to import and 4, I prefer not to do much algorithms on the data during the load portion.
For the best performance in the most general cases, load to a flat staging table with good reliable basic type conversion and exceptions done at that time (using SSIS or DTS).  For very large data (multi-million row daily loads, say), I load in 100,000 or 1,000,000 record batches (this is easily settable in BCP or SSIS).  Any derived columns are either created at the time of the load (SSIS or DTS) or right after with an UPDATE.  Run exceptions, validate the data and create contraints.  Then manipulate the data into the final schema as part of one or more transactions - UPDATEs, INSERTs, DELETEs, GROUP BYs for dimensions or entities or whatever.
Obviously, there are exceptions to this and it depends a lot on the input data and the model.  For instance, with EBCDIC packed data in inputs, there's no such thing as good reliable basic type conversion in the load stage, so that causes your load to be more complex and slower as the data has to be processed more significantly.
Using this overall approach, we let SQL do what it is good for, and let client applications (or SSIS) do what they are good for.


text:
Q: two or more nested RelativeLayout  I want to ask, working with two or more nested RelativeLayout.
First code looks like picture 1, When I add android:layout_alignParentRight="true" in second RelativeLayout, this looks like picture 2. I want to align text right to second RelativeLayout. Where is my fault?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:background="@drawable/background"
        android:layout_height="wrap_content"
        android:id="@+id/testRL">
        <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:id="@+id/testRotateLL"
                android:background="@drawable/picture_border_offer_first_page">
                <TextView
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:text="7000TL"
                        android:textSize="15sp"
                        android:textColor="@android:color/white"
                        android:id="@+id/amountLayoutTV" />
        </RelativeLayout>
</RelativeLayout>

Picture 1:

And I add android:layout_alignParentRight="true"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:background="@drawable/background"
    android:layout_height="wrap_content"
    android:id="@+id/testRL">
    <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:id="@+id/testRotateLL"
            android:background="@drawable/picture_border_offer_first_page">
            <TextView
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:text="7000TL"
                    android:layout_alignParentRight="true"
                    android:textSize="15sp"
                    android:textColor="@android:color/white"
                    android:id="@+id/amountLayoutTV" />
    </RelativeLayout>
</RelativeLayout>

Picture 2:

A: This question is unanswered. when I updated ADT version, this problem solved. There was a bug, I think.
I suggest you to check version of ADT sometimes...

A: In the first RelativeLayout you have:
android:layout_width="wrap_content"
android:layout_height="wrap_content"

You probably want:
android:layout_width="fill_parent"
android:layout_height="fill_parent"

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to use javascript/css to navigate through a pure css carousel/slideshow? I've created a simple slideshow using just CSS3 animation and keyframes and I'm trying to figure out how I could create navigation arrows that allow you to flick through the slides.
I would want a next and previous button/arrow that slides to each video in the slide on click. I've been trying to do it with CSS but not having much luck, I wondered if anyone might have a solution I might have overlooked.
Any suggestions would be appreciated.
Heres a simple slider to demonstrate what I have...
http://jsfiddle.net/D5Qcw/5/
HTML

Logo Name

Menu Button

Content box

open button

Content box paragraph text

Play button

Content box 2

open button

Content box paragraph text

Play button

Content box 3

open button

Content box paragraph text

Play button

Content box 4

open button

Content box paragraph text

Play button

CSS
.wrapper {
    position: absolute;
    width: 100%;
    height: 400px;
    overflow: hidden;
    margin: 0;
    padding:0;
    z-index: 1;
}

.header {
    position: absolute;
    height: 20em;
    z-index: 2;
    width: 100%;
    display: block;
    padding-top: 2em;
}

h1 {
    font-size: 20px;
    color: blue;
    z-index: 999;
    float: left;
}

h2 {
    position: absolute;
    float: left;
}

p.menu {
    position: absolute;
    color: blue;
    z-index: 999;
    float: left;
    right: 20px;
}

p {
    position: absolute;
    padding-top: 3em;
}

ul {
    margin: 0;
    padding: 0;
}

ul li {
   list-style: none;
}

#carousel {
    width: 100%;
}

#carousel .video-list {
    position: relative;
    width: 400%;
    height: 100%;
    transform: translateX(-100%);
    -webkit-transform: translateX(-100%);
    -moz-transform: translateX(-100%);
    -o-transform: translateX(-100%);
    -ms-transform: translateX(-100%);
    animation: slider 40s ease-in-out infinite;
    -webkit-animation: slider 40s cubic-bezier(.93,.11,.32,.94) infinite;
    -moz-animation: slider 40s cubic-bezier(.93,.11,.32,.94) infinite;
    -o-animation: slider 40s cubic-bezier(.93,.11,.32,.94) infinite;
    -ms-animation: slider 40s cubic-bezier(.93,.11,.32,.94) infinite;
}

@keyframes slider {
    0% { transform: translateX(0%); }
    23% { transform: translateX(0%); }
    26% { transform: translateX(-25%); }
    51% { transform: translateX(-25%); }
    54% { transform: translateX(-50%); }
    79% { transform: translateX(-50%); }
    82% { transform: translateX(-75%); }
    97% { transform: translateX(-75%); }
    100% { transform: translateX(0%); }
}

@-webkit-keyframes slider {
    0% { -webkit-transform: translateX(0%); }
    23% { -webkit-transform: translateX(0%); }
    26% { -webkit-transform: translateX(-25%); }
    51% { -webkit-transform: translateX(-25%); }
    54% { -webkit-transform: translateX(-50%); }
    79% { -webkit-transform: translateX(-50%); }
    82% { -webkit-transform: translateX(-75%); }
    97% { -webkit-transform: translateX(-75%); }
    100% { -webkit-transform: translateX(0%); }
 }

 @-moz-keyframes slider {
    0% { -moz-transform: translateX(0%); }
    23% { -moz-transform: translateX(0%); }
    26% { -moz-transform: translateX(-25%); }
    51% { -moz-transform: translateX(-25%); }
    54% { -moz-transform: translateX(-50%); }
    79% { -moz-transform: translateX(-50%); }
    82% { -moz-transform: translateX(-75%); }
    97% { -moz-transform: translateX(-75%); }
    100% { -moz-transform: translateX(0%); }
}

#carousel .video-list li {
    position: relative;
    width: 25%;
    height: 100%;
    overflow: hidden;
    display: inline-block;
    float: left;
}

#carousel .video-list .content-wrapper {
    position: absolute;
    width: 100%;
    height: 50%;
    bottom: -130px;
    z-index: 999;
    background: rgba(255, 255, 255, 0.9);
    -webkit-transition: bottom 1s;
    -moz-transition: bottom 1s;
    -o-transition: bottom 1s;
    -ms-transition: bottom 1s;
    transition: bottom 1s;
}

.progress-bar {
    background: #000;
    height: 5px;
    width: 40px;
    position: relative;
    animation: mymove 10s infinite;
    -webkit-animation: mymove 10s infinite;
    -moz-animation: mymove 10s infinite;
    -o-animation: mymove 10s infinite;
    -ms-animation: mymove 10s infinite;
    animation-timing-function: linear;
    -webkit-animation-timing-function: linear;
    -moz-animation-timing-function: linear;
    -o-animation-timing-function: linear;
    -ms-animation-timing-function: linear;
}

@keyframes mymove {
    from {left:0;}
    to {right:-97%;}
}

@-webkit-keyframes mymove {
    from {left:0;}
    to {right:-97%;}
}

#carousel .video-wrapper {
    position: relative;
    top: 0%;
    left: 0%;
    width: 200%;
    height: 200%;
    z-index: 2;
}

#carousel .video-wrapper iframe {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-width: 50%;
    min-height: 50%;
    margin: auto;
    z-index: 2;
}

.crossRotate {
    position: absolute;
    font-size: 20px;
    right: 0;
    -webkit-transition-duration: 1s;
-moz-transition-duration: 1s;
-o-transition-duration: 1s;
-ms-transition-duration: 1s;
transition-duration: 1s;
    -webkit-transition-property: -webkit-transform;
    -moz-transition-property: -moz-transform;
    -o-transition-property: -o-transform;
    -ms-transition-property: -o-transform;
    transition-property: transform;
    z-index: 999;
 }

.crossRotate:hover {
    cursor: pointer;
 }

A: I would use Javascript for the userinteraction
here is an easy tutorial.
Hope this helps
Here is a JSFiddle that should give you the idea :)
$(function () {
    var position = 0;
    $('#next').on('click', function (e) {
        e.preventDefault();

        position = (position + 25) % 100;

        $('#carousel .video-list').css('-webkit-transform', 'translateX(-' + position + '%)');
    });
});

http://jsfiddle.net/D5Qcw/6/


text:
Q: PostgreSQL: function returns multiple recordsets: how to read in c#? Using this link
http://www.sqlines.com/postgresql/npgsql_cs_result_sets
I have created the example, but it does not work:
There is my function:
 CREATE OR REPLACE FUNCTION show_cities_multiple()
 RETURNS SETOF refcursor AS $$
    DECLARE
      ref1 refcursor;
      ref2 refcursor;
    BEGIN
      OPEN ref1 FOR SELECT user_id, user_name FROM users;
      RETURN NEXT ref1;

      OPEN ref2 FOR SELECT id, company FROM customers;
      RETURN NEXT ref2;
    END;
    $$ LANGUAGE plpgsql;

The 1st loop reads recordsets names only and that is all what I can read from the function.
         NpgsqlConnection conn = new NpgsqlConnection(GetConnectionString());
                conn.Open();
                NpgsqlTransaction tran = conn.BeginTransaction();
                NpgsqlCommand command = new NpgsqlCommand("show_cities_multiple", conn);
                command.CommandType = CommandType.StoredProcedure;
                NpgsqlDataReader dr = command.ExecuteReader();
                while (dr.Read())
                {
                   Console.Write("{0}\n", dr[0]);
                }
// ----------there is output - only names of cursors recordsets
// <unnamed portal 1>
// <unnamed portal 2>

                dr.NextResult();
// But there is nothing to read, no additional recordsets
                while (dr.Read())
                    Console.Write("{0}\t{1} \n", dr[0], dr[1]);

                tran.Commit();
                conn.Close();

What is wrong? How to read multiple recordsets from a PGSQL function?

A: There are a few ways to work with cursors for different versions
how can I get cursor data with calling stored procedure in npgsql


text:
Q: How to compare two Time objects only down to the hour I want to compare two Time objects only down to the hour, while ignoring the difference of minutes and seconds.
I'm currently using t0.strftime("%Y%m%d%H") == t1.strftime("%Y%m%d%H"), but I don't think this is a good solution.
Is there better way to do this?

A: You can use this trick in pure Ruby
t0.to_a[2..9] == t1.to_a[2..9]

Where Time#to_a
$> Time.now.to_a
# => [7, 44, 2, 8, 3, 2014, 6, 67, false, "GMT"]
# [ sec, min, hour, day, month, year, wday, yday, isdst, zone ]

So you can check that the times are equals or not up to the level you want and without missing important components of the object like the zone, etc.

A: If you have ActiveSupport (either through Rails, or just installed as a gem), it includes an extension to the Time class that adds a change method which will truncate times:
$> require "active_support/core_ext/time"
# => true
$> t = Time.now
# => 2014-03-07 21:30:01 -0500
$> t.change(hour: 0)
# => 2014-03-07 00:00:00 -0500

This won't modify the original time value either. So you can do this:
t0.change(minute: 0) == t1.change(minute: 0)

It'll zero out everything at a lower granularity (seconds, etc.).

A: require 'time'

t1 = Time.new ; sleep 30 ; t2 = Time.new
t1.hour == t2.hour

This should give you a boolean answer.


text:
Q: Apache Camel, SpringBoot application in PCF results with message failures We have developed Apache Camel, SpringBoot based application to read data from Oracle table and do some transformation of record and publish to Kafka topic. We are using Camel SQL component  for DB integration and implemented Split & parallel processing pattern to parallelize processing to achieve high throughput. Oracle tables are partitioned, so we are creating multiple routes, one route per table partition, to speed up the processing. We have 30 partitions in table and so created 30 routes.
           from(buildSelectSqlEndpoint(routeId))
                .process(new GenericEventProcessor("MessagesReceived"))
                .split(body())
                .parallelProcessing()
                .process(new GenericEventProcessor("SplitAndParallelProcessing"))
                .process(new InventoryProcessor())
                .process(new GenericEventProcessor("ConvertedToAvroFormat"))
                .to(buildKafkaProducerEndPoint(routeId));

I tested the application in local laptop with an adequate load and it is processing as expected. But when we deployed the application in PCF, we see some of the threads are failing. I have enabled the Camel debug log and i see below debug log line -

Pipeline - Message exchange has failed: so breaking out of pipeline
for exchange

Due to these thousands of messages are not published to Kafka.
From initial analysis, i figured out Camel is creating one thread for each route and based on maxMessagePerPoll configuration, it creates number of threads equal to maxMessagePerPoll.  With Split & parallel processing enabled, Camel creates additional threads equal to maxMessagePerPoll for Kafka publish. with this approach,  we will have hundreds of threads  created and not sure any issue with PCF. Also I tried number of routes with 2, to check the message delivery failures, and still see hundreds of failures and with only 2 routes, increases total processing time for millions of records.
Could you please let me know, how to use Apache Camel with containers like PCF? any additional configurations we need to have in PCF or Camel ?


text:
Q: jQuery not working on my Drupal page Here is the live page I am trying to implement on my Drupal website:
Working Page
This page works perfectly fine and uses the same versions of jQuery and jQueryUI that Drupal 7 uses.
Now when I put this content onto my Drupal site located here:
Drupal Page - Not working
jQueryUI seems to be not working. The jQuery Rotate is working fine however.
I've been searching for answers and implemented several methods, all of which have failed including the method of wrapping my jQuery in this code:
(function($) {

})(jQuery);

Any help as soon as possible would be amazing!

A: This is what you're doing (according what I see on your html code)
jQuery(document).ready(function($) {
...
})(jQuery);

That is incorrect. Try with this
(function($) {
    $(function() {
    ...
    });
})(jQuery);

Check this popular question in order to get more details about the correct syntax.

A: The solution was pretty obscure. My code called for jquery 1.7 so that's what I had loaded up. On a hunch, I changed it back to Drupal's default jQuery 1.5 and it worked.


text:
Q: Linq group by and select most occuring item in sub group I have been struggling to write a linq query in c# for this scenario below, I have got a list with the structure
PostCode, Premise, Connectivity, Availability
XYZ 123,    1,       HIGH,         TRUE
XYZ 123,    2,       LOW,          TRUE
XYZ 123,    3,       LOW,          FALSE
ABC 234,    1,       HIGH,         FALSE
ABC 123,    2,       HIGH,         FALSE

I am trying to generate the below which I have done in SQL using ROW_NUMBER and partition but it's a challenge for me to achieve in c#. Any help is highly appreciated.
PostCode,  Connectivity, Availability
XYZ 123,         LOW,          TRUE
ABC 234,         HIGH,         FALSE

A: It this what you are looking for :
class Program
{
    static void Main(string[] args)
    {
        List<PostCode> postCodes = new List<PostCode>() {
            new PostCode() {postcode = "XYZ 123", premise = 1, connectivity = "HIGH", availability = "TRUE"},
                new PostCode() {postcode = "XYZ 123", premise = 2, connectivity = "LOW", availability = "TRUE"},
                new PostCode() {postcode = "XYZ 123", premise = 3, connectivity = "LOW", availability = "FALSE"},
                new PostCode() {postcode = "ABC 234", premise = 1, connectivity = "HIGH", availability = "FALSE"},
                new PostCode() {postcode = "ABC 123", premise = 2, connectivity = "HIGH", availability = "FALSE"}
            };

            var results = postCodes.GroupBy(x => x.postcode)
                .Select(x => x.GroupBy(y => y.premise).Select(z => new { item = z, count = z.Count() }).ToList())
                .ToList();
        }
    }
    public class PostCode
    {
        public string postcode {get; set;}
        public int premise { get; set; }
        public string connectivity { get; set; }
        public string availability { get; set; }

    }


text:
Q: Difference between property initializer and init() function Basically I want to create two properties where one is dependent on the other. I find that if I try to initialize the dependent property in this manner, it doesn't work.
class Bus {
    private let driverList = ["A", "B", "C"]
    private var driver: String = driverList.randomElement()!
    @Published private var bus: String = createBus(driver: driver)

    static func createBus(driver: String) -> String {
        return "Bus with driver \(driver)"
    }
}

I get "Cannot use instance member 'driver' within property initializer; property initializers run before 'self' is available" error message. What I understand is that self is still not available since all of the class members haven't been initialzed yet. However, when I put it inside init() like it, it works.
class Bus {
    private let driverList = ["A", "B", "C"]
    private var driver: String = driverList.randomElement()!
    @Published private var bus: String

    init() {
        self.bus = Bus.createBus(driver: driver)
    }

    static func createBus(driver: String) -> String {
        return "Bus with driver \(driver)"
    }
}

As a result, I wonder if init() behaves similarly to lazy or it is called directly after self is available which is confusing since all of the members still haven't been initialized so how come init() has access to self.
Edit: I moved the array inside the class and I actually have @Published for bus property because I want to monitor the changes and update in the view. I find that having @Published makes things more complicated. My apology for not including in the first place since I thought it was irrelevant.

A: According to the Swift documentation, the init() function prepares a class for use / creates a new instance of it.
In the sense, the class doesn't exist until init() is called, meaning you cannot access the variable driver until you initialize the class. Since init() initializes the class, it creates the self you can use.


text:
Q: Iterate over unknown repeated protobuf field with FieldDescriptor I am trying to write a generalized method to iterate through a protobuf message and basically create an object tree.
So far I have
IMessage message = new Message() as IMessage;
foreach (FieldDescriptor field in message.Descriptor.Fields.InFieldNumberOrder())
            {
                if (field.FieldType == Google.Protobuf.Reflection.FieldType.Message)
                {
                    if (field.IsRepeated)
                    {
                        // How to do this?
                    }
                    else
                    {
                        Children.Add(new MessageNode(field, (IMessage)field.Accessor.GetValue(message)));
                    }
                }
                else
                {
                    Children.Add(new FieldNode(field, message));
                }
           }

Works fine except for repeated fields (and probably the same problem will crop up for Map fields).
If I do field.Accessor.GetValue(message) for the repeated field, I get an object[RepeatedField<T>] with T being some nested message. However, I cannot iterate over something of type object.
I tried casting object to RepeatedField<IMessage> but this just returns 0.
Is there any way to iterate over a repeated field without knowing the type inside? I would just need an IMessage pointer to the objects inside, from there I can work with the Descriptor in IMessage.

A: As you noted in your answer, as per the protobuf documentation field.Accessor.GetValue(protobufMessage) will return you an IList for repeated fields and an IDictionary for map fields.
Here is some code I wrote that iterates recursively through a protobuf message using the field descriptors. It may be a useful starting point for doing other operations instead of printing.
    public static void PrintProtobufMessage(IMessage protobufMessage)
    {
        if (protobufMessage == null)
        {
            return;
        }
        foreach (var field in protobufMessage.Descriptor.Fields.InFieldNumberOrder())
        {
            if (field.IsMap)
            {
                // for map fields, the field type is always a MapField, inside of which are contained a keyField and valueField
                //var keyField = field.MessageType.Fields.InFieldNumberOrder()[0];
                var valueField = field.MessageType.Fields.InFieldNumberOrder()[1];
                IDictionary mapFields = field.Accessor.GetValue(protobufMessage) as IDictionary;
                if (mapFields != null)
                {
                    foreach (DictionaryEntry mapField in mapFields)
                    {
                        Console.WriteLine("Iterating Map, Field {0} ({1}): Key {2}:", field.FieldNumber, field.Name, mapField.Key);
                        if (valueField.FieldType == Google.Protobuf.Reflection.FieldType.Message)
                        {
                            PrintProtobufMessage(mapField.Value as IMessage);
                        }
                        else
                        {
                            PrintProtobufField(valueField, mapField.Value);
                        }
                    }
                }
            }
            else if (field.IsRepeated)
            {
                IList repeatedFieldValues = field.Accessor.GetValue(protobufMessage) as IList;
                if (repeatedFieldValues != null)
                {
                    foreach (var repeatedFieldValue in repeatedFieldValues)
                    {
                        // for repeated fields, the field type represents each element in the list, handle them accordingly
                        if (field.FieldType == Google.Protobuf.Reflection.FieldType.Message)
                        {
                            PrintProtobufMessage(repeatedFieldValue as IMessage);
                        }
                        else
                        {
                            PrintProtobufField(field, repeatedFieldValue);
                        }
                    }
                }
            }
            else
            {
                if (field.FieldType == Google.Protobuf.Reflection.FieldType.Message)
                {
                    var fieldValue = field.Accessor.GetValue(protobufMessage);
                    PrintProtobufMessage(fieldValue as IMessage);
                }
                else
                {
                    PrintProtobufField(field, protobufMessage);
                }
            }
        }
    }

    public static void PrintProtobufField(FieldDescriptor field, IMessage protobufMessage)
    {
        var fieldValue = field.Accessor.GetValue(protobufMessage);
        PrintProtobufField(field, fieldValue);
    }

    public static void PrintProtobufField(FieldDescriptor field, object fieldValue)
    {
        if (fieldValue != null)
        {
            Console.WriteLine(
                "Field {0} ({1}): {2}",
                field.FieldNumber,
                field.Name,
                fieldValue
            );
        }
    }

A: I don't know how blind I have been in the last two days trying to solve this...
Right in the documentation for GetValue of the Accessor it says

For repeated values, this will be an IList implementation. For map values, this will be an IDictionary implementation.

So yeah, IList d = field.Accessor.GetValue(message) as IList; does the trick and provides an iterable collection of the repeated field.


text:
Q: Truncated table names in diagrams on Ubuntu My SchemaCrawler (version 15.01.03) schema diagrams are truncating table names on Ubuntu 18.04 LTS. It looks like the tables are drawn too narrow in general because the "[TABLE]" notation also bleeds out of the box. The same looks fine when rendered on my Mac.
Is there a way to fix this?
---update---
I've tried changing the font in _schemacrawler/config/schemacrawler.config.properties. It's set to Helvetica by default, but Ubuntu doesn't have Helvetica so I changed it to Mukti Narrow...
schemacrawler.graph.graphviz.node.fontname=Mukti Narrow

This causes less of the text to be truncated but doesn't fix it completely. Comparing with different fonts makes me think the width calculation is done the same regardless of font.
The properties file lists these two URLs for graphviz settings...
https://www.graphviz.org/doc/info/attrs.html
https://www.graphviz.org/doc/info/command.html
I've tried a number of the settings listed there but so far haven't found one that changes the font width calculation.
I've also installed Helvetica but get the same results.

A: Actually I had the same problem - table names were cut (kind of overflow). I had been using the pure Java Graphviz library as stated https://www.schemacrawler.com/diagramming.html . Once I installed complete Graphviz, all table names fit in diagram as expected.
Solution: Dont use only pure Java Graphviz library.

A: Boz,
I am sorry, but SchemaCrawler does not directly control the graph output - this is delegated to Graphviz. You are on the right track by investigating Graphviz options. One thing you could try is to use is SchemaCrawler's "pure Java" Graphviz integration. Download the main distribution, and go through the instructions on how to download "pure Java" Graphviz. Please see if that makes a difference.
Sualeh Fatehi, SchemaCrawler

A: Solved...
I hadn't installed graphviz. Thought I had but nope. So...
sudo apt install graphviz

fixed it.
Thanks for the reply Sualeh. I'm not sure how the graphs were being generated without graphviz installed. Looking at the code I see a place where it attempts to use graphviz and then tries Java if graphviz isn't available. I didn't run it in a debugger or anything, but it seems like it ended up using Java. In retrospect, it might have helped if schemacrawler printed a caution or warning that graphviz was missing. But really I look at this as my own mistake. ... Liked reading your code, by the way. #thumbsup


text:
Q: AC current in a coil. Why is this statement true? I can't understand the following statement:

*

*"A contactor coil with a small control voltage, e.g. 24V AC, consumes
a higher coil current than a similar contactor coil for 230V AC."

Does this phenomenon have something to do with the fact that the self-induced voltage creates a current and that current generates a magnetic counter-flux which weakens the magnetic field in the input? Hence, I think that with the 230V, the counter-current will be higher and so the current in the circuit will be lower. Is this true?
Your answers will be greately appreciated.

A: A 230 V AC coil will have many more turns and therefore much more inductance than a 24 volt AC coil. Given that it is ampere_turns that generates the magnetic field inside a contactor, for the same pulling force on both, the current in the 230 V coil will be proportionately smaller due to it having many more turns.

Does this phenomenon have something to do with.....

No. It's all about making sure that the magnetic core inside the contactor does not saturate. The higher voltage coil has to have more turns in order to make inductance higher. Inductance is proportional to turns squared hence, doubling the number of turns means 4 times the inductance and one quarter of the current for the same applied AC voltage.
This in turn means that to get the same ampere_turns, the applied voltage will double for a coil with twice the turns. So, the turns have doubled and the current is half i.e. same ampere_turns.
All things being equal a 230 V coil will have approximately 9.6 x the number of turns of a 24 V coil.

A: Generally the power taken by the coil of any given contactor is constant, regardless of whether it's wound for a low or high voltage.
Consider the coil has two windings, that can be connected in series or parallel. In series, they take twice the voltage of the parallel connection. In parallel, they take twice the current of the series connection. In both cases, you have the same pair of coils running under the same conditions, so the same magnetic force, and the same power being dissipated.
For comparing 24 V and 240 V, imagine 10 windings in series or parallel.


text:
Q: Syllogism and Logic I have been presented with this syllogism:
All labradors are four legged (1)
All dogs are labradors (2)
Therefore, some dogs are four legged (3)

I responded valid, my reasoning as follows:
L = Labrador
F = Four Legged
D = Dog

∀x L(x) ->F(x) -- 1
∀x D(x) -> L(x) --2

The hypothesis:
∃x D(x) ∧ F(x)

I think I am allowed to begin my assumption by saying that if x is a dog, then by combining rules 1 and 2 then x is also four legged:
∀x (D(x) -> L(x) ∧ L(x) -> F(x)) -> ∀x ( D(x) -> F(x) ) -- 1+2

But - isn't the "is valid for all" statement trivially imply "is valid for some"?
Let me explain. If we have a generic predicate P, wouldn't it make sense that:
(a) ∀x P(x) |= ∃x P(x)

If that wasn't the case, then we'd have:
(b) ∀x P(x) |= ¬∃x P(x)

(Quite simply, because there either is or isn't an x that makes a given predicate valid, saying (c) ¬∃x P(x) ∧ ∃x P(x) would be a contradiction! )
Well, b must be false, as it translates to "P(x) being valid for all x entails that there is no x for which P(x) is valid" which is a contradiction. So by c we must accept a which allows me to (trivially) say that if all dogs are four legged, then some dogs are four legged.
..Any thoughts?

A: Assuming a non-empty domain, it is indeed the case that $\forall x P(x) \models \exists x P(x)$. However, from that you can't conclude that $\forall x (P(x) \to Q(x)) \models \exists x (P(x) \wedge Q(x)$! In particular, if you have a model in which $\forall x \neg P(x)$, then $\forall x (P(x) \to Q(x))$ will be true (since nothing satisfies the antecedent), but $\exists x (P(x) \wedge Q(x))$ is false (since there's no $x$ which satisfies $P(x)$), e.g., take the domain to be $\{0\}$ and $P = \varnothing$.
So the syllogism isn't valid, as it could be the case that nothing is a dog, which would make the premises true, but the conclusion false.


text:
Q: Declare object inside the environment.ts file Any clue to declare object inside the environment.ts file? I have tried as shown below. But it doesn't detect the HotelEnvironment interface?
export const environment = {
  production: false,

  /*hotelEnvironment:HotelEnvironment={
     apiUrl: "",
     titanUrl: "",
     hotelName: ""
  }*/

   hotelEnvironment:HotelEnvironment={
     apiUrl: "",
     titanUrl: "",
     hotelName: ""
  }
};

export interface HotelEnvironment {
    apiUrl: string;
    titanUrl: string;
    hotelName: string;
}

'HotelEnvironment' only refers to a type, but is being used as a value
  here.ts(2693)

Update:
I need to declare 2 or more hotel environments. i.e. I will have many hotels. But 1 hotel will appear once on the environment file. When we deploy the app, dev needs to comment out other hotels and enable only 1. My idea here was to minimize the errors dev will do when commented out the code. i.e. If I have 3 lines of code instead of a single object then dev may be commented out 2 lines and other will be missing and stay as uncommented. That will lead to unexpected behavior of the app.

A: Your export const environment declares an simple json object.
Inside an object assignment, you cannot declare attribute type with : but just a value.
You could try with the following snippet but not sure it will work
export const environment: {production: boolean, hotelEnvironment: HotelEnvironment} = {
  production: false,
  hotelEnvironment:{
     apiUrl: "",
     titanUrl: "",
     hotelName: ""
  }
};

export interface HotelEnvironment {
    apiUrl: string;
    titanUrl: string;
    hotelName: string;
}


text:
Q: Phonegap jQuery.ajax requests works on AVD but fails on real device I have this annoying problem on my app PhoneGap that the request below works fine on my web browser and my AVD, but fails on device, I keep getting readyState 0, can anyone help?
var appCredentials = "client_id=MY_CLIENT_ID&client_secret=MY_CLIENT_SECRET";

function loadVenues(){

    var url = "https://api.foursquare.com/v2/venues/search?";
    var ll = "&ll=-23.6057,-46.6662&limit=4";
    var request = url+appCredentials+ll;

    $.ajax({
        dataType: "json",
        url: request,
        success: loadVenuesSuccess,
        error: error
        });

}

function error(param1, param2, param3){
    alert(JSON.stringify(param1));
        alert(param2);
            alert(param3);
}

Please note that it works on both browser and AVD.

A: Had the same issue, in my case the problem was my url contained htaccess information like (http://username:mypassword@www.domain.com/.....)
took me hours to find that bug in phonegap (works on every others plattform, also the avd etc, only on the real device not.)
Not sure that is your problem, but it might give you a hint were to investigate further...


text:
Q: Doubt in the proof of Implicit function theorem by Rudin's PMA,(Theorem 9.28,p224-227) I have some doubts when I goes through the proof of  Rudin's Implicit function theorem
(Theorem 9.28,p224-227 in Rudin's Principles of mathematical Analysis, 3ed).
Notation:If $\textbf{x}=(x_1,x_2,..,x_n)\in \mathbb{R}^n$ and $\textbf{y}=(y_1,y_2,...y_m)\in \mathbb{R^m}$.Then $(\textbf{x},\textbf{y})$ repesent the vector $(x_1,x_2,..,x_n,y_1,y_2,...y_m)\in \mathbb{R}^{n+m}$

*

*Let $\textbf{f}$  be a $C'-$ mapping of an open set $E\subset \mathbb{R}^{n+m}$ to $\mathbb{R}^n$.  Let $\textbf{F}(\textbf{x}, \textbf{y})=(\textbf{f}((\textbf{x}, \textbf{y}) , \textbf{y}) ,\space ;(\textbf{x}, \textbf{y})\in E $ . Then how can we prove that $\textbf{F}$ is a $C'-$ mapping of $E$ into $\mathbb{R}^{n+m}$?

*If $A(\textbf{h}, \textbf{k})$ is a linear transformation from $\mathbb{R}^{n+m}$ to $\mathbb{R}^n$ , then how can we prove that $(\textbf{h} , \textbf{k} ) \to  (A(\textbf{h}, \textbf{k}) ,\textbf{k}  )$ is a linear transformation  form $\mathbb{R}^{n+m}$ to $\mathbb{R}^{n+m}$?

*Suppose $V$ is an open set in $\mathbb{R}^{n+m}$ with   $(\textbf{0}, \textbf{b})\in V$. Let $W$ be the set of all $\textbf{y}\in \mathbb{R}^m $ such that $(\textbf{0},\textbf{y})\in V$ . Then how can we prove that $W$ is open ?

*If $\textbf{G} \in C'$ and $(\textbf{g(y),y)}=\textbf{G(0,y)}$ then how can we prove that $\textbf{g}\in C'$

*If $\Phi(\textbf{y})=(\textbf{g(y),y)}$ then how can we prove that $\Phi'(\textbf{y})\textbf{k}=(\textbf{g}'(\textbf{y)k,k})$
Sometimes it may be trivial for you, but I am not getting this.So Please help me to understand

A: *

*If $f:X \to Y$, $g:X \to Z$ are differentiable mappings, then the map $F: X \to Y\times Z$ given by $F(x) = (f(x),g(x))$ is differentiable and
$DF(x) = (Df(x), Dg(x))$. In the above case, $g(x) = x$, the identity map.

*Let $H$ be the map $H((h,k)) = (A(h,k), k)$, then it is trivial to check that
$H(\lambda(h,k)) = H((\lambda h, \lambda k)) = (A(\lambda h, \lambda k), \lambda k) = \lambda (A(h,k),k) = \lambda H((h,k))$ and it is similarly trivial to
verify that $H ((h_1,k_1)+(h_2,k_2)) = H((h_1,k_1))+H((h_2,k_2))$.

*Let $L$ be the continuous (in fact linear) map $L(y) = (0,y)$. Since $L$ is
continuous, we have that $W=L^{-1}(V)$ is open.

*Let $T$ be the linear map $T((x,y)) = x$ and $S$ be the linear map
$S((x,y)) = (0,y)$. Then $g = T \circ G \circ S$, and since $T,G,S$ are
differentiable it follows that $G$ is.

*This follows from 1. which shows that $\Phi' = (g',I)$.


text:
Q: Display txt file on Java panel Hello I want to display my txt file but probably something is wrong! Any help? Here is my code:
    public class Display  extends Items{

 public int countLines(String filename){
        int lines = 0; //mporei na metrhsei mexri "int" grammes (~2.1 dis grammes)
        try {
            // Open the file that is the first command line parameter
            FileInputStream fstream = new FileInputStream(filename);
            // Get the object of DataInputStream
            DataInputStream in = new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            String strLine;
            //Read File Line By Line
            while ((strLine = br.readLine()) != null) {
                lines++;//metrhths grammwn/eggrafwn
            }
            //close input stream
        } catch (Exception e) {//Catch exception if any
            System.err.println("Error: " + e.getMessage());
        }

    return lines;}

 public String[] showAllRegisteredLessons(String filename, int size) {

        String[] temp = new String[size+1]; //mexri "size" kataxwrhseis ma8hmatwn dld (mege8os "int")

        try {
            int x = 0;
            // Open the file that is the first command line parameter
            FileInputStream fstream = new FileInputStream(filename);
            // Get the object of DataInputStream
            DataInputStream in = new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            String strLine;
            //Read File Line By Line

            while ((strLine = br.readLine()) != null) {
                //System.out.println(strLine.replace("#", " "));
                temp[x] = strLine;
                x++;
            }
            //close input stream
        } catch (Exception e) {//Catch exception if any
            System.err.println("Error: " + e.getMessage());
        }
        return temp;
    }

    public JPanel pinakas(String[] pinaka) {
        int sr = 0;
        //int ari8mos  =0;

        String[] COLUMN_NAMES = {"Κωδικός", "Ποσότητα", "Τιμή", "Περιγραφή", "Μέγεθος", "Ράτσα"};
//pio panw mporoume na pros8esoume ws prwto column to "#", wste na deixnei ton ari8mo ths ka8e kataxwrhshs
        DefaultTableModel modelM = new DefaultTableModel(COLUMN_NAMES, 0);
        JTable tableM = new JTable(modelM);
        JPanel mainPanel = new JPanel(new BorderLayout());
        mainPanel.add(new JScrollPane(tableM), BorderLayout.CENTER);

        Display disp = new Display();
        while (pinaka[sr] != null) // !!!!tha ektupwsei kai mia parapanw "/n" logo ths kataxwrhshs prwtou h teleytaiou mahmatos
        {
            String[] temp5 = disp.lineDelimiter(pinaka[sr],6, "#");
            Object[] doge = { temp5[0], temp5[1], temp5[2], temp5[3], temp5[4], temp5[5],temp5[6]};//edw mporoume sthn arxh na valoume to ari8mos gia na fainetai o ari8mos twn kataxwrhsewn
            modelM.addRow(doge);
            sr++;
            //ari8mos++;
        }

        return mainPanel;
    }

and in main()
 if(category31=="ΣΚΥΛΟΙ"){
                    Display disp= new Display();

                    int numberofline=disp.countLines("Dogss.txt");
                    String[] tempΜ1 = disp.showAllRegisteredLessons("Dogss.txt",numberofline);
                    //System.out.println(numberofline);

                    JOptionPane.showMessageDialog(null, disp.pinakas(tempΜ1), "Καταχωρημένα Kατοικίδια", JOptionPane.PLAIN_MESSAGE);

                     break;
                    }

I get this error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6
        at program.Display.pinakas(Display.java:83)
        at program.Main.main(Main.java:334)

A: I bet the problem is in the following lines (which is probably line 83..):
 String[] temp5 = disp.lineDelimiter(pinaka[sr],6, "#");
 Object[] doge = { temp5[0], temp5[1], temp5[2], temp5[3], temp5[4], temp5[5],temp5[6]};

The array has only 6 elements. But you are accessing the 7th element with:
temp5[6]

That's why you get the ArrayIndexOutOfBoundsException.


text:
Q: Do I need to free elements of a list? Hello I have a list of type TList. I fill it with pointer to records which are created with new.
One of my coworkers told me that freeing the list will free all elements, but I have my doubts because I'm use to C. So does Delphi 7 have some sort of garbage collection and I really don't have to free each element? Can someone explain to me how that works?

A: TList holds pointers, but it does not own the things they point at. It cannot, because it has no idea how you allocated them, so it cannot know how to release them, either. You need to destroy those items yourself, if they're supposed to be destroyed.
Your colleague might be thinking of TObjectList, which can optionally own the items in the list.


text:
Q: How do I prevent a dropdown menu to move/affect content/elements of a web page? I have searched both here and elsewhere on the internet for an answer, but have not found anything that has solved my problem. I also tried to include relevant code only, but I am sorry if I included something irrelevant.
I have made a navigation bar with 4 alternatives (or 4 buttons, if you prefer), where the fourth one is a dropdown menu with 3 additional alternatives that are visible while hovering over the fourth button. I have also added an image to the web page, but the problem I am having is that, while hovering the fourth alternative and thus displaying the dropdown menu, the image moves.
I would like to make it so that the picture, and any additional content for that matter, stays at the same place while the cursor is hovering over the fourth alternative.
HTML:

 Navbutton 1
 Navbutton 2
 Navbutton 3
 Navbutton 4

 Link 1
 Link 2
 Link 3

CSS:
#logoquotebar {
background-color:white;
width:1200px;
height:200px;
}

#logopic {
position:fixed;
margin-top:-160px;
}

.navbutton4 {
display:block;
width:236px;
height:35px;

background-color:#8B6969;
text-align:center;
line-height:33px;
font-family:Verdana;

-webkit-transition-duration:0.4s;
transition-duration:0.4s;

margin-left:964px;
margin-top:-35px;
}

.dropdowncontent {
display:none;
width:236px;
height:105px;

background-color:white;
text-align:center;
line-height:33px;
font-family:Verdana;

margin-left:964px;

-webkit-transition-duration:0.2s;
transition-duration:0.2s;

}

#link1 {
display:block;
width:236px;
height:35px;
}

#link2 {
display:block;
width:236px;
height:35px;
}

#link3 {
display:block;
width:236px;
height:35px;
}

.navbutton4:hover + .dropdowncontent {
display:block;
}

.dropdowncontent:hover {
display:block;
}

A:  .dropdowncontent {
   position: absolute;
   z-index:100;
 }

Try this

A:  .dropdowncontent {
   position: fixed;
 }

That should work


text:
Q: How to get anonymous list of live streams by game I run the LiveStreamBrowser family of Chrome extensions, which display listings of currently live streams for popular games. I'd like to include YouTube Gaming as a provider, but I can't find a way in the API to do so.
liveBroadcasts/list and liveStreams/list both seem like they'd have the information I need, but neither seems to be returning anything when I use the test on the API page. liveStreams/list also complains about a missing filter parameter, when there's not one documented.
Further, I need an API that is callable directly from JavaScript. For example, Twitch's /streams API, which is called with a 'game' parameter and an API key.
Am I just missing something in the API documentation?

A: I don't think there is an API exposed for gaming live streams specifically.  You can use the Search/list endpoint of the regular YouTube v3 API and filter the results return live content.  From there, you could break down the results even more, searching by the game title.
part -> snippet
eventType -> live
type -> video (required when setting eventType to live)
HTTP GET https://www.googleapis.com/youtube/v3/search?part=snippet&eventType=live&type=video&key={YOUR_API_KEY}


text:
Q: android cannot find corresponding jni function I've followed here and I've added the .so files to my android project. Loaded the library and the project runs.
Now I want to use a function of the library. I tried like this in my MainActivity:
public final static native int crypto_aead_chacha20poly1305_encrypt(byte[] jarg1, int[] jarg2, byte[] jarg3, int jarg4, byte[] jarg5, int jarg6, byte[] jarg7, byte[] jarg8, byte[] jarg9);

Android gives me that he cannot find the corresponding JNI function.
The so files are in jniLibs in the right architecture map.
Has this something to do with my packagename that he tries to find it in my package instead of in the so library?
When I run this I get:
java.lang.UnsatisfiedLinkError: No implementation found for int be.example.libtest.MainActivity.crypto_aead_chacha20poly1305_encrypt(byte[], int[], byte[], int, byte[], int, byte[], byte[], byte[]) (tried Java_be_example_libtest_MainActivity_crypto_1aead_1chacha20poly1305_1encrypt and Java_be_example_libtest_MainActivity_crypto_1aead_1chacha20poly1305_1encrypt___3B_3I_3BI_3BI_3B_3B_3B)

A: I see that Robosodium uses Swig to generate wrapper. In this case there should be also some automatically generated Java files in src/main/java/org/abstractj/kalium that need to be added to your project as well. All native calls should be made using methods provided in that classes.

A: Create folders with names of "armeabi" and "armeabi-v7a" in libs folder of your project and place your ".so" file into that both folders and clean the project and run it.


text:
Q: Tab menu not working with AJAX Got a tab menu from http://www.menucool.com/tabbed-content, This works fine on load of the webpage.
My issue is when I click on a button, AJAX is done and content will be loaded (with this tab menu content), but the its not working as normal.
Here are my screen shots with on page onload and AJAX load,
Normal Page load

Works fine
AJAX load

Not working
May be the js file will be loaded only for page load.
How can can make it work for AJAX
My AJAX,
$.ajax({
        type: 'GET',
        url: destinationUrl,
        data: content, // my parameters
        dataType: "text",
        success: function(data) { // data is tab menu content
        $('#successDiv').html(data); // data is populated in successDiv
        }
    });

There are no errors in console. But tabbing is not working with ajax as working in page load

A: According to the example in: http://www.menucool.com/tabbed-content

Features

How to Use

Source Code

        content 1

        content 2

        content 3

you could do this:
$(document).ready(function(){

    $("ul.tabs li a").click(function(){

        var menuId = $(this).prop('href');
        var el = $(menuId);
        menuId = id.substring(1);

        var request = $.ajax({
          url: "script.php",
          type: "POST",
          data: {id : menuId},
          dataType: "html"
        });

        request.done(function(msg) {
          el.html( msg );
        });

        request.fail(function(jqXHR, textStatus) {
          alert( "Request failed: " + textStatus );
        });

    })

})


text:
Q: Add keyframe to middle of video without reencoding entire video I need to add I-frames to the middle of mp4s at ad breaks so I can segment to HLS and have I-frames when the video cues back in. I know how to do this while reencoding the entire video and forcing key frames at particular spots, but I'd much rather cut out the spot (maybe 1 second of video) where the keyframe is needed, add the keyframe, then stitch the video back together. This should greatly reduce encoding time since I can mostly copy codecs except for the one second of video where the I-frame is being added.
The only problem is that the video profile and settings change where I'm adding the I-frame and I don't get a clean stitch when putting it all back together. I understand I can do a reencode with the concat, but I'm trying to avoid that processing time.
Some simple examples of what I'm trying to do with ffmpeg:
ffmpeg -i input.mp4 -ss 30 -t 1 -c:a copy -y -copyts clipped2.mp4

ffmpeg -i input.mp4 -t 30 -c copy -y -copyts clipped1.mp4

ffmpeg -i "concat:clipped1.mp4|clipped2.mp4" -c copy -y newOutput.mp4

I might have to use ffprobe and specify bitrate, profile, and other settings for the 1 second clip so that it doesn't default to some random stuff, but I still can't get this to work right.
Has anybody accomplished this? This is specifically being done for server side ad insertion.

A: I am copying this answer:
You can use ffmpeg to insert keyframes where you want them using the -force_key_frames option.
eg:
./ffmpeg -i input.mp4 -c:a copy -c:v copy -force_key_frames 0:05:00,0:10:00 out.mp4

will put a keyframe as close to the 5 and 10s mark as it can. The time values can be in hh:mm:ss format, or just seconds (single values, no colons).
You can check if there are frames inserted where you want them using:
./ffprobe -select_streams v:0 -skip_frame nokey -show_entries frame=pkt_pts_time out.mp4


text:
Q: Out of memory error when use Volley ImageLoader in a list view with infinite scroller I am using a ListView to show a list of books using Google API. I have maximum 40 books shown with book cover loaded using Volley ImageLoader. It was working fine.
Then today I decided to add an infinite scroller to my list view which loads 40 next books every time I scroll to the bottom. The issue is, I am getting out of memory error after around 80 books are loaded.
If I just comment out the ImageLoader part, I can scroll down to thousands without an issue.
So I am not sure what is causing the memory error issue, and how to solve that. Any help will be highly appreciated.
FYI, I am using Singletone to load imageLoader
ImageLoader method (inside ListView adapter)
private ImageLoader imageLoader = new ImageLoader(mRequestQueue, new ImageLoader.ImageCache() {
    private LruCache<String, Bitmap> cache = new LruCache<>((int)Runtime.getRuntime().maxMemory()/1024/8);
    @Override
    public Bitmap getBitmap(String url) {
        return cache.get(url);
    }

    @Override
    public void putBitmap(String url, Bitmap bitmap) {
        cache.put(url, bitmap);
    }

});
imageLoader.get(urlThumb, new ImageLoader.ImageListener() {
    @Override
    public void onResponse(ImageLoader.ImageContainer response, boolean b) {
        holder.thumb.setImageBitmap(response.getBitmap());
    }
});

Infinite Scroller
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    if(!_loading && (totalItemCount - firstVisibleItem - visibleItemCount) < 5){
        _loading = true;
        // LOAD NEXT 40
    }
}

A: Maybe your images are to big when you downloaded them. A single image with 800 x 600 pixels will be less than 100kb when it comes as JPG as it is compressed. However, when you decode it into an bitmap it will become approx. 2MB of data. When you load 80 books, you will get 160MB of data very soon. Mabye you should load less books (20) or reduce the size of your images from the server.
Usually, logcat prints an Exception which will show you what causes the OutOfMemoryException. When I got this exception it was always caused by too big or too many pictures at a time.


text:
Q: java spring mysql 1000 tranactions per second interferes each other I have the following logic:
1. Check if A in DB
2. If not, insert A.

This method has @Transactional annotation, and it works. But, when I have 1k requests per second, with the same A, the second request can't see A, and only Nth request starts to see A. How to make them see A right starting from the second request? Performance is very important. Requests are coming in many different threads. How to make them see the change of the first insert A in all further requests?


text:
Q: Access permission in adb as root : can't access database So I made a basic android application that inserts data in SQLite Database using Async, and I would like to view this database and the tables it contains.
The android monitor doesn't allow me to oppen the data file, so I tried to use the command line using :
C:\users\user\AppData\Local\Android\sdk\platform-tools>adb root

Then I get this message :adb unable to connect for root : protocol fault (couldn't read status): connection reset by peer
And I tried also without connecting as root using just :
adb -s <device code> shell
shell@m0:/ $ /data/data/com.example.user.myapplication/databases/mydb.db

But it gives me this message :
can't execute : permission denied

I tried to run this command :
C:\Users\user\AppData\Local\Android\sdk\platform-tools>adb shell

when it opened the shell I used the Super User command :
shell@m0 :/ $ su

And it successfully connected as root:
root@m0:/ #

In spite of that I still get the permission denied message when I want to access the database. I'm out of options.
I should point out the fact that my android device is rooted.

A: you can:
1) get the DB with the command: adb pull /data/data/com.example.user.myapplication/databases/mydb.db
2) launch <android sdk path>\platform-tools\sqlite3 mydb.db  and use SQL commands within (eg. SELECT * FROM table1)

A: I just found out how to overcome the permission denied problem and get access to database.
Actually the problem with what I've been doing is that I was trying to get access to file that had a permission of only execution and not read and/or write. You can see the type of permission either by Android Device Monitor or by typing this command in the adb shell :ls -l
So what you need to do is to change the permission type from execute only to read/write/execute, which is done by this command : chmod 777 /data
Actually you need to chmod 777 every directory from /data until /data/data//databases/dbname.db so that you can access the db and pull it into a directory in your computer.
See the full documentation in this article : http://www.codeproject.com/Articles/825304/Accessing-internal-data-on-Android-device
I hope this helps you.
Don't forget that I was connected to the adb shell as root (by rooting my android device and executing the adb shell in Super User mode).


text:
Q: Apex domain will not verify on AWS SES I am new to setting up domains and actually had to get some help from AWS themselves to get it setup but it currently is running.  Here is my setup and what I am trying to do:
I have a www.alkouri.com domain

*

*I have a hosted zone for "www.alkouri.com" in Route 53 and GoDaddy

a. The nameservers that Route 53 provided me are put into goDaddy DNS settings in hosted zones
b. The A Record is pointing to a cloudFront distribution (this is so that I can get the HTTPS running)

*The cloudFront distribution is pointing to an S3 bucket so that I can host a static website.

All of this is running fine, I am able to get to all variations of alkouri.com and it points to HTTPS no problem.
Now I want to be able to set up email going into a separate S3 bucket and this is where I am running into issues.
So in SES console I verify a new domain for www.alkouri.com and point in to the new S3 bucket and I try to send emails to blah@alkouri.com but nothing comes up.
I then try blah@www.alkouri.com and it works.  Well obviously I don't want an email address with "www." in it so I create another hosted zone with just "alkouri.com."  This generates 4 new AWS nameservers.  I add these 4 nameservers to goDaddy and then everything just breaks.  I quickly remove the 4 nameservers from GoDaddy and try many other things I found online and nothing seems to work.
Can someone point me in the right direction here?  I just want to be able to send emails to @alkouri.com without the www.

A: As you attempted you will need another nameserver for your apex record domain.
You will need to migrate the records from your www public hosted zone into the one you create for the apex domain. Make sure that the records include the www part in their subdomain name when you import them.
Once you're happy that the records are copied switch the nameservers over as you previously tried. Finally add the record for the SES apex domain to your new public hosted zone.
There is no alternative if you have no configured DNS for the apex record as AWS will not be able to resolve the records to validate the domain.


text:
Q: echo $SHELL shows `/bin/bash` as the output even after changing the default shell to zsh I referred to this answer to change my default shell How to change default shell to ZSH - chsh says "invalid shell"
After adding zsh to /etc/shells and doing sudo chsh -s "$(command -v zsh)" "${USER}" I ran echo $SHELL (which gave no output btw so I thought that it must have ran successfully) and it gave me /bin/bash
I closed my shell and opened up a new shell session and zsh showed up so I thought it must have been fixed with a restart, after that when I ran echo $SHELL in the zsh session it still gave me the same output /bin/bash``$SHELL --version also gives me the bash version not the zsh one
everytime I do ctrl+alt+t I do get a zsh session but this echo $SHELL output is making me suspicious.
UPDATE: I am running Ubuntu Budgie 18.04.3 and I got /bin/zsh from echo $0

A: The SHELL environment variable is only set when you perform a full login, e.g. by logging out and logging in again, or by using su - "$USER" or ssh "$USER@localhost" or some other command that performs a full login.
It is usually the login program that sets this variable based on what the user's login shell is in the passwd database.  This is called as part of the login process by whatever process is accepting a login request from a user (e.g. via sshd or gdm etc.)
From the login(1) manual on Ubuntu:

Your user and group ID will be set according to their values in the /etc/passwd file. The value for
  $HOME, $SHELL, $PATH, $LOGNAME, and $MAIL are set according to the appropriate fields in the password
  entry. Ulimit, umask and nice values may also be set according to entries in the GECOS field.

Just starting a new shell session will not set this variable's value, not even if the shell is started as a "login shell".

A: Wanting to add to Kusalananda's excellent and accepted answer:
On macOS if you want to to see the change without logging out of the GUI you can enter the following in Terminal:
$ logout [your username]

Then open a new Terminal session and enter:
echo $SHELL

You will see your new environment setting.


text:
Q: Javascript Button Keeps Pointing to Same Page I have a custom Javascript button on the OpportunityLineItem object that is a List button on the Opportunity.  It's designed to take users to various edit pages for Opportunity products based upon the Opportunity record type.  However, it only seems to take the user to the first page it selects, even when the record type is changed in the Opportunity and re-saved.  Is there some type of "reset" code that needs to be included in the button?
if('{!Opportunity.Commitment_Type__c}' == 'Portfolio'){
if('{!CONTAINS(Opportunity.RecordTypeId,$Label.ENT_CommitRT_ID)}'){
    window.open('/apex/VF_opportunityProductEntry?id={!Opportunity.Id}')
}
}
else if('{!CONTAINS(Opportunity.RecordTypeName_ENT__c,"Premier")}'){

if(window.location.href.indexOf("premierreseller") > -1){
window.open('/premierreseller/apex/opportunityProductEntry?id={!Opportunity.Id}')
}
else {
window.open('/apex/opportunityProductEntry?id={!Opportunity.Id}')
}
}

else if(window.location.href.indexOf("premierreseller") > -1){
    window.open('/premierreseller/p/opp/SelectSearch?addTo={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}')
}

else if('{!CONTAINS(Opportunity.RecordTypeId,$Label.ENT_ExclusiveRT_ID)}'){
window.open('/apex/opportunityProductEntry_Exclusive?id={!Opportunity.Id}')
}

else{
    window.open('/p/opp/SelectSearch?addTo={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}')
}

A: Your first condition:
if('{!CONTAINS(Opportunity.RecordTypeId,$Label.ENT_CommitRT_ID)}')

Would end up evaluating to either if('true') or if('false') which are both truthy in Javascript. Try removing the single quotes from around the {!expression} when it's returning a boolean.


text:
Q: Building an interface to search a .txt file depending on the user input, then print the results next to it I've been playing around with this quite a bit and I feel like I'm making a mess of it.
I need an interface where if someone enters a word in the text field, it'll print any lines within a .txt file containing that word in the box next to it.
Here's what I have so far:
    import Tkinter as tk
    from Tkinter import *
    from scipy import *

    import math

    def cbc(id, tex):
        return lambda : callback(id, tex)

    def callback(id, tex):
        t = Search(id)
        tex.insert(tk.END, t)
        tex.see(tk.END)
    #def retrieve_input():
    #    input = self.entn.get("0.0",END)
    def Search(id):
        with open("file.txt", "r") as s:
            searchlines = s.readlines()
        for i, line in enumerate(searchlines):
            if entn.get() in line:
                for line in searchlines[i:i+1]: print line,
                print
    top = tk.Tk()
    tex = tk.Text(master=top)
    tex.pack(side=tk.RIGHT)
    bop = tk.Frame()
    bop.pack(side=tk.LEFT)
    entn = tk.Entry()
    entn.pack(side=tk.TOP, fill=Y)
    tb = "Search"
    b = tk.Button(bop, text=tb, command=cbc(id, tex))
    b.pack()

    tk.Button(bop, text='Exit', command=top.destroy).pack()
    top.mainloop()

I'm pretty new to this, as you can probably tell - so any help will be really appreciated.

A: Your callback is inserting the result of Search(id) but that function isn't returning anything. You need to add a return statement in that function to return the strings you want to show in the text widget.
A better way might be to pass in a reference to tne text widget to Search so that you can directly insert each match as you find them.


text:
Q: How to process an uploaded csv file in python script using flask How to process the file which is uploaded by giving the file path to the python script and download the processed file ?
The code
@app.route("/upload", methods=['POST'])
def upload():
    target = os.path.join(APP__ROOT, 'data/')
    print(target)
    if not os.path.isdir(target):
        os.mkdir(target)
    for file in request.files.getlist("file"):
        filename = file.filename
        print(filename)
        destination = "/".join([target, filename])
        print(destination)
        file.save(destination)
    return render_template("downloads.html")

A: You need to return the file.
response = app.make_response(file)
response.headers["Content-Disposition"] = "attachment; filename=yourfile.csv"
return response


text:
Q: Can't access specific element using xpath with selenium Python I am trying to parse the wind direction using selenium and I think using xpath is the easiest way to get this info.
There is a table with all the information and the xpath of the elements within this table follow the same structure, hence my following code:
wind_directions = [browser.find_element_by_xpath(f'//*[@id="archive_results"]/table/tbody/tr/td/table/tbody/tr[3]/td[{i}]').text for i in range(14,25)]

Indeed, the structure of the data on the site is the following:

My issue is that I would like to get the content "rotate(494, 50, 50) translate(0,5)" from the picture above but I can't:
If I try to write replace the previous fstring with f'//*[@id="archive_results"]/table/tbody/tr/td/table/tbody/tr[3]/td[{i}]/svg/g'],
The compiler tells me that Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="archive_results"]/table/tbody/tr/td/table/tbody/tr[3]/td[14]/svg/g"}.
Any idea why I get such a message while this is the exact xpath that appears when I check on the element on Chrome ? (I triple-checked the indexes in the fstring and it is not the source of the error).

A: svg g etc. are special tag names.
To locate such nodes with XPath you can change your XPath expression as following:
'//*[@id="archive_results"]/table/tbody/tr/td/table/tbody/tr[3]/td[{i}]/*[name()="svg"]/*[name()="g"]'


text:
Q: How do I get Row Totals using QUERY() in Google Sheets? I'm working with the following Google Sheet.
Sheet2 uses the following QUERY() function to retrieve data from Sheet1
=QUERY(IMPORTRANGE("1s8krJ7rbZ1DMblZ3vdLcG5pySVM3ESCBy1o7R5Zv4LM", "Sheet1!B3:D"))
Is it possible to return the Row Totals (For Example: B4+C4+D4 for Row 4) using the above QUERY() function?
Please Advise.
My Query and Expected Output are Outlined on the Google Sheet.

A: You should be able to do something like this:
=QUERY(IMPORTRANGE("1s8krJ7rbZ1DMblZ3vdLcG5pySVM3ESCBy1o7R5Zv4LM", "Sheet1!B3:D"), "Select Col1+Col2+Col3 label Col1+Col2+Col3 ''")

Note that importing from another tab in the same spreadsheet doesn't require importrange. In that case, this should also work:
=QUERY(Sheet1!B3:D, "Select B+C+D label B+C+D ''")

Another way, to achieve the same result would be
=ArrayFormula(if(len(Sheet1!B3:B), Mmult(--Sheet1!B3:D, transpose(column(Sheet1!B2:D2)^0)),))

A: Be aware that while a simple QUERY can return the results, it will actually take up the entire column if you don't limit it. In other words, all the null rows from Sheet1! B:D will also come over with the QUERY. If you want only the results that have numbers, try something like this:
=QUERY(Sheet1!B3:D, "Select B+C+D WHERE B+C+D is not null label B+C+D ''")
Or you could use MMULT like this:
=MMULT(FILTER(Sheet1!B3:D,Sheet1!B3:B<>""),SEQUENCE(3,1,1,0))
The results may look the same whether limited or not. But in a QUERY or MMULT without limitations, you won't be able to use the space below the visible results for anything. I only mention this because, currently in your sheet, you do have data (a TRANSPOSE formula) below the main results. If you won't in your real sheet and don't care about the are below the visible results being inaccessible to other data or formula entry, then you don't need to limit.


text:
Q: Sum First Column on basis of Second Column I have written a Bash script which stores the number of records(line count) in a file and File name which is present in the directory in a output.txt file.
The output.txt file is as below.
No.ofRecord    FileName                   delimiter
563394         1--UnixfileName.txt        28
364794         2--UnixfileName.txt        28
785895         3--UnixfileName.txt        28
99778453       1--NextUnixFileName.txt    18
95645453       2--NextUnixFileName.txt    18
99745313       3--NextUnixFileName.txt    18

Required results
output.txt
No.ofRecord    FileName                   delimiter
563394         1--UnixfileName.txt        28
364794         2--UnixfileName.txt        28
785895         3--UnixfileName.txt        28
99778453       1--NextUnixFileName.txt    18
95645453       2--NextUnixFileName.txt    18
99745313       3--NextUnixFileName.txt    18

TOTAL :
1714083  UnixfileName
295169219 NextUnixFileName

Note:
Sum the No.ofRecord if File name like UnixFileName
Sum the No.ofRecord if File name like NextUnixFileName.
Thanks in advance.

A: $ awk 'NR > 1 { k = substr($2, 4); cnt[k] += $1 } { print } END { print "\nTOTAL:"; for (k in cnt) print cnt[k], k }' file
No.ofRecord    FileName                   delimiter
563394         1--UnixfileName.txt        28
364794         2--UnixfileName.txt        28
785895         3--UnixfileName.txt        28
99778453       1--NextUnixFileName.txt    18
95645453       2--NextUnixFileName.txt    18
99745313       3--NextUnixFileName.txt    18

TOTAL:
1714083 UnixfileName.txt
295169219 NextUnixFileName.txt

The awk script sums up the first column based on a key k which is taken as the second column from its fourth character onwards. This is done for all input line from the file, except the first (which is a header). All input lines are passed on unmodified as output.
At the end, the totals are printed for each found key.
To get the same column width on the totals as for the rest of the data, that last print cnt[k], k may be changed to some variation of
printf("%-15d%s\n", cnt[k], k)

which formats the number as a left-justified, 15 character wide, integer.


text:
Q: When and how to use a template literal operator? On cppreference there is a mentioning that one can have templated user-literal operators, with some restrictions:

If the literal operator is a template, it must have an empty parameter list and can have only one template parameter, which must be a non-type template parameter pack with element type char, such as

template <char...> double operator "" _x();

So I wrote one like in the code below:
template <char...>
double operator "" _x()
{
    return .42;
}

int main()
{
    10_x; // empty template list, how to specify non-empty template parameters?
}

Question:

*

*The code works, but how can I use the operator with some non-empty template parameters? 10_x<'a'>; or 10_<'a'>x; does not compile.

*Do you have any example of real-world usage of such templated operators?

A: Your template parameters are already specified--they're the source-code characters comprising your literal value! So for 10_x, you're actually calling:
template<> double operator "" _x<'1', '0'>();

Here's a working example. It compiles without error, and none of the assertions are triggered.
#include <cassert>

enum class MyEnum
{
  ONE,
  TWO,
  THREE
};

template<char...> MyEnum operator "" _e();

template<> MyEnum operator "" _e<'1'>()
{
  return MyEnum::ONE;
}
template<> MyEnum operator "" _e<'2'>()
{
  return MyEnum::TWO;
}
template<> MyEnum operator "" _e<'3'>()
{
  return MyEnum::THREE;
}

int main()
{
  assert(1_e == MyEnum::ONE);
  assert(2_e == MyEnum::TWO);
  assert(3_e == MyEnum::THREE);
}

A: You can elaborate the parameters pack somehow (as mentioned by others) or access them as a compile-time string if you prefer:
template<int N>
constexpr double f(const char(&str)[N]) { return .42; }

template <char... C>
constexpr double operator "" _x()
{
     return f({C...});
}

Do you have any example of real-world usage of such templated operators?

You can use the above mentioned technique to deal with compile-time string-to-num converter and have something like 10_x instead of f("10") or whatever.

A:
10_x; // empty template list, how to specify non-empty template parameters?

That isn't quite right. The template parameter list isn't empty. When you write:
template <char... Cs>
??? operator "" _x()

The Cs get populated from the stuff on the left-hand side of the literal. That is, when you write:
10_x

that calls:
operator ""_x<'1', '0'>();

One simple example would be to build a compile time, overflow-safe binary literal such that:
template <uint64_t V>
constexpr uint64_t make_binary() {
    return V;
}

template <uint64_t V, char C, char... Cs>
constexpr uint64_t make_binary() {
    static_assert(C == '0' || C == '1', "invalid binary");

    return make_binary<2*V + C - '0', Cs...>();
}

template <char... Cs>
uint64_t operator "" _b()
{
    static_assert(sizeof...(Cs) <= 64, "overflow");

    return make_binary<0, Cs...>();
}

uint64_t a = 101_b; // OK: a == 5
uint64_t b = 102_b; // error: invalid
uint64_t c = 11111111110000000000111111111100000000001111111111000000000011111111110000000000_b; // error: overflow


text:
Q: Solve the quadratic congrunce Solve the following quadratic congreunce
$x^2+ 7x + 10 \equiv 0$ (mod $11$).
I want to know a general and easy method how to solve this kind of questions.

A: For $ax^2+bx+c\equiv 0$ (mod $p$), if $p$ is an odd prime not dividing $a$, then this is the same as solving a simpler question about quadratic residues $y^2\equiv b^2-4ac$ (mod $p$), and $y\equiv 2ax+b$ (mod $p$).

A: Use the quadratic formula $$\frac{-b \pm \sqrt{b^2-4ac}}{2a}$$
so $b^2-4ac = 7^2 - 40 = 9 = 3^2$
so $\pm \sqrt{b^2-4ac} = \pm 3$
and $-b \pm 3 = -10,-4$
and so the answers are -5 and -2.


text:
Q: C# WinForm .Visible and Image Change Issues I am attempting to create a WinForm menu system in C# for WinCE 6.0.
The general idea for this menu system is that there are a few picture boxes that act as buttons along the bottom of the screen. These allow for switches between general settings (screen brightness, language, etc.), date/time settings and other system specific settings. And there are a few more picture boxes that act as buttons in the middle of the screen along with labels defining the options for the user.
So, quick example. Entering the settings menu brings you to the general settings by default:
labelTitle.Text = "General";
labelOption1.Text = "Brightness";
picOption1Left.Image = bmpDown;
picOption1Right.Image = bmpUp;

Tapping on the down arrow next to brightness, will lower the screen brightness; up arrow will raise brightness.
Tapping the Date/Time option button along the bottom of the screen will change these fields to the following:
labelTitle.Text = "Date and Time";
labelOption1.Text = "Time";
picOption1Left.Visible = false;
picOption2Right.Image = bmpInput;

Only one image is used for this setting. Tapping the input image will allow the user to input the time through a virtual keyboard, or possible other means.
Thats the basic concept. The problem is that after switching images and or toggling the .Visible value between true and false eventually cause the device to stall and crash. My troubleshooting so far makes me think this is some sort of issue with memory.
Why would I be consuming memory (enough to make the device crash) just by toggling visibility or changing the image associated with an asset? Tested and both functions will cause the crash. Is there something bad about programming a menu system this way? Is there a better way to reach this goal? Should I consider programming in a different language since an embedded device will be more limited? I appreciate any thoughts and/or advice on the matter.
Thanks!


text:
Q: Java Program Notification I have a java program, that has a console that shows in Terminal (im using mac os) and I want to be able to show basic notifications, like the ones that pop up in the corner or something. It could also involve the icon bouncing or something. What's the easiest way to do that? Is there an easy way to do that without using external libraries?

A: Possibly using JOption pane. Import looks like:
import javax.swing.JOptionPane;

and lets say you have a method called
public void gotNotification(){
JOptionPane.showMessageDialog (null, "You just received a notification!!!");
}

that way a box pops up saying "You just received a notification!!!". Thats the best suggestion I have.


text:
Q: When M is a payoff matrix what does $\max\limits_{i} \min\limits_{j} M_{ij}$ and $ \min\limits_{j} \max\limits_{i} M_{ij}$ mean exactly? I am reading a book on randomized algorithms leading up to Yao's Technique and I stumbled on the following min/max notation for some payoff matrix $M$:
$$\color{green}{(1)}: \max\limits_{i} \min\limits_{j} M_{ij} $$
$$\color{blue}{(2)}: \min\limits_{j} \max\limits_{i} M_{ij} $$
So what I am looking for is for someone to maybe phrase this more eloquent than me.
The way that I understand $\color{green}{(1)} $ and $\color{blue}{(2)}$  is that $i$ is the strategy/index the row player R picks and $j$ is the index/strategy that the column player C picks.
Then $\color{green}{(1)}$ means to express that we let $i$ vary over all of its rows, for each row we find the minimum, and then we take the maximum of all of the minimums and return that? and vice versa for $\color{blue}{(2)}$? So both is eventually just a value.


text:
Q: Sharepoint 2013 Quick Launch Treeview is it possible to change the order of the menu in the Quick Launch in treeview mode only ?
Thanks you.

A: According to your post, my understanding is that you want to reorder the Tree View of the site contents in SharePoint 2013.
Per my knowledge, we only can enable or disable the Tree View in the Site Settings, there is no out of box way to reorder the Tree View in SharePoint as DareDevil say.
As a workaround, if you simply want to hide some lists which is not necessary from the Tree View, I recommend that you can select the Hide from browser check box in the General Settings of these lists by using SharePoint Designer 2013.
Also, you can try to add some proper prefix on the names of the site contents to regularly reorder the Tree View based on your need.
And, if you still want to implement the customizable order of the Tree View, you need to customize own code to create a new Tree View to get the site contents dynamically and add it into the master page to replace the default Tree View.
There are some articles as below for your reference:

*

*Overview of site navigation in SharePoint 2013

*http://sharepoint.stackexchange.com/questions/59774/hide-some-lists-from-treeview

*Site Map Web Part (SharePoint 2013)


text:
Q: How to get total records with multi value in one filed? I use the code below to get total records group by schools type.
It works fine, but now I want the choice of school type multiple.
Previously, the field had only one value now one value or multi value as statge= ('primary','secondary','nursery') and different from row to other.
I try to use explode in SQL but I did not succeed.
$resultt = mysqli_query($con, "SELECT count(*) as total_records, statge  FROM schools group by statge ");

$statge = '';
$primary = '';
$secondary = '';
$college = '';
$training = '';
$nursery = '';

while ($row = mysqli_fetch_assoc($resultt)) {
    switch (true) {

        case $row['statge'] == "primary":
            $primary = $row['total_records']=;
            break;

        case $row['statge'] == "secondary":
            $secondary = $row['total_records'];
            break;

        case $row['statge'] == "college":
            $college = $row['total_records'] . '	';
            break;

        case $row['statge'] == "training":
            $training = $row['total_records']=;
            break;

        case $row['statge'] == "nursery":
            $nursery = $row['total_records'];
            break;
    }
}

Now not count any filed include multi values this problem.

A: The value to switch on has to be the column value:
switch ($row['statge']) {

    case "primary":
        $primary = $row['total_records'];
        break;

    case "secondary":
        $secondary = $row['total_records'];
        break;

    case "college":
        $college = $row['total_records'] . '	';
        break;

    case "training":
        $training = $row['total_records'];
        break;

    case "nursery":
        $nursery = $row['total_records'];
        break;
}

Check the switch docs for more examples: https://www.php.net/manual/en/control-structures.switch.php


text:
Q: Connecting to oracle database using python(cx_oracle) I am trying to connect to oracle database using cx_Oracle in python. I am able to connect to the database and pull the data.
Now I am trying to connect to one more database where I have to call a security procedure first and then only I can see data in the underlying tables. Can you please help me in calling the procedure by adjusting the below block of code. My procedure will be like:  exec ef.applogin('1234')
def connect_oracle():
    import cx_Oracle
    import pandas as pd
    ip = 'some_ip'
    port = 1521
    SID = 'some_SID'
    dsn_tns = cx_Oracle.makedsn(ip, port, SID)
    connection = cx_Oracle.connect('user_name', 'password', dsn_tns)
    #Procedure to be executed here..
    query = """ SELECT * from table_name """
    df_ora = pd.read_sql(query, con=connection)
    return df_ora

connect_oracle()

Many thanks in advance!!

A: Create def for connect by Oracle. for execute procedure use cursor. Don't forget close connect and cursor. Also in case exception.
import cx_Oracle
import pandas as pd

ip = 'some_ip'
port = 1521
SID = 'some_SID'
user_name = 'user_name'
password = 'password'
query = """ SELECT * from table_name """

def connect_oracle(ip, port, SID, user_name, password):
    dsn_tns = cx_Oracle.makedsn(ip, port, SID)
    connection = cx_Oracle.connect(user_name, password, dsn_tns)
    return connection

def get_df(conn, query):
    df_ora = pd.read_sql(query, con=conn)
    return df_ora

def execute_proc(conn, procname, param):
    my_cursor=conn.cursor()
    my_cursor.callproc(procname, param)
    conn.commit()

def execute_func(conn, procname, param):
    my_cursor=conn.cursor()
    out_parameter = my_cursor.var(cx_Oracle.NUMBER)
    qw = my_cursor.callfunc(procname, out_parameter)
    return qw

conn1 = connect_oracle(ip, port, SID, user_name, password)
df = get_df(conn1, query)
df.head()
execute_proc(conn1, "insert_temp", [])
execute_func(conn1, "get_version", [])

Function for test:
create or replace function get_version
return number
is
    v_version NUMBER(8) := 11;
begin
    return v_version;
end;

Procedure for test:
create table temp (clm number);
create or replace procedure insert_temp
is
    v_version NUMBER(8) := 11;
begin
    insert into temp(clm) values(v_version);
end;
select *  from temp


text:
Q: How To Restore Default Ownership of System32 Subfolders and Files? I'm fixing a friend's computer (well, trying to) and found that he had taken ownership of the System32 folder... Is there a simple way to revert ownership of all its subfolders and files back to the factory/default owners (besides reinstalling Windows 10 Home)? I know the majority of these system files and folders belong to 'TrustedInstaller', but a considerable portion (25% perhaps) are owned by the 'System' account, and/or 'Administrators' group. Please help.

A: To restore TrustedInstaller ownership to system files

*

*Open File Explorer

*Browse to the System32 folder

*Right-click it and select Properties

*Click the Security tab

*Click the Advanced button

*On "Advanced Security Settings", click Change

*On the "Select User or Group" page, type NT Service\TrustedInstaller

*Click OK

*Click Apply

*Click OK to complete.

Don't forget to check the options "Replace owner on the subcontainers and objects" and
"Replace all child object permission entries with inheritable permission entries from this object". This might take some time to complete.
To remove full control from the user account

*

*Right-click the System32 folder and select Properties

*Click on the Security tab

*Click Advanced

*On the "Advanced Security Settings" page select the user account

*Click Remove

*Click Apply

*Click OK to complete.


text:
Q: Couldn't fetch remote media on Cloudinary I would like to overlay remote media on smaple.jpg in Cloudinary. But :type=>"fetch" wouldn't work and the image wouldn't show up.
Just read Document, but this doesn't apply to the current case.
<%= cl_image_tag(
  "ogp.png",
  :transformation=>[
    {:color=> '#fff', :overlay=>{:color=> "#ffffff", :font_family => 'Open Sans', :font_size=> 20, :text_align=> 'center', :text=> @channel.user.name},},
    {:flags=>"layer_apply", :gravity=>"north", :y=>90},
    {:type=> 'fetch'},
    {:overlay=> Base64.encode64('https://[PUBLI IMAGE URL].jpg'), :type=>"fetch"},
  ],
) %>

=> https://res-4.cloudinary.com/remotehour/image/upload/co_rgb:fff,l_text:Open%20Sans_20_center:Shun/fl_layer_apply,g_north,y_90/l_aHRXXXXXXXXXXXXXXXXXwMC5qcGc=/sampple.jpg

A: Instead of using the base64 encoded version, you would need to do specify image with the url parameter. You don't need to specify fetch since the SDK will automatically take care of it. You can find an example here.
Here's the code in Python as I'm not too familiar with PHP.
import cloudinary

resp = cloudinary.CloudinaryImage('sample').image(
    transformation = [
        {"overlay": {"text": "hi",'font_family': 'roboto', 'font_size':30},'gravity': 'north_west','x':20,'y':20,'color':'blue'},
        {"overlay": {'url': 'https://images.pexels.com/photos/3948546/pexels-photo-3948546.png'},'gravity':'south_east','width':250,'height':250,'crop':'fill','x':10,'y':10}
    ]
)
print(resp)

This will generate an image with a text at top left and the overlay image at bottom right.

Output URL: https://res.cloudinary.com/akshayranganath/image/upload/co_blue,g_north_west,l_text:roboto_30:hi,x_20,y_20/c_fill,g_south_east,h_250,l_fetch:aHR0cHM6Ly9pbWFnZXMucGV4ZWxzLmNvbS9waG90b3MvMzk0ODU0Ni9wZXhlbHMtcGhvdG8tMzk0ODU0Ni5wbmc=,w_250,x_10,y_10/sample


text:
Q: Spring Boot + Quartz + Postgresql 9.4 I am using Spring Boot + Quartz + Postgresql 9.4
For initializing Quartz tables, I have wrote all sql scripts related to Quartz in data.sql which Spring boot automatically reads and run file in every restart.
data.sql
drop table if exists qrtz_fired_triggers;
drop table if exists qrtz_paused_trigger_grps;

create table qrtz_job_details ...
create table qrtz_triggers....
...
...
create index idx_qrtz_j_req_recovery ...
create index idx_qrtz_j_grp ...

application.properties
spring.jpa.hibernate.ddl-auto=update

With this configuration, Table is created successfully.
Now if I create a job with 15 minutes from now, job will be successfully saved in quartz table.
At this point if server is restarted, all tables of quartz will be dropped and recreated because "data.sql" will run again and all future jobs will be deleted because of drop script in data.sql
I want to keep my quartz table and all jobs intact.
What should be best approach to solve this problem, I am using postgresql 9.4, so problem is i can't use create index if not exist
Approach I am thinking
Approach 1
Logically creates table and index after application starts.
Approach 2
I keep my jobs in Quartz table as well as in my schedule table, so upon restart my schedule table is intact as it is mapped to java entity, so read jobs from schedule table upon restart and create the jobs in quartz table again.
I would like to know the best approach.


text:
Q: $.ajax not working with IE and working fine with Mozilla i have a following code which runs fine with Mozilla but give object undefined error
when run on IE
here is the code
 $(document).ready(function () {
           $("#button").click(function () {

               $.ajax({
                   type: "POST",
                   beforeSend: function (xhr) {
                       xhr.setRequestHeader("Content-type",
                     "application/json; charset=utf-8");
                   },
                   data: "{'customerid':" + "'" + $("#check").val + "'}",
                   url: "ajaxcall.aspx/checkval",
                   success: function (data) {
                       var c = data.d;
                       alert("success");
                       $("#result").html("day:" + c.seconds);
                   }
               });

           });
       });

now i have changed my server side c# code inside
checkval function using json serialzation
Mydate md = new Mydate();
        md.day = DateTime.Now.Day.ToString();
        md.month = DateTime.Now.Month.ToString();
        md.year = DateTime.Now.Year.ToString();
        md.seconds = DateTime.Now.Second.ToString();

        JavaScriptSerializer js = new JavaScriptSerializer();
       return js.Serialize(md);

Now code is working in IE but only showing the string  as

{"month":"10","year":"2011","day":"13","seconds":"44"}
  and not working with Mozilaa
in place of c.seconds if i write c only
  in this code
$("#result").html("day:" + c.seconds);

it works for all browsers but the result is

{"month":"10","year":"2011","day":"13","seconds":"44"}

Still not getting what i need
here is the answer atlast i got it
in place of this
                   var c = data.d;
                   alert("success");
                   $("#result").html("day:" + c.seconds);

Write
                   var mydata = $.parseJSON(data.d);
                   $("#result").html(mydata.seconds);

this will work in IE and Mozilla both

A: Perhaps a small typo in data: "{'customerid':" + "'" + $("#check").val + "'}".
Have you tried $("#check").val()?


text:
Q: isn't it possible to get partial derivatives for x^(1/3)y^(1/3)? I'm studying "vector calculus written by Jerrold E.marsden, Anthony Tromba 6th Ed"
My problem is I couldn't understand example 4 in 2.3section
They said that they can get partial derivatives of $x^{1/3}y^{1/3}$ at (0,0) like below
$$f_x(x,y)=lim_{h\rightarrow0}\frac{f(h,0)-f(0,0)}{h}=lim_{h\rightarrow0}\frac{0-0}{h}=0$$
Next paragraph, they said there are no partial derivatives in $x^{1/3}y^{1/3}$ because It doesn't have tangent plane at (0,0)
I'm confusing these two contradictory explanation.
It seems like that I could get partial derivatives by definition of partial derivative.
But I know It couldn't be happen
what is the turth of this example?


text:
Q: Captions for Tikz drawings I have a question concerning captions for Tikz drawings. Below, you see the source code for a binary tree I've drawn with Tikz. I want to place a caption beneath it but unfortunately, the caption does not appear directly below the center of the tree but far at the right side of the tree.
Does anybody know how to place captions directly below of a tree?
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{tikzpicture}
[level distance=20mm, every node/.style={fill=red!60,circle, draw, inner sep=2pt},
level 1/.style={sibling distance=40mm,nodes={fill=red!45}},
level 2/.style={sibling distance=20mm,nodes={fill=red!30}},
level 3/.style={sibling distance=10mm,nodes={fill=red!25}}]
\node {A}
   child {node {D}
         child {node {3}
              child {node {X}}
         child[missing]
         }
         child {node {9}}
      }
  child {node {V}
         child {node {19}}
         child {node {6}}
   };
\end{tikzpicture}
\caption{A tree}
\end{figure}
\end{document}

By the way, does anybody know how to place annotations/comments by the side of nodes such as in this picture (the Höhe tags):
Thanks so much for your help!

A: You would want to center your tree using \centering
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\begin{document}
\begin{figure}[htb]  %% use position specifiers [htb]
\centering           %% <-- here
\begin{tikzpicture}
[level distance=20mm, every node/.style={fill=red!60,circle, draw, inner sep=2pt},
level 1/.style={sibling distance=40mm,nodes={fill=red!45}},
level 2/.style={sibling distance=20mm,nodes={fill=red!30}},
level 3/.style={sibling distance=10mm,nodes={fill=red!25}}]
\node {A}
   child {node {D}
         child {node {3}
              child {node {X}}
         child[missing]
         }
         child {node {9}}
      }
  child {node {V}
         child {node {19}}
         child {node {6}}
   };
\end{tikzpicture}
\caption{A tree}
\end{figure}
\end{document}

A: To add comment, an internal name () is required so that you can refer to later (in this demonstration (D) and (3) are defined). Here relative distance is used via positioning from tikzlibrary, meaning pos=<0~1>, above, left, right, below, or combination of those keys can be used to position the comments. Also, you need to use draw=none and fill=none since every node style is already defined with circle filled with color.

Code
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
[level distance=20mm,  every node/.style={fill=red!60,circle, draw, inner sep=2pt},
level 1/.style={sibling distance=40mm,nodes={fill=red!45}},
level 2/.style={sibling distance=20mm,nodes={fill=red!30}},
level 3/.style={sibling distance=10mm,nodes={fill=red!25}}]
\node {A}
   child {node(D) {D}
         child {node(3) {3}
              child {node {X}}
         child[missing]
         }
         child {node {9}}
      }
  child {node {V}
         child {node {19}}
         child {node {6}}
   };
\draw (D) -- (3) node[below left= 0.5cm of D,draw=none,fill=none](){comment};
\end{tikzpicture}
\caption{A tree}
\end{figure}
\end{document}


text:
Q: Installation of Windows Server 2012 R2 x64 I regularly swap OS during a development process. With "normal" OSs I can expect and install (.iso) to reach <=4GB, no problem, I usually use DVD. Now, I need to do some testing with Windows Server 2012 R2, this .iso is HUGE at 5.2GB!
The problem I have is that this will not fit on a single DVD, and it will not fit on a bootable USB stick due to file size limitations of FAT32.
I could split the file over separate DVDs, but I don't think this is possible from experience (am I wrong?).
My question is a simple one, how can I install Windows Server 2012 R2?
Thanks for your time.

A: NTFS-formatted USB stick.
Command prompt (run as administrator):
diskpart
list disk
select disk N (N = the disk you want to format)
clean
create partition primary
active
format fs=ntfs quick
assign

After you have done this, just copy all the files of WS2012R2 on the USB. it should work without additionally requiring bootsect command (bootsect.exe/nt60 N:). This command is needed only if the USB will not boot, but it should not happen on WS2012.

A: You have to burn the iso on a double-layer DVD, where you can store up to 8.5 GB.
http://en.wikipedia.org/wiki/DVD%2BR_DL
You can also use an USB key in FAT32, as you have to copy installation files on it (not the .iso) which aren't bigger than the FAT32 limit (https://technet.microsoft.com/en-us/library/dn293258.aspx)