Two-note-same-root chord progressions with the G and B strings

Question: I have a question regarding two note chord progressions on the G and B strings. I have noticed this in at least two songs:

The intro to Teacher's Pet in School of Rock

Tab courtesy of Guitar_Legend01
INTRO

e|-------------------------------------------|
B|7-7-7-8-8-10-8-7-|[8-8-8-7-7-8-8-----------|
G|7-7-7-7-7--7-7-7-|[7-7-7-7-7-7-7]----------| (x2)
D|-------------------------------------------|
A|-------------------------------------------|
E|-------------------------------------------|

The chords are D-F#, D-G, D-A. So technically, this is a D (root-3rd), Dsus4, D (root 5th) chord progression, with the two D chords being different inversions, correct?

The outro of Sum 41's In Too Deep (link is timestamped)

Tab courtesy of izak.atak
3:16

  {Gtr 2
e|---------------------------------------------|
B|--9-10-9-10-12-10-9-10--9-10-9-10-9----------|
G|--9-9--9-9--9--9--9-9---9-9--9-9--9-11-9-11--|
D|------------------------------------11-9-11--|
A|---------------------------------------------|
E|---------------------------------------------|

3:20

  {Gtr 2
e|-----------------------------------------------|
B|--9-10-9-10-12-10-9-10--9-10-9-10-9------------|
G|--9-9--9-9--9--9--9-9---9-9--9-9--9-11-9-11-9--|
D|------------------------------------11-9-11-9--|
A|-----------------------------------------------|
E|-----------------------------------------------|

The chords are E-G#, E-A, E-B. This would result in an E (root-3rd), Esus4, E (root-5th) chord progression, with the two E chords also being different inversions similar to the Teachers Pet intro, correct?

Another example that is slightly different is the into to Sum 41's Baby You Don't Wanna Know
Tabs courtesy of jake41
Intro (x6)

e|---------------------------------------------------------------------------|
B|---------------------------------------------------------------------------|
G|-5--7-7--5--7---5--7--5--7--5--7--5----------------------------------------|
D|-5--7-7--5--7---5--7--5--7--5--7--5--7-------------------------------------|
A|-------------------------------------7-------------------------------------|
E|---------------------------------------------------------------------------|

This riff also uses the 4th but does so using the D and G string so it is the 4ths that are stacked and not the 3rd.

My question is this: Is there any theory behind this progression of using inversions and suspended chords, or does this technique have a name? Is there something inherent about the 4th that creates tension in between the inverted major chords? The tuning of the B string makes these types of progressions/riffs super easy to play (as the root and third are stacked plus the sus4th and 5th are one fret closer) and they are fun to explore in different keys and melodies. It has a very punchy, vibrant sound to it which fascinates me. I have noticed it in other songs but these two examples really resonate with me. Even using this strategy with different strings like the D and G strings in the third example is captivating when the root and 4th are stacked.
Also, if anyone has other cool examples of this, please feel free to share in your response to my questions if it helps drive the point across.
NOTE: IF YOU THINK THESE TABS ARE WRONG, PLEASE REFRAIN FROM POINTING THAT OUT, AS THAT IS NOT WHAT MY QUESTION IS. IF YOU DISAGREE, PLEASE DO NOT ANSWER OR SIMPLY ANSWER MY QUESTION UNDER THE ASSUMPTION THESE TABS ARE CORRECT.
EDIT: Grammar
Answer: The best description for your first two examples is that there is a pedal point. That's the idea that one pitch is repeated throughout a section, while another "voice" moves around, creating different intervals against it. I wouldn't worry about analyzing each interval that is created as a separate "chord" (for one thing, you'd be extrapolating from just two notes!); rather, I'd just go with the analysis "there's a pedal point under this melody."
It's been a very popular device throughout history and across genres. Here's an example from the famous Bach(?) Toccata and Fugue in D minor:

In this case the organists sticks the repeated As "in between" the moving notes, but the effect is similar.
Or, in the opening bars of Van Halen's "Jump," the bass and synth left hand stay parked on the tonic note as the right hand creates chords above it, only budging for the cadence:

Meanwhile, the "Baby You Don't Wanna Know" excerpt simply uses parallel fourths. It isn't really related, except: it only moves by occasionally briefly visiting the step below, so it sort of "counts" as a sustained pitch. And once the vocals enter, they "move around" above it, so there's sort of a "pedal point" of the guitar's parallel 4ths riff under the vocal melody.
Answer:
The chords are D-F#, D-G, D-A. So technically, this is a D (root-3rd),
Dsus4, D (root 5th) chord progression, with the two D chords being
different inversions, correct?

Not quite.  The lower note is always D.  So, if we choose to name these incomplete chords as if they were variations of a D major triad, they're not different inversions, rather all root position.
Full descriptions would be D(omit5), Dsus4(omit5), D (omit3), or, for the last one just D5 - though that has connotations of a 'power chord' which this isn't really.
You can think of the sequence as named chords.  Or as a melody over a constant D pedal.  The 1st and 3rd intervals/chords are consonant, the 2nd is less stable.
Answer: Without having heard the song, I'd call it D, G/D, D. Partial chords with the high notes forming a sort of melody line over the pedal D. The actual melody line and other instruments may change that.


Views: Add class to body based on Views

Question: In Drupal, every Views page has a class that is stored in $css_name (inside views-view.tpl.php).
Is there are any way to get this class to appear in the body class of the page?
Ideally, I would like to prefix it with page- (So views-index, would become page-views-index). I would also like to do it without install extra modules.
Answer: Two simple ways I might approach this:

Context Module
jQuery

1) Context Module: create a new context where Condition is "Views" (select the appropriate view) and the Reaction is "Theme HTML" (add the class you want to display in the body there).
Cons: the class is not dynamic, unfortunately. Or at least I have not investigated any way to make dynamically name the class (i.e. page-[node:field_field_yourfieldvalue]). Because of this, you will most likely need to create a new context for each variation if you choose this approach.
2) jQuery: if you want to get the classes in views and add an altered version of these classes to the body tag, then you could use some javascript to pull that off. Something to the effect of this might work:
var myClasses = $(.view-name).attr('class');

$('body').addClass(myClasses);

Something like that, just cleaned up. Hope that helps :)
Answer: You can do something like that:
function THEMENAME_preprocess_html(&$vars) {
  if ($the_view = views_get_page_view()) {
   $vars['classes_array'][] = 'views-' . $the_view->name;
  }
}

Views: Add class to body based on Views


Validação com JSF

Question: Quero realizar a validação do formulário exibido na imagem de uma forma diferente da que o framework me impõe. A validação seria algo como um alerta, ou seja, o usuário seria informado de que só pode adicionar dados se selecionar uma opção do combo. Essa validação deve ocorrer após o clique no botão Adicionar. Algo como: "Selecione uma opção antes de adicionar". Isso é possível sem uso de JavaScript? Como fazer?
Answer: Tem como fazer o que você quer.
Primeiramente adicione isso no seu XHTML:

Em seguida, no método disparado pelo botão Adicionar, após fazer a devida validação, adicione a seguinte linha de código para disparar uma mensagem na página:
FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_INFO, "Mensagem", "Descrição");
FacesContext.getCurrentInstance().addMessage(null, facesMessage);

Para maiores detalhes, clique aqui.
Answer: Você pode fazer isso utilizando o Primefaces.
No seu SelectOneMenu teria as seguintes propriedades:

uma property chamada required="true" que diria que o campo é obrigatório.
uma property chamada requiredMessade="Sua mensagem" onde você diria qual mensagem você quer adicionar.

Acima do seu form teria um campo de mensagens para ser mostradas, que poderia ser assim:

No seu botão precisaria adicionar as seguintes propriedades:

ajax="true" para fazer a validação utiliando o ajax.
immediate="false" (caso for true ele não fará as validações de tela)

Ou caso você não queira utilizar o primefaces, poderia colocar após o clique do botão, no seu Bean, uma mensagem utilizando o Faces, dessa forma:
FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_INFO, "Qual a mensagem", "O que dizer na mensagem");

Qualquer dúvida você pode checar no próprio site do primefaces:
http://www.primefaces.org/
Comment: Olá @Dante, o atributo "ajax" vem definido com "true" por padrão mano.
Comment: @ColdHack é verdade, não lembrei desse detalhe, mas a informação foi passada pelo menos. Obrigado pela correção!

Validação com JSF


Copy & paste is stalling my macro

Question: I have a macro which takes data from one workbook, filters the fairly large page down to the data i require only, then copies values to a dummy sheet in my main workbook where non required rows are removed and columns are sorted into an order more suitable for my application.
my problem is it takes an age to complete and quite often crashes.
I am still new to VBA and have tried my best to slicken the code but am not getting anywhere. I have used F8 to define the areas which slow it up and they are the filtering, copy/paste and cut/insert. If anyone can help it would be greatly appreciated.
Thanks in advance
M
`Sub NEW_OPS_AWAY_REPORT()

MsgBox ("BOTTLENECKS AND OPS AWAY SPREADSHEET & GEARSHOP WORK TO LIST FROM REPORT CENTRE MUST BE OPEN FOR THIS REPORT TO FUNCTION CORRECTLY")

Application.Calculation = xlCalculationManual

Application.ScreenUpdating = False

Application.DisplayStatusBar = False

Application.EnableEvents = False

ActiveSheet.DisplayPageBreaks = False

Windows("DAILY BOTTLENECKS ANALYSIS & OPS AWAY.xlsm").Activate
Sheets("WIP by Op").Visible = True
Sheets("WIP by Op").Range("$A$1:$Q$47290").AutoFilter Field:=1, Criteria1:="TS1H124*", Operator:=xlFilterValues
Windows("PRESS QUENCH FIRST OFF DATABASE.xlsm").Activate
Sheets("REPORT DATA TRANSFER").Visible = True
Sheets("REPORT DATA TRANSFER").Select
Cells.Select
Selection.ClearContents
Windows("DAILY BOTTLENECKS ANALYSIS & OPS AWAY.xlsm").Activate
Sheets("WIP by Op").Select
Cells.Select
Selection.Copy
Windows("PRESS QUENCH FIRST OFF DATABASE.xlsm").Activate
ActiveSheet.Paste
Range("F:F,G:G,H:H,M:M,P:P,Q:Q").Select
Range("Q1").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Columns("A:K").Select
Columns("A:K").EntireColumn.AutoFit
Columns("J:J").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Columns("I:I").Select
Selection.Cut
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Columns("J:J").Select
Selection.Cut
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Columns("G:G").Select
Selection.Cut
Columns("D:D").Select
Selection.Insert Shift:=xlToRight
Columns("H:H").Select
Selection.Cut
Columns("E:E").Select
Selection.Insert Shift:=xlToRight
Columns("H:H").Select
Selection.Cut
Columns("F:F").Select
Selection.Insert Shift:=xlToRight
Columns("J:J").Select
Selection.Cut
Columns("I:I").Select
Selection.Insert Shift:=xlToRight
Application.Calculation = xlCalculationAutomatic
Range("A1:K1").Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("REPORT DATA TRANSFER").AutoFilter.Sort.SortFields. _
    Clear
ActiveWorkbook.Worksheets("REPORT DATA TRANSFER").AutoFilter.Sort.SortFields. _
    Add Key:=Range("A1"), SortOn:=xlSortOnValues, Order:=xlAscending, _
    DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("REPORT DATA TRANSFER").AutoFilter.Sort
    .header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
End With
Sheets("Ops Away Report").Select
Columns("A:K").Select
Selection.ClearContents
Sheets("REPORT DATA TRANSFER").Select
Columns("A:K").Select
Selection.Copy
Sheets("Ops Away Report").Select
Range("A1").Select
ActiveSheet.Paste
Range("A:A,E:E,F:F,I:I,J:J").Select
Range("J1").Activate
Application.CutCopyMode = False
With Selection
    .HorizontalAlignment = xlCenter
    .VerticalAlignment = xlBottom
    .WrapText = False
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .MergeCells = False
End With
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
    .LineStyle = xlContinuous
    .ColorIndex = 0
    .TintAndShade = 0
    .Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
    .LineStyle = xlContinuous
    .ColorIndex = 0
    .TintAndShade = 0
    .Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
    .LineStyle = xlContinuous
    .ColorIndex = 0
    .TintAndShade = 0
    .Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
    .LineStyle = xlContinuous
    .ColorIndex = 0
    .TintAndShade = 0
    .Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
    .LineStyle = xlContinuous
    .ColorIndex = 0
    .TintAndShade = 0
    .Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
    .LineStyle = xlContinuous
    .ColorIndex = 0
    .TintAndShade = 0
    .Weight = xlThin
End With
Range("A1:L1").Select
Selection.AutoFilter
Columns("B:B").Select

Sheets("REPORT DATA TRANSFER").Visible = False

Dim lastRow As Long

lastRow = Range("A2").End(xlDown).Row

For Each Cell In Range("A2:Q" & lastRow) ''change range accordingly
If Cell.Row Mod 2 = 1 Then ''highlights row 2,4,6 etc|= 0 highlights 1,3,5
    Cell.Interior.ColorIndex = 34 ''color to preference
Else
    Cell.Interior.ColorIndex = xlNone ''color to preference or remove
End If
Next Cell

Columns("D:D").EntireColumn.AutoFit
Columns("H:H").ColumnWidth = 7.43
Range("A1:O1").AutoFilter

Application.Calculation = xlCalculationAutomatic

Application.ScreenUpdating = True

Application.DisplayStatusBar = True

Application.EnableEvents = True

ActiveSheet.DisplayPageBreaks = True

End Sub`
Comment: I believe the `.Select` `.Activate` is probably contributing to some of the slowness. `Application.ScreenUpdating = False` is already present in the code. There's a lot happening in this code. Is there any particular block of it that is causing it to run long?
Comment: If you are only copying values then ditch copy/paste entirely and just assign directly to the `.Value` property of the target range.
Comment: Start by using `Application.ScreenUpdating = False` at the beginning of your macro (and reset it to `True` and the end). Then read up on [how to avoid using `Select` in your macro](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba#10717999)
Comment: In particular, this section causes the first long waiting period when single blocking through the code.'Sheets("WIP by Op").Range("$A$1:$Q$47290").AutoFilter Field:=1, Criteria1:="TS1H124*", Operator:=xlFilterValues
Windows("PRESS QUENCH FIRST OFF DATABASE.xlsm").Activate
Sheets("REPORT DATA TRANSFER").Visible = True
Sheets("REPORT DATA TRANSFER").Select
Cells.Select
Selection.ClearContents
Windows("DAILY BOTTLENECKS ANALYSIS & OPS AWAY.xlsm").Activate
Sheets("WIP by Op").Select
Cells.Select
Selection.Copy
Windows("PRESS QUENCH FIRST OFF DATABASE.xlsm").Activate
ActiveSheet.Paste'
Answer: Looking through your code there's a lot of extra code in there.
For instance, adding a border around each cell can be done with Selection.Borders.LineStyle = xlContinuous
This code starts with the two workbooks closed.  Update the Const variables with the correct file paths.
You'll probably need to disable events still, depending on what code's in the other workbooks.
Public Sub New_Ops_Away_Report()

    Const BottleNecks_Path As String = "C:\Somefolder\DAILY BOTTLENECKS ANALYSIS & OPS AWAY.xlsm"
    Const OpsAway_Path  As String = "C:\Somefolder\PRESS QUENCH FIRST OFF DATABASE.xlsm"

    Dim wrkBk_BottleNeck As Workbook
    Dim wrkbk_OpsAway As Workbook

    Dim rWIP_LastCell As Range
    Dim rReport_LastCell As Range

    Set wrkBk_BottleNeck = Workbooks.Open(Filename:=BottleNecks_Path)
    Set wrkbk_OpsAway = Workbooks.Open(Filename:=OpsAway_Path)

    'Clear the contents of the named sheet.
    wrkbk_OpsAway.Worksheets("REPORT DATA TRANSFER").Cells.ClearContents

    With wrkBk_BottleNeck
        'Find the last populated cell on the worksheet.
        Set rWIP_LastCell = LastCell(.Worksheets("WIP by OP"))
        With .Worksheets("WIP by OP")
            With .Range(.Cells(1, 1), rWIP_LastCell)
                'Add a filter from A1 to the last populated cell.
                .AutoFilter Field:=1, Criteria1:="TS1H124*", Operator:=xlFilterValues
                .Copy Destination:=wrkbk_OpsAway.Worksheets("REPORT DATA TRANSFER").Range("A1")
            End With
        End With
    End With

    With wrkbk_OpsAway.Worksheets("REPORT DATA TRANSFER")

        ''''''''''''''''''''''''
        'This bit is confusing in your code.
        'I think it's trying to do as below, but I've commented out the last line
        'as it appears to clear the data you just copied over.
        .Range("F:F,G:G,H:H,M:M,P:P,Q:Q").Delete Shift:=xlToLeft
        .Columns("A:K").EntireColumn.AutoFit
        '.Columns("A:J").EntireColumn.ClearContents
        ''''''''''''''''''''''''

        'Find last populated cell on the worksheet.
        Set rReport_LastCell = LastCell(wrkbk_OpsAway.Worksheets("REPORT DATA TRANSFER"))

        With .Sort
            .SortFields.Clear
            .SortFields.Add Key:=Range("A1").Resize(rReport_LastCell.Row), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
            .SetRange wrkbk_OpsAway.Worksheets("REPORT DATA TRANSFER").Range("A1").Resize(rReport_LastCell.Row, rReport_LastCell.Column)
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With

        .Range("A1").Resize(rReport_LastCell.Row, rReport_LastCell.Column).Borders.LineStyle = xlContinuous

    End With

End Sub

Public Function LastCell(wrkSht As Worksheet, Optional Col As Long = 0) As Range

    Dim lLastCol As Long, lLastRow As Long

    On Error Resume Next

    With wrkSht
        lLastCol = .Cells.Find("*", , , , xlByColumns, xlPrevious).Column
        lLastRow = .Cells.Find("*", , , , xlByRows, xlPrevious).Row

        If lLastCol = 0 Then lLastCol = 1
        If lLastRow = 0 Then lLastRow = 1

        Set LastCell = wrkSht.Cells(lLastRow, lLastCol)
    End With
    On Error GoTo 0

End Function

Comment: Much appreciated. I'm still having problems though. i would normally run the macro from a button in the 'ops away' worksheet. the code you kindly gave me looks to open the worksheet that will receive the data and also the one that will send it. i have tried the code in a blank WB with the other WB's closed and it doesn't complete and results in me having to force excel to close. i have tried some amendments but with my low skill level I am not getting anywhere. Thank you in advance for any further help that can be given.
Comment: If the code is in the `OpsAway_Path` workbook I think the easiest change will be to this line:  `Set wrkbk_OpsAway = Workbooks.Open(Filename:=OpsAway_Path)` to `Set wrkbk_OpsAway =ThisWorkbook`.  `ThisWorkbook` always refers to the file that contains the code.

Copy & paste is stalling my macro


Teaming a 4-port NIC with a on-board NIC?

Question: Is there any reason NOT to team a high quality 4-Port NIC with one of the on-board ports on the motherboard?
I am considering adding one of the on-board ports to the 4-Port for redundancy, but I wanted to make sure that it would not impact performance negatively at all.
Answer: You can team across onboard and expansion adapters without consequence. But it really depends on what you're trying to protect against.
In general, NIC failure is pretty rare, and if your onboard server NIC or NICs go bad, you likely have bigger problems that would entail unplanned service disruptions.
Comment: Well the ports are there, so I thought it wouldn't be a bad idea  to add one to protect against NIC failure. So then on the rare chance it does happen, we can still have a functioning server until we can bring it down to remedy the problem. I just wanted to make sure that adding the on-board NIC link to the faster dedicated NIC card wouldn't have any negative consequences.
Comment: For onboard NICs, the problem is rarely isolated to the interfaces alone. You're typically talking about a system board replacement. That's why I don't think this method of teaming is a useful means of protection. However, that said, there's absolutely no harm in doing so.
Comment: You can't always team across adapters depending what OS you are running and what adapters are installed. For example, prior to Windows 2012's built in teaming, you had to use 3rd party teaming software which didn't always play nicely together across different NIC chipsets.
Comment: @Rex I assumed Linux.


PromiseKit.framework: bundle format unrecognized, invalid, or unsuitable

Question: Until now our project and all associated pods have been in objective c. We wanted to use the latest version of PromiseKit and so added use_frameworks! to our podfile.  Before adding PromiseKit to the PodFile, I confirmed the project runs. After adding PromiseKit to the podfile, I get a 'Command /bin/sh failed with exit code -1' saying 'PromiseKit.framework: bundle format unrecognized, invalid, or unsuitable.'
sent 2733061 bytes  received 98 bytes  5466318.00 bytes/sec
total size is 2732456  speedup is 1.00
Code Signing /Users/bryanboyko/XCode/HereOne-iOS/HereOne/Build/Products/Debug-iphoneos/HereOne.app/Frameworks/Parse.framework with Identity iPhone Developer: Bryan Boyko (2J2F768B2X)
/usr/bin/codesign --force --sign 453628556ADD8E5593F102CEF9634DB02042AA98  --preserve-metadata=identifier,entitlements "/Users/bryanboyko/XCode/HereOne-iOS/HereOne/Build/Products/Debug-iphoneos/HereOne.app/Frameworks/Parse.framework"
/Users/bryanboyko/XCode/HereOne-iOS/HereOne/Build/Products/Debug-iphoneos/HereOne.app/Frameworks/Parse.framework: replacing existing signature
rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "/Users/bryanboyko/XCode/HereOne-iOS/HereOne/Build/Products/Debug-iphoneos/PromiseKit.framework" "/Users/bryanboyko/XCode/HereOne-iOS/HereOne/Build/Products/Debug-iphoneos/HereOne.app/Frameworks"
building file list ... done
PromiseKit.framework/

sent 102 bytes  received 26 bytes  256.00 bytes/sec
total size is 0  speedup is 0.00
Code Signing /Users/bryanboyko/XCode/HereOne-iOS/HereOne/Build/Products/Debug-iphoneos/HereOne.app/Frameworks/PromiseKit.framework with Identity iPhone Developer: Bryan Boyko (2J2F768B2X)
/usr/bin/codesign --force --sign 453628556ADD8E5593F102CEF9634DB02042AA98  --preserve-metadata=identifier,entitlements "/Users/bryanboyko/XCode/HereOne-iOS/HereOne/Build/Products/Debug-iphoneos/HereOne.app/Frameworks/PromiseKit.framework"
/Users/bryanboyko/XCode/HereOne-iOS/HereOne/Build/Products/Debug-iphoneos/HereOne.app/Frameworks/PromiseKit.framework: bundle format unrecognized, invalid, or unsuitable
Command /bin/sh failed with exit code 1

After removing DerivedData, Pods, .xcworkspace, and Podfile.lock, and then pod installing, this error still occurs.
Answer: Try pod deintegrate, it worked for me to solve weird problems when I was migrating a project to use_frameworks!.
$ pod deintegrate Project.xcodeproj
$ pod install

I have documented the problems I had and how I fixed them here.
Answer: I have the same error by other framework after upgraded to Xcode 8.3.1. Solved by removing ~/Library/Developer/Xcode/DerivedData/


At most finite elements of the sequence $\{x_{n}\}_{n\in \mathbb{Z}^+}$ is nonzero under certain conditions.

Question: Let $\{x_{n}: n\in \mathbb{Z}_{+}\}$ be a sequence of complex numbers such that $$\sum\limits_{p\in \mathbb{Z}_{+}}\vert x_{p} \vert^2=1$$ and
$$\sum\limits_{p\in \mathbb{Z}_{+} }x_{p} \overline{x_{p+r}}=0~~ \text{for all}~~ r\geq 1.$$
Does it imply at most finitely many $x_{p}$ can be non zero. Can you please provide  ideas how to solve this?
Any help is appreciated. Thank you in advance!
Comment: I don't have an answer, but if only finitely many $x_p$ are nonzero, then only one is nonzero. Because if $x_{p_1},\ldots,x_{p_m}$ are nonzero, then $$\sum_k x_k\overline{x_{k+(p_m-p_1)}}=x_{p_1}\overline{x_{p_m}}\ne0.$$
Comment: Dear Martin, thanks for sharing your thoughts.  I also don't have any idea how to tackle this question.
Answer: There is a counterexample to your question.
Set $x_{1}=1$.
For $n \geq 2$ set $x_{n} = q^{n-2}$ where $q = \frac{1-\sqrt{5}}{2}$
Note that $\sum_{j=1}^{\infty}|x_{j}|^2 = 1+\sum_{k=0}^{\infty}q^{2k} = 1+\frac{1}{1-q^2}= \frac{\sqrt{5}+3}{2} = 1+\phi$
Thus $(\frac{1}{\sqrt{1+\phi}}x_{j})_{j=1}^{\infty}$ is a normalized sequence.
We claim that $(\frac{1}{\sqrt{1+\phi}}x_{j})_{j=1}^{\infty}$ is a $\textbf{counterexample}$. We can ignore the normalization factor $\frac{1}{\sqrt{1+\phi}}$ for the computation below.
For $r \geq  1,$ $\sum_{j=1}^{\infty}x_{j}\overline{x_{j+r}}$ is
$$(q^{r-1})+\sum_{j=2}^{\infty}q^{j-2}q^{r+j-2}$$
$$ =  q^{r-1} + \sum_{k=0}^{\infty}q^{r+2k}$$
$$ = q^{r-1}+q^{r}\frac{1}{1-q^{2}}$$
$$ = q^{r-1}(\frac{1-q^2+q}{1-q^2})$$
Note $1-q^2+q = 0$ by wolfram alpha, thus the above quantity is $0$.
$(\frac{1}{\sqrt{1+\phi}}x_{j})_{j=1}^{\infty}$ is a $\textbf{counterexample}$ to your question.
Comment: Using "by wolfram alpha" as an argument here seems strange
Comment: Yeah...I just wanted to make sure


how to validate against a schema in Vala

Question: I'm want to parse a xml file into a Xml.Doc object and validate it against a schema file in Vala. Does Vala provide this functionality? I've searched http://valadoc.org, but I cannot find anything.
I would expect the following C functions to be available in Vala:

xmlSchemaParserCtxtPtr parser_ctxt = xmlSchemaNewDocParserCtxt(schema_doc);
xmlSchemaPtr schema = xmlSchemaParse(parser_ctxt);
xmlSchemaValidCtxtPtr valid_ctxt = xmlSchemaNewValidCtxt(schema);

I can only find the third one, SchemaValidCtxt mentioned in valadoc, but the page is virtually blank. Is this a valid usable class?
Answer:
I'm want to parse a xml file into a Xml.Doc object and validate it against a schema file in Vala. Does Vala provide this functionality? I've searched http://valadoc.org, but I cannot find anything.

If you're looking for the Vala equivalent of a C function in libxml you can just search libxml-2.0.vapi and look for the cname.  Valadoc.org does not currently allow you to search for C symbols, though AFAIK the feature is planned.

I would expect the following C functions to be available in Vala:

xmlSchemaParserCtxtPtr parser_ctxt = xmlSchemaNewDocParserCtxt(schema_doc);
xmlSchemaPtr schema = xmlSchemaParse(parser_ctxt);
xmlSchemaValidCtxtPtr valid_ctxt = xmlSchemaNewValidCtxt(schema);

The libxml-2.0 Vala bindings are pretty incomplete and nobody wants to work on them since the C API is really messy.  Usually what ends up happening is someone comes along and needs something specific so they add it and submit a patch.  Apparently you're the first person to need support for XML Schemas.
xmlSchemaNewDocParserCtxt is bound as Xml.ParserCtxt.ParserCtxt.create_doc.  The other two functions are not currently bound, though it's not very difficult to bind them.  Adding something like this (completely untested) to the libxml-2.0 VAPI should do the trick:
<code>    [Compact]
    [CCode (cname = "xmlSchema", free_function = "xmlSchemaFree", cheader_filename = "libxml/xmlschemas.h")]
    public class Schema {
        [CCode (cname = "xmlSchemaDump", instance_pos = -1)]
        public void dump (GLib.FileStream output);
    }

    [Compact]
    [CCode (cname = "xmlSchemaParserCtxt", free_function = "xmlSchemaFreeParserCtxt", cheader_filename = "libxml/xmlschemas.h")]
    public class SchemaParserCtxt {
        [CCode (cname = "xmlSchemaNewParserCtxt")]
        public SchemaParserCtxt (string URL);
        [CCode (cname = "xmlSchemaNewDocParserCtxt")]
        public SchemaParserCtxt.from_doc (Xml.Doc doc);
        [CCode (cname = "xmlSchemaNewMemParserCtxt")]
        public SchemaParserCtxt.from_buffer (uint8[] buffer);
        [CCode (cname = "xmlSchemaParse")]
        public Xml.Schema parse ();
    }

    [Compact]
    [CCode (cname = "xmlSchemaValidCtxt", free_function = "xmlSchemaFreeValidCtxt", cheader_filename = "libxml/xmlschemas.h")]
    public class SchemaValidCtxt {
        public SchemaValidCtxt (Xml.Schema schema);
    }
</code>

I can only find the third one, SchemaValidCtxt mentioned in valadoc, but the page is virtually blank. Is this a valid usable class?

It is just an empty shell right now--none of the methods are bound.  Luckily, adding bindings is pretty easy.


Changing Word Icon in Top Left of FileDialog

Question: Is there a way to change the Microsoft Word Icon when using the FileDialog in VBA?
Reason being is that I am using the Dialog to select files another than a Word Document (or Excel when using Excel VBA).
See image below for visual of the Icon.
Answer: The FileDialog doesn't allow you to do this.  However you can use the Common File Dialog instead.  This involves a bit more work, and a call to the Win API.
First you will need to declare the API GetOpenFileName.
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long

Then you will need to declare the OPENFILENAME structure.  This allows you to configure the dialog.
   Private Type OPENFILENAME
     lStructSize As Long
     hwndOwner As Long
     hInstance As Long
     lpstrFilter As String
     lpstrCustomFilter As String
     nMaxCustFilter As Long
     nFilterIndex As Long
     lpstrFile As String
     nMaxFile As Long
     lpstrFileTitle As String
     nMaxFileTitle As Long
     lpstrInitialDir As String
     lpstrTitle As String
     flags As Long
     nFileOffset As Integer
     nFileExtension As Integer
     lpstrDefExt As String
     lCustData As Long
     lpfnHook As Long
     lpTemplateName As String
   End Type

Using these two objects you can call the common dialog like this:
Private Sub Example()
    Dim OpenFile As OPENFILENAME
    Dim lReturn As Long
    Dim sFilter As String

    'Configure the dialog.
    OpenFile.lStructSize = Len(OpenFile)
    sFilter = "Batch Files (*.bat)" & Chr(0) & "*.BAT" & Chr(0)
    OpenFile.lpstrFilter = sFilter
    OpenFile.nFilterIndex = 1
    OpenFile.lpstrFile = String(257, 0)
    OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
    OpenFile.lpstrFileTitle = OpenFile.lpstrFile
    OpenFile.nMaxFileTitle = OpenFile.nMaxFile
    OpenFile.lpstrInitialDir = "C:\"
    OpenFile.lpstrTitle = "Use the Comdlg API not the OCX"
    OpenFile.flags = 0

    ' Call the dialog.
    lReturn = GetOpenFileName(OpenFile)

    ' Inspect the result.
    If lReturn = 0 Then
       MsgBox "The User pressed the Cancel Button"
    Else
       MsgBox "The user Chose " & Trim(OpenFile.lpstrFile)
    End If
End Sub

EDIT: In my original answer I didn't explain how to add an icon to the dialog.  This is done by setting the HwndOwner property of the OpenFileName structure.  The Dialog will pickup the icon of the passed windows handle (hwnd).
Comment: How would I go about adding a specific icon before the Title?
Comment: I've edited my answer to include an explanation.  You might also want to read this: http://www.cpearson.com/excel/SetIcon.aspx.  It details how to change the icon of a running app, which would then be used by the Common File Dialog.
Comment: Thanks, I used the script in the **cpearson** link to find the hwndOwner number for my desired App and I then assigned it with the `OpenFile.hwndOwner`
Comment: Correction. Once I use the script link to assign my desired icon to Excel, I can then use that assigned number for my OpenFile.hwndOwner, but I can seem to get it to work without assigning it to Excel first.


Prove $\frac{\partial (x,y,z)}{\partial (u,v,w)}\frac{\partial (u,v,w)}{\partial (x,y,w)}=1$

Question: If $$x=f(u,v,w)$$
$$y=g(u,v,w)$$
$$z=h(u,v,w)$$
Provided $\frac{\partial(x,y,z)}{\partial(u,v,w)\neq 0}$, prove $$\frac{\partial (x,y,z)}{\partial (u,v,w)}\frac{\partial (u,v,w)}{\partial (x,y,w)}=1$$
I tried to use the property of determinant, if for matrix
$$M=AB$$
then
$$det(M)=det(A)det(B)$$
So I want to prove that the product of these two Jacobian equals the determinant of the product of these two matrix. I wish the later one would be easier, but I did not go anywhere... Any help? Thanks~
Answer: We can write the differential system that describes the transformation from $(u,v,w)$ to $(x,y,z)$ in matrix form as
$$\begin{bmatrix} dx\\dy\\dz \end{bmatrix}=\begin{bmatrix} \frac{\partial x}{\partial u}&\frac{\partial x}{\partial v}&\frac{\partial x}{\partial w}\\\frac{\partial y}{\partial u}&\frac{\partial y}{\partial v}&\frac{\partial y}{\partial w}\\\frac{\partial z}{\partial u}&\frac{\partial z}{\partial v}&\frac{\partial z}{\partial w} \end{bmatrix}\begin{bmatrix} du\\dv\\dw \end{bmatrix} \tag 1$$
and the differential system that describes the inverse transformation as
$$\begin{bmatrix} du\\dv\\dw \end{bmatrix}=\begin{bmatrix} \frac{\partial u}{\partial x}&\frac{\partial u}{\partial y}&\frac{\partial u}{\partial z}\\\frac{\partial v}{\partial x}&\frac{\partial v}{\partial y}&\frac{\partial v}{\partial z}\\\frac{\partial w}{\partial x}&\frac{\partial w}{\partial y}&\frac{\partial w}{\partial z} \end{bmatrix}\begin{bmatrix} dx\\dy\\dz \end{bmatrix} \tag 2$$
Substituting $(1)$ into $(2)$ reveals
$$\begin{bmatrix} dx\\dy\\dz \end{bmatrix}=\begin{bmatrix} \frac{\partial x}{\partial u}&\frac{\partial x}{\partial v}&\frac{\partial x}{\partial w}\\\frac{\partial y}{\partial u}&\frac{\partial y}{\partial v}&\frac{\partial y}{\partial w}\\\frac{\partial z}{\partial u}&\frac{\partial z}{\partial v}&\frac{\partial z}{\partial w} \end{bmatrix}\begin{bmatrix} \frac{\partial u}{\partial x}&\frac{\partial u}{\partial y}&\frac{\partial u}{\partial z}\\\frac{\partial v}{\partial x}&\frac{\partial v}{\partial y}&\frac{\partial v}{\partial z}\\\frac{\partial w}{\partial x}&\frac{\partial w}{\partial y}&\frac{\partial w}{\partial z} \end{bmatrix}\begin{bmatrix} dx\\dy\\dz \end{bmatrix} \tag 3$$
which holds for all $dx$, $dy$, and $dz$.  Therefore, the we find that $(3)$ implies
$$\begin{bmatrix} \frac{\partial x}{\partial u}&\frac{\partial x}{\partial v}&\frac{\partial x}{\partial w}\\\frac{\partial y}{\partial u}&\frac{\partial y}{\partial v}&\frac{\partial y}{\partial w}\\\frac{\partial z}{\partial u}&\frac{\partial z}{\partial v}&\frac{\partial z}{\partial w} \end{bmatrix}\begin{bmatrix} \frac{\partial u}{\partial x}&\frac{\partial u}{\partial y}&\frac{\partial u}{\partial z}\\\frac{\partial v}{\partial x}&\frac{\partial v}{\partial y}&\frac{\partial v}{\partial z}\\\frac{\partial w}{\partial x}&\frac{\partial w}{\partial y}&\frac{\partial w}{\partial z} \end{bmatrix}=\begin{bmatrix} 1&0&0\\0&1&0\\0&0&1 \end{bmatrix}$$
as was to be shown!


Can a diffeomorphism not be an immersion or a submersion

Question: This may be a stupid question, but I have not seen anywhere that it is  said that a diffeomorphism must be an immersion and a submersion. Therefore I am asking the following two questions:
(I) Is a diffeomorphism between smooth manifolds necessarily a submersion?
(II) Is a diffeomorphism between smooth manifolds necessarily an immersion?
(III) If either (I) or (II) aren't true, can someone help by giving a counter example?
Thanks in advance.
Answer: Since the derivative of a diffeomorphism at every point is bijective, every diffeomorphism is both a submersion and an immersion.
Comment: Just one further question if I may, are two diffeomorphic smooth manifolds essentially the same object in an appropriate category?
Comment: Yes: in the category of differentiable manifolds.
Comment: why is the deriviative of a diffeomorphism bijective?


format_date() seems to ignore the time zone

Question: I am having issues with dates and time zones in Drupal 7. I have created a content type that stores the date in $field_event_date. When I use the Views module this works correctly.  However, I am using a template file to manipulate the display of this data. When I output the raw value, it is correct, so is the time zone; when I attempt to format it with the time zone format_date() seems to ignore the time zone value. Is there a proper way to do this in Drupal?
    print '
' . $field_event_date[0]['value']; // outputs 2011-11-04 21:30:00
    print '
' . $field_event_date[0]['timezone']; // outputs America/New_York
    print '
' . date('g:ia', strtotime($field_event_date[0]['value'])); // outputs 9:30pm
    print '
' . format_date(strtotime($field_event_date[0]['value']), 'medium', 'g:ia', $field_event_date[0]['timezone']); // outputs 9:30pm (????)

I have done this with just pure PHP this way:
// Get the timezone offset
$timezone = $field_event_date[0]['timezone'];
$remote_dtz = new DateTimeZone($timezone);
$remote_dt = new DateTime("now", $remote_dtz);
$offset = $remote_dtz->getOffset($remote_dt);

// Get the date
$start_date_string = $field_event_date[0]['value'];
$end_date_string = $field_event_date[0]['value2'];

// Apply the timezone offset
$start_date_string = strtotime(date("Y-m-d g:ia", strtotime($field_event_date[0]['value'])) . " " . $offset . " seconds");
$end_date_string = strtotime(date("Y-m-d g:ia", strtotime($field_event_date[0]['value2'])) . " " . $offset . " seconds");

// Build the date
$start_disp_date = date('l, F j, Y', $start_date_string);
$end_disp_date = date('l, F j, Y', $end_date_string);
$start_disp_time = date('g:ia', $start_date_string);
$end_disp_time = date('g:ia', $end_date_string);

This was working fine until recently a few dates started showing up about one hour off. I would prefer to use a Drupal centric solution (like format_date) since it might help me avoid odd occurrences like this one. Any advice for either approach would be appreciated however. This is all on a production site, so I just need to get it working.
Thank you for your time.
EDIT/UPDATE:
My PHP only solution was broken because of daylight savings time. So I replaced that code with this:
// Get the timezone offset
$offset = date('Z', strtotime($field_event_date[0]['value']));

// Apply the timezone offset
$start_date_string = strtotime(date("Y-m-d g:ia", strtotime($field_event_date[0]['value'])) . " " . $offset . " seconds");
$end_date_string = strtotime(date("Y-m-d g:ia", strtotime($field_event_date[0]['value2'])) . " " . $offset . " seconds");

// Build the date
$start_disp_date = date('l, F j, Y', $start_date_string);
$end_disp_date = date('l, F j, Y', $end_date_string);
$start_disp_time = date('g:ia', $start_date_string);
$end_disp_time = date('g:ia', $end_date_string);

Granted, this doesn't solve the problem with format_date(). While I'm going to stick with my PHP centric solution, others might have the same problem. Perhaps I am using the function incorrectly.
Answer: Yep, i was having similar problems, but in Drupal 6.
I'm surprised your  $field_event_date[0]['value'] was in New York time. My understanding is that that value comes straight out of the database, and it's pretty standard to keep all times in the db as UTC times, and only use local times when displaying them (since local times go crazy a couple of times a year).
$field_event_date[0]['timezone_db'] will tell you for certain what timezone $field_event_date[0]['value'] is in.
And $field_event_date[0]['timezone'] will tell you what timezone it should be displayed in (according to your site's 'default timezone'). If you look at $field_event_date[0]['view'], it should be in the display timezone.
When i'm trying to display dates from the raw 'value', i do something like...
/**
* @param
*     $date A CCK date field, like you'd get in your node templates,
*     e.g. $field_event_date[0]
*/
function get_display_date($date) {
    $date_convert = new DateTime($date['value'], new DateTimeZone($date['timezone_db']));
    $date_convert->setTimezone(new DateTimeZone($date['timezone']));
    return $date_convert->format('Y-m-d H:i:s');
}

I've yet to find any documentation which can confirm all this, so i may be totally wrong! But it works for me so far. Hopefully Drupal 7 isn't too different.
Answer: In addition to Chichilatte's answer: If you're using the date_api module (part of the date project) you can also do this:
$date_object = new DateObject($date['value'], new DateTimeZone($date['timezone_db']));
$date_object->setTimezone(new DateTimeZone($date['timezone']));
return date_format_date($date_object, 'custom', 'Y m d');

Answer: Working with a Drupal 6 site this helped me get a reliable solution to display the date with correct timezone
// Get the timezone offset
$offset = date('Z', strtotime($node->field_date[0][value]));
// Get the date from datebase using database timezone
$unixdate = strtotime($node->field_date[0]['value'].' '.$node->field_date[0]['timezone_db']);
// Apply timezone offset and format display datetime
$time = format_date($unixdate, 'custom', 'g:ia', $offset);


Truss Rod Can't Get Any Looser

Question: I'm trying to adjust the neck tension on an Ibanez electric guitar for some regular light gauge strings, but I've maxed out loosening the truss rod and the neck still doesn't provide enough relief and a lot of my notes buzz.  Unfortunately the guitar doesn't have a dual action truss rod (it's a nut based adjustment) so I can't utilize the truss rod to solve my problem.  Is there any way I can fix this?  The guitar is still under warranty so I'm wondering if I need to send it in.
It's worth noting that my playing style and comfort level dictates that I shouldn't use heavier strings (aka more tension which should've in theory helped with the issue).
Comment: Do not completely loosen a truss rod. It may rattle inside the neck. If you want it as loose as possible, start by "maxing it out", but then tighten it to keep it in place.
Comment: Even if you took very good pictures with a good digital camera, this would be next to impossible to diagnose over a Q&A forum like this.
Comment: > *the neck still doesn't provide enough relief*

What is the evidence? If you press a given string down at the lowest fret and highest fret simultaneously, how much string-fret clearance is there halfway between them?

You can use a guitar pick as a crude gauge.
Answer: If the guitar is new or recently built, and played fine before you bought it, then you shouldn't have to "max out" the truss rod. It does not require large turns to have an effect. You don't need a dual-action rod to play with light gauge strings. I highly recommend putting it back to the way it was, if you can remember how many times you turned it, and raising your bridge saddles slightly.
There are many variables at play here besides the truss rod. Use a guide like this exceptional blog post explaining how to properly "sight" your neck, adjust your truss rod, and set up your guitar correctly: https://www.sweetwater.com/sweetcare/articles/guitar-setup-part-1-adjusting-the-truss-rod-2/
(it includes pictures)
Ibanez has been making electric guitars for light gauge strings for decades. There's nothing wrong with your guitar (or at least there wasn't before you made adjustments). Also, and I mean this with all due respect, there's nothing unusual about your playing style and comfort level.
Comment: How do you know? Maybe **that** Ibanez is a lemon. Factory reject pawned off or whatever.
Comment: Because, knowing how guitars are made on CNC machines and what not, and the store's quality control before selling it, and the fact that the OP bought the guitar (and surely would have noticed it was a lemon before they paid money) unless they bought it online ... probably not a lemon.
Answer: I would return it.  I've bought a lot of guitars on eBay and this is one problem that gets players to sell their guitar and make it someone else's problem.  The problem is that it has a back bow, which is not that rare.  Heavier strings will usually put enough pull on the neck that it's at least flat, but light strings won't work on a guitar with a severe back bow.  People that sell their back bow guitars on eBay usually set the strings really high hoping you won't adjust the action and find that it has a back bow. You don't want this problem, and it would be unethical to sell it in the future.

Truss Rod Can't Get Any Looser


A cada N repetições exibir X no PHP

Question: Estou exercitando os conhecimentos no PHP e me surgiu uma dúvida. Como faço para exibir um texto após N repetições do laço DO?
    <?php do { ?>

<?php echo $titulo_da_foto; ?>

    <img src="upload/<?php echo $arquivo; ?>" />

    <?php } while ($rsVarejo > 0); ?>

Neste caso, gostaria de ocultar o background da class fotos na 4ª repetição, alguma sugestão?
Comment: Você quer que a cada 4 fotos oculte e volte a mostrar nas 3 seguintes, e oculte de novo, ou oculte permanentemente da quarta em diante? Seria bom você por um exemplo da saída desejada na pergunta.
Answer: Você poderia fazer isto:
<?php
$counter = 0;
do {
  $counter++;
  if ($counter == 4){
    ?>

    <?php
  }
  else {
    ?>

    <?php
       }
    ?>

<?php echo $titulo_da_foto; ?>

  <img src="upload/<?php echo $arquivo; ?>" />

<?php
   } while ($rsVarejo > 0); ?>

E adicionar uma classe CSS "ocultar":
.ocultar {
  background: none !important;
}

Answer: Uma solução possível, seria em jquery:
 $( ".classdesejada:nth-child(4)" ).css("background", "rgba(0, 0, 0, 0)" );

Answer: Acho que isso resolve seu problema:
<?php
    $aux = 0;
    do {
          $aux++;
          if($aux >= 4){
              $nomeDaClasse = 'classe';
              $aux = 0;
          }
?>
          <div class="<?php echo $nomeDaClasse;?>">

<?php echo $titulo_da_foto; ?>

             <img src="upload/<?php echo $arquivo; ?>" />

<?php
       } while ($rsVarejo > 0);
?>

Answer: <?php
    $fim = 100;
    $incremento = 1;
    $diferente = 4;
    $contador=0;
    do {
        $contador = $contador + $incremento;
        $resto = contador % diferente;
        ?><div class="<?php
        if ( $resto != 0 ) {
        echo $id_do_estilo_css_normal;
       } else {
       echo $id_do_estilo_css_diferente;
     }
     ?>">Conteudo do elemento, tag, etiqueta

    } while ( $contador < $fim);
?>

Recomendações:
O estilo de codificação original desta postagem deve ser repensada.
Nele há mistura de camadas conceituais. Não se utiliza esse estilo de concepção de projeto por diversas razões. Estude e utilize o modelo Model, View, Controller entre outros modelos para atualizar seu aprendizado.
A todos desejo MUITA boa sorte nos estudos e obrigado por lerem este texto.
Comment: `$resto = $contador % $n_interacoes;`

A cada N repetições exibir X no PHP


Showing the most recent opened items in a menu bar

Question: I want to create a window with Java Swing. The window will have a menu bar with a File->Open button from where the user can select a file from hid hard drive. The File menu should also have a list of the most recent opened items, like many other applications show. Does anyone know what is the best approach?
Answer: I would suggest using the Preferences class to persist the most recently opened items.  That way, if the user restarts the application the items will still be available.
Note that on Windows the Preferences class stores data in the registry, which is how many native Windows applications store and retrieve recently open file names.
Also, note that the Preferences class simply acts as an API for storing and retrieving (key, value) pairs.  You will still need to decide how you wish to store the information, and be responsible for dynamically building / updating the JMenu when a new file is accessed.  To accomplish this I would suggest implementing a Action (extend AbstractAction) to deal with when the user attempts to open a file.  When the Action runs it should persist the newly accessed file's name to the Preferences class and dynamically rebuild the File JMenu (in addition to opening the file).
Comment: +1 For `Preferences`, although it's not _just_ for Swing. As an aside, `Preferences` on Mac OS X are stored in individual files in `~/Library/Preferences`.
Comment: Good point - I've amended my answer.  I could have sworn Preferences was in the javax.swing package.


Big delay with JQuery animate on window resize

Question: I have 2 divs floating to the left and right of my main content. I want to shrink the divs if the user shrinks their browser window, so they dont cover the content. Conversly, I want them to expand again if the user makes the window big enough.
To do this, I have created the following code:
<code>$(window).resize(function() {
  var windowwidth = $(window).width();

  if(windowwidth < 1400){
    $('#sliderholder').animate({width:'25px'});
    $('#contactholder').animate({width:'25px'});
  }

  if(windowwidth > 1400){
    $('#sliderholder').animate({width:'222px'});
    $('#contactholder').animate({width:'222px'});
  }

});
</code>
But this doesnt work properly - the animations seem to occur at random, or are very much delayed.
Would anyone know how to improve this?
EDIT: did some experimenting and have found it is delayed, rather then out of synch
Answer: I added <code>.stop()</code> to the above and it seems to solve it.
<code>$(window).resize(function() {
  var windowwidth = $(window).width();

  if(windowwidth < 1400){
    $('#sliderholder').stop().animate({width:'25px'});
    $('#contactholder').stop().animate({width:'25px'});
  }

  if(windowwidth > 1400){
    $('#sliderholder').stop().animate({width:'222px'});
    $('#contactholder').stop().animate({width:'222px'});
  }

});
</code>
Comment: Well .. i just wasted a few hours of my life. O.o What a simple fix .


Convert Excel HTML to cleaner HTML

Question: Is there an easy way to convert the output of Excel 2003's Save to HTML option to something more 'friendly'? I have an Excel document with about 20 columns and 50 rows.
Throughout the saved HTML file I have obsolete HTML (example:
), in line styles, and empty cells all over the place.
I'd like something less 'table-y'. Is there a way to either force Excel 2003 to save it using more CSS and less tables or a way to convert tables to divs more easily than going through the HTML file by hand?
Answer: If still of interest, Tidy shall neatly do the task in hand!
It seems to be somewhat without support so expect to find some troubles to make it useful for your needs.
Anyway, for POC you can rely on a on-line version found at http://infohound.net/tidy/.
Just checking the 'Clean' option leaving everything as-is would lead to a result close to your expectations.
Regards and good luck.
Answer: If you have Dreamweaver, you can use its markup cleaner tool...which I believe is designed for this kind of thing.
Create a new HTML document in Dreamweaver, copy and paste your code in and use the cleanup tool.
Here's one guide I find, but you could probably find better if it doesn't help:
http://www.articleonlinedirectory.com/656381/cleaning-up-unwanted-formatting-dreamweaver.html
Good luck.
Answer: Open the html file in browser and run some code in console is a way, a rough example:
var whiteList = ["rowspan", "colspan"];

[...document.querySelectorAll("table")].forEach(table => {
  rmAttr(table);
  [...table.querySelectorAll("tr")].forEach(tr => {
    rmAttr(tr);
    [...tr.querySelectorAll("td")].forEach(td => {
      rmAttr(td);
    });
  });
  console.log(table.outerHTML);
});

function rmAttr(dom) {
  [...dom.attributes].forEach(attr => {
    if (!~whiteList.indexOf(attr.name)) {
      dom.removeAttribute(attr.name);
    }
  });
}

Convert Excel HTML to cleaner HTML


How can let form submit the value of input inside shadow root of custom HTML element?

Question: I created a custom HTML input element like follow:

<form action="/test">
  <test-input></test-input>
  <input type="submit"></input>
</form>

However, when I used spring to receive the form parameters, I get nothing. How can I submit the form with the value of input inside the shadow root?
Comment: Have you seen this article? https://web.dev/more-capable-form-controls/
Comment: @NickParsons This article solved my problem! Thanks!
Comment: Click on `<>` in question editor and turn this into a runnable snippet that others can quickly copy and test with right here in the page
Comment: @NickParsons could you please add the article as an answer and the owner (Michael Tsai) to accept it? Sometimes people miss the comments on a question.

Thanks for the solution!
Comment: @charlietfl I turned it into a runnable sinppet. Thanks.
Comment: The `form.elements` collection completely ignores the input in the custom element and only returns the submit button. Must it be in a custom element? Or could you put the whole form in it? I've never worked with form controls this way so just tossing around ideas right now
Comment: @charlietfl it must be in a custom element and I can't put the whole form in it. Because this is a requirement of my project.
Answer: Per web.dev/more-capable-form-controls linked in the comments by @nick-parsons.

First you want to add formAssociated static prop to the class of your custom-element and assign it true in order to turn your custom-element into a form-associated custom element like so:
class MyCustomElem extends HTMLElement {
  static formAssociated = true;
  //...
}

Then you want to call HTMLElement.attachInternals() on your custom-element

can be done in the constructor() like
let internals = this.attachInternals()

in order to use ElementInternals.setFormValue() returned from attachInternals().
Finally, you would use setFormValue() to update the value that your custom-element will submit to the outer form, probably called through an addEventListener().

Modifying the example from the question:

<form action="/test">
  <test-input></test-input>
  <input type="submit"></input>
</form>

Answer: I had the same problem. but I made my won solution by creating an input inside the shadow Host and outside the shadow Root. that input's value will be updated whenever the one inside shadow Root value change.
shadow Host => <test-input name='email'>
shadow Root => appears in the runtime like this #shadow-root (open)
you should use connectedCallback to bind addEventListner with the new input.
and finally, you can use normal querySelector to point out shadow Host and shadow Root and the value of input inside.
but that way you are accessing the shadow Root by JS and you can't get the value directly by submitting the form.
the other option as mentioned by creating new input and update its value within connectedCallback and that way you can use FormData or submit the form normally and then you will recive the value based on the name attribute

let form = document.getElementById('frm');

form.addEventListener('submit', (event) => {
    // stop form submission
    event.preventDefault();

    alert('get value from shadowRoot: ' + form.querySelector('test-input').shadowRoot.querySelector('input').value);

    alert('get value of binded elemnet within shadowHost: ' + form.email.value);

});

let shadow;
class TestInput extends HTMLElement {

      constructor() {
        super();
        shadow = this.attachShadow({mode:'open'});
        var cinput = document.createElement('input');
        cinput.setAttribute('type', 'text');
        cinput.setAttribute('value', 'test');
        shadow.append(cinput);
        this.cinput = cinput;

        var inputToBind = document.createElement('input');
        let name = this.getAttribute('name');
        inputToBind.setAttribute('name', name);
        inputToBind.setAttribute('value', cinput.value);
        this.appendChild(inputToBind);
        }

connectedCallback() {

        this.cinput.addEventListener("input",
          (event) => {
          let value = event.target.value;
          this.querySelector('input').setAttribute('value', value);
          })
  }

}
customElements.define('test-input', TestInput);
<form id='frm'>
  <test-input name='email'>

  </test-input>
  <button type="submit">submit</input>
</form>


Postagem de um aplicativo

Question: Como postar um aplicativo tendo como "dono" uma empresa?
Existe uma conta de usuário empresarial? ou é feita por uma conta de alguém e no apk é descrito que o app é de tal empresa?
Answer: Vai usar o o nome que estiver na sua conta do Google, se voce aderir ao programa de app com  a sua conta pessoal provavelmente a parte onde mostra o "dono" do app vai ficar com a o seu nome por exemplo Rodolfo.JJ

Postagem de um aplicativo


Accessing array items generically through pointer to array of chars?

Question: If I'm writing a generic algorithm, am I allowed to alias an array of unknown type as a pointer to an array where each element is the size provided without invoking undefined behavior?
For example, is there UB in the following code?
typedef void (*action_t)(const void *item);
void do(void *array, size_t eltCount, size_t eltSize, action_t action)
{

    // Convenient typedef.
    typedef char element[eltSize];
    element *elts = array;
    element *end = elts + eltCount;

    for (; elts != end; elts++) {
        action(elts);
    }
}

I know I can do this:
char *elts = array;
char *end = elts + eltCount * eltSize;

for (; elts != end; elts += eltSize) {
    action(elts);
}

But the first bit of code seems more idiomatic to me since the compiler does the pointer arithmetic for me. The function above compiles without warnings using both gcc and clang (relevant compilation flags are -std=c99 -O3 -fstrict-aliasing -pedantic-errors -Wextra -Wall).  I'm also wondering about strict aliasing, but as far as I can tell, it seems like I'm not breaking it here since objects are allowed to be used indirectly via char*.
Comment: Your latter example would pass a single char to a function expecting a pointer to void, at least. A typo?
Comment: @IljaEverilä Fixed it. Thank you
Comment: If you are in trouble then `qsort()` and `bsearch()` are too..,
Answer: In C, a typedef doesn't introduce a new type.  It just names a construct.  The name and its definition are interchangeable.  (The same is not true for, say, struct, where there is no way to express the structure's definition other than by its name.)
So, as long as you're only talking about some form of char * -- which as you know, is special because any data pointer can be converted to it -- then you're relying on defined behavior.


What is V65/III in D major?

Question: In the key of D major what is V65/III but, the III is natural? I'm having a hard time with this. Also, V7/bVI?
Answer: In D major, III is an F♯ major chord. (It isn't diatonic: iii or F♯ minor is.) That being the case, V65/III is a first inversion dominant seventh chord on C♯ (see Ex. 1). However, V65/III is the same chord as V65/iii, so it isn't that far removed from the key as secondary sevenths go.
♭VI in D major is going to be a B♭ major chord. It's pretty much a borrowing from the parallel minor key (D minor). That being the case, then V7/♭VI is going to be a dominant seventh on F (see Ex. 2).
Answer: I'm actually going to have to disagree with the first half of Patrx2's answer. The second half is totally fine; ♭VI in D major is B♭, so the V7/♭VI will in fact be F A C E♭.
As for the first one, OP asked:

In the key of D major what is V65/III but, the III is natural?

Since the III is both uppercase (thus not iii, which would be F♯ minor) and natural, it seems the question is asking for the V65/F (F being the "naturalled" [that is, lowered] third scale degree). The V7 of F is a C7 chord, C E G B♭, which will have the E in the bass for its 65 position.
Comment: Ah. Don't think I've ever seen the natural used, probably because it isn't very "key-agnostic".
Comment: That's my point, Richard. This notation is _meant_ to be key-agnostic: III or iii for the mediant degree in major, ♭III or ♭iii for the minor's mediant, _regardless_ of where the tonic is situated.
Comment: Then it becomes V7/♭III, no?
Comment: fIII or nIII, both work.
Comment: But in the case of D Major, nIII would be more correct than fIII.
Comment: Should the question then be about V65/bIII. As III will always be F# in D maj. If the III in question needs to be F natural, it's got to be called bIII, surely? which then equates to a flattened sharp note, e.g. natural.
Comment: I think this is the correct answer; given that the second half of the question is about bVI it makes sense that both questions are dealing with standard modal mixture chords. I agree with @user16935 that key-agnostic bIII is a slightly superior way to write it, but using a natural is very common. However, I think it would help the OP if the answers made it clear that bIII and bVI are common modal mixture chords, since that's the common link between the two halves of the question.
Comment: Yes, if we're using the I, II, III... system of naming chords, bIII is the usual way, whether the actual root is a flat, sharp or natural.   (It COULD be a sharp, in D# major...)
Answer: In D major III is an F#major chord.  But you say it's a natural, so I think we're talking about F major (which would normally be labelled as bIII).  So you're asking for the first inversion dominant 7th of F, which is C7/E  (C7 with E as the lowest note).
bVI in D is Bb.   The dominant of Bb is F.
The third note of the D major scale is F#.  The minor third is F natural.  But we call the F chord bIII, even though 'flattening' it resulted in a natural.
In the same way, consider F major.  Fourth note is Bb.  So a Bb chord is IV. We call a B (natural) chord #IV, even though the actual note is a natural.  The Bb has been 'sharpened' to Bnat.

What is V65/III in D major?


How do I negate a mathematical statement?

Question: I just knew that negation uses "not." "Atleast" negates to "less than." "Atmost" negates to "more than." "All" negates to "some." "Some" negates to "none."
How about this, "There are 12 months in a year."
What is the negation of this statement?
Comment: "There are *not* $12$ months in a year."
Comment: The "trichotomy" property. For real numbers $a,b$, either $ab$ or $a=b$. If one of them is false, one of the other two must be true. If "there are 12" is false then one of "there are less than 12", or "there greater than 12" months in a year must be true.
Comment: The negation of "all" is "not all", which is different than "some". For example it is false that all people have 40 heads, but it is also false that some people have 40 heads.
Comment: The negation of "All *do* (something)" is "Some *do not* (that thing)"  It is false that all people have 40 heads, because I do not have 40 heads.
Comment: As a general rule, you want to think about the _meaning_ of the negation to choose how to say it. Don't rely on mechanical  rules for substituting words.
Answer: You could simply say: "There are not 12 months in a year"
Or, you could say: "There are either less than 12, or more than 12, months in a year"


How can I redirect my abc.com to www.abc.com?

Question:
Possible Duplicate:
asp.net mvc: How to redirect a non www to www and vice versa

I want to redirect my site url from abc.com to www.abc.com so that I get standard URL format.
How can I achieve this? Can any one help me out?
Answer: You should setup a "HTTP 301 redirect" from abc.com to www.abc.com
Techniques for doing this depend on what kind of HTTP server platform you are using, and are described succinctly in the following section of Wikipedia's page on URL redirection:
https://en.wikipedia.org/wiki/URL_redirection#HTTP_status_codes_3xx


Olympic sports where teams compete for entry

Question: Most Olympic sports are competed by individuals, or by teams that are are assembled from individuals in a selection or trial process.
But curling (at least in the US) selects existing teams to represent in the mens and womens events.  (Even after reading the US curling site, I'm still not clear on how the mixed event is selected)
Are there any other sports where existing teams of players compete for selection instead of individuals?  A team should be larger than 2 people for the purposes of this question, so not counting any pairs events.
Comment: Are you restricting this to only the actual players of the sport? Officials compete for selection as a team in some major tournaments e.g. FIFA World Cup officials are picked as a team and mistakes by just one official can get their whole team removed from duties for the remainder of the competition.
Comment: Interesting.  I hadn't thought about officials.  I'll limit it to just players.
Comment: I'm not sure. So just a comment: 4-men bobsleigh?
Comment: Yes, bobsleigh are existing teams as well.
Comment: @diy, do you have any more detail on that?  The team page https://www.teamusa.org/USA-Bobsled-Skeleton-Federation/Features/2017/October/04/USA-Bobsled-and-Skeleton-National-Team-Trials-to-begin-October-7 suggests to me that individuals are chosen rather than teams.
Comment: @BowlOfRed there are always exceptions. because there's no official ruling on that afaik. Usually teams are pre-existing ones, because they already know each others and perform better that way. Unfortunately I have no source for that except for own experience.
Answer: Curling and maybe rowing.
I couldn't find anything official, and I didn't understand all the information I found on rowing.
I went down the list of Olympic sports and made my own list of sports that seemed to involve team competition.  Most are pretty obvious, but several I wasn't certain of.  Sailing in particular appears to only have events with one or two sailors at a time, so not a team event for this question.
My list:

athletics (some track relay events are teams.  Not sure of any others
here)
basketball
cycling (team pursuit)
football
gymnastics artistic
gymnastics rythmic
handball
hockey
rowing
rugby
swimming (some relay events are team competition)
synchronized swimming
volleyball
water polo
bobsleigh
curling
ice hockey

As this is my own list, there could be mistakes.  Many of the major sports I know (like team USA basketball and ice hockey) have a national team that is composed of selected individuals.  For the others, I tried to find information on the selection process.
The only ones that seemed likely to be similar to curling to me were bobsleigh and rowing.
Everything I could find for bobsleigh suggests that individuals are selected onto the national team.  I don't know how the competing teams are put together, but it appears to be after team selection, not before.
The last one that bugged me is rowing.  There seem to be different procedures for selection by different rowing classes.  So while some individuals are chosen, I got the impression that some classes might be selected as a crew through trials.  If anyone knows more detail about rowing to rule it in or out, that would be appreciated.
Comment: I think you should make "My List:" into "The list of sports I searched:". The way it is now it appears to be a list of sports that meet the OP's criteria.
Comment: I'm not 100% certain about rowing, but it is indeed complicated. Because outside the Olympics, the most competitive arena in the sport is often intercollegiate athletics, it's not uncommon for entire university boats ("teams") to show up at selection camps to contend for selection. (The well-known book "The Boys in the Boat" documents the University of Washington heavyweight 8 being selected for the 1936 Olympics and eventually winning gold, but I'm not sure how common that is these days). But it's also not uncommon for boats to be put together "on the fly" at selection camps.
Comment: I suspect this is a thing in rowing because rowers working well together is a huge part of a successful crew - you can't just drop the eight strongest rowers in a boat and expect it to be faster than all the others.


The confusion about the proof of if function is continuous on a closed interval $[a,b]$,then it is integrable

Question: In many proofs, it uses the fact that if a function is continuous on the interval $[a,b]$, then it is uniformly continuous on that interval
Thus, statement :$\forall \epsilon>0, \exists \delta>0, \forall x,x'\in [a,b];|x-x'|<\delta\implies |f(x)-f(x')|<\epsilon$
Then choose a partition $P$ such that for any partitioned interval $[t_{i-1},t_i],t_i-t_{i-1}<\delta$
Then for any $x,x'\in [t_{i-1},t_i]$,based on the definition of uniformly continuous, it will be $|f(x)-f(x')|<\epsilon \implies f(x')-\epsilon<f(x)<f(x')+\epsilon$
For any given $x'$,and based on the definition of sup and inf:
\begin{equation}
 \ f(x')-\epsilon\leq\inf f(x)\leq f(x)\leq\sup f(x)\leq f(x')+\epsilon
\end{equation}
Thus $\sup f(x)-\inf f(x)<2\epsilon$ for any $x\in [t_{i-1},t_i]$ this means ($M_i$ is $\sup f(x)$ on any $[t_{i-1},t_i]$ and $m_i$ is $\inf f(x)$ on any $[t_{i-1},t_i]$)
\begin{equation}
 U(f,P)-L(f,P)=\displaystyle \sum^n_{i=1}(M_i-m_i)(t_i-t_{i-1})<2\epsilon(b-a)
\end{equation}
Then does the above is enough to say that $U(f, P)-L(f, P)<\epsilon$? Since $2\epsilon(b-a)$ can also represent arbitrary positive numbers.

However, in some proofs, I saw that they first let $M_i-m_i<\epsilon_1$
Then after getting $\displaystyle \sum^n_{i=1}(M_i-m_i)(t_i-t_{i-1})<\epsilon_1(b-a)$. There will be another step which is letting $\epsilon_1(b-a)<\epsilon$ to get $\epsilon_1<...$ Is this a necessary step?
Comment: The numbers $a$ and $b$ are fixed so $b-a$ is a constant.
Comment: But I think since $\epsilon$ itself is any positive number, then, in particular, it can be $\frac{1}{2(b-a)}$, $\frac{2}{2(b-a)}$,...,or anything. As a result, $2\epsilon(b-a)$ is also a positive random number.
Comment: Epsilon is also fixed before you do the calculation. That is true of non-uniform continuity as well. Given $\epsilon\gt 0$ we can find $\delta$ such that ... For a different $\epsilon$ you need a different $\delta$.
Answer: Your intuition is correct: since $2(b-a)$ is constant, showing there's a partition where $U(f,P)-L(f,P) < 2\epsilon (b-a)$ means that $U-L$ gets arbitrarily small, so the function is integrable.
The trouble with a rigorous formal proof is that the definition requires showing for any given particular $\epsilon$ that there's a partition where $U-L < \epsilon$. And though $2 \epsilon (b-a)$ is also "arbitrarily small", it's not the same as the "arbitrarily small" number $\epsilon$.
So a rigorous proof takes care of this by giving different names $\epsilon$ and $\epsilon_1$ to these two numbers. $\epsilon$ is the original and final given number, where the overall goal of the proof is to show that $U-L < \epsilon$. $\epsilon_1$ is the value involved in the definition of uniform continuity, and appears in statements like "for any $\epsilon_1>0$, there is a partition $P$ so that if $x$ and $x'$ are in the same interval of $P$ then $f(x')-\epsilon_1 < f(x) < f(x')+\epsilon_1$". Near the end, we have shown that "for any $\epsilon_1>0$, there is a partition $P$ such that $U(f,P)-L(f,P) < 2 \epsilon_1(b-a)$". To finish the proof, we just make that statement about any positive $\epsilon_1$ specific: "Let $\epsilon_1 = \frac{\epsilon}{2(b-a)}$, and there is a partition $P$ such that $U(f,P)-L(f,P) < \epsilon$."
Sometimes you may see proofs which make things shorter by using $\epsilon_1$ as some function of $\epsilon$ right away: "Since $f$ is uniformly continuous, there exists a $\delta > 0$ such that for any $x,x' \in [a,b]$, $|x-x'| < \delta \implies |f(x)-f(x')| < \frac{\epsilon}{2(b-a)}$." This gives a valid and shorter proof, but hides how the author came up with the proof. When reading along in order, there's no obvious reason to divide by $2(b-a)$ there; it's essentially a magic step which later cancels out nicely.
Answer: To directly answer your question of "is this step necessary?", the answer is it depends. It depends on whether or not you actually know how to prove that it is equivalent to the usual statement which only has $<\epsilon$ at the end. If you already know the equivalence, then of course you don't have to keep repeating it. If you don't know the equivalence, then of course, you have to go the extra step; after all, the reason why sometimes we might go the extra step of starting with $\frac{\epsilon}{2(b-a)}$ or starting with a different quantitity $\epsilon_1$ is just to make contact directly with the theorems proved/definitions involved.
Perhaps that last part may have been a little cryptic, so let me instead illustrate with an example. Suppose $f:I\to \Bbb{R}$ is a given function where $I$ is say an open interval containing the point $a$. Also, let $l\in\Bbb{R}$. Consider now the following statements:

for every $\epsilon>0$, there is a $\delta>0$ such that for all $x\in I$, if $0<|x-a|<\delta$ then $|f(x)-l|<\epsilon$.
for every $\epsilon>0$, there is a $\delta>0$ such that for all $x\in I$, if $0<|x-a|<\delta$ then $|f(x)-l|\leq \epsilon$.
for every $\epsilon>0$, there is a $\delta>0$ such that for all $x\in I$, if $0<|x-a|\leq \delta$ then $|f(x)-l|< \epsilon$.
for every $\epsilon>0$, there is a $\delta>0$ such that for all $x\in I$, if $0<|x-a|\leq\delta$ then $|f(x)-l|\leq \epsilon$.

In other words, I have just replaced some of the strict inequalities with weak inequalities. Now consider the next "type" of statement:

there is a $k>0$ such that for every $\epsilon>0$, there is a $\delta>0$ such that for all $x\in I$, if $0<|x-a|<\delta$ then $|f(x)-l|< k\epsilon$.
there is a $k>0$ such that for every $\epsilon>0$, there is a $\delta>0$ such that for all $x\in I$, if $0<|x-a|<\delta$ then $|f(x)-l|\leq k\epsilon$.
there is a $k>0$ such that for every $\epsilon>0$, there is a $\delta>0$ such that for all $x\in I$, if $0<|x-a|\leq\delta$ then $|f(x)-l|< k\epsilon$.
there is a $k>0$ such that for every $\epsilon>0$, there is a $\delta>0$ such that for all $x\in I$, if $0<|x-a|\leq\delta$ then $|f(x)-l|\leq k\epsilon$.

So, I have added the prefix "there exists $k>0$" and finished off with $k\epsilon$, again with the four variants of weak/strict inequalities. Finally, let me introduce the following type of statement. Suppose $\psi:(0,\infty)\to (0,\infty)$ is a function such that $\lim\limits_{\epsilon\to 0^+}\psi(\epsilon)=0$. Now consider the following statements:

for every $\epsilon>0$, there is a $\delta>0$ such that for all $x\in I$, if $0<|x-a|<\delta$ then $|f(x)-l|<\psi(\epsilon)$.
for every $\epsilon>0$, there is a $\delta>0$ such that for all $x\in I$, if $0<|x-a|<\delta$ then $|f(x)-l|\leq\psi(\epsilon)$.
for every $\epsilon>0$, there is a $\delta>0$ such that for all $x\in I$, if $0<|x-a|\leq\delta$ then $|f(x)-l|<\psi(\epsilon)$.
for every $\epsilon>0$, there is a $\delta>0$ such that for all $x\in I$, if $0<|x-a|\leq\delta$ then $|f(x)-l|\leq \psi(\epsilon)$.

So, the twelve statements I made above, with various choices of weak/strict inequalities, and with various choices of the final quantity ($\epsilon$ vs $k\epsilon$ vs $\psi(\epsilon)$), it turns out they are all logically equivalent. To someone who has finished a first course in real analysis, these equivalences tend to become almost obvious (furthermore, here I only stated things for functions defined on subsets of $\Bbb{R}$ and with values in $\Bbb{R}$, but the same can be generalized to metric spaces and stuff). The key to understanding the equivalence is the role of the quantifiers "for every" and "there exist".
Point ($1$) is often taken as the definition of "$\lim\limits_{x\to a}f(x)=l$", so if you start with that as the definition, you have to prove the remaining statements as theorems. Often times textbooks avoid mentioning that these statements are all equivalent (some textbooks may leave some of these equivalences as exercises, such as Spivak). Also, since point (1) is the definition straight out of a textbook, often in an attempt to not to invoke results not already proved, they may resort to making their proofs slightly more opaque by bringing in $\frac{\epsilon}{2}$ or $\frac{\epsilon}{2k}$ or stuff like that; in a sense this method of brining in "auxillary epsilons" is pretty much a way of proving the equivalence of the above statements, without explicitly saying that's what they're doing.
For the case of the upper and lower sums, it's the same story. The statement

for every $\epsilon>0$ there is a partition $P$ of the interval $[a,b]$ such that $U(f,P)-L(f,p)<\epsilon$

can also be expressed equivalently in many ways. We can use either $<$ or $\leq$
at the end. We can add the prefix "there is a $k>0$" in the beginning and finish off with $<k\epsilon$; we can also suppose there is a function $\psi$ as described previously and end with $<\psi(\epsilon)$.
So once again, the question of "is this step necessary" depends entirely on what you have/have not already proved. From a strict logical perspective, yes if you start with one of the statements as a definition, you have to prove that the remaining eleven are equivalent. However, to many "experienced" people (where "experienced" means usually by the end of a 1-2 semester course in analysis) these equivalences are almost obvious, so going the extra step may be unnecessary.
In practice, we often end up proving something like statement (8) (where usually we have some explicit value for $k$ like $k=2$ or $k=10$ or $k=2\sup\limits_{x\in [a,b]}|f(x)|$) or (12) instead, because weak inequalities are more forgiving, and that's all we really need.


Locally connected set in compact metric space

Question:
Suppose that ($X,d$) is a compact metric space. Prove that $X$ is locally connected if and only if for each $\epsilon>0$, there is a finite cover of X by compact connected sets of diameter less than $\epsilon$.

For ($\rightarrow$), I have already find it in this site.
For ($\leftarrow$), I somehow show that $\forall x \in X$, $\forall G \in \tau$ s.t. $x \in G,$ $\exists V \in \mathfrak{N}(x)$ such that $x \in V \subseteq G$ and $V$ is connected set.
By the way,
I really don't know how to choose such $V$ to be open instead of just a neighborhood.
Every hint is appreciated.
Thank you
Answer: HINT: It's probably easiest to prove the contrapositive: if $X$ is not locally connected, then there is an $\epsilon>0$ such that $X$ has no finite cover by compact, connected sets of diameter less than $\epsilon$.
If $X$ is not locally connected, then $X$ is not weakly locally connected: there are a point $p\in X$ and an open nbhd $U$ of $p$ such that if $V$ is a connected nbhd of $p$, not necessarily open, then $V\nsubseteq U$. (You can find a short proof that every weakly locally connected space is locally connected here. Choose $\epsilon>0$ such that $B(p,\epsilon)\subseteq U$; then no connected nbhd of $p$ is contained in $B(p,\epsilon)$.
Now suppose that $X$ has a finite cover $\mathscr{C}$ by compact, connected sets of diameter less than $\epsilon$. Let $\mathscr{C}_0=\{C\in\mathscr{C}:p\notin C\}$, and let $K=\bigcup\mathscr{C}_0$; $\mathscr{C}_0$ is finite, so $K$ is closed. Let $W=X\setminus K$; clearly $W$ is an open nbhd of $p$.

Show that $W\subseteq\bigcup(\mathscr{C}\setminus\mathscr{C}_0)\subseteq B(p,\epsilon)$.
Show that $\bigcup(\mathscr{C}\setminus\mathscr{C}_0)$ is connected.
Conclude that $\bigcup(\mathscr{C}\setminus\mathscr{C}_0)$ is a connected nbhd of $p$ contained in $B(p,\epsilon)$, contradicting the choice of $p$ and $\epsilon$.
Comment: @BigbearZzz: It's often easier to start with a single bad thing and show that it can't exist than it is to show that everything is good.
Comment: I attempted the constructive route and got as far as $\mathscr{C}_0=\{C\in\mathscr{C}:p\notin C\}$ but somehow couldn't seem to get an open connected set out in the end. Maybe contrapositive is the way to go.
Answer: For the sake of completeness and those who will need it I add the following references are from Ryszard Engelking's «General Topology» (2nd ed., Heldermann, Berlin, 1989).

Thus (c) directly implies the implication ($\rightarrow$). Implication ($\leftarrow$) hold because every open cover of a compact metric space $X$ has a Lebesgue number.


Dynamically loaded Angular 10 component cannot access CommonModule

Question: I'm currently working on an Angular application. In one of my methods, I dynamically create a component, however I am unable to use ngClass, ngIf and other such directives from the CommonModule in the component.
Below is an example of the error:
Error when I use ngIf or ngClass inside the dynamically loaded logo component
WHAT I DID ALREADY:

I've imported commonModule in my project app.module.ts
I've imported commonModule in my display component and it works as I'm able to use ngIf and ngClass in every other component without any problem
Also I'm able to import any component without errors as long as I'm not using any directive from the CommonModule in my html
I've tried importing an instance of the NgModule through component factory createComponent function as shown in the angular documentation:

Quick view of angular documentation on component factory createcomponent
I have spent hours on this and believe it's related to my use of the createComponent method.
Please Help!
Here's my app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule, HammerGestureConfig, HammerModule,
 HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
import { GoogleAnalyticsService } from
 './shared/services/googleanalytics'; // import our Google Analytics
 service
import { BrowserAnimationsModule } from '@angular/platform-
browser/animations';
import { HttpClientModule } from '@angular/common/http';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { CommonModule } from '@angular/common';

@NgModule({
  declarations: [AppComponent],
  imports: [
   CommonModule,
   BrowserModule,
   AppRoutingModule,
   HttpClientModule,
   BrowserAnimationsModule,
   ],
  providers: [GoogleAnalyticsService],
  bootstrap: [AppComponent],
 })
 export class AppModule {}

Here's my Display component (Bdoc-a.component.ts)
import {
  Component, OnInit, Input, Output, Renderer2, AfterViewInit,
 AfterContentChecked, ViewChild, ElementRef,
  ComponentFactoryResolver, ViewContainerRef, ViewChildren, QueryList
  } from '@angular/core';
 import { StorageService } from
 '../../../../shared/services/storage.service';
import { AuthService } from '../../../../auth/auth.service';

 @Component({
  selector: 'app-bdoc-a',
  templateUrl: './bdoc-a.component.html',
  styleUrls: ['./bdoc-a.component.scss'],
 })
 export class BdocAComponent implements OnInit, AfterViewInit,
 AfterContentChecked {
  @Input() docConfig = { aspectRatio: '4:3', width: 800, height: 500 };
  @Input() bgStyles = { shadow: true, bgClr: '#ffcc00' };
  @Input() showBtns = false;

  fWidth = this.docConfig.width;
  fMaxWidth = this.docConfig.width;
  fHeight = this.docConfig.height;
  fMaxHeight = this.docConfig.height;

  @Input() url = '';
  @Input() settings = { ...  };

  ...

  @ViewChildren('loadDynAssetElEditItms', { read: ViewContainerRef })
  biEditEls: QueryList<ViewContainerRef>;
  @ViewChildren('loadDynAssetElViewItms', { read: ViewContainerRef })
  biViewEls: QueryList<ViewContainerRef>;
  loadDynAssetEl: any;

  @ViewChild('bieditorFloat', { read: ElementRef }) bieditorFloat:
  ElementRef;
  @ViewChild('bieditorFloatViewer', { read: ElementRef })
  bieditorFloatViewer: ElementRef;

  // variable to hold all document page elements
  allDocPages: any;
  allDocPageComp = [];

  constructor(private storage: StorageService,
          private resolver: ComponentFactoryResolver,
          private authService: AuthService,
          private elmRef: ElementRef) {
   this.url = 'templates/logo/1/logo1a/logo1a.component';
   }

   ngAfterViewInit(): void {
    this.initBrandAsset();
   }

  initBrandAsset(): void {
    this.allDocPageComp = [];

    setTimeout(() => {
      for (let i = 0; i < this.pages; i++) {
        this.loadDynAsset(this.url, i);
      }
      this.setDocPageVar();
    }, 200);
  }

  async loadDynAsset(url, pgIndex) {
    const impEl = await import( 'src/app/' + url);
    const allKeys = Object.keys(impEl);

    this.biEditEls.forEach((itm, i) => {
      if (i === pgIndex) {
      itm.clear();
      const newComp = itm.createComponent(
      this.resolver.resolveComponentFactory(impEl[allKeys[0]]));
      newComp.instance['bol']['test'] = 'LOGO TEST TEXT HERE... ' + pgIndex;

      this.allDocPageComp.push(newComp.instance);
    }
    });

    }
   }

Here's my Logo1a.component.html

      <ng-container>

B

S

   </ng-container>
   <ng-container *ngIf="config.body.show">

    <ng-container *ngIf="config.body.txt.show">

Logo Body Text Area

    </ng-container>
    <ng-container *ngIf="config.body.tag.show">

Logo Tag
   Area...

    </ng-container>

   </ng-container>

Here's my Logo1a.component.ts
import { NgModule, Component, OnInit, Input, Output, Renderer2,
AfterViewInit, AfterContentChecked, ViewChild, ElementRef,
 ComponentFactoryResolver, ViewContainerRef, ViewChildren, QueryList
} from '@angular/core';
 import { StorageService } from
'../../../../shared/services/storage.service';
 import { AuthService } from '../../../../auth/auth.service';

 @Component({
  selector: "app-logo1a",
   templateUrl: "./logo1a.component.html",
  styleUrls: ["./logo1a.component.scss"],
})

export class Logo1aComponent implements OnInit, AfterViewInit {
  @ViewChild('loadExtra', { read: ViewContainerRef }) loadExtra:
 ViewContainerRef;

 @Input() bol = { test: 'LOGO 1A LOADED!' }; // breadth of life

 public config = {
   symb: {
   show: true,
   mode: 'txt', // 'txt', 'symb', 'img'
  },
 body: {
  show: true,
  txt: { show: true },
  tag: { show: true }
  }
 }

  constructor(private storage: StorageService,
          private resolver: ComponentFactoryResolver,
          private vcRef: ViewContainerRef,
          private authService: AuthService,
          private elmRef: ElementRef) { }

     ngOnInit(): void {}

     ngAfterViewInit() {}
  }

Here's my Logo1a.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Logo1aComponent } from './logo1a.component';

@NgModule({
  imports: [CommonModule],
  declarations: [Logo1aComponent],
  exports: [Logo1aComponent]
})
export class Logo1aModule {}

But this was the error that was thrown after I dynamically imported the module instead of the component in my Angular 10 app as @jburtondev suggested:
ERROR Error: Uncaught (in promise): Error: ASSERTION ERROR: Type passed in is not ComponentType, it does not have 'ɵcmp' property.
....
Comment: @jburtondev ok would do that ...thanks
Comment: Hey Bode, welcome to stack overflow! Great to have you. Can you post your code please.
Comment: hi @jburtondev thanks for trying to help. Should I post the code in the comments on re-edit my original posts?
Comment: My pleasure, yes please.
Comment: Hi Bode! funny thing, something similar happend to me a few months ago. Turns out that I was over engineering that component, i didn't have to use the ```ViewContainerRef``` at all, just a simple ngFor loop was all I need to achieve what I want. I advice you like @jburtondev did, edit your question with some code and business requirement so we can help you
Comment: Great point Rod! I think I know the solution, just need to see the code lol now.
Comment: @Bode add the code to Stackblitz and provide a link in the question text. Just so it's easier to read.
Answer: The component needs to be in its own module which declares the CommonModule. Otherwise, Angular cannot associate it with the CommonModule at runtime.
1. Create a component module
@NgModule({
  declarations: [ YourDynamicComponent ],
  imports: [ CommonModule ] // THIS IS WHAT WILL TELL ANGULAR TO LOAD IT INTO YOUR COMPONENT
  exports: [ YourDynamicComponent ]
})

export class YourDynamicModule { }

2. Load the component
constructor(private compiler: Compiler, private viewContainerRef: ViewContainerRef) {}

createDynamicComponent(): void {
  const componentModule = this.compiler.compileModuleAndAllComponentsSync(YourDynamicModule);
  const factory = componentModule.componentFactories.find(c => comp.componentType === YourDynamicComponent);
  this.viewContainerRef.createComponent(factory);
}

3. It should now be be decorated with the CommonModule
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/224009/discussion-on-answer-by-jburtondev-dynamically-loaded-angular-10-component-canno).
Answer: So I finally got a not-so-clean working approach to my question.

I created a new module, LogoModules, where I imported all the logo modules I will be displaying in my display component
import { NgModule } from '@angular/core';
import { Logo1aModule } from '../templates/logo/1/logo1a/logo1a.module';
import { Logo2aModule } from '../templates/logo/2/logo2a/logo2a.module';
import { Logo3aModule } from '../templates/logo/3/logo3a/logo3a.module';
@NgModule({
// imports: [],
// exports: [],
})
export class LogoModules {}

This was modified a bit from @jburtondev's suggestion to pre-import all the modules but I still think there should be a cleaner way to do this part. Dynamically loading the modules and components without pre-importing the modules still works but also fails sometimes. I think this is due to some settings with the compiler and webpack in tsconfig. I need more research to clarify this.

I imported the LogoModules module in my display component
import { LogoModules } from '../templates/logo/logos.module';
...

BUT ...
So I am able to store the relative paths of each logo template in my database and display them dynamically based on user clicks, I updated my dynamic component loader in my Display component (Bdoc-a.component.ts) as shown below:
....
async loadDynAsset(url, pgIndex) {
  const mObj = await import('src/app/' + url2);
  const mKeys = Object.keys(mObj);
  const mName = mKeys[0];

  this.compiler.compileModuleAndAllComponentsAsync(mObj[mName])
    .then((factories) => {
      const f = factories.componentFactories[0];
      const newComp = this.testDynComp.createComponent(f);
      newComp.instance['bol']['test'] = 'LOGO TEST TEXT HERE... ' + pgIndex;
    });

  ....

}
....

And then I was able to get a consistent result without errors. Thanks again to @jburtondev for some suggestions. I'll update my answer as soon as I discover a better approach to my question.


Automatically download csv file with hidden link

Question: I'm trying to write a function that automatically download the table from the link below (when you click Tabelle exportieren->CSV-export button on the right)
https://www.marktstammdatenregister.de/MaStR/Einheit/Einheiten/OeffentlicheEinheitenuebersicht
The thing is, when I checked its HTML code, there is no link for the .csv file (href = '#'), seems like the link was hidden.
Is there any way to search for that hidden link, with some filters applied for the table?
Comment: if page uses JavaScript to add data then you may have to use selenium to control web browser which runs JavaScript. If you need to download only this file then you can get url after downloading in browser (in download manage should be option "get url of downloaded element") and then you can use this url in your code.
Comment: it seems it doesn't generate CSV on sever but in browser using JavaScript. You will have to use [Selenium](https://selenium-python.readthedocs.io/) to control web browser and click this link - and browser will download it.
Comment: it's something like this: blob:url/d158690c-25bb-4c32-824a-c4107b7cb249. Seems like an arbitrary query...
Answer: The website is loading the data dynamically, i.e. there is a server at the backend which is populating the result, for this you need to use selenium package and then capture the html.


Using Custom Dataset With nprtool

Question: Am trying to clasify objects using neural networks' nprtool in MATLAB. However, loading the data (input and outputs) is my problem. I have gone through the given examples in the documentation but am not able to customize the inputs and outputs. Part of the dataset is given below for your reference; assume that the data is already normalized. How can one use the the MATLAB Neural Network Toolbox nprtool with custom data like these?
% Small vehicles
XS1 = 1.0e+03 *[3.2730    0.0712    0.0614        5.1480]; % frame 167
XS2 = 1.0e+03 *[4.4680    0.0869    0.0668        6.2370];% frame 555
XS3 = 1.0e+03 *[2.5450    0.0742    0.0659        4.6900]; % frame 780
XS4 = 1.0e+03 *[1.9830    0.0617    0.0477        2.9680]; % frame 826
XS5 = 1.0e+03 *[2.9090    0.0630    0.0610        4.1600]; % frame 880
XS6 = 1.0e+03 *[3.8460    0.0797    0.0640        5.6700]; % frame 1283

% Medium vehicles
XM1 = 1.0e+03 *[4.7770    0.0981    0.0663        6.9560]; % frame 167
XM2 = 1.0e+03 *[5.1050    0.0997    0.0678        7.4460]; % frame 430
XM3 = 1.0e+03 *[4.0240    0.0846    0.0619        5.4780]; % frame 2020
XM4 = 1.0e+03 *[6.9750    0.1165    0.0794        9.6280]; % frame 2982
XM5 = 1.0e+03 *[5.2040    0.1063    0.0652        7.0810]; % frame 3081
XM6 = 1.0e+03 *[3.2830    0.0733    0.0645        4.6080]; % frame 4314

% Large vehicles
XL1 = 1.0e+04 *[1.0092    0.0148    0.0089        1.4948]; % frame 1340
XL2 = 1.0e+04 *[0.9351    0.0129    0.0096        1.2444]; % frame 1375
XL3 = 1.0e+04 *[0.6021    0.0141    0.0095        1.5096]; % frame 1625
XL4 = 1.0e+04 *[0.8734    0.0143    0.0086        1.1868]; % frame 1679
XL5 = 1.0e+04 *[1.0773    0.0141    0.0100        1.4933]; % frame 2204
XL6 = 1.0e+04 *[0.8491    0.0118    0.0097        1.0556]; % frame 3535

% CONCATANATING THE OBJECT FEATURES
XS = [XS1;XS2;XS3;XS4;XS5;XS6];
XM = [XM1;XM2;XM3;XM4;XM5;XM6];
XL = [XL1;XL2;XL3;XL4;XL5;XL6];

%  inputs matrix
X = [XS;XM;XL];

%% OUTPUTS
YS ={'smallvehicle';'smallvehicle';'smallvehicle';'smallvehicle';'smallvehicle';'smallvehicle'};
YM ={'mediumvehicle';'mediumvehicle';'mediumvehicle';'mediumvehicle';'mediumvehicle';'mediumvehicle'};
YL ={'largevehicle';'largevehicle';'largevehicle';'largevehicle';'largevehicle';'largevehicle'};

% outputs matrix
Y = [YS;YM;YL];

Answer: As the MATLAB documentation states:

Then arrange another set of Q target vectors so that they indicate the classes to which the input vectors are assigned

Here, we need a set of Q=3 target vectors, which are 1 if a training sample belongs to that class. In your example, the target matrix looks like this:
T =

     1     0     0
     1     0     0
     1     0     0
     1     0     0
     1     0     0
     1     0     0
     0     1     0
     0     1     0
     0     1     0
     0     1     0
     0     1     0
     0     1     0
     0     0     1
     0     0     1
     0     0     1
     0     0     1
     0     0     1
     0     0     1

The first column corresponds to small, the second to medium and the third to large vehicles. You can generate this matrix from your existing cell array Y by using cellfun to compare the entries to the strings 'smallvehicle' and so on:
T = [ cellfun(@(x)strcmp(x,'smallvehicle'),Y)   , ...
      cellfun(@(x)strcmp(x,'mediumvehicle'),Y)  , ...
      cellfun(@(x)strcmp(x,'largevehicle'),Y)   ];

Then you can start
nprtool

and use X as input and T as target. Remember to select Matrix Rows and not Matrix columns. The summary on the right helps: "Inputs 'X' is a 18x4 matrix, representing static data: 18 samples of 4 elements".
Comment: Thanks for this insight. Now how can the trained network be used to predict unseen data by stating the class of the vehicle. It is returning a matrix instead which I don't understand.
Comment: The output of `y=sim(net,someNewInput)` should be a 3x1 vector, which contains the outputs of the net for this input. The highest value will be your class (e.g. `[0.99 0.01 0]` will be a small vehicle). If this doesn't help, please ask a new question with details on what function you call, what your input is, and what the net returns (and what you expect).
Comment: Thanks for your response and help. Using the trained network on a new vehicle,XL, gave the following matrix. First  of all XL = [4.3569    3.3396    4.5793    6.1457] , then, sim(net,XL) = [0.0000    0.0000    0.0000    0.0000;  0.0845    0.1116    0.0773    0.0288;     0.9155    0.8884    0.9227    0.9712]. What does this matrix mean? Thanks a lot for the help.

Using Custom Dataset With nprtool


I want to change the style of all sibling elements

Question: I am using buttons for a tabbed navigation interface. I want to have the active tab red, and the rest black.

<button type="button" onclick="selectTab(this);">Astringents</button>
<button type="button" onclick="selectTab(this);">Exfoliators</button>
<button type="button" onclick="selectTab(this);">Moisturizers</button>

function selectTab(activeTab){
var siblings = activeTab.parentNode.childNodes;
for (s in siblings){
s.style.color='black';
}
activeTab.style.color='red';

I am having problems accessing the siblings properly. There are more buttons than these three so I need to solve this dynamically. I will be using Ajax so this page will not reload.
Answer: You are trying to do extra work... Why not keep a reference to the currently selected tab, then when a new selection is made, reset its style.
Also, it is much better to use CSS classes than inline styles for this (this way, you don't need to muck about with Javascript to change how your tabs look):

Tab 1

Tab 2

Comment: Thanks it worked and its cleaner than changing all the siblings for the sake of one.