text:
Q: How to differentiate between a list and parallelism In the phrase "inhibition of reflexes and skeletal relaxation", what sort of punctuation is used to differentiate between the 2 possible meanings - "inhibition of both reflexes and skeletal relaxation" and "inhibition of reflexes and skeletal relaxation"?

A: In the case of a list of only two items, it is better to rephrase the sentence (as already done in the case of one meaning in the question) than to rely solely on punctuation.

Without more extensive rewording, a common way of distinguishing the two is to use numbers in parentheses:

*

*I want to discuss the inhibition of (1) reflexes and (2) skeletal relaxation.

*I want to discuss (1) the inhibition of reflexes and (2) skeletal relaxation.

But if you are speaking strictly of punctuation, only one of the meanings can be made explicit—and it uses a nonstandard construction:

*I want to discuss the inhibition of reflexes; and skeletal relaxation.

This use of a semicolon is awkward, because it would not normally be used in this fashion. On the other hand, it makes the meaning very clear. Sometimes, otherwise awkward punctuation is necessary to make meaning clear—and conveying meaning is, ultimately, more important than how it's conveyed. But only if there is no other way of doing so.
Note that a comma could also be used, but using a comma for only two list items is even more unusual in this context than a semicolon.
If the list contained three or more items, then (depending on the nature of the items) a combination of a colon, commas, and semicolons would be the normal way of punctuating it to avoid ambiguity.

Note that the sentence as written can also be interpreted a third way that has not yet been mentioned:

*I want to discuss the inhibition of reflexes and skeletal relaxation.

In this interpretation, there is only a single thing being discussed.


text:
Q: Redirect a bookmarked page to login page I've a login page and some pages managed with session after login. If a user bookmarks a page after logging in, and tries to access the same bookmark later, I want that page to be redirected to login page again to enable secure access. How can this be achieved with jsp. Or is there some other way like javascript,etc., I would appreciate any help on this.
Thanks in advance.

A: IT's hard to say for sure without seeing any code. Essentially what you need to do is check the users session to see if it is still valid and then do the redirect if it is not valid.
you can redirect in JavaScript via
window.location = "Redirect Url"

You say you are using JSP so check this question, it looks to be what you need to do.
Checking if a user is already logged in or the session is started in jsp

redpajama_set_name: RedPajamaStackExchange


text:
Q: Django Unicode Error while loading Russian translation I am trying to install a Russian translation on a Django site.
What I did: in the 'locale' folder, alongside other languages I created the 'ru' folder then inside that I created the 'LC_MESSAGES' folder and that's where I placed the 'django.po' file with the translations. I created that .po file manually because the translations were given to me as an Excel file. In that .po file I copied the header that I found in another .po file on the same project and then with a script I created the 'msgid' / 'msgstr' pairs extracting this info from the Excel file. I checked the file and after modifying manually some errors it appeared to be correct and when doing a compilemessages I receive no error and the .mo file gets created.
Then I added 'ru' as a language in the settings file. Then I reloaded the home page and in the widget that we use to switch languages appeared Russian. But when I click it, it reloads the page and I get the Unicode error.
Some context: The site is in English but a Spanish translation is already installed and working properly with non ascii characters.
Any idea is welcome, even if not a full solution, just a way to debug it would be appreciated.
The error is: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128). You passed in  ()
From what I have found it is a problem with ugettext lazy but what I don't understand is why it works with other translations...
I get a Unicode hint from Django: The string that could not be encoded/decoded was: ������
This string changes according to what page I try to load.
Here is the traceback:
Traceback:
File "/home/env/project/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  136.                     response.render()
File "/home/env/project/lib/python2.7/site-packages/django/template/response.py" in render
  96.             self._set_content(self.rendered_content)
File "/home/env/project/lib/python2.7/site-packages/django/template/response.py" in rendered_content
  75.         content = template.render(context)
File "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in render
  123.             return self._render(context)
File "/home/env/project/lib/python2.7/site-packages/django/test/utils.py" in instrumented_test_render
  57.     return self.nodelist.render(context)
File "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in render_node
  757.         return node.render(context)
File "/home/env/project/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  127.         return compiled_parent._render(context)
File "/home/env/project/lib/python2.7/site-packages/django/test/utils.py" in instrumented_test_render
  57.     return self.nodelist.render(context)
File "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in render_node
  757.         return node.render(context)
File "/home/env/project/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  127.         return compiled_parent._render(context)
File "/home/env/project/lib/python2.7/site-packages/django/test/utils.py" in instrumented_test_render
  57.     return self.nodelist.render(context)
File "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in render_node
  757.         return node.render(context)
File "/home/env/project/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  64.             result = block.nodelist.render(context)
File "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in render_node
  757.         return node.render(context)
File "/home/env/project/lib/python2.7/site-packages/django/templatetags/i18n.py" in render
  76.         return _render_value_in_context(output, context)
File "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in _render_value_in_context
  777.     value = force_unicode(value)
File "/home/env/project/lib/python2.7/site-packages/django/utils/encoding.py" in force_unicode
  93.             raise DjangoUnicodeDecodeError(s, *e.args)

Exception Type: DjangoUnicodeDecodeError at /
Exception Value: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128). You passed in <django.utils.functional.__proxy__ object at 0x9f3f16c> (<class 'django.utils.functional.__proxy__'>)

Edit:
I tried to start again from scratch. I deleted my manually created locale folder and .po files to try with the 'makemessages' command and during the execution of that command I get this error:
processing language ru
Traceback (most recent call last):
  File "./manage.py", line 15, in <module>
    execute_manager(settings)
  File "/home/env/project/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/home/env/project/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/env/project/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/env/project/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/home/env/project/lib/python2.7/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/home/env/project/lib/python2.7/site-packages/django/core/management/commands/makemessages.py", line 365, in handle_noargs
    make_messages(locale, domain, verbosity, process_all, extensions, symlinks, ignore_patterns, no_wrap, no_obsolete)
  File "/home/env/project/lib/python2.7/site-packages/django/core/management/commands/makemessages.py", line 233, in make_messages
    f.write(templatize(src, orig_file[2:]))
  File "/home/env/project/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 127, in templatize
    return _trans.templatize(src, origin)
  File "/home/env/project/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 450, in templatize
    content = u''.join(comment)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 7: ordinal not in range(128)

So obviously something must be wrong somewhere else. I'll keep looking.
Edit:
Apparently the 'makemessages' tool cannot handle non ascii characters in templates, whether marked as to be translated or not. I spotted quite a lot of them and I don't know yet what to do with them. Once I find it I will report here.

A: I have updated to Django 1.4.5 and the problem totally disappeared. The .po file is generated properly and the compilation goes well too.


text:
Q: Get the updated cell value when i press the buttom in the grid row i have a datagrid in wpf contains text column and button column with c# code when i update the cell and press the button in the row it takes the original value from datagrid sourceItems
but if i Pressed Enter then i went back to column and pressed the button it takes the updated value
please find below thw xml code and c# code
I tried to get the selected row the take the values but the problem same it takes the values from source items
 <DataGrid x:Name="GrdExamCheck" AutoGenerateColumns="False" HorizontalAlignment="Left" Background="{x:Null}" VerticalAlignment="Stretch" Canvas.Top="10" FontFamily="Times New Roman" Width="1079" FontWeight="Bold" Canvas.Left="10" >
                <DataGrid.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="TextBlock.TextAlignment" Value="Center"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type DataGridCell}">
                                    <Grid Background="{TemplateBinding Background}">
                                        <ContentPresenter VerticalAlignment="Bottom"/>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </DataGrid.CellStyle>
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Student ID" Visibility="Hidden" Binding="{Binding StuId}"/>
                    <DataGridTemplateColumn Header="Student" Width="180" IsReadOnly="True">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="{Binding StuImage}" Width="50" Height="50" />
                                    <TextBlock Text="{Binding StuName}" VerticalAlignment="Bottom" FontFamily="Times New Roman" FontWeight="Bold" FontSize="13"/>
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTextColumn Header="Mark" Width="100" Binding="{Binding CheckMark}"></DataGridTextColumn>
                    <DataGridTemplateColumn Header="Factor" Width="100" IsReadOnly="True">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Factor}" TextAlignment="Center"  VerticalAlignment="Bottom" FontFamily="Times New Roman" FontWeight="Bold" FontSize="13"/>
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn Header="Versions" Width="100" IsReadOnly="True">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding CheckUpdated}" VerticalAlignment="Bottom" TextAlignment="Center"  FontFamily="Times New Roman" FontWeight="Bold" FontSize="13"/>
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn Header="Remark" Width="200" >
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Text="{Binding Remark}" VerticalAlignment="Bottom"  HorizontalAlignment="Stretch" FontFamily="Times New Roman" FontWeight="Bold" FontSize="13" Foreground="Black" BorderBrush="{x:Null}" Background="{x:Null}"/>
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn Header="Absent" Width="70">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button x:Name="BtnAbsent" Content=""  Width="40" Height="40" BorderBrush="{x:Null}" Click="BtnAbsent_Click" >
                                    <Button.Background>
                                        <ImageBrush ImageSource="/School Manager v001;component/Pics/absent.ico" Stretch="Uniform"/>
                                    </Button.Background>
                                </Button>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn Header="Submit" Width="70">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button x:Name="BtnSubmit" Content=""  Width="40" Height="40" BorderBrush="{x:Null}" Click="BtnSubmit_Click" >
                                    <Button.Background>
                                        <ImageBrush ImageSource="/School Manager v001;component/Pics/submitMark.ico" Stretch="Uniform"/>
                                    </Button.Background>
                                </Button>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn Header="Attach" Width="70">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button x:Name="BtnAttach" Content=""  Width="40" Height="40" BorderBrush="{x:Null}" Click="BtnAttach_Click" >
                                    <Button.Background>
                                        <ImageBrush ImageSource="/School Manager v001;component/Pics/attachment.ico" Stretch="Uniform"/>
                                    </Button.Background>
                                </Button>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>

c# code :
private void BtnSubmit_Click(object sender, RoutedEventArgs e)
    {
        var mark = GrdExamCheck.CurrentItem as Mark;
        if (mark != null)
        {
            InsertMark(int.Parse(LbExamIdContent.Content.ToString()), mark.StuId, DateTime.Now.ToShortDateString(), mark.Remark, Convert.ToDecimal(mark.CheckMark), Convert.ToDecimal(LbFactorContent.Content.ToString()));
        }
        FillClassStudentList(int.Parse(LbCLassIdContent.Content.ToString()));

    }

I need to get the current text from Mark column if i edit the text and directly pressed the submit button

A: You have to trigger the update of the binding source when the property changes:
 Binding="{Binding Path=CheckMark, UpdateSourceTrigger=PropertyChanged}"


text:
Q: c++: statically link against different versions of the same library? I include a 3rd party library in my code. I maintain a static link to it and am unable to support dynamic links (which would be the easiest solution to the problem but is not possible in my case). Recently, the developer of that library posted an update which includes some breaking changes (function parameters changed within the API, features added/removed, etc).
I have users who rely on features of the old version of the library, and users who will want the new features as well. I would like to avoid having to compile multiple version of my code in order to support multiple versions of the library. Instead, I would like to include a switch in my UI that allows users to choose which version of the library they'd like to use.
When it comes to compiling my code, if I try a naive solution and simply include both old and new libraries, I get multiply-defined-symbols errors (because not all function signatures between the versions are different) and such....and many of the header filenames are identical so there's no straight-forward way differentiate between the two in many cases.
I was thinking of creating an intermediate wrapper library for both libraries...the wrappers would be compiled separately and their APIs couched in different namespaces, and then included in my code. I would then call a different wrapper depending on my needs, which would access the appropriate library internally....but is such a thing possible? I wanted to ask here before putting in all the legwork of setting up those wrappers, only to run into the same multiple-symbol-definition errors again....
Or is there another way? Thanks in advance.

A: Your described solution is pretty much the way to go about this. You won't run into multiple-definition errors so long as your intermediate wrappers only expose your custom interface and not the symbols from the 3rd party library.


text:
Q: Access violation to server in Delphi Was trying to write simple client and server recieveing/sending data through TMemoryStream. When I push button in client btnTestClick it apperas an error
Access violation at address 005D5581 in module 'Client.exe'. Write of adress 00000000. What I do wrong?
Btw client server connection works okay I thin cuz IdTCPClient1Connected function is writing 'Client Connected!'.
Client code
procedure TForm1.btnTestClick(Sender: TObject);
var
  msRecInfo: TMemoryStream;
  arrOf: array of Integer; i:integer;
begin
  for i := 0 to 10 do
    arrOf[i]:=random(100);

  msRecInfo:= TMemoryStream.Create;

  try
    msRecInfo.Write(arrOf, SizeOf(arrOf));
    idTCPClient1.IOHandler.Write(msRecInfo);
  finally
     msRecInfo.Free;
  end;

end;

end

Server code
procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var
   msRecInfo: TMemoryStream;
  arrOf: array of Integer; i:integer;
begin
  msRecInfo:= TMemoryStream.Create;
  try
    AContext.Connection.IOHandler.ReadStream(msRecInfo, -1, False);

    msRecInfo.Position := 0;
    msRecInfo.Read(arrof, SizeOf(arrof));
  finally
    memo1.Lines.Add(IntToStr(arrOf[1]));
    msRecInfo.Free;
  end;
  //AContext.Connection.IOHandler.ReadStream(msRecInfo, SizeOf(arrOf));
  //msRecInfo.Read(arrOf, sizeOf(arrOf));
end;

A: You start writing into a dynamic array before you've allocated any elements for it. Dynamic arrays do not automatically grow like you might be used to from some other languages. You need to set their lengths first.
If you haven't set the length of a dynamic array, then it will just be a null pointer, which explains why you get an access violation at address 0.
Change your btnTestClick method like so:
var
  msRecInfo: TMemoryStream;
  arrOf: array of Integer;
  i: integer;
begin
  SetLength(arrOf, 11);
  for i := 0 to 10 do
    arrOf[i] := Random(100);


text:
Q: stripping files extention but only if it exists I have a question.
I would like to know how i can strip a files extention from its name but only if it exists to begin with, thus simply stripping the last four characters wont work.
I use batch
this causes my delema:
rem SETS THE NAME THE USER WANTS TO SAVE THE FILE AS...
SET /P MY_NAME=   FILE NAME:

REM SAVES FILE AS INDICATED BY USER...
ECHO %MYTEXT% > "%MY_DIR%\%MY_NAME%.txt"

I could leave the extention completely off  (second line of code) But then the user might not add the extention there self.

A: [Documenting that this question is answered by @npocmaka]
To check if file exists use:
if [not] exist %myfile% (something)

To get file name without extension use:
for /f %%F in (%myfile%) do ( echo %%~nF)


text:
Q: "git push" failing on Heroku I am trying to see how to use React on a Heroku app for the first time.
I followed these tutorials:

*

*https://www.bacancytechnology.com/blog/deploy-react-app-on-heroku

*https://stackabuse.com/how-to-deploy-a-react-app-to-heroku/
By the end I hit the issue below when running the command: git push heroku main
I did two trials and had the same problem each time. I do not remember having seen this before. What is the way to handle the situation?
remote: Verifying deploy...
remote:
remote: !   Push rejected to testapp.
remote:
To https://git.heroku.com/testapp.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/testapp.git'
me@My-MacBook testapp %

For more details; this is the complete result of running the git push heroku main command:
me@My-MacBook testapp % git push heroku main
Enumerating objects: 22, done.
Counting objects: 100% (22/22), done.
Delta compression using up to 8 threads
Compressing objects: 100% (22/22), done.
Writing objects: 100% (22/22), 307.67 KiB | 8.10 MiB/s, done.
Total 22 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-22 stack
remote: -----> Using buildpack: mars/create-react-app
remote: -----> React.js (create-react-app) multi app detected
remote:
remote: =====! create-react-app-buildpack has reached end-of-life
remote:        This build may succeed, but the buildpack is no longer maintained.
remote:        On the Heroku-22 stack and beyond, this may fail to build at all.
remote:
remote:        Please consider migrating to https://nextjs.org or https://remix.run to develop React apps which are deployable using Heroku's Node.js buildpack https://github.com/heroku/heroku-buildpack-nodejs, or you may develop your own create-react-app deployment with Node.js and Nginx buildpacks.
remote:
remote: =====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-multi.git
remote: =====> Detected Framework: Multipack
remote: =====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-nodejs.git
remote: =====> Detected Framework: Node.js
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 18.x...
remote:        Downloading and installing node 18.13.0...
remote:        Using default npm version: 8.19.3
remote:
remote: -----> Installing dependencies
remote:        Installing node modules
remote:
remote:        added 1470 packages, and audited 1471 packages in 19s
remote:
remote:        231 packages are looking for funding
remote:          run `npm fund` for details
remote:
remote:        6 high severity vulnerabilities
remote:
remote:        To address all issues (including breaking changes), run:
remote:          npm audit fix --force
remote:
remote:        Run `npm audit` for details.
remote:
remote: -----> Build
remote:        Running build
remote:
remote:        > testapp@0.1.0 build
remote:        > react-scripts build
remote:
remote:        Creating an optimized production build...
remote:        Compiled successfully.
remote:
remote:        File sizes after gzip:
remote:
remote:          46.6 kB  build/static/js/main.c9d4c383.js
remote:          1.78 kB  build/static/js/787.49a3df42.chunk.js
remote:          541 B    build/static/css/main.073c9b0a.css
remote:
remote:        The project was built assuming it is hosted at /.
remote:        You can control this with the homepage field in your package.json.
remote:
remote:        The build folder is ready to be deployed.
remote:        You may serve it with a static server:
remote:
remote:          npm install -g serve
remote:          serve -s build
remote:
remote:        Find out more about deployment here:
remote:
remote:          https://cra.link/deployment
remote:
remote:
remote: -----> Caching build
remote:        - npm cache
remote:
remote: -----> Pruning devDependencies
remote:
remote:        up to date, audited 1471 packages in 4s
remote:
remote:        231 packages are looking for funding
remote:          run `npm fund` for details
remote:
remote:        6 high severity vulnerabilities
remote:
remote:        To address all issues (including breaking changes), run:
remote:          npm audit fix --force
remote:
remote:        Run `npm audit` for details.
remote:
remote: -----> Build succeeded!
remote: =====> Downloading Buildpack: https://github.com/mars/create-react-app-inner-buildpack.git#v9.0.0
remote: =====> Detected Framework: React.js (create-react-app)
remote:        Writing `static.json` to support create-react-app
remote:        Enabling runtime environment variables
remote: =====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-static.git#21c1f5175186b70cf247384fd0bf922504b419be
remote: =====> Detected Framework: Static HTML
remote: Stack heroku-22 is not supported!
remote:  !     Push rejected, failed to compile React.js (create-react-app) multi app.
remote:
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: f609d0c54516882f24faf2a1b4fcad975cc76b04
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version f609d0c54516882f24faf2a1b4fcad975cc76b04
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: !   Push rejected to testapp.
remote:
To https://git.heroku.com/testapp.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/testapp.git'
me@My-MacBook testapp %

A: As your logs explain, this is not a git push issue but rather heroku version compatibility issue with react. I hope this helps,
https://stackoverflow.com/a/72743983/2699319

> pre-receive hook declined
indicates either that branch is protected from direct pushes OR you lack the permissions to push to that branch. If it's your own project, you can change this in the repository's settings. If it's a group/company project, you might want to ask around for permissions/access.
Since it is called main, I will assume the branch is important for the overall project. You might want to make a pull request then ask your peers to review and approve it.
Alternatively if you are testing this out in a sandbox environment by yourself, you can just force push
git push -f heroku main


text:
Q: How to put a block in the top part of a column? How can I put a block in the top part of a column in beamer?
For example I have the following code:
\documentclass[pdf]{beamer}
\begin{document}

\begin{frame}
    \begin{columns}
        \begin{column}{0.5\textwidth}
            Left column
        \end{column}
        \begin{column}{0.5\textwidth}
            \begin{block}{Block 1}
                Text of the block
            \end{block}
        \end{column}
    \end{columns}
\end{frame}

\end{document}

If I insert the option [t] to frame it moves up also the content of the left column.
How can I put the block in the top part of its column?

A: beamer columns are  basically just glorified minipages. If you directly use minipages, you can control their height and vertical position:
\documentclass{beamer}
\begin{document}

\begin{frame}

        \begin{minipage}[c][.8\textheight][c]{0.5\textwidth}
            Left column
        \end{minipage}%
        \begin{minipage}[c][.8\textheight][t]{0.5\textwidth}
            \begin{block}{Block 1}
                Text of the block
            \end{block}
        \end{minipage}%

\end{frame}

\end{document}


text:
Q: Post-human Earth with intelligent animals. In one scene, bear rubs against crystal pylon to leech energy from structure holding stored human minds Another question reminded me of two similar stories that I can't place regarding intelligent animals.
In the one I'm asking about in this question, there are various species of sapient animals in a far future Earth. Humans no longer walk the Earth -- they apparently all uploaded their consciousnesses into towering crystalline structures long ago, and if those uploaded minds are still conscious, they have had no apparent interaction with the external world for a very long time.
I don't remember whether the animals had been artificially uplifted or had evolved intelligence naturally, but if they possessed (as they seemed to) passed-down stories of what humans were, I would guess they had been at least more sapient already, when the last breathing humans vanished, than non-human animals are now.
The main character is a member of one of the species of sapient animals. I don't remember the story very well, I but remember a scene in which the main character is shocked by seeing a bear deliberately brush up against one of the crystalline structure pylons. This taboo act somehow leeches some psychic energy from the structure that houses the uploaded minds, conferring some extra intelligence or something like that.
I think there may have been another element to the story -- that the main character was in telepathic communication with an animal elsewhere on Earth. This might be a memory mixed in from some other story, however.
This story was probably in a science fiction magazine or anthology from the 1960s to early '00s.
It is not Edmond Hamilton's "Day of Judgment".
I do not think it is Andre Norton's novel A Breed to Come (which was a suggested answer to the question linked at the top), either. This was at most novella length, not a full book.

A: That sounds like Brian W. Aldiss' short story "Old Hundredth".  It fits in every point.  The main character as an uplifted sloth and human minds are in semi-material structures called Involutes.  IIRC, bears jump through those Involutes to gain...something, and this is considered not right by the other animals.

Each Involute carried thousands or even millions of people. They were, not dead, not living. How they exulted or wept in the transubstantiation, nobody left could say. Only the could be said: man had gone and a great emptiness was fallen over the Earth.

The uplifted animals could do the Involute thing, but when they were ready to die turn into something like columns of music. The sloth main character, Dandi, chooses the music to "Old Hundredth"..."All creatures that on Earth do dwell."
Wikipedia has an article: https://en.wikipedia.org/wiki/Old_Hundredth_(short_story).  It's been widely reprinted: https://www.isfdb.org/cgi-bin/title.cgi?51068 and https://www.isfdb.org/cgi-bin/title.cgi?493321.


text:
Q: Persist virtual network after reboot in Windows I'm not sure in the terms, but I create "virtual" network in Windows by running netsh interface ip add address "vEthernet (WSL)" 192.168.99.1 255.255.255.0 command. It does all I need with the only problem that it disappears after reboot. Is it possible to make it persistent in other rather than creating startup script way?
Could you please also say the right name for that network? Is that virtual or what?


text:
Q: Model-independent Rails 4 file upload in dynamically loaded (nested) form field I'm looking for a way for simple image upload onto the file system so that the image is not stored in the database. I understand this step is rather easy, just using a file_input tag, however I have problems making it happen because of how my form is built.
I have a project where I create static campaign pages by having a user specify a page layout, or a template, for the page. Once the user selects which template they want to load for their page, a form is loaded that contains a section for each of the widgets that the specified template contains. The user inputs their information, presses submit, and a static page is created.
One of the widgets is an image widget, where the user should select a file from their system and that should get uploaded to the server on submitting the form. The problem is that because of how I'm using the form helpers, I'm facing the issue, where file upload gives filename as a string instead of the IO object (https://www.ruby-forum.com/topic/125637). I need help on trying to work around this.
The form for inputting data onto the page (which is stored in the table campaign_pages) looks like this:
= form_for(@campaign_page, class: 'form-horizontal') do |f|
  fieldset
    legend Basic page information
    .form-group
      = f.label :featured, class: 'control-label col-lg-2'
      .col-lg-10
        = f.check_box :featured, class: 'form-control'

      = f.label :title, class: 'control-label col-lg-2'
      .col-lg-10
        = f.text_field :title, placeholder: 'Unique and really catchy page title!', class: 'form-control'

      = f.label :campaign_id, 'Campaign: ', class: 'control-label col-lg-2'
      .col-lg-10
        = f.select :campaign_id, options_from_collection_for_select(@campaigns, 'id', 'campaign_name', @campaign), {}, html_options= {:class => 'form-control'}

      = f.label :language_id, 'Language: ', class: 'control-label col-lg-2'
  .col-lg-10
        = f.select :language_id, options_from_collection_for_select(Language.all,'id', 'language_name'), {}, html_options= {:class => 'form-control'}

      label for='template_id' class='control-label col-lg-2' Template:
  .col-lg-10
        = select_tag 'template_id', options_from_collection_for_select(@templates, 'id', 'template_name', @template), class: 'form-control'
      | data-no-turbolink="true"

This is where forms for content for each widget on the page gets loaded once a template has been selected:
    #widget_location
      = render :file => 'templates/show_form', layout: false

    .form-group
      = f.submit 'Save Page', class: 'btn btn-sm btn-primary'

The form for the image widget (which creates the problem) looks like so:
#image_widget_form.form-group
  = label_tag 'widgets[image][image_url]', 'Image URL:', class: 'control-label col-lg-2'
  .col-lg-10
    = text_field_tag 'widgets[image][image_url]', options['image_url'], class: 'form-control'
    = hidden_field_tag 'widgets[image][widget_type]', WidgetType.find_by(:widget_name => 'image').id
    = file_field_tag 'widgets[image][image_upload]'

After reading the documentation (http://guides.rubyonrails.org/form_helpers.html#uploading-files) and other issue reports, my understanding is that the problem is "multipart => true", which you have to specify if you want your file field tag to work. That shouldn't be a problem, because I'm using form_for @campaign_page instead of form_tag. However, the widgets and their content do not belong to the campaign page table, and so they aren't specified in the model for a campaign page. Thus, I can't simply use f.file_field for the file input.
I'm looking for a solution for this. Would using nested attributes and then using field_for for the image upload work?
Another issue is that specifications and content for the widgets are stored in a Postgres JSONB field, and I'm not sure how nested attributes would work for those.

A: I assumed that the form had multipart set, because specifying multipart => true for a form_for helper is not necessary according to Rails documentation. The fix turned out to be pretty simple, however - it works after setting multipart: true in a html options hash for the form tag:
= form_for(@campaign_page, class: 'form-horizontal', html: {multipart: true}) do |f|
...


text:
Q: Slack interactive Button configaration and workflow using botkit,expressjs? i want to know about how an interactive button in slack works with the help of botkit,any one show one simple example with the above combination and that will more helpful for me.

A: Did you see this example in the docs?
https://github.com/howdyai/botkit/blob/master/examples/slack/slackbutton_bot_interactivemsg.js


text:
Q: Specify "base" from-table in SQLAlchemy Suppose I have 3 tables: A, B, C.
A: id, fieldA
B: id, id_a, fieldB; id_a - foreign key for A.id
C: id, id_b, fieldC; id_b - foreign key for B.id

Now I want to run this sql query:
SELECT A.fieldA,
       B.fieldB
FROM   C
       LEFT JOIN B
            LEFT JOIN A
              ON A.id = B.id_a
         ON B.id = C.id_b
WHERE  C.fieldC = :myvalue

The SQLAlchemy query would be:
session.query(A.fieldA, B.fieldB).join(...).join(...).filter(C.fieldC == myvalue)
                                 ^------------------^ issue here

The problem is that all the joins will be applied to the table that was selected in the query first, i.e. in this case to A.
I can use some dummy hack like:
session.query(C.fieldC, A.fieldA, B.fieldB).join(B).join(A).filter(C.fieldC == myvalue)
              ^------^ I don't need this column

But, of course, this is not desirable.
Is there a way to specify base table that will have all the joins attached to?

A: Given your example, you need:

*

*to specify the left part of the join using select_from

*and use an outerjoin (and not an inner join)

I don't have SQLAlchemy at hand right now, so I cannot guarantee this will work "out of the box", but something like that would be a good starting point:
session.query(A.fieldA, B.fieldB)        \
          .select_from(C)                \
          .outerjoin(B, ....)            \
          .outerjoin(A, ....)            \
          .filter(C.fieldC == myvalue)


text:
Q: delete message for one user but not for the other hello I have a database with 3 tables.
USERS('user_id','name','surname')
MESSAGE_GROUP('user_one','user_two', 'hash')
MESSAGES('from_id','group_hash', 'messages')

My php code enables me to send messages between users. My question is how to enable a user to delete a message from its mailbox but the other user still watching the message. The messages must be full deleted only if both users delete the message. I am not interesting about the code, I am interesting only in finding the logic behind this. Any proposals that includes mysql code are welcome. thanks

A: I think you should follow this. :)

*

*You can keep an extra field in message_group table something like 'deleted_from' which will be initially 0

*If user one deletes it make the value of 'deleted_from'=1, if user two deletes it, make the value of 'deleted_from' = 2.

*When you go to delete the message for a user, and you find the value 'deleted_from' other than 0, delete the message completely, else mark the value of 'deleted_from' as '1' or '2'.

A: You will need to either:

*

*Make a new table that specifies the mailboxes the message resides in, so that you can connect it to both users mailboxes

*Or duplicate the message so that each user has their own copy that can be deleted

*Add flags to the message table (not recommended) indicating whether the sender or recipient has deleted it. This I would avoid as it will not scale well if you have (or intend to add) group messaging.

A: add to MESSAGE_GROUP a status field with values :
0 no owner and should be deleted
1 only the sender owns the message
2 only the reciever owns the message
3 both sender and recievers own it

A: I would change the fields from the table in between like this (example that every user only can send a message to one person at a time):
    USERS('user_id','name','surname')
    MESSAGE_GROUP('user_id','message_id')
    MESSAGES('from_id', 'to_id', 'messages')

So every user that has a message, will have a row in the MESSAGE_GROUP. When one user deletes the post, delete that row in MESSAGE_GROUP


text:
Q: What's is the path to Hostinger? I want to reach my php files that are in Hostinger in my Android studio. Whats is the path for doing that?
private static final String URL =    "http://mysql.hostinger.pt/u488015497_park/list.php";

Is this path correct?


text:
Q: Как понять данную запись с пайплайном ("|")? Есть такая вот строчка кода: (i / 3 | 0) * 10. i принимает значения от 0 до 14. Как ее понять и, что более важно, можно ли (а если можно, то как) записать это более очевидно?
Для полного "Дзена" было бы еще неплохо получить хотя бы примерное представление о том, как она работает на примере двоичного числа.

A: Знак | является оператором "побитовое или".
num | 0 не меняет биты числа как таковой, поэтому число num не меняется. Но в комментариях к вопросу было выяснено, что в JavaScript при этом отбрасывается дробная часть. То есть суть данного выражения - приведение дробного числа к целому. В данном конкретном примере берется целая часть от выражения i / 3 (и умножается на 10, вестимо).
Также, наверное, стоит упомянуть про приоритет выполнения. У операции | приоритет ниже, чем у арифметических операций, поэтому скобки вокруг i / 3 здесь не нужны.


text:
Q: how to remove dependencies Java Hi how I can remove dependecies in this code
public boolean removeJob(final JobEntity job) {

    @OneToOne(cascade=CascadeType.REMOVE)
    final boolean result =
        updateByNamedQuery(JobQueries.REMOVE_JOB_X_BY_ID_KEY, job.getId()) > 0;
    if (result) {
        updateByNamedQuery(JobQueries.REMOVE_JOB_BY_ID_KEY, job.getId());
    }
    return result;
}

and Hibernate:
@NamedQuery(name = "JobEntity." + JobQueries.REMOVE_JOB_X_BY_ID_KEY, query
               JobQueries.REMOVE_JOB_TRIGGER_BY_ID)


text:
Q: Android on Kotlin: How to pass data from an Activity to an event listener? (Android newbie learning Kotlin here...) I have an app with 3 components: A UI activity where a user indicates what color car she wants to see; A service that uses the device's camera to observe a road and report every car that passes by; And an event listener latched on the service. The job of the event listener is to determine whether any car reported by the camera is of the requested color and, if so, do something about it.
I'm tripping over something that's probably basic: how does the listener know what color to look for? I can:

*

*Have the activity (a class) write to a variable owned by the listener (an object) (hmmm...)

*Have the activity drop the color in an event bus (does it have to be so complicated?)

*Have the listener reach over and read a screen variable (hmmm...)

*Use some global variable in some singleton (hmmm...)

What's the proper way to do this? Many thanks!

A: I think you can take help of the Shared preferences to store the value(i.e color)or you can do as you mentioned in the 4th point.


text:
Q: chrome.management.get not working function Notify(header,content,image){
    var note = webkitNotifications.createNotification(image||"",header,content);
    note.show();
return note;}

var extensions = ["pbjhaapnigfhipfahcfkeakpcgkmnklc"];

function CheckReload(){
    for(var CN=0;CN<extensions.length;CN++){
        var id = extensions[CN];
        var ex = chrome.management.get(id);
        console.log("Checking",ex,"-",id);
        if(!ex.enabled){
            Notify("Extension reloaded!",ex.name+" was found crashed, and reloaded!");
            chrome.management.setEnabled(id,true);
        }
     }
}
setInterval(CheckReload,1000);

Ok, so what I was expecting was for this to check the extensions in the "extensions" array, and if they weren't enabled it would create a notification saying that it wasn't, and then enable it.
However, chrome.management.get(id) seems to be returning undefined.
I expected an output like:
Checking Object - [id]
Instead, what I got was:
Checking undefined - pbjhaapnigfhipfahcfkeakpcgkmnklc
Uncaught TypeError: Cannot read property 'enabled' of undefined
How can I fix this?

A: Most of the methods provided by chrome don't return a value, instead they take a callback function as a parameter, and call that function with the wanted result.
You should replace your code by
chrome.management.get(id, function(ex) {
    console.log("Checking",ex,"-",id);
    if(!ex.enabled){
        Notify("Extension reloaded!",ex.name+" was found crashed, and reloaded!");
        chrome.management.setEnabled(id,true);
    }
});

See http://developer.chrome.com/extensions/management.html#method-get for details.

A: If you are running your code from an extensions, make sure that your extension have permissions to management.


text:
Q: What is similar to LSQUnivariateSpline in C# I have one project in python and I want to convert into C#.
I don't know anything about Python.
So can you guys tell me, What is LSQUnivariateSpline and How can I implement similar thing in c#?


text:
Q: Android resource linking failed - Daemon: AAPT2 aapt2-3.2.0-4818971-windows Daemon #0 I upgraded android studio to 3.2.0 and created the default project. But the compiler shows the error:
Android resource linking failed
Output:  D:\android1\project\algeria\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml:54: error: unexpected element <action> found in <manifest><application><service>.

Command: C:\Users\nthan\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\82eccc572f5d84358296092db0bec570\aapt2-3.2.0-4818971-windows\aapt2.exe link -I\
    D:\Sdk\platforms\android-26\android.jar\
    --manifest\
    D:\android1\project\algeria\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
    -o\
    D:\android1\project\algeria\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
    -R\
    @D:\android1\project\algeria\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
    --auto-add-overlay\
    --java\
    D:\android1\project\algeria\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
    --custom-package\
    \
    -0\
    apk\
    --output-text-symbols\
    D:\android1\project\algeria\app\build\intermediates\symbols\debug\R.txt\
    --no-version-vectors
Daemon:  AAPT2 aapt2-3.2.0-4818971-windows Daemon #0

My Project build gradle:
buildscript {
repositories {
    jcenter()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}
allprojects {
repositories {
    jcenter()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

My Module build gradle:
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "27.0.1"
defaultConfig {
    applicationId ""
    minSdkVersion 16
    targetSdkVersion 26
    versionCode 3
    versionName "2.3"
    testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
    }
}
buildTypes.each {
    it.buildConfigField 'String', 'handsome', black
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-
   core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.android.exoplayer:exoplayer:r1.5.3'
implementation 'com.google.code.gson:gson:2.6.2'
implementation 'com.google.firebase:firebase-ads:10.2.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-ads:8.4.0'
testImplementation 'junit:junit:4.12'
}

My manifests:
  <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:windowSoftInputMode="stateAlwaysHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <!--<action android:name="android.intent.action.PHONE_STATE" >-->
            <!--</action>-->
        </intent-filter>
    </activity>
    <activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:theme="@android:style/Theme.Translucent" />
    <activity android:name=".InterstitialActivity"></activity>
    <service android:name=".service.ForegroundService" >
        <action android:name="android.intent.action.PHONE_STATE" />
    </service>

</application>

I have the last version of android studio and my project worked perfectly before upgrading my gradle...
And I can't think of any way out.Just for help!!

A: there is a problem in your manifest code.
the  service tag  needs to contain intent-filter  tag
before using the action tag !!
https://developer.android.com/guide/topics/manifest/service-element
solution :
<service android:name=".service.ForegroundService" >
<intent-filter>
        <action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
    </service>


text:
Q: Docke-sync issue : i am running the docker-sync start cmd and i got an error i'm workin on windows 10 OS, im already running docker on my machine as you can see in the picture
and i am trying to run " docker-sync start" on a sub-system linux ( an app ( named Debian) I installed from Microsoft store ) and i got the error i shared in the picture, the sub-system doesn't detect docker desktop on my machine.
anyone has an idea how te resolve this ?
this is my image error

A: Restarting Docker from command line worked for me.

Stop Docker:
test -z "$(docker ps -q 2>/dev/null)" && osascript -e 'quit app "Docker"'

Start Docker:
open --background -a Docker


text:
Q: Find contour/edge in pcolor in Matlab I'm trying to make a contour that follows the edges of the 'pixels' in a pcolor plot in Matlab. This is probably best explained in pictures. Here is a plot of my data. There is a distinct boundary between the yellow data (data==1) and the blue data (data==0):

Note that this is a pcolor plot so each 'square' is essentially a pixel. I want to return a contour that follows the faces of the yellow data pixels, not just the edge of the yellow data.

So the output contour (green line) passes through the mid-points of the face (red dots) of the pixels.
Note that I don't want the contour to follow the centre points of the data (black dots), which would do something like this green line. This could be achieved easily with contour.

Also, if it's any help, I have a few grids which may be useful. I have the points in the middle of the pixels (obviously, as that's what I've plotted here), I also have the points on the corners, AND I have the points on the west/east faces and the north/south faces. IF you're familiar with Arakawa grids, this is an Arakawa-C grid, so I have the rho-, u-, v- and psi- points.
I've tried interpolation, interweaving grids, and a few other things but I'm not having any luck. Any help would be HUGELY appreciated and would stop me going crazy.
Cheers, Dave
EDIT:
Sorry, I simplified the images to make what I was trying to explain more obvious, but here is a larger (zoomed out) image of the region I'm trying to separate:

As you can see, it's a complex outline which heads in a "southwest" direction before wrapping around and moving back "northeast". And here is the red line that I'd like to draw, through the black points:

A: You can solve this with a couple of modifications to a solution I posted to a related question. I used a section of the sample image mask in the question for data. First, you will need to fill the holes in the mask, which you can do using imfill from the the Image Processing Toolbox:
x = 1:15;  % X coordinates for pixels
y = 1:17;  % Y coordinates for pixels
mask = imfill(data, 'holes');

Next, apply the method from my other answer to compute an ordered set of outline coordinates (positioned on the pixel corners):
% Create raw triangulation data:
[cx, cy] = meshgrid(x, y);
xTri = bsxfun(@plus, [0; 1; 1; 0], cx(mask).');
yTri = bsxfun(@plus, [0; 0; 1; 1], cy(mask).');
V = [xTri(:) yTri(:)];
F = reshape(bsxfun(@plus, [1; 2; 3; 1; 3; 4], 0:4:(4*nnz(mask)-4)), 3, []).';

% Trim triangulation data:
[V, ~, Vindex] = unique(V, 'rows');
V = V-0.5;
F = Vindex(F);

% Create triangulation and find free edge coordinates:
TR = triangulation(F, V);
freeEdges = freeBoundary(TR).';
xOutline = V(freeEdges(1, [1:end 1]), 1);  % Ordered edge x coordinates
yOutline = V(freeEdges(1, [1:end 1]), 2);  % Ordered edge y coordinates

Finally, you can get the desired coordinates at the centers of the pixel edges like so:
ex = xOutline(1:(end-1))+diff(xOutline)./2;
ey = yOutline(1:(end-1))+diff(yOutline)./2;

And here's a plot showing the results:
imagesc(x, y, data);
axis equal
set(gca, 'XLim', [0.5 0.5+size(mask, 2)], 'YLim', [0.5 0.5+size(mask, 1)]);
hold on;
plot(ex([1:end 1]), ey([1:end 1]), 'r', 'LineWidth', 2);
plot(ex, ey, 'k.', 'LineWidth', 2);

A: Take a look at the following code:
% plotting some data:
data = [0 0 0 0 0 0 1 1
    0 0 0 0 0 1 1 1
    0 0 0 0 1 1 1 1
    0 0 0 0 0 1 1 1
    0 0 0 0 1 1 1 1
    0 0 0 0 1 1 1 1
    0 0 0 0 1 1 1 1];
p = pcolor(data);
axis ij
% compute the contour
x = size(data,2)-cumsum(data,2)+1;
x = x(:,end);
y = (1:size(data,1));
% compute the edges shift
Y = get(gca,'YTick');
y_shift = (Y(2)-Y(1))/2;
% plot it:
hold on
plot(x,y+y_shift,'g','LineWidth',3,'Marker','o',...
    'MarkerFaceColor','r','MarkerEdgeColor','none')

It produces this:

Is this what you look for?
The most important lines above is:
x = size(data,2)-cumsum(data,2)+1;
x = x(:,end);

which finds the place of shifting between 0 to 1 for every row (assuming there is only one in a row).
Then, within the plot I shift y by half of the distance between two adjacent y-axis tick, so they will be placed at the center of the edge.

EDIT:
After some trials with this kind of data, I have got this result:
imagesc(data);
axis ij
b = bwboundaries(data.','noholes');
x = b{1}(:,1);
y = b{1}(:,2);
X = reshape(bsxfun(@plus,x,[0 -0.5 0.5]),[],1);
Y = reshape(bsxfun(@plus,y,[0 0.5 -0.5]),[],1);
k = boundary(X,Y,1);
hold on
plot(X(k),Y(k),'g','LineWidth',3,'Marker','o',...
    'MarkerFaceColor','r','MarkerEdgeColor','none')

It's not perfect, but may get you closer to what you want in a more simple approach:

A: OK, I think I've solved it... well close enough to be happy.
First I take the original data (which I call mask_rho and use this to make masks mask_u, mask_v, which is similar to mask_rho but is shifted slightly in the horizontal and vertical directions, respectively.
%make mask_u and mask_v
for i = 2:size(mask_rho,2)
for j = 1:size(mask_rho,1)
    mask_u(j, i-1) = mask_rho(j, i) * mask_rho(j, i-1);
end
end
for i = 1:size(mask_rho,2)
for j = 2:size(mask_rho,1)
    mask_v(j-1, i) = mask_rho(j, i) * mask_rho(j-1, i);
end
end

I then make modified masks mask_u1 and mask_v1 which are the same as mask_rho but averaged with the neighbouring points in the horizontal and vertical directions, respectively.
%make mask which is shifted E/W (u) and N/S (v)
mask_u1 = (mask_rho(1:end-1,:)+mask_rho(2:end,:))/2;
mask_v1 = (mask_rho(:,1:end-1)+mask_rho(:,2:end))/2;

Then I use the difference between the masks to locate places where the masks change from 0 to 1 and 1 to 0 in the horizontal direction (in the u mask) and in the vertical direction (in the v mask).
% mask_u-mask_u1 gives the NEXT row with a change from 0-1.
diff_mask_u=logical(mask_u-mask_u1);
lon_u_bnds=lon_u.*double(diff_mask_u);
lon_u_bnds(lon_u_bnds==0)=NaN;
lat_u_bnds=lat_u.*double(diff_mask_u);
lat_u_bnds(lat_u_bnds==0)=NaN;
lon_u_bnds(isnan(lon_u_bnds))=[];
lat_u_bnds(isnan(lat_u_bnds))=[];
%now same for changes in mask_v
diff_mask_v=logical(mask_v-mask_v1);
lon_v_bnds=lon_v.*double(diff_mask_v);
lon_v_bnds(lon_v_bnds==0)=NaN;
lat_v_bnds=lat_v.*double(diff_mask_v);
lat_v_bnds(lat_v_bnds==0)=NaN;
lon_v_bnds(isnan(lon_v_bnds))=[];
lat_v_bnds(isnan(lat_v_bnds))=[];
bnd_coords_cat = [lon_u_bnds,lon_v_bnds;lat_u_bnds,lat_v_bnds]'; %make into 2 cols, many rows

And the result grabs all the coordinates at the edges of the boundary:

Now my answer goes a bit awry. If I plot the above vector as points plot(bnd_coords_cat(:,1),bnd_coords_cat(:,2),'kx' I get the above image, which is fine. However, if I join the line, as in: plot(bnd_coords_cat(:,1),bnd_coords_cat(:,2),'-' then the line jumps around, as the points aren't sorted. When I do the sort (using sort and pdist2) to sort by closest points, Matlab sometimes chooses odd points... nevertheless I figured I'd include this code as an appendix, and optional extra. Someone may know a better way to sort the output vectorbnds_coords_cat:
% now attempt to sort
[~,I]=sort([lon_u_bnds,lon_v_bnds]);
bnd_coords_inc1 = bnd_coords_cat(I,1);
bnd_coords_inc2 = bnd_coords_cat(I,2);
bnd_coords = [bnd_coords_inc1,bnd_coords_inc2];
bnd_coords_dist = pdist2(bnd_coords,bnd_coords);
bnd_coords_sort = nan(1,size(bnd_coords,1));
bnd_coords_sort(1)=1;
for ii=2:size(bnd_coords,1)
 bnd_coords_dist(:,bnd_coords_sort(ii-1)) = Inf; %don't go backwards?
 [~,closest_idx] = min(bnd_coords_dist(bnd_coords_sort(ii-1),:));
 bnd_coords_sort(ii)=closest_idx;
end
bnd_coords_final(:,1)=bnd_coords(bnd_coords_sort,1);
bnd_coords_final(:,2)=bnd_coords(bnd_coords_sort,2);

Note that the pdist2 method was suggested by a colleague and also from this SO answer, Sort coordinates points in matlab. This is the final result:

To be honest, plotting without the line is fine. So as far as I'm concerned this is close enough to be answered!


text:
Q: How can I see the time taken to complete a method call? I want to do some research to improve my programmer skills by seeing see how long a method takes to finish.
But I don't want to write any code in the java files I am testing because I have a lot of methods to test (for some of the code I do not have permission to edit the code) so if possible I just want to "watch" the methods.
For example:
public void methodZero(){
  methodOne();
  methodTwo();
}

Should ideally print something like:
Time of methodZero = x. Time of methodOne = y. Time of methodTwo = z.

Question: Can I measure timing like this? Is there some additional info that would be important to me, like memory use?

A: Timing a method in isolation is usually completely meaningless, for a start you need statistical samples. If you want to get run times for a method you have to take a lot of things into consideration and give as much context to the target of your timing as possible.
For example, suppose your method has a return value, but you don't use it in any way in your benchmark - you are possibly going to encounter "dead-code elimination" by the JVM, which makes your timings meaningless. The JVM does many clever things like this (openjdk.net: Performance techniques used in the Hotspot JVM), all of which confuse and complicate taking meaningful timings.
A good library to use to help you do this (that also has good documentation and tutorials) is JMH.
Just as important as actual timings, but often related to taking meaningful timings, is measuring algorithm space and time complexity. This allows you to understand how your algorithm will grow as the input dataset changes in size. For example MethodA might be faster on a small input array and impractically slow on an input array 100x bigger, whereas MethodB may take the same time regardless of array size.
If you want to find out where in a program you should start looking to improve performance you can use a profiler (e.g. eclipse.org: An introduction to profiling Java applications). This will help you identify things such as: high memory usage, high GC usage, total method time (e.g. low method call count but high execution time, or high call count and small but significant execution time). However profilers will impact on your program's execution time as well.
TL;DR: profiling and performance testing is hard. Often you aren't really measuring what you think you are measuring.

A: long startTime = System.nanoTime();
methodOne();
long endTime = System.nanoTime();
long duration = (endTime - startTime);

You as a programmer should be more interested in complexity (Usually Time Complexity, but sometimes you should also worry about Space Complexity) of your algorithm rather than actual time taken to execute the program.
Have a read here about analysing algorithm complexity


text:
Q: Как сделать выемку в меню под логотип? Как можно сделать прозрачным участок меню вокруг логотипа.

Думала как-то clip-path применить, но что-то не то получается. Была бы фоновая картинка однотонной, нарисовала бы просто обводку в PhotoShop, но фон фоткой идет, так что обводка будет некрасиво выделяться.
Подскажите решение, пожалуйста! C помощью CSS или svg, или еще как-нибудь.

A: Руки оторвать этому вашему 'Дизайнеру'
Второй вариант : https://codepen.io/topicstarter/pen/KRjLbK

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" id="svg8" viewBox="0 0 2561 237">
  <g id="layer1" transform="translate(2264 -91)">
    <g id="g1068">
      <path id="path819" stroke-width=".26499999" d="M298 91L-2 328"/>
      <path id="path827" fill="none" stroke-width=".26458332px" d="M38 110a401 401 0 0 1 5 1 49031 49031 0 0 1 4 1h1a33 33 0 0 1 2 0 400 400 0 0 1 5 1 127 127 0 0 1 2 0h1v1a32 32 0 0 1 2 0 3999 3999 0 0 1 7 2 1623 1623 0 0 1 9 2 403 403 0 0 1 3 1 1712 1712 0 0 1 5 2 127 127 0 0 1 3 0 567 567 0 0 1 5 1 566 566 0 0 1 5 1l1 1h2l1 1a794 794 0 0 1 6 0 3980 3980 0 0 1 8 2 1619 1619 0 0 1 9 1h1a33 33 0 0 1 3 0 400 400 0 0 1 5 1 840 840 0 0 1 8 1v1h2a571 571 0 0 1 4 0 404 404 0 0 1 3 1 508 508 0 0 1 7 0 404 404 0 0 1 4 1 1677 1677 0 0 1 5 1 794 794 0 0 1 6 0 403 403 0 0 1 3 1 572 572 0 0 1 5 1 403 403 0 0 1 5 1 568 568 0 0 1 5 1 1874 1874 0 0 1 7 2l5 2a400 400 0 0 1 3 1 24352 24352 0 0 1 2 0 286 286 0 0 1 5 0l1 1 1 1h2a401 401 0 0 1 3 1 118 118 0 0 1 3 0l1 2h2a404 404 0 0 1 3 1 3364 3364 0 0 1 19 2l1 1h2a569 569 0 0 1 9 0 508 508 0 0 1 7 0l-1 1h-3a508 508 0 0 0-9 0h-1a570 570 0 0 0-4-1l-1-1h-2a1143 1143 0 0 0-8 0l-3-1a3366 3366 0 0 0-7-1h-1a404 404 0 0 0-3-1l-2-1h-2l-1-1a402 402 0 0 0-4-1l-1-1h-1a272 272 0 0 0-6 0l-1-1h-2l-1-1a2766 2766 0 0 0-6-1l-2-1a1866 1866 0 0 0-6-2h-1-2l-4-1-1-1h-3a567 567 0 0 0-4-1 402 402 0 0 0-3 0h-7a1687 1687 0 0 0-3-2h-1-1a402 402 0 0 0-2-1h-7-1a404 404 0 0 0-3 0 566 566 0 0 0-4-1v-1h-2-1-2a841 841 0 0 0-7-1 402 402 0 0 0-3 0h-1l-1-1h-5a1618 1618 0 0 0-7-1l-5-2h-6l-1-1h-2l-1-1h-3a567 567 0 0 0-4 0h-1a568 568 0 0 0-4-1h-1v-1h-1-2a1686 1686 0 0 0-3-2 402 402 0 0 0-3 0h-2-1a404 404 0 0 0-7-3 3984 3984 0 0 0-6-2h-1-1v-1h-6a400 400 0 0 0-3 0 48763 48763 0 0 1-2-1h-2l-1-1h-1-2-1l-1-1z" color="#000" font-family="sans-serif" font-weight="400" overflow="visible" white-space="normal"/>
      <g id="g1043" fill="red" stroke-width=".26458332px" transform="matrix(5.00277 0 0 4.85417 9980 -371)">
        <path id="path1011" d="M-2398 140l10-6c11-4 24-6 28 4l2 6h-7c-2-12-13-12-22-9l-11 5"/>
        <path id="path1020" d="M-2404 141l-4-4c1-3 11-7 11-7 13-5 34-11 38 7-4-11-16-13-43 3"/>
      </g>
      <g id="g1059" transform="translate(-4 425)">
        <path id="path1029" fill="red" stroke-width="1.44479847px" d="M-325-117l626 1-1-213-2559 3v211l104 1 52-1c102-93 250-157 327-1h48l1403-1"/>
      </g>
    </g>
  </g>
</svg>


text:
Q: Stored Procedure Not working as Expected When I create the stored procedure without parameter it works as expected, but when I create it with parameter  it doesn't return any row.
DELIMITER //

CREATE PROCEDURE search()
BEGIN
SELECT * FROM locality WHERE (LOWER( REPLACE(  `locality_area` ,  ' ',  '' ) ) REGEXP ('^.* GS Road.*$')) UNION ALL SELECT * FROM locality WHERE (`locality_area` REGEXP ('^.* GS Road.*$'));

END//

The above procedure returns the rows.
But this doesn't return any value
DELIMITER //

CREATE PROCEDURE search(IN **qry** varchar(100))
BEGIN
SELECT * FROM locality WHERE (LOWER( REPLACE(  `locality_area` ,  ' ',  '' ) ) REGEXP ('^.* ***qry**.*$')) UNION ALL SELECT * FROM locality WHERE (`locality_area` REGEXP ('^.* ***qry**.*$'));

END//

A: That's because you're looking for the string 'qry' instead of the value held by the parameter qry.
Replace:
REGEXP ('^.* qry.$'))

With
REGEXP CONCAT('^.* ',qry, '.$'))


text:
Q: Unity code works in the editor but does not work on Build (EXE File) C# My code load external images and build from them a SkyBox for unity3d.
All the files of the SkyBox are on the right paths (Copied manually).
The code loads 6 external images and then builds a SkyBox And I think there's a problem in the loading when it's in build stat. (But not sure)
Or maybe Unity prevents me from doing it?
And i have no error or warning code. It really drives me crazy!!!
using System.IO;
using UnityEngine;

public class ChangeSkyBox : MonoBehaviour
{

public static Texture2D LoadPNG(string filePath)
{

    Texture2D tex = null;
    byte[] fileData;

    if (File.Exists(filePath))
    {
        fileData = File.ReadAllBytes(filePath);
        tex = new Texture2D(1024, 1024);
        tex.LoadImage(fileData);
    }
    tex.wrapMode = TextureWrapMode.Clamp;
    return tex;
}

public static Material CreateSkyboxMaterial(SkyboxManifest manifest)
{
    Material result = new Material(Shader.Find("RenderFX/Skybox"));
    result.SetTexture("_FrontTex", manifest.textures[0]);
    result.SetTexture("_BackTex", manifest.textures[1]);
    result.SetTexture("_LeftTex", manifest.textures[2]);
    result.SetTexture("_RightTex", manifest.textures[3]);
    result.SetTexture("_UpTex", manifest.textures[4]);
    result.SetTexture("_DownTex", manifest.textures[5]);

    return result;
}

private Texture2D[] textures;

private void Start()
{

    Texture2D xt1 = LoadPNG(Directory.GetCurrentDirectory() + "\\Assets\\SkyBox\\Front.png");
    Texture2D xt2 = LoadPNG(Directory.GetCurrentDirectory() + "\\Assets\\SkyBox\\Back.png");
    Texture2D xt3 = LoadPNG(Directory.GetCurrentDirectory() + "\\Assets\\SkyBox\\Left.png");
    Texture2D xt4 = LoadPNG(Directory.GetCurrentDirectory() + "\\Assets\\SkyBox\\Right.png");
    Texture2D xt5 = LoadPNG(Directory.GetCurrentDirectory() + "\\Assets\\SkyBox\\Top.png");
    Texture2D xt6 = LoadPNG(Directory.GetCurrentDirectory() + "\\Assets\\SkyBox\\Bottom.png");
    SkyboxManifest manifest = new SkyboxManifest(xt1, xt2, xt3, xt4, xt5, xt6);

    Material newMat = new Material(Shader.Find("RenderFX/Skybox"));
    newMat = CreateSkyboxMaterial(manifest);

    RenderSettings.skybox = newMat;

    DynamicGI.UpdateEnvironment();
}

}

public struct SkyboxManifest
{
    public Texture2D[] textures;

    public SkyboxManifest(Texture2D front, Texture2D back, Texture2D left, Texture2D right, Texture2D up, Texture2D down)
    {
        textures = new Texture2D[6]
        {
             front,
             back,
             left,
             right,
             up,
             down
        };
    }

}

A: I believe your problem lies on this Line.
 Material result = new Material(Shader.Find("RenderFX/Skybox"));

Unity cannot find it at runtime. To fix it, make the "base" Material by hand in Unity and attach it to your script throurgh the Inspector.


text:
Q: Configuration Error: Unable to run scripts on mobile Device Mobile device chrome browser is starting and closing, url is not getting fetched in the browser.
Eclipse: oxygen 1.0
Samsung S5
Appium version: 1.4.16
Browser : Chrome.
I am trying the hit the url "us.justdial.com" in the mobile browser. Devices browser is starting & closing consecutive 4 times and then scripts get failed.
Below is an error report:
[RemoteTestNG] detected TestNG version 6.13.1
FAILED: Appium_device1
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: A new session could not be created. (Original error: session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"15216.1","isDefault":true},"id":1,"name":"","origin":"://"}
  (Session info: chrome=55.0.2883.91)
  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86))) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 30.09 seconds
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: 'MUM-SOFT-VAIBHA', ip: '172.29.5.188', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_144'
Driver info: driver.version: AndroidDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
    at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
    at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
    at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:89)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
    at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:38)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:83)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:93)
    at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:72)
    at Appium_device.Appium_device1(Appium_device.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:571)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:707)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:979)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.privateRun(TestRunner.java:648)
    at org.testng.TestRunner.run(TestRunner.java:505)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
    at org.testng.SuiteRunner.run(SuiteRunner.java:364)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1116)
    at org.testng.TestNG.runSuites(TestNG.java:1028)
    at org.testng.TestNG.run(TestNG.java:996)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

===============================================
    Default test
    Tests run: 1, Failures: 1, Skips: 0
===============================================

===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0

Test Scripts are as follows:
import java.net.MalformedURLException;
import java.net.URL;
//import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
//import org.openqa.selenium.remote.RemoteWebDriver;
//import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import io.appium.java_client.android.AndroidDriver;

public class Appium_device {
    @Test
    public void Appium_device1() throws MalformedURLException, InterruptedException {
    //APPLICATION_LOG.info("Initializing project properties");
    DesiredCapabilities capabilities = new DesiredCapabilities();

      // Set android deviceName desired capability. Set your device name.
    //  capabilities.setCapability("deviceName", "5203a1bbea4a8385");
    //  capabilities.setCapability("deviceName", "4100df0accbd9f00");
    //   capabilities.setCapability("deviceName", "0123456789ABCDEF");
      capabilities.setCapability("deviceName", "4d007af54ac04177");

      // Set BROWSER_NAME desired capability. It's Android in our case here.
      capabilities.setCapability(CapabilityType.BROWSER_NAME, "Chrome");
    // capabilities.setCapability("browsername", "chrome");

      // Set android VERSION desired capability. Set your mobile device's OS version.
    //  capabilities.setCapability(CapabilityType.VERSION, "4.2.2");
    // capabilities.setCapability(CapabilityType.VERSION, "6.0.1");
    capabilities.setCapability(CapabilityType.VERSION, "6.0.1");

      // Set android platformName desired capability. It's Android in our case here.
      capabilities.setCapability("platformName", "Android");

      // Set android appPackage desired capability. It is
      // com.android.calculator2 for calculator application.
      // Set your application's appPackage if you are using any other app.
    // capabilities.setCapability("appPackage", "org.mozilla.firefox");
      capabilities.setCapability("appPackage", "com.android.chrome");

      // Set android appActivity desired capability. It is
      // com.android.calculator2.Calculator for calculator application.
      // Set your application's appPackage if you are using any other app.
      capabilities.setCapability("appActivity", "com.google.android.apps.chrome.Main");

      // Created object of RemoteWebDriver will all set capabilities.
      // Set appium server address and port number in URL string.
      // It will launch calculator app in android device.
    //   webdriver.Chrome(executable_path='C:\Users\Ganeshkumarg\Downloads\chromedriver_win32\chromedriver.exe');
     URL url = new URL("http://127.0.0.1:4723/wd/hub");
     // webDriver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

      WebDriver driver = new AndroidDriver (url, capabilities);
      Thread.sleep(10000);
      driver.get("us.justdial.com");
        Thread.sleep(5000);
        System.out.println("Site hit");
        //exclewrtdt.writeData("Launched justdial website", "true");
        Thread.sleep(3000);
    }
}

Refer screenshot for Appium logs.
Request you to please look into same.

A: Several things you need to be fixed:

*

*Update appium server to 1.7.x, 1.4.16 is too old and might not work properly on devices with Android 6+ : npm -g update appium

*Use correct capabilities:
{
  "platformName": "Android",
  "deviceName": "device",
  "browserName": "Chrome"
}

*Initialise driver correctly:
AppiumDriver driver = new AndroidDriver(
    new URL("http://127.0.0.1:4723/wd/hub"),
    capabilities
 );

A: Thanks a ton for all the suggestions and answers, finally, I have updated my appium and  used @dmle
method
"AppiumDriver driver = new AndroidDriver(
    new URL("http://127.0.0.1:4723/wd/hub"),
    capabilities
 );"

Same worked.
Thanks

A: change this line of code
    URL url = new URL("http://127.0.0.1:4723/wd/hub");
 WebDriver driver = new AndroidDriver (url, capabilities);

To :-
  WebDriver driver;
 driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

A: Where are you using 'AppiumDriver'?  Use as follows
 AppiumDriver driver = new AndroidDriver(new URL(appiumHost + ":" + appiumPort + "/wd/hub"), capabilities);


text:
Q: GC selection for Java/Netty file upload REST service I have a Java REST service which runs on Netty and is used for uploading(streaming) large number of files of 5MB to 500MB. When I'm increasing the number of concurrent uploads at some point the application goes out of memory, which is expected, but I'm looking for recommendations on which Java GC and VM settings should I use in this scenario to improve the performance and to reduce the memory footprint.
I would really appreciate if somebody could share similar experiences.
UPDATE: To add more context to the question, the REST service is getting file as a stream and passing the same stream to Amazon S3.

A: Likely you should use a flow control when sending large data amount. You can check if the channel is writable (Channel.isWritable()) before sending data and wait untill it will be ready. You can use notifications via ChannelInboundHandler.channelWritabilityChanged(ChannelHandlerContext ctx) to track this. Without flow control all your large files will consume memory waiting for sending in Netty's output buffer.


text:
Q: Why are query strings ignored depending on my router order? As a lot of people here, I'm trying to learn programming by myself. I have just started learning Express and API building and I can't seem to find why the following happens when setting my routes. For example, if I have:

import express from "express"

import cors from 'cors'

import { users, posts } from "./variables"

const app = express()

app.use(express.json())

app.use(cors())

app.listen(3003, () => {
    console.log("Server running at http://localhost:3003");
});

app.get("/posts", (req, res) => {
    res.send(posts)
})

app.get("/posts", (req, res) => {
    let userId = Number(req.query.userId)
    let arrayPosts = posts.filter((post) => post.userId === userId)
    res.send(arrayPosts)
})

Where my variables are:
import { User, Post } from "./types"

export let users : User[] = [
    {id : 1, name: "Test 1"},
    {id : 2, name: "Test 2"},
]

export let posts : Post[] = [
    {id : 1, title : "Bla bla", body : "Bla bla bla bla", userId: 1},
    {id : 2, title : "Ble ble", body : "Ble ble ble ble", userId: 2},
]

And I hit the endpoint http://localhost:3003/posts?userId=1, I get all posts. However, as soon as I change orders:
app.get("/posts", (req, res) => {
    let userId = Number(req.query.userId)
    let arrayPosts = posts.filter((post) => post.userId === userId)
    res.send(arrayPosts)
})

app.get("/posts", (req, res) => {
    res.send(posts)
})

It works as expected. Is that how is it supposed to be? If positive, why? It doesn't seem intuitive tbh.
Edit:
So the first two comments made me realize I should just

    app.get("/posts", (req, res) => {
        let userId = req.query.userId ? Number(req.query.userId) : 0
        if (userId) {
            let arrayPosts = posts.filter((post) => post.userId === userId)
            res.send(arrayPosts)
        } else {
            res.send(posts)
        }
    })


text:
Q: Kendo UI Grid + AngularJS: problems with $scope variable as Datasource i've tried several tips and tricks from nearly any thread regarding my problem - i can't get it done.
i want to replace a trNgGrid with the Kendo UI Grid. trNgGrid seems to work a bit different. it gets it's data from a $scope variable that i called $scope.items. the grid calls a function whenever it needs to refresh the data (filter, paging, sorting events...). inside that function i call my sharepoint service to get the items and after that overwrite the $scope.items with new data from the sharepoint list.
var getItemsFromSPService = function () {
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () {
        SPService.loadItems($scope.gridParams).then(function (result) {
            $scope.items = result.items;
        });
    });
};

the grid refreshes. sadly, there is no rest/soap webservice i could consume - i use standard sharepoint client context methods to get the data. because of that sharepoint SP.SOD.stuff, i also haven't found a solution to return items from my function. i'm just able to populate a variable with data or call another function and send that data to it. that's all async of course.
i tried to set $scope.items as datasource in the Kendo UI Grid directive - it does not refresh when the variable gets updated. i tried $scope.grid.refresh - nothing. i tried observable arrays from Kendo - no luck.
i think there might be a way using the grid options:
dataSource: {
        serverFiltering: true,
        transport: {
        read: function(options) {
            options.success(....

but i can't figure that out.

*

*so i can refresh the $scope.items with new data or my function can call any other function and include the data as parameter - the grid needs to refresh, too. how can i tell it "hey, the $scope.items got updated - show it!"?

*i need support for IE8

*i need server side sorting, filtering, paging - grid needs to trigger events so that my function can refresh the data

is there any solution for that? it's crazy, that something so "trivial" seems to be so tricky :O
thank you very much!

A: In my app, when I want refresh a grid i use
$scope.gridName.dataSource.read();

But you need implementing your logic in function read. Like you show in your example.
For instance, the function that create grid could be something like this
$scope.createGrid = function () {
   $scope.kendoGridOpMantOptions = {
      dataSource: {
         schema: {
            // your schema...
         },
         transport: {
             read: function (e) {
                  // call to service that return data
             }
         }
      }
      // More grid configuration
   }
}

If you have defined a function to read data in grid you can refresh your grid with $scope.gridName.dataSource.read();
With regard to IE8, I am not sure. I am reading a lot of problems with IE about this issue.
Good luck!


text:
Q: CSS: aligning two divs to the bottom of the page on the right side with position: absolute I am trying to make a simple chatbox with a header in css, I am trying to align the chat to the bottom of the page, and to the right of the page. I have tried using
float: right;
bottom: 0;
position: absolute;

It aligns it to the bottom of the page but not to the right. Here is my full code
CSS
#chatbox {
    height: 360px;
    width: 320px;
    border-left: 1px solid #000;
    border-right: 1px solid #000;
    border-bottom: 1px solid #000;
    float: right;
    bottom: 0;
    position: absolute;
}
.chatheader {
    font-family:'PT Sans';
    background: #999;
    width: 322px;
    height: 36px;
    color: #fff;
    text-align: center;
    padding-top: 15px;
}

HTML

chatboxheader

Here is a demo of the code DEMO
This is just a very simple script because I am trying to get it aligned first, later On I will make it look better. Thanks in advance to anyone who can help me!

A: Since you want both chatheader and chatbox on the bottom right of the page. I have modified code little bit. I have wrapped both of them in a div.
HTML:

chatboxheader

CSS:
#chat-container {
    right :0;
    bottom: 0;
    position: absolute;
}

right:0 will keep the element on extreme right.
Updated fiddle here.

A: DEMO
HTML
#chatbox {
    height: 360px;
    width: 320px;
    border-left: 1px solid #000;
    border-right: 1px solid #000;
    border-bottom: 1px solid #000;
}
.chatheader {
    font-family:'PT Sans';
    background: #999;
    width: 322px;
    height: 36px;
    color: #fff;
    text-align: center;
    padding-top: 15px;
    float:right;
}
.chatMain {
    position:absolute;
    bottom:0;
    right:0;
}


text:
Q: getElementById seems to fail within forms I have been having problems with getting getElementById working on a specific webpage.  So, I've cut it down the following minimal code.  In this code, first alert() is displayed, but the second one is not, and about the only thing I can guess why is getElementById() is failing.  Any ideas?

<!doctype html>

        <meta charset="utf-8">
        <title>Test</title>

            <form onsubmit="Process(getElementById('YourName').value);return false;">
                Your name
                <input type="text" maxlength="50" name="YourName" id="YourName">

                <input type="submit" value="Do it" />
            </form>

A: Document.getElementById fails because getElementById is a property of the document object not the Document object. JS is case-sensitive.
getElementById('YourName') fails because getElementById is a property of the document object and is not a global.


text:
Q: What are the types of classes/instances I can inject a CDI event into? I want to have a class that can fire an event. Ideally, I'd like to have it in a POJO (dealing with legacy code that's in POJOs) but I know that's not possible. So instead, I'd like to have something that the POJOs can call which can fire the event.
NOTE: I'm on Tomcat with CDI, JPA also installed (It is not an option to switch to a full EE server on this project)
I'm not sure if it should be a singleton/app-wide-singleton, or should be per request (or even session). So my questions are:

*

*What can an event be injected into? (e.g. @WebListener, @Singleton, RequestScoped, @Stateless)

*Which one makes the most sense for this use case?

*how would a POJO get access to that class/instance (the POJO is called from a servlet)?
Sample Code:
//Is this correct?
@WebListener
public class EventHandler
{
    @Inject
    @MyEventQualifier
    private Event<MyEvent> myEvent;

    public void fireEvent(MyEvent anEvent)
    {
        myEvent.fireAsync( anEvent );
    }
}

A: The fundamental container classes are your standard "managed" objects, like the one you listed (WebListeners, Filters, Servlets). These act as the root of the context chain. Since those are managed by CDI, anything that they Inject are also managed, and on down that line.
If your Servlet (for example) injects PojoX, PojoX can inject PojoY, and on and on. The game is to avoid new and use CDI constructs instead to create your POJOs.
As for hurdling the legacy POJO/CDI divide, you could do a couple of things.
You could inject an instance of EventHandler in to the Servlet, and then pass that instance in to the POJO as a parameter.
You can stick that instance in to the request as an attribute, or shove the instance in to the ServletContext when the Servlet is first created.
You can make EventHandler an @Singleton and in its @PostConstruct set a static variable that can be returned via a standard, static getInstance call.
You can have your POJO call the container directly to do the lookup (or call a utility function).
And, of course, if the POJO can be injected itself, just do it that way.
Addenda for the comment:
You can simply inject the POJO, if that's appropriate for you work.
Here's an example:
@WebServlet(name = "NewServlet", urlPatterns = {"/NewServlet"})
public class NewServlet extends HttpServlet {

    @Inject
    Instance<Pojo> pojoInstance;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Pojo pojo = pojoInstance.get();
        String world = pojo.getWorld();

        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
            out.println("<!DOCTYPE html>");
            out.println("");
            out.println("");
            out.println("<title>Servlet NewServlet</title>");
            out.println("");
            out.println("");
            out.println("
Servlet NewServlet at " + request.getContextPath() + "
");
            out.println("
Hello " + world);
            out.println("");
            out.println("");
        }
    }
}

public class Pojo {

    @Inject
    Event<PojoEvent> pojoEventHdlr;

    @PostConstruct
    public void postConstruct() {
        System.out.println("Look, another Pojo!");
    }

    public String getWorld() {
        PojoEvent pe = new PojoEvent("World event pojo fired");
        pojoEventHdlr.fire(pe);

        return "world";
    }
}

public class PojoEvent {

    String msg;

    public PojoEvent() {
    }

    public PojoEvent(String msg) {
        this.msg = msg;
    }

    public String toString() {
        return "PojoEvent with msg: " + msg;
    }
}

@Singleton
public class SingletonPojo {

    public void pojoEventObserver(@Observes PojoEvent pe) {
        System.out.println("We got a PojoEvent " + pe);
    }
}

The important thing to note, is that I injected an Instance<Pojo> in to the servlet, and then used Instance.get on it, rather than just the Pojo directly. The reason for that is Servlet are nominally Singletons within the web app, so if you injected an actual Pojo, all of your requests would use the exact same instance of the Pojo (unlikely what you want).
You can see the Pojo fires the event, and I have a @Singleton class observing the event and dumping out the message.
If you're willing to make changes to you legacy code, you can do what you like and there's no real need to jump through hoops to bridge the CDI <-> legacy divide. Just roll them in to CDI as necessary.


text:
Q: Ofbiz: Error on Set OFBIZ_HOME I'm trying to compile the ofbiz in my local machine. I'm getting the follow error:

Any idea the source of the problem?

A: Setting OFBIZ_HOME works without an error. The problem occurs, as the following stacktrace shows, during the OFBiz start sequence. The specified port is already in use.
It is very likely that you already have started OFBiz before so that the port is occupied by this instance. Close all running OFBiz instances and the errors should be gone.


text:
Q: Replacement for name locator strategy in Appium version >= 1.5.0 I am writing Mobile App automation test cases for Android/iOS using java and appium.
I have upgraded my appium version from 1.4.16 to 1.5.3. Now I am not able use name locator.
name Locator:-
By.name("name here")

Remove long-deprecated name locator strategy in Appium v1.5
I have tried findElementByAccessibilityId locator. But this doesn't help me.
driver.findElementByAccessibilityId("name");

FYI I don't have specific id or class to use it. What is the replacement for name locator ?

A: Using wildcards with xpath's can be very slow as it will scan the entire tree. It's also prone to returning the incorrect element if there are more than 1 item with the same name. Use precise locators wherever possible. Example: By.xpath("//UIAButton[@name='foo']")

A: If accessibilityID isn't getting you there, have you tried using xpath with something like the below?
By.xpath("//*[@name='enter name here']")


text:
Q: angular-js filter to find an empty string I'd like to use the filters to return all values that have an empty string for a particular field.
That is, in the code:
var groups = $filter('unique')(addresses, 'country');
var groupedByCountry = [];

angular.forEach(groups, function (value, key) {
   var selectedGroup = value['country'];
   var grouped = $filter('filter')(addresses, { country: selectedGroup });
   this.push(grouped);
}, groupedByCountry);

As can be seen in http://jsfiddle.net/b7cjM/, it creates groups as expected where a country is specified, but I'd like the last group to contain only the addresses that have no country specified (instead of, as currently, a group of all addresses in existence).
Is this possible using angularjs?
**
As suggested by punund, I wrote a 'groupBy' filter [a naive conversion of the 'unique' filter: http://jsfiddle.net/b7cjM/1 ], which is a much simpler solution to my problem than the one I was attempting. I suspect a custom 'filterByEmpty' of this type is also the solution for the problem as presented.

A: underscore or lodash may work better for you:
groupedBy = _.groupBy($scope.addresses, 'country');

Empty strings are properly taken into account, and you don't need the second filter.  Another option would be to implement a kind of "groupBy" angular filter yourself.


text:
Q: Determine a closed form for this sequence Every year, 38 % of the amount of fish in a pond die. The 1st of May 2011 there were 5200 fish in the pond. Every year after May 1st 2011, 1900 new fish are added to the pond.
Let $a_n$ be the amount of fish in the pond (directly after new fish have been added) $n$ years after May 1st 2011.
Determine a closed form for this sequence.
How to solve this problem?
My attempt is: $a_n = 5200 - 0,38a_n + 1900n \Rightarrow 1,38a_n = 5200 + 1900n \Rightarrow a_n = \frac{5200 + 1900n}{1,38}$

A: Here's how I would start: $$\begin{align*}a_0 &= 5200 \\ a_1 &= 5200\cdot 0.62+1900 \\ a_2 &= (5200\cdot 0.62+1900)\cdot 0.62 +1900 = 5200\cdot 0.62^2+1900(1+0.62) \\ a_3 &= 5200\cdot 0.62^3+1900(1+0.62+0.62^2) \\ \vdots\end{align*}$$ Can you find a general $a_n$ from here? A fun bonus question is: If the process repeats indefinitely, how many fish will be left at the end?

A: hints
Looks like $a_{n+1} = (1-0.38) a_n + 1900 = 0.62 a_n + 1900$ with $a_0 = 5200$.
In general you should get $a_n = A 0.62^n + B + Cn$, note that
$5200 = a_0 = A + B$ and get other initial conditions and find B and C.

A: Nope, but it is a good start, $a_1=5200+1900$,$a_2=0.68^2\cdot 5200+1900\cdot 0.68+1900$,$a_3=0.68^3\cdot 5200+1900\cdot 0.68^2+1900\cdot 0.68+1900$, see the pattern?
$$a_n=5200\cdot 0.68^n+1900\cdot\frac{1-0.68^{n-1}}{0.32}$$


text:
Q: Is there a benefit from using a dock to charge wireless controllers I now have a PS4 with a wireless controller. Is there a compelling reason to use a charging station, other than aesthetics?

A: Some charging docks uses the EXT port rather than the micro USB. This saves wear and tear on the USB port and, according to several reviews, is faster.
You also have the advantage of not needing a USB cable, as well as saving energy by not needing to leave the PS4 on.