text:
Q: Melhor desempenho em um sistema em WPF Como deixar um sistema em alta performance?
Seguir um padrão de projetos MVVM?
Eu tenho o seguinte XAML, mas quando eu executo ele trava na hora de passar o foco para outros textBox. Por que?
O meu sistema fica muito lento, não estou entendendo o porque.
<UserControl x:Class="Curriculos_3_Camadas.View.EmpresaView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
         xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
         mc:Ignorable="d"
         Width="auto" Height="auto" Background="White" d:DesignWidth="1232.5" d:DesignHeight="853">
<Grid Margin="0,0,0,77">

    <!-- L I N H A    U M -->
    <TextBlock Text="Código:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="150,17,0,0"/>
    <TextBox Name="textEmpCodigo" VerticalAlignment="Top" HorizontalAlignment="Left" MinHeight="22" Height="15" Width="170" Margin="196,15,0,0"/>
    <TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="0" Text="F2" Margin="371,18,0,0" FontWeight="Bold" Foreground="Red"/>
    <TextBlock x:Name="labelUltimoCodigoEmpresa" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="0" Margin="390,18,0,0" Width="177"/>
    <CheckBox x:Name="cbEmpresaInativa" Content="Empresa Inativa" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="0" Margin="600,17,0,0" />

    <TextBlock Text="CNPJ / CPF:" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="0" Margin="130,43,0,0"/>
    <TextBox Name="textEmpCnpjCpf" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="0" MinHeight="22" Height="15" Width="170" Margin="196,40,0,0"/>
    <TextBlock Text="Data de Abertura:" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="0" Margin="390,43,0,0"/>
    <TextBlock x:Name="labelDataAbertura" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="0" Margin="489,43,0,0" Width="111"/>

    <TextBlock Text="Razão Social / Nome:" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="0" Margin="79,67,0,0"/>
    <TextBox Name="textEmpRSNome" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="0" MinHeight="22" Height="15" Width="560" Margin="196,65,0,0"/>

    <!-- L I N H A    D O I S -->
    <Rectangle VerticalAlignment="Top" HorizontalAlignment="Left" Width="1900" Height="25" Fill="#E8E8E8" Margin="0,115,-668,0"/>

    <TabControl Name="tabControl" Margin="150,115,0,38">

        <TabControl.Resources>
            <Style TargetType="TabItem">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="TabItem">
                            <Grid Name="Panel">
                                <Border
                             Name="Border"
                             BorderBrush="#A9A9A9"
                             BorderThickness="1,1,1,0"
                             CornerRadius="3,3,0,0"
                             MinWidth="120">
                                </Border>
                                <ContentPresenter
                                    VerticalAlignment="Center"
                                    HorizontalAlignment="Center"
                                    ContentSource="Header"
                                    Margin="10,2"/>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsSelected" Value="True">
                                    <Setter TargetName="Panel" Property="Background" Value="white" />
                                </Trigger>
                                <Trigger Property="IsSelected" Value="False">
                                    <Setter TargetName="Panel" Property="Background" Value="#E8E8E8" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </TabControl.Resources>

        <TabItem Name="tiDadosGeraisEmpresas" Header="Dados Gerais" FontSize="12" FontWeight="Bold" IsSelected="True" Margin="70,0,-80,-5" TabIndex="-67">
            <ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Margin="-72,0,2,-13">
                <Canvas Grid.Row="1" Height="655">

                    <TextBlock Text="Nome Fantasia:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="26" Canvas.Top="17"/>
                    <TextBox Name="textEmpNomeFantasia" VerticalAlignment="Top" HorizontalAlignment="Left" Width="290" MinHeight="22" Height="15" Canvas.Left="113" Canvas.Top="15"/>
                    <TextBlock Text="Contato:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="448" Canvas.Top="17"/>
                    <TextBox Name="textEmpContato" VerticalAlignment="Top" HorizontalAlignment="Left" Width="240" MinHeight="22" Height="15" Canvas.Left="498" Canvas.Top="15"/>
                    <TextBlock Text="Site:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="784" Canvas.Top="17"/>
                    <TextBox Name="textEmpSite" VerticalAlignment="Top" HorizontalAlignment="Left" Width="240" MinHeight="22" Height="15" Canvas.Left="811" Canvas.Top="15"/>

                    <TextBlock Text="CEP:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="85" Canvas.Top="43"/>
                    <TextBox Name="textEmpCep" VerticalAlignment="Top" HorizontalAlignment="Left" Width="160" MinHeight="22" Height="15" Canvas.Left="113" Canvas.Top="40"/>

                    <TextBlock Text="Código IBGE:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="329" Canvas.Top="43"/>
                    <TextBox Name="textEmpCodigoIbge" VerticalAlignment="Top" HorizontalAlignment="Left" Width="160" MinHeight="22" Height="15" Canvas.Left="403" Canvas.Top="40"/>
                    <TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Text="F2" FontWeight="Bold" Foreground="Red" Canvas.Left="568" Canvas.Top="43"/>
                    <TextBlock Text="Município:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="343" Canvas.Top="93"/>
                    <TextBox Name="textEmpMunicipio" VerticalAlignment="Top" HorizontalAlignment="Left" Width="210" MinHeight="22" Height="15" Canvas.Left="403" Canvas.Top="90"/>
                    <TextBlock Text="Bairro:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="75" Canvas.Top="93"/>
                    <TextBox Name="textEmpBairro" VerticalAlignment="Top" HorizontalAlignment="Left" Width="190" MinHeight="22" Height="15" Canvas.Left="113" Canvas.Top="90"/>
                    <TextBlock Text="Estado (UF):" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="628" Canvas.Top="93"/>
                    <TextBox Name="textEmpUf" VerticalAlignment="Top" HorizontalAlignment="Left" Width="50" MinHeight="22" Height="15" Canvas.Left="696" Canvas.Top="90"/>

                    <TextBlock Text="Tipo de Logradouro:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Top="68"/>
                    <TextBox Name="textEmpTipoLogradouro" VerticalAlignment="Top" HorizontalAlignment="Left" Width="160" MinHeight="22" Height="15" Canvas.Left="113" Canvas.Top="65"/>
                    <TextBlock Text="Logradouro:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="333" Canvas.Top="68"/>
                    <TextBox Name="textEmpLogradouro" VerticalAlignment="Top" HorizontalAlignment="Left" Width="210" MinHeight="22" Height="15" Canvas.Left="403" Canvas.Top="65"/>
                    <TextBlock Text="Número:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="644" Canvas.Top="68"/>
                    <TextBox Name="textEmpNumero" VerticalAlignment="Top" HorizontalAlignment="Left" Width="115" MinHeight="22" Height="15" Canvas.Left="696" Canvas.Top="65"/>
                    <TextBlock Text="Complemento:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="853" Canvas.Top="63"/>
                    <TextBox Name="textEmpComplemento" VerticalAlignment="Top" HorizontalAlignment="Left" Width="115" MinHeight="22" Height="15" Canvas.Left="936" Canvas.Top="60"/>

                    <TextBlock Text="Inscrição Estadual:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Top="118" Canvas.Left="12"/>
                    <TextBox Name="textEmpInscEst" VerticalAlignment="Top" HorizontalAlignment="Left" Width="190" MinHeight="22" Height="15" Canvas.Left="113" Canvas.Top="115"/>
                    <TextBlock Text="Cód. Serv.:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="393" Canvas.Top="118"/>
                    <TextBox Name="textEmpCodServ" VerticalAlignment="Top" HorizontalAlignment="Left" Width="160" MinHeight="22" Height="15" Canvas.Left="453" Canvas.Top="115"/>
                    <TextBlock Text="Cód. Ativ.:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="638" Canvas.Top="118"/>
                    <TextBox Name="textEmpCodAtiv" VerticalAlignment="Top" HorizontalAlignment="Left" Width="355" MinHeight="22" Height="15" Canvas.Left="696" Canvas.Top="115"/>

                    <TextBlock Text="Inscrição Municipal:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Top="143" Canvas.Left="4"/>
                    <TextBox Name="textEmpInscMun" VerticalAlignment="Top" HorizontalAlignment="Left" Width="190" MinHeight="22" Height="15" Canvas.Left="113" Canvas.Top="140"/>
                    <TextBlock Text="Regime Trib.:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="379" Canvas.Top="143"/>
                    <TextBox Name="textEmpRegTrib" VerticalAlignment="Top" HorizontalAlignment="Left" Width="598" MinHeight="22" Height="15" Canvas.Left="453" Canvas.Top="140"/>

                    <TextBlock Text="RNTRC:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Top="168" Canvas.Left="68"/>
                    <TextBox Name="textEmpRntrc" VerticalAlignment="Top" HorizontalAlignment="Left" Width="190" MinHeight="22" Height="15" Canvas.Left="113" Canvas.Top="165"/>
                    <TextBlock Text="Tipo de Empresa:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="357" Canvas.Top="168"/>
                    <TextBox Name="textEmpTipoEmpresa" VerticalAlignment="Top" HorizontalAlignment="Left" Width="598" MinHeight="22" Height="15" Canvas.Left="453" Canvas.Top="165"/>

                    <TextBlock Text="CNAE - Classificação Nacional de Atividades Econômicas" Canvas.Left="113" Canvas.Top="195"/>

                    <TextBlock Text="Código:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Top="219" Canvas.Left="68"/>
                    <TextBox Name="textEmpCodigoCnae" VerticalAlignment="Top" HorizontalAlignment="Left" Width="100" MinHeight="22" Height="15" Canvas.Left="113" Canvas.Top="216"/>
                    <TextBlock Text="Descrição:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="243" Canvas.Top="219"/>
                    <TextBox Name="textEmpDescCnae" VerticalAlignment="Top" HorizontalAlignment="Left" Width="644" MinHeight="22" Height="15" Canvas.Left="302" Canvas.Top="216" FontWeight="Normal"/>
                    <Button Name="btnAdicionarCnae" Content="Adicionar" Width="100" Canvas.Left="951" Canvas.Top="214" FontWeight="Bold" TabIndex="-76"/>
                    <DataGrid Name="dataGridCnae" Height="100" Canvas.Left="113" Canvas.Top="243" Width="938" FontWeight="Normal" IsReadOnly="True"
                              AutoGenerateColumns="False" GridLinesVisibility="All">

                        <DataGrid.Columns>
                            <DataGridTextColumn Binding="{Binding Path=codigo}" Header="Código" />
                            <DataGridTextColumn Binding="{Binding Path=descricao}" Header="Descrição" />
                        </DataGrid.Columns>

                    </DataGrid>

                    <TextBlock Text="Contatos" Canvas.Left="113" Canvas.Top="354"/>

                    <TextBlock Text="E-mail:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Top="378" Canvas.Left="68"/>
                    <TextBox Name="textEmpEmail" VerticalAlignment="Top" HorizontalAlignment="Left" Width="348" MinHeight="22" Height="15" Canvas.Left="114" Canvas.Top="375"/>
                    <TextBlock Text="Observações:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="485" Canvas.Top="378"/>
                    <TextBox Name="textEmpObs1" VerticalAlignment="Top" HorizontalAlignment="Left" Width="386" MinHeight="22" Height="15" Canvas.Left="560" Canvas.Top="375" FontWeight="Normal"/>
                    <Button Name="btnAdicionarEmails" Content="Adicionar" Width="100" Canvas.Left="951" Canvas.Top="372" FontWeight="Bold" TabIndex="-73"/>
                    <DataGrid Name="dataGridEmails" ItemsSource="{Binding}"
                              AutoGenerateColumns="False" HorizontalAlignment="Left" VerticalAlignment="Top" Height="100"
                              Canvas.Left="114" Canvas.Top="414" Width="937" FontWeight="Normal" IsReadOnly="True" GridLinesVisibility="All">

                        <DataGrid.Columns>
                            <DataGridTextColumn Binding="{Binding Path=email}" Header="E-mail (s)" />
                            <DataGridTextColumn Binding="{Binding Path=obs}" Header="Observação" />
                        </DataGrid.Columns>

                    </DataGrid>

                    <TextBlock Text="Prefixo (99):" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Top="520" Canvas.Left="46"/>
                    <TextBox Name="textEmpPrefixo" VerticalAlignment="Top" HorizontalAlignment="Left" Width="100" MinHeight="22" Height="15" Canvas.Left="113" Canvas.Top="517"/>
                    <TextBlock Text="Telefones:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="243" Canvas.Top="520"/>
                    <TextBox Name="textEmpTelefones" VerticalAlignment="Top" HorizontalAlignment="Left" Width="160" MinHeight="22" Height="15" Canvas.Left="302" Canvas.Top="517"/>
                    <TextBlock Text="Observações:" VerticalAlignment="Top" HorizontalAlignment="Left" FontWeight="Normal" Canvas.Left="485" Canvas.Top="520"/>
                    <TextBox Name="textEmpObs2" VerticalAlignment="Top" HorizontalAlignment="Left" Width="386" MinHeight="22" Height="15" Canvas.Left="560" Canvas.Top="517"/>
                    <Button Name="btnAdicionarTelefones" Content="Adicionar" Width="100" Canvas.Left="951" Canvas.Top="515" FontWeight="Bold" TabIndex="-69"/>

                    <DataGrid AutoGenerateColumns="False" HorizontalAlignment="Left" VerticalAlignment="Top"
                              ItemsSource="{Binding}" Name="dataGridTelefones" Height="100" Canvas.Left="114" Canvas.Top="557"
                              Width="937" FontWeight="Normal" GridLinesVisibility="All" IsReadOnly="True">

                        <DataGrid.Columns>
                            <!-- <DataGridTextColumn Binding="{Binding Path=id_empresa}" Header="Código" /> -->
                            <DataGridTextColumn Binding="{Binding Path=prefixo}" Header="Prefixo2" />
                            <DataGridTextColumn Binding="{Binding Path=telefone}" Header="Telefone2" />
                            <DataGridTextColumn Binding="{Binding Path=obs}" Header="Observação2" />
                        </DataGrid.Columns>

                    </DataGrid>

                </Canvas>
            </ScrollViewer>
        </TabItem>

    </TabControl>

    <WindowsFormsHost VerticalAlignment="Top" HorizontalAlignment="Left" Name="wfhSample" Grid.Row="0" Height="50" Width="186" Margin="862,10,0,0">
        <WindowsFormsHost.Child>
            <wf:PictureBox x:Name="picLetras"/>
        </WindowsFormsHost.Child>
    </WindowsFormsHost>
    <Image x:Name="imgCarregaCaptcha" HorizontalAlignment="Left" Height="16" Margin="1051,15,0,0" VerticalAlignment="Top" Width="17" />
    <TextBlock Name="labelCaptcha" Text="Digite os caracteres acima e pressione Enter:" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="0" Foreground="Red" Margin="862,65,0,0"/>
    <TextBox Name="textCaracteres" VerticalAlignment="Top" HorizontalAlignment="Left" MinHeight="22" Height="15" Width="260" Margin="862,86,0,0"/>

    <Rectangle Fill="#E8E8E8" Height="33" VerticalAlignment="Bottom" Width="auto" Margin="0,0,0,-2" />
    <Button x:Name="btnSalvarEmpresa" Content="Salvar (F9)" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="100" Margin="198,0,0,2"/>
</Grid>

A: A pergunta é um tanto ampla, não tem um problema específico mas vou tentar ajudar, ainda que de forma genérica.
O WPF realmente tem uma série de detalhes que se não forem observados gerará problemas de performance. O mecanismo é complexo e não é fácil entender todas implicações. Além disto os defaults não são ideias para gerar boa performance.
Eu não possuo conhecimento específico mas existe bastante material sobre o assunto, vou listar alguns. Você precisará ler todas, procurar novas fontes, estudar muito o assunto e perfilar bastante até chegar em um bom resultado.
A primeira coisa que precisa conhecer é a ferramenta de análise de performance do WPF. Outra ferramenta.
Esse artigo começa dar uma boa explicação sobre o problema.
Aqui tem dicas para melhorar a performance.
Outras maneiras que ajudam melhorar a performance.
Mais uma lista de dicas.
Considerações importantes de como melhorar a inicialização.
Um dos artigos que mais gosto sobre o assunto.
Mais um artigo interessante.
O fato de usar o MVVM não ajuda nada, pode até atrapalhar em alguns casos, mas nada significativo. Claro que se usar um padrão ruim ou fizer sem padrão algum pode atrapalhar.


text:
Q: Excessive thread count yields better results with file reading I have a hundred million files, my program reads all these files at every startup. I have been looking for ways to make this process faster. On the way, I've encountered something strange. My CPU has 4 physical cores, but reading this many files with even higher thread counts yields much better results. Which is interesting, given that opening threads more than the logical core count of the CPU should be somewhat pointless.
8     Threads: 29.858 s
16    Threads: 15.882 s
32    Threads: 9.989 s
64    Threads: 7.965 s
128   Threads: 8.275 s
256   Threads: 8.159 s
512   Threads: 8.098 s
1024  Threads: 8.253 s
4096  Threads: 8.744 s
16001 Threads: 10.033 s

Why this may occur ? Is it some disk bottleneck ?

*

*Did the homework, profiled the code, literally %95 of the runtime consists of read(), open() and close()

*I am reading the first 4096 bytes of every file (my pagesize)

*Ubuntu 18.04

*Intel i7 6700HQ

*Samsung 970 Evo Plus NVMe SSD

*GCC/G++ 11

A:
Why this may occur ?

If you open one file at "/a/b/c/d/e" then read one block of data from the file; the OS may have to fetch directory info for "/a", then fetch directory info for "/a/b", then fetch directory info for "/a/b/c", then... It might add up to a total of 6 blocks fetched from disk (5 blocks of directory info then one block of file data), and those blocks might be scattered all over the disk.
If you open a 100 million files and read one block of file data from each; then this might involve fetching 600 million things (500 million pieces of directory info, and 100 million pieces of file data).
What is the optimal order to do these 600 million things?
Often there's directory info caches and file data caches involved (and all requests that can be satisfied by data that's already cached should be done ASAP, before that data is evicted out of cache/s to make room for other data). Often the disk hardware also has rules (e.g. faster to access all blocks within the same "group of disk blocks" before switching to the next "group of disk blocks"). Sometimes there's parallelism in the disk hardware (e.g. two requests from the same zone can't be done in parallel, but 2 requests from different zones can be done in parallel).
The optimal order to do these 600 million things is something the OS can figure out.
More specifically; the optimal order to do these 600 million things is something the OS can figure out; if and only if the OS actually knows about all of them.
If you have (e.g.) 8 threads that send one request (e.g. to open a file) and then block (using no CPU time) until the pending request completes; then the OS will only know about a maximum of 8 requests at a time. In other words; the operating system's ability to optimize the order that file IO requests are performed is constrained by the number of pending requests, which is constrained by the number of threads you have.
Ideally; a single thread would be able to ask the OS "open all the files in this list of a hundred million files" so that the OS can fully optimize the order (with the least thread management overhead). Sadly, most operating systems don't support anything like this (e.g. POSIX asynchronous IO fails to support any kind of "asynchronous open").
Having a large number of threads (that are all blocked and not using any CPU time while they wait for their request/s to actually be done by file system and/or disk driver) is the only way to improve the operating system's ability to optimize the order of IO requests.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How can I test if my jar file has any unresolved dependencies? I'm writing a custom tool to build jar files from our build tree. We like to build "minimal" jar files that contain only the .class files actually referenced from the "root" class (where main() lives) -- and so on, recursively following dependencies.
Historically we have done this by getting javac to follow source dependencies, but that means recompiling common files many many times. (We build 60 or 70 distinct application jars from a single source tree.) I'm writing a new build system that compiles each source file only once, but that means we need to follow dependencies by parsing .class files.
The good news is, I've got working code that does what I want. But I need to be absolutely sure I didn't screw it up, i.e. I want to ensure that I'm building internally consistent jar files, where "consistent" means that all unresolved references can be resolved with one of our known third-party jars.
So ideally I want a MagicTool that I can run like
MagicTool \
  --classpath commons-lang.jar:commons-collections.jar:[...etc...] \
  myapp.jar

that will examine every unresolved reference inside myapp.jar and make sure that it can be resolved by one of the third-party jars passed to --classpath. If not, barf.

A: Better hope nothing in that path includes any sort of reflection, forName, etc.
I use depfind (if I'm not using my own Java spelunking tools) which may or may not provide output in a way that's helpful for you. jdepend is another option, although I've never used it for anything other than package-level dependencies.
Other tools like ProGuard will strip out unused classes (amongst other things), with the same reflective caveats.
I'm very wary of trying too hard to create minimal jar files; there's a point of diminishing returns/increased risk.

A: I am pretty sure that ProGuard is your magic tool, even if I don't now the exact call syntax.

A: At one stage some years ago, trying to index a JAR file with jar -i made it throw an exception if there were unresolved dependencies. I can't quickly test the current state of things.


text:
Q: A miraculous number N Of course we can talk about 1 digit prime numbers, 2 digit primes , 3 digit primes , and so on..., my question is : is there an N (N greater than zero) such that there are no N-digit prime numbers ? I realize that it will be truly miraculous if there exist such an N , in other words the existence of such an N would be highly highly improbable due to the statement that there exists at least one prime number between 2 consecutive cubic numbers or even 2 consecutive square numbers , but these statements have not yet been proven (rigorously?). So does there exist such an N ?

A: By Bertrand's postulate, for any integer $n>3$ there is a prime $p$ such that $n<p<2n-2$.
If $b>1$ is the base of your numbering system, we have that $b^{n+1}-1>2b^{n}-2$, because $b^{n+1}-2b^n=b^n(b-2)\ge0>-1$. So no number $n>1$ can be miraculous in base $b$, because $b^n>3$ as soon as $n>1$ or $b>3$.
The case $b=3$ and $n=1$ is ruled out, because $2$ is one digit long in base $3$.
So the only miraculous number is $1$, with respect to base $2$.

A: The comment by Martin-Bras points to Bertrand's postulate proved in 19th century: that there exists a prime number between  $n$ and $2n$. When you double an $n$ digit number if it becomes an $n+1$ digit then that $n+1$ digit number will have $1$ as leading digit. So the prime could be starting with 1 as leading digit; or if it is $n$ digit long then its next double will lead to such one (etc). So one will be able find for each $n$ a prime that is $n$ digit long and starting with 1 as leading digit; this guarantees in 3 more doublings 3 more primes that are equally long.


text:
Q: command line for putting bootable iso on usb Is there a basic linux command line, that does not make use of any 3rd party software, that places a bootable .iso file onto a USB memory stick that is then bootable and will install said linux?
I have the rhel-8.1 iso but it is 7.6gb.
I am out of dual-layer dvd's and would like to use my 32gb USB stick to install rhel-8.1.
Last time I tried which I think was CentOS-7.7 having put that onto USB via my windows10 pc, it booted but I then ran into some sata driver errors during install.  And became really frustrated and just went back to dvd which worked.
Looking for a reliable, frustration-free, way to

*

*plug 32gb usb stick into pc running centos 7.7

*get the rhel-8.1 iso onto that usb stick and have that usb stick bootable

*

*either by native command line

*or using a free 3rd party software in linux, which i am ok with

*boot a UEFI pc having that bootable usb stick and successfully install rhel 8.1 (or any linux iso) onto a single SSD connected via SATA.

A: There are many possibilities: cat, dd, pv, cp.
I think that cp is the easiest and should be available on each UNIX
and Linux system. Use it like that:
cp <iso_image> /dev/<disk_name>

Use a disk name such as /dev/sdb, not a partition such as
/dev/sdb1.  Make a backup of data on the disk you're copying to
because it will be replaced with contents of .iso image and be careful
to use a correct disk name to not inadvertently overwrite your
current filesystem.  You shouldn't need to be root because on today's
desktop Linux systems removable storage devices are owned by plugdev
and users are already members of that that group.

A: You'd think dd would be a good choice. Sorry, but https://askubuntu.com/questions/25476/how-to-make-a-usb-drive-bootable-after-live-image-is-copied-into-it-using-dd-c says it's not reliable for this use.
Therefore, in the absence of anything better documented, would you consider  using unetbootin which is designed to create a bootable Live USB drive?
Once installed, launch the app, and a menu appears. Select the Diskimage button and ISO should be chose in the spin box, then click on the triple dot box and browse to the location of your ISO file.

Make sure not to use persistence  ("Space used to preserve...") on the next to last line of the menu screen.


text:
Q: How allow copy/paste/cut in UIAlertView? (iOS, Objective C) I want to allow users to copy/cut but mainly PASTE data from other apps into my app. I need to allow them to paste data in UIAlertView, when they are logging to the app. How can i make it?
This is my code:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
                                                message:[NSString stringWithFormat:NSLocalizedString(@"enter_login", nil)]
                                               delegate:self
                                      cancelButtonTitle:@"Ok"

[alert setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
[[alert textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeEmailAddress];
[[alert textFieldAtIndex:1] becomeFirstResponder];
[UserDefaultsServices resetLoginCredentials];
[UserDefaultsServices resetLoginData];
self.alertView = alert;
[alert show];

It does this:
show what my code does, I need to allow users to paste data in password TextField

A: You can use this answer for swift versions :
Objective C version of shared answer is :
- (IBAction)showAlert:(id)sender {
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Add New Name" message:@"Your message" preferredStyle:UIAlertControllerStyleAlert];

    [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
        textField.placeholder = @"Name";
    }];

    [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
        textField.placeholder = @"Password";
        textField.secureTextEntry = true;
    }];

    UIAlertAction *saveAction = [UIAlertAction actionWithTitle:@"Save" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        // here you can access your textfields' texts
        NSString *textField1 = alertController.textFields[0].text;
        NSString *textField2 = alertController.textFields[1].text;
        NSLog(@"Saving %@ %@", textField1, textField2);
    }];

    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        // here you can access your textfields' texts
        NSString *textField1 = alertController.textFields[0].text;
        NSString *textField2 = alertController.textFields[1].text;
        NSLog(@"Canceled %@ %@", textField1, textField2);
    }];

    [alertController addAction:saveAction];
    [alertController addAction:cancelAction];

    [self presentViewController:alertController animated:YES completion:nil];
}

Above code work like this :


text:
Q: How visible is a SharePoint Site Collection to users without access? I've received a request to create a new "secret" site in our SP Farm which will have a very restricted set of users, and should be entirely invisible to other users of our SP site. Ideally, nobody* should have any idea that the site exists.
I'm planning on creating this as a Site Collection, partially so that it won't exist as a sub-site in any other site's All Site Content. Also, I intend to exclude this SC from search indexing, and of course it's permissions will be restricted.
Is there any other way a normal (non admin) user could see that a Site Collection exists if they don't have permission to it?

A: The only thing I can think of is if the user guessed the URL.  Then they would see the "Not Authorized" page and know something was there.


text:
Q: How to handle GSJ02 and WGS84 coordinate system in ios MKMapview? As I have done analysis, i got to know china using Gcj02 coordinate system.
so I have some douts on below scenarios
So in my ios app I am using MKMapview and showing some location which I am getting in WGS84 format

*

*If the location which l get in response is for mainland China and we shown as it as for outside china user will it show correct location or not? Or that is also need to convert in Gcj02?

*In same case what will happen if user is also in mainland China(MKMapview will show as AMap) and location is also in mainland land china? Do we need to convert?

*If user is outside china and location is also outside china then he can see correct location.

*But when user in china(MKMapview will show as AMap) and location is outside china? Will that location displayed correctly?

As there are some converter classes available for wgs to gcj or vice versa
As per above scenarios if I have to use both GCJ to WGS and WGS to GCJ, how will I get know location is in which format?
Thanks in advance for your help!!!


text:
Q: How to convert loop to apply family function for efficiency? I am trying to add a column based on if 2 of the already known columns are within a certain distance, I am able to accomplish this with a for loop but there are many rows, so it takes hours to execute. I am having trouble converting this to an apply function to make it more efficient
for(i in 1:nrow(Current_Month){
    d = distm(c(90, 90), c(Current_Month$Lon[i], Current_Month$Lat[i]), fun=distHaversine)
    Current_Month$Nearby[i] = ifelse(d < 1000, 1, d)
}

A: As markus said:
You don't actually have to loop through your Current_Month - data.frame.
The distm - function takes also a matrix (or data.frame) with two columns.
This worked for me with a small dummy sample data.
Current_Month <- data.frame("Lon" = sample(1:100, 1000, replace = TRUE),
                            "Lat" = sample(1:90, 1000, replace = TRUE))

start <- Sys.time()
d = distm(c(90, 90), Current_Month, fun=distHaversine)
end <- Sys.time()
end - start
> Time difference of 0.001993895 secs

In contrast to your:

start <- Sys.time()
for(i in 1:nrow(Current_Month)){
  d = distm(c(90, 90), c(Current_Month$Lon[i], Current_Month$Lat[i]),
      fun=distHaversine)
 }
end <- Sys.time()
end - start
Time difference of 0.2293599 secs

So it's considerably faster.
Then proceed:
Current_Month$Nearby = t(ifelse(d < 1000, 1, d)) #had to transpose this one though


text:
Q: Creating a UITableView Programmatically I have an application in Xcode 4.6 which uses storyboards. I added a UITableView to a view controller class, which worked as expected. However, when I tried deleting the UITableView in the storyboard and adding it back into the same class programmatically, I ran into two specific problems:
1) Although I set the UITableViewCell type to be of type subtitle, the detail label no longer appears.
2) The segue that should occur when I select a cell does not occur, and prepare segue is not even being called, indicating that no message is being sent to the table view when a cell is selected.
Here is the relevant code:
@interface StatsTableViewController () <UITableViewDataSource, UITableViewDelegate>
@property (strong, nonatomic) UITableView *tableView;

@end

@implementation StatsTableViewController

-(UITableView *)makeTableView
{
    CGFloat x = 0;
    CGFloat y = 50;
    CGFloat width = self.view.frame.size.width;
    CGFloat height = self.view.frame.size.height - 50;
    CGRect tableFrame = CGRectMake(x, y, width, height);

    UITableView *tableView = [[UITableView alloc]initWithFrame:tableFrame style:UITableViewStylePlain];

    tableView.rowHeight = 45;
    tableView.sectionFooterHeight = 22;
    tableView.sectionHeaderHeight = 22;
    tableView.scrollEnabled = YES;
    tableView.showsVerticalScrollIndicator = YES;
    tableView.userInteractionEnabled = YES;
    tableView.bounces = YES;

    tableView.delegate = self;
    tableView.dataSource = self;

    return tableView;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.tableView = [self makeTableView];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"newFriendCell"];
    [self.view addSubview:self.tableView];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"newFriendCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }

    Friend *friend = [self.fetchedResultsController objectAtIndexPath:indexPath];

     **//THIS DATA APPEARS**
    cell.textLabel.text = friend.name;
    cell.textLabel.font = [cell.textLabel.font fontWithSize:20];
    cell.imageView.image = [UIImage imageNamed:@"icon57x57"];

    **//THIS DATA DOES NOT APPEAR**
    cell.detailTextLabel.text = [NSString stringWithFormat:@"%i Games", friend.gameCount];
    cell.detailTextLabel.textColor = [UIColor lightGrayColor];

    return cell;
}

 -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"detailsView" sender:self];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
      //I set the segue identifier in the interface builder
     if ([segue.identifier isEqualToString:@"detailsView"])
     {

         NSLog(@"segue"); //check to see if method is called, it is NOT called upon cell touch

         NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
         ///more code to prepare next view controller....
     }
}

I am not sure what I am forgetting to do so that I can solve these two issues. Any help is appreciated.

A: - (void)viewDidLoad {
     [super viewDidLoad];
     arr=[[NSArray alloc]initWithObjects:@"ABC",@"XYZ", nil];
     tableview = [[UITableView alloc]initWithFrame:tableFrame style:UITableViewStylePlain];
     tableview.delegate = self;
     tableview.dataSource = self;
     [self.view addSubview:tableview];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return arr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyCell"];

    if(cell == nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyCell"];
    }

    cell.textLabel.text=[arr objectAtIndex:indexPath.row];

    return cell;
}

A: When you register a class, and use dequeueReusableCellWithIdentifier:forIndexPath:, the dequeue method is guaranteed to return a cell, so your if (cell == nil) clause is never entered. So, just do it the old way, don't register the class, and use dequeueReusableCellWithIdentifier:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"newFriendCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }
//etc.
return cell;
}

As for the segue, it can't be called because you can't make a segue to a table that you've created in code, not in IB. Again, go back to the old way and use tableView:didSelectRowAtIndexPath: which will be called when you select a cell. Instantiate your detail controller there and do the trasition in code.
After edit:
I didn't see your added code there. You've implemented didDeselectRowAtIndexPath rather than didSelectRowAtIndexPath. If you change that, your segue should work.

A: - (void)viewDidLoad
{
    [super viewDidLoad];
    tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    tableView.delegate = self;
    tableView.dataSource = self;

    tableView.backgroundColor = [UIColor grayColor];

    // add to superview
    [self.view addSubview:tableView];
}

#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:    (NSInteger)section
{
    return 1;
}

// the cell will be returned to the tableView
- (UITableViewCell *)tableView:(UITableView *)theTableView  cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"HistoryCell";

    // Similar to UITableViewCell, but
    UITableViewCell *cell = (UITableViewCell *)[theTableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    cell.descriptionLabel.text = @"Testing";
    return cell;
}

A: You might be do that  its  works 100% .
- (void)viewDidLoad
{
    [super viewDidLoad];
    // init table view
    tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];

    // must set delegate & dataSource, otherwise the the table will be empty and not responsive
    tableView.delegate = self;
    tableView.dataSource = self;

    tableView.backgroundColor = [UIColor cyanColor];

    // add to canvas
    [self.view addSubview:tableView];
}

#pragma mark - UITableViewDataSource
// number of section(s), now I assume there is only 1 section
- (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView
{
    return 1;
}

// number of row in the section, I assume there is only 1 row
- (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

// the cell will be returned to the tableView
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"HistoryCell";

    // Similar to UITableViewCell, but
    JSCustomCell *cell = (JSCustomCell *)[theTableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[JSCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    // Just want to test, so I hardcode the data
    cell.descriptionLabel.text = @"Testing";

    return cell;
}

#pragma mark - UITableViewDelegate
// when user tap the row, what action you want to perform
- (void)tableView:(UITableView *)theTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"selected %d row", indexPath.row);
}

@end

A: Creating a tableview using tableViewController .
import UIKit

class TableViewController: UITableViewController
{
    let tableViewModel = TableViewModel()
    var product: [String] = []
    var price: [String] = []
    override func viewDidLoad()
    {
        super.viewDidLoad()
        self.tableView.contentInset = UIEdgeInsetsMake( 20, 20 , 0, 0)
        let priceProductDetails = tableViewModel.dataProvider()

        for (key, value) in priceProductDetails
        {
            product.append(key)
            price.append(value)
        }
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
    {
        return product.count
    }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    {
        let cell = UITableViewCell(style: .Value1, reuseIdentifier: "UITableViewCell")
        cell.textLabel?.text = product[indexPath.row]
        cell.detailTextLabel?.text = price[indexPath.row]
        return cell
    }

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
    {
        print("You tapped cell number \(indexPath.row).")
    }
}

A: sample table
 #import "StartreserveViewController.h"
 #import "CollectionViewController.h"
 #import "TableViewCell1.h"
@interface StartreserveViewController ()

{
NSArray *name;
NSArray *images;
NSInteger selectindex;

}

@end

@implementation StartreserveViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.

self.view.backgroundColor = [UIColor blueColor];
_startReservetable.backgroundColor = [UIColor blueColor];

name = [[NSArray alloc]initWithObjects:@"Mobiles",@"Costumes",@"Shoes",
nil];
images = [[NSArray
 alloc]initWithObjects:@"mobilestitle.jpg",@"costumetitle.jpeg",
 @"shoestitle.png",nil];

  }

 - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

pragma mark - UiTableview Datasource
 -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
 {
return 1;
 }

 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:
 (NSInteger)section
 {
return 3;
 }

 - (UITableViewCell *)tableView:(UITableView *)tableView
  cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {

static NSString *cellId = @"tableview";

TableViewCell1  *cell =[tableView dequeueReusableCellWithIdentifier:cellId];

cell.cellTxt .text = [name objectAtIndex:indexPath.row];

cell.cellImg.image = [UIImage imageNamed:[images
objectAtIndex:indexPath.row]];

return cell;

 }

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:
(NSIndexPath *)indexPath
 {
selectindex = indexPath.row;
[self performSegueWithIdentifier:@"second" sender:self];
}

   #pragma mark - Navigation

 // In a storyboard-based application, you will often want to do a little
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

if ([segue.identifier isEqualToString:@"second"])

  {
    CollectionViewController *obj = segue.destinationViewController;
           obj.receivename = [name objectAtIndex:selectindex];

  }

// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}

 @end

.h
#import <UIKit/UIKit.h>

@interface StartreserveViewController :
UIViewController<UITableViewDelegate,UITableViewDataSource>
@property (strong, nonatomic) IBOutlet UITableView *startReservetable;

 @end

A: vc.m
#import "ViewController.h"

import "secondViewController.h"
 @interface ViewController ()
 {

NSArray *cityArray;
NSArray *citySubTitleArray;
NSArray *cityImage;
NSInteger selectindexpath;

}
@end

 @implementation ViewController

 - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

cityArray = [[NSArray
alloc]initWithObjects:@"Coimbatore",@"Salem",@"Chennai",nil];

citySubTitleArray = [[NSArray alloc]initWithObjects:@"1",@"2",@"3", nil];
cityImage = [[NSArray alloc]initWithObjects:@"12-300x272.png"
 , @"380267_70d232fc33b44d4ebe7b42bbe63ee9be.png",@"apple-logo_318
 -40184.png", nil];

 }

 #pragma mark - UITableView Data Source

 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
 {
return 1;

 }

 - (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection
 :(NSInteger)section
  {
return cityImage.count;
 }

- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellId = @"city";

UITableViewCell *cell =
 [tableView dequeueReusableCellWithIdentifier:cellId];

if (cell == nil)
{
    cell = [[UITableViewCell
  alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellId];
}

cell.textLabel.text = [cityArray objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [citySubTitleArray objectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:
 [cityImage objectAtIndex:indexPath.row]];

 //    NSData *data = [[NSData alloc]initWithContentsOfURL:
 [NSURL URLWithString:@""]];

 //    cell.imageView.image = [UIImage imageWithData:data];

return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath
:  (NSIndexPath *)indexPath
 {
 NSLog(@"---- %@",[cityArray objectAtIndex:indexPath.row]);
 NSLog(@"----- %@",[cityImage objectAtIndex:indexPath.row]);
 selectindexpath=indexPath.row;
 [self performSegueWithIdentifier:@"second" sender:self];
  }

  #pragma mark - Navigation

 // In a storyboard-based application, you will often want to do a little p
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 if ([segue.identifier isEqualToString:@"second"])
 {
    secondViewController *object=segue.destinationViewController;
    object.cityName=[cityArray objectAtIndex:selectindexpath];
    object.cityImage=[cityImage objectAtIndex:selectindexpath];
       }
 }

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
 }

 @end

vc.m
 #import <UIKit/UIKit.h>

 @interface ViewController : UIViewController<UITableViewDataSource
  , UITableViewDelegate>
 @property (strong, nonatomic) IBOutlet UITableView *cityLabelList;

@end

sv.m
 #import <UIKit/UIKit.h>

@interface secondViewController : UIViewController
@property(strong, nonatomic) NSString *cityName;
 @property(strong,nonatomic)NSString *cityImage;
@end

sv.h
#import "secondViewController.h"

 @interface secondViewController ()

 @property (strong, nonatomic) IBOutlet UILabel *lbl_desc;
 @property (strong, nonatomic) IBOutlet UIImageView *img_city;
    @end

 @implementation secondViewController

 - (void)viewDidLoad {
 [super viewDidLoad];
// Do any additional setup after loading the view.
self.title=self.cityName;

if ([self.cityName isEqualToString:@"Coimbatore"])
{

    self.lbl_desc.text=@"Coimbatore city";
    self.img_city.image=[UIImage imageNamed:
    [NSString stringWithFormat:@"%@",self.cityImage]];
}
 else if ([self.cityName isEqualToString:@"Chennai"])
 {

    self.lbl_desc.text= @"Chennai City Gangstar";
    self.img_city.image=[UIImage imageNamed:
   [NSString stringWithFormat:@"%@",self.cityImage]];

   }
  else
   {

    self.lbl_desc.text= @"selam City";
    self.img_city.image=[UIImage imageNamed:
   [NSString stringWithFormat:@"%@",self.cityImage]];

   }
 }

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

A: - (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)theTableView  cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"HistoryCell";

    UITableViewCell *cell = (UITableViewCell *)[theTableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    cell.descriptionLabel.text = @"Testing";
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //Code for selection.
}

these are UITableView delegate methods.

A: #import "ViewController.h"

@interface ViewController ()

{

    NSMutableArray *name;

}

@end

- (void)viewDidLoad

{

    [super viewDidLoad];
    name=[[NSMutableArray alloc]init];
    [name addObject:@"ronak"];
    [name addObject:@"vibha"];
    [name addObject:@"shivani"];
    [name addObject:@"nidhi"];
    [name addObject:@"firdosh"];
    [name addObject:@"himani"];

    _tableview_outlet.delegate = self;
    _tableview_outlet.dataSource = self;

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

return [name count];

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    static NSString *simpleTableIdentifier = @"cell";

    UITableViewCell *cell = [tableView       dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
    }

    cell.textLabel.text = [name objectAtIndex:indexPath.row];
    return cell;
}


text:
Q: Grouping by time interval in a pandas dataframe I have a pandas DataFrame that imports with 2 columns (Time, Heart Rate).
The time comes in with the format MM:SS.s (for minutes:Seconds.miliseconds). I am trying to convert this time into a float of seconds (e.g. 0.6s or 65.3s) (to later be used to collapse into 10s windows). For example:
import pandas as pd
hr_raw = pd.read_csv('hr_data.csv')
hr_raw.dropna(inplace=True)
print(hr_raw.head())

   Time       HR bpm
0  00:00.6    97.0
1  00:01.0    92.0
2  00:01.3    80.0
3  00:01.6    81.0
4  00:02.0    80.0

Previously (when importing using the standard CSV module) I just split this string, converted to a float and did the math to convert it to seconds:
 with open('hr_data.csv', 'rU') as infile:
     hr_data = list(csv.DictReader(infile, delimiter=','))
     for row in hr_data:
         temp = row['Time']
         time.append(float(temp[3:7]) + (float(temp[0:2]) * 60))

Now that I am using a pandas df the code isn't working. I've tried to modify so that I am accessing the 'Time' column (see below), but not having much luck.
import pandas as pd

win_size = 10  # user defined window in seconds

hr_raw = pd.read_csv('hr_data.csv')
hr_raw.dropna(inplace=True) #remove NaN artifact from import

#### problem code ####
for row in hr_raw.Time:
    hr_raw.Time[row] = float(hr_raw.Time[row][3:]) + float((hr_raw.Time[row][0:2] * 60))

# set time as index
hr_raw.set_index('Time', inplace=True)

# bin data based on user defined window
hr_bin = hr_raw.groupby((hr_raw.index // win_size + 1) * win_size).mean()

The error that comes up is:
Traceback (most recent call last):
  File "pandas\_libs\index.pyx", line 154, in pandas._libs.index.IndexEngine.get_loc (pandas\_libs\index.c:5126)
  File "pandas\_libs\hashtable_class_helper.pxi", line 759, in pandas._libs.hashtable.Int64HashTable.get_item (pandas\_libs\hashtable.c:14010)
TypeError: an integer is required

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\mitbl001\Dropbox\CPET_python\import_hr_csv.py", line 11, in <module>
    hr_raw.Time[row] = float(hr_raw.Time[row][3:]) + float((hr_raw.Time[row][0:2] * 60))
  File "C:\Users\mitbl001\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\series.py", line 601, in __getitem__
    result = self.index.get_value(self, key)
  File "C:\Users\mitbl001\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\indexes\base.py", line 2477, in get_value
    tz=getattr(series.dtype, 'tz', None))
  File "pandas\_libs\index.pyx", line 98, in pandas._libs.index.IndexEngine.get_value (pandas\_libs\index.c:4404)
  File "pandas\_libs\index.pyx", line 106, in pandas._libs.index.IndexEngine.get_value (pandas\_libs\index.c:4087)
  File "pandas\_libs\index.pyx", line 156, in pandas._libs.index.IndexEngine.get_loc (pandas\_libs\index.c:5210)
KeyError: '00:00.6'

A: Convert your time column to float using pd.to_timedelta:
df['Time'] = pd.to_timedelta('00:' + df.Time).dt.total_seconds()
df

   Time  HR bpm
0   0.6    97.0
1   1.0    92.0
2   1.3    80.0
3   1.6    81.0
4   2.0    80.0

A groupby should be simple now using the syntax:
df.groupby(df.Time // x * x)

Where x is your desired window of time. Here's an example of grouping in intervals of 0.5 seconds and taking the mean of the heart rate:
df.groupby(df.Time // 0.5 * 0.5)['HR bpm'].mean()

Time
0.5    97.0
1.0    86.0
1.5    81.0
2.0    80.0
Name: HR bpm, dtype: float64

The above outputs a series. If you want to obtain a dataframe, you can call reset_index after the groupby.
df.groupby(df.Time // 0.5 * 0.5)['HR bpm'].mean().reset_index()

   Time  HR bpm
0   0.5    97.0
1   1.0    86.0
2   1.5    81.0
3   2.0    80.0

In your case, you'd do something along the lines of df.groupby(df.Time // 10 * 10).

A: I think you need indexing with str with cast to float by astype:
hr_raw.Time = hr_raw.Time.str[3:].astype(float) + hr_raw.Time.str[0:2].astype(float) * 60
print (hr_raw)

   Time  HR bpm
0   0.6    97.0
1   1.0    92.0
2   1.3    80.0
3   1.6    81.0
4   2.0    80.0

Another solution is converting to_timedelta, but before add from right side hours by radd:
hr_raw.Time = pd.to_timedelta(hr_raw.Time.radd('00:')).dt.total_seconds()
print (hr_raw)

   Time  HR bpm
0   0.6    97.0
1   1.0    92.0
2   1.3    80.0
3   1.6    81.0
4   2.0    80.0

And then set_index is not necessary, use column Time:
# bin data based on user defined window
hr_bin = hr_raw.groupby((hr_raw.Time // win_size + 1) * win_size).mean()
print (hr_bin)
      Time  HR bpm
Time
10.0   1.3    86.0


text:
Q: Route values from HTTPContext in Webform I'm using Routing in web-forms, I'm trying to write HTTP module in which I want to retrieve Route values from the route. When I try to use below line I get null. Is there anything other than this to get route data in web-forms? I want to know if the route that is currently in request context contains any route values in the route or not.
HttpContext.Current.Request.RequestContext.RouteData

PS: I read in other posts on stack overflow that the above line works in MVC.

A: Perhaps you should take another look at your global.asax file and see if your route has actually been mapped properly or not.
Example
protected void Application_Start(object sender, EventArgs e)
{
    RegisterRoutes(RouteTable.Routes);
}

public static void RegisterRoutes(RouteCollection routes)
{
    routes.MapPageRoute("",
        "Category/{action}/{categoryName}",
        "~/categoriespage.aspx");
}

For more details, please refer to the following links:
https://msdn.microsoft.com/en-us/library/dd329551.aspx#Anchor_1
https://msdn.microsoft.com/en-us/library/cc668201.aspx#Anchor_2


text:
Q: How set start page in nodejs I use node js without frameworks etc. and I have problem, I don't understand how set "start html page" for my first request to server.
I tried do it like this
var server = new http.Server();
server.listen(1137, '127.0.0.1');

server.on('request', function(req, res) {
    fs.readFile('../public/index.html', function (err, html) {
        if (err) {
            throw err;
        } else {
            res.write(html);
            res.end();
        }
    });
});

When I do request to 127.0.0.1:1137 - I got html in browser, but links to CSS/JS files isn't correct and how I can this to fix I don't know :(
I want get the html page ../public/index.html in browser when I will do first request to my server.
my server location
project/server/server.js
my html-page location
project/public/index.html

A: Your page includes references to images and stylesheets, which you said don't work.
Well, you are responding to every single HTTP request with the contents of the specified HTML page.
When the browser parses the HTML, it will see the image and stylesheet links and issue HTTP requests to those URL's.  But those URL's don't respond with images or stylesheets.  They respond with HTML.
GET /index.html

yields
<html>
  <head>
    <link rel="stylesheet" href="styles.css">
  </head>

  <body>
    <img src="someimage.png">
  </body>
</html>

The browser then requests
GET /styles.css

yields
<html>
...
</html>

The browser then requests
GET /someimage.png

yields
<html>
...
</html>

You need to make the response conditional based on the request.  To prevent disclosure of information, like @minitech mentioned, you need to be careful not to blindly concatenate the paths.  Then you have to worry about MIME types.
You're really best off using a framework like express.

A: You will need to return different files, depending on the path that was requested.
On the 'request' handler you are getting a ClientRequest object, which has a path property. Use this information to return the correct files (index.html, the CSS or JS files...). An example request callback could be:
function onRequest(req, res) {
  var path = req.path;
  fs.readFile('../public' + path, function(err, contents) {
    if (err) {
      res.writeHead(500);
      res.end(err);
      return;
    }

    res.end(contents);
  });
}

This is still very basic, you will probably want to handle non-existent files with a 404 result code, return the correct Content-Type headers the different file kinds (text/html, text/css, etc).
Update: as minitech recommends, the path should be checked for ../, which would go up the filesystem and access sensitive files.
Hope this helps.


text:
Q: Only run WayPoints if viewport width is greater than 1000px? Is there a way to only run WayPoints when the viewport is greater than a certain width? Preferably checking if that width changes on resize?
Normally I'd just leave this but I have 4 sections and when they come into view I add a class of .in-view to them so I can animate the divs within. The problem is (I think) that on mobile my sections display in a slideshow (Slick slider) so I have the same animation/transition styling on .slick-current and sometimes they don't work, which is likely because it's setting the elements to .in-view still?
This is the code I'm using:
$(document).ready(function(){
    var waypoints = document.querySelectorAll('.showcase__item');
    for (var i = waypoints.length - 1; i >= 0; i--) {
        var waypoint = new Waypoint({
            element: waypoints[i],
            handler: function(direction) {
                this.element.classList.toggle('in-view');
            },
            offset: '60%',
        });
    }
});

Is this possible ...is it even a good idea? Not sure how stressful this would be on performance?

A: I don't know really this plugin but it would be possible using window.matchMedia().addListener() method, it would be better than binding to window resize event. Then you could enabling/disabling waypoint plugin. By the way, you should initialize plugin using jQuery's way.
The following code hasn't been tested:
var widthMatch = window.matchMedia("(min-width:1000px)");
var waypoints;

widthMatch.addListener(function(e) {
  switchWayPoints(e.matches);
});

function switchWayPoints(enable) {
  waypoints[enable ? "enableAll" : "disableAll"]();
}

$(document).ready(function() {
  waypoints = $('.showcase__item').waypoint(function(direction) {
    // -> Seem strange to call it here without any direction check?! ->$(this).toggleClass('in-view');
  }, {
    offset: '60%'
  });

  switchWayPoints(widthMatch.matches);
});

A: You can check the $(window).resize() and $(window).width(); .
$(window).resize() event is sent to the window element when the size of the browser window changes and $(window).width(); gets the current width of the window. Here is the snippet of the code.
$(document).ready(function(){
    $(window).resize(function () {
        width=$(window).width();
        if (width > 1000){
            var waypoints = document.querySelectorAll('.showcase__item');
            for (var i = waypoints.length - 1; i >= 0; i--) {
                var waypoint = new Waypoint({
                    element: waypoints[i],
                    handler: function(direction) {
                        this.element.classList.toggle('in-view');
                    },
                    offset: '60%',
                });
            }
        } else {
            // Your logic when the screen size is less then 1000 px.
            if ($("#someID").hasClass("classname")) {
                $("#someID").removeClass("classname");
            }
        }
    });
});


text:
Q: How I can view my uploaded pdf from firebase storage with flutter? I have recently uploaded a pdf file to firebase storage via picking a pdf by file_picker plugin.
now file is uploaded successfully :

but when I go to firebase storage : tapped on that pdf link , showing ERROR MESSAGE failed to load pdf decoument

Code for picking pdf via file_picker
void sendPdf() async {
   FilePickerResult result = await FilePicker.platform.pickFiles(

     type: FileType.custom,
   allowedExtensions: ['pdf'],
   );

   if(result != null) {
     File file = File(result.files.single.path);
       _storageMethods.uploadPdf(
       pdf: file,
       uploaderId: widget.adminUser.uid,
       courseTitle:_courseTitleController.text,
       coursePrice:_coursePriceController.text,
      uploadProvider: _uploadProvider);
   } else {
     // User canceled the picker
   }

 }

Code for uploading a file to firebase storage:
Future<String> uploadPdfToStorage(File pdfFile) async {
   try {
     Reference ref = FirebaseStorage.instance.ref().child('pdfs/${DateTime.now().millisecondsSinceEpoch}');
   UploadTask uploadTask = ref.putFile(pdfFile, SettableMetadata(contentType: 'pdf'));

    TaskSnapshot snapshot = await uploadTask;

   String url = await snapshot.ref.getDownloadURL();

 print("url:$url");
 return  url;
   } catch (e) {
     return null;
   }
 }

A: Have found the issue with contentType
 UploadTask uploadTask = ref.putFile(pdfFile, SettableMetadata(contentType: 'pdf'));

I've replaced with:
 UploadTask uploadTask = ref.putFile(pdfFile, SettableMetadata(contentType: 'application/pdf'));


text:
Q: RandomAccessFile readInt how to read numbers from a file???
when i use readInt method i get big number, and it not equals number from a file.
how to fix it???
Scanner is not good idea, becouse file contains more then 1000 millions numbers... it will takes very long time...
yes, text file.
file contains numbers devided space symbols. for example ( test.txt )
1 2 4 -4004 15458 8876

   public static void readByMemoryMappedFile(int buffer[], String filename) throws IOException
   {
      int count = 0;

      RandomAccessFile raf = new RandomAccessFile(filename, "r");
      try {
            MappedByteBuffer mapFile = raf.getChannel().map(MapMode.READ_ONLY, 0, raf.length());

            StringBuilder b = new StringBuilder();
            try {
                  while (mapFile.hasRemaining()) {
                        byte read = mapFile.get();
                        if (read == ' ' && b.length() > 0) {
                              buffer[count++] = mapFile.getInt();//Integer.parseInt(b.toString());
                              b.delete(0, b.length());
                        } else {
                              b.append((char) read);
                        }
                  }
            } catch (BufferUnderflowException e) {
                  // Всё, файл закончился
            }
            if (b.length() > 0) {
                  buffer[count++] = Integer.parseInt(b.toString());
            }
      } finally {
            raf.close();
      }
   }

so, i attached report:

// operation: time
reading: 39719   // t0
reading: 28297   // t1
reading: 56719   // t2
reading: 125735  // t3
reading: 199000  // t4

t0 < t1 < t2 < t3 < t4
How to change behavior of my program that get this: t0 ~ t1 ~ t2 ~ t3 ~ t4 ???

A: A possible reason for the large number may be due to byte ordering.  Java uses Big Endian by default when reading from a channel.  If the file you are reading from is Little Endian, then small numbers will become large, because the least significant byte becomes the most significant byte.
You can change the byte ordering of ByteBuffer by using the order method.

A: If you want to randomly access data, you need to be able to determine where to start and where to finish.  With a text format this can be tricky and you may have to read all the previous lines/text to find the one you want.
With binary formats, you may be able to calculate exactly where you want to read, but you need to know how the number was encoded. e.g. was it big endian or little endian?
Scanner may not be optimal for text, and useless for binary data, but if may be more than fast enough.
Much of the time taken to scan a large file is the time it takes to read off disk (assuming it won't fit in memory) you can speed up this significantly if the file compresses well, e.g. text full of numbers does. Instead of taking 20 seconds to read it might take only 2 seconds if compressed. (And it might fit in the OS file cache)

A: This all depends on how the numbers are stored.
I guess the short answer is: One way or another, you have to know where the number starts and where it ends, and whether it is stored as text or in binary, and if it's in binary what the byte order is, i.e. little-endian or big-endian.
If it's stored as text, build a String from the digits, then call Integer.parseInt on that String. (Or if it's a floating point number, Double.parseDouble, etc for other data types.)
If it's stored as a binary integer, then read the bytes in to an array, or read them one by one, then multiply by powers of 256 and add together.
For example, suppose you have a four-byte number in little-endian order. You read it into a byte array of size 4. Then:
byte[] incoming=new byte[4];
file.read(incoming);
int n=0;
for (int p=0;p<4;++p)
  n=n*256+incoming[p];
return n;

A: If your numbers are stored as text readInt() won't work.  You must parse the file, it is the only way.


text:
Q: Mac App Store Automatically Cancels Downloading Xcode When I try to download Xcode from the MAS, the download automatically stops after several minutes.
It's not because of internet problems because the internet was working fine at the same time as the download.  I have tried multiple times but still get the same result.
Does anyone know what could be causing this?


text:
Q: How to access a class's property inside another generic class by object passing? In my code, Generic class Public will receive a generic object in check() method. These generic objects might be from JuniorInstructor class or SeniorInstructor class.I wanna access the properties of JuniorInstructor class or SeniorInstructor class. I tried with below implementation and it works. But, Is there any better way to do this?
   class JuniorInstructor extends Instructor {

    public JuniorInstructor(String id, String name) {
        super(id, name);

    }

}

class Public<T> {
    T object;
    JuniorInstructor j1;
    SeniorInstructor s1;

    public void check(T object) {

        this.object = object;
        if (object instanceof SeniorInstructor) {
            s1 = (SeniorInstructor) object;
            System.out.println("name: " + s1.name + "\tid: " + s1.id);
        } else {
            j1 = (JuniorInstructor) object;
            System.out.println("name: " + j1.name + "\tid: " + j1.id);
        }
    }// check
}
public static void main(String[] args) {
        SeniorInstructor s1 = new SeniorInstructor("120", "Ashik");
        JuniorInstructor j1 = new JuniorInstructor("677", "Tareq");
        Public p = new Public();

        p.check(j1);

    }

A: You can further qualify T:
class Public<T extends Instructor>

And simply make sure all the methods you need to access are defined on Instructor. You'll then be able to call them directly in Public.
[Edit] @JBNizet has an excellent point in comments that Public doesn't really need to be generics if Instructor and its subclasses are all it needs to handle.

A: You can declare the Public class like
class Public<T extends Instructor> {
      ...
   }

in this way you can avoid to check for instance type, as long as you need to access to 'Instructor' property.
Hope this help

A: I think might want to use polymorphism instead of generics.
Create 2 overloaded versions of check method:

*

*one that accepts a JuniorInstructor

*one that accepts a SeniorInstructor
In this way, there is no need to use instanceOf or casting objects to a given type.
class Public {
    JuniorInstructor j1;
    SeniorInstructor s1;

    public void check(SeniorInstructor object) {
        s1 = object;
        System.out.println("name: " + s1.getName() + "\tid: " + s1.getId());
    }

    public void check(JuniorInstructor object) {
        j1 = object;
        System.out.println("name: " + j1.getName() + "\tid: " + j1.getId());
    }
}

A: As Ward mentioned,

One of the benefits of generics is that you can write generic code, without the need for using instanceof and casting etc...

You can modify the Public class as below :
class Public<T extends Instructor> {
   T instructor;

   public void check(T object) {
       this.instructor = object;
       System.out.println("name: " + this.instructor.name + "\tid: " + this.instructor.id);
   }
}

A: public class Instructor {

private String id;
private String name;

public Instructor(String id, String name) {
        this.id= id; this.name= name;
}

//getters and setters
 }

Then a class public :
class Public<T extends Instructor> {
T object;

public void check(T object) {
        System.out.println("name: " + object.getName() + "\tid: " + object.getId());
}
}

However, if your class has only 1 method using this T as parameter, you can modify it to:
class Public {

public <T extends Instructor> void check(T object) {
        System.out.println("name: " + object.getName() + "\tid: " + object.getId());
}
 }

Or since usage of generics is not clear here, we can simply use:
class Public {

public  void check(Instructor object) {
        System.out.println("name: " + object.getName() + "\tid: " + object.getId());
}
 }

And in main:
 public static void main(String[] args) {
    Public obj= new Public();
    obj.check(new JuniorInstructor("1","Payal"));
}


text:
Q: search multi keywords from sql So I'm getting data from sql like this :
$date = 1-02-2011
$sql = "SELECT * FROM abc  WHERE date='$date'"

Now I want to get data from multiple dates for creating a graph
$date1 = 1-02-2011
$date2 = 2-02-2011
$date3 = 3-02-2011
$date4 = 4-02-2011
$date5 = 5-02-2011
$date6 = 6-02-2011

and so on..
Is there any quick way? Or will have to create different querys for each date?

A: You can use IN:
SELECT * FROM abc WHERE date IN ('2011-02-01', '2011-02-03', '2011-02-05')

or if your dates are always consecutive like in your example then you could use BETWEEN:
SELECT * FROM abc WHERE date BETWEEN '2011-02-01' AND '2011-02-06'

Then to read the results:
$result = mysql_query($query) or trigger_error(mysql_error());

while ($row = mysql_fetch_assoc($result)) {
    $date =  $row['date'];
    $col1 = $row['col1'];
    // Do something with the results.
}

Edit: To show NULL for missing values you can use a LEFT JOIN:
SELECT T1.date, T2.*
FROM (
    SELECT '2011-02-01' AS date
    UNION ALL
    SELECT '2011-02-02'
    UNION ALL
    ...
    UNION ALL
    SELECT '2011-02-06'
) AS T1
LEFT JOIN T2
ON T1.date = T2.date


text:
Q: How do I center this "navbar"? I added this options to make a small navbar, but I can't make the content to be centered. So it looks like this image
What do I need to change so it displays all the options in the centre?
Here is the code:
I don't know if the snippet will look exactly like the picture I attached, but I think the problem will still be noticeable

body{
    background-color: #eeeeee;
    margin: 0;
}
/*Esto es el logo*/
#parte1{
    background-color: #da291c;
    margin-bottom: 10px;

}
#menu{
    margin: 0px 0px 0px 0px;
    font-size: 20px;
    font-family: Arial;
    border-bottom: 1px solid #CCC;

}
/*Esta es la blowjob de los equipos*/
#parte3{
    background-color: white;
    margin: 10px 25% 0px 25%;
    height: 150px;
    font-family: Arial;

}

#logo{

    background-color:  #da291c;
    margin-top: 10px;
    margin-bottom: 10px;

}

#parte1-samsung{
    background-color: #da291c;
}
#parte2-samsung{
    background-color: white;
    margin: 10px 0px 0px 0px;
    font-size: 20px;
    font-family: Arial;
}
ul{
    padding: 0;
}
nav ul li{
    list-style: none;
    margin: 0 25px;
    display: inline-flex;

}

nav ul li a{
    text-decoration: none;
    color: #444;
    font-weight: bold;
    justify-self: center;

}

 nav ul li a:hover{
    color: #d02e10;
    background-color: #d02e10;
    color: white;
    border-radius: 5px;
    transition: .3s ease all;
    padding-left: 5px;
    padding-right: 5px;

 }

a{
    text-decoration: none;

}
<!DOCTYPE html>

    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="estilos.css">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title> Caracteristicas Claro</title>

            INICIO

            SAMSUNG

            APPLE

            HUAWEI

            XIAOMI

            MOTOROLA

            HONOR

            OPPO

            REALME

            VIVO

            ZTE

            COOLPAD

Equipos

A:    #menu{
margin: 0px 0px 0px 0px;
font-size: 20px;
font-family: Arial;
border-bottom: 1px solid #CCC;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
 }

does this fix your problem?

A: You can just put text-align: center on your #menu nav element.
Also, you should avoid using the center tag that surrounds the #parte1 div. That is long deprecated. All you need to do is put text-align: center on your #parte1 div, and it will center it for you.

A: You can use flex position to the
 tag with justify-content : center property.
You can also add the property flex-wrap : wrap for the responsive design.

body{
    background-color: #eeeeee;
    margin: 0;
}
/*Esto es el logo*/
#parte1{
    background-color: #da291c;
    margin-bottom: 10px;

}
#menu{
    margin: 0px 0px 0px 0px;
    font-size: 20px;
    font-family: Arial;
    border-bottom: 1px solid #CCC;
}
/*Esta es la blowjob de los equipos*/
#parte3{
    background-color: white;
    margin: 10px 25% 0px 25%;
    height: 150px;
    font-family: Arial;

}

#logo{

    background-color:  #da291c;
    margin-top: 10px;
    margin-bottom: 10px;

}

#parte1-samsung{
    background-color: #da291c;
}
#parte2-samsung{
    background-color: white;
    margin: 10px 0px 0px 0px;
    font-size: 20px;
    font-family: Arial;
}
ul{
    padding: 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}
nav ul li{
    list-style: none;
    margin: 0 25px;
    display: inline-flex;

}

nav ul li a{
    text-decoration: none;
    color: #444;
    font-weight: bold;
    justify-self: center;

}

 nav ul li a:hover{
    color: #d02e10;
    background-color: #d02e10;
    color: white;
    border-radius: 5px;
    transition: .3s ease all;
    padding-left: 5px;
    padding-right: 5px;

 }

a{
    text-decoration: none;

}
<!DOCTYPE html>

    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="estilos.css">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title> Caracteristicas Claro</title>

            INICIO

            SAMSUNG

            APPLE

            HUAWEI

            XIAOMI

            MOTOROLA

            HONOR

            OPPO

            REALME

            VIVO

            ZTE

            COOLPAD

Equipos


text:
Q: Guarda de rotas no Ionic é possível? Atualmente estou fazendo a segurança da minhas rotas no ngOnInit, se tiver no localStorage a chave token, então ele permanece na rota Home (Minha rota root é a home). Caso contrário, ele redireciona para a tela de login.
O problema é que tem um delay, a tela Home é mostrada durante alguns milisegundos e depois troca para a tela de Login.
Já tentei no constructor/ngOnInit e também no appcomponen.ts assim que a plataforma é pronta, porém dessa maneira eu continuo tendo uma "piscada" na tela.
Alguém tem alguma solução para isso?

A: [EDITADO] - Fiz em ionic 3 para voce. Faz isso no seu app.component.ts
Eu estou usando Ionic 4, no meu arquivo app-routing.module.ts eu uso em Guarda de Rotas para verificar se o usuário tem alguma informação salva no local storage, caso tenha eu redireciono para a home ou se não tiver eu mando ele para login. Segue a logica.
import { Component, ViewChild } from '@angular/core';
import { Platform, Nav, ToastController } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { SharedData } from '../providers/shared-data';
import { ClientStorage } from '../database/client-storage';

@Component({
    templateUrl: 'app.html'
})
export class MyApp {
    @ViewChild(Nav) nav: Nav;
    rootPage: any;

    constructor(
        public platform: Platform,
        public statusBar: StatusBar,
        public splashScreen: SplashScreen,
        public sharedData: SharedData,
        private clientStorage: ClientStorage,
    ) {
            this.clientStorage.buscaRealizada.then(() => {
                statusBar.styleDefault();
                splashScreen.hide();
                if (this.clientStorage.data.UserId)
                    this.rootPage = 'HomePage';
                else
                    this.rootPage = 'LoginPage';
            });
        });
    }
}

A: Sim, existe outra solução melhor. Você pode dar uma lida nos Lifecycle events na documentação do IONIC. No seu caso, vc pode usar o ionViewCanEnter. Antes da página ser criada, ele vai verificar sua lógica. Se o usuario tiver acesso, sua logica retorna true e cria a pagina a ser acessada, se não retorna false.
Veja este tutorial
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';

@Component({
  selector: 'page-a',
  templateUrl: 'a.html'
})
export class PageA{

  constructor(public navCtrl: NavController) {}

  ionViewCanEnter() {
    \\sua logica aqui. retorne true ou false.
  }
}


text:
Q: Closing the Form opened in another thread I'm getting some troubles with my Winforms C# app.
I wish to make form named Popup closing after some operations in main thread are done. The problem is an exception caused by cross-thread form closing.
private void loginButton_Click(object sender, EventArgs e)
{
    LoginProcess.Start();    // Running Form.show() in new thread
    ActiveAcc.IsValid = false;
    ActiveAcc.Username = userBox.Text;

    try
    {
        LoginCheck(userBox.Text, passBox.Text);
    }
    catch (IOException)
    {
        MessageBox.Show("..");
        return;
    }
    catch (SocketException)
    {
        MessageBox.Show("..");
        return;
    }

    if (ActiveAcc.IsValid)
    {
        MessageBox.Show("..");
        Close();
    }
    else
    {
        Popup.Close();      // Error caused by closing form from different thread
        MessageBox.Show("");
    }
}

public Login()             // 'Main' form constructor
{
    InitializeComponent();

    ActiveAcc = new Account();
    Popup = new LoginWaiter();
    LoginProcess = new Thread(Popup.Show);      //Popup is an ordinary Form
}

I've been trying to use various tools such as LoginProcess.Abort() or Popup.Dispose() to make it work properly, but even if app is working on runtime environment its still unstable due to Exceptions which are thrown.
I would be grateful for any help, and I am sorry for ambiguities in issue describing.

A: Why don't you let the UI thread do UI stuff like opening and closing Forms, and spawn the other thread (or background worker, or async task) to do the other stuff?
IMO, having other threads attempt to interact with elements on the UI thread (e.g., have a background thread directly set the text of a label or some such) is asking for heartache.
If you simply must keep your code as is, here is a fairly simple thing you could do. In Popup, add a static bool that defaults to true. Also in Popup, add a timer task that once every X milliseconds checks the status of that boolean. If it finds that the value has been set to false, let Popup tell itself to close within that timer tick.
I'm not crazy about this design, but it could look something like:
 public partial class Popup : Form
    {
        public static bool StayVisible { get; set; }

        private System.Windows.Forms.Timer timer1;

        public Popup()
        {
            StayVisible = true;
            this.timer1.Interval = 1000;
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);

            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (!StayVisible) this.Close();
        }

    }

Then, from another thread, when you want Popup to close, call
Popup.StayVisible = false;

Better yet, you would fire an event that Popup would receive so that it could close itself. Since you intend to use multiple threads, you'll have to deal with raising events cross-thread.


text:
Q: Calculating integral $ \int_L A \cdot dr$ I'm trying to solve an integral $ \int_L A  \cdot dr$, where $ L$ is $ r=1+t,\theta = \frac \pi 4, \phi = \pi t , t: 0 \to 2$ . Note that $r, \theta, \phi$ are spherical coordinates.
I have $$dr = h_r e_r dr + h_\theta e_\theta d\theta + h_\phi e_\phi d\phi$$
$$ dr = 1 \cdot e_r dr + r \cdot e_\theta d\theta + r \sin\theta \cdot e_\phi d\phi$$
$$ dr =  (e_r + (1+t)e_\theta + (1+t)\sin\frac \pi 4 e_\phi )dt$$
And here it is where I have a different answer than what was given by my solution sheet, which is $ dr = (e_r + \pi r \sin\theta e_\phi) dt $, which I do not understand where the $\pi$ came from, and also where the $e_\theta$ term went?

A: You have
$d\vec r = h_r \, e_r \, dr + h_\theta \, e_\theta \, d\theta + h_\phi \, e_\phi \, d\phi.$ Here we have $h_r = 1, \ h_\theta = r, \ h_\phi = r \sin\theta,$ and since $r=1+t, \ \theta = \frac \pi 4, \ \phi = \pi t$ we have $dr = dt, \ d\theta = 0 \, dt, \ d\phi = \pi \, dt.$ Summing up, we thus get
$$d\vec r = 1 \, e_r \, dt + r \, e_\theta \, 0 \, dt + r \sin\theta \, e_\phi \, \pi \, dt = (e_r + \pi \, r \sin\frac \pi 4 \, e_\phi) \, dt.$$
Thus, to answer your two questions, $\pi$ comes from the derivative of $\phi = \pi t$ and $e_\theta$ went away since $\theta$ is constant so $d\theta = 0.$


text:
Q: Difference Between *list and **list If I have a struct:
typedef struct A
{
   char c[100];
}A;

Then I create a
sizeOfA = 5000;
A *list = (A*) malloc(sizeOfA * sizeof(A));

Is list[i] a pointer to a struct?
Or if I want a pointer to the struct, should I do
A **list = (A**) malloc (sizeOfA * sizeof(A*);

[EDIT]
Now let's say I created the list using A *list (which I did already). How would I create 5000 pointers and make them point to the elements on the list?
p0 -> list[0]
p1 -> list[1]
..
..
p[n] -> list[n]

After going back and forth a few times I noticed that for sorting the pointers help a lot.
To be fair I will post the edit above as a separate question.

A: After this statement:
A *list = (A*) malloc(sizeOfA * sizeof(A));

list is a pointer to the starting location of a memory block that can hold sizeOfA elements of type struct A. Thus, *list is of type struct A, and similarly, list[i] is of type struct A, not pointer to struct A (that would be list+i).
If you want list[i] to be a pointer to struct A, then your second piece of code would be the correct one, since you're allocating a memory location with enough space to hold sizeOfA pointers to struct A. Note that you are only allocating space to hold pointers, not actual struct A instances. Attempting to read list[i]->c will result in undefined behavior.

A: A *list = (A*) malloc(sizeOfA * sizeof(A));
Is list[i] a pointer to a struct?

No -- list is a pointer to an address in the heap, which is the start of a memory chunk that has size sizeOfA * sizeof(A). list[i] is the same thing as *(list + i), which is a dereference that will give you an actual A.
However..
A **list = (A**) malloc (sizeOfA * sizeof(A*);
Is list[i] a pointer to a struct?

Yup.


text: Q: Virtual Machine using vmware to get windows OS and sql server 2012? Does a VM affect computer performance when it is shut down? I'm about to be taking Database Administration, and we're going to be using SQL server 2012, and I have a macbook, and an iMac. My MacBook has an i7 2.whatever GHz quad core processor, 16GB RAM, 750SSD... Is there anything I should be worried about? And what is the best Windows OS to run on my mac, that is compatible with sql server? I've never used all of this stuff, and I heard VM is probably better on my machine. If it does affect the performance on my computer when it's shut down, what's the best way to maintain the integrity of my machine, regardless whether the performance issues carry on or not, I'd like to know any maintenance suggestions from you guys. Thanks in advance!


text:
Q: I2C protocol speeds I'm trying to make a persistence of vision display (Example: https://www.youtube.com/watch?v=QAGnpKz7zvY) that will display images and videos. I have purchased an LED strip that has 72 LEDs that communicate over I2C. The goal is to implement a polar coordinate grid and light the LEDs up to the appropriate colors as it passes over the image. Upon my research for the project I've seen others saying I2C is a slow protocol.  My question is I2C appropriate for this application of high frequency color changes to 72 LEDs?

A: It seems that you have got a useful answer, but to the wrong question.
This isn't really an answer to what you should have asked, but it's too long for a comment and it does help you (and future readers) by explaining what you should be researching.
You asked about the I2C interface:

is I2C appropriate for this application of high frequency color changes to 72 LEDs?

However the Amazon product page for your LED strip, which you later mentioned in a comment, shows that this LED strip is a very common type which does not use I2C!
As kindly pointed out by "mmmm" in their comment, this is a WS2812B-based LED strip (see below image from that Amazon page, where I have highlighted the relevant text):

These (and similar addressable LEDs) use the "NeoPixel" protocol, which is different to I2C and has different timing requirements.
This is an example of an XY-problem. You asked about what you thought was the problem (I2C bus speed) but didn't reveal enough information, until later on, about the real device. Then we saw that I2C wasn't involved at all :-(
You can research terms like WS2812 protocol, or NeoPixel protocol, or WS2812 library (to see examples of other people's code). (Note that the WS2812B datasheet shows slightly timing to the WS2812 timing.)

A: OK, first of all there are at least three standard I2C speeds:

*

*Classic 100kHz (10µs bit time)

*Fast 400kHz (2.5µs bit time)

*High speed 3.4MHz (only the data phase is high speed, for simplicity 300ns bit time)

these works as normal bidirectional I2C buses (the high speed has a negotiation trick for compatibility and the transceiver is different but the capabilities are more or less the same)
There is altro another kind of I2C called Ultra Fast Mode which is I2C only in name since it's simplex (it can only send master to slave, there's not even an acknowledge slot). Ultra fast mode is actually designed for LED control and is pumped at 5 MHz (200ns bit time).
High speed and ultra fast mode are really niche protocols, there's only an handful of ICs supporting them. The bulk of I2C peripheral these days is fast mode.
Now, regardless on the protocol used (which is relevant for cabling, as commented), you can estimate your refresh rate. Of course it depends on the kind of protocol used, so the part number will be useful*!
Let's assume the absolutely best case, when the strip only requires one address bit and one byte for each LED (technically the extreme case would be one bit for led, but do not oversimplify).
Each byte on I2C takes 9 bit times: 8 data and one acknowledge slot. There's also a one-and-half-bit overhead for the start-stop-restart condition but let's ignore these.
So, one address plus 72 data bits would be 657 bit times, assuming you can pump the I2C controller fast enough (with DMA, for example). At fast speed (the most common these days) this would take slightly less than 16.5ms; it's hardly fast enough for a polar display; assuming a minimum of 24Hz of refresh rate (24 RPM) you would have… 2.5 polar strips for scan.
It will get better with greater bit packing and faster transmit modes, just redo the computations.


text:
Q: Nested formulas with error handling I have data and would like to use formulas to determine if the installed version is x86 or x64:
OSTYPE                                          SHORTPATH                                       VERSION     VERSIOND
Microsoft Windows 7 Enterprise Edition, 64-bit  C:\PROGRAM FILES (X86)\JAVA\JRE1.8.0_45\BIN\    8.0.45.14   8.0.45.14 x86
Microsoft Windows 7 Enterprise Edition, 64-bit  C:\PROGRAM FILES\JAVA\JRE1.8.0_66\BIN\          8.0.660.18  8.0.660.18 x64
Microsoft Windows 7 Enterprise Edition, 32-bit  C:\PROGRAM FILES\JAVA\JRE6\BIN\                 6.0.510.9   6.0.510.9 x86

The intent is that VERSIOND will contain the VERSION value and then append either x86 for a 32bit install or x64 for 64bit install.
If SHORTPATH contains "(x86)" then it's a 32bit install
If SHORTPATH doesn't contain "(x86)" and OSTYPE contains "64-bit" then it's a 64bit install
If SHORTPATH doesn't contain "(x86)" and OSTYPE contains "32-bit" then it's a 32bit install

I've almost got it working via:
=IF(ISERROR(SEARCH("(x86)";D2));IF(SEARCH("64-bit";C2)>0;CONCATENATE(E2;" x64");CONCATENATE(E2;" x86"));CONCATENATE(E2;" x86"))

Column C is OSTYPE, column D is SHORTPATH and column E is VERSION.
It works except when OSTYPE is 32-bit, and it's because of SEARCH("64-bit";C2)>0 returning #VALUE!'
How to add the second ISERROR for handling that error?

A: Assuming that you want the result in column E to be concatenated with " x86" if either SHORTPATH contains "(x86)" or OSTYPE contains 32-bit, otherwise you want it concatenated with " x64" you could use OR to describe when you want to use " x86" and not even explicitly search for "64-bit":
=IF(OR(NOT(ISERROR(SEARCH("(x86)",D2))),NOT(ISERROR(SEARCH("32-bit",C2)))),CONCATENATE(E2," x86"),CONCATENATE(E2," x64"))

The above was tested, but you seem to be using a regional setting which uses ; in place of ,, so I guess that would be:
=IF(OR(NOT(ISERROR(SEARCH("(x86)";D2)));NOT(ISERROR(SEARCH("32-bit";C2))));CONCATENATE(E2;" x86");CONCATENATE(E2;" x64"))

A: A shorter version:
=E2&" "&IF(AND(ISERROR(SEARCH("x86";D2));NOT(ISERROR(SEARCH("64-bit";C2))));"x64";"x86")


text:
Q: How does MetaPost compare to MetaFont, featurewise? I'm interested in possibly using MetaPost to design a font for a writing system of my own invention. One of the appeals of the Meta* languages is MetaFont's "pen" features. However, MetaFont itself is somewhat clunky to use and of course only outputs bitmap fonts, instead of vector. The problem is that it's unclear to me whether MetaPost actually has all of the same capabilities as MetaFont. There's MetaType1, which as I understand, does not include pen capabilities, and is based on MetaFont.
Incidentally, the workflow I have in mind is something like:
MetaPost --> PS --> FontForge --> OTF

A: You can indeed use Metapost to generate fonts.  Read the chapter called "MetaPost Versus METAFONT" in the appendix of the Metapost manual.  You need to use the mfplain macro package.  If you do something like
mpost -mem=mfplain cmr10.mf

MetaPost will produce a PostScript file for each character in the font.  But as it says in the manual, "some editing would be required in order to merge them into a downloadable Type 3 PostScript font".
Basically the combination of MetaPost + mfplain has all the administrative  features required for font making that are discussed in detail in the Metafont Book.  The only things it lacks, are all those features in MetaFont that are directly related to dealing with pixels.


text:
Q: Android Geolocation on webview I need to get the location of a user from within a webview and it's not asking me for permission to get the location. Below is my webview code:
WebView Setup
public void WebViewSettings(){

    webView = (WebView) findViewById(R.id.webview);
    webView.canGoBack();

    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setSupportZoom(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.setWebViewClient(new WebViewClientSetup());
    //webView.setWebChromeClient(new GeoWebChromeClient());
    webView.getSettings().setGeolocationEnabled(true);
    //webView.getSettings().setGeolocationDatabasePath( context.getFilesDir().getPath() );

    myTimer = new Timer();
    //Start this timer when you create you task
    myTimer.schedule(new loaderTask(), 20000);

}

WebChromeClient:
public class GeoWebChromeClient extends WebChromeClient {
    @Override
    public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
        callback.invoke(origin, true, false);
    }
}

WebViewClient:
public class WebViewClientSetup extends WebViewClient {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        return false;
    }

    @Override
    public void onLoadResource(WebView view, String url) {
        // Check to see if there is a progress dialog
        if (progressDialog == null) {
            progressDialog = new ProgressDialog(context);
            progressDialog.setTitle("Loading...");
            progressDialog.setMessage("Please wait.");
            progressDialog.setCancelable(true);
            progressDialog.setIndeterminate(true);
            progressDialog.show();
        }
    }

    @Override
    public void onReceivedSslError(WebView view, SslErrorHandler handler,
            SslError error) {
        handler.proceed();
    }

    @Override
    public void onPageFinished(WebView view, String url) {
        isPageLoadedComplete = true;
        View mapHeight = (View) findViewById(R.id.webview);
        int height = mapHeight.getHeight();
        Log.d("map height", "map height" + height);
        // Page is done loading;
        // hide the progress dialog and show the webview
        if (progressDialog.isShowing()) {
            progressDialog.dismiss();
        }
    }

    @Override
    public void onReceivedError(WebView view, int errorCod,
            String description, String failingUrl) {
        AlertDialog();
    }
}

it's not asking me for permission and I don't know why, can anyone see where I'm going wrong? Thanks in advance!

A: You should add the permissions that you want to use in your android-manifest.xml.
Add the following lines to the android-manifest.xml.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />


text:
Q: Spring Roo stackOverflow "getRuleContext" error when starting Roo Roos:
Running on Mac OSX using STS 3.2 and Spring Roo 1.2.4, when I start Roo for my project, after considerable delay (5 minutes or more), I will get this:
StackOverflowError at org.antlr.v4.runtime.ParserRuleContext.getRuleContext(ParserRuleContext.java:248)

After that, Roo seems to run fine and does its updates as expected when I modify a Java class, etc.
This error occurred for me in Roo 1.2.2 and 1.2.3.  It does not seem to otherwise be a problem, so I am tempted to ignore it.  However, does anyone know why I see this, or can anyone suggest what to do to remove it?
Thanks in advance.