text:
Q: What word describes words that can be more that one part of speech? Some words, depending on how they're used, can be used as different parts of speech.
i.e a noun in one case and a verb in another.

Examples
Here's a couple examples: Top, Quiet, Fast

*

*Top

*

*
noun in "the spinning top fell over"

*
adjective in "the top shelf"

*Quiet

*

*
adjective in "she's a quiet person"

*
noun in "I need peace and quiet" or "please keep quiet"

*Fast

*

*
noun in "they completed a two day fast"

*
adjective in "the new car is fast"

What are these types of words called?

A: The process itself is called "conversion" or "zero derivation" . It refers to the process of changing a word's part of speech without any change to its morphology.

Conversion normally involves changing a word's syntactic category
  without any concomitant change of form, as in the creation of the verb
  humble from the adjective humble or of the noun attempt from the verb
  attempt

from Huddleston, R, and GK Pullum. 2002. The Cambridge Grammar of English. Cambridge
The words that experience conversion may be referred to as "zero-derived words".
There are words like record or permit which can be used as a noun or verb. They have the same spellings and the same (or lets say related) meanings, but the stress is moved to a different syllable, so they are a little different in pronunciation. This process is called "initial-stress-derivation":

Initial-stress derivation is a phonological process in English that
  moves stress to the first syllable of verbs when they are used as
  nouns or adjectives. (This is an example of a suprafix.) This process
  can be found in the case of several dozen verb-noun and verb-adjective
  pairs and is gradually becoming more standardized in some English
  dialects, but it is not present in all. The list of affected words
  differs from area to area, and often depends on whether a word is used
  metaphorically or not. At least 170 verb-noun or verb-adjective pairs
  exist. Some examples are:

*

*record: as a verb, "Remember to recórd the show!".

*record: as a noun, "I'll keep a récord of that request."

A: Your examples above are all homonyms. Homonyms are words that are spelled and pronounced the same but have different meanings.
Taking "top" as a single example; as a noun it can be used to describe an item of clothing (in UK English anyway) and obviously that is something entirely different to a "spinning top". So what you have are two different things that are spelled and pronounced the same. The fact they have the same root meaning is certainly relevant, but doesn't make them the same.
One comment suggested that they are "homophones", but that isn't completely accurate if they are spelled the same. True, a homonym is also by definition a homophone, but two words can be considered homophones if they simply sound the same (for example sea and see). If they are spelled and sound the same they are homonyms.

*

*Homophone - words that sound the same but have different meanings. (eg "sea" and "see")

*Homograph - words that are spelled the same but have different meanings. (eg "wind" as in windmill, and "wind" as in the long and winding road)

*Homonym - words that are spelled and sound the same but have different meanings. (eg "fly" as in insect, or to travel by air)

The reason I feel this is the most appropriate answer is because "homonym" accurately describes the words above regardless of whether or not they are different word classes (what you call "parts of speech", eg nouns, adjectives, etc).
Also two words can be described as homonyms whether or not the words have the same derivation. For example, "mine" as a noun for an underground excavation is of French or possibly Celtic origin. The adjective "mine" meaning to dig such an excavation is clearly derived from it. However, "mine" as a possessive pronoun is of Germanic origin, so it cannot be referred to as a derivation. However, all three are homonyms.


text:
Q: How to get last month date using Date::Calc in perl? How to get last month date using Date::Calc in perl?
For example, today is 8/2018 - I would like the function to return 7/2018.
If the date today is 1/2019 - it should return 12/2018

A: Try this below code
use Date::Calc qw(:all);

my ($current_year,$current_month,$current_day)=Today;

my ($result_year,$result_month,$result_day)=Add_Delta_YM($current_year,$current_month,$current_day,0,-1);

If you need fulll month name use below format
my $result_month_name=Month_to_Text($result_month);

A: Date::Calc seems to make everything far more complex than it needs to be:
#!/usr/bin/perl

use strict;
use warnings;
use feature 'say';

use Date::Calc qw[Today Add_Delta_Days];

my @today = Today;

my ($year, $month) = Add_Delta_Days(@today, -$today[2]);

say "$month/$year";

I'd recommend looking at DateTime instead.
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';

use DateTime;

my $today = DateTime->today;
$today->subtract(days => $today->day);
say $today->strftime('%m/%Y');

A: Time::Moment provides a nice alternative as well:
use strict;
use warnings;
use feature 'say';
use Time::Moment;

say Time::Moment->now->minus_months(1)->strftime('%m/%Y');

redpajama_set_name: RedPajamaStackExchange


text:
Q: cannot use internet through ethernet in12.04 getting error net connection has .local domain. Works fine in wifi but problem using wired connection I am using ubuntu 12.04. Earlier I was using net through ethernet port & it was working fine. But I now get a error that the service provider has a .local domain and the net connection shuts down.
When I spoke to the service provider he says the mac no is binded & I will have to use a wifi connection to use internet in ubuntu.
I am faced with a dilemma whether to move back to windows as if i cannot use internet in ubuntu the updates will not be possible.
Is there any other solution to this ? Plz help, thanks in advance.

A: This link helped me while investigating a similar problem.
http://ubuntuforums.org/showthread.php?t=2050126
Especially the following:
 lspci -nn | grep 0200

sudo apt-get install linux-headers-generic build-essential
wget http://www.orbit-lab.org/kernel/compat-wireless-3-stable/v3.5/compat-wireless-3.5.1-1-snpc.tar.bz2
tar -xf compat-wireless-3.5.1-1-snpc.tar.bz2
cd compat-wireless-3.5.1-1-snpc
./scripts/driver-select alx
make
sudo make install
sudo modprobe alx


text:
Q: Provision Service Applications using c#? Is there a way to provision service applications using c# ?
Can anyone code to provision any one of the following service applications in a single standalone setup.

*

*Search Service Application

*Managed MetaData Application

*UserProfile Application.

There are ways doing with PowerShell, but what if it comes to the native SharePoint API?

A: While it is possible, I wouldn't recommend it.  The issue is that there are no public-facing methods to call from C# to do this.  You would need to use a reflection tool (i.e. dotPeek or .NET Reflector) to get the internal methods to create the service applications.  For instance, you could reflect the Microsoft.SharePoint.PowerShell assembly to view how the Cmdlet does the work.  Once you have the code, you would have to use reflection to get and invoke the methods from your code.  The bad thing here is that the code can change from update to update (cumulative updates often change internal methods, etc.).
I would recommend a different approach: run the Cmdlets from your C# code.  There are a number of examples on the web, this one should be enough to get you started: http://www.codeproject.com/Articles/18229/How-to-run-PowerShell-scripts-from-C.


text:
Q: how cache detect forms inputs like firstname and lastname and distribute value in them when we hover on form in any website the dialog box is displayed and when we click on that dailog box. input fields are detected like first name or last name or may be address .My question is that how browser detects the exect input field and distribute values in them .like using name , id type of input field or other process are used .if possible give some references too.thanks
js developers..web
how cache detect form fields and distribute inputs.


text:
Q: How do I fix 301 redirects? I am using trying to use grammarapi using nodejs. My code seems to be fine but doesn't know why it is showing status_code =301 not 200 I have no idea how to fix it. pls, suggest some solution.
error :
trailers: {},
  rawTrailers: [],
  aborted: false,
  upgrade: false,
  url: '',
  method: null,
  statusCode: 301,
  statusMessage: 'Moved Permanently',
  client: TLSSocket {
    _tlsOptions: {
      allowHalfOpen: undefined,
      pipe: false,
      secureContext: [SecureContext],

My code:
const express = require('express');
const https = require('https');

const app = express();

app.get("/", function(req, res){
     const url = "https://www.stands4.com/services/v2/grammar.php?uid=1001&tokenid=tk324324&text=i%20loves%20you&format=json"

     https.get(url, function(response){
         console.log(response);
     })
});

app.listen(port = 3000, function(){

    console.log("Server is running on port 3000 ");
});


text:
Q: populating a text box with lloyalty points from a access database; Im trying to populate a text box with infromation that is searched by using a customerID which is inputted throught a text box here is the code im using below
private void txtCustomerID_TextChanged(object sender, EventArgs e)
{
    string strCon = Properties.Settings.Default.PID2dbConnectionString;
    OleDbConnection conn = new OleDbConnection(strCon);

    String sqlPoints = "SELECT points FROM customer WHERE [customerID]=" +   txtCustomerID.Text;
     txtPoints.Text = sqlPoints;
}

but the text box "txtPoints" only outputs the text of the sqlpoints and not the information in the database? I'm not exactly sure what im doing wrong here.
Any help is appreciated, thanks in advance.

A: You are not executing the SQL statement on the database. Instead, you are assigning it to txtPoints.Text. You need to execute it on the DB server using, e.g., an OleDbCommand object.
What you need to do instead is something like the following (note this is pseudo-code - I haven't tested it runs)
using (OleDbConnection conn = new OleDbConnection(strCon))
{
    String sqlPoints = "SELECT points FROM customer WHERE [customerID]=" +   txtCustomerID.Text;

    // Create a command to use to call the database.
    OleDbCommand command = new OleDbCommand(sqlPoints, conn)

    // Create a reader containing your results
    using(OleDbReader reader = command.ExecuteReader())
    {
        reader.Read(); // Advance to the first row.
        txtPoints.Text = reader[0].ToString(); // Read the contents of the first column
    }
}

Note also my use of using. This will ensure that your database connections are properly closed once you are finished with them.


text:
Q: Trouble getting data from JSON with ReactJS I have a JSON file like this, named data.json
{
  "link_template": "http://api.rottentomatoes.com/api/public/v1.0/lists/movies/box_office.json?limit={num-results}&country={country-code}",
  "links": {
    "alternate": "http://www.rottentomatoes.com/movie/box-office/",
    "self": "http://api.rottentomatoes.com/api/public/v1.0/lists/movies/box_office.json?limit=20&country=us"
  },
  "movies": [
    {
      "abridged_cast": [
        {
          "characters": [
            "Dominic Toretto"
          ],
          "id": "162652472",
          "name": "Vin Diesel"
        },
        {
          "characters": [
            "Brian O'Conner"
          ],
          "id": "162654234",
          "name": "Paul Walker"
        },
        {
          "characters": [
            "Louie Tran"
          ],
          "id": "162684066",
          "name": "Tony Jaa"
        },
        {
          "characters": [
            "Deckard Shaw"
          ],
          "id": "162653720",
          "name": "Jason Statham"
        },
        {
          "characters": [
            "Luke Hobbs"
          ],
          "id": "770893686",
          "name": "Dwayne \"The Rock\" Johnson"
        }
      ],
      "alternate_ids": {
        "imdb": "2820852"
      },
      "critics_consensus": "",
      "id": "771354922",
      "links": {
        "alternate": "http://www.rottentomatoes.com/m/furious_7/",
        "cast": "http://api.rottentomatoes.com/api/public/v1.0/movies/771354922/cast.json",
        "reviews": "http://api.rottentomatoes.com/api/public/v1.0/movies/771354922/reviews.json",
        "self": "http://api.rottentomatoes.com/api/public/v1.0/movies/771354922.json",
        "similar": "http://api.rottentomatoes.com/api/public/v1.0/movies/771354922/similar.json"
      },
      "mpaa_rating": "PG-13",
      "posters": {
        "detailed": "http://resizing.flixster.com/pVDoql2vCTzNNu0t6z0EUlE5G_c=/51x81/dkpu1ddg7pbsk.cloudfront.net/movie/11/18/14/11181482_ori.jpg",
        "original": "http://resizing.flixster.com/pVDoql2vCTzNNu0t6z0EUlE5G_c=/51x81/dkpu1ddg7pbsk.cloudfront.net/movie/11/18/14/11181482_ori.jpg",
        "profile": "http://resizing.flixster.com/pVDoql2vCTzNNu0t6z0EUlE5G_c=/51x81/dkpu1ddg7pbsk.cloudfront.net/movie/11/18/14/11181482_ori.jpg",
        "thumbnail": "http://resizing.flixster.com/pVDoql2vCTzNNu0t6z0EUlE5G_c=/51x81/dkpu1ddg7pbsk.cloudfront.net/movie/11/18/14/11181482_ori.jpg"
      },
      "ratings": {
        "audience_rating": "Upright",
        "audience_score": 88,
        "critics_rating": "Certified Fresh",
        "critics_score": 82
      },
      "release_dates": {
        "theater": "2015-04-03"
      },
      "runtime": 140,
      "synopsis": "Continuing the global exploits in the unstoppable franchise built on speed, Vin Diesel, Paul Walker and Dwayne Johnson lead the returning cast of Fast & Furious 7. James Wan directs this chapter of the hugely successful series that also welcomes back favorites Michelle Rodriguez, Jordana Brewster, Tyrese Gibson, Chris \"Ludacris\" Bridges, Elsa Pataky and Lucas Black. They are joined by international action stars new to the franchise including Jason Statham, Djimon Hounsou, Tony Jaa, Ronda Rousey and Kurt Russell.",
      "title": "Furious 7",
      "year": 2015
    },
    {
      "abridged_cast": [
        {
          "characters": [
            "Oh"
          ],
          "id": "770702500",
          "name": "Jim Parsons"
        },
        {
          "characters": [
            "Tip"
          ],
          "id": "351524959",
          "name": "Rihanna"
        },
        {
          "characters": [
            "Captain Smek"
          ],
          "id": "162654836",
          "name": "Steve Martin"
        },
        {
          "id": "162652167",
          "name": "Jennifer Lopez"
        }
      ],
      "alternate_ids": {
        "imdb": "2224026"
      },
      "critics_consensus": "",
      "id": "771315639",
      "links": {
        "alternate": "http://www.rottentomatoes.com/m/home_2015/",
        "cast": "http://api.rottentomatoes.com/api/public/v1.0/movies/771315639/cast.json",
        "reviews": "http://api.rottentomatoes.com/api/public/v1.0/movies/771315639/reviews.json",
        "self": "http://api.rottentomatoes.com/api/public/v1.0/movies/771315639.json",
        "similar": "http://api.rottentomatoes.com/api/public/v1.0/movies/771315639/similar.json"
      },
      "mpaa_rating": "PG",
      "posters": {
        "detailed": "http://resizing.flixster.com/LO7V_j1xUTlsbwzIyCINBxBm5qE=/54x80/dkpu1ddg7pbsk.cloudfront.net/movie/11/18/17/11181778_ori.jpg",
        "original": "http://resizing.flixster.com/LO7V_j1xUTlsbwzIyCINBxBm5qE=/54x80/dkpu1ddg7pbsk.cloudfront.net/movie/11/18/17/11181778_ori.jpg",
        "profile": "http://resizing.flixster.com/LO7V_j1xUTlsbwzIyCINBxBm5qE=/54x80/dkpu1ddg7pbsk.cloudfront.net/movie/11/18/17/11181778_ori.jpg",
        "thumbnail": "http://resizing.flixster.com/LO7V_j1xUTlsbwzIyCINBxBm5qE=/54x80/dkpu1ddg7pbsk.cloudfront.net/movie/11/18/17/11181778_ori.jpg"
      },
      "ratings": {
        "audience_rating": "Upright",
        "audience_score": 69,
        "critics_rating": "Rotten",
        "critics_score": 47
      },
      "release_dates": {
        "theater": "2015-03-26"
      },
      "runtime": 93,
      "synopsis": "When Oh, a loveable misfit from another planet, lands on Earth and finds himself on the run from his own people, he forms an unlikely friendship with an adventurous girl named Tip who is on a quest of her own. Through a series of comic adventures with Tip, Oh comes to understand that being different and making mistakes is all part of being human. And while he changes her planet and she changes his world, they discover the true meaning of the word HOME. (c) Fox",
      "title": "Home",
      "year": 2015
    }
  ]
}

This is my ReactJS code, intended to get data from that JSON file and bind in my React components
var CastMember=React.createClass({
    render:function(){

    }
});
var Cast=React.createClass({
    render:function(){
        var cast_members=this.props.cast.map(function (member){
            return (
                <CastMember member={member}/>
            );
        });
        return (

                {cast_members}

        );
    }
});
var Movie=React.createClass({
    render:function(){
        return (

                <Cast cast={this.props.movie.abridged_cast}/>

        );
    }
});
var MovieList=React.createClass({
    render:function(){
        var movieNodes=this.props.movies.map(function (movie){
            return (
                <Movie movie={movie}/>
            );
        });
        return (

                {movieNodes}

        );
    }
});
var DataBlock = React.createClass({
        getInitialState:function() {
            return {data:{
                movies:[
                    {abridged_cast:[]}
                ]
            }}
        },
        componentDidMount:function() {
            var a=this;
            $.ajax({
                url:this.props.url,
                dataType:'json',
                cache:false,
                success:function(data){
                    this.setState({data:data})
                }.bind(this)
            });
        },
        render: function() {
            return (

Movie List

                    <MovieList movies={this.state.data.movies}/>

);
}
});
React.render(
    <DataBlock url="data.json"/>,
    document.getElementById('content')
);

I have been doing this demo in bottom-to-top order. I was able to get list of movies from JSON file and render it, but now stuck in getting abridged_cast in each movie
In render function of Cast component, if I replace it with rendering {this.props.cast}, everything will show up. But I fail in mapping them to member property of CastMember component: My code above didn't display anything. What's wrong with my code?

A: var CastMember=React.createClass({
    render:function(){

    }
});

CastMember component should handle its prop, as you pass the data member to CastMember-> <CastMember member={member}/>.
This would be help:
var CastMember=React.createClass({
        render:function(){
            return (

                 {this.props.member}

            );
        }
    });


text:
Q: unable to set toggle button on right most side of list view? i  used list view in my android app. i used toggle button in my listview. i want to set the toggle button at right corner of listview. but i am unable to do the same. so please help me out.... the code snippet of my xml file are here......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

    android:orientation="horizontal"
    >

    <LinearLayout
        android:id="@+id/aaa"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_gravity="center_vertical"
        android:layout_marginRight="8dip"
        android:background="@drawable/image_bg"
        android:padding="3dip">

        <ImageView
            android:id="@+id/list_image"
            android:layout_width="50dip"
            android:layout_height="50dip"

            android:src="@drawable/rihanna" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <!-- Name Label -->

       <TextView
           android:id="@+id/email"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:paddingBottom="2dip"
           android:paddingTop="5dp"
           android:textColor="#acacac" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="right">

    </LinearLayout>

    <ToggleButton
        android:id="@+id/toggleButton1"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:gravity="right"

        android:background="@drawable/toggle"
        android:text=""
        android:textOff=""
        android:textOn=""
        android:focusable="false">
    </ToggleButton>
    </LinearLayout>
 <!--
       <ImageView android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:src="@drawable/arrow"
           android:layout_alignParentRight="true"
           android:layout_centerVertical="true"
           android:layout_marginLeft="150dp"
           android:layout_marginTop="30dp"
           /> -->

</LinearLayout>

A: android:layout_alignParentLeft

and
android:layout_alignParentRight

are not the properties of LinearLayout.You have to use RelativeLayout for that.Here see the changes i've made in your xml so that the radio button comes in Right.(change the drawables back acc to your req as this is a demo)
 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

    android:orientation="horizontal"
    >

    <LinearLayout
        android:orientation="vertical"
        android:id="@+id/aaa"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_gravity="center_vertical"
        android:layout_marginRight="8dip"
        android:background="@drawable/abc_ic_commit_search_api_mtrl_alpha"
        android:padding="3dip"
        android:layout_alignBottom="@+id/list_image"
        android:layout_alignParentTop="true">

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:orientation="vertical">

        <!-- Name Label -->

        <TextView
            android:id="@+id/email"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="2dip"
            android:paddingTop="5dp"
            android:textColor="#acacac" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:gravity="right">

        </LinearLayout>

        <ToggleButton
            android:id="@+id/toggleButton1"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:text=""
            android:textOff=""
            android:textOn=""
            android:focusable="false">
        </ToggleButton>
    </LinearLayout>

    <ImageView
        android:id="@+id/list_image"
        android:layout_width="50dip"
        android:layout_height="50dip"
        android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/aaa"
        android:layout_toEndOf="@+id/aaa" />
    <!--
          <ImageView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:src="@drawable/arrow"
              android:layout_alignParentRight="true"
              android:layout_centerVertical="true"
              android:layout_marginLeft="150dp"
              android:layout_marginTop="30dp"
              /> -->

</RelativeLayout>

A: <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

    android:orientation="horizontal"
    >

    <LinearLayout
        android:id="@+id/aaa"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_gravity="center_vertical"
        android:layout_marginRight="8dip"
        android:background="@drawable/image_bg"
        android:padding="3dip">

        <ImageView
            android:id="@+id/list_image"
            android:layout_width="50dip"
            android:layout_height="50dip"

            android:src="@drawable/rihanna" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical">

        <!-- Name Label -->

       <TextView
           android:id="@+id/email"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:paddingBottom="2dip"
           android:paddingTop="5dp"
           android:textColor="#acacac" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="right">

    </LinearLayout>

    <ToggleButton
        android:id="@+id/toggleButton1"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:gravity="right"
    android:layout_gravity="right"

        android:background="@drawable/toggle"
        android:text=""
        android:textOff=""
        android:textOn=""
        android:focusable="false">
    </ToggleButton>
    </LinearLayout>
 <!--
       <ImageView android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:src="@drawable/arrow"
           android:layout_alignParentRight="true"
           android:layout_centerVertical="true"
           android:layout_marginLeft="150dp"
           android:layout_marginTop="30dp"
           /> -->

</LinearLayout>

Try this. I have added android:layout_weight="1" to the layout and
    android:layout_gravity="right" for toggle button.


text:
Q: Código para Aproveitar cache do navegador deixa o site fora do ar Bom, estou tendo um problema para tirar o bendito "Aproveitar cache do navegador" do PageSpeed Insights.O site que estou fazendo isso é em Wordpress. A internet inteira indica um mesmo código para ser inserido no arquivo .htaccess, seja em inglês ou português, que é o seguinte:
# COMEÇA BROWSER CACHE

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType application/javascript "access plus 1 month"
ExpiresDefault "access plus 2 days"
</IfModule>

# TERMINA BROWSER CACHE

Só que sempre que eu uso esse, o site fica fora do ar, não sei porque isso ocorre, já usei esse mesmo código em outros sites e não ficou assim.

Alguém saberia me dizer se houve alguma mudança e essa forma não está funcionando mais?

A: O problema são as aspas " e ", este tipo de aspas não funciona, deve substituir por " para ambos:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType application/javascript "access plus 1 month"
ExpiresDefault "access plus 2 days"
</IfModule>

Sobre o PageSpeed Insights

*

*Duvida Sobre Cache

*Guardar ou não cache do navegador?
Sobre Etag

*

*É possível usar if-modified-since com "304 not modified" sem PHP

A: eu uso esse código em alguns sites e ele funciona, faça um teste no seu projeto, altere apenas o prazo de cada item que pode ser diferente para você !
#Força a utilizar Cache-Control e Expires header
<IfModule mod_headers.c>
    Header unset ETag
</IfModule>
FileETag None
<IfModule mod_expires.c>
    ExpiresActive on
    ExpiresDefault "access plus 1 month"
    ExpiresByType text/cache-manifest "access plus 0 seconds"
    # HTML
    ExpiresByType text/html "access plus 0 seconds"
    # DATA
    ExpiresByType text/xml "access plus 0 seconds"
    ExpiresByType application/xml "access plus 0 seconds"
    ExpiresByType application/json "access plus 0 seconds"
    # FEED
    ExpiresByType application/rss+xml "access plus 1 hour"
    ExpiresByType application/atom+xml "access plus 1 hour"
    # FAVICON
    ExpiresByType image/x-icon "access plus 1 week"
    # MEDIA: IMAGES, VIDEO, AUDIO
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType video/ogg "access plus 1 month"
    ExpiresByType audio/ogg "access plus 1 month"
    ExpiresByType video/mp4 "access plus 1 month"
    ExpiresByType video/webm "access plus 1 month"
    # HTC files
    ExpiresByType text/x-component "access plus 1 month"
    # WEBFONTS
    ExpiresByType application/x-font-ttf "access plus 1 month"
    ExpiresByType font/opentype "access plus 1 month"
    ExpiresByType application/x-font-woff "access plus 1 month"
    ExpiresByType image/svg+xml "access plus 1 month"
    ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
    # CSS / JS
    ExpiresByType text/css "access plus 1 year"
    ExpiresByType application/javascript "access plus 1 year"
    ExpiresByType application/x-javascript  "access plus 1 year"
</IfModule>


text:
Q: Extract string part from text in r I have text string such like this: Stoli 2.0 Intel PAV UMA, Phelps 1.0 Intel PAV_BayTrail x360 and I need to extract only the part Stoli 2.0 from the first one and Phelps 1.0 from the second one.
Could you anyone give me some sufficient solutio, how to do that, please? Thank you very much in advance.

A: You can use the gsub function to do what you need:
> x <- c("Stoli 2.0 Intel PAV UMA", "Phelps 1.0 Intel PAV_BayTrail x360")
> gsub("(^.* [0-9]*\\.[0-9]*).*", "\\1", x, perl = T, )
[1] "Stoli 2.0"  "Phelps 1.0"


text:
Q: How can I change font size on x-y labels I have the following code which I copied from here How to draw the unit hyperbola in LaTex?, and rotated it. The axis labels font is too large. Going through the manual and deveral posts, am not able to settle my problem. I tried to put {font size=tiny at various location, nothing changes.
Help will be appreciated
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=5cm,compat=1.12}
% axis style, ticks, etc
\pgfplotsset{every axis/.append style={font=\tiny}{
axis x line=middle,    % put the x axis in the middle
axis y line=middle,    % put the y axis in the middle
axis line style={->}, % arrows on the axis
`xlabel={\footnotesize$x^{'}$},          % default put x `on x-axis
                ylabel={\footnotesize$y^{'}$},{font=\tiny}          %
default put y on y-axis
                rotate=40.0}}
% arrows as stealth fighters
\tikzset{>=stealth}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
            xmin=-5,xmax=5,
        ymin=-5,ymax=5]
        \addplot [red,domain=-2:2] ({cosh(x)}, {sinh(x)});
    \addplot [red,domain=-2:2] ({-cosh(x)}, {sinh(x)});
    \addplot[red,dashed] expression {x};
    \addplot[red,dashed] expression {-x};
\end{axis}
\end{tikzpicture}

\end{document}

A: You can modify font size of labels and tick labels with label style={font=\tiny} and tick label style={font=\tiny}
\documentclass[tikz]{standalone}
\usepackage{pgfplots}

% axis style, ticks, etc
\pgfplotsset{every axis/.append style={
                    axis x line=middle,    % put the x axis in the middle
                    axis y line=middle,    % put the y axis in the middle
                    axis line style={<->}, % arrows on the axis
                    xlabel={$x$},          % default put x on x-axis
                    ylabel={$y$},          % default put y on y-axis
                    label style={font=\tiny},
                    tick label style={font=\tiny}
                    }}

% arrows as stealth fighters
\tikzset{>=stealth}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[
            xmin=-5,xmax=5,
        ymin=-5,ymax=5]
        \addplot [red,thick,domain=-2:2] ({cosh(x)}, {sinh(x)});
        \addplot [red,thick,domain=-2:2] ({-cosh(x)}, {sinh(x)});
        \addplot[red,dashed] expression {x};
        \addplot[red,dashed] expression {-x};
    \end{axis}
\end{tikzpicture}

\end{document}


text:
Q: organizing classes - help for an OOP beginner Examples I read of class structure typically begin with a base class and that base class gets extended with more refined classes ie. the often quoted:
class Animal {}
class Rodent extends Animal {}
class Mouse extends Rodent {}

But in my real world project of a CMS/ecommerce system I seem to be building this structure the other way around i.e. starting with a class for one type of situtation and extending it with something related to the whole project but not actually to the extending class.
class page {}
class product extends page{}
class category extends product{}
class basket extends category{}
class shop extends basket{}

So this way I am just calling $s = new shop() and getting access to all the classes/methods needed to run the shop. I suppose I am just extending the classes to save instantiating each one separately. This seems backwards to most examples I have read and I'm surely missing what OOP is all about here. My classes seem to be getting more general and less specialised as they get extended.
Should I continue in this way or restructure how I am building this class system?

A: What you're doing is using inheritance only as a way to reuse code, which is not really what it is meant for. Inheritance is meant to model a relationship that is described as is a (which also allow re-use of code).
A product is not a page, but a page might list products.
Take a look at http://en.wikipedia.org/wiki/Object-oriented_design for inspiration!

A: You could google composition over inheritance and is-a vs has-a.
In your design sketch, you mix up a bunch of stuff as you noticed. The easiest example to dissect would be class category{} extends product. One category is not a product, but it has/contains several products. This would be more suitable:
class product {
        public $title; // for simplicity
        public $price; // for simplicity
}
class category {
        private $name;
        private $products;
        public function __construct($name) {
                $this->name = $name;
                $this->products = array();
        }
        public function addProduct(product $p) {
                $this->products[] = $p;
        }
        public function printProducts() {
                $product_names = array_map(function($product) {
                        return $product->title;
                }, $this->products);
                echo implode(', ', $product_names);
        }
}

$c = new category('fruits');
$apple = new product;
$apple->title = 'apple';
$orange = new product;
$orange->title = 'orange';
$banana = new product;
$banana->title = 'banana';

$c->addProduct($apple);
$c->addProduct($orange);
$c->addProduct($banana);

$c->printProducts();

Notice how you keep both entities separated and let product worry about what a product is and can do, and what a category is (name), has (products) and can do (print a listing of its products).
Another tip for decoupling (minimizing dependencies between classes) is that you should try to keep data out of your objects for as long as possible. The classes in the example above are simplistic but functional. If you can make them work without database access (which is a common reason to have a huge chain of extends), you realize that none of these classes needs database access and that they instead can be filled/created by classes that do have access to the database. Something like this:
class category_factory {
  public function __construct(PDO $pdo) { $this->pdo = $pdo; }
  public function getCategories() {
    $rows = $this->pdo->query("SELECT * FROM categories")->fetchAll();
    $categories = array();
    foreach($rows as $row) {
      $categories[] = new category($row['name']);
    }
    return $categories;
  }
}

*PDO contains a db connection

A: You should read 'extends' as 'is a(n)'. A Mouse is a Rodent, a Rodent is an Animal. That's not the case with your other classes.
If the relation you're trying to realize can be described as 'has a(n)', you should use member variables.

A: Yes, you do seem to have got things backwards.
A category presumably is a group of products, similarly a basket. But since a basket might provide some of the same interface as a product (e.g. cost, weight) It'd be more likely to implement this as a collection of products rather than extending the product class. OTOH it doesn't make much sense to track the total cost of a category. So although both category and basket are collections of products, they are not otherwise closely related.
The 'page' entity doesn't make a lot of sense in relation to the product - certainly a product might have an instance of a page associated with it.
In PHP the class is not very important - what is important is the interface (i.e. what methods are exposed) so you don't need to stick to a rigid object hierarchy.

A: There should always be a logical relation between classes. Just think of products, categories, shop, as individual objects which is not in inheritance chain. These objects will be communicating using method calls, which is the real oops paradigm. Also you can identify some properties and methods that will be common in all these objects. So all these classes can extend a single parent class, say page.


text:
Q: Explicit type parameter Reading Java Generics and Collections book.
//given
public static <T> void copy(List<? super T> dst, List<? extends T> src) {
  ....
}

Now, it says - We could also declare the above method with several possible signatures.
public static <T> void copy(List<T> dst, List<T> src)                    1
public static <T> void copy(List<T> dst, List<? extends T> src)          2
public static <T> void copy(List<? super T> dst, List<T> src)            3
public static <T> void copy(List<? super T> dst, List<? extends T> src)  4

The first of these is too restrictive, as it only permits calls when the destination and source have exactly the same type(understood).
The remaining three are equivalent for calls that use implicit type parameters (understood - type inference algo will infer the appropriate type),
Confusing part -
but differ for explicit type parameters.
For the example calls above, the second signature works only when the type parameter is Object, the third signature works only when the type parameter is Integer.
Am confused because of what I tried (below)
public class AsList {
    public static void main (String...a) {
        List<Number> l4 = new ArrayList<Number>();
        List<Object> l5 = new ArrayList<Object>();
        List<Integer> l6 = new ArrayList<Integer>();

        //type is inferred implicitly for the below call
        copy(l4, Arrays.<Integer>asList(1, 2, 3));

        //type is specified explicitly
        AsList.<Number>copy(l4, Arrays.<Integer>asList(1, 2, 3));   \\why?  5
        AsList.<Object>copy(l5, Arrays.<Integer>asList(1, 2, 3));           6
        AsList.<Integer>copy(l6, Arrays.<Integer>asList(1, 2, 3));  \\why?  7
    }
    public static <T> void copy(List<T> dst, List<? extends T> src) {
        for (int i = 0; i < src.size(); i++) {
            dst.add(src.get(i));
        }
    }
}

Here, as per the Confusing part only statement 6 should have executed but 5 & 7 are also working. Why?
Edit
Example calls mentioned in the Confusing part are as below
Collections.copy(objs, ints);
Collections.<Object>copy(objs, ints);
Collections.<Number>copy(objs, ints);
Collections.<Integer>copy(objs, ints);

A: In case 5 the formal parameters are List<Number> and List<? extends Number>. Passing in a List<Number> and a List<Integer> is perfectly ok.
In case 7 the formal parameters are List<Integer> and List<? extends Integer>. Again passing in List<Integer> and List<Integer> is fine.


text:
Q: Loop takes more cycles to execute than expected in an ARM Cortex-A72 CPU Consider the following code, running on an ARM Cortex-A72 processor (optimization guide here). I have included what I expect are resource pressures for each execution port:

Instruction
B
I0
I1
M
L
S
F0
F1

.LBB0_1:

ldr     q3, [x1], #16

0.5
0.5

1

ldr     q4, [x2], #16

0.5
0.5

1

add     x8, x8, #4

0.5
0.5

cmp     x8, #508

0.5
0.5

mul     v5.4s, v3.4s, v4.4s

2

mul     v5.4s, v5.4s, v0.4s

2

smull   v6.2d, v5.2s, v1.2s

1

smull2  v5.2d, v5.4s, v2.4s

1

smlal   v6.2d, v3.2s, v4.2s

1

smlal2  v5.2d, v3.4s, v4.4s

1

uzp2    v3.4s, v6.4s, v5.4s

1

str     q3, [x0], #16

0.5
0.5

1

b.lo    .LBB0_1
1

Total port pressure
1
2.5
2.5
0
2
1
8
1

Although uzp2 could run on either the F0 or F1 ports, I chose to attribute it entirely to F1 due to high pressure on F0 and zero pressure on F1 other than this instruction.
There are no dependencies between loop iterations, other than the loop counter and array pointers; and these should be resolved very quickly, compared to the time taken for the rest of the loop body.
Thus, my intuition is that this code should be throughput limited, and considering the worst pressure is on F0, run in 8 cycles per iteration (unless it hits a decoding bottleneck or cache misses). The latter is unlikely given the streaming access pattern, and the fact that arrays comfortably fit in L1 cache. As for the former, considering the constraints listed on section 4.1 of the optimization manual, I project that the loop body is decodable in only 8 cycles.
Yet microbenchmarking indicates that each iteration of the loop body takes 12.5 cycles on average. If no other plausible explanation exists, I may edit the question including further details about how I benchmarked this code, but I'm fairly certain the difference can't be attributed to benchmarking artifacts alone. Also, I have tried to increase the number of iterations to see if performance improved towards an asymptotic limit due to startup/cool-down effects, but it appears to have done so already for the selected value of 128 iterations displayed above.
Manually unrolling the loop to include two calculations per iteration decreased performance to 13 cycles; however, note that this would also duplicate the number of load and store instructions. Interestingly, if the doubled loads and stores are instead replaced by single LD1/ST1 instructions (two-register format) (e.g. ld1 { v3.4s, v4.4s }, [x1], #32) then performance improves to 11.75 cycles per iteration. Further unrolling the loop to four calculations per iteration, while using the four-register format of LD1/ST1, improves performance to 11.25 cycles per iteration.
In spite of the improvements, the performance is still far away from the 8 cycles per iteration that I expected from looking at resource pressures alone. Even if the CPU made a bad scheduling call and issued uzp2 to F0, revising the resource pressure table would indicate 9 cycles per iteration, still far from actual measurements. So, what's causing this code to run so much slower than expected? What kind of effects am I missing in my analysis?
EDIT: As promised, some more benchmarking details. I run the loop 3 times for warmup, 10 times for say n = 512, and then 10 times for n = 256. I take the minimum cycle count for the n = 512 runs and subtract from the minimum for n = 256. The difference should give me how many cycles it takes to run for n = 256, while canceling out the fixed setup cost (code not shown). In addition, this should ensure all data is in the L1 I and D cache. Measurements are taken by reading the cycle counter (pmccntr_el0) directly. Any overhead should be canceled out by the measurement strategy above.

A: First off, you can further reduce the theoretical cycles to 6 by replacing the first mul with uzp1 and doing the following smull and smlal the other way around: mul, mul, smull, smlal => smull, uzp1, mul, smlal
This also heavily reduces the register pressure so that we can do an even deeper unrolling (up to 32 per iteration)
And you don't need v2 coefficents, but you can pack them to the higher part of v1
Let's rule out everything by unrolling this deep and writing it in assembly:
    .arch armv8-a
    .global foo
    .text

.balign 64
.func

// void foo(int32_t *pDst, int32_t *pSrc1, int32_t *pSrc2, intptr_t count);
pDst    .req    x0
pSrc1   .req    x1
pSrc2   .req    x2
count   .req    x3

foo:

// initialize coefficients v0 ~ v1

    stp     d8, d9, [sp, #-16]!

.balign 64
1:
    ldp     q16, q18, [pSrc1], #32
    ldp     q17, q19, [pSrc2], #32
    ldp     q20, q22, [pSrc1], #32
    ldp     q21, q23, [pSrc2], #32
    ldp     q24, q26, [pSrc1], #32
    ldp     q25, q27, [pSrc2], #32
    ldp     q28, q30, [pSrc1], #32
    ldp     q29, q31, [pSrc2], #32

    smull   v2.2d, v17.2s, v16.2s
    smull2  v3.2d, v17.4s, v16.4s
    smull   v4.2d, v19.2s, v18.2s
    smull2  v5.2d, v19.4s, v18.4s
    smull   v6.2d, v21.2s, v20.2s
    smull2  v7.2d, v21.4s, v20.4s
    smull   v8.2d, v23.2s, v22.2s
    smull2  v9.2d, v23.4s, v22.4s
    smull   v16.2d, v25.2s, v24.2s
    smull2  v17.2d, v25.4s, v24.4s
    smull   v18.2d, v27.2s, v26.2s
    smull2  v19.2d, v27.4s, v26.4s
    smull   v20.2d, v29.2s, v28.2s
    smull2  v21.2d, v29.4s, v28.4s
    smull   v22.2d, v31.2s, v20.2s
    smull2  v23.2d, v31.4s, v30.4s

    uzp1    v24.4s, v2.4s, v3.4s
    uzp1    v25.4s, v4.4s, v5.4s
    uzp1    v26.4s, v6.4s, v7.4s
    uzp1    v27.4s, v8.4s, v9.4s
    uzp1    v28.4s, v16.4s, v17.4s
    uzp1    v29.4s, v18.4s, v19.4s
    uzp1    v30.4s, v20.4s, v21.4s
    uzp1    v31.4s, v22.4s, v23.4s

    mul     v24.4s, v24.4s, v0.4s
    mul     v25.4s, v25.4s, v0.4s
    mul     v26.4s, v26.4s, v0.4s
    mul     v27.4s, v27.4s, v0.4s
    mul     v28.4s, v28.4s, v0.4s
    mul     v29.4s, v29.4s, v0.4s
    mul     v30.4s, v30.4s, v0.4s
    mul     v31.4s, v31.4s, v0.4s

    smlal   v2.2d, v24.2s, v1.2s
    smlal2  v3.2d, v24.4s, v1.4s
    smlal   v4.2d, v25.2s, v1.2s
    smlal2  v5.2d, v25.4s, v1.4s
    smlal   v6.2d, v26.2s, v1.2s
    smlal2  v7.2d, v26.4s, v1.4s
    smlal   v8.2d, v27.2s, v1.2s
    smlal2  v9.2d, v27.4s, v1.4s
    smlal   v16.2d, v28.2s, v1.2s
    smlal2  v17.2d, v28.4s, v1.4s
    smlal   v18.2d, v29.2s, v1.2s
    smlal2  v19.2d, v29.4s, v1.4s
    smlal   v20.2d, v30.2s, v1.2s
    smlal2  v21.2d, v30.4s, v1.4s
    smlal   v22.2d, v31.2s, v1.2s
    smlal2  v23.2d, v31.4s, v1.4s

    uzp2    v24.4s, v2.4s, v3.4s
    uzp2    v25.4s, v4.4s, v5.4s
    uzp2    v26.4s, v6.4s, v7.4s
    uzp2    v27.4s, v8.4s, v9.4s
    uzp2    v28.4s, v16.4s, v17.4s
    uzp2    v29.4s, v18.4s, v19.4s
    uzp2    v30.4s, v20.4s, v21.4s
    uzp2    v31.4s, v22.4s, v23.4s

    subs    count, count, #32

    stp     q24, q25, [pDst], #32
    stp     q26, q27, [pDst], #32
    stp     q28, q29, [pDst], #32
    stp     q30, q31, [pDst], #32

    b.gt    1b
.balign 16
    ldp     d8, d9, [sp], #16
    ret

.endfunc
.end

The code above has zero latency even in-order. The only thing that could affect the performance would be cache miss penalty.
You can measure the cycles, and if it far exceeds 48 per iteration, there must be something wrong with the chip or the document.
Otherwise, the OoO engine of A72 might be lackluster as Peter pointed out.
PS: Or the load/store ports might be not issuing in parallel on A72. This makes sense given your unrolling experiment.

A: Starting from Jake's code, reducing the unrolling factor by half, changing some of the register allocation, and trying many different variations of load/store instructions (as well as different addressing modes) and instruction scheduling, I finally arrived at the following solution:
    ld1     {v16.4s, v17.4s, v18.4s, v19.4s}, [pSrc1], #64
    ld1     {v20.4s, v21.4s, v22.4s, v23.4s}, [pSrc2], #64

    add     count, pDst, count, lsl #2

    // initialize v0/v1

loop:
    smull   v24.2d, v20.2s, v16.2s
    smull2  v25.2d, v20.4s, v16.4s
    uzp1    v2.4s, v24.4s, v25.4s

    smull   v26.2d, v21.2s, v17.2s
    smull2  v27.2d, v21.4s, v17.4s
    uzp1    v3.4s, v26.4s, v27.4s

    smull   v28.2d, v22.2s, v18.2s
    smull2  v29.2d, v22.4s, v18.4s
    uzp1    v4.4s, v28.4s, v29.4s

    smull   v30.2d, v23.2s, v19.2s
    smull2  v31.2d, v23.4s, v19.4s
    uzp1    v5.4s, v30.4s, v31.4s

    mul     v2.4s, v2.4s, v0.4s
    ldp     q16, q17, [pSrc1]
    mul     v3.4s, v3.4s, v0.4s
    ldp     q18, q19, [pSrc1, #32]
    add     pSrc1, pSrc1, #64

    mul     v4.4s, v4.4s, v0.4s
    ldp     q20, q21, [pSrc2]
    mul     v5.4s, v5.4s, v0.4s
    ldp     q22, q23, [pSrc2, #32]
    add     pSrc2, pSrc2, #64

    smlal   v24.2d, v2.2s, v1.2s
    smlal2  v25.2d, v2.4s, v1.4s
    uzp2    v2.4s, v24.4s, v25.4s
    str     q24, [pDst], #16

    smlal   v26.2d, v3.2s, v1.2s
    smlal2  v27.2d, v3.4s, v1.4s
    uzp2    v3.4s, v26.4s, v27.4s
    str     q25, [pDst], #16

    smlal   v28.2d, v4.2s, v1.2s
    smlal2  v29.2d, v4.4s, v1.4s
    uzp2    v4.4s, v28.4s, v29.4s
    str     q26, [pDst], #16

    smlal   v30.2d, v5.2s, v1.2s
    smlal2  v31.2d, v5.4s, v1.4s
    uzp2    v5.4s, v30.4s, v31.4s
    str     q27, [pDst], #16

    cmp     count, pDst
    b.ne    loop

Note that, although I have carefully reviewed the code, I haven't tested whether it actually works, so there may be something missing that would impact performance. A final iteration of the loop, removing the load insructions, is required to prevent an out-of-bounds memory access; I omitted this to save some space.
Performing a similar analysis as to that of the original question, assuming the code is fully throughput-limited, would suggest that this loop would take 24 cycles. Normalizing to the same metric as used elsewhere (i.e. cycles per 4-element iteration), this would work out to 6 cycles/iteration. Benchmarking the code resulting in 26 cycles per loop execution, or in the normalized metric, 6.5 cycles/iteration. While not the bare minimum supposedly achievable, it comes very close to this.
Some notes for anyone else who stumbles across this question, after scratching their heads about Cortex-A72 performance:

*

*The schedulers (reservation stations) are per-port rather than global (see this article and this block diagram). Unless your code has a very balanced instruction mix among loads, stores, scalar, Neon, branches, etc., then the OoO window will be smaller than you would expect, sometimes very much so. This code in particular is a pathological case for per-port schedulers. since 70% of all instructions are Neon, and 50% of all instructions are multiplications (which only run on the F0 port). For these multiplications, the OoO window is a very anemic 8 instructions, so don't expect the CPU to be looking at the next loop iteration's instructions while executing the current iteration.

*Attempting to further reduce the unrolling factor by half results in a large (23%) slowdown. My guess for the cause is the shallow OoO window, due to the per-port schedulers and the high prevalence of instructions bound to port F0, as explained in point 1 above. Without being able to look at the next iteration, there is less parallelism to be extracted, so the code becomes latency- rather than throughput-bound. Thus, it appears that interleaving multiple iterations of a loop is an important optimization strategy to consider for this core.

*One must pay attention to the specific addressing mode used for loads. Replacing the immediate post-index addressing mode used in the original code with immediate offset, and then manually performing incrementing the pointers elsewhere, resulted in performance gains, but only for the loads (stores were unaffected). In section 4.5 ("Load/Store Throughput") of the optimization manual, this is hinted in the context of a memory copy routine, but no rationale is given. However, I believe this is explained by point 4 below.

*Apparently the main bottleneck of this code is writing to the register file: according to this answer to another SO question, the register file only supports writing 192 bits per cycle. This may explain why loads should avoid the use of addressing modes with writeback (pre- and post-index), as this consumes an extra 64 bits writing the result back to the register file. It's all too easy to exceed this limit while using Neon instructions and vector loads (even more so when using LDP and 2/3/4-register versions of LD1), without the added pressure of writing back the incremented address. Knowing this, I also decide to replace the original subs in Jake's code with a comparison to pDst, since comparisons don't write to the register file -- and this actually improved performance by 1/4 of a cycle.
Interestingly, adding up the number of bits written to the register file during one execution of the loop results in 4992 bits (I have no idea whether writes to PC, specifically by the b.ne instruction, should be included in the tally or not; I arbitrarily chose not to). Given the 192-bit/cycle limit, this works out to a minimum of 26 cycles to write all these results to the register file across the loop. So it appears that the code above can't be made faster by rescheduling instructions alone.
Theoretically it might be possible to shed 1 cycle by switching the addressing mode of the stores to immediate offset, and then including an extra instruction to explicitly increment pDst. For the original code, each of the 4 stores would write 64 bits to pDst, for a total of 256 bits, compared to a single 64-bit write if pDst were explicitly incremented once. Thus, this change would result in saving 192 bits, i.e., 1 cycle's worth of register file writes. I attempted this change, trying to schedule the increments of pSrc1/pSrc2/pDst across many different points of the code, but unfortunately I was only able to slow down rather than speed up the code. Perhaps I am hitting a different bottleneck such as instruction decoding.

A: I revisited the problem recently, and although Jake's approach of replacing mul with uzp1 is a definite improvement, I was still curious as to whether I could get closer to the expected 8 cycles/iteration using the original approach.
I implemented a 6-stage software pipeline using C and intrinsics:
load → mul/smull/smull2 → mul → smlal/smlal2 → uzp2 → store
Compiling with clang and using #pragma clang loop unroll_count(6) for the main loop, I was able to achieve ~8.9 cycles per iteration. It is possible that experimenting with ldp/stp and ld1/st1 might yield even better results.
Thus, software pipelining might be a profitable avenue to explore in the Cortex-A72, in order to overcome the short OOO window due to per-port scheduling queues, if most instructions execute on a limited number of ports (or even a single one).


text:
Q: while reading the file through python, prints file printed successfully after each printed line but after one empty line, why? I am trying to learn python in this lockdown. I am completely new to programming. I am practicing to read a file. The code used with the results is in the first screenshot. I noticed that after every line it reads and prints from the file it prints the statement file printed successfully. But prints that after one empty line. So, if the file which has to be read has an empty line it prints an empty line, and then after one more empty line, it prints file printed successfully. Is it possible to print the file printed successfully exactly below the printed line without any blank line? Could you please help me out? I am stuck in this.
The code used is below:
fileptr = open(r"C:\Users\Owner\PycharmProjects\untitled\Day1.py")
for line in fileptr.readlines():
    if '#' in line:
        print(line)
print("file is opened successfully")

A: Didn't quite get what u want to do, but here I go.
Okay so, what's happening here is that in the text file whenever u proceeds to next line for that there's a '\n' which tells python it's a new line and since you are in a loop puts the '\n' in a new line leaving blank space therefore, you must be getting a blank line. The indentation is not clear but if u want the "printed successfully" to be printed just once then this statement should be out of the 'for loop'.
To print "print sucessfully" after each line but without an empty line you can use a method called '.rstrip()' inside which u can give the parameter '\n'(using the inverted commas). This will remove the "\n" from each line that will be printed.


text:
Q: Transform equal function handles to other equal function handles Minimalistic Example:
classdef MyClass
properties
    arr
    handArr
end
properties(Dependent)
    rowAcc
    colAcc
end
methods
    function obj = MyClass(arr, handRow, handCol)
        obj.arr = arr;
        obj.handArr{1} = handRow;
        if ~isequal(handRow, handCol)
            obj.handArr{2} = handCol;
        end
    end
    function r = get.rowAcc(obj)
        r = obj.handArr{1}(obj.arr);
    end
    function c = get.colAcc(obj)
        c = obj.handArr{end}(obj.arr);
    end
end
end

Now assume I pass equal functions to the constructor, I want the row and col access would also be the same:
f=@(x)@(y) y;
x=MyClass(1, f, f);
isequal(x.rowAcc, x.colAcc) //should be 1

Is this possible?
I have a good reason for this 'insane' requirement:
I have several algorithms which run with 100+ MBs of input and takes those two functions as input, and when they are equal they can be optimized very efficiently; to call the algorithms I need to make transformations to the input functions which are encapsulated inside this class. I can't change the algorithms (not my code) and they use isequal on they're own functions to dispatch.

A: Two variables pointing to the same anonymous function are considered to be equal
f = @(x)x;
g = f;

isequal(f, g)
%   1

However, if you define the anonymous functions at different times, then they are not considered to be equal because the internal workspaces of the two functions could differ.
f = @(x)x;
g = @(x)x;

isequal(f, g)
%   0

In order to have your property return equal handles, you could have some "shadow" property (accessors_) which caches the accessors and you update these cached values whenever the arr property is changed.
classdef MyClass

    properties
        arr
        handArr
    end

    properties (Access = 'protected')
        accessors_      % An array of accessor functions for rows & columns
    end

    properties (Dependent)
        rowAcc
        colAcc
    end

    methods
        function set.arr(obj, value)
            % Set the value
            obj.arr = value;

            % Update the accessors_
            self.accessors_ = obj.handArr{1}(obj.arr);

            % Only assign another accessor if we have a second one
            if numel(obj.handArr) > 1
                self.accessors_(2) = obj.handArr{2}(obj.arr);
            end
        end

        function res = get.rowAcc(obj)
            res = obj.accessors_(1);
        end

        function res = get.colAcc(obj)
            % If only one was stored, this will return a duplicate of it
            res = obj.accessors_(end);
        end
    end
end

This also has the added benefit that you aren't creating function handles every time that colAcc and rowAcc are retrieved.


text:
Q: How to undo effects of freopen when launching a shell? A piece of code ties stdout to a file in C using freopen. After this piece of code, a script is executed which launches a shell. The problem is now that all stdout output is going into that file, so any commands run in that shell are being placed in that file.
I've arrived at this script that launches the shell:
/bin/sh 1>&2 2>&1

Although it prints to the screen, I am not sure how I can verify that it is actually printing to stdout vs stderr. Can someone verify that I've gotten the IO redirection right?
EDIT:
I do not have access to the program that calls freopen, just the script to run.

A: Your shell fragment:

*

*Makes standard output (1) go to the place where standard error (2) is currently going; and

*Makes standard error (2) go to the place where standard output (1) is currently going.

The second operation is not needed.
Original answer
More seriously, if the piece of code is invoked with its standard error going to a file, then the shell's output is going to go to the same file.  If you really want it to go to the same place as the original standard output, you need to preserve the original standard output before redirecting with freopen().  You'd do that with:
int fd1 = dup(FILENO_STDOUT);

...now do freopen...

dup2(fd1, FILENO_STDOUT);
close(fd1);

...now launch shell...without I/O redirection

Revised answer
Given the scenario:

*

*A login shell is used to run a program Program-A (for which you don't have the source, and which uses freopen() on standard output)

*Program-A runs Program-B (which is a shell script that ends up launching an interactive shell, using the /bin/sh 1>&2 2>&1 notation)

And assuming you want the standard output of the interactive shell to go to the original standard output, then you can do this with the following code:
launch.sh
Runs Program-A with extra I/O redirections and environment variables set:
set -x
fd -n 32
exec 3>&1
echo "$0: $@"
fd -n 32
FD_COPY_STDIN=3 exec ./Program-A "$@"

The fd program prints o for a file descriptor that's open and a - for a file descriptor that's closed.  The -n 32 specifies 'print status for first 32 file descriptors' (by default, it prints for all possible file descriptors, but hundreds of lines consisting of 64 dashes is very boring to read).
Program-A
Shell script simulating your non-modifiable program.  It runs Program-B after changing standard output to go to a file (standard.output).
set -x
echo "$0: $@"
# Simulate freopen("./standard.output", "w", stdout);
exec 1> ./standard.output
echo "$0: $@"
fd -n 32
exec ./Program-B "$@"

(You could, if you preferred, remove the last exec and then echo something after Program-B exits.)
Program-B
This is your revised script — the program run by Program-A:
echo "$0: $@"
fd -n 32

exec 1>&${FD_COPY_STDOUT:-3}
exec 3>&- 2>&1
echo "$0: $@"
fd -n 32
exec ${SHELL} -i

(Again, it would be possible to delete the final exec and do something else afterwards in the script.)
The -i option invokes an interactive shell.  The 2>&1 redirects standard error to the same place that standard output is going.  The interactive shell prompts on standard error (as I found out again the hard way — though I'd come across the behaviour before).
Example runs
The isodate command is equivalent to date +'%Y-%m-%d %H:%M:%S'.  My standard prompt on machine osiris is Osiris JL:.
Without standard error redirected to a file:
Osiris JL: ls
launch.sh  Program-A  Program-B
Osiris JL: bash launch.sh $(isodate)
+ fd -n 32
ooo-----------------------------
+ exec
+ echo 'launch.sh: 2014-05-20' 17:03:59
launch.sh: 2014-05-20 17:03:59
+ fd -n 32
oooo----------------------------
+ FD_COPY_STDIN=3
+ exec ./Program-A 2014-05-20 17:03:59
+ echo '/home/jleffler/soq/New/Program-A: 2014-05-20' 17:03:59
/home/jleffler/soq/New/Program-A: 2014-05-20 17:03:59
+ exec
+ echo '/home/jleffler/soq/New/Program-A: 2014-05-20' 17:03:59
+ fd -n 32
+ exec ./Program-B 2014-05-20 17:03:59
/home/jleffler/soq/New/Program-B: 2014-05-20 17:03:59
ooo-----------------------------
jleffler@osiris:~/soq/New$ ls -l
total 16
-rwxr----- 1 jleffler eng 100 May 20 17:02 launch.sh
-rwxr----- 1 jleffler eng 158 May 20 17:02 Program-A
-rwxr----- 1 jleffler eng 121 May 20 17:02 Program-B
-rw-r----- 1 jleffler eng 208 May 20 17:03 standard.output
jleffler@osiris:~/soq/New$ exit
exit
Osiris JL:

With standard error redirected to a file:
Osiris JL: bash launch.sh $(isodate) 2>standard.error
ooo-----------------------------
launch.sh: 2014-05-20 17:05:11
oooo----------------------------
/home/jleffler/soq/New/Program-A: 2014-05-20 17:05:11
/home/jleffler/soq/New/Program-B: 2014-05-20 17:05:11
ooo-----------------------------
jleffler@osiris:~/soq/New$ ls -l
total 20
-rwxr----- 1 jleffler eng 100 May 20 17:02 launch.sh
-rwxr----- 1 jleffler eng 158 May 20 17:02 Program-A
-rwxr----- 1 jleffler eng 121 May 20 17:02 Program-B
-rw-r----- 1 jleffler eng 343 May 20 17:05 standard.error
-rw-r----- 1 jleffler eng 208 May 20 17:05 standard.output
jleffler@osiris:~/soq/New$ exit
exit
Osiris JL: cat standard.error
+ fd -n 32
+ exec
+ echo 'launch.sh: 2014-05-20' 17:05:11
+ fd -n 32
+ FD_COPY_STDIN=3
+ exec ./Program-A 2014-05-20 17:05:11
+ echo '/home/jleffler/soq/New/Program-A: 2014-05-20' 17:05:11
+ exec
+ echo '/home/jleffler/soq/New/Program-A: 2014-05-20' 17:05:11
+ fd -n 32
+ exec ./Program-B 2014-05-20 17:05:11
Osiris JL: cat standard.output
/home/jleffler/soq/New/Program-A: 2014-05-20 17:05:11
oooo----------------------------
/home/jleffler/soq/New/Program-B: 2014-05-20 17:05:11
oooo----------------------------
Osiris JL:


text:
Q: Database reports option is disabled in SQL Server I restored the database from a .bak file by running a PowerShell script. Today, when I tried to check the database with "Reports", I noticed it had been disabled. See the screenshot:

Not quite sure whether there is anything wrong with the script I used to restore the database, but here it is:
$restoredDbName = "dbx"

[string] $dbCommand = "RESTORE DATABASE [$($restoredDbName)] " +
                    "FROM    DISK = N'$($bakFilePath)' " +
                    "WITH    FILE = 1," +
                    "MOVE N'$($fileLogicalName)' TO     N'$($restorePathD)\$($restoredDbName).mdf'," +
                    "MOVE N'$($fileLogicalName)_Log' TO N'$($restorePathD)\$($restoredDbName)_Log.ldf',"

if($bakFilename.Contains("xyz")) {
    $dbCommand += "MOVE N'abc' TO N'$($restorePathD)\$($restoredDbName).ndf',"
}

$dbCommand += "NOUNLOAD,  REPLACE,  STATS = 1"

A: It is because your SSMS is of older version than the one required to be compatible with your running version of sql server instance.
Try upgrading your ssms. This should solve the problem.

A: Few things to try:
It could be a IIS Role that is not installed correctly.
Common HTTP Features (Select All)
Application Development (Select ASP .NET)
Security (Windows Authentication)
It could be that SSMS is not running as an Admin 'Run as Administrator' i.e. right-click on the SSMS icon or menu option and opt to 'Run as Administrator'. Give this a try.
I am sure its not the PowerShell script.
Also, I see a few issues in your PowerShell script to SQL. This is my goto script for restoring databases.
$DBName="RestoreDB"
$fileLogicalName_DATA="XYZ"
$fileLogicalName_LOG="XYZ_LOG"
$backupFilePath="D:\RestoreDB.bak"
$Datafilepath="D:\DataStore" #Do not add the trailing \
$Logfilepath="D:\LogStore" #Do not add the trailing \
$dbCommand = "use [master];RESTORE DATABASE [$DBName] " + "FROM DISK = N'$backupFilePath'" + "WITH FILE = 1, NOUNLOAD, STATS = 10, " + "move '$fileLogicalName_DATA' to '$Datafilepath" + "\" + "$DBName" + "_data.mdf', " + "move '$fileLogicalName_LOG' to '$Logfilepath" + "\" + "$DBName" + "_log.ldf';" + "alter database [$DBName] modify file (name=N'$fileLogicalName_DATA', newname=N'$DBName" + "_data');" + "alter database [$DBName] modify file (name=N'$fileLogicalName_LOG', newname=N'$DBName" + "_log');" + "alter database [$DBName] set read_committed_snapshot on with rollback immediate;" + "alter database [$DBName] set COMPATIBILITY_LEVEL = 100;"
sqlcmd -S $DBServerName -E -Q $dbCommand -r0


text:
Q: ¿Alguien sabe cómo trabajar con datos de ficheros? Quiero trabajar con los datos de este fichero, pero no sé cómo, tan sólo sé abrir el archivo y leerlo, pero no sé cómo identificar línea por línea, diferenciar frases, etc.
Los datos satisfacen los siguientes términos:

*

*cause_of_death: Causa de muerte registrada.

*Date: fecha en formato YYYMMDD, por ejemplo: 20180523

*Dead: cantidad de muertes confirmadas asociadas al evento.

*Missing: cantidad de desaparecidos asociados al evento.

*Latitude: latitud asociada al evento.

*Longitude: longitud asociada al evento.

migraciones.txt

drowned 20150430 41 12 540 131.42
drowned 20150430 13 3 510 173.56
car_accident 20150430 1 63 501 132.57
shot_by_police 20150430 53 3 630 163.51

A:
No sé cómo identificar línea por línea, diferenciar frases, etc.

Por lo que veo, tu archivo es de texto, así que podrás usar el operador de extracción de datos (>>) de los flujos (stream) de datos:
struct muertes
{
    std::string motivo;
    unsigned int fecha;
    unsigned int muertos;
    unsigned int desaparecidos;
    float latitud;
    float longitud;
};

if (std::ifstream migraciones{"migraciones.txt"})
{
    muertes m;
    migraciones >> m.motivo;
    migraciones >> m.fecha;
    migraciones >> m.muertos;
    migraciones >> m.desaparecidos;
    migraciones >> m.latitud;
    migraciones >> m.longitud;
}

Si haces que la lectura esté en un bucle, puedes leer línea por línea:
if (std::ifstream migraciones{"migraciones.txt"})
{
    muertes m;
    while (migraciones >> m.motivo &&
        migraciones >> m.fecha &&
        migraciones >> m.muertos &&
        migraciones >> m.desaparecidos &&
        migraciones >> m.latitud &&
        migraciones >> m.longitud)
    {
        // Tratar los datos.
    }
}

Puedes ver el código funcionando en Wandbox 三へ( へ՞ਊ ՞)へ ハッハッ.


text:
Q: How to use python to read and write a register via LLDB? I'm trying to use python to read/write a register when it hits the breakpoint.
I was able to execute a simple python script when a breakpoint is triggered.
The problem I'm having is reading and writing a single register. I can get a list of registers, but not a register.
* thread #1, stop reason = signal SIGSTOP
    frame #0: 0x000000010521562c dyld` ImageLoaderMachO::usablePrebinding(ImageLoader::LinkContext const&) const  + 56
dyld`ImageLoaderMachO::usablePrebinding:
->  0x10521562c <+56>: ldrb   w8, [x19, #0x76]
    0x105215630 <+60>: ldrh   w9, [x19, #0x74]
    0x105215634 <+64>: bfi    w9, w8, #16, #8
    0x105215638 <+68>: tbz    w9, #0x9, 0x105215694     ; <+160>
    0x10521563c <+72>: ldr    x8, [x19]
    0x105215640 <+76>: ldr    x8, [x8, #0x378]
    0x105215644 <+80>: mov    x0, x19
    0x105215648 <+84>: blr    x8
Target 0: (BBM) stopped.
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> print lldb.frame.registers

Can anyone help me which python api I can use to change the x1 register value?

A: The registers property on SBFrames is an SBValueList that stores the sets of registers (GPR's, etc.).  Each register set is an SBValue, and the individual registers are represented as children of the register set, with the child name being the register name.  x1 is a GPR, and the GPR's are always the first register set in registers.  SBValueList also GetFirstValueByName to get an  element by name, so you can also find the "General Purpose Register"'s programmatically.
So you would do something like:
error = lldb.SBError()
did_change = lldb.frame.registers[0].GetChildMemberWithName('x1').SetValueFromCString("0x12345",error)

SetValueFromCString returns True if it was able to change the value, and if it wasn't, the reason why will be stored in the error parameter.
Note that volatile registers like x1 aren't stored across function calls, so you can only access or change their values in the currently executing frame.
SBValues are described here:
https://lldb.llvm.org/python_reference/lldb.SBValue-class.html
if you want to know what else you can do with them.

A: An alternative to the registers property, is the register property. It's a convenience for accessing registers by name. For example:
(lldb) script print lldb.frame.register["x1"].value
(lldb) script lldb.frame.register["x1"].value = "0"

A: @Dave Lee's answer worked in the script interface of lldb.
When I tried the same in a full script, I was getting null register values.
The documentation https://lldb.llvm.org/use/python-reference.html explained all.  You needed to pass in exe_ctx to get the correct context.  This was the lldb.SBExecutionContext.
def YDFooBarFunction(debugger, command, exe_ctx, result, internal_dict):
    """
        Reads and writes a register.
    """
    frame = exe_ctx.frame
    error = lldb.SBError()
    disposition = frame.FindRegister("rsi")
    print("[*]Original register: " + str(disposition))

    if disposition.unsigned == 2:
        print "[!]found 2 in the register"
        result = frame.registers[0].GetChildMemberWithName('rsi').SetValueFromCString("0x1", error)
        messages = {None: 'error', True: 'pass', False: 'fail'}
        print ("[*]PATCHING result: " + messages[result])

    thread = frame.GetThread()
    process = thread.GetProcess()
    process.Continue()

I hope this saves people hours of hunting.
Note, I used part of the great man's ( @Jim Ingham's ) answer to write a register.


text:
Q: Get YouTube Video Views YouTube API I'm creating an app for my YouTube channel using the YouTube API. I'm getting the videos from a playlist using Alamofire by doing this:
let parameters = ["part":"snippet","maxResults":50,"channelId":CHANNEL_ID,"playlistId":UPLOADS_PLAYLIST_ID,"key":API_KEY] as [String : Any]

class VideoModel: NSObject {

    var videoArray = [Video]()

    func getFeedVideo() {
        Alamofire.request("https://www.googleapis.com/youtube/v3/playlistItems", parameters: parameters, encoding: URLEncoding.default, headers: nil).responseJSON { (response) in

            if let JSON = response.result.value {

                if let dictionary = JSON as? [String: Any] {

                    var arrayOfVideos = [Video]()

                    guard let items = dictionary["items"] as? NSArray else { return }

                    for items in dictionary["items"] as! NSArray {
                        print(items)
                        //  Create video objects off of the JSON response

                        let videoObj = Video()
                        videoObj.videoID = (items as AnyObject).value(forKeyPath: "snippet.resourceId.videoId") as! String
                        videoObj.videoTitle = (items as AnyObject).value(forKeyPath: "snippet.title") as! String
                        videoObj.videoDescription = (items as AnyObject).value(forKeyPath: "snippet.description") as! String
                        videoObj.videoThumbnailUrl = (items as AnyObject).value(forKeyPath: "snippet.thumbnails.maxres.url") as! String

                        arrayOfVideos.append(videoObj)

                    }
                    self.videoArray = arrayOfVideos
                    if self.delegate != nil {
                        self.delegate!.dataReady()
                    }
                }
            }
        }
    }

I've been searching around, and I can't find a simple way to do this. I found an answer like this one: How to get number of video views with YouTube API? But, I'm using Swift. Does anyone have any ideas?

A: Working solution. I'd use Decodable instead of raw JSON but I followed your code for the last request.
let apiKey = "API_KEY"
let playlistId = "PLAYLIST_ID"
let url = URL(string: "https://www.googleapis.com/youtube/v3/playlistItems?playlistId=\(playlistId)&maxResults=25&part=snippet%2CcontentDetails&key=\(apiKey)")!

// Get videos
Alamofire.request(url).responseJSON { (response) in

    guard let JSON = response.result.value,
        let dictionary = JSON as? [String: Any],
        let items = dictionary["items"] as? [AnyObject]
        else { return }

    let videos: [Video] = items.map {
        let videoObj = Video()
        videoObj.videoID = $0.value(forKeyPath: "snippet.resourceId.videoId") as! String
        videoObj.videoTitle = $0.value(forKeyPath: "snippet.title") as! String
        videoObj.videoDescription = $0.value(forKeyPath: "snippet.description") as! String
        videoObj.videoThumbnailUrl = $0.value(forKeyPath: "snippet.thumbnails.default.url") as! String
        return videoObj
    }

    let videoIds = videos.map({ $0.videoID }).joined(separator: ",")
    let statsUrl = URL(string: "https://www.googleapis.com/youtube/v3/videos?part=statistics&id=\(videoIds)&key=\(apiKey)")!

    // Get view count for all videos
    Alamofire.request(statsUrl).responseJSON { (response) in

        guard let JSON = response.result.value,
            let dictionary = JSON as? [String: Any],
            let items = dictionary["items"] as? [AnyObject]
            else { return }

        for i in 0..<items.count {
            let views = items[i].value(forKeyPath: "statistics.viewCount") as! String
            videos[i].viewCount = Int(views)!
        }

        print(videos)
    }
}


text:
Q: How to hide a popup after time elapses in Java/GWT
Possible Duplicate:
How can we count the time of process?

I have a pop-up dialog that pops up after a user had saved a value. I want the popup to disappear after 2 seconds. Somthing like
if(timeElapsed(2 seconds)){
    popup.hide()
}

The related questions I saw measure the running time of a function. How can I run a dummy loop for 2 seconds and then call the hide function?

A: You can define a Timer in your popup panel. Next you can init the Timer in the show() method like this:
Timer t = new Timer() {
  public void run() {
    Popup.this.hide();
  }
}

t.schedule(2000);

This will start the timer when the popup is first showed. When the timer expires, the popup will be hidden.
Eventually you can define the timer as a global variable in the popup and use a boolean to see if the timer is running, so that if you need to display the popup again while an instance is still showing, you won't start a new timer.


text:
Q: Raster to polygon conversion's raster field takes only "Value" Recently I am working with raster data and arcobjects.net. Here I find something new for me. And here some question arises in my mind. I tried to search some document that can satisfy my mind, but I couldn't find. Any pointer or document or link would be helpful.
When I perform Raster to polygon conversion's, fourth parameter is raster_field. Sometimes I can give either "Value" field or "Count" field in it, sometimes, its only "Value" field. when and why? When does it take only "Value" field?

A: Would that be any help for you- Raster dataset attribute tables?

A: You can use Calculate Geometry if I got your problem correctly.

*

*Add a new Field (while Editor Closed)>

*Start The Editor

*Right click on field Name

*click Field Calculator


text:
Q: How do I determine whether the filesystem is case-sensitive in .net? Does .net have a way to determine whether the local filesystem is case-sensitive?

A: Keep in mind that you might have multiple file systems with different casing rules. For example, the root filesystem could be case-sensitive, but you can have a case-insensitive filesystem (e.g. an USB stick with a FAT filesystem on it) mounted somewhere. So if you do such checks, make sure that you make them in the directory that you are going to access.
Also, what if the user copies the data from say a case-sensitive to a case-insensitive file system? If you have files that differ only by case, one of them will overwrite the other, causing data loss. When copying in the other direction, you might also run into problems, for example, if file A contains a reference to file "b", but the file is actually named "B". This works on the original case-insensitive file system, but not on the case-sensitive system.
Thus I would suggest that you avoid depending on whether the file system is case-sensitive or not if you can. Do not generate file names that differ only by case, use the standard file picker dialogs, be prepared that the case might change, etc.

A: There is no such a function in the .NET Class Library.
You can, however, roll out your own: Try creating a file with a lowercase name and then try to open it with the upparcase version of its name. Probably it is possible to improve this method, but you get the idea.
EDIT: You could actually just take the first file in the root directory and then check if both filename.ToLower() and filename.ToUpper() exist. Unfortunately it is quite possible that both uppercase and lowercase variants of the same file exist, so you should compare the FileInfo.Name properties of both the lowercase and uppercase variants to see if they are indeed the same or not. This will not require writing to the disk.
Obviously, this will fail if there are no files at all on the volume. In this case, just fall back to the first option (see Martin's answer for the implementation).

A: It's not a .NET function, but the GetVolumeInformation and GetVolumeInformationByHandleW functions from the Windows API will do what you want (see yje lpFileSystemFlags parameter.

A: How about this heuristic?
public static bool IsCaseSensitiveFileSystem() {
   var tmp = Path.GetTempPath();
   return !Directory.Exists(tmp.ToUpper()) || !Directory.Exists(tmp.ToLower());
}

A: There are actually two ways to interpret the original question.

*

*How to determine whether a specific file system is able to preserve case-sensitivity in file names?

*How to determine whether the current operating system interprets file names case-sensitively when working with a specific file system.

This answer is based on the second interpretation, because I think that is what the OP wanted to know and also what matters to most people.
The following code is loosely based on M4N's and Nicolas Raoul's answer and attempts to create a really robust implementation that is able to determine whether the operating system handles file names case-sensitive inside of a specified directory (excluding sub-directories, since these could be mounted from another file system).
It works by creating two new files in succession, one with lower-case, the other one with upper-case characters. The files are locked exclusively and are deleted automatically when closed. This should avert any negative side effects caused by creating files.
Of course, this implementation only works if the specified directory exists and the current user is able to create files inside of it.
The code is written for .NET Framework 4.0 and C# 7.2 (or later).
using System;
using System.IO;
using System.Reflection;

/// <summary>
/// Check whether the operating system handles file names case-sensitive in the specified directory.
/// </summary>
/// <param name="directoryPath">The path to the directory to check.</param>
/// <returns>A value indicating whether the operating system handles file names case-sensitive in the specified directory.</returns>
/// <exception cref="ArgumentNullException"><paramref name="directoryPath"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="directoryPath"/> contains one or more invalid characters.</exception>
/// <exception cref="DirectoryNotFoundException">The specified directory does not exist.</exception>
/// <exception cref="UnauthorizedAccessException">The current user has no write permission to the specified directory.</exception>
private static bool IsFileSystemCaseSensitive(string directoryPath)
{
    if (directoryPath == null)
    {
        throw new ArgumentNullException(nameof(directoryPath));
    }

    while (true)
    {
        string fileNameLower = ".cstest." + Guid.NewGuid().ToString();
        string fileNameUpper = fileNameLower.ToUpperInvariant();

        string filePathLower = Path.Combine(directoryPath, fileNameLower);
        string filePathUpper = Path.Combine(directoryPath, fileNameUpper);

        FileStream fileStreamLower = null;
        FileStream fileStreamUpper = null;
        try
        {
            try
            {
                // Try to create filePathUpper to ensure a unique non-existing file.
                fileStreamUpper = new FileStream(filePathUpper, FileMode.CreateNew, FileAccess.Write, FileShare.None, bufferSize: 4096, FileOptions.DeleteOnClose);

                // After ensuring that it didn't exist before, filePathUpper must be closed/deleted again to ensure correct opening of filePathLower, regardless of the case-sensitivity of the file system.
                // On case-sensitive file systems there is a tiny chance for a race condition, where another process could create filePathUpper between closing/deleting it here and newly creating it after filePathLower.
                // This method would then incorrectly indicate a case-insensitive file system.
                fileStreamUpper.Dispose();
            }
            catch (IOException ioException) when (IsErrorFileExists(ioException))
            {
                // filePathUpper already exists, try another file name
                continue;
            }

            try
            {
                fileStreamLower = new FileStream(filePathLower, FileMode.CreateNew, FileAccess.Write, FileShare.None, bufferSize: 4096, FileOptions.DeleteOnClose);
            }
            catch (IOException ioException) when (IsErrorFileExists(ioException))
            {
                // filePathLower already exists, try another file name
                continue;
            }

            try
            {
                fileStreamUpper = new FileStream(filePathUpper, FileMode.CreateNew, FileAccess.Write, FileShare.None, bufferSize: 4096, FileOptions.DeleteOnClose);

                // filePathUpper does not exist, this indicates case-sensitivity
                return true;
            }
            catch (IOException ioException) when (IsErrorFileExists(ioException))
            {
                // fileNameUpper already exists, this indicates case-insensitivity
                return false;
            }
        }
        finally
        {
            fileStreamLower?.Dispose();
            fileStreamUpper?.Dispose();
        }
    }
}

/// <summary>
/// Determines whether the specified <see cref="IOException"/> indicates a "file exists" error.
/// </summary>
/// <param name="ioException">The <see cref="IOException"/> to check.</param>
/// <returns>A value indicating whether the specified <see cref="IOException"/> indicates a "file exists" error.</returns>
private static bool IsErrorFileExists(IOException ioException)
{
    // https://referencesource.microsoft.com/mscorlib/microsoft/win32/win32native.cs.html#dd35d7f626262141
    const int ERROR_FILE_EXISTS = 0x50;

    // The Exception.HResult property's get accessor is protected before .NET 4.5, need to get its value via reflection.
    int hresult = (int)typeof(Exception)
        .GetProperty("HResult", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
        .GetValue(ioException, index: null);

    // https://referencesource.microsoft.com/mscorlib/microsoft/win32/win32native.cs.html#9f6ca3226ff8f9ba
    return hresult == unchecked((int)0x80070000 | ERROR_FILE_EXISTS);
}

As you can see there is a tiny possibility for a race condition which can cause a false-negative. If this race condition is something you really worry about I suggest you do the check a second time when the result is false, either inside the IsFileSystemCaseSensitive method or outside of it.
However, in my opinion, the probability of encountering this race condition once, let alone two times in a row, is astronomically small.

A: You can create a file in the temp folder (using lowercase filename), then check if the file exists (using uppercase filename), e.g:
string file = Path.GetTempPath() + Guid.NewGuid().ToString().ToLower();
File.CreateText(file).Close();
bool isCaseInsensitive = File.Exists(file.ToUpper());
File.Delete(file);

A: Try creating a temporary file in all lowercase, and then check if it exists using uppercase.

A: Here is the approach that does not use temporary files:
using System;
using System.Runtime.InteropServices;

static bool IsCaseSensitive()
{
    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ||
        RuntimeInformation.IsOSPlatform(OSPlatform.OSX))  // HFS+ (the Mac file-system) is usually configured to be case insensitive.
    {
        return false;
    }
    else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
    {
        return true;
    }
    else if (Environment.OSVersion.Platform == PlatformID.Unix)
    {
        return true;
    }
    else
    {
       // A default.
       return false;
    }
}

Instead, it contains an ingrained knowledge about operating environments.
Readily available as NuGet package, works on everything .NET 4.0+ and updated on a regular basis: https://github.com/gapotchenko/Gapotchenko.FX/tree/master/Source/Gapotchenko.FX.IO#iscasesensitive

A: /// <summary>
/// Check whether the operating system is case-sensitive.
/// For instance on Linux you can have two files/folders called
//// "test" and "TEST", but on Windows the two can not coexist.
/// This method does not extend to mounted filesystems, which might have different properties.
/// </summary>
/// <returns>true if the operating system is case-sensitive</returns>
public static bool IsFileSystemCaseSensitive()
{
    // Actually try.
    string file = Path.GetTempPath() + Guid.NewGuid().ToString().ToLower() + "test";
    File.CreateText(file).Close();
    bool result = ! File.Exists(file.ToUpper());
    File.Delete(file);

    return result;
}

Based on M4N's answer, with the following changes:

*

*Static names so that we are sure it contains a letter and not only numbers.

*Maybe more readable?

*Wrapped in a method.

*Documentation.

A better strategy would be to take a path as an argument, and create the file on the same filesystem, but writing there might have unexpected consequences.

A: I invoke The Cheat:
Path.DirectorySeparatorChar == '\\' ? "I'm insensitive" : "I'm probably sensitive"


text:
Q: JTable cells getting overlapped I have implemented a JTree and populated some data. The table contains three columns and based on some values on a specific cell it should have either labels or combo boxes. All the values in the 3rd column are editable. I too have a JTree from which a node is selected and based on it the table values change accordingly. The issue exists when I edit a cell in the table and move to another node in the tree (which populates a new set of data in the table), the previously edited cell values exist in the table on top of the new cell values. Below is how I implemented TableCellRenderer and TableCellEditor. I might have used some concepts wrong since I am a beginner for swing. Please help me figure out what I have done incorrectly.
        public void populateTableData(List<Field> list,JTree jTree){
        fieldList = null;
        tcBuilderTree = jTree;
        fieldList = list;
        md=new PropertiesTableModel(fieldList);
        getPropertieseTable().setModel(md);

        final TableCellRenderer cellRenderer = new TableCellRenderer() {
            @Override
            public Component getTableCellRendererComponent(JTable arg0,
                                                            Object value,
                                                            boolean isSelected,
                                                            boolean hasFocus,
                                                            int row,
                                                            int col) {

                if(value instanceof List<?>) {
                    List<Value> valueList=(ArrayList)value;
                    return createComboBox(valueList);
                }
                else{
                    JLabel lbl=new JLabel();
                    lbl.setText((String)value);
                    return lbl;
                }

            }
        };
        propertiesTable.setDefaultRenderer(Object.class, cellRenderer);

        final TableCellEditor cellEditor = new TableCellEditor() {
            private DefaultCellEditor textEditor;
            private DefaultCellEditor currentEditor;
            @Override
            public Component getTableCellEditorComponent(JTable table,
                                                        Object value,
                                                        boolean isSelected,
                                                        int row,
                                                        int column) {
                textEditor = new DefaultCellEditor(new JTextField());
                PropertiesTableModel model = (PropertiesTableModel) table.getModel();
                List<Value> values = model.getPossibleValues(row, column);
                if (values != null) {
                    List<Value> valueList=(ArrayList)value;
                    currentEditor = new DefaultCellEditor(createComboBox(valueList));
                } else {
                    currentEditor = textEditor;
                }
                return currentEditor.getTableCellEditorComponent(table, value,
                        isSelected, row, column);
            }

            @Override
            public Object getCellEditorValue() {
                return currentEditor.getCellEditorValue();
            }

            @Override
            public boolean isCellEditable(EventObject anEvent) {
                JTable tbl = (JTable) anEvent.getSource();
                int row, col;
                if (anEvent instanceof MouseEvent) {
                    MouseEvent evt = (MouseEvent) anEvent;
                    row = tbl.rowAtPoint(evt.getPoint());
                    col = tbl.columnAtPoint(evt.getPoint());
                } else {
                    row = tbl.getSelectedRow();
                    col = tbl.getSelectedColumn();
                }
                if(col<2){
                    return false;
                }
                else
                {
                    return true;
                }
            }

            @Override
            public boolean shouldSelectCell(EventObject anEvent) {
                return true;
            }

            @Override
            public boolean stopCellEditing() {
                Object obj = currentEditor.getCellEditorValue();
                fieldList.get(propertiesTable.getEditingRow())
                                                .setDefaultValue(obj);
                return currentEditor.stopCellEditing();
            }

            @Override
            public void  cancelCellEditing() {
                currentEditor.cancelCellEditing();
            }

            @Override
            public void addCellEditorListener(CellEditorListener l) {
            }

            @Override
            public void removeCellEditorListener(CellEditorListener l) {

            }
        };
        propertiesTable.setDefaultEditor(Object.class,cellEditor);
    }

A:
The issue exists when I edit a cell in the table and move to another node in the tree (which populates a new set of data in the table), the previously edited cell values exist in the table on top of the new cell values.

I would guess you are not stopping editing of the table cell before you reload the table with new data.
You probably should add the following to your code when you create the JTable:
JTable table = new JTable(...);
table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

See Table Stop Editing for more information.

The table contains three columns and based on some values on a specific cell it should have either labels or combo boxes

You may not need to create custom editors. Just have the table choose the appropriate default editor based on the cell being edited. You can do this by overriding the getCellEditor(...) method of the JTable. Check out: How to add unique JComboBoxes to a column in a JTable (Java) for an example of this approach.


text:
Q: Hiding columns from 2 ranges I have to hide columns when a range is empty, and I have 2 ranges in different sheets to control when to hide or unhide these columns.
I'm trying to use a FOR loop with 2 variables, but i's not working, this is my code:
Sub HiddenColumns()

    Dim HiddenColumn1 As Range
    Dim HiddenColumn2 As Range

    Dim c As Range
    Dim d As Range

    Set HiddenColumn1 = Range("rngColumnHidden")
    Set HiddenColumn2 = Range("rngColumnHidden2")

    For Each c In HiddenColumn1
        For Each d In HiddenColumn2

            If c.Value = "" Then
                c.EntireColumn.Hidden = True
                If d.Value = "" Then
                d.EntireColumn.Hidden = True
                End If
            End If
        Next d
    Next c

End Sub

With one range it's working perfectly, but when I try to hide another range, I have problems, this is the code for one range:
Sub HiddenColumns()

    Dim HiddenColumn1 As Range
    Dim c As Range

    Set HiddenColumn1 = Range("rngColumnHidden")
    For Each c In HiddenColumn1

            If c.Value = "" Then
                c.EntireColumn.Hidden = True
            End If
    Next c

End Sub

A: edited after OP's comment
don't nest loops
Sub HiddenColumns()
    Dim c As Range

    For Each c In Range("rngColumnHidden").Rows(1).Cells
        c.EntireColumn.Hidden = (c.Value = "")
    Next c

    For Each c In Range("rngColumnHidden2").Rows(1).Cells
        c.EntireColumn.Hidden = (c.Value = "")
    Next c
End Sub

and for the sake of avoiding code repetitions you could use a helper sub and code
Sub HiddenColumns()
    HideColumns Range("rngColumnHidden")
    HideColumns Range("rngColumnHidden2")
End Sub

Sub HideColumns(columnsRng As Range)
    Dim c As Range
    For Each c In columnsRng.Rows(1).Cells
        c.EntireColumn.Hidden = (c.Value = "")
    Next c
End Sub