text:
Q: MYSQL not returning all rows I want to get the results from the database of the whole year.
This is the query:
SELECT COUNT(tickets_replay.id) AS amount, users.name,
  MONTHNAME(tickets_replay.created) AS month
    FROM `tickets_replay` INNER
    JOIN users ON tickets_replay.user_id = users.id
      WHERE tickets_replay.`created` LIKE '2018%'
        AND tickets_replay.`deleted` = '0000-00-00 00:00:00'
        AND tickets_replay.comment NOT LIKE
         'Uitvoerdatum aangepast naar:%'
        AND tickets_replay.comment NOT LIKE
         'Status is aangepast naar:%'
        AND users.deleted = '0000-00-00 00:00:00'
        AND users.id = 21 GROUP BY MONTH(tickets_replay.created)

In my PhpMyAdmin I'm getting this:

And in my code I get this back:

PHP code:
$sql_dylan = "
SELECT COUNT(tickets_replay.id) AS amount, users.name,
  MONTHNAME(tickets_replay.created) AS month
    FROM `tickets_replay` INNER
    JOIN users ON tickets_replay.user_id = users.id
      WHERE tickets_replay.`created` LIKE '2018%'
        AND tickets_replay.`deleted` = '0000-00-00 00:00:00'
        AND tickets_replay.comment NOT LIKE
         'Uitvoerdatum aangepast naar:%'
        AND tickets_replay.comment NOT LIKE
         'Status is aangepast naar:%'
        AND users.deleted = '0000-00-00 00:00:00'
        AND users.id = 21 GROUP BY MONTH(tickets_replay.created)
";

if ($results_dylan = mysqli_query($sql_connect, $sql_dylan)){
    while($rows_dylan = mysqli_fetch_assoc($results_dylan)) {
        printr($rows_dylan, false);
    }
}

function printr($data, $exit = TRUE)
{
    if ($data) {
        print '<pre>';
        print_r($data);
        print '</pre>';
    }
    if ($exit) {
        exit;
    }
}

I'm using the exact same query and all but I'm not getting all the results.
How can I change that?

A: Short answer:
The reason you are getting different results is because you are testing against different sets of data.
How do we know this?
Look at March and April in your screenshots from the two locations.
Your PHPMyAdmin:

Your PHP Code:

This shows that because the SQL is exactly the same, that the data must be different.
So, double check your MySQL connection is connecting to the correct table on the correct database.


text:
Q: How to execute/Configure JS file from spec file of galen framework I have to invoke a js file from spec file
below is sample files
spec file
 @script highlight.js

 @objects
    header              xpath   /html/body/app/mbx-header/div

 = Verify the focus of header button =
 header:
    text is "${highlight()}"
    ${click('//some/xpath')}
    css box-shadow is "rgb(233, 238, 206)"

highlight.js
this.highlight = function () {
return 'test123';
};

click.js
this.click = function (xpath) {
//code to click element
};

Actually in the above code validation of text works but is there a way to click on element using js. is there a way to inject js file in the spec file to click on a element during execution and then verify the properties
i'm new to java script and Galen .

A: Galen Spec files are more into HTML and CSS rather than performing actions.
To inject Javascript in the middle of the execution you need to create a test.js file.
Here is an example:
test("Inject Javascript", function () {
  var driver = createDriver("http://website_url_goes_here", "640x480");
  inject(driver,"your javascript code here");
  checkLayout(driver, "yourspec.gspec");
});

Hope this helps.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to define a dependency to a specific package of a third party jar. I do not want all packages of the Jar just few specific packages Let's suppose I have a 3rd party jar commons-lib-1.1.0.jar  that contains 3 packages like com.web, com.service and com.dao. I only want com.dao package in my project. I am referring it in my Gradle build as a dependency.
dependencies {
   implementation 'com.testorg:commons-lib:1.1.0.jar'
}

This way I am getting whole jar (all packages), but I just want com.dao package from it.
Please help how to define a dependency to a specific package of a third party jar. Is it even possible in Gradle or Maven?


text:
Q: Restoring SQL Server 2012 Enterprise to Web Edition not possible due to full text partitioning I have an SQL Server 2012 Enterprise database I'm trying to restore to SQL Server 2012 Web Edition instance. I've used sys.dm_db_persisted_sku_features to find features to remove before a backup/restore down edition will work. I found partitioning and compression which I removed but sys.dm_db_persisted_sku_features still tells me partitioning exists.
After looking closer I found several partition schemes and functions with names like ifts_comp_fragment_data_space_xxxxxxxx and ifts_comp_fragment_partition_function_xxxxxxxx respectfully which are set to is_system=1. When trying to remove them I get the error "Cannot drop the partition scheme 'ifts_comp_fragment_data_space_ xxxxxxxx ', because it does not exist or you do not have permission."
Apparently these are automatically created when full text indexes become large. I've removed all full text catalogs but the schemes and functions remain. Thinking they may not matter I tried the backup /restore. Within the restore error message was "Database '' cannot be started in this edition of SQL Server because it contains a partition function 'ifts_comp_fragment_partition_function_xxxxxxxx".
I've only found one solution here which forces the objects is_system property to 0 but it comes with a disclaimer that the solution probably isn't supported by Microsoft. Assuming this would disqualify us for support in the future this is not an option for me.
Is there any other way around this problem? A way to remove these partitioning schemes and functions?


text: Q: Webcam not detected after installing ubuntu 18.04 on macBook 2,1 I have installed ubuntu 18.04 LTS on my macBook 2,1. After installing, cheese is working perfectly but whenever i am trying to connect through zoom or something like video calling softwares it show "something went wrong, no webcam and microphone detected".


text:
Q: Set width of grid column with dynamic number of columns Is it possible to set width of columns in grid when we don't know the number and order of them?
I have a dynamically rendering data. For example:
  dataArray = [
{
  title: 'A',
  data: [1, 2, 3, 4],
},
{
  title: 'B',
  data: [1, 2, 3, 4],
},
{
  title: 'C',
  data: [1, 2, 3, 4],
},
{
  title: 'D',
  data: [1, 2, 3, 4],
},
  ];

I 'm displaying it as grid in this way:

{{ d.title }}

{{ data }}

My css:
.grid {
  display: grid;
}

.column {
  grid-row: none;
}

Now I want to set width to some columns. For example I want to set width of column:

*

*title: A - width 100px

*title: D - width: 150px.

I want to set those widths by titles, I don't know in witch order those column will render and how many of them will be. And I want the other columns to fit the content. I tried with grid-template-columns but I missed. Can anyone help me?
Thanks


text:
Q: Insert Query If Statement PHP I created a process form that inserts values from one php page into the database. I would like to email the results of the form to several users using some type of authentication method. I thought I could achieve this with mysql_query(), but it plugs in the data, but isn't sending a email.
$sql = insert query
$connection = mysql_connect

I used:
if (!mysql_query($sql,$connection))
 {
     die('Error' . mysql_error());
 }

I tried to insert mail() after the if statement, but it doesn't work. If I insert mail() after the die statement anyone is able to process the file and send emails. How can I get this to work? Any help is appreciated.

A: Without more information, this is the best answer I could give on the situation.
$query = mysql_query($sql,$connection);
if($query === true){
    //mail code
    mail();
} else {
    //Log some errors here
}

A: Whenever you execute mysql_query function, it returns a resource id in case of success.
So you can use in this way:
$result = mysql_query($sql,connection);

if($result){
    // mail function
    mail();
}else{
   die(mysql_error());
}

And as you stated, mail function is called after die(), that should be possible only in case, when no mysql_error is thrown and mail function is called out of the if loop.


text:
Q: Create UITableView with multiple Custom Cells in Swift What is the best current way to create an UITableView with multiples Custom Cell with the storyboard and the tableView methods?
For now, I get correctly my JSON response split into 3 arrays then I want to use it to update my tableView with 3 different custom cells.
class MainViewController: UIViewController {

    // MARK: - Properties
    var starters = [Starter]()
    var dishes = [Dish]()
    var deserts = [Desert]()

    // MARK: - Outlets
    @IBOutlet weak var foodTableView: UITableView!

    // MARK: - Functions
    func updatDisplay() {
        ApiHelper.getFoods { starters, dishes, deserts in
            self.starters = starters
            self.dishes = dishes
            self.deserts = deserts
            self.foodTableView.reloadData()
        }
    }

    // MARK: - View Lifecycle
    override func viewDidLoad() {
        super.viewDidLoad()
        updatDisplay()
    }
}

extension MainViewController: UITableViewDelegate, UITableViewDataSource {

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 0
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "StarterCell", for: indexPath)

        return cell

    }
}

A: Assuming that you have the three sections "starters", "dishes" and "deserts" you can display the cells like this:
override func numberOfSections(in tableView: UITableView) -> Int {
    return 3
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if section == 0 {
        return starters.count
    }
    else if section == 1 {
        return dishes.count
    }
    else {
        return deserts.count
    }
}

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
    if section == 0 {
        return "Starters"
    }
    else if section == 1 {
        return "Dishes"
    }
    else {
        return "Deserts"
    }
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    if indexPath.section == 0 {
        return tableView.dequeueReusableCell(withIdentifier: "StarterCell", for: indexPath)
    }
    else if indexPath.section == 1 {
        return tableView.dequeueReusableCell(withIdentifier: "DishesCell", for: indexPath)
    }
    else {
        return tableView.dequeueReusableCell(withIdentifier: "DesertsCell", for: indexPath)
    }
}


text:
Q: How to add LVL to my non-gradle project? I have had to modify one old app, developed in Eclipse. I have working with Android Studio, and I need to integrate License Verification Library in the project, but it is not a gradle project, so I don't know how to put the files, reading the documentation of google, I'm not able to achieve this.
I have downloaded the play licensing from the SDK. My project has assests, res, libs, gen, and src folders. What I need to do?
Sorry for my english.

A: If your project is compiling fine in Android Studio, then that means that it already has gradle. Import the LVL into your project as a module, then add it to the app module's gradle build script as a dependency.


text:
Q: pygame constant movement with if statement i am trying to make a simple game but movement doesn't work properly
i want it to constantly move while the buttons are pressed but respect the borders of the screen currently the buttons will work overall but it causes the rectangle to stutter, here is my code,
import pygame

pygame.init()

SD = pygame.display.set_mode((640,480))
x = 16
y = 16

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()
        keys = pygame.key.get_pressed()
        if keys[pygame.K_w]:
            if y > 0:
                y -= 8
        if keys[pygame.K_a]:
            if x > 0:
                x -= 8
        if keys[pygame.K_s]:
            if y < 448:
                y += 8
        if keys[pygame.K_d]:
            if x < 608:
                x += 8
    SD.fill((255,255,255))
    pygame.draw.rect(SD, (255,0,0), (x,y, 30, 30))
    pygame.display.update()

A: pygame.event.get() will only return an event if a hardware event happened like pressing a key. So your if keys[...] won't be evaluated when nothing happens (a pressed key event won't get repeated)
Move your ifs one level up and it will work without stuttering but you'll have to slow down the movement of your box afterwards (a sleep(0.1) will do for the example but you probably want to move to something more advanced since you don't want to sleep in you drawing loop)

A: The way key presses are handled in pygame (and most other game engines) is that you only get an event when a key is pressed or released. The reason your character movement is looking so jumpy, is because the key press is being handled like holding a key down in a text editor. If you hold the key down, a letter will show up and after a short while you'll get lots of the letter repeating.
What you really want to do is to have a boolean for each key that you set to True when you get a key press event, and False when you get a key release event (take a very careful look at the process_events function).
I've modified your code to do just that (along with some other changes that I'll explain afterwards):
import pygame

class Game(object):
    def __init__(self):
        """
        Initialize our game.
        """
        # The initial position.
        self.x = 16
        self.y = 16

        # The keyboard state.
        self.keys = {
            pygame.K_w: False,
            pygame.K_a: False,
            pygame.K_s: False,
            pygame.K_d: False,
        }

        # Create the screen.
        self.SD = pygame.display.set_mode((640,480))

    def move_character(self):
        """
        Move the character according to the current keyboard state.
        """
        # Process vertical movement.
        if self.keys[pygame.K_w] and self.y > 0:
            self.y -= 1
        if self.keys[pygame.K_s] and self.y < 448:
            self.y += 1

        # Process horizontal movement.
        if self.keys[pygame.K_a] and self.x > 0:
            self.x -= 1
        if self.keys[pygame.K_d] and self.x < 608:
            self.x += 1

    def process_events(self):
        """
        Go through the pending events and process them.
        """
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()
            # If the event is a key press or release event, then register it
            # with our keyboard state.
            elif event.type == pygame.KEYDOWN:
                self.keys[event.key] = True
            elif event.type == pygame.KEYUP:
                self.keys[event.key] = False

    def draw(self):
        """
        Draw the game character.
        """
        self.SD.fill((255,255,255))
        pygame.draw.rect(self.SD, (255,0,0), (self.x, self.y, 30, 30))
        pygame.display.update()

    def run(self):
        while True:
            self.process_events()
            self.move_character()
            self.draw()

def main():
    pygame.init()

    game = Game()
    game.run()

# This just means that the main function is called when we call this file
# with python.
if __name__ == '__main__':
    main()

The biggest change I've made is to move your game into a class to give you better access to variables from your functions. It also lets you partition your code into different functions that make it easier to read.


text:
Q: Kähler form on the Blow up of a Kähler manifold Given a Kähler manifold $X$, the blow up is a Kähler manifold aswell (see Hodge theory and CAG by Voision Prop. 3.24).
The idea is of course to use the pull-back the Kähler form $\pi^*\omega_X$. It says that this form is not positive, but only semi-positive and I fail to see why exactly.
Positivity of $\omega_x$ means that locally we can write $\omega_x= \sum_i \alpha_i dz_i\wedge d\bar z_i$ with $\alpha_i$ real and non-negative.
Now $\pi^*\omega_X= \sum_i (\alpha_i\circ\pi) d(z_i\circ\pi)\wedge d(\bar z_i\circ\pi)$.
Obviously the coefficients $(\alpha_i\circ\pi)$ still remain positive, so somehow the differential forms $ d(z_i\circ\pi)\wedge d(\bar z_i\circ\pi)$ must vanish on some special tangent vectors in a neighborhood around the blow up?
I am also not sure, if my notion of positivity is correct or appropriate here.

A: Let $\widetilde X$ be the blowup of $X$, and let $\pi\colon \widetilde X\to X$ denote the blow-down map. If the local coordinates $(z_i)$ are chosen so that $z=0$ is the point being blown up, then $D = \pi^{-1}(0)\subseteq \widetilde X$ is a complex hypersurface called the exceptional divisor. Because $z_i\circ\pi\equiv 0$, it follows that $d(z_i\circ \pi)$ annihilates every vector tangent to $D$, and the same goes for $d(\bar z_i\circ\pi)$.

A: If $M$ and $N$ be complex manifolds of the same dimension and $π:M→N$ is a holomorphic mapping, then for a volume form (as measure )$Ψ$ on $N$ the pull-back $π^∗Ψ$ is positive outside aramification divisor of $M$ and may not be a positive on the whole of $M$. There is a classical paper of P. Griffiths
http://publications.ias.edu/sites/default/files/nevanlinna.pdf
From Principles of Algebraic Geometry by Phillip Griffiths and Joseph Harris, we have:
Let $Y\subset X$. If $Y$ is compact then blow up is Kahler but to construct the metric on $Bl_YX $substantially you use $π^∗ω+εc_1(\mathcal O(−E))$ where $E$ is the exceptional divisor and $π:Bl_YX\to X$ is the canonical surjection
Definition of positivity of pull back of kahler form as current is different with what you wrote , see this paper. See also the definition of pull back of current https://arxiv.org/pdf/math/0606248.pdf
See Lemma 34. of this paper


text:
Q: Ommiting a row when boxplotting I have a file that looks like this:
        1   0.237340    0.135170    0.339511    0.237653    0.135482    0.339823
        2   0.561320    0.422007    0.700633    0.165871    0.026558    0.305184
        3   0.694760    0.534205    0.855314    0.074856    -0.085698   0.235411
        4   0.728306    0.560179    0.896432    0.003361    -0.164765   0.171487
        5   0.711710    0.544944    0.878477    -0.044582   -0.211349   0.122184
        6   0.671241    0.511191    0.831291    -0.073347   -0.233397   0.086703
        7   0.621177    0.471219    0.771135    -0.088418   -0.238376   0.061540
        8   0.569354    0.431826    0.706882    -0.094382   -0.231910   0.043146
        9   0.519973    0.396571    0.643376    -0.094619   -0.218022   0.028783
        10  0.475121    0.366990    0.583251    -0.091467   -0.199598   0.016664

Most of the time, I need to plot two columns against eachother. That works fine. Occasionally, however, I need a row-wise boxplot. To do this, my idea was to transpose the table and then select the row I want as a column. The problem then is that the first row contains the indices and needs to be removed. This answer shows how to ommit a number of rows for scatter plots and histrograms, but the suggested workaround for boxplots is a bit hacky. I was wondering if there is an easyier solution, especially since I only need to ommit the first row and also know its value.
This is what I have now, but since the index is not ommited, there is a big outlier (10) in the boxplot.
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{tikz}
\usepgfplotslibrary{statistics}
\usepackage{pgfplotstable}

\begin{document}
    \pgfplotstableread{
        1   0.237340    0.135170    0.339511    0.237653    0.135482    0.339823
        2   0.561320    0.422007    0.700633    0.165871    0.026558    0.305184
        3   0.694760    0.534205    0.855314    0.074856    -0.085698   0.235411
        4   0.728306    0.560179    0.896432    0.003361    -0.164765   0.171487
        5   0.711710    0.544944    0.878477    -0.044582   -0.211349   0.122184
        6   0.671241    0.511191    0.831291    -0.073347   -0.233397   0.086703
        7   0.621177    0.471219    0.771135    -0.088418   -0.238376   0.061540
        8   0.569354    0.431826    0.706882    -0.094382   -0.231910   0.043146
        9   0.519973    0.396571    0.643376    -0.094619   -0.218022   0.028783
        10  0.475121    0.366990    0.583251    -0.091467   -0.199598   0.016664
    }{\table}
    \pgfplotstabletranspose[string type]\tableT{\table}
    \pgfplotstablegetcolsof{\tableT}
    \pgfmathsetmacro\numberofCols{\pgfplotsretval-1}
    \begin{tikzpicture}
        \begin{axis}[]
            \addplot+[boxplot] table [y index=\numberofCols]{\tableT};
        \end{axis}
    \end{tikzpicture}
\end{document}

A: For this case you can tell pgfplotstable to use the first column as the header row for the transposed table, with colnames from={0}. Because your table doesn't have a header row, no text entries in the first row, column indices are used as column names. pgfplotstable counts from zero, so 0 is the first column.
Note by the way that with pgfplotstableread{..}\table you break the table environment, because \begin{table} does \table, so be careful what you use for table names.

\documentclass{article}
\usepackage{pgfplotstable} % loads pgfplots which loads tikz
\usepgfplotslibrary{statistics}

\begin{document}

    % be careful what you name these, with \table you break the table-environment,
    % because \begin{table} does \table "behind the scenes"
    \pgfplotstableread{
        1   0.237340    0.135170    0.339511    0.237653    0.135482    0.339823
        2   0.561320    0.422007    0.700633    0.165871    0.026558    0.305184
        3   0.694760    0.534205    0.855314    0.074856    -0.085698   0.235411
        4   0.728306    0.560179    0.896432    0.003361    -0.164765   0.171487
        5   0.711710    0.544944    0.878477    -0.044582   -0.211349   0.122184
        6   0.671241    0.511191    0.831291    -0.073347   -0.233397   0.086703
        7   0.621177    0.471219    0.771135    -0.088418   -0.238376   0.061540
        8   0.569354    0.431826    0.706882    -0.094382   -0.231910   0.043146
        9   0.519973    0.396571    0.643376    -0.094619   -0.218022   0.028783
        10  0.475121    0.366990    0.583251    -0.091467   -0.199598   0.016664
    }{\datatable}

    % the colnames from-key lets you define a column from the old table
    % to use as column names in the transposed one
    \pgfplotstabletranspose[string type,colnames from={0}]\tableT{\datatable}
    \pgfplotstablegetcolsof{\tableT}
    \pgfmathsetmacro\numberofCols{\pgfplotsretval-1}

    \pgfplotstabletypeset\tableT

    \begin{tikzpicture}
        \begin{axis}[]
            \addplot+[boxplot] table [y index=\numberofCols]{\tableT};
        \end{axis}
    \end{tikzpicture}

\end{document}


text:
Q: Wordpress thumbnail and meta data being ignored when posting to facebook wall I'm having a problem that I can't seem to figure out, though I'm not sure if I'm on the right track. Can anyone please advise?
I've just created a wordpress website, that post's will be shared on facebook.
I'm using featured images and I would like my featured image facebook thumbnail to be used.
It seems when I post a link to facebook, facebook just picks up images on the page and you can choose a thumbnail.
I'm not really up for that because the images are landscape and don't look good. So I started looking into meta tag with the open graph property to see if I could dynamically populate the content that facebook captures when posting a link to the wall.
This is what I tried...
<meta name="description" content="" />
<meta name="author" content="" />
<meta charset="utf-8" />
<meta property="fb:app_id" content="0000000000000000" />

<?php if ( is_single() || is_page() ) { ?>

<meta property="og:title" content="<?php echo get_the_title(); ?>" />
<meta property="og:type" content="article" />
<meta property="og:url" content="<?php echo get_permalink(); ?>" />
<meta property="og:image" content="<?php $fbthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'facebook-thumb' ); echo $fbthumb[0]; ?>" />
<meta property="og:site_name" content="myblog.co.uk"/>
<meta property="og:description" content="<?php echo get_the_excerpt(); ?>" />

<?php } ?>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

But all of this is ignored!!!
Can anyone help me understand how to control the content facebook draws in via a link being posted to a wall. I would appreciated your help very much.
Thanks

A: I had this problem the other day. Facebook wants og:images to be larger than 200px in both directions, or it will ignore them. I found I got the best result when I used wp_get_attachment_image_src($img.ID, 'large')
Have you tried looking at your site with the Facebook Debugger to see what it has to say about your site? https://developers.facebook.com/tools/debug


text:
Q: Python SIP expose function I'm writing a Python module for some C++ code using SIP. However whilst I can easily expose classes, I cannot find a way to expose standalone functions.
Here is my header file defining the functions that I wish to expose to Python: ProxySettings.h
#include <Windows.h>
#include <Wininet.h>

bool SetConnectionOptions(const char * proxy_full_addr);
bool DisableConnectionProxy();

And here is my attempt at my SIP file so far: ProxySettings.sip. Currently running sip.exe generates C++ code with no problems, but when I come to compile it, the compiler complains about missing identifiers SetConnectionOptions and DisableConnectionProxy.
%Module ieproxy 0

bool SetConnectionOptions(const char * proxy_full_addr);
bool DisableConnectionProxy();

I think that I have to use a directive to include the ProxySettings.h header file into my SIP file, but I am not sure what directive to use. %TypeHeaderCode which is what you use for a class doesn't work with just a function.
Does anyone have any suggestions?

A: Try this:
%Module ieproxy 0

%UnitCode
#include <ProxySettings.h>
%End

bool SetConnectionOptions(const char * proxy_full_addr);
bool DisableConnectionProxy();


text:
Q: Application does not own action type I am working with an application that uses facebook opengraph to post custom objects to a user's wall with a respective custom action. While working in an iOS environment, I am attempting to use the SDK function call:
- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
                         andParams:(NSMutableDictionary *)params
                     andHttpMethod:(NSString *)httpMethod
                       andDelegate:(id <KC_FBRequestDelegate>)delegate;
to post the object. I specified the GraphPath as:
"me/[APP_NAME]:[APP_ACTION]"

and supplied the Params with a correct access token, api_key, and url to the object to be posted on the user's wall.
I then receive the error message:
{"error":{"message":"(#100) Application does not own 479077275455517 action type","type":"OAuthException","code":100}}

in the response from Facebook.
Any insights?

A: While following a tutorial for iOS SDK integration, I experienced this same issue running tests through the Graph API Explorer, until  I finally noticed the sentence on the tutorial: "Go to the Graph API Explorer and select your app from the ''Application'' list."
Essentially I was attempting to post an action to the Graph API Explorer app itself, hence the error, since I do not have privileges to access that app, obviously.
So with that said, most likely somewhere in the setup of the Facebook sdk in your project, you have not entered or incorrectly entered your facebook app id, which produces the error you see.

A:
Application does not own 479077275455517 action type

Is that the name of your action? I doubt it. Rather looks like it might be your app id.
That clearly points to a wrongly build Graph URL. Write it somewhere for debugging, and see what it really contains.

A: I know this post is old, but I had this same problem and recently resolved it. Be sure to check the FB API call for the correct [APP_NAME]. In my case, I had a test app and a live app, and I had coded the live [APP_NAME] in my FB API call:
FB.api("me/[APP_NAME]:[APP_ACTION]"...
So even though I had the my test app ID in the init, I was calling the prod app namespace in my FB API call.
Yes, [APP NAME] represents the app's namespace.
Hope this helps to clarify for anyone else who runs into this issue.


text:
Q: Запись списка кортежей побайтово в файл Есть список пар чисел <= 10**9.
l = [(0, 15), (3, 48)]

Как записать их в файл в байтовом виде, чтобы на каждый элемент списка в итоге было по 8 байт? Т.е. размер итоговый:
len(l) * (4 + 4)

A: Думаю, примерно так:
import os.path

l = [(0, 15), (3, 48)]

with open('file.txt', 'wb') as f:
    for (a, b) in l:
        f.write(a.to_bytes(4, 'big'))
        f.write(b.to_bytes(4, 'big'))

print(len(l) * (4 + 4))
# 16

print(os.path.getsize('file.txt'))
# 16

A: l = [(0, 15), (3, 48)]

with open('file.txt', 'wb') as f:
    for (a, b) in l:
        f.write(a.to_bytes(4, 'big') + b.to_bytes(4, 'big'))

    f.write(b'\n')

Попробовал так, всё получилось, спасибо gil9red.


text:
Q: Output always corrupt from FFMPEG using selenium python i try to running testcase using selenium python and want to record video on every testacases, but when i try the output is always corrupted. FFMPEG process are running, no error appear on the output line. I attach my code, Please anyone help me is there anything i need to add or remove
here's the first file, for recorder :
import subprocess
from subprocess import Popen
from subprocess import call

class recorderMethod():
    videoRecording = None

    @staticmethod
    def recorder_start(res,name):
        rec_lib          = 'ffmpeg -y -rtbufsize 2000M -f dshow  -i video="screen-capture-recorder" -s '
        resolution       = res
        buffer           = ' -b:v 512k -r 20 -vcodec libx264 '
        filename         = name
        extension        = '.mp4'
        complete_command = rec_lib+resolution+buffer+filename+extension

        recorderMethod.videoRecording = Popen(str(complete_command))

    @staticmethod
    def recorder_stop():
        if recorderMethod.videoRecording.poll() is None:
            call('taskkill /F /T /PID ' + str(recorderMethod.videoRecording.pid))

here's the main test file for record the video
import unittest
import recorder_main
from selenium import webdriver
from time import sleep

class recordingTest(unittest.TestCase):
    #init test
    browser         = webdriver.Chrome()
    baseurl         = 'http://www.facebook.com/'
    record          = recorder_main.recorderMethod

    #setup
    def setUp(self):
        #declare to use browser
        self.driver = recordingTest.browser
        #make variable for easy access
        driver = self.driver
        #maximize Firefox
        driver.maximize_window()
        #go to maukerja
        driver.get(recordingTest.baseurl)

    #test001
    def test_001_record(self):
        #start recording
        recordingTest.record.recorder_start('1920x1080','Test_Sleep')
        sleep(10)
        #stop_recording
        recordingTest.record.recorder_stop()

    #teardown
    def test_999_ShutDownTest(self):
        self.driver.close()

if __name__ == '__main__':
    unittest.main(exit=False)

A: You need to gracefully stop FFmpeg:
You may use the following code:
import signal

# ...

# https://stackoverflow.com/questions/9722624/how-to-stop-ffmpeg-remotely
# https://stackoverflow.com/questions/27356837/send-sigint-in-python-to-os-system
def recorder_stop():
    if recorderMethod.videoRecording.poll() is None:
        recorderMethod.videoRecording.send_signal(signal.CTRL_C_EVENT)
        sleep(3)  # To be sure that the process ends

The code you are using for closing FFmpeg is:
call('taskkill /F /T /PID ' + str(recorderMethod.videoRecording.pid))

Closing FFmpeg using taskkill, results a corrupted file.
FFmpeg is terminated without finish writing the video stream to the output file.
In old versions of FFmpeg recording is stopped by pressing Q (I don't know how old).
For new versions, the recording is stopped by pressing Ctrl-C.
Lets assume we are using a new version.
Sending signal.CTRL_C_EVENT is equivalent to quitting by pressing Ctrl-C.

Note:
In case you want FFmpeg to record the screen for 10 seconds and terminate, you may add -t 10 (output) argument, without executing recorder_stop().

A: First i change this line
rec_lib          = 'ffmpeg -y -rtbufsize 2000M -f dshow  -i video="screen-capture-recorder" -s '

into this line
rec_lib          = 'ffmpeg -y -rtbufsize 2000M -f dshow -i video="screen-capture-recorder" -b:v 512k -r 20 -vcodec libx264 -strict -2 -preset slow -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -f mp4 '

and then for stopping i adding this :
recorderMethod.videoRecording.stdin.write('q'.encode("GBK"))
recorderMethod.videoRecording.communicate()
if recorderMethod.videoRecording.poll() is None:
   call('taskkill /F /T /PID ' + str(recorderMethod.videoRecording.pid))


text:
Q: Align a TextBlock and image in top of screen - uwp I want to place an image at top left of screen. and a TextBlock at center of same line as image placed. Means at the top of screen there should be an image at left and a TextBlock at center. I tried like below. But both image and TextBlock are seems to be aligned at center.
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Background="AliceBlue" VerticalAlignment="Top">
    <Image x:Name="icon_goback2" Source="Assets/icon_home.png" Margin="10,0,0,0" Height="50" Width="50" />
    <TextBlock Text="Your Page" HorizontalAlignment="Center" FontWeight="Bold" Foreground="White" FontSize="70" />
</StackPanel>

A: You can try the following code :
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Image x:Name="icon_goback2" Source="Assets/icon_home.png" Margin="10,0,0,0" Height="50" Width="50"/>
    <TextBlock Grid.Column="1" Text="Your Page" HorizontalAlignment="Center" FontWeight="Bold" Foreground="White" FontSize="70"/>
</Grid>

What this code will do is divide your grid into 3 Columns and place the <Image> in the 1st Column (Grid.Column="0") and <TextBlock> in the 2nd Column (Grid.Column="1"). You can additionally change the alignment of Image and Texblock if you need to.
Also, it is good to note that StackPanel will always override the Horizontal alignment of the Child elements when you are setting its orientation as horizontal. This is the reason why using a grid and dividing it into multiple rows and columns is better in scenarios like this.

Edit :
Since you have quite a large textblock you can change the column definitions to something like this :
<Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
 </Grid.ColumnDefinitions>

This will divide your grid into 2 parts with the column widths set automatically.
Hope this helps.

A: Just use a Grid and set HorizontalAlignment as Left and Center for Image and TextBlock respectively
<Grid VerticalAlignment="Top">
    <Image HorizontalAlignment="Left"/>
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>


text:
Q: Cannot read property 'isLoggedIn' of null Hi all I am currently stuck with the following:
Cannot read property 'isLoggedIn' of null
>  9 | const Header = () => {
  10 |   const {isLoggedIn} = useContext(AuthContext);
  11 |   return (
  12 |

I am new in React and I was following a tutorial to implement a sign-in/sign-up form and sending data to firebase (which is also something completely new to me). I was able to fix a couple of previous issues on my own but I am now stuck at this one.
If I don't import the Header into the Routing the site works fine but as soon as I try to import it in any way to Routing.js it's failing.
Header.js
import React, { useContext } from "react";
import routes from "./routes";
import { Link } from "react-router-dom";
import { AuthContext } from "./test";

const Header = () => {
  const {isLoggedIn} = useContext(AuthContext);
  return (

    {routes.map((route, i) => (

        <Link to={route.path}>{route.name}</Link>

    ))}
    {isLoggedIn &&
<Link to="/reports">Profile</Link>
}

  )
}

export default Header;

Routing.js
import React from "react";
import Head from "./Head";
import Join from "./Join";
import Login from "./Login";
import Test from "./test";
import HomePage from "./HomePage";
import Header from "./Header";

import { BrowserRouter as Router, Switch, Route, Link} from "react-router-dom";

function Home() {
  return (

    <HomePage />

  );
}

function Reviews() {
  return (

);
}

function Logging() {
  return (

    <Test />

  );
}

function Signup() {
  return (

    <Test />

  );
}

function App() {
  return (
    <Router>
      <Switch>
        <Route path="/" exact component={Home} />
        <Route path="/review" exact component={Reviews} />
        <Route path="/login" exact component={Logging} />
        <Route path="/signup" exact component={Signup} />
      </Switch>
    </Router>
  )
}

export default App;

import React, { useState, useEffect } from "react";
import ReactDOM from "react-dom";
import { Switch, BrowserRouter as Router, Route } from "react-router-dom";
import routes from "./routes.js";
import Header from "./Header";
import "./styles.css";

import * as firebase from "firebase";
import firebaseConfig from "./firebase.config";
import protectedRoutes from './protectedRoutes'

import ProtectedRouteHoc from './ProtectedRouteHoc'

firebase.initializeApp(firebaseConfig);

export const AuthContext = React.createContext(null);

function Test() {
  const [isLoggedIn, setLoggedIn] = useState(false);

  function readSession() {
    const user = window.sessionStorage.getItem(
            `firebase:authUser:${firebaseConfig.apiKey}:[DEFAULT]`
        );
        if (user) setLoggedIn(true)
  }
  useEffect(() => {
    readSession()
  }, [])

  return (
    <AuthContext.Provider value={{ isLoggedIn, setLoggedIn }}>
      Is logged in? {JSON.stringify(isLoggedIn)}

        <Router>

          <Switch>
            {protectedRoutes.map(route => (
              <ProtectedRouteHoc
                key={route.path}
                isLoggedIn={isLoggedIn}
                path={route.path}
                component={route.main}
                exact={route.exact}
                public={route.public}
              />
            ))}
            {routes.map(route => (
              <Route
                key={route.path}
                path={route.path}
                exact={route.exact}
                component={route.main}
              />
            ))}
          </Switch>
        </Router>

    </AuthContext.Provider>
  );
}

export default Test;

I would appreciate any tips or things I can read through to get a better understanding in this.

A: You're destructing the return value of  useContext(AuthContext). You're expecting it to return an object with a key isLoggedIn, e.g. { isLoggedIn: false }, but it's returning null instead. You probably haven't given it a default value when you instantiated the context instance, e.g.
// Possibly what you're doing, no default value
const AuthContext = React.createContext() // null

// Instantiated with a default value
const AuthContext = React.createContext({ isLoggedIn: false })


text:
Q: Mean error on training set equals mean error on testing set? I am training a deep network (GoogleNet) on an image classification issue. I have a dataset of around 7300 images labelized among only 2 classes.
I divided my set in a training and validating set in these proportions : 0.66 / 0.33.
During the training I compute the mean error on the training set and on the testing set to see how it evolves.
The thing is that these two values are always equal (or reeeeally close).
So maybe it is not an issue but I did not expect that to happen. Since I am training on my training set I expected the mean error on my training set to always be ess that the mean error on my testing set (even if I hoped for these two value to converge towards around the same value).
Maybe someone here could tell me if it is normal or not ? And in the case of it being expected, why ? and if it's not, any idea on what is going on ?
Further info that might be useful : I use mini batches of 50, adam optimizer, my loss is computed with tf.nn.softmax_cross_entropy_with_logits(labels=y_, logits=y_predict), I use a dropout of 0.4 (but when I compute the mean error I make sure it is 1).
Thank you.

A: This is quite reasonable.  You partitioned your data into two random samples from the same population.  Yes, they should have nearly identical averages, given the sizes of the samples.  This is a simple effect of the law of large numbers: samples taken from the same population will tend to have the same mean.


text:
Q: How to Add a BIOS version and computer model name using a System.Windows.Forms.Form - PowerShell I'm new to powershell and I would like to know if is possible to add BIOS version and Laptop/Desktop model name on a Multiple-selection list boxes on PowerShell.
This is an image of the script interface.

I started building this script with this link:
https://learn.microsoft.com/en-us/powershell/scripting/samples/multiple-selection-list-boxes?source=recommendations&view=powershell-7.3
And add some features visiting another sites, but ain't found one code that help me to show this info on form (and i don't know if this is possible)
I do not finish the script yet, but the goal with this script will help me to install multiple software and learn more about PowerShell
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

$form = New-Object System.Windows.Forms.Form
$form.Text = $env:COMPUTERNAME
$form.Size = New-Object System.Drawing.Size(450,400)
$form.StartPosition = 'CenterScreen'

$okButton = New-Object System.Windows.Forms.Button
$okButton.Location = New-Object System.Drawing.Point(130,230)
$okButton.Size = New-Object System.Drawing.Size(75,23)
$okButton.Text = 'OK'
$okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $okButton
$form.Controls.Add($okButton)

$cancelButton = New-Object System.Windows.Forms.Button
$cancelButton.Location = New-Object System.Drawing.Point(230,230)
$cancelButton.Size = New-Object System.Drawing.Size(75,23)
$cancelButton.Text = 'Cancel'
$cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $cancelButton
$form.Controls.Add($cancelButton)

$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(80,50)
$label.Size = New-Object System.Drawing.Size(300,50)
$label.Text = 'Please select Software or BIOS:'
$form.Controls.Add($label)
$label.Font = New-Object System.Drawing.Font("Arial",11,[System.Drawing.FontStyle]::Regular)

$label2 = New-Object System.Windows.Forms.Label
$label2.Location = New-Object System.Drawing.Point(90,10)
$label2.Size = New-Object System.Drawing.Size(250,30)
$label2.Text = 'Bios'
$form.Controls.Add($label2)

$listBox = New-Object System.Windows.Forms.ListBox
$listBox.Location = New-Object System.Drawing.Point(70,100)
$listBox.Size = New-Object System.Drawing.Size(290,80)
$listBox.Height = 125
$listBox.Font = New-Object System.Drawing.Font("Arial",12,[System.Drawing.FontStyle]::Regular)

[void] $listBox.Items.Add('All W10-BR')
[void] $listBox.Items.Add('All W10-ES')
[void] $listBox.Items.Add('All W11-BR')
[void] $listBox.Items.Add('All W11-ES')
[void] $listBox.Items.Add('Open Text-10.5')
[void] $listBox.Items.Add('Fuze-22.06.24445')
[void] $listBox.Items.Add('VLC-3.0.18')
[void] $listBox.Items.Add('Five9')
[void] $listBox.Items.Add('CitrixWorkspaceApp-2212')
[void] $listBox.Items.Add('W11-KB5022303-22H2-22621.1105')
[void] $listBox.Items.Add('W10-KB5022282-22H2-19045.2486')
[void] $listBox.Items.Add('Office LangPack Pt-br2013.exe')
[void] $listBox.Items.Add('Office LangPack ES.exe')
[void] $listBox.Items.Add('Latitude')
[void] $listBox.Items.Add('Latitude')
[void] $listBox.Items.Add('Latitude')

$listBox.Add_SelectedIndexChanged({
    # inside here, you can refer to the $$listBox as $this
    # set the return variable to the SelectedItem
    $script:x = $this.SelectedItem  # there is only one SelectedItem

    # or, if you want it to, you can start the action here immediately without leaving the form:
    # switch ($this.SelectedItem) {
        # "Item 1" { <# do something when Item 1 is selected #> }
        # "Item 2" { <# do something when Item 2 is selected #> }
        # "Item 3" { <# do something when Item 3 is selected #> }
        # "Item 4" { <# do something when Item 4 is selected #> }
        # "Item 5" { <# do something when Item 5 is selected #> }
    # }
})
$form.Controls.Add($listBox)

$Form.Add_Shown({$Form.Activate()})
$dialogResult = $Form.ShowDialog()

$Form.Dispose()

if ($dialogResult -ne 'Cancel' -or $x.Count -eq 0) {

 switch ($x){
        "All W10-BR" {Start-Process "C:\Users\dvd87592\Desktop\Pacote de Instalação\5-CitrixWorkspaceApp-2212.exe" /passive -Wait
        Start-Process "C:\Users\dvd87592\Desktop\Pacote de Instalação\3-VLC-3.0.18.msi" /passive}

        "Fuze-22.06.24445" {Start-Process "C:\Users\dvd87592\Desktop\Pacote de Instalação\2-Fuze-22.06.24445.msi" /passive -wait}

        "VLC-3.0.18" { Start-Process "C:\Users\dvd87592\Desktop\Pacote de Instalação\2-VLC-3.0.18.msi" /passive -wait}

        "CitrixWorkspaceApp-2212" { Start-Process "C:\Users\dvd87592\Desktop\Pacote de Instalação\3-CitrixWorkspaceApp-2212.exe" /silent }

    }
    }

I checked other sites and forums and tried a few commands but doesn't work.


text:
Q: MySQL stored procedure returns different results I've a query that should search through rows in a table, find any row that contains searched term ('dog%' for example), and then return id of related parent (joined from different table). So, I'm grouping results by parent id, then reordering it and finally, putting an limit/offset to get a list of 10 uniqe ids. Query is inside stored procedure, I call it from PHP.
Problem is, I'm often getting different results. Even though IN params are the same, and nothing in database is changed, I can get very different results per request - ids are not the same, there are differences in order, I'm getting duplicated ids in two requests...
This is procedure:
CREATE DEFINER=`root`@`localhost` PROCEDURE `FIND_VOCABULARY_ID_BY_MEANING`(IN `in_searched_value` varchar(50)
, IN `in_offset` INT)
    LANGUAGE SQL
    NOT DETERMINISTIC
    CONTAINS SQL
    SQL SECURITY DEFINER
    COMMENT ''
BEGIN
        insert into test values (in_searched_value,in_offset);

        SELECT
        v.id
        FROM vocabulary AS v
        LEFT JOIN vocabulary_sense AS vs ON vs.vocabulary_id = v.id
        LEFT JOIN vocabulary_sense_gloss_eng AS vsg ON vsg.sense_id = vs.id
        WHERE vsg.gloss LIKE CONCAT(in_searched_value,'%')
        GROUP BY v.id
        ORDER BY v.calculated_prio DESC
        LIMIT 10 OFFSET in_offset;
END

How do I call it:
$stmt = $this->pdo->prepare("CALL $procedureToCall('$searchedTerm', $offset)");

In PHP I'm logging values (request and then its result) to log file. Here are two different approaches, in each there is five requests:
[2016-10-11 13:35:19] CALL FIND_VOCABULARY_ID_BY_MEANING('vulgar', 0)
[2016-10-11 13:35:19] 17141,16446,38334,58166,17121,45822,35328,37553,41185,45832
[2016-10-11 13:35:22] CALL FIND_VOCABULARY_ID_BY_MEANING('vulgar', 10)
[2016-10-11 13:35:22] 46659,51149,53639,55276,56388,95,63900,71780,73935,17134
[2016-10-11 13:35:25] CALL FIND_VOCABULARY_ID_BY_MEANING('vulgar', 20)
[2016-10-11 13:35:25] 83260,97433,17176,103416,111512,135069,147790,38335,159709,38338
[2016-10-11 13:35:27] CALL FIND_VOCABULARY_ID_BY_MEANING('vulgar', 30)
[2016-10-11 13:35:27] 162898,38340,163783,38359,165067,38360,171044,38364,38378,38380
[2016-10-11 13:35:31] CALL FIND_VOCABULARY_ID_BY_MEANING('vulgar', 40)
[2016-10-11 13:35:31] 38384,41163,41211,45832,45833,45837
[2016-10-11 13:35:33] CALL FIND_VOCABULARY_ID_BY_MEANING('vulgar', 50)

[2016-10-11 13:50:38] CALL FIND_VOCABULARY_ID_BY_MEANING('vulgar', 0)
[2016-10-11 13:50:38] 17141,16446,38334,58166,17121,45822,35328,37553,41185,56388
[2016-10-11 13:50:41] CALL FIND_VOCABULARY_ID_BY_MEANING('vulgar', 10)
[2016-10-11 13:50:41] 95,63900,71780,73935,17134,83260,97433,17176,103416,111512
[2016-10-11 13:50:45] CALL FIND_VOCABULARY_ID_BY_MEANING('vulgar', 20)
[2016-10-11 13:50:45] 135069,147790,38335,159709,38338,162898,38340,163783,38359,165067
[2016-10-11 13:50:48] CALL FIND_VOCABULARY_ID_BY_MEANING('vulgar', 30)
[2016-10-11 13:50:48] 38360,171044,38364,38378,38380,38384,41163,41211,45832,45833
[2016-10-11 13:50:50] CALL FIND_VOCABULARY_ID_BY_MEANING('vulgar', 40)
[2016-10-11 13:50:50] 45837,45841,46659,51149,53639,55276
[2016-10-11 13:50:53] CALL FIND_VOCABULARY_ID_BY_MEANING('vulgar', 50)

As you can see, 45832 id is send to me twice in first approach (offset 0 and 40). In second approach it exists once, but in offset 30...
Im also logging input params - offset and searchedTerm - in Mysql - there are also correct, consistent with php's generated log above. So why I'm having those diffenreces?? What I'm doing wrong here?
EDIT
I've found that calling procedure directly from MYSQL client (not php) gives me consitent results - but then again, when I call just the plain query:
    SELECT
    v.id
    FROM vocabulary AS v
    LEFT JOIN vocabulary_sense AS vs ON vs.vocabulary_id = v.id
    LEFT JOIN vocabulary_sense_gloss_eng AS vsg ON vsg.sense_id = vs.id
    WHERE vsg.gloss LIKE CONCAT('vulgar','%')
    GROUP BY v.id
    ORDER BY v.calculated_prio DESC
    LIMIT 10 OFFSET 0;

results are also different (still consitent, I'm getting the same results, but those results differs from query inside procedure)...
EDIT 2
Here is structure of tables used in query:
CREATE TABLE `vocabulary` (
    `id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
    `entry_sequence` MEDIUMINT(8) UNSIGNED NOT NULL,
    `jlpt_level` TINYINT(4) NULL DEFAULT NULL,
    `calculated_prio` MEDIUMINT(9) NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`),
    INDEX `idx_vocabulary_calculated_prio` (`calculated_prio`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=174912
;

CREATE TABLE `vocabulary_sense` (
    `id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
    `vocabulary_id` MEDIUMINT(8) UNSIGNED NOT NULL,
    PRIMARY KEY (`id`),
    INDEX `fk_vocabulary_sense_vocabulary_id` (`vocabulary_id`),
    CONSTRAINT `fk_vocabulary_sense_vocabulary_id` FOREIGN KEY (`vocabulary_id`) REFERENCES `vocabulary` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=195529
;

CREATE TABLE `vocabulary_sense_gloss_eng` (
    `id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
    `sense_id` MEDIUMINT(8) UNSIGNED NOT NULL,
    `gloss` TEXT NOT NULL,
    PRIMARY KEY (`id`),
    INDEX `vocabulary_sense_gloss_vocabulary_sense_id` (`sense_id`),
    INDEX `vocabulary_sense_gloss_gloss` (`gloss`(255)),
    CONSTRAINT `vocabulary_sense_gloss_eng` FOREIGN KEY (`sense_id`) REFERENCES `vocabulary_sense` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
ROW_FORMAT=COMPACT
AUTO_INCREMENT=317857
;

vocabulary is the main entry. vocabulary_sense (one to many) is pointing at it. And vocabulary_sense_gloss_eng (again, one to many) is pointing at vocabulary_sense.
The "calculated_prio" is just an static INT value.

A: Oh damn, I'm so dumb :)
Problem was with sorting, calculated_prio had positive value for first nine rows only, and for rest of them it was just 0. So only first nine rows were in particular order, everything else was random.


text:
Q: PHP Not Posting in SQL Database Insert Statement So I'm attempting to gather data from a form in HTMl using the POST method and insert said data into a MySQL database using MySQLi functions. When in standalone PHP (without the database connection), I'm able to POST and echo data successfully to the second document.
However, once I open the connection to the database and attempt to use an insert statement, the data stops POSTing all together. I've tested the insert statement using strings, it works just fine.
Here's my form:
<form action="welcome" method="post">
    First Name*

    <input type="text" name="userFN" required>

    Last Name*

    <input type="text" name="userLN" required>

    Email*

    <input type="email" name="userEmailAddress" required>

    Password*

    <input type="password" name="userPassword" required>

    Tell Us About Yourself

    <textarea rows="4" cols="50" name="userDescription">
    </textarea>

    <input type="submit">
</form>

Here's my PHP (welcome, as used in the action above).
$conn = new mysqli($servername, $username, $password, $dbname);

    // Check connection

    if ($conn->connect_error) {

        die("Connection failed: " . $conn->connect_error);

    }

    //post form info into variables
    $userFN = mysqli_real_escape_string($conn, $_POST['userFN']);
    $userLN = mysqli_real_escape_string($conn, $_POST['userLN']);
    $userEmailAddress = mysqli_real_escape_string($conn, $_POST['userEmailAddress']);
    $userPassword = mysqli_real_escape_string($conn, $_POST['userPassword']);
    $userDescription = mysqli_real_escape_string($conn, $_POST['userDescription']);

    $sql = "INSERT INTO users (userFN, userLN, userEmailAddress, userPassword, userDescription) VALUES" . " ('" . $userFN .  "','" . $userLN . "','" . $userEmailAddress . "','" . $userPassword . "','" . $userDescription . "');";

    echo $sql;

    if ($conn->query($sql) === TRUE) {

        echo "New record created successfully";

    } else {

        echo "Error: " . $sql . "
" . $conn->error;

    }

It always returns New record created successfully, and inserts a new record into the database, but all of the fields are blank. When I echo the insert statement, I get this:
INSERT INTO users (userFN, userLN, userEmailAddress, userPassword, userDescription) VALUES ('','','','','');
So it's clearly not getting my POST data anymore. I've tried using prepared statements and still no luck. What am I doing wrong here? I greatly appreciate any and all advice, thank you in advance.

A: The answer may surprise you.
So the issue is actually in the form "action". Because of the way my webhosting provider is configured, I actually needed to specify /index.php/ after the folder name in the action. It was actually confusing the server and for some reason translated to 'GET' instead of 'POST'. Hope this helps.
Thanks for all the support!


text:
Q: How to add and/or subtract a constant from some XML element values with xmlstarlet I have an XML file with lots of entries like the following:
<object>
    <name>buf</name>
    <bndbox>
        <xmin>535</xmin>
        <ymin>725</ymin>
        <xmax>636</xmax>
        <ymax>821</ymax>
    </bndbox>
</object>

Is there a way to use xmlstarlet (or another tool) to subtract the value of 10 from each xmin element's current value?

A: To subtract the value of 10 from all xmin elements, use the following xmlstarlet command:
xmlstarlet ed -u "//xmin" -x ".-10" input.xml

Output of the sample XML is:
<?xml version="1.0" encoding="UTF-8"?>
<ParentId>
  <object>
    <name>buf</name>
    <bndbox>
      <xmin>525</xmin>
      <ymin>725</ymin>
      <xmax>636</xmax>
      <ymax>821</ymax>
    </bndbox>
  </object>
</ParentId>


text:
Q: Geometric Interpretation of negativity of interaction information The interaction information (II) in 3D is defined as a generalization of the 2D mutual information (MI).
$$
\begin{eqnarray}
I(X:Y:Z)
&=& I(X:Y) - I(X:Y|Z) \\
&=& H(X) + H(Y)+H(Z) - H(XY) - H(XZ) - H(YZ) + H(XYZ)
\end{eqnarray}
$$
II can be negative, for example for $Z = \mathrm{XOR}(X, Y)$. It is easy to convince oneself of this fact by simply calculating all terms for the XOR example and confirming that it is indeed negative.
My question is about the geometric interpretation of this fact. The multivariate mutual information is typically illustrated by this three-way Venn diagram, where the entropies of each variable (which are positive quantities) are subdivided into shared and unique parts. Naively looking at this diagram it feels like each slice of a positive quantity should also be a positive quantity. How is it possible that the centre piece of this diagram is negative geometrically? Where does the naive intuition go wrong? Is there something better than a Venn diagram to geometrically illustrate this result?


text:
Q: How to have OpenJPA recursively remove children and their children? My client wants me to change their application -which uses JPA- in such a way that the current Hibernate provider is replaced by OpenJPA provider. I have no OpenJPA experience and I was hoping to just have to do some configuration to achieve this goal. I removed the Hibernate provider and properties from persistence.xml and added some OpenJPA properties. I set OpenJPA as a default provider on the server (WebSphere Application Server 8.0).
When the application starts, it tries to remove children B from parent A.
B itself has children C which should be removed from B, and children D should be removed from C. They are all configured by annotation, bi-directional: @OneToMany and @ManyToOne combinations are used for each parent/child relationship. The parent sides all have the properties mappedBy="[parent class name lowercase]", cascade=CascadeType.ALL.
Having Hibernate implemented, this worked perfectly by iterating through all elements B, explicitly deleting them by using entityManager.delete and finally emptying the collection of B's. All the C's and D's were removed as well.
Having OpenJPA implemented this results in a FK constraint violation: it looks like it is trying to remove B before the C's and D's are removed.
I tried adding orphanRemoval=true to all the @OneToMany annotations. In that case just emptying the collection of B's without explicitly removing them first. Same problem.
I looked into many articles and StackOverflow topics but I can't seem to find a solution. Can anyone help me with this please?
(Currently I have no access to the code, therefore describing it.)


text:
Q: Reversing lines and words Gotta write a program that receives a file path and a "task" as inputs, and does functions according to the input "task".
if the task input is "rev", the program needs to print the file content in reverse (both the lines and the words).
I tried:
def file_play():
    file_path = input("Please enter a file path: ")
    task = input("Please enter a task: ")
    my_file = open(file_path, "r")

    if task == "rev":
        for line in my_file:
            for word in line.split():
                print(word[::-1], end=" ")
    my_file.close()

The text in the file:
i believe i can fly i believe i can touch the sky
i think about it every night and day spread my wings and fly away

Current output:
i eveileb i nac ylf i eveileb i nac hcuot eht yks i kniht tuoba ti yreve thgin dna yad daerps ym sgniw dna ylf yawa

Required output:
yks eht hcuot nac i eveileb i ylf nac i eveileb i
yawa ylf dna sgniw ym daerps yad dna thgin yreve ti tuoba kniht i

A: You are reversing each word. What you want is to reverse the line like this :
def file_play():
    file_path = input("Please enter a file path: ")
    task = input("Please enter a task: ")
    my_file = open(file_path, "r")

    if task == "rev":
        for line in my_file:
            print(line[::-1])
        my_file.close()

A: You can just reverse the line:
task = ['i believe i can fly i believe i can touch the sky', 'i think about it every night and day spread my wings and fly away']

for line in task:
    print(line[::-1], end='\n')

output
yks eht hcuot nac i eveileb i ylf nac i eveileb i
yawa ylf dna sgniw ym daerps yad dna thgin yreve ti tuoba kniht i

A: If it is a string, then first convert it to a list
a = "Hack it"
a = list(a)
a.reverse()
b = ""
for i in range(len(a)):
    b += a[i]
print("Reversed string/list: " + b)
Output:
Reversed string/list: ti kcaH

Really hope this helps!


text:
Q: selfsigned https cert how to install selfsigned https cert to PHPmyadmin (LAMP)?
If any one has done please share the step by step!

A: Create the self signed certificate in OpenSSL
Configure an SSL Cert in Apache


text:
Q: How to run Spring Boot in GraalVM without JRE I'm trying to run Spring Boot application using GraalVM Native. After successful compilation into single file, I can easily run binary, Spring Boot starts normally, but when I trying to run it inside docker with ubuntu image (it not contains java, but simple HelloWorld in GraalVM native works without JRE) I getting this error:
Error: No bin/java and no environment variable JAVA_HOME

I've read that I probably need to init classes at runtime instead of compile time (from: Problem with creating AWS Lambda function using Micronaut and GraalVM). But I don't know which classes should I pass to --delay-class-initialization-to-runtime. How can I run my Spring Boot app without JRE?


text:
Q: DotNet Core - Purpose of Solution Files What's the purpose of using solution files for DotNet Core projects? I'm using a Mac, and I can use project-to-project reference to modularize and build shared libraries without solution files:
dotnet add reference ..\Library\Library.csproj

which adds the following to my current directory's .csproj file:
<ItemGroup>
  <ProjectReference Include="..\Library\Library.csproj" />
</ItemGroup>

And now building my current directory's .csproj will build Library.csproj.

A: Solution file works as container for application's project/projects. It comes handy when you are working on your application out of IDE. Following are some of uses of solution file.

*

*Open project or multiple projects in IDE just by opening solution file in IDE. e.g. If you open solution file in visual studio then all of projects which are part of solution will get opened in visual studio.

*You can control build/deployment of projects (what to build and what not to) under solution using solution level configuration.

*If you are using editor like VS Code then solution file facilitate to build all those project which are part of solution just by running "dotnet build" command. If projects were not part of solution then you need to build them individually.

*When working out of IDE (like Visual Studio) and source control you can add all project files and solution to source control just by adding solution to source control. Same goes with check in or checkout.

These are some of advantages of solution file and there can be many more. However solution file is not must have thing and you can still live without it. Its just makes developer's life easy and improves productivity.


text:
Q: openssl: unable to get local issuer certificate for accounts.google.com I am getting unable to get local issuer certificate for accounts.google.com over SSL. I downloaded an update CA file from: https://curl.haxx.se/ca/cacert.pem and am using openssl s_client to render:
➜  ~ openssl s_client -connect accounts.google.com:443 -CAfile ~/certs/cacert.pem
CONNECTED(00000003)
depth=2 /C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
 0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=accounts.google.com
   i:/C=US/O=Google Inc/CN=Google Internet Authority G2
 1 s:/C=US/O=Google Inc/CN=Google Internet Authority G2
   i:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
 2 s:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
   i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIEoTCCA4mgAwIBAgIIZMJyEcZ8LIAwDQYJKoZIhvcNAQELBQAwSTELMAkGA1UE
BhMCVVMxEzARBgNVBAoTCkdvb2dsZSBJbmMxJTAjBgNVBAMTHEdvb2dsZSBJbnRl
cm5ldCBBdXRob3JpdHkgRzIwHhcNMTcwMzE2MDkxNjU0WhcNMTcwNjA4MDg1NDAw
WjBtMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwN
TW91bnRhaW4gVmlldzETMBEGA1UECgwKR29vZ2xlIEluYzEcMBoGA1UEAwwTYWNj
b3VudHMuZ29vZ2xlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
AI53MUFYpFrV3J+B6ZbblEh+MlLsVbDqwMwFNEG4c+IjVXGDuUDGp+C7jkdVmIn2
T8skXutZj6E14D7WZvakq4pvSMBRkmkuWZk4+nWUY2/+TXuMYZXV0fnKBcDXTUxm
Bbc7a9gKVPD/dUHjJFWfkGznyq9lP0taT2MYsYE8+am4GAykSEgF2e4dEE4TrqWM
BP0+M/QfreykfpO/BF0UyqWXwzp4oYUWUyv2g8TU+i5hlELnVLU/0/jxaDA01ucH
+z0IRXxLxZW3/HXGNxr3wd24fvBD0PBe45ftUIM1Hq5x0kf0iv18aFR9Uy1yDl5W
ie4V8cRNq1m8h+b+IDiiuWsCAwEAAaOCAWcwggFjMB0GA1UdJQQWMBQGCCsGAQUF
BwMBBggrBgEFBQcDAjA1BgNVHREELjAsghNhY2NvdW50cy5nb29nbGUuY29tghUq
LnBhcnRuZXIuYW5kcm9pZC5jb20waAYIKwYBBQUHAQEEXDBaMCsGCCsGAQUFBzAC
hh9odHRwOi8vcGtpLmdvb2dsZS5jb20vR0lBRzIuY3J0MCsGCCsGAQUFBzABhh9o
dHRwOi8vY2xpZW50czEuZ29vZ2xlLmNvbS9vY3NwMB0GA1UdDgQWBBQ1jLhJdsYE
BiSt2vOb6DCTV5y+EjAMBgNVHRMBAf8EAjAAMB8GA1UdIwQYMBaAFErdBhYbvPZo
tXb1gba7Yhq6WoEvMCEGA1UdIAQaMBgwDAYKKwYBBAHWeQIFATAIBgZngQwBAgIw
MAYDVR0fBCkwJzAloCOgIYYfaHR0cDovL3BraS5nb29nbGUuY29tL0dJQUcyLmNy
bDANBgkqhkiG9w0BAQsFAAOCAQEAi2c6nKtNZ5bHAG7mbBuqS2OA093euznd+d0q
0DG+LvgSFwOHeSZn0VHGDiQ8nGhvA/3W7cva+p2zO29zQDiFTUW3+Ni+vFLl1yY+
JXiTBqStVAihau9BLitvsFXT/3+NjxJ/TgDz9EkoDlEAnsofZ7amH2mA4+cMdN5P
eAMUjJgKc7iJdxgZMLYXC7oYoHDz2PqgKy+lgk4+mIxxLWfiYWRqMFVvIwFlY1eC
ORulBjAOdRkm1yLpMfmHcXxA4C7jtoxrtr1vJs7i061JF78grhuqYdKvSc5TEhD+
II5MNcN2ArQgWbA92Pv1YVk0COEDcJoVSZ4bJtOH+iEpLg7fRg==
-----END CERTIFICATE-----
subject=/C=US/ST=California/L=Mountain View/O=Google Inc/CN=accounts.google.com
issuer=/C=US/O=Google Inc/CN=Google Internet Authority G2
---
No client certificate CA names sent
---
SSL handshake has read 3273 bytes and written 456 bytes
---
New, TLSv1/SSLv3, Cipher is AES128-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : AES128-SHA
    Session-ID: 50C97032E3B74D2CC706CA939CC7FF5EFD40C8D590E8F2B084CD36F092721547
    Session-ID-ctx:
    Master-Key: 1F4565E7707F318C872DA80E1544501E2DA5E0F1508193762D8E61EFB69C2683AE7914D2117E150746F328FAA01CC499
    Key-Arg   : None
    Start Time: 1490708489
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)
---

Not sure how to resolve

A: asonge is correct that the problem is due to the fact that the third certificate in the certificate chain, GeoTrust Global CA) was issued by Equifax Secure Certificate Authority which is not listed as a trusted CA certificate in the file downloaded from the Curl website. I thought I'd complement his/her answer – and reassure bcardarella – by explaining why this is the case.
The list of trusted CA certificates from the Curl website is actually generated from the root certificates used by Mozilla.  The reason the Equifax certificate is not listed in it is that: Equifax and other CA certificates were removed from Mozilla's list of trusted CA certificates in October 2016. See the following bug report that led to this change: Remove non-audited Symantec root certs from NSS.
Cross-signed certificate
The GeoTrust certificate is actually a cross-signed certificate. This means that there are two versions of the GeoTrust certificate generated from the same private key (used to sign the Google Internet Authority G2 certificate).

*

*self-signed one (now listed by most CA root stores)

*one signed by Equifax

The second certificate was useful back in the day when the GeoTrust CA was first started. At the time, clients would trust it since they trusted the Equifax cert that was used to sign it. Such a certificate is known as a bridging certificate.
With cross-signed certificates, there are more than one possible verification path:
1. Using the self-signed certificate
This is the default behaviour of recent versions of OpenSSL.
$ echo | openssl s_client -connect accounts.google.com:443 -CAfile cacert.pem >/dev/null
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify return:1
depth=1 C = US, O = Google Inc, CN = Google Internet Authority G2
verify return:1
depth=0 C = US, ST = California, L = Mountain View, O = Google Inc, CN = accounts.google.com
verify return:1
DONE

2. Using the "bridge" certificate
Here's a demonstration of the longer chain of by intermediate certificates. I used OpenSSL 1.0.2k and emulated its old default behaviour of not following alternative certificate chains. Since the Equifax root CA certificate no longer exists in my system certificate store, I explicitly specify its use as the CA root store for this one command:
$ echo | openssl s_client -connect accounts.google.com:443 -CAfile Equifax_Secure_CA.pem  -no_alt_chains >/dev/null
depth=3 C = US, O = Equifax, OU = Equifax Secure Certificate Authority
verify return:1
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify return:1
depth=1 C = US, O = Google Inc, CN = Google Internet Authority G2
verify return:1
depth=0 C = US, ST = California, L = Mountain View, O = Google Inc, CN = accounts.google.com
verify return:1
DONE

OpenSSL behaviour
The way older versions of OpenSSL built up a chain of intermediate certificates was to build the longest possible chain from the certificates sent by the remote server and to then look for a trusted certificate that signed that chain. If no such certificate was found in its trust store, it would throw a verification error.
This caused problems as bridging certificates were gradually removed from root CA trust stores and OpenSSL had to change this behaviour. See Cross-signed certs rejected by OpenSSL because root cert not base of chain
This specific problem
In this case, running s_client with the -showcerts option shows that the Google web server still sends the legacy bridge certificate signed by Equifax's private key. I suspect that you're using an older version of OpenSSL (before 1.0.2b) and that it uses all of them when constructing its chain of intermediate certificates.
Solutions
Here are some possible solutions to ensure s_client shows all certificates in the chain of trust being correctly verified:

*

*Upgrading to a newer version (1.02b up) which checks if an alternative (shorter) chain can be constructed that verifies – if the first (long) chain can't be verified.

*Some older version of s_client accept a -trusted_first option which results in OpenSSL checking whether it can build a
shorter chain using certificates from its list of trusted root CA certificates (before attempting to build a long chain).

*Import the Equifax Secure Certificate Authority into your certificate store – or save it as a file and refer to it using either the -CAfile or -CApath options for s_client.

A: This is not actually an error. This bottoms out in a trusted certificate (the one with the subject s:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA), but that trusted certificate has an issuer i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority that is not in the trusted list. This is actually completely fine. If you look at the final verify status at the bottom, you are properly verified.
Some of the time, the root CA may be self-signed (issuer == subject), but this does not happen to be the case. As long as one certificate in the chain is in the trust, it is properly authenticated.


text:
Q: A facade root has not been set. in lumen in my get() function from web.php , I am sending the following, and then I get the error "A facade root has not been set."

A: In your bootstrap/app.php, make sure to uncomment
$app->withFacades();


text:
Q: Why are transparent holes appearing in my Firefox pages? I've noticed recently on my machine (Windows 7, 64 bit) running FireFox 19.0.2 I get strange holes over my browser and sites. This happens with in StackExchange Chat, and also when I'm on the Facebook home page.
It always appears on the right hand side, along the top like in the image below, or at the bottom corner just above my task bar and system clock. It might be flash issues although I really don't know and I can't find anything else online about it. I've got Adblock Plus installed, and nothing else.
The same setup on my work machine (Windows 7, FireFox 19) does not have this issue. Also, it doesn't do this all the time, on every page.

A: Looks like a video issue.
This to try:

*

*Update your video drivers to the latest offered by your manufacturer.

*Disable hardware acceleration in FireFox.

If this is a new thing, you changed nothing before it started, and updating/reverting the video driver doesn't help, I'd be concerned that the video adapter is failing.

A: This is a side effect of the Update KB2670838 (Platform Update for Windows 7 to support Internet Explorer 10). If you don't need the Ie10, remove the Update.


text:
Q: Edit Atom's autocompete Is there a way of editing Atom's auto-complete so that it auto completes with a different attribute?
Currently I can type 'template' and it auto completes to
<template id=""></template>

which I would prefer auto completed to
<template name=""></template>

if there is a file somewhere maybe I could edit?

A: One possible solution is to define your own snippet:
File > Open your snippets
Add the following:
'.source.js':
  'tmpl':
    'prefix': 'Template Trigger'
    'body': '<template name=""></template>'

You will probably want to customize the scope for your requirements.


text:
Q: Does it make sense to learn Windows Phone 7 development to learn Windows 8? I want to learn Windows 8 development (specially for smartphones) but can't install Windows 8 release preview right now. And there is more info, tutorials, etc. in the internet about Windows Phone with SDK 7.
I know nothing about Windows development. Is Windows Phone with SDK 7 a good basis for Windows 8? Or will I waste my time and it's better to wait and start directly with Windows 8?
Thanks!

A: I would say yes. Whether you choose the XAML/C# route or the HTML/JS route, you're not going to learn much while studying Win Phone 7 development that doesn't apply to Win Phone 8 development and even Win 8 development.

A: Well, according to this article at least, although it doesn't talk mainly about development, there are too much differences and it probably doesn't make sense to learn Windows (phone) 7 as "intro".
http://crave.cnet.co.uk/mobiles/windows-phone-7-was-doomed-by-design-microsoft-admits-50008466/
On the other side, there's this article in Microsoft's site:
http://msdn.microsoft.com/en-US/library/windows/apps/hh465136
Which clearly suggests there's a significant common base, since the apps are supposed to be easily portable. Hmm... Will see :)

A: If you're not committed to Silverlight you could just go the HTML5 route for Windows 8 apps.  Then you could start learning HTML5 now without having Windows 8 installed.
Since you know nothing about Windows dev, I'd say learn HTML5, then you can use it on the web, as well as on Windows 8 apps.
There's a great series of self-study exercises on up Microsoft's GenerationApp site - http://bit.ly/30tolaunch .   Free, and pretty good for beginner ramp up.


text:
Q: Python requests no Exception on status 400 I'm setting up a small Python script so my colleagues can collect data from a certain internal API based on a few inputs using the following code:
url = "https://....."
params = dict(...)
client = BackendApplicationClient(client_id=client_id)
client.prepare_request_body(scope=[])
session = OAuth2Session(client=client)
response = session.get(url=url, params=params, verify=session.verify)

where the params are based on the manual inputs. I can guarantee some of the inputs will not conform to the API's requirements fully (like lower case letters where upper case is needed, etc.). In this case, the API will return a response with status 400:
>> response
<Response [400]>
>> response.text
{"statusCode":400,"errorMessage":"Bad Request","errors": ...}
>> response.status_code
400

I thought I could capture this with response.raise_for_status(), but no Exception is raised, and the returned value is None:
>> response.raise_for_status()
None

Why is this? I thought the raise_for_status function was supposed to raise an Exception based on the response's status_code

A: raise_for_status() on a response from the requests module will raise an HTTPError exception if the HTTP status code is 400. This is a peculiarity of OAuth2Session which you can read about here


text:
Q: Detect if requested page is PWA on server side I'm trying to determine if the user is browsing PWA on server side. On client side I can check if the browser mode is standalone via JavaScript and detect PWA, but on server side this is not an option. So I'm using simple query parameter for that. Start URL in manifest has query param isPwa appended and every time user opens PWA, it goes to https://example.com/?isPwa. What I need now is to keep that parameter while user browses PWA, so I need to set isPwa parameter to next URL that user opens if the referer URL already had isPwa parameter, but my code goes to redirection loop and I'm unable to identify the cause of this. Here's my code:
function addIsPwaQueryArg() {
    $referer = wp_get_referer();
    if (strpos($referer, 'isPwa') !== false) {
        $location = remove_query_arg('isPwa');
        wp_redirect(add_query_arg('isPwa', '', $location));
        exit;
    }
}
add_action('template_redirect', 'addIsPwaQueryArg');

Can someone tell me what's wrong with my code and why is it not working?
Thanks!

A: You're not passing the actual querystring to remove_query_arg(). After some quick testing, I think your $location value is probably an empty string, and the location you're attempting to redirect to is ?isPwa.
The 2nd parameter to remove_query_arg() should be the $referer value.
function addIsPwaQueryArg() {
    $referer = wp_get_referer();
    if (strpos($referer, 'isPwa') !== false) {
        $location = remove_query_arg('isPwa', $referer );
        wp_redirect(add_query_arg('isPwa', '', $location));
        exit;
    }
}
add_action('template_redirect', 'addIsPwaQueryArg');

However: I'm not sure that's the root cause of your redirect loop. It looks like you're checking to see if isPwa is in the querystring, removing it if it is, and then adding it back in (with a blanked value) as you redirect. Is this your intent?


text:
Q: Trying to understand Unreal Engine 4 replication I'm trying to understand how to call events between client and server. My goal for now is simple. I want to create anything that is interactable for 2 players.
Easiest thing I could think of was cube that is switching color when clicked. So I did create actor based blueprint, checked "Replicates" and AlwaysRelevant to be sure. PlayerController is also replicated and there is no pawn needed.
Color change blueprint:

SM is just static mesh if that is important. As far as I know client have no authority to call multicast events so I wanted to push it through server but it stops there. Called from server works as expected and color itself IS replicated to client, however client cannot change color himself.
What am I missing in this concept? I've watched like 5 videos about replication and I started to think there is something missing which is either obvious for everyone but me or their examples do not need things I do here.

A: As you've found out, a player's client can not directly call server RPCs on actors which the player does not own. Calls must be routed through that player's PlayerController. The server copy of the player's PlayerController can then call server methods on server-owned actors.
Another issue is that you seem to be using both RPCs and replicated properties for the same purpose. Unclear to me why changed is replicated since you're modifying it in a multicast event which normally runs on all the machines. This is a recipe for hard to find race condition bugs.
Replication in Unreal is definitely one of the harder concepts to get the hang of. The resource that helped me the most is this guide which while quite dated, is both comprehensive and to the point.

A: You can't have it in PlayerController, it's got to be in a Pawn, or if not, in PlayerState, or it won't get shared to other clients.


text:
Q: How to troubleshoot a very simple application consuming high CPU? I was reported about some performance issues on a app I'm currently developing. It's a quite simple application without very complex logic.
Opened on the main view without any user activity, it takes about 25% of the CPU (15% of "user" and 10% of "kernel") on a Samsung S5 device. There is a background network polling but I tried removing that and CPU usage is similar.
This is a trace output (no user activity, just app in foreground)

I'm not sure if this is normal but I found some references that it could be indicating a deadlock (due java.lang.Object.wait taking most of the time)
Do you see any obvious problema on my trace? How to better troubleshoot this?
I've seen much more complex apps using 2 or 3% of the CPU so there must be something I can improve.


text:
Q: Max similarity of two character dictionaries? Say I have a python dictionary:
d = {"a":1, "b":2}

this represents the number of occurrences a character has in a string. So the above dictionary could generate a string of "abb", "bab", or "bba".
The Max similarity between two dictionaries is a ratio >= 0 and <= 1 that describes how similar the two most similarly generated strings are.
For example,
d1 = {"a":1, "b":2}
d2 = {"c": 3}
d3 = {"a":1, "d":2}

max_sim(d1, d2) # equals to 0.0 because no indexes
# of an arrangement of ccc matches any indexes of an arrangement of abb
max_sim(d1, d3) # equals to 0.333 because an arrangement of add matches
# one out of three characters of an arrangement of abb
# note that if we compared dda and abb, the similarity ratio would be 0.0
# but we always take into account the most similarly generated strings

How can I generate the max similarity of any two dictionaries (same length) simply by looking at the number of occurrences per character? i.e. simply analyze the dictionaries and not actually generate the strings and check the similarity ratio of each pair.
Note: I'm using max_sim on dictionaries rather than strings because I've already looped through two strings to gather their dictionary data (in addition to something else).  If I use max_sim on two strings (either the original strings or convert the dictionaries back to strings), I figure I'd be just doing redundant computation. So I'd appreciate it if the answer took two dictionaries as inputs.

A: What about this:
def max_sim(d1, d2):
    # assume that's the same for both dicts
    length = sum(d1.values())
    matches = 0
    for letter in set(d1.keys() + d2.keys()):
        matches += min(d1.get(letter, 0), d2.get(letter, 0))
    return matches / float(length)

Result:
d1 = {"a":1, "b":2}
d2 = {"c": 3}
d3 = {"a":1, "d":2}
d4 = {"a": 1, "b": 1, "c": 1 }

max_sim(d1, d2) # 0.0
max_sim(d1, d3) # 0.333
max_sim(d1, d4) # 0.666
max_sim(d1, d1) # 1.0


text:
Q: How do I guarantee node order for an XPath 'OR' query I have a snippet of XML that looks like
<body>
   Some text....
   <nodeA>....</nodeA>
   more text
   <someOtherNode>
      <nodeA>.......</nodeA>
   </someOtherNode>
   <nodeB>.......</nodeB>
   etc.....
</body>

I'm selecting all nodeA and NodeB nodes inside <body> using an XPATH query similar to
//nodeA|//nodeB
As I understand it, .NET supports XPath 1.0 which does not guarantee node order.
How can I guarantee selected nodes are returned in document order in my OR query : that's to say:
nodeA, nodeA, nodeB

A:
As I understand it, .NET supports
  XPath 1.0 which does not guarantee
  node order

When an XPath 1.0 expression that selects nodes is evaluated, the selected nodes form a node-set. A node-set is a set and this, among many other things, means that it is unordered.
For practical purposes, though, there is one main ordering chosen to enumerate the nodes of a node set: document order. In practice, all XPath 1.0 engines I know (and certainly in .NET) return the selected nodes in document order. In the future this is unlikely to change, because vendors try to preserve backwards compatibility.
Therefore, just try using the SelectNodes() or Evaluate() methods and verify that the nodes in the results are in document order.
Do note: The order of the following cannot be guaranteed and is implementation-dependent:

*

*Attributes of the same element.

*Nodes belonging to different documents (a node-set containing nodes from different documents can be produced using the XSLT function document(), so this most probably is of no concern to you).

A: You have to sort the nodes outside of XPath. So iterate through the nodes in the node-set and add them to a collection, which you then sort using XPathNavigator.ComparePosition for comparisons.
Either that or use an XPath 2.0 implementation for .NET


text:
Q: change hue/saturation of screen without using form background color in vb.net i would like to change the hue and saturation and darkness of the screen without using a form.
for example these two colors change the color of the screen directly (however i doubt they were programmed in vb.net)
http://www.stereopsis.com/flux/
http://colororacle.cartography.ch/

A: I didn't try out the stereopsis program, but it looks to me like the ColorOracle program just takes a "snapshot" of the screen, re-colors it however, and then pops up a screen-size form with the image on it (which goes away when you click it).
This would be easy to do in .Net, but I'm guessing that you want your actual real live screen to change hue, and I'm not sure that's even possible (unless your monitor settings can be changed programatically in Windows).


text:
Q: Install a specific version of an older package by adding an old mirror I'm attempting to install a specific version of gcc to Ubuntu 18.04.
By default the version of Ubuntu at the time of this writing is 18.04.5. Installing it  with sudo apt-get install gcc-7 results in the following:
user@server:~$ gcc-7 -v
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
user@server:~$ sudo apt-cache policy gcc-7
gcc-7:
  Installed: 7.5.0-3ubuntu1~18.04
  Candidate: 7.5.0-3ubuntu1~18.04
  Version table:
 *** 7.5.0-3ubuntu1~18.04 500
        500 http://hr.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        500 http://hr.archive.ubuntu.com/ubuntu bionic-security/main amd64 Packages
     7.3.0-16ubuntu3 500
        500 http://hr.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

Apt recognizes two versions and has installed the 7.5.0-3ubuntu1~18.04 one.
I need the version 7.4.0.
I have found a package mirror which has the required package version (gcc-7-multilib_7.4.0-1ubuntu1~18.04.1_amd64.deb) and did the following:
# Add "deb https://mirror.squ.edu.om/ubuntuarchive/ubuntu bionic main restricted multiverse universe" to /etc/apt/sources.list
user@server:~$ sudo apt-get update
user@server:~$ sudo apt-cache policy gcc-7
gcc-7:
  Installed: 7.5.0-3ubuntu1~18.04
  Candidate: 7.5.0-3ubuntu1~18.04
  Version table:
 *** 7.5.0-3ubuntu1~18.04 500
        500 http://hr.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        500 http://hr.archive.ubuntu.com/ubuntu bionic-security/main amd64 Packages
     7.3.0-16ubuntu3 500
        500 http://hr.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        500 https://mirror.squ.edu.om/ubuntuarchive/ubuntu bionic/main amd64 Packages

However this only added a new mirror to the 7.3.0-16ubuntu3. It didn't introduce the version 7.4.0-1ubuntu1~18.04 which exists as a package in the mirrors. I expected to see the new versions available.
Am looking for an explanation for this behavior and ways to add the 7.4.0 version?

A: Here's one way to do it.

*

*Look at apt changelog gcc-7-multilib to see which older releases of Ubuntu include version 7.4.0. This avoids a lot of mucking about with broken dependencies. Here's the edited  list:

    gcc-7 (7.5.0-1ubuntu1) focal
    gcc-7 (7.4.0-15ubuntu1) focal

    gcc-7 (7.4.0-14ubuntu2) eoan
    gcc-7 (7.4.0-14ubuntu1) eoan
    gcc-7 (7.4.0-12ubuntu2) eoan
    gcc-7 (7.4.0-11ubuntu1) eoan
    gcc-7 (7.4.0-10ubuntu2) eoan
    gcc-7 (7.4.0-9ubuntu1) eoan

    gcc-7 (7.4.0-8ubuntu1) disco
    gcc-7 (7.4.0-7ubuntu1) disco
    gcc-7 (7.4.0-6ubuntu1) disco
    gcc-7 (7.4.0-5ubuntu1) disco
    gcc-7 (7.4.0-4ubuntu1) disco
    gcc-7 (7.4.0-3ubuntu2) disco
    gcc-7 (7.4.0-3ubuntu1) disco
    gcc-7 (7.4.0-2ubuntu1) disco
    gcc-7 (7.4.0-1ubuntu1) disco
    gcc-7 (7.3.0-31ubuntu1) disco

*You can see that both 19.04 (Disco) and 19.10 (Eoan) shipped with the version you want.

*

*Note: Both releases are past End of Life. Neither receives security patches, and neither is supported here at AskUbuntu anymore.

*Unsupported releases of Ubuntu are available at https://old-releases.ubuntu.com/releases/ . If you decide to use an old release for a specific purpose, run it in a VM and be sensible about its access to your network.


text:
Q: How do I specify starting location in a ForEach using GeometryReader? I have a project where I list pieces of art. Once a piece is selected you go into a detail view. From there, I want you to be able to swipe up and down to go to the previous or next piece in the list.
I'm using a filtered ForEach for the list view and a ForEach with GeometryReader for the detail view.
How do I make the detail view start on the correct piece instead of just starting at the beginning of a ForEach?
Thanks for any help!
Code snippets:
LIST VIEW
          ScrollView {
            ScrollViewReader { proxy in
                LazyVStack(spacing:0) {
                    Spacer()

                    if user_settings.isSortTitle == true {
                        ForEach(titleSortedArts, id: \.self) { art in
                            NavigationLink(destination:DetailView(art:art)) {
                                ArtRow(art: art)
                            }
                        }
                    }
                    else if user_settings.isSortCreator == true {
                        ForEach(creatorSortedArts, id: \.self) { art in
                            NavigationLink(destination:DetailView(art:art)) {
                                ArtRow(art: art)
                            }
                        }
                    }
                    else {
                        ForEach(arts, id: \.self) { art in
                            NavigationLink(destination:DetailView(art:art)) {
                                ArtRow(art: art)
                            }
                        }
                    }
                } // Lazy Vstack
            } // Scrollviewreader
        } // Scrollview
    } // Vstack

DETAIL VIEW
         GeometryReader { geometry in
            return ScrollView(showsIndicators: true) {
                VStack(spacing: self.spacing) {
                    ForEach(arts) { art in
                        DetailHeaderView(art: art)
                        NFTDetail(nft:nft)
                            .frame(width: geometry.size.width, height: geometry.size.height)
                    }
                }
            }
            .content.offset(y: self.offset)
            .frame(width: geometry.size.width, height: geometry.size.height, alignment: .leading)
            .gesture(
                DragGesture()
                    .onChanged({ value in
                        self.offset = value.translation.height - geometry.size.height * CGFloat(self.index)
                    })
                    .onEnded({ value in
                        if -value.predictedEndTranslation.height > geometry.size.height / 2, self.index < arts.count {
                            self.index += 1
                        }
                        if value.predictedEndTranslation.height > geometry.size.height / 2, self.index > 0 {
                            self.index -= 1
                        }
                        withAnimation { self.offset = -(geometry.size.height + self.spacing) * CGFloat(self.index) }
                    })

            )
        }

A: I am not too knowledgeable about this subject, but it seems like iterators would be the best option in this situation. Presumably once you make the iterator you could then set that iterator to a value on tap and then go back to it once you exit.
https://developer.apple.com/documentation/swift/array/1688032-makeiterator


text:
Q: Converting Letters to Numbers 2 Refer to Converting Letters to Numbers
In the file test.in.rtf, I have 'abcd' typed. However, when I run the program, I get ??? ???????????  ???????? plus maybe a few more in test.out.rtf. Why is this? Am I missing something?
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Test {

    public static void main(String[] args) throws IOException  {

        BufferedReader f = new BufferedReader(new FileReader("test.in.rtf"));

        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("test.out.rtf")));

        StringTokenizer st = new StringTokenizer(f.readLine());

        StringBuilder sb = new StringBuilder();

        for (char c : st.nextToken().toCharArray()) {
            sb.append((char)(c - 'a' + 1));
        }

        out.println(sb);                           // output result
        out.close();                                  // close the output file
        System.exit(0);
    }

}

A: I'm pretty sure you want
sb.append(Integer.toString(c - 'a' + 1));

or simply
sb.append( c - 'a' + 1 );

which implicitly does the same thing, since the expression c - 'a' + 1 is implicitly cast to an int since Java does all non-long integer math (anything involving chars, bytes, shorts, and/or ints) by converting everything to ints first.
What you had cast the integer result to a char, which would be represented by the character whose ASCII value is that number (something b/w 1 and 26), which isn't something readable.

A: You are trying to write the char values 1,2,3 and 4 ('a'-'a' + 1 = 1 and so on), which are all "unwriteable" hence the "?"s. Why you get 7 and not 4? I don't know - maybe a locale issue or 3 of them are just written as two "?".


text:
Q: Move Win7 partition to another disk I have a problem: my HP Stream has a 32GB built-in drive, and the software updates to Win7 need more space :-(
The partitions on the 32GB drive are:

*

*EFI

*MS protected

*Win7

*Windows recovery

I have a 64GB SHDC card in it, with linux installed (and dual boot). I'd like to swap them (so linux is on the 32GB drive & win7 on the 64GB one). I tried moving the MS protected + win7 partitions to the 64GB drive (after reformatting it), but then windows wouldn't boot and insisted on doing a full system recovery.
How can I move the installed Win7 to the 64GB drive?

*

*which partitions to move?

*what other changes to make (apart from post-move linux install)?

p.s. I've read the other answers relating to moving windows partitions, and they all assume that the old drive will be replaced by the new one.  That isn't the case for me.  I want to keep the existing drive as the boot drive, and move windows to another drive and have it dual bootable with linux on the old drive ...

A: With dual boot you must have grub installed.
The following procedure might work:

*

*Copy the Win7 contents to the 64GB drive

*Let grub discover it so having 2 Win7 installations

*Verify that the new Win7 installation can boot

*Install Linux over the previous Win7 partition and update grub.

Take a backup image of the 32GB disk first and have some means of restoring it,
just in case.
You will not be able to copy Windows from within Windows, so you will need
to use a tool such as
AOMEI Backupper Freeware
and ensure you can boot it.
Do not use a Linux Live CD/USB to copy Windows files.
I remark that an SHDC card is not as safe a media as a hard disk
(nor as fast),
so you should be careful with backups.


text:
Q: Sql query to perform Load check for an Employee I have a table design like this ...

*

*1 Project--> Multiple products.

*1 Product--> Multiple environment.

*1 Employee--> Multiple activities.

Status can be = "new", "inprogress", "on hold", "closed"
    Activity table- ActID(PK), assignedtoID(FK), Env_ID(FK), Product_ID(FK), project_ID(FK), Status.
    Product_table - Product_ID(PK), Product_name
    Project_Table- Project_ID(PK), Project_Name.
    Environment_Table- Env_ID(PK), Env_Name.
    Employee_Table- Employee_ID(PK), Name.
    Employee_Product_projectMapping_Table -Emp_ID(FK), Project_ID(FK), Product_ID(FK).
    Product_EnvMapping_Table - Product_ID(FK), Env_ID(FK).

Load check query
First find out the total number of activities assigned to each employee in a particular project.
(A). then find the number of activities for that employee in that project where status = new or inprogress.
(B). Divide A/B. Compute this A/B in percentage value.
So my final query table output will consist of

*

*Name of employee

*name of project

*total assigned act(Count value)

*Act having status new or in process(Count)

*Load(the percentage value. )

Can anyone help me with the query and explain how I can achieve this result? Thanks.
So far i have tried this much ... getting the results of A and B but now i need to combine these two...
(A).

SELECT activity_table.assignid, activity_table.projid, Count(activity_table.actid) AS CountOfactid
FROM activity_table
GROUP BY activity_table.assignid, activity_table.projid;

(B).

SELECT activity_table.assignid, activity_table.projid, Count(activity_table.actid) AS CountOfactid
FROM activity_table where status in ('new','inprogress')
GROUP BY activity_table.assignid, activity_table.projid ;

A: This is Upto 3rd result...not for 4th one.
select Employee_table.name,Project_table.Project_Name, Count(activity_table.actid) AS CountOfactid

from Activity table,Employee_Table,Project_Table,Employee_Product_projectMapping_Table

where Activity_Table.Product_Id=Project_Table.Product_Id

 and

aage ka syntax yaad nai aa raha hai...

Employee_Product_projectMapping_Table aur  Employee_Table ko combine karke emp name through equating product id...

for the 4th one use nested query......
will try to solve this query asap.....:P
409008....