text:
Q: Principal Post Wordpress Category Shortcode Returning "Array" I have created some simple shortcodes in the past to get post title and thumbnail image and everything was fine. But now I am struggling to get the primary category of posts and portfolios on Wordpress.
I have included in my functions.php file the next function from this site:
function get_primary_taxonomy_term( $post = 0, $taxonomy = 'category' ) {
    if ( ! $post ) {
        $post = get_the_ID();
    }

    $terms = get_the_terms( $post, $taxonomy );
    $primary_term = array();

    if ( $terms ) {
        $term_display = '';
        $term_slug    = '';
        $term_link    = '';
        if ( class_exists( 'WPSEO_Primary_Term' ) ) {
            $wpseo_primary_term = new WPSEO_Primary_Term( $taxonomy, $post );
            $wpseo_primary_term = $wpseo_primary_term->get_primary_term();
            $term               = get_term( $wpseo_primary_term );
            if ( is_wp_error( $term ) ) {
                $term_display = $terms[0]->name;
                $term_slug    = $terms[0]->slug;
                $term_link    = get_term_link( $terms[0]->term_id );
            } else {
                $term_display = $term->name;
                $term_slug    = $term->slug;
                $term_link    = get_term_link( $term->term_id );
            }
        } else {
            $term_display = $terms[0]->name;
            $term_slug    = $terms[0]->slug;
            $term_link    = get_term_link( $terms[0]->term_id );
        }
        $primary_term['url']   = $term_link;
        $primary_term['slug']  = $term_slug;
        $primary_term['title'] = $term_display;
    }
    return $primary_term;
    }

Later I have created a shortcode to get the primary category term from that function:
add_shortcode( 'show_category1', 'get_primary_taxonomy_term' );

Using the shortcode [show_category1] I just get the word 'Array' and not the category term.
enter image description here
Thanks in advance for any feedback.

A: In your function $primary_term is defined as an array, and the result is obviously an array that contains 'url', 'slug' and 'title' strings. Perhaps try to return something like this:
function get_primary_taxonomy_term( $post = 0, $taxonomy = 'category' ) {
    if ( ! $post ) {
        $post = get_the_ID();
    }

    $terms = get_the_terms( $post, $taxonomy );

    if ( $terms ) {
        $term_display = '';
        $term_slug    = '';
        $term_link    = '';
        if ( class_exists( 'WPSEO_Primary_Term' ) ) {
            $wpseo_primary_term = new WPSEO_Primary_Term( $taxonomy, $post );
            $wpseo_primary_term = $wpseo_primary_term->get_primary_term();
            $term               = get_term( $wpseo_primary_term );
            if ( is_wp_error( $term ) ) {
                $term_display = $terms[0]->name;
                $term_slug    = $terms[0]->slug;
                $term_link    = get_term_link( $terms[0]->term_id );
            } else {
                $term_display = $term->name;
                $term_slug    = $term->slug;
                $term_link    = get_term_link( $term->term_id );
            }
        } else {
            $term_display = $terms[0]->name;
            $term_slug    = $terms[0]->slug;
            $term_link    = get_term_link( $terms[0]->term_id );
        }
    }

    $primary_term= '' . esc_attr($term_display) . '';
    return $primary_term;
}


text:
Q: MS Access VBA Writing to a table from a form
*

*I have a form (Purchase Orders) and a sub-form in it
(Purchase Order Details). The Main form contains Number of the
PO (text box), Supplier (combo-box), Employee (combo-box),
Status (combo-box) which contains 2 records (New and Done) and a date box (when the PO was created). The Sub-form (datasheet) contains Product (combo-box), Quantity and a Price field.

*What I want to do is to add a button on the main form which will do
next.

*When the button is pressed a VBA code should be executed and do next.
Take data from the Main form (Number of the PO, Status and the date)
and the Sub-form (Product, Quantity and Price) and put all that into
a table (StockMovements).
I managed to do that with the next code:
Private Sub cmdOrder_Click()
Dim strSQL As String

    strSQL = "INSERT INTO StockMovement (ID_Product, Status, Quantity, ID_PurchaseOrder) VALUES (" & _
               Me.frmPurchaseOrderDetails_Subform.Form!comboboxProduct & ", '" & _
               Me!txtStatus & "', " & _
               Me.frmPurchaseOrderDetails_Subform.Form!txtQuantity & ", " & _
               Me!txtID_PurchaseOrder & ");"
    DoCmd.RunSQL strSQL
    Me.Requery

End Sub

However, there are 2 problems:

*

*As you can see I didnt add the date field because I get an error,
cant remember which one it was exactly but I think 2075;

*The code works without the date, but only adds one Product to the
table, the first one. And in a Purchase Order there are usually more
than one products.

Because Im totally new in VBA, I would kindly ask you to treat me like a newbie and explain more detailed, if possible.
(Fixed the code, forgot to change the language. I mean I pasted the wrong one, now its the right one but still not working of course :))
Thanks!

A: 1) If you only have a problem with one specific field, I would check whats special with that one. Probably the input is formatted as a string and the field as Date/Time. In that case try to use the CDate()-Function. I could imagine, that a .Value at the end could solve the problem, too.
Dim datDate as Date

datDate = CDate(Me!txtDate.Value)

2) That your code inserts only one row is absoluterly correct. Remember that e.g. Me!txtStatus.Value is a textbox that contains only one single piece of data. The rows of data are saved in a table and depending on the row you have selected with a main-form (= one row), the corresponding value is shown in the textbox.
INSERT INTO table (field1,field2) VALUES (value1,value2)

An INSERT INTO inserts one row every time it's executed. So the SQL in the code you have mentioned needs to be repeated. You could do so using loops.
Dim strSQL As String

strSQL = ""

 For Each Item In Group
    strSQL = strSQL & "INSERT INTO table (field1,field2) VALUES (value1,value2)"
 Next

In my opinion, copying data that way is absolutely annoying with VBA. You need to create recordsets, modify and merge them. I would try to solve as much as possible with Access Non-VBA-Solutions.
My question to you: Did you think about linking the form (and sub-form) directly to the table(s)?

A: The date can be inserted this way:
"INSERT INTO StockMovement ([DateField]) " & _
"VALUES (#" & Format(Me!DateField.Value, "yyyy\/mm\/dd") & "#)"

That said, your code will insert one record only. To insert multiple records you need a select query or - much faster - use DAO to open the target table as a recordset and then, as source, loop the RecordsetClone of your subform and copy the records to the target table one by one.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How do I authenticate on a page that requires JavaScript by using HttpClient? I am trying to programmatically authenticate a url and get the response using Apache Commons httpclient.
The response code is 200 however the i am getting a response with the a sign on page. I want to deep dive in to the sign on page and get the response.
I am noticing that the cookies are blank when i try printing using the following code:
Cookie[] cookies = httpclient.getState().getCookies();
The response has the following message:
"Your browser does not have JavaScript enabled. This feature is needed to support XXXX's Windows Single Sign-On (WSSO). Please contact your
PC support person or call"
Pls help.

A: Ensure you set the following cookie policy:
httpClient.getParams().setParameter("http.protocol.cookie-policy", CookiePolicy.BROWSER_COMPATIBILITY);

From the link http://hc.apache.org/httpcomponents-client-ga/tutorial/html/statemgmt.html
Browser compatibility:  This implementation strives to closely mimic the (mis)behavior of common web browser applications such as Microsoft Internet Explorer and Mozilla FireFox.


text:
Q: Find first and last dates of streaks in R This is my dataframe:
date <- as.Date(c("1993-09-21", "1994-02-12", "1994-02-23", "1994-05-14", "1994-08-18", "1994-08-25", "1994-08-29", "1994-09-17", "1994-10-16", "1994-10-16", "1994-10-22", "1994-10-26", "1994-12-26", "1995-04-12", "1995-05-04", "1995-06-20", "1995-07-11", "1995-07-27", "1995-08-14", "1995-08-15", "1995-08-22", "1995-08-27", "1995-08-27", "1995-08-28", "1995-08-30", "1995-08-30", "1995-09-03", "1995-09-03", "1995-09-03", "1995-09-15"))

value <- c(2, 1, 1, 1, 2, 1, 2, 4, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1)

df <- data.frame(date, value)

df$value.equals.1 <- df$value == 1

I need two things: (1) The first and last date of each consecutive streak of values of 1 (2) The length of each consecutive streak of values of 1.
I've annotated the dataframe with what I need. How can I achieve this in R?

A: We can do this with rleid from data.table.  Create the grouping variable with rleid on 'value.equals.1', subset the 'date' based on the 'value.equals.1' and extract the first and last 'date' grouped by 'grp'
library(data.table)
setDT(df)[, date[value.equals.1], .(grp  = rleid(value.equals.1))
      ][, .(date  = c(V1[1], V1[.N]), n = .N), by = grp][, grp := NULL][]
#          date n
# 1: 1994-02-12 3
# 2: 1994-05-14 3
# 3: 1994-08-25 1
# 4: 1994-08-25 1
# 5: 1994-10-22 1
# 6: 1994-10-22 1
# 7: 1994-12-26 8
# 8: 1995-08-15 8
# 9: 1995-08-27 3
#10: 1995-08-30 3
#11: 1995-09-03 2
#12: 1995-09-15 2

Or this can be done with tidyverse
library(dplyr)
df %>%
   group_by(grp = rleid(value.equals.1)) %>%
   filter(all(value.equals.1)) %>%
   mutate(n = n()) %>%
   slice(c(1, n())) %>%
   ungroup %>%
   select(date, n)
# A tibble: 12 x 2
#   date           n
#   <date>     <int>
# 1 1994-02-12     3
# 2 1994-05-14     3
# 3 1994-08-25     1
# 4 1994-08-25     1
# 5 1994-10-22     1
# 6 1994-10-22     1
# 7 1994-12-26     8
# 8 1995-08-15     8
# 9 1995-08-27     3
#10 1995-08-30     3
#11 1995-09-03     2
#12 1995-09-15     2

Or use rle from base R to create the group
grp <- inverse.rle(within.list(rle(df$value.equals.1), values <- seq_along(values)))
do.call(c, lapply(with(df, split(date[value.equals.1],
        grp[value.equals.1])), function(x) c(x[1], x[length(x)])))


text:
Q: Laravel + Apache + Routes Configuration Assets? I have the following problem trying to put my app in production related to apache2 routes and Laravel routs.
What I have :
Server1 - Domain www.example.com <--- working with other apache and website
server2 - Domain www.example.com/myapp  <--- Server for my App Production
Laravel 5.5
Apache2
PHP 7.1
Apache confs
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory /var/www/html >
               AllowOverride All
     </Directory>
</VirtualHost>

.htpasswd file

        Options -MultiViews

RewriteEngine On

# Redirect www to non-www
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

The problem is when I type on the browser www.example.com/myapp I access server2 but my css assets call server1 like www.example.com/css/app.css instead of calling www.example.com/myapp/app.css.
How can I solve this issue ?
Thanks in advance for the support.
Best

A: If I understand correctly, you can make use of the base element in the head section of your html/blade file. Like
<head>
    <base href="www.example.com/myapp">
    <link rel="stylesheet" href="css/app.css">
</head>

This will resolve the link to www.example.com/myapp/css/app.css
Read more at https://www.w3schools.com/tags/tag_base.asp


text:
Q: How to play one video in jQuery tab and stop others? I have 4 Jquery tabs, In each tab there is 2 videos. how I make one video play at the time and pause all others? and How make the video pause when I switch to new Tab?
this is the code Jsfiddle
/* play one video at a time */

$('video').bind('play', function() {
  activated = this;
  $('video').each(function() {
      if(this != activated) {
          this.pause();
      }
  });
});

/* get the active tab */
var active = $( "#issuestabs" ).tabs( "option", "active" );

/* pause all videos that are not in the active tab*/

if (!active) {
    $("video").each(function(){
        $(this).get(0).pause();
    });

}

can anyone show me what is wrong?
thanks!

A: can you use:
$('.tab').on('click', function() {
  $('.tabcontent:hidden').find('video').each(function() {
    $(this).get(0).pause();
  });
});

(where .tabcontent is the name of your content panels that are hidden/shown, the click function i showed is just an example since I do not know which library you are using for tabs.)


text:
Q: Getting Error 524 while running jupyter lab in google cloud platform I am not able to access jupyter lab created on google cloud

I created one notebook using Google AI platform. I was able to start it and work but suddenly it stopped and I am not able to start it now. I tried building and restarting the jupyterlab, but of no use. I have checked my disk usages as well, which is only 12%.
I tried the diagnostic tool, which gave the following result:

but didn't fix it.
Thanks in advance.

A: The error might be caused by a corrupted disk partition "/dev/sdb". After connecting to the notebook instance through SSH, run sudo fsck /dev/sdb to perform a disk check and repair, and then perform a reboot.
In case this does not help, you can download your data after zipping the required content from the "/home/jupyter/" folder and upload it to a new notebook instance.
Below is the zip utility command for your reference.
cd /home/
sudo zip -r test-1.zip jupyter/

A: You should try this Google Notebook trouble shooting section about 524 errors : https://cloud.google.com/notebooks/docs/troubleshooting?hl=ja#opening_a_notebook_results_in_a_524_a_timeout_occurred_error


text:
Q: Localization using i18n in angular 7 is not working after deployment to Azure I'm following this link to implement localization in Angular using i18n.
When i navigate to "url/en" or "url/fr", instead of pointing to respective directory folders it is trying to search for a route and giving the below error message.
core.js:15723 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'fr'

I have created this Angular 7 project using VS2019.
For the backend i'm using asp.net core 2.2 web api.
Running following commands shows the page with the correct translations locally.

ng serve --configuration=fr

My angular.json file as shown below.

My Package.json file as shown below

I have configured route in this way in app.modules.ts

RouterModule.forRoot([
  {
    path:'',
    component:HomeComponent,
    canActivate:[AuthGuard]
  },

I modified the .csproj file in this way.
  <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build-locale" />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build-locale:ssr" Condition=" '$(BuildServerSideRenderer)' == 'true' " />

Here are my directory structure

A: Looks like you should overide the url on Web server level. For example add web.config:
    <rule name="FR Rule" stopProcessing="true">
      <match url="(fr/)" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Rewrite" url="/fr/" />
    </rule>


text:
Q: Adding View extending from SurfaceView to layout gives me a blank screen I'm very new to Android programming, so this is probably something pretty basic.  I just have an xml layout with a few buttons.  I'm trying to follow the model given by the JetBoy demo, so I'm adding a view to the layout which extends SurfaceView.  When this new view is put in my xml layout, I just get a blank screen.
Here's the XML layout if it helps.  The gameview element is what causes the screen to be blank
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:alwaysDrawnWithCache="true">
 <game.test.gameEngine
      android:id="@+id/gameView"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"/>
<Button android:text="Easy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/EasyButton"></Button>
<Button android:text="Medium" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/MedButton"></Button>
<Button android:text="Hard" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/HardButton"></Button>
<DatePicker android:id="@+id/DatePicker01" android:layout_width="wrap_content" android:layout_height="wrap_content"></DatePicker><Button android:id="@+id/Button04" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Exit"></Button>

</LinearLayout>

A: what is game.test.gameEngine? Does it extend the View class? If so, it is taking up the entire screen. you have both width and height set to "fill_parent", which means that the buttons and datepicker are off the screen. If you want the buttons to appear on top of the game engine view, then you will have to either set the buttons as children of the game engine, or you will have to set the height and width to values that will leave space for the buttons.
embedding and arranging views can be difficult and complicated to learn, so i would suggest looking for code examples similar to what you are doing, as well as browsing the tutorials posted by google on their site.

A: I would absolutely suggest looking into a Relative Layout if you're intending on having a main game view with other things like buttons on top. I have a GLSurfaceView done this way and it works very well.
The general idea with a Relative Layout, is that without any layout parameters given, each view given is drawn in the upper left. However, when told to be aligned somewhere in the parent or next to (to the left/right of, or above/below) another view you can control where things appear.
It's also good to note that each new view listed appears on top of the other (if not aligned otherwise) so you'd list the main surface game view first and the buttons after it.


text:
Q: How can I show XMPP messages in a chat using Strophe on Angular? I am making an application for messaging using Angular 10, Strophe.js and Openfire. I can connect to the server, send messages and receive them, but when I receive them I can't show the messages in the chat. Here is my code:
connection.connect(this.doc_name + "@server", 'password', this.onConnect);

onConnect(status) {
    if (status == Strophe.Status.CONNECTING) {
      console.log('Strophe is connecting.');
    } else if (status == Strophe.Status.CONNECTED) {
      console.log('Strophe is connected.');
      connection.addHandler(reMessage, null, 'message', 'chat', null, null, null);

      function reMessage(msg) {
        // parse out the from and type attributes of <message>, and the body sub-elements
        var from = msg.getAttribute('from');
        var type = msg.getAttribute('type');
        var elems = msg.getElementsByTagName('body');
        if (type == "chat" && elems.length > 0) {
          var body = elems[0];
          console.log(from);
          console.log("The message received is: "+ Strophe.getText(body));

        }
        var text = Strophe.getText(body);
        console.log(text);
        this.receiveMessage(text, false, from);

        return true;
      }

      connection.send($pres().tree());
    }}

    receiveMessage(event: any, reply: boolean, from: any) {
    const files = !event.files ? [] : event.files.map((file) => {
      return {
        url: file.src,
        type: file.type,
        icon: 'file-text-outline',
      };
    });

    this.messages.push({

      text: event.message,
      date: new Date(),
      reply: reply,
      type: files.length ? 'file' : 'text',
      files: files,
      user: {
        name: from,
      },
    });
}

In particular, the error that I am facing is:
TypeError: this.receiveMessage is not a function

I tried many solutions found on this site and others, using arrow function, .bind(), maybe using them in the wrong way due to the fact that I am new to Angular. Anyway I didn't solve my problem.
I think it is related to the callback function and on the scope of this.
Can anyone help me?

A: Ok, I finally did it. For the others that could face the same issue, I was focusing just on the reMessage function while the problem was on the onConnect function, indeed I used .bind(this) on that particular function and everything went fine.
connection.connect(this.doc_name + "@server", 'password', this.onConnect.bind(this));


text:
Q: Why do I get a warning that says " each child in a list should have a unique key prop" but I already have a unique key prop for the child component I am new to react and doing a code along on an online course. I am getting a warning of each child on a list should have a unique key prop. The child component however already has a unique key prop.
The program should increase the value of an object value, in this case counter.value by one when the increment button is pressed but I am getting a key error.
I have tried adding (argument, index) to the map function that I am using but i get an error that the child component is not defined.
//Parent Component

import React, { Component } from "react";
import Counter from "./counter";

class Counters extends Component {
  state = {
    counters: [
      { id: 1, value: 9 },
     ]
  };

  handleIncrement = counter => {
    const counters = [...this.state.counters];
    const index = counters.indexOf(counter);
    counters[index] = { ...counters };
    counters[index].value++;
    this.setState({ counters });
  };

   render() {
    return (

        {this.state.counters.map(counter => (
          <Counter
            key={counter.id}
            onIncrement={this.handleIncrement}

          />
        ))}

    );
  }
}

export default Counters;

//Child Component
import React, { Component } from "react";

class Counter extends Component {
   return (

        <button
          onClick={() => this.props.onIncrement(this.props.counter)}

        >
          Increment
       </button>

}

export default Counter;

A: Replace the render section with this:
 render() {
    const { counters } = this.state;
    return (

        {counters.map(counter => {
            const counterKey = `counter-${counter.id}`;
            return (
                <Counter
                  key={counterKey}
                  onIncrement={this.handleIncrement}
                />
            )})
        }

    );
  }


text:
Q: Problems with TextView Ok i have a TabActivity with a FragmentActivity in each tab. In one of those tabs i have a root Fragment which contains a ScrollView with multiples HorizontalScrollView like the picture:
In each HorizontalScrollView i add dinamically a few of objects inflated like this:

To get the effect of Gallery, well the main problem is when I click in each item to replace for another fragment, i add this fragment to backstack, BUT when i press back to return to this fragment all my textview are contains the same text... It's so very strange, and i dont know WHY!? Some ideas?
I put the onCreateView function that i'm using:
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
    {
        if (view == null) {
            this.view = inflater.inflate(R.layout.activity_home, container, false);
         } else {
             ((ViewGroup) view.getParent()).removeView(view);
         }
        return this.view;
    }


text:
Q: In React's Flux how to use a store, when two components need different data from the store at the same time? I have a store (MovieStore) which I would like to use as a central store to movies in my React App. I have a search page, that lists the movies based on a search string (and uses of course the MovieStore).
In addition I have a typeahead component, that makes suggestions based on the string the user typed into the search box. I want to use the same MovieStore for the typeahead too.
The problem is, that in this case the MovieStore should represent two states at the same time (the result list from the previous search, and the typeahead suggestions based on the current search string)
I ended up emitting two different kinds of events from the store, the typeahead listening to one event, the result list listening to the other, but it feels awkward. (because at the end of the day, one of the two components get out of synch, it just does not listen to a specific kind of event deliberately).
What better solution would you suggest for this?
Here is the simplified version of my code (I'm sure it is a bad design, because the store is not pure anymore, it was adjusted to these specific components)
var MovieStore = _.extend({}, EventEmitter.prototype, {

    getAll: function() {
        return movies;
    },

    //this will notify when the "search result" changed
    emitListChange: function() {
        this.emit('listChange');
    },

    //this will notify when the "typeahead string" changed
    emitSearchChange: function() {
        this.emit('searchChange');
    },

    // ... add/remove listeners
});

var Typeahead = React.createClass({
    componentDidMount: function() {
        MovieStore.addSearchChangeListener(this.onMoviesChanged);
    },

    onMoviesChanged() {
        this.setState({
            movies: Movies.getAll(),
        });
    },

    //...
});

var List = React.createClass({
    componentDidMount: function() {
        MovieStore.addListChangeListener(this.onMoviesChanged);
    },

    onMoviesChanged() {
        this.setState({
            movies: Movies.getAll(),
        });
    },

    //...
});

A: Why not have each component simply listen for a CHANGE event from the store. Then each component can query the store for the information it needs.
Example...
var Typeahead = React.createClass({
  // deliberately omitting some stuff

  componentDidMount() {
    MovieStore.addChangeListener(this.onMovieStoreChange);
  },

  onMovieStoreChange() {
    this.setState({movies: MovieStore.getAll()});
  },
});

// Then in List

var List = React.createClass({
  componentDidMount() {
    MovieStore.addChangeListener(this.onMovieStoreChanged)
  },
});

So, now, whenever the MovieStore updates, both the Typeahead and the List will update. Don't worry about the "cost" of updating both components when perhaps only one needs to be updated: it's miniscule.
Hope that helps


text:
Q: Reading keyboard events (Windows 7) with C/C++ I saw examples from keyloggers that are working like that:
for (int i = 8; i < 191; i++) {
    if (GetAsyncKeyState(i) & 1 == 1) {
            cout << i << endl;
    }
}

This is working, but it takes events from every keyboard that is connected to the computer (for example the standard-keyboard and a barcode-scanner).
Is there a possibility to read the events only from a specific keyboard (the barcode-scanner).
I know the function GetRawInputDeviceList(...) that list all the devices that are connected to the computer. This seems like an interesting beginning.
A simple working example would be nice :)
Edit:
I wrote a solution to the problem. It is available under this link:
https://drive.google.com/drive/folders/0BzWPIxqSSyP8fkZiaDI2c3VWNmNqSGd0aDc4TFVpLVYtbWdLdmZjMU9RUVFIMXNtY0FYdEk
It is heavily commented :)
but some of them are in German, sorry :(


text:
Q: Embed external swf file I can host a swf file locally with the web page it is embededed in, but if I change the src attaribute for the embed tag in the html file to point to an external link on mediafire.com the content never loads.
Is there anything I need to configure to host a swf file externally to the server which hosts the web page it is embedded into ?
NB: I can  open the media file directly by clicking a  link on my page
<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" WIDTH="1137" HEIGHT="912" CODEBASE="active.macromedia.com/flash5/cabs/…; <PARAM NAME=movie VALUE="mediafire.com/file/dvtk94k4qyi1w1b/page1.swf">; <PARAM NAME=play VALUE=true> <PARAM NAME=loop VALUE=false> <PARAM NAME=wmode VALUE=transparent> <PARAM NAME=quality VALUE=low>
<EMBED SRC="mediafire.com/file/dvtk94k4qyi1w1b/page1.swf"; WIDTH=1137 HEIGHT=912 quality=low loop=false wmode=transparent TYPE="shockwave-flash" PLUGINSPAGE="macromedia.com/shockwave/download/…; </EMBED> </OBJECT>

Edit: Here's the html for the page, which is at a different domain to the swf.

<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" WIDTH="1137" HEIGHT="912" CODEBASE="http://active.macromedia.com/flash5/cabs/swflash.cab#version=7,0,0,0">
<PARAM NAME=movie VALUE="http://www.mediafire.com/file/dvtk94k4qyi1w1b/page1.swf">
<PARAM NAME=play VALUE=true>
<PARAM NAME=loop VALUE=false>
<PARAM NAME=wmode VALUE=transparent>
<PARAM NAME=quality VALUE=low>
<EMBED SRC="http://www.mediafire.com/file/dvtk94k4qyi1w1b/page1.swf" WIDTH=1137 HEIGHT=912 quality=low loop=false wmode=transparent TYPE="shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</EMBED>
</OBJECT>

A: Are you sure you can access the file? Use firebug or Chrome's built in debugger and check the net tab.
My bet is that the swf is password protected, and your clients just cant reach the file.


text:
Q: How to include a partial into another partial's block? I use Swig as a template engine.
I need to include a partial but only into another partial's block. But Swig includes it just below, ignoring a block tag. Here is how it looks:
1.
layout.html
<!DOCTYPE html>

        {% block title %}{% endblock %}
        {% block headtag %}
            <link rel='stylesheet' href='/assets/css/global.css' />
            <link rel='stylesheet' href='/bower_components/bootstrap/dist/css/bootstrap.css' />

        {% endblock %}

            {% block content %}{% endblock %}

2.
This is a page view that is rendered after request.
index.html
{% extends 'layouts/layout.html' %}

{% block title %}
    <title>{{ title }}</title>
{% endblock %}

{% block headtag %}
    {% parent %}
    <link href="/assets/css/index/index.css" rel="stylesheet">
    <link href="/assets/css/header.css" rel="stylesheet">
{% endblock %}

{% block content %}

    {% include 'index_content.html' %}

{% endblock %}

3.
Here I include a header partial (partials/header.html). And this header partial has an empty block tag (header_nav) in which I want to include another partial (header_nav.html). But only into the block. See the header.html lower.
index_content.html
{% include 'partials/header.html' %}

{% block header_nav %}
    {% include 'header_nav.html' %}
{% endblock %}

4.
Here is an html-code of the partials/header.html. See the block tag header_nav. In that block I want to place header_nav.html. But it doesn't work. It places header_nav.html just bellow partials/header.html:

            {% block header_nav %}
                ... I want to include a partial here only ...
            {% endblock %}

... But Swig ignores header_nav block and places here for some reason ...

How to acheave it? As I understand for now this is a real drawback of Swig. Is there some workaround?

A: If i got you right, this cannot be done.
Take a look at this similar question.
In this comment there's a link to a related issue on github.
paularmstrong wrote:

Blocks are not supported in included templates. You should (be able to) structure your extends/inheritance to accomplish the same thing...
...You should use multiple extends...
Blocks in includes will never be supported.

There's also an example similar to yours that you might want to check out.


text:
Q: Use MYSQLi Prepared Statement to display Data on HTML Table I want to use a mysqli prepared statement to display data into an html table.However when I run the code I get a blank page. The code is presented below.

<?php

include_once 'includes/db_connect.php';

?>
<?php

  if($stmt = $mysqli->prepare("SELECT id first_name  second_name , request , purpose, description
                                       FROM data_centre_users WHERE status <> 'approved'")){

   $stmt->execute();    // Execute the prepared query.
        $stmt->store_result();
        // get variables from result.
        $stmt->bind_result($id , $first_name, $second_name ,$request , $purpose , $description );

function myDate($x){

   if ( !strtotime($x)) {
  return "00-00-0000 00:00:00";
   }
    else{
  return strftime('%Y-%m-%dT%H:%M:%S',
               strtotime($x));
     }
  return "";
}

?>

                Name
                Request
                Purpose
                Description
                Approve
                Delete

            <?php
            if($stmt->num_rows > 0){
                // output data of each row
                while($stme->fetch()){ ?>

                        <?php echo $first_name."  ".$last_name; ?>
                        <?php echo $request; ?>
                        <?php echo $purpose; ?>
                        <?php echo $description; ?>
                        <a href="javascript:if(confirm('Are you sure you want to approve?')){ location.href='approve.php?id=<?php echo $id; ?>'; }">approve
                        <a href="javascript:if(confirm('Are you sure you want to delete?')){ location.href='deny.php?id=<?php echo $id; ?>'; }">deny

                    <?php
                }
            }
            ?>

 <?php } ?>

<?php

 ?>

This is the code for the database connection.

<?php

include_once 'psl-config.php';   // Needed because functions.php is not included
$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
if ($mysqli->connect_error) {
    header("Location: ../error.php?err=Unable to connect to MySQL");
    exit();
}

This is the script for the table.

CREATE TABLE IF NOT EXISTS `data_centre_users` (
  `id` int(6) NOT NULL AUTO_INCREMENT,
  `first_name` varchar(120) NOT NULL,
  `last_name` varchar(120) NOT NULL,
  `request` varchar(200) NOT NULL,
  `purpose` varchar(200) NOT NULL,
  `description` varchar(200) NOT NULL,
  `booking_time` datetime(6) NOT NULL,
  `access_time` datetime(6) NOT NULL,
  `exit_time` datetime(6) NOT NULL,
  `status` varchar(35) NOT NULL DEFAULT 'not yet',
  `approved_by` varchar(150) NOT NULL,
  `accessed_by` varchar(16) NOT NULL,
  `time_approved` datetime(6) NOT NULL,
  `task_completed` varchar(16) NOT NULL,
  `time_completed` datetime(6) NOT NULL,
  `time_started` datetime(6) NOT NULL,
  `department` varchar(250) NOT NULL,
  `unit` varchar(140) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=76 ;

--
-- Dumping data for table `data_centre_users`
--

INSERT INTO `data_centre_users` (`id`, `first_name`, `last_name`, `request`, `purpose`, `description`, `booking_time`, `access_time`, `exit_time`, `status`, `approved_by`, `accessed_by`, `time_approved`, `task_completed`, `time_completed`, `time_started`, `department`, `unit`)

VALUES
(6, 'kazare', 'Jaguar', 'rautine maintenance', 'Unofficial', 'dust and clean', '2015-08-07 04:34:12.000000', '2015-08-10 02:50:00.000000', '1970-01-01 01:00:00.000000', 'approved', 'SYSTEM', 'Staff', '2015-08-10 09:22:09.000000', 'completed', '2015-08-13 09:30:57.000000', '0000-00-00 00:00:00.000000', '', ''),

When I run the code I get a blank (empty) page.
After adding the following code to the php.ini file from this page ,
'ini_set('display_errors', 1);'
'ini_set('display_startup_errors', 1);'
'error_reporting(E_ALL);'
The following error is displayed.
Fatal error: Class 'mysqli' not found in C:\wamp\www\datacentre\admin\includes\db_connect.php on line 4

Any help.


text:
Q: Does extraposition work in "I made happy my friend who..."? Can we use extraposition rule in the situations like below?
"I made my friend who came here last week happy"
Can it be like this?
"I made happy my friend who came here last week"

A: I believe this is an example of shifting and not extraposition. Extraposition would require moving a constituent in such a way that it causes a discontinuity, but here there is no discontinuity. If you wanted to use extraposition, you could word it this way.

"I made my friend happy who came here last week."

Please note that the first way you have it written is the most canonical word ordering.
See the Wikipedia articles on extraposition and shifting, linked below, for more details and examples.

*

*https://en.wikipedia.org/wiki/Extraposition

*https://en.wikipedia.org/wiki/Shifting_(linguistics)


text: Q: is there a way to recover variable names in llvm generated code? Is there a way to recover the source code variables in llvm bytecode? I've looked into debug information that llvm provides but I don't think they are stored.


text:
Q: Powershell splatting: pass ErrorAction = Ignore in hash table Here's a script to list directories / files passed on the command line -- recursively or not:
param( [switch] $r )
@gci_args = @{
  Recurse = $r
  ErrorAction = Ignore
}
$args | gci @gci_args

Now this does not work because Ignore is interpreted as a literal. What's the canonical way to pass an ErrorAction?
I see that both "Ignore" and (in PS7) { Ignore } work as values, but neither seems to make a difference for my use case (bad file name created under Linux, which stops PS5 regardless of the ErrorAction, but does not bother PS7 at all). So I'm not even sure the parameter has any effect.

A:
because Ignore is interpreted as a literal

No, Ignore is interpreted as a command to execute, because it is parsed in argument mode (command invocation, like a shell) rather than in expression mode (like a traditional programming language) - see this answer for more information.
While using a [System.Management.Automation.ActionPreference] enumeration value explicitly, as in filimonic's helpful answer, is definitely an option, you can take advantage of the fact that PowerShell automatically converts back and forth between enum values and their symbolic string representations.
Therefore, you can use string 'Ignore' as a more convenient alternative to [System.Management.Automation.ActionPreference]::Ignore:[1]
$gci_args = @{
  # ...
  ErrorAction = 'Ignore'
}

Note that it is the quoting ('...') that signals to PowerShell that expression-mode parsing should be used, i.e. that the token is a string literal rather than a command.
Also note that -ErrorAction only operates on non-terminating errors (which are the typical kind, however) - see this answer for more information.

As for discovery of the permissible -ErrorAction values:

*

*The conceptual about_CommonParameters help topic covers all common parameters, of which -ErrorAction is one.

*Many common parameters have corresponding preference variables (which accept the same values), covered in about_Preference_Variables, which allow you to preset common parameters.

*Interactively, you can use tab-completion to see the permissible values (as unquoted symbolic names, which you simply need to wrap in quotes); e.g.:
# Pressing the Tab key repeatedly where indicated
# cycles through the acceptable arguments.
Get-ChildItem -ErrorAction <tab>

[1] Note that using a string does not mean giving up type safety, if the context unambiguously calls for a specific enum type, such as in this case. Validation only happens at runtime either way, given that PowerShell is an interpreted language.
However, it is possible for a PowerShell-aware editor - such as Visual Studio Code with the PowerShell extension - to flag incorrect values at design time. As of version 2020.6.0, however, that does not yet appear to be the case. Fortunately, however, tab-completion and IntelliSense work as expected, so the problem may not arise.
That said, as zett42 points out, in the context of defining a hashtable entry for latter splatting the expected type is not (yet) known, so explicit use of [System.Management.Automation.ActionPreference] does have advantages: (a) IntelliSense in the editor can guide you, and (b) - assuming that Set-StrictMode -Version 2 or higher is in effect - an invalid value will we reported earlier at runtime, namely at the point of assignment, which makes troubleshooting easier. As of PowerShell 7.1, a caveat regarding Set-StrictMode -Version 2 or higher is that you will not be able to use the intrinsic (PowerShell-supplied) .Count property on objects that don't have it type-natively, due to the bug described in GitHub issue #2798.

A: I think the best way is to use native type.
$ErrorActionPreference.GetType().FullName # System.Management.Automation.ActionPreference

So, use
$gci_args = @{
  Recurse = $r
  ErrorAction = [System.Management.Automation.ActionPreference]::Ignore
}


text:
Q: Add custom properties to android build.gradle library project and override the same in the application project I would like to add custom properties in my libraries build.gradle and allow the developers using my library to provide input to these properties from the applications build.gradle. How do I achieve this and how do I access these custom properties in my libraries build.gradle to perform certain actions.
For Eg:
android {
    compileSdkVersion 28

    defaultConfig {
        excludeModule "true"
    }

    packagingOptions {
        if(android.defaultConfig.excludeModule=="true"){
            println 'Including Feature A'
        }
    }
}

Now can the property excludeModule "true" be overridden in the applications using the build.gradle and can i use that variable to perform some build action in the library. How do i achieve this?


text:
Q: Django TruncDate gives null I'm using Django 2.2
I'm filtering records using Django query like
from datetime import datetime
from django.db.models.functions import TruncDate

start_date = datetime.strptime('2020-02-01', '%Y-%m-%d').date()
end_date = datetime.strptime('2020-03-31', '%Y-%m-%d').date()

lead_list = LeadList.objects.all()

# Filter query
query = LeadListEntry.objects.filter(
    lead_list__in=lead_list
  )

# Filter by start date
query = query.filter(
    created__gte=start_date
  )

# Filter by end date
query = query.filter(
    created__lte=end_date
  )

# Annotate date
query = query.annotate(
     created_date=TruncDate('created')
   ).order_by(
     'created_date'
   ).values('created_date').annotate(
     **{'total': Count('created')}
   )

The SQL query generated is
SELECT
    DATE(CONVERT_TZ(`lead_generation_leadlistentry`.`created`, 'UTC', 'UTC')) AS `created_date`,
    COUNT(`lead_generation_leadlistentry`.`created`) AS `total`
FROM `lead_generation_leadlistentry`
WHERE (
    `lead_generation_leadlistentry`.`lead_list_id` IN (
        SELECT
            U0.`id` FROM `lead_generation_leadlist` U0
        WHERE
            U0.`deleted` IS NULL
    )
    AND `lead_generation_leadlistentry`.`created` >= '2020-02-01 00:00:00'
    AND `lead_generation_leadlistentry`.`created` <= '2020-03-31 00:00:00'
)
GROUP BY DATE(CONVERT_TZ(`lead_generation_leadlistentry`.`created`, 'UTC', 'UTC'))
ORDER BY `created_date` ASC

This is behaving different on local and staging server
Local Development server
+--------------+-------+
| created_date | total |
| ------------ | ----- |
| 2020-02-25   | 15    |
| 2020-02-27   | 10    |
+--------------+-------+

Staging server
+--------------+-------+
| created_date | total |
| ------------ | ----- |
| null         | 15    |
+--------------+-------+

The date column is null
NOTE: Django has timezone enabled by USE_TZ=True
LeadListEntry model
class LeadListEntry(models.Model):
    lead_list = models.ForeignKey(LeadList, on_delete=models.CASCADE, related_name='lead_list_entry')
    data = models.TextField(help_text='Lead List entry data. (JSON data)', blank=False)

    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)

A: Here is the solution for the users getting the same error
The error was not with the Django, instead it was with the MySQL database setup.
The date field returns null because CONVERT_TZ does not work. This can be due to no timezone data in the MySQL database.
To import the timezone data, execute following command
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

After importing, restart the mysql server.

A: The problem of different results from local to staging may happen because of different DateTime of the machine, I got this before when I was developing on windows but the staging was ubuntu, it turned out strptime() date parameters were different and kept showing errors.
For date filtering and as your code sample you don't have to create a date object, just a correct string date format will be enough
start_date = '2020-02-01'
end_date = '2020-03-31'

Then go as normal.
I would like to do something like this,
# As you only need LeadList id's for foreginkey filtering, this is more optimized
lead_list = LeadList.objects.all().values_list('id')

# Filter query
query = LeadListEntry.objects.filter(
    lead_list__in=lead_list, created__date__gte = start_date, created__date__lte=end_date
  )

and to group by date
query = query.values('created__date').annotate(count=Count('created__date')).order_by('created__date')


text:
Q: OpenCV Sorting Contours by Area in Java This is my first time working with OpenCV, I am having trouble figuring out a method to sort the contours by area. I am looking for the two largest areas. Currently I have:
 List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
 Imgproc.findContours(MatOut, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);

A: For Java 8+
//finding max area
Optional<MatOfPoint> largest = contours.stream().max(new Comparator<MatOfPoint>() {
        public int compare(MatOfPoint c1, MatOfPoint c2) {
            return (int) (Imgproc.contourArea(c1)- Imgproc.contourArea(c2));
        }
    });
// sorting
contours.sort(new Comparator<MatOfPoint>() {
        public int compare(MatOfPoint c1, MatOfPoint c2) {
            return (int) (Imgproc.contourArea(c1)- Imgproc.contourArea(c2));
        }
    });

For Java 7 use Collections.sort with same comparator and get the first element.

A: Relatively simple once I understood how it worked, simply apply a sorting method using contourArea as the key.


text:
Q: how to delete all files in My Drive on colab? Now I can't mount colab because of too many files on 'My Drive' when use the command:
from google.colab import drive
drive.mount('/content/gdrive')

So shall I delete all files on 'My Drive' by command or other sets?


text:
Q: Why do I get Lexerr:unterminated quote error? I have the following template:

Not voted

    Voted for this concept

    Voted for another concept

When I try to run it, I get
Error: [$parse:lexerr] Lexer Error: Unterminated quote at columns 8-57 ['http://ballentines.herokuapp.com/{{finalist.slug] in expression [enabled('http://ballentines.herokuapp.com/{{finalist.slug].
http://errors.angularjs.org/1.2.11/$parse/lexerr?p0=Unterminated%20quote&p1=s%208-57%20%5B'http%3A%2F%2Fballentines.herokuapp.com%2F%7B%7Bfinalist.slug%5D&p2=enabled('http%3A%2F%2Fballentines.herokuapp.com%2F%7B%7Bfinalist.slug

What am I doing wrong?

A: I get this error from time to time when Chrome's Angular Batarang extension is installed. It auto updates itself and sometimes the error is present, sometimes not.
To test this, I just disable Batarang and refresh the app.

A: ng-show expects expression while {{ }} is just shortcut for ng-bind directive. In your case

Not voted

should work.


text:
Q: Can't Access Parent-document from Iframe I have a main page for navigating to other 3 pages in an iframe
Main page: 1.html
Other 3 pages: one.html, two.html, 3.html.
Code
1.html

One

Two

Three

one.html

        1.html.

But there is a problem showing the location of the parent-document. It's giving an alert message as follws:
SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.

Can anyone please explain the meaning of the terms used in the message in the context of this error or simply why this happend???
N.B.: No Server Used

A: Chrome rather strictly assumes that there is no connection between local files.
On a Mac you can start Chrome from the terminal like this:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --allow-file-access-from-files

and it will work, but the best thing would be to use a webserver.


text:
Q: Sending login and password through PHP Soap Client doesn't get picked up by WCF Service Host? I am instantiating a PHP Soap Client like this:
$client = new SoapClient('http://localhost:8731/MathService?wsdl',array(
'login' => "test2", 'password' => "test"));

When I do this above, the Request contains:
Authorization: Basic dGVzdDI6dGVzdA==
But the above is not being picked up by my CustomUserNamePasswordValidator.  I just have the WCF Service running in a Console app, so I do not know how to set the client credentials on the service host.  I am using TransportWithCredentialOnly with Basic HTTP and Message="UserName".  My CustomUserNamePassword Validator is hard-coded only to accept test and test as the username and password, but even if I pass in test2 to the SoapClient, the operation still passes.

A: I changed the Security mode to TransportCredentialOnly and the transport clientCredentialType to Basic and it worked.


text:
Q: Object unchanged when running knife client edit I'm running knife client edit command to edit a node in Chef to set admin permissions. I would like to do this programmatically so my intention is to add this command to a shell script if I can make it work.
The previous state of the node is (UPDATE):
$ knife client show -Fj my_node
{
  "name": "my_node",
  "public_key": "-----BEGIN PUBLIC KEY-----\n...key...\n-----END PUBLIC KEY-----\n",
  "validator": false,
  "admin": false,
  "json_class": "Chef::ApiClient",
  "chef_type": "client"
}

When running the command it says that the object is unchanged and after checking the node with knife client I can
verify that still has the admin attribute set to false:
$ knife client edit -d my_node < my_node.json
Object unchanged, not saving

The content of my_node.json file is:
{
  "name": "my_node",
  "public_key": "-----BEGIN PUBLIC KEY-----\n...key...\n-----END PUBLIC KEY-----\n",
  "validator": false,
  "admin": true,
  "json_class": "Chef::ApiClient",
  "chef_type": "client"
}

I don't know how to make this piece work.
Any help on this will be very much appreciated.
NOTE:
    $ knife --version
    Chef: 12.2.1
UPDATE: I couldn't find an accepted answer in this thread which is quite similar.
UPDATE 2: I tried these other ways as well with no luck at all (using same json file):
$ cat my_node.json | knife client edit my_node -d
Object unchanged, not saving

$ knife client edit my_node -d < my_node.json
Object unchanged, not saving

A: If you already got the file with the content you need, there is a trick to use it.
knife client edit -e "cp my_node.json"

Explanation on how interactive editing works on an app (knife in this case):

*

*The app starts on foreground the command on EDITOR environment variable passing a temporary file as argument

*When the command ends, the app opens the temporary file and uses it

So if all you want is changing a word, you can use sed instead:
knife client edit -e "sed -i  's/\"admin\":\s*false/\"admin\": true/'"

A: There is no difference between your my_node.json and your my_node settings. Change a value and try again.


text:
Q: Is $\approx$ actually an entourage? I was looking at applying the ideas in the paper On Nonstandard Topology to Uniform spaces. Given a uniform space $(X,\Phi)$, we can define the relation $\approx$ on ${}^*X$ as follows $$\approx \, = \bigcap \{{}^*U:U \in \Phi \}$$
For example, if $(X,\Phi)$ is the real numbers with their ordinary uniform structure, then $x \approx y$ iff $x-y$ is an infinitesimal in the hyperreal numbers. If we use the metric $|x^3 - y^3|$ instead of the real numbers ordinary $|x - y|$ metric, then $H + \frac 1H \not \approx H$ for infinite $H$ (although $H + \frac 1{H^3} \approx H$).
In fact, it appears that we can prove that $\approx$ is an entourage (i.e. $\approx \, \in {}^*\Phi$). Take the following statements

*

*The statement "$V \in \Phi$"

*The statement "$V \subseteq U$" for each $U \in \Phi$.

By the third property of entourages, any finite number of these statements is satisfiable. Therefore, by the Saturation property, there is nonstandard $V$ that satisfies the transfer of all these statements. In particular, $V \in {}^* \Phi$. Additionally, $V \subseteq \, \approx$. By the second property of entourages, $\approx$ is therefore an entourage.
Is my proof correct though? The issue is that, going back to the real line with its usual uniform structure, we can assign each entourage a $V$ "diameter", defined as the supremum of the distances between points $x$ and $y$ such that $(x,y) \in V$. Therefore, we should be able to assign either a hyperreal number of $\infty$ to $\approx$ like this, but we can't really. It is less than every positive non-infinitesimal (so in particular is not $\infty$), but greater than every infinitesimal.
So, what's going on? Is $\approx$ actually an entourage?

A: Your proof would be correct if you knew that $\approx$ is an internal set.  However, it usually won't be, and if it is not an internal set, it certainly can't be an element of ${}^*\Phi$.  Indeed the contradiction you reached shows that for the usual uniformity on the real line, $\approx$ cannot be internal.
To be clear, ${}^*\Phi$ is not a uniformity in the most literal set-theoretic sense.  Rather, it satisfies the version of the definition of a uniformity you get by applying Transfer to the usual definition.  In particular, the usual definition involves quantification over all subsets of $X\times X$ (i.e., elements of $\mathcal{P}(X\times X)$), and this will turn into a quantification over all internal subsets of ${}^*X\times {}^*X$ (since those are the elements of ${}^*\mathcal{P}(X\times X)$).


text:
Q: Making Django admin display the Primary Key rather than each object's Object type In Django 1.1 admin, when I go to add or change an object, my objects are displayed as:
Select host to change
    * Add host

    Host object
    Host object
    Host object
    Host object
    Host object

This happens for all models in my site, not just Hosts.
Rather than display the same name for each object, I would like Django to display the primary key.
Select host to change
    * Add host

    machine1
    machine2

Here is my code:
from django.db import models

# Create your models here.

class Host(models.Model):
    host = models.CharField(max_length=100,primary_key=True)
    class Admin:
        list_display = ('host')

class Test(models.Model):
    testname = models.CharField(max_length=100,primary_key=True)
    class Admin:
        list_display = ('testname')

class Result(models.Model):
    host = models.ForeignKey(Host)
    TESTRESULT_CHOICES = (
        ('P', 'Pass'),
        ('F', 'Fail'),
    )
    testresult = models.CharField(max_length=1, choices=TESTRESULT_CHOICES)
    reason = models.CharField(max_length=100)
    time = models.DateTimeField()
    testname = models.OneToOneField(Test, primary_key=True)
    class Admin:
        list_display = ('host','testname','time','testresult','reason')

Reading http://docs.djangoproject.com/en/dev/ref/contrib/admin/:
"ModelAdmin.list_display
Set list_display to control which fields are displayed on the change list page of the admin."
However this simply does not seem to work. Am I doing something wrong?

A: Add a __unicode__() method to Host. To show the primary key of your host objects, you'd want something like:
class Host(models.Model):
    host = models.CharField(max_length=100, primary_key=True)

    def __unicode__(self):
        return self.pk

    ...

You might want to think about showing the contents of the host field:
class Host(models.Model):
    host = models.CharField(max_length=100, primary_key=True)

    def __unicode__(self):
        return self.host

    ...

You'll need to do something similar for every model you've got.
For Python 3 compatibility, you'll want to do something like this (see the documentation):
from __future__ import unicode_literals
from django.utils.encoding import python_2_unicode_compatible

@python_2_unicode_compatible
class Host(models.Model):
    host = models.CharField(max_length=100, primary_key=True)

    def __str__(self):
        return self.host

    ...

A: It might also be worth mentioning that, if you are using an auto-incrementing primary key for your models, you will need to coerce it into a string, eg:
def __unicode__(self):
    return str(self.pk)

A: contrib.admin has been reworked in 1.0, and old Admin classes inside models no longer work. What you need is ModelAdmin subclass in your_application.admin module, e.g.
from your_application.models import Host
from django.contrib import admin

class HostAdmin(admin.ModelAdmin):
    list_display = ('host',)

admin.site.register(Host, HostAdmin)

Or use __unicode__ in the model itself, e.g.
class Host(models.Model):
    host = models.CharField(max_length=100,primary_key=True)

    def __unicode__(self):
        return self.host


text:
Q: Amazon S3 and M3u8 and ts files i encode my videos to Hls locally
then
i upload them to the s3 bucket in aws and disable public access
then
i made IAM user with this primission
   {
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObjectAcl",
                "s3:GetObject",
                "s3:PutBucketAcl",
                "s3:ListBucket",
                "s3:DeleteObject",
                "s3:GetBucketAcl",
                "s3:GetBucketLocation",
                "s3:PutObjectAcl"
            ],
            "Resource": [
                "arn:aws:s3:::bucketname",
                "arn:aws:s3:::bucketname/*"
            ]
        }
    ]
}

then added only permission to access bucket from my domain
{
    "Version": "2012-10-17",
    "Id": "http referer policy example",
    "Statement": [
        {
            "Sid": "Allow get requests originating from www.example.com and example.com.",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": "arn:aws:s3:::bucketname/*",
            "Condition": {
                "StringLike": {
                    "aws:Referer": [
                        "http://www.mydomain.ext/*",
                        "http://mydomain.ext/*",
                        "https://www.mydomain.ext/*",
                        "https://mydomain.ext/*"
                    ]
                }
            }
        }
    ]
}

then enabled cors
[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET",
            "POST",
            "PUT"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [],
        "MaxAgeSeconds": 3000
    }
]

now i use wordpress on my domain and installed fv player and added the key and the secret
the problem is :
when i try to play mp4 , it work fine
when i try to play the  .m3u8 file not work, it loads the m3u8 file but give 403 error when it loads ts file
when i make the bucket public it work fine
how i make it private and solve the 403 error , knowing that all the credentials are correct and work when connect to mp4 file just fine
in the attached image the 1st xhr request is successful and it's for the m3u8 file
the below xhr requests is for the ts file and all are 403 error

any help in this ?

A: i think i have to uncheck this option

*

*Block public and cross-account access to buckets and objects through any public or access point policies

i don't know if there's some roles to enable private access without unchecking this option, but at my end it just work.


text:
Q: EF Power Tools Beta 2 and Visual Studio 2012 Express I can't seem to get EF Power Tools to install with VS2012 Express for Web.  Is it only compatible with Standard or Ultimate Editions of VS?

A: Yes it is not compatible with Express edition because Express editions don't allow installing plugins.


text:
Q: jQuery-ui-Slider-Pips Arabic Support Does jQuery-ui-Slider-Pips Has Arabic Support, because if we just make the direction from right to left it will select the wrong item when we click on the drag icon of the slide?
And how can  it be configured to support Arabic or any right to left language?

A: you must use utf8 when you need your code supported arabic:
i think this can helpful
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">

A: Codifier; the plugin does not have any notion of language/text. It simply displays the slider values (by default; numbers) in a linear fashion. But the order is left>right.
If you supply a labels option to the plugin it will accept an array of strings; http://simeydotme.github.io/jQuery-ui-Slider-Pips/#example-hanzi-labels so you may provide your Arabic values in reverse order which could achieve the result you desire.
var numerals = ["٠","١","٢","٣","٤","٥","٦","٧","٨","٩","١٠"];

You may see an example here; http://jsfiddle.net/1utnokeg/1/


text:
Q: 3 balls drawn from 1 urn - probability all same color (with/without replacement)
An urn contains 5 red, 6 blue and 8 green balls. 3 balls are randomly selected from the urn, find the probability that they are all of the same color if:
(a) the balls are drawn without replacement;
(b) the balls are drawn with replacement.

A: $1.$ With replacement: There are three ways this can happen, red, red, red; blue, blue, blue; and green, green, green.
The probability of red, red, red is $\left(\dfrac{5}{19}\right)^3$. Find similar expressions for the other two colurs, and add up.
$2.$ Without Replacement: The probability of red, red, red is $\left(\dfrac{5}{19}\right)\left(\dfrac{4}{18}\right)\left(\dfrac{3}{17}\right)$. Find similar expressions for the other two colours, and add up.
Remark: We could also do the problem by a counting argument. Let's look at the first problem. Put labels on the balls to make them distinct. Then for with replacement, there are $19^3$ strings of length $3$ of our objects. (The three objects in the string are not necessarily distinct.) All of these $19^3$ strings are equally likely.
There are $5^3$ all red strings, $11^3$ all blue, and $8^3$ all green. This gives probability $\dfrac{5^3+6^3+8^3}{19^3}$.
One can do a similar calculation for the without replacement case.
For without replacement, there is a third approach. We can choose $3$ objects from $19$ in $\dbinom{19}{3}$ ways. And we can choose $3$ of the same colour in $\dbinom{5}{3}+\dbinom{6}{3}+\dbinom{8}{3}$ ways.


text:
Q: Is it possible inserting pdf format image in a reportlab generated pdf document? I do not think. It is just to be sure that I need to save in png, jpeg,  etc ... format the images or graphs before inserting in the document.

A: A PDF can contain images, but PDF isn't an image format. You need to save images as images, in an image format (PNG, JPG, etc.).


text:
Q: Nginx config issue I have a peculiar issue with Nginx. I have 2 docker containers one is running with our application and Nginx as a web server(port:80) and the second one contains "traefik". When I browsed my application directly with port(http://example.com), it worked fine but failed when browsing with "traefik" with http://example.com/formbuilderui. We have added some changes in the code level for sub directly(formbuilderui) to work. It was working fine now. Now the actual issue is I am not able to browse my application directly without "traefik". We are doing some modifications to the Nginx config file.
Nginx Change

 root /opt/application;
  index index.html index.htm;

location / {
    try_files \$uri /index.html =404;
  }

  location /formbuilderui {
    rewrite ^/formbuilderui/(.*) /$1  break;
    try_files \$uri /index.html =404;
  }

What I am doing wrong here?


text:
Q: Using FFmpeg to encode a video to h264 using Intel QuickSync I am running this command:
ffmpeg -init_hw_device qsv=hw -filter_hw_device -f rawvideo -pix_fmt yuv420p -s:v 2560x1440 -i normal-desktop-use-1440p.mkv -c:v h264_qsv -
b:v 5M output.mp4
I get the following error:
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-init_hw_device' ... matched as option 'init_hw_device' (initialise hardware device) with argument 'qsv=hw'.
Reading option '-filter_hw_device' ... matched as option 'filter_hw_device' (set hardware device used when filtering) with argument 'hw'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rawvideo'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuv420p'.
Reading option '-s:v' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '2560x1440'.
Reading option '-i' ... matched as input url with argument 'normal-desktop-use-1440p.mkv'.
Reading option '-vf' ... matched as option 'vf' (set video filters) with argument '-c:v'.
Reading option 'h264_qsv' ... matched as output url.
Reading option '-b:v' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '15M'.
Reading option '-framerate' ... matched as AVOption 'framerate' with argument '30'.
Reading option 'output.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Applying option init_hw_device (initialise hardware device) with argument qsv=hw.
[AVHWDeviceContext @ 0x556f744cf5c0] Cannot open X11 display .
[AVHWDeviceContext @ 0x556f744cf5c0] Opened VA display via DRM device /dev/dri/renderD128.
[AVHWDeviceContext @ 0x556f744cf5c0] libva: VA-API version 1.1.0
[AVHWDeviceContext @ 0x556f744cf5c0] libva: va_getDriverName() returns 0
[AVHWDeviceContext @ 0x556f744cf5c0] libva: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
[AVHWDeviceContext @ 0x556f744cf5c0] libva: Found init function __vaDriverInit_1_1
[AVHWDeviceContext @ 0x556f744cf5c0] libva: va_openDriver() returns 0
[AVHWDeviceContext @ 0x556f744cf5c0] Initialised VAAPI connection: version 1.1
[AVHWDeviceContext @ 0x556f744cf5c0] Format 0x32315659 -> yuv420p.
[AVHWDeviceContext @ 0x556f744cf5c0] Format 0x30323449 -> yuv420p.
[AVHWDeviceContext @ 0x556f744cf5c0] Format 0x3231564e -> nv12.
[AVHWDeviceContext @ 0x556f744cf5c0] Format 0x32595559 -> yuyv422.
[AVHWDeviceContext @ 0x556f744cf5c0] Format 0x59565955 -> uyvy422.
[AVHWDeviceContext @ 0x556f744cf5c0] Format 0x48323234 -> yuv422p.
[AVHWDeviceContext @ 0x556f744cf5c0] Format 0x58424752 -> rgb0.
[AVHWDeviceContext @ 0x556f744cf5c0] Format 0x58524742 -> bgr0.
[AVHWDeviceContext @ 0x556f744cf5c0] Format 0x30313050 -> p010le.
[AVHWDeviceContext @ 0x556f744cf5c0] VAAPI driver: Intel i965 driver for Intel(R) Skylake - 2.1.0.
[AVHWDeviceContext @ 0x556f744cf5c0] Driver not found in known nonstandard list, using standard behaviour.
[AVHWDeviceContext @ 0x556f744cf140] Error initializing an MFX session: -3.
Device creation failed: -1313558101.
Failed to set value 'qsv=hw' for option 'init_hw_device': Unknown error occurred
Error parsing global options: Unknown error occurred

I was expecting ffmpeg to encode my video using a hw accelerated h264 encoder via Intel QuickSync.
Useful info about my ffmpeg build:
ffmpeg version N-93636-g6829c3c Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-27ubuntu1~18.04)
  configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/root/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libmfx --enable-nonfree

I have --enable-libmfx enabled.
Using this processor: model name   : Intel(R) Xeon(R) CPU E3-1578L v5 @ 2.00GHz
If I do ffmpeg -encoders | grep qsv I get the following:
 V..... h264_qsv             H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration) (codec h264)
 V..... hevc_qsv             HEVC (Intel Quick Sync Video acceleration) (codec hevc)
 V..... mjpeg_qsv            MJPEG (Intel Quick Sync Video acceleration) (codec mjpeg)
 V..... mpeg2_qsv            MPEG-2 video (Intel Quick Sync Video acceleration) (codec mpeg2video)

A: Pay attention to the output from the console:
[AVHWDeviceContext @ 0x556f744cf5c0] VAAPI driver: Intel i965 driver for Intel(R) Skylake - 2.1.0.
[AVHWDeviceContext @ 0x556f744cf5c0] Driver not found in known nonstandard list, using standard behaviour.
[AVHWDeviceContext @ 0x556f744cf140] Error initializing an MFX session: -3.
Device creation failed: -1313558101.
Failed to set value 'qsv=hw' for option 'init_hw_device': Unknown error occurred

That occurs because you're using the wrong VAAPI driver for QuickSync.
The correct driver should be set to the intel media driver, iHD, as you're using the Media SDK for QuickSync and not the VAAPI-based encoders.
I'll document the steps needed to derive an FFmpeg build with the features you require (QuickSync) with support for extra codecs as may be needed, with extra notes on using the correct driver below:
Ensure the platform is up to date:
I noticed that you're on Ubuntu 18.04 LTS, so these instructions will do:
sudo apt update && sudo apt -y upgrade && sudo apt -y dist-upgrade
Install baseline dependencies first:
sudo apt-get -y install autoconf automake build-essential libass-dev libtool pkg-config texinfo zlib1g-dev libva-dev cmake mercurial libdrm-dev libvorbis-dev libogg-dev git libx11-dev libperl-dev libpciaccess-dev libpciaccess0 xorg-dev intel-gpu-tools libwayland-dev xutils-dev libssl-dev
Then add the Oibaf PPA, needed to install the latest development headers for libva:
sudo add-apt-repository ppa:oibaf/graphics-drivers
sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y dist-upgrade

To address linker problems down the line with Ubuntu 18.04LTS:
Update: This is no longer needed, but it remains for future reference.
Referring to this: https://forum.openframeworks.cc/t/ubuntu-unable-to-compile-missing-glx-mesa/29367/2
Create the following symlink as shown:
sudo ln -s /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0 /usr/lib/x86_64-linux-gnu/libGLX_mesa.so

Build the latest libva and all drivers from source:
Setup build environment:
Work space init:
mkdir -p ~/vaapi
mkdir -p ~/ffmpeg_build
mkdir -p ~/ffmpeg_sources
mkdir -p ~/bin

Start with libva:
1. Libva :
Libva is an implementation for VA-API (Video Acceleration API)
VA-API is an open-source library and API specification, which provides access to graphics hardware acceleration capabilities for video processing. It consists of a main library and driver-specific acceleration backends for each supported hardware vendor. It is a prerequisite for building the VAAPI driver components below.
cd ~/vaapi
git clone https://github.com/01org/libva
cd libva
./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
time make -j$(nproc) VERBOSE=1
sudo make -j$(nproc) install
sudo ldconfig -vvvv

2. Gmmlib:
The Intel(R) Graphics Memory Management Library provides device specific and buffer management for the Intel(R) Graphics Compute Runtime for OpenCL(TM) and the Intel(R) Media Driver for VAAPI.
The component is a prerequisite to the Intel Media driver build step below.
To build this, create a workspace directory within the vaapi sub directory and run the build:
mkdir -p ~/vaapi/workspace
cd ~/vaapi/workspace
git clone https://github.com/intel/gmmlib
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE= Release ../gmmlib
make -j$(nproc)

Then install the package:
sudo make -j$(nproc) install

And proceed.
3. Intel Media driver:
The Intel(R) Media Driver for VAAPI is a new VA-API (Video Acceleration API) user mode driver supporting hardware accelerated decoding, encoding, and video post processing for GEN based graphics hardware, released under the MIT license.
cd ~/vaapi/workspace
git clone https://github.com/intel/media-driver
cd media-driver
git submodule init
git pull
mkdir -p ~/vaapi/workspace/build_media
cd ~/vaapi/workspace/build_media

Configure the project with cmake:
cmake ../media-driver \
-DMEDIA_VERSION="2.0.0" \
-DBS_DIR_GMMLIB=$PWD/../gmmlib/Source/GmmLib/ \
-DBS_DIR_COMMON=$PWD/../gmmlib/Source/Common/ \
-DBS_DIR_INC=$PWD/../gmmlib/Source/inc/ \
-DBS_DIR_MEDIA=$PWD/../media-driver \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=/usr/lib/x86_64-linux-gnu \
-DINSTALL_DRIVER_SYSCONF=OFF \
-DLIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri

Then build the media driver:
time make -j$(nproc) VERBOSE=1

Then install the project:
sudo make -j$(nproc) install VERBOSE=1

Add yourself to the video group:
sudo usermod -a -G video $USER

Note: FFmpeg can now pick up the correct QSV driver on launch, typically iHD if its' installed and present in the ldconfig entries. You no longer have to set the correct driver system-wide in /etc/environment or per launch session in FFmpeg.
4. libva-utils:
This package provides a collection of tests for VA-API, such as vainfo, needed to validate a platform's supported features (encode, decode & postproc attributes on a per-codec basis by VAAPI entry points information).
cd ~/vaapi
git clone https://github.com/intel/libva-utils
cd libva-utils
./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
time make -j$(nproc) VERBOSE=1
sudo make -j$(nproc) install

At this point, issue a reboot:
sudo systemctl reboot

This is needed to reflect the changes made above, such as adding your user to the video group.
Then on resume, proceed with the steps below.
Build Intel's MSDK:
This package provides an API to access hardware-accelerated video decode, encode and filtering on Intel® platforms with integrated graphics. It is supported on platforms that the intel-media-driver is targeted for.
For supported features per generation, see this.
Build steps:
(a). Fetch the sources into the working directory ~/vaapi:
cd ~/vaapi
git clone https://github.com/Intel-Media-SDK/MediaSDK msdk
cd msdk
git submodule init
git pull

(b). Configure the build:
mkdir -p ~/vaapi/build_msdk
cd ~/vaapi/build_msdk
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_WAYLAND=ON -DENABLE_X11_DRI3=ON ../msdk
time make -j$(nproc) VERBOSE=1
sudo make install -j$(nproc) VERBOSE=1

CMake will automatically detect the platform you're on and enable the platform-specific hooks needed for a working build.
Create a library config file for the iMSDK:
sudo nano /etc/ld.so.conf.d/imsdk.conf

Content:
/opt/intel/mediasdk/lib
/opt/intel/mediasdk/plugins

Then run:
sudo ldconfig -vvvv

To proceed.
Build a usable FFmpeg binary with the iMSDK:
Include extra components as needed:
(a). Build and deploy nasm: Nasm is an assembler for x86 optimizations used by x264 and FFmpeg. Highly recommended or your resulting build may be very slow.
Note that we've now switched away from Yasm to nasm, as this is the current assembler that x265,x264, among others, are adopting.
cd ~/ffmpeg_sources
wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.gz
tar xzvf nasm-2.14.02.tar.gz
cd nasm-2.14.02
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"
make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean

(b). Build and deploy libx264 statically: This library provides a H.264 video encoder. See the H.264 Encoding Guide for more information and usage examples. This requires ffmpeg to be configured with --enable-gpl --enable-libx264.
cd ~/ffmpeg_sources
git clone https://code.videolan.org/videolan/x264.git
cd ~/ffmpeg_sources/x264
git pull
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static --disable-opencl --bit-depth=all --enable-pic
PATH="$HOME/bin:$PATH" make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean

(c ). Build and configure libx265: This library provides a H.265/HEVC video encoder. See the H.265 Encoding Guide for more information and usage examples.
cd ~/ffmpeg_sources
hg clone https://bitbucket.org/multicoreware/x265
cd ~/ffmpeg_sources/x265/build/linux
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
make -j$(nproc) VERBOSE=1
make -j$(nproc) install VERBOSE=1
make -j$(nproc) clean VERBOSE=1

(d). Build and deploy the libfdk-aac library: This provides an AAC audio encoder. See the AAC Audio Encoding Guide for more information and usage examples. This requires ffmpeg to be configured with --enable-libfdk-aac (and --enable-nonfree if you also included --enable-gpl).
cd ~/ffmpeg_sources
git clone https://github.com/mstorsjo/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean

(e). Build and configure libvpx:
cd ~/ffmpeg_sources
git clone https://github.com/webmproject/libvpx
cd libvpx
./configure --prefix="$HOME/ffmpeg_build" --enable-runtime-cpu-detect --enable-vp9 --enable-vp8 \
--enable-postproc --enable-vp9-postproc --enable-multi-res-encoding --enable-webm-io --enable-better-hw-compatibility --enable-vp9-highbitdepth --enable-onthefly-bitpacking --enable-realtime-only --cpu=native --as=nasm
time make -j$(nproc)
time make -j$(nproc) install
time make clean -j$(nproc)
time make distclean

(f). Build LibVorbis:
cd ~/ffmpeg_sources
wget -c -v http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.6.tar.xz
tar -xvf libvorbis-1.3.6.tar.xz
cd libvorbis-1.3.6
./configure --enable-static --prefix="$HOME/ffmpeg_build"
time make -j$(nproc)
time make -j$(nproc) install
time make clean -j$(nproc)
time make distclean

(g). Build FFmpeg:
Build an FFmpeg binary with the required options:
cd ~/ffmpeg_sources
git clone https://github.com/FFmpeg/FFmpeg -b master
cd FFmpeg
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig:/opt/intel/mediasdk/lib/pkgconfig" ./configure \
  --pkg-config-flags="--static" \
  --prefix="$HOME/bin" \
  --bindir="$HOME/bin" \
  --extra-cflags="-I$HOME/bin/include" \
  --extra-ldflags="-L$HOME/bin/lib" \
  --extra-cflags="-I/opt/intel/mediasdk/include" \
  --extra-ldflags="-L/opt/intel/mediasdk/lib" \
  --extra-ldflags="-L/opt/intel/mediasdk/plugins" \
  --enable-libmfx \
  --enable-vaapi \
  --enable-opencl \
  --disable-debug \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libdrm \
  --enable-gpl \
  --cpu=native \
  --enable-libfdk-aac \
  --enable-libx264 \
  --enable-libx265 \
  --enable-openssl \
  --enable-pic \
  --extra-libs="-lpthread -lm -lz -ldl" \
  --enable-nonfree
PATH="$HOME/bin:$PATH" make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean
hash -r

Now you can launch your FFmpeg binary from ~/bin/ffmpeg, with the required features.
Notes on encoding with the QSV encoders:
Typically, you will need to initialize a hardware device that will be used by both the encoder(s) in use and filtering, as shown in the example below:
ffmpeg -y -loglevel debug -init_hw_device qsv=hw -filter_hw_device hw -hwaccel qsv -hwaccel_output_format qsv \
-i simpsons.mp4 -vf 'format=qsv,hwupload=extra_hw_frames=64'  \
-c:v hevc_qsv \
-bf 3 -b:v 3.75M -maxrate:v 3.75M -bufsize:v 0.5M -r:v 30 -c:a copy -f mp4 trolled.mp4

See how the hardware device for use with MFX sessions has been initialized (-init_hw_device qsv=hw) and mapped as available to filters such as hwupload (-filter_hw_device hw). Recommended for further reading: The Advanced Video Options section on FFmpeg wiki.
The example above demonstrates the use of the hevc_qsv encoders with some private options passed to it, for reference.
Another example, showing the use of the h264_qsv encoder:
ffmpeg -y -loglevel debug -init_hw_device qsv=hw -filter_hw_device hw -hwaccel qsv -hwaccel_output_format qsv \
-i simpsons.mp4 -vf 'format=qsv,hwupload=extra_hw_frames=64'  \
-c:v h264_qsv \
-bf 3 -b:v 15M -maxrate:v 15M -bufsize:v 2M -r:v 30 -c:a copy -f mp4 trolled.mp4

Take note that both examples above will use the constant bitrate control (CBR) method in MFX, as shown in the console log:
[hevc_qsv @ 0x55faf21eedc0] Using the constant bitrate (CBR) ratecontrol method

Rate control, similar to how the VAAPI implementation governs it, is driven by the parameters -b:v (target video bitrate) and the -maxrate:v (maximum video bitrate) passed to the encoder. If they are equal, CBR (constant bitrate control) is used. If maxrate is greater than target bitrate, then VBR, and in effect, look-ahead based control (if so desired) are enabled.
Observe how we call up the hwupload filter, chained with the format=qsv filter to ensure that the MFX runtime receives a supported pixel format. Failure to pass this video filter chain will result in initialization failure, with output similar to this:
[h264_qsv @ 0x560e1bda7280] Selected ratecontrol mode is unsupported
[h264_qsv @ 0x560e1bda7280] Low power mode is unsupported
[h264_qsv @ 0x560e1bda7280] Current frame rate is unsupported
[h264_qsv @ 0x560e1bda7280] Current picture structure is unsupported
[h264_qsv @ 0x560e1bda7280] Current resolution is unsupported
[h264_qsv @ 0x560e1bda7280] Current pixel format is unsupported
[h264_qsv @ 0x560e1bda7280] some encoding parameters are not supported by the QSV runtime. Please double check the input parameters.
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

The error message may seem ambiguous at first, but it stems primarily from mapping invalid options to the underlying MFX library, such as an unsupported pixel format.
The extra argument extra_hw_frames=64 passed to hwupload has to do with the MFX runtime requiring a fixed frame pool size to be per-allocated. Use a number suitable to your requirements. Generally, you'll need a larger number (64, or thereabouts) if using features such as look-ahead (LA-ICQ).


text:
Q: Providing a default style (attributes) in a custom view Please, let me know, how can I set the default background of a custom button to null.
I mean...
I know I can define a "style" which set android:background to "@null",
and ask users to explicitly apply the style in their layout. For example:
<style name="MyButton" parent="@android:style/Widget.Button">
    <item name="android:background">@null</item>
</style>

and
<com.xxx.widget.MyButton
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    style="@style/MyButton"
    android:text="MyButton" />

Above code is working well.
But how can I apply this style in my class "MyButton" internally and let users not to set style explicitly?
For example, how to make following layout works as before:
<com.xxx.widget.MyButton
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="MyButton" />

I tried to do this in the constructor as below, but its not working.
public MyButton(Context context, AttributeSet attrs) {
    this(context, attrs, com.xxx.R.style.MyButton);
}

PS. I want to apply this "null" background when a user does not set the background
    explicitly.

A: Really late to the party here. But in case someone stumbles upon the same problem, here is my solution.
Let's say we want to have a custom view that extends a TextInputLayout. Here's what the class would typically look like:
class MyTextInputLayout: TextInputLayout {
    constructor(context: Context) : this(context, null)
    constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
        : super(context, attrs, defStyleAttr)
}

Now, in order to use our custom style as default, change the third constructor (the one with three arguments) into this:
class MyTextInputLayout: TextInputLayout {
    constructor(context: Context) : this(context, null)
    constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
        : super(ContextThemeWrapper(context, R.style.MyTextInputLayoutStyle), attrs, defStyleAttr)
}

Now we can use the custom view in a layout XML file like this:
<com.xxx.MyTextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

we no longer need to define style="@style/MyTextInputLayoutStyle" in the component.
In short, we need to replace the context passed to the super constructor with the one that wraps our style. This way we don't need to define R.attr.MyTextInputLayoutStyle in the existing theme. Useful when you want to use the custom view as a library.

A: In your MyButton() constructor, why not call setBackground(null)?

A: This is more or less a cheap way to do it, but why not set the background to a transparent square. Like this ->
transparent_square.xml: (Put it in the drawable directory)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/square"
    android:>

    <solid android:color="#00808080"></solid> // The first two zeros set the alpha
                                              // to 0

</shape>

Then set the background of the button to your drawable.
Button:
<Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Send"
        android:id="@+id/sendButton"
        android:layout_weight="1"
        android:background="@drawable/transparent_square"/>


text:
Q: Equivalent word for 'overseas' for a non-island country? In New Zealand, as an island country, 'overseas' is taken to mean 'any foreign country'.
eg.

I'm going overseas for holiday.
Overseas investors brought $1bn into the country last year.
Instead of buying clothes produced overseas, consider supporting local producers.

The question is - what word is used here when the foreign country isn't 'overseas' per se, for example, Germany talking about France.

A: Consider abroad:

in or to a foreign country

Examples:

I'm going abroad for holiday.
Investors abroad brought $1bn into the country last year.
Instead of buying clothes produced abroad, consider supporting local
  producers.

Source: Merriam-Webster

A: The U.S. is not an island but we routinely refer to foreign countries as "overseas". People quibble about whether Canada and Mexico are "overseas" as you don't have to go over any seas to get there.
In general, "abroad" and "foreign" refer to other countries regardless  of any intervening water. I think "abroad" is relatively rarely used these days. We often simply say "another country". If you're talking about something brought to this country from another country, we say "imported".
Common ways to express your examples:

I'm going to another country for a vacation.
I'm going abroad for a vacation.
Foreign investors brought $1bn into the country last year.
Instead of buying imported clothes, consider supporting local producers.
Instead of buying clothes produced in other countries, ...

I'm suddenly reminded of a news program where the anchorman introduced a reporter's special report by saying, "And now Sally Jones (or whatever her name was) will tell us what she learned when she was a broad ... I mean overseas."

A: For the case where the two countries are adjacent to each other (as in your example of Germany and France), you can use the phrase "across the border".
An American going on vacation might say "I'm going across the border to Canada/Mexico."

A: I think 'overseas' was originally a British term, for the obvious reason that visiting any place 'abroad' involved going 'overseas'. It was widely used up to the 1960s - remember BOAC (British Overseas Airways Corporation).
My own experience whilst living in Australia was that they and the New Zealanders had retained it, perhaps since they were each far more isolated from elsewhere by sea than the 'mother country' was.
It was a societal landmark for middle-aged people to say that their children 'were overseas', meaning they were taking an extended working holiday in Europe or America. It seemed to have that connotation more than it simply meaning they had gone on holiday.
As for Europeans, they would be unlikely to use the word 'overseas'. If they were speaking in their own language, if at all, they might say 'Nous allons à l'étranger cette année' - 'We are going abroad (to foreign lands) this year'. But French people nowadays don't always regard going to Germany as going abroad, as it doesn't involve any passport check, or even that you slow down on the motorway as you pass a sign which says 'Deutschland'.

A: 'International' is another option. (http://en.wiktionary.org/wiki/international#Adjective - sense #5)

From or between other countries [ref]

e.g.
I'm travelling internationally tomorrow, so I'll need some foreign currency.
International investors brought $1bn into the country last year.
Instead of buying clothes produced internationally, consider supporting local producers.

A: "I'll be going out of the country next week."  That's how I'd say it.  I'm in the USA.

A: I suppose that if you're a Brit in Britain, you might say "I'm heading off to the continent for holiday."
If a Brit or American were in Germany and heading for France, I don't think they'd use abroad.  I think they'd identify the country: "I'm popping over to France for a short holiday."  It feels to me that "abroad" is nearly a synonym for "overseas".
I am a Yank living in Washington state, and I sometimes visit Victoria, BC (recommended!). This requires a ferry trip, but no way would I ever say "I'm going overseas/abroad for a vacation."  Unless I were trying to be deceptive.  To me, and I think to those around me, overseas and abroad are nearly the same thing and imply a greater than usual distance.

A: If the specific identity of the foreign country/countries is not important, you can define the category they belong to in terms of the one you are contrasting it with.
For example, your query sentences could be reworded like this:

I'm {staying in this country / not going {overseas / abroad}} when I go on holiday.
Non-German investors brought $1bn into the country last year.
Instead of buying clothes not produced in Germany, consider supporting local producers.


text:
Q: How do I display a users firebase account name using JSQMessages? I am trying to retrieve a persons user information such as, first and last name from the firebase database and have it displayed above the message bubble when a user sends a message to another user.
Below is my code. I am able to send send messages, it is just displaying the firebase user name. Any suggestions?
Thank you!
class ChatViewController: JSQMessagesViewController {

var messages = [JSQMessage] ()

lazy var outgoingBubble: JSQMessagesBubbleImage = {
    return JSQMessagesBubbleImageFactory()!.incomingMessagesBubbleImage(with: UIColor.jsq_messageBubbleLightGray())
} ()

lazy var incomingBubble: JSQMessagesBubbleImage = {
    return JSQMessagesBubbleImageFactory()!.incomingMessagesBubbleImage(with: UIColor.jsq_messageBubbleBlue())
} ()

override func viewDidLoad() {
    super.viewDidLoad()

    self.senderDisplayName = "Wolverine"
    self.senderId = Auth.auth().currentUser?.uid

    // The first line hides the attachment button on the left of the chat text input field. The other two lines of code set the avatar size to zero, again, hiding it.

    inputToolbar.contentView.leftBarButtonItem = nil
    collectionView.collectionViewLayout.incomingAvatarViewSize = CGSize.zero
    collectionView.collectionViewLayout.outgoingAvatarViewSize = CGSize.zero

    // Do any additional setup after loading the view.
    let query = Constants.refs.databaseChats.queryLimited(toLast: 10)

    _ = query.observe(.childAdded, with: { [weak self] snapshot in

        if  let data        = snapshot.value as? [String: String],
            let id          = data["sender_id"],
            let name        = data["name"],
            let text        = data["text"],
            !text.isEmpty
        {
            if let message = JSQMessage(senderId: id, displayName: name, text: text)
            {
                self?.messages.append(message)

                self?.finishReceivingMessage()
            }
        }
    })
}
override func collectionView(_ collectionView: JSQMessagesCollectionView!, messageDataForItemAt indexPath: IndexPath!) -> JSQMessageData! {
    return messages[indexPath.item]

}

override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return messages.count
}
override func collectionView(_ collectionView: JSQMessagesCollectionView!, messageBubbleImageDataForItemAt indexPath: IndexPath!) -> JSQMessageBubbleImageDataSource!
{
    return messages[indexPath.item].senderId == senderId ? outgoingBubble : incomingBubble
}

// This function simply returns nil when JSQMVC wants avatar image data, effectively hiding the avatars. hides the avatars for message bubbles. JSQMVC can show them, but its not needed.

override func collectionView(_ collectionView: JSQMessagesCollectionView!, avatarImageDataForItemAt indexPath: IndexPath!) -> JSQMessageAvatarImageDataSource!
{
    return nil
}
override func collectionView(_ collectionView: JSQMessagesCollectionView!, attributedTextForMessageBubbleTopLabelAt indexPath: IndexPath!) -> NSAttributedString!
{
    return messages[indexPath.item].senderId == senderId ? nil : NSAttributedString(string: messages[indexPath.item].senderDisplayName)
}

override func collectionView(_ collectionView: JSQMessagesCollectionView!, layout collectionViewLayout: JSQMessagesCollectionViewFlowLayout!, heightForMessageBubbleTopLabelAt indexPath: IndexPath!) -> CGFloat
{
    return messages[indexPath.item].senderId == senderId ? 0 : 15
}
override func didPressSend(_ button: UIButton!, withMessageText text: String!, senderId: String!, senderDisplayName: String!, date: Date!)
{
    let ref = Constants.refs.databaseChats.childByAutoId()

    let message = ["sender_id": senderId, "name": senderDisplayName, "text": text]

    ref.setValue(message)

    finishSendingMessage()
  }
 }


text:
Q: GetWindowTextLength() returns 0, supposedly because of invalid window handle I'm trying to build a simple graph plotting application with C and Windows API for studying purposes. It is supposed to take user's input containing a math function of one real variable and then to plot it. I tried to implement user's input capabilities by creating textbox and submit button through calling CreateWindow() from the callback window function. However, when I attempted to test the textbox by evaluating input text size, I received 0 under any conditions (I also made sure that it is not an ASCII/UNICODE issue). GetLastError() got 1400 error code, i.e. invalid window handle. What could be possible reasons for this error and why respective window handle is considered invalid?
I'm using Bloodshed Dev-C++ 5.11 on Windows 10 x64 with 64-bit TDM-GCC 4.9.2.
Please find below the piece of callback function that is causing problems:

    LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
        int len;
        (...other declarations go here...)
        HWND text_box;
        HWND plot_button;

        switch (message){
            case WM_CREATE:
                text_box = CreateWindow("EDIT",
                                       "",
                                       WS_BORDER | WS_CHILD | WS_VISIBLE,
                                       10, 5, 390, 20,
                                       hwnd, (HMENU) 0, NULL, NULL);
                plot_button = CreateWindow("BUTTON",
                             "Plot",
                             WS_VISIBLE | WS_CHILD | WS_BORDER,
                             420, 5, 165, 20,
                             hwnd, (HMENU) 1, NULL, NULL);
                break;

            case WM_COMMAND:
                switch(LOWORD(wParam)){
                    case 1:
                        len = GetWindowTextLength(text_box);
                        printf("%d", len); // a simple console output for testing purposes only, returns 0 disregarding the text length
                    (...other irrelevant code...)
                    break;
                }
            break;
         (...other irrelevant code...)
    }

A: Based on a comment by rafix07:
You need to make text_box static. Every time the window procedure is called this variable is created, so when the WM_COMMAND message is processed this variable is uninitialized.
To make text_box static, do this:
static HWND text_box;


text:
Q: JUnit for a class that contains native method I'm trying to create a unit test for a class that contains a native method. Any propositions how to achieve this because I'm getting as expected a java.lang.UnsatisfiedLinkError when I try go create an instance in the unit test.

A: You have to add the folder containing your dll to your -Djava.library.path configuration for your unit test. This will vary depending on how you're running it. If it's through your IDE, you can set it in there. If it's with maven, you should be able to set that through the surefire plugin http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#argLine.


text:
Q: Permission denied in ubuntu I have the following Lua code:
local f = io.popen("/home/mohammad/LUA", "r")
if f then
    print(f:read("*a"))
else
    print("failed to read")
end

When I execute it in Ubuntu I get an error:
mohammad@ubuntu:~$ lua LUA/project.lua
sh: 1: /home/mohammad/LUA: Permission denied

This is the file permission:
-rwxrwxrwx 1 mohammad mohammad 1185 Feb  3 01:56 LUA/project.lua*

What is the problem? How can I solve it?

A: You are doing
lua LUA/project.lua

If project.lua is in /home/mohammad/LUA then with
io.popen("/home/mohammad/LUA", "r")

you are attempting to popen (pipe-open) the folder. But popen docs in Lua ref manual say

Starts program prog in a separated process and returns a file handle
  that you can use to read data from this program

A folder is not a process so this won't work.
If you meant to use io.open, the call will succeed if folder exists, and the return will be non-nil on Linux (some differences between Linux and Windows in Why is this lua script unable to open a Windows subdirectory?).