Why cant I type in the text box of the second form

Question: Im trying to make two froms on one page. one right underneather the other. The first form is to put the main information in and then the second form is suppossed to be a report. The problem is that the second form wont allow any text to be put into the text box, it doesnt even seem to regonise that there is a text box on the page.
Any ideas why this might be happening?
Thanks

* {
  box-sizing: border-box;
}

#tl {
   padding: 1em;
  background: #f9f9f9;
  border: 1px solid #c1c1c1;
  margin-top: 2rem;
  width: 1400px;
  height:190px;
  margin-left: auto;
  margin-right: auto;
  padding: 1em;
  text-transform: uppercase;

}

#tl input {
  margin-bottom: 1rem;
  background: #fff;
  border: 1px solid #9c9c9c;
}

#report {
  padding: 1em;
  background: #f9f9f9;
  border: 1px solid #c1c1c1;
  margin-top: 2rem;
  width: 1400px;
  height:690px;
  margin-left: auto;
  margin-right: auto;
  padding: 1em;
  text-transform: uppercase;
}

#report input {
  margin-bottom: 1rem;
  background: #fff;
  border: 1px solid #9c9c9c;
}

.fdate{
  position:relative;
  left:60px;
  top:30px;
}

.fsales{
  position:relative;
  left:320px;
  bottom:22px;
}

.fservice{
  position:relative;
  left:650px;
  bottom:75px;
}

.fpart{
  position:relative;
  left:1000px;
  bottom:127px;
}

.fqty{
  position:relative;
  left:20px;
  bottom:120px;
}

.fhour{
  position:relative;
  left:376px;
  bottom:175px;
}

.fcust{
  position:relative;
  left:691px;
  bottom:225px;
}

.fname{
  position:relative;
  left:1068px;
  bottom:280px;
}

  .inputs{
   position:relative;
   top: 20px;

  }
.title1{
  position:relative;
  bottom:430px;
  left:500px;
}

<form>

        Date:
        <input type="text" id="fdate" name="fdate">

        Sales Order:
        <input type="text" id="fsales" name="fsales">

        Service Order:
        <input type="text" id="fservice" name="fservice">

        Part Number:
        <input type="text" id="fpart" name="fpart">

        Quantity:
        <input type="text" id="fqty" name="fqty">

        Hours:
        <input type="text" id="fhour" name="fhour">

        Customer:
        <input type="text" id="fcust" name="fcust">

        Name:
        <input type="text" id="fname" name="fname">

 Missing & Damaged Report

</form>

<form>

        Part Number:
        <input type="text" id="P1" name="P1">

</form>

Answer: The problem is postion:relative; to input class see work example:

* {
  box-sizing: border-box;
}

#tl {
   padding: 1em;
  background: #f9f9f9;
  border: 1px solid #c1c1c1;
  margin-top: 2rem;
  width: 1400px;
  height:190px;
  margin-left: auto;
  margin-right: auto;
  padding: 1em;
  text-transform: uppercase;

}

#tl input {
  margin-bottom: 1rem;
  background: #fff;
  border: 1px solid #9c9c9c;
}

#report {
  padding: 1em;
  background: #f9f9f9;
  border: 1px solid #c1c1c1;
  margin-top: 2rem;
  width: 1400px;
  height:690px;
  margin-left: auto;
  margin-right: auto;
  padding: 1em;
  text-transform: uppercase;
}

#report input {
  margin-bottom: 1rem;
  background: #fff;
  border: 1px solid #9c9c9c;
}

.fdate{
  position:relative;
  left:60px;
  top:30px;
}

.fsales{
  position:relative;
  left:320px;
  bottom:22px;
}

.fservice{
  position:relative;
  left:650px;
  bottom:75px;
}

.fpart{
  position:relative;
  left:1000px;
  bottom:127px;
}

.fqty{
  position:relative;
  left:20px;
  bottom:120px;
}

.fhour{
  position:relative;
  left:376px;
  bottom:175px;
}

.fcust{
  position:relative;
  left:691px;
  bottom:225px;
}

.fname{
  position:relative;
  left:1068px;
  bottom:280px;
}

  .inputs{

   top: 20px;

  }
.title1{
  position:relative;
  bottom:430px;
  left:500px;
}

<form>

        Date:
        <input type="text" id="fdate" name="fdate">

        Sales Order:
        <input type="text" id="fsales" name="fsales">

        Service Order:
        <input type="text" id="fservice" name="fservice">

        Part Number:
        <input type="text" id="fpart" name="fpart">

        Quantity:
        <input type="text" id="fqty" name="fqty">

        Hours:
        <input type="text" id="fhour" name="fhour">

        Customer:
        <input type="text" id="fcust" name="fcust">

        Name:
        <input type="text" id="fname" name="fname">

 Missing & Damaged Report

</form>

<form>

        Part Number:
        <input type="text" id="P1" name="P1">

</form>

Comment: Thanks its working now - Just so I can learn a bit more about it, why does having possition relative effect this?
Comment: because the `div` with class `inputs` is above the second `form`, so when you click on the `textbox` you are actually clicking on the first `div`


Linear time algorithm for $n\times n$ array of 1's and 0's

Question: Suppose that each row of an $n \times n$ array $A$ consists of 1's and 0's such that, in any row of A, all the 1's come before any 0's in that row. Assuming $A$ is already in memory, describe a method running in O($n$) time for finding the row of $A$ that contains the most 1's.
I don't understand how this is possible if the array was not already sorted. How can you possibly do this in O($n$) time? What if every element in the array was a 1? Then any algorithm I could think of would run in O($n^2$).
Comment: If every element in the array was $1$ you can already terminate after looking at the first row because there can't be more than $n$ ones.
Comment: Perhaps better off here: http://scicomp.stackexchange.com/ ?
Comment: @DanielFreedman: I looked at the site and it doesn't seem to have any questions about asymptotics.
Answer: Hint: Once you've seen a $1$ in column $k$, you never have to look at columns $\le k$ in any row anymore. You can move on to column $k+1$. In each step, if you see a $0$, you can exclude that row, and if you see a $1$ you can move on to the next column. Thus there can be at most $2n$ steps. I didn't fill in all the details because this is homework; feel free to ask if it's too vague.
Comment: Oh wow that is so simple. But I don't see where you got 2n from. Also, what would happen if every element is a 0?
Comment: very nice and tricky
Comment: @styfle: The $2n$ comes from the fact that there are $n$ rows and $n$ columns and each step excludes either a row or a column, so after at most $n+n=2n$ steps there's nothing left to exclude. If every element is a $0$, you just look at all the $0$s in the first column and then pick any of the rows. (That was part of the detail I'd left out: You start in the first column.)
Comment: To me it seems like you could do it in n steps instead of 2n steps. Since the outer loop would go from 1 to n (for each column) and inside: if A[row][col]=1, mark as answer, else, row = row + 1. The next iteration of the loop would then check the next column in the row with most ones (current answer). Does that make sense?
Comment: @styfle:  I don't think so. If you increment the column in every step, even if the step increments the row, then you can miss a better row. For instance, what would your algorithm do if the only $1$s are one in the first row and two in the last row? I think it would miss the last row and give the first row as the answer?
Comment: It would go through every element in the first row since all of them are 1's. Then it would be done and return the first row as the answer. If there are ties, it prefers the row closest to the top (just like with all zeros).
Comment: @styfle: That's a misunderstanding. By "if the only $1$s are one in the first row and two in the last row", I meant that there is exactly one $1$ in the first row and there are exactly two $1$s in the last row.
Comment: Oh I see what you're saying. It has to stay on the k+1 column to check rows that are further down. You're right.


pegar dados json imprimir php

Question: Gente como pego os dados em php de latitude e longitude dessa url abaixo
https://api.findmespot.com/spot-main-web/consumer/rest-api/2.0/public/feed/0ozWRQqxiMnv5bqJzSUIMyUIIbMGrP5qu/message.json

Answer: Você pode usar a função file_get_contents(). Ficaria algo como:
$conteudo = file_get_contents('https://api.findmespot.com/spot-main-web/consumer/rest-api/2.0/public/feed/0ozWRQqxiMnv5bqJzSUIMyUIIbMGrP5qu/message.json');
echo $conteudo;

Como é um JSON, podemos transformar ele em um objeto usando a função json_decode($conteudo). Se quiser ver o formato exato do JSON você pode usar o seguinte código
echo '
';
print_r($conteudo);
echo '
';

Agora que você já tem o conteúdo em um objeto, podemos fazer um foreach para percorrer todo o conteúdo do JSON
foreach ($conteudo->response->feedMessageResponse->messages->message as $key) {
    print_r('Latitude: '.$key->latitude);
    echo ' - ';
    print_r('longitude: '.$key->longitude);
    echo '
';
}

O código completo ficou assim então:
$conteudo = json_decode(file_get_contents('https://api.findmespot.com/spot-main-web/consumer/rest-api/2.0/public/feed/0ozWRQqxiMnv5bqJzSUIMyUIIbMGrP5qu/message.json'));
foreach ($conteudo->response->feedMessageResponse->messages->message as $key) {
    print_r('Latitude: '.$key->latitude);
    echo ' - ';
    print_r('longitude: '.$key->longitude);
    echo '
';
}

Comment: Phelipe e isso mesmo so nao estou sabendo agora e pegar latitude e longitude  rsrs
Comment: Complementei minha resposta. Agora ele pega os valores que você queria. Basta entender a estrutura do JSON e ir percorrendo ele.
Comment: Perfeito meu amigo
Comment: pode me tirar só mais uma duvida como eu faria para pegar apenas o ultima latitude e longitude ?
Comment: pode me tirar só mais uma duvida como eu faria para pegar apenas o ultima latitude e longitude ?

pegar dados json imprimir php


Type warning in Flaslist's renderItem prop

Question: I am getting a type warning in an application I developed with React native. I get the following warning in Flaslist's renderItem prop. How can I fix this warning?
Warning:

Type
'import("/Users/mac/Desktop/project/pokeApp/node_modules/@react-native/virtualized-lists/Lists/VirtualizedList").ListRenderItem<import("/Users/mac/Desktop/project/pokeApp/api/pokeapi").Pokemon>'
is not assignable to type
'import("/Users/mac/Desktop/project/pokeApp/node_modules/@shopify/flash-list/dist/FlashListProps").ListRenderItem<import("/Users/mac/Desktop/project/pokeApp/api/pokeapi").Pokemon>'.
Types of parameters 'info' and 'info' are incompatible.
Property 'separators' is missing in type 'import("/Users/mac/Desktop/project/pokeApp/node_modules/@shopify/flash-list/dist/FlashListProps").ListRenderItemInfo<import("/Users/mac/Desktop/project/pokeApp/api/pokeapi").Pokemon>'
but required in type
'import("/Users/mac/Desktop/project/pokeApp/node_modules/@react-native/virtualized-lists/Lists/VirtualizedList").ListRenderItemInfo<import("/Users/mac/Desktop/project/pokeApp/api/pokeapi").Pokemon>'.ts(2322)
VirtualizedList.d.ts(79, 3): 'separators' is declared here.
FlashListProps.d.ts(37, 5): The expected type comes from property
'renderItem' which is declared here on type 'IntrinsicAttributes &
IntrinsicClassAttributes<FlashList> &
Pick<Readonly<FlashListProps>, "pointerEvents" | ... 171 more
... | "persistentScrollbar"> & InexactPartial<...> &
InexactPartial<...>'

import { View, Text, ScrollView, TouchableOpacity, StyleSheet, Image, ActivityIndicator, ListRenderItem } from 'react-native'
import React, { useEffect, useState } from 'react'
import { Link } from 'expo-router'
import { Pokemon, getPokemon } from '@/api/pokeapi'
import { Ionicons } from '@expo/vector-icons';
import { useQuery } from '@tanstack/react-query';
import { FlashList } from "@shopify/flash-list";

const Page = () => {

    const pokemonQuery = useQuery({
        queryKey: ["pokemon"],
        queryFn: getPokemon,
        refetchOnMount: false
    })

    const renderItem: ListRenderItem<Pokemon> = ({ item }) => {
        return (
            <Link href={`/(pokemon)/${item.id}`} key={item.id} asChild>
                <TouchableOpacity>
                    <View style={styles.item}>
                        <Image source={{ uri: item.image }} style={styles.preview} />
                        <Text style={styles.itemText} >{item.name}</Text>
                        <Ionicons name='chevron-forward' size={24} />
                    </View>
                </TouchableOpacity>
            </Link>
        )
    }

    return (
        <View style={{ flex: 1 }}>
            {pokemonQuery.isLoading && <ActivityIndicator style={{ marginTop: 30 }} />}
            <FlashList
                data={pokemonQuery.data}
                renderItem={renderItem}
                ItemSeparatorComponent={() => <View style={{ height: 1, width: "100%", backgroundColor: "#dfdfdf" }} />}
                estimatedItemSize={100}
            />
        </View>
    )
}

const styles = StyleSheet.create({
    item: {
        padding: 10,
        height: 100,
        flexDirection: "row",
        alignItems: "center",
        justifyContent: "center"
    },
    itemText: {
        fontSize: 18,
        textTransform: "capitalize",
        flex: 1
    },
    preview: {
        width: 100,
        height: 100
    }
})
export default Page
Answer: The FlashList has its own types. For the prop renderItem that has a type ListRenderItem, maybe you can't use the ListRenderItem from react-native as a type to the FlashList's renderItem. Try not to pass the type to the renderItem or try to type the parameters.
const renderItem = ({ item }: Pokemon) => {
  return (
    <Link href={`/(pokemon)/${item.id}`} key={item.id} asChild>
      <TouchableOpacity>
        <View style={styles.item}>
          <Image source={{ uri: item.image }} style={styles.preview} />
          <Text style={styles.itemText} >{item.name}</Text>
          <Ionicons name='chevron-forward' size={24} />
        </View>
      </TouchableOpacity>
    </Link>
  )
}


Display external link using theme settings

Question: I'm using theme-settings.php to store links to external pages (like Facebook, Twitter, etc.) and the links aren't storing correctly. In theme-settings.php, I have:
function mytheme_form_system_theme_settings_alter(&$form, $form_state) {
 $form['mytheme_facebook'] = array(
'#type'          => 'textfield',
'#title'         => t('Facebook Link'),
'#default_value' => theme_get_setting('mytheme_facebook'),
'#description'   => t("Appears in sidebar block."),

);
On my Theme Settings page, I enter https://www.facebook.com/ in the "Facebook Link" field. When I hit save, I see that only "www.facebook.com" has been saved in that field.
So, when I call the field on my site, using
print theme_get_setting('mytheme_facebook');

the link that gets outputted is http://www.myurl.org/www.facebook.com/.
How can I get I get rid of the "myurl" stuff, so I get a working link to Facebook? Oh, and I'm using Drupal 7, if that helps.
Thanks in advance for any tips!
Answer: Drupal is probably applying your default text format to your field.
Try adding a #format value to the array that matches one of your less strict input formats.


Edit receber caption de varios labels

Question: Gostaria que um TEdit recebesse o valor de um TLabel e ao clicar em outra TLabel a propriedade caption concatenaria o que foi recebido antes.
Ex :
edit.text := valorlabel1 valorlabel2 valorlabel3 .....

Tentei usar uma variável global, mas uma hora ficará inviável.
var variavel_global1 : string;

Ao clicar na label:
procedure TForm3.edt_variavel1Click(Sender: TObject);
begin
edit1.Text := edt_variavel1.caption + ' ';
variavel_global1 := edit1.Text;
end;

Existe alguma outra forma disso ser feito?
Answer: A maneira mais simples seria, no evento onclick do label:
Edi1.Text := Edit1.Text + TLabel(Sender).caption+ ' ';
Comment: Bacana cara, era o que eu precisava...
Começou bem no site, bem vindo

Edit receber caption de varios labels


Is there any method to share database in iphone?

Question: I want build a app, in that app i should  able to shear my database with every one.
Is there any method to do that?
Comment: You'll need to be a bit more specific. Do you mean share your database with other apps on the iPhone, or with other iPhones? Or do you mean have one central database that your iPhone app will connect to?
Comment: yes i mean one central database that your iphone app will connect
Answer: Not in Apple's security model.  You can share it between several of your own applications, if your set things up correctly to begin with.


How might Google go about estimating and updating traffic speeds?

Question: This is, I guess, a specific example of a wider class of problem, one to which there must be a well-established solution, but which I, as a relative layman when it comes to statistics have thus far been unable to find.
I understand that Google can track the speed of cars on road segments, and therefore has a set of speed observations which are taken at irregular intervals. I initially, therefore, have two questions:

How can one take those irregular observations and come up with an estimate of current traffic speed (or indeed traffic speed at any point in time during the set of observations) given that traffic speed will vary over time, and
How can the uncertainty in that estimate be calculated given a knowledge of when the observations were taken?

For my second question, I would assume that the further in the past one's last observation was taken, the greater the uncertainty in the estimate, but how can this be formalised mathematically?
Is this a Bayesian problem?
Answer: There are many possible ways to approach this problem, depending on exactly what data you have and what your goals are. The most standard type of solution would be from the family of Kalman Filters. This is a Bayesian model, which updates our estimate (and uncertainty) for a quantity based on noisy measurements.
There are basically three components to the model:

Modeling the internal dynamics of the state. In the traffic case, this might say that traffic speeds change slowly over time, but can sometimes decrease very rapidly (e.g. due to an accident).
Modeling how external driving forces (which we know about) will affect the state. This could be time of day in the traffic case.
Modeling how noisy measurements are generated from the state. Perhaps traffic data comes from large trucks, so we say that measurements will be slight underestimates of the true speed except when the speeds are very low, and we have quantified how noisy the estimates are.

You can then plug in your assumptions and get the optimal estimator. Note that the vanilla Kalman filter assumes that all these models are linear, but more complex versions can allow for arbitrarily complicated models.
Answer: I would start with the dumbest thing like this $$\hat v(t,x)=(1-\phi) v_{limit}+\phi v(\tau,z)$$
where $$\phi=e^{-\kappa(z-x)^2-\theta(t-\tau)}$$
Here, $\hat v(t,x)$ current estimate of the speed at the coordinate $x$, $v(\tau,z)$ - last speed reading from the nearest road segment with coordinate $z$, $v_{limit}$ speed limit, $\kappa,\theta$ coefficients.
You can make it more complicated by adding multiple speed readings instead of the latest and nearest. The $\phi$ makes sure that in the absence of recent and near readings, the speed limit is your best estimate of the speed. It accounts for proximity both in time and space.
I should totally patent this.


Webpack: How to compile all less files in a project

Question: I use webpack for JS and now I want to use it for styles. I have a lot of styles in different folders and i want to compile them all without requiring each of them mannaully. The question is how to gather all the .less files in the folders and compile them via less-loader?
Answer: This isn't how webpack is meant to work, really. If you really want to do this, grunt/gulp is going to be a better choice.
Webpack's require mechanism ensures you build only the CSS you need for any given entry point, and gives you dependency management as well. If you do want to use webpack, but don't want to use the style-loader to insert them into the DOM etc., you can use the Extract Text plugin to build your compiled CSS into a separate file.
Comment: Thanks for the answer. Maybe it is possible to do the following: create less file and use webpack's require to search all the less files and then require this single file which requires all the others and then use Extract Text Plugin?
Comment: @aspirisen You could write a custom loader or plugin to do something along those lines, but I think it would be easiest to use Grunt or Gulp to create the single LESS file first, then `require` that in your webpack build (and optionally use the Extract Text plugin). The idea of 'compile all the files in this directory' is much more suited to grunt/gulp than to webpack.
Answer: I found some workaround using require.context.
First you need to create a js file in the root of the styles folder if you don't have one.
Use this code if you use css or less and always extract them
require.context('./', true, /(\.less$)|(\.css$)/);

First argument is relative path to folder in which webpack should search for the files, second tells that it should search in subfolders and the last one is regexp of the extension of the files that webpack should require. Then you need to requre this file or use it as entry point. This works if you use extract-text-webpack-plugin but doesn't work otherwise.
Using styles without extracting them to style separate file
The example above doesn't work if you don't extract them because webpack generate modules with styles but doesn't execute them. This is complete example that works in both cases:
(function (requireContext) {
    return requireContext.keys().map(requireContext);
} (require.context('../', true, /(\.less$)|(\.css$)/)));

Comment: I really wonder, how to do that in v3: https://webpack.js.org/configuration/entry-context/#context


Java Android Arraylist is null outside the method where it is assigned

Question: I am developing the home of my Social Network; so, to view the posts of the following users I have to insert all the following users on an array list.
The following variables are declared globally:
private ArrayList<String> Uidrecord = new ArrayList<>();
private ArrayList<String> uidFollowing = new ArrayList<>();

I'm doing it like this: (This is on the oncreate)
FirebaseFirestore.getInstance().collection("following").document(FirebaseAuth.getInstance().getCurrentUser().getUid()).collection("userFollowing").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
            @Override
            public void onComplete(@NonNull Task<QuerySnapshot> task) {
                if (task.isSuccessful()) {
                    for (QueryDocumentSnapshot document : task.getResult()) {
                        document.getData();
                        Uidrecord.add(cont,String.valueOf(document.getData()));
                        cont++;
                    }
                    int conta = 0;
                    for (String item: Uidrecord){
                        if(item == null) {
                            Toast.makeText(MainActivity.this, "null item", Toast.LENGTH_SHORT).show();
                            break;
                        }
                        uidFollowing.add(conta, item);
                        //Toast.makeText(MainActivity.this, uidFollowing.get(conta), Toast.LENGTH_SHORT).show();
                        conta++;

                    }
                    Toast.makeText(MainActivity.this, uidFollowing.size() + "", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(MainActivity.this, task.getException().toString(), Toast.LENGTH_SHORT).show();
                }
            }
        });

the problem is that when I go to do (outside the addOnCompleteListener method but always in the oncreate):
uidFollowing.get(0)

the returned value is null.
Do you know how I could solve this problem?
Comment: Data is loaded from Firestore asynchronously and by the time your `uidFollowing.get(0)` executes, the `uidFollowing.add(conta, item)` hasn't been called yet. I recommend verifying this by running the code in a debugger, or by checking the order of some log messages on the lines before/after those statements. For an explanation and how to deal with this asynchronous behavior, see https://stackoverflow.com/a/51002413/209103
Answer: Yes you will get null because addOnCompleteListener is async method,if you call get() method outside addOnCompleteListener, get() method will executed before onComplete() .if you want item at 0 call right after add().
  for (String item: Uidrecord){
                        if(item == null) {
                            Toast.makeText(MainActivity.this, "null item", Toast.LENGTH_SHORT).show();
                            break;
                        }
                        uidFollowing.add(conta, item);
                        //Toast.makeText(MainActivity.this, uidFollowing.get(conta), Toast.LENGTH_SHORT).show();
                        conta++;

                    }

log.i("following",String.valueOf(uidFollowing.get(0)))

Comment: So there is no way to call the get out of the method? because I need the get for a firestore query and I have to use recyclerview. This is my complete code https://codeshare.io/WdN6pM
Comment: I tried to put the recyclerview inside the oncomplete like this https://codeshare.io/Lwno6e but then it gives me the following error: `2021-06-14 11: 25: 11.666 11745-11745 / com.conta.pophome E / AndroidRuntime: FATAL EXCEPTION: main
     Process: com.conta.pophome, PID: 11745
     java.lang.NullPointerException: Attempt to invoke virtual method 'void com.firebase.ui.firestore.FirestoreRecyclerAdapter.startListening ()' on a null object reference
         at com.conta.pophome.MainActivity.onStart (MainActivity.java:467)`
Comment: All the work that rely on "uidFollowing" list should be inside onComplete.@PopHome2
Comment: Unfortunately I can't just put the query on onComplete because I need a for that also includes the Recyclerview code. I have moved on to this question for this problem->https://stackoverflow.com/questions/67971227/java-android-firestore-make-an-oncomplete-and-firestorerecycleradapter-synchrono


How to allow visitors add option in poll?

Question: I would like to have a poll for logged in and anonymous users to vote.
In the poll, users are allowed to add in their own poll option and vote. (Just like how Facebook poll is working previously)
Is there any drupal way which I can do this? Or I need to use some combination of ways to achieve this?
Answer: Advanced Poll

Advanced Poll is a replacement to Drupal's poll module and provides
multiple voting systems, decision-making tools, and management
options.

Then in permissions (<code>/admin/people/permissions</code>), allow anonymous and authenticated users to vote and add write in votes.
Comment: But advance poll does not allow voters to add their own option and vote for that?
Comment: In permissions there is a `Add write in-votes` (2nd last on the picture above)


Accordion table em fileira única

Question: Estou trabalhando em uma app rails. No momento estou mexendo no front-end. Tenho uma tabela de como ela se comporta em telas grandes.

porém ao reduzir a tela (tamanho de celular) gostaria q ela ficasse no estilo acordion com dropdown somente pele thead Nome.
Todos os outros campos ("email, telefone, origem, status e codigo") ficariam escondidos e só mostraria quando o usuário clicasse no Nome que ele quisesse, daí faria um dropdown no resto das informaçoes, mostrando uma embaixo da outra.
Alguém sabe como fazer? Não sei quase nada de JS, e acho q terá q fazer boa parte nele né...
Comment: Na verdade não precisa de JS, vc pode ter um dropdown "escondido" que só aparece quando a tela for pequena. Então ao mesmo passo que vc mostra o Dropdown em telas pequenas vc tb pode esconder a tabela nessas telas. Tudo com @media e CSS, se quiser eu monto um exemplo simples pra vc.
Comment: Se for possível montar o exemplo agradeceria! Obrigado
Comment: Postei um exemplo, ele apenas alterna os valores do display no CSS quando a tela é menor. Pra vc testar copie o código no seu projeto e faça um teste diminuindo e aumentando a janela do Browser
Answer: Conforme dito no comentário usei apenas @media only screen and (max-width: 576px) que é o menor breacking point oficial do Bootstrap para setar display na tabela e no collapse. Sendo assim, quando a tela for menor que 576px eu escondo a tabela e mostro o collapse, e quando for mair escondo o collapse e mostro a tabela.
Veja abaixo o exemplo: (vc precisa colocar a tela em 576px para ver mudar a tabela pelo collapse ok)

#accordion {
    display: none;
}
.table {
    display: table;
}
@media only screen and (max-width: 576px) {
    #accordion {
    display: block;
    }
    .table {
        display: none;
    }
}
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous" />

        #
        First
        Last
        Handle

        1
        Mark
        Otto
        @mdo

        2
        Jacob
        Thornton
        @fat

        3
        Larry
        the Bird
        @twitter

            <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
                First
            </button>

Mark

Otto

@mdo

            <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
                Last
            </button>

Jacob

Thornton

@fat

            <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
                Handle
            </button>

Larry

the Bird

@twitter

OBS: Usei exemplos de código retirador diretamente da Documentação oficial

Accordion table em fileira única


Call $().dropdown inside react component

Question: I'm using react version of Semantic-UI in a project and i need to create a custom dropdown component which has slightly different inner html structure than semantic-ui dropdown. So i decided to define a new class to return my desired html structure like this:
import React from 'react';
import {Icon} from 'semantic-ui-react';

class CustomDropdown extends React.Component {

    componentDidMount() {
        console.log(!!window.jQuery); // outputs 'true', which means jquery is defined
        $('.ui.dropdown').dropdown();
    }

    render() {
        return(

                <input name="states" type="hidden"/>

                Some text
                <Icon name="dropdown"/>

States

Alabama

Alaska

Arizona

Arkansas

        );
    }
}

export default CustomDropdown;

Jquery is loaded using webpack ProvidePlugin:
new webpack.ProvidePlugin({
    $: 'jquery',
    jQuery: 'jquery',
    'window.jQuery': 'jquery'
}),

but when i use this component in my codes, the line $('.ui.dropdown').dropdown() gives error :
Uncaught TypeError: $(...).dropdown is not a function
So how can i use .dropdown() function inside my react component?
Comment: have you tried jQuery('.ui.dropdown').dropdown() ?
Comment: @beaumontwebdev same error : `jQuery(...).dropdown is not a function`
Comment: Are you also loading the `dropdown` plugin somehow? It's not a regular jQuery method. You could try logging `!!window.jQuery.fn.dropdown` to see if it's available for you.
Comment: @m90 that's what i need to know, how to import `dropdown` js plugin ? tried `!!window.jQuery.fn.dropdown` and it returns false
Comment: @MehranTorki to be on the same page the `dropdown` function is provided by `semantic-ui-react` since from what I know `jquery`  does not provides such kind of function
Comment: the `dropdown` function belongs to which package ? because it does not belongs to `semantic-ui-react` since I scanned your code again and `dropdown` function was not coming from `semantic-ui-react`
Comment: @Gardezi When i include directly [jquery.js](https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js) and [semantic.js](https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.12/semantic.js) in my template as script tags, then .dropdown() works fine in browser console.
Comment: @MehranTorki is `semantic-ui-react` `semantic.js` ???
Answer: @MehranTorki you will need to import dropdown function semantic.
and you will need to do something like this
import React from 'react'
import { Dropdown } from 'semantic-ui-react'

// TODO: This is missing functionality for sub-menu here from SUI core examples.
// The "Publish To Web" item should contain a sub-menu.

const DropdownExampleDropdown = () => (
  <Dropdown text='File'>
    <Dropdown.Menu> // -------------------------------
      <Dropdown.Item text='New' />
      <Dropdown.Item text='Open...' description='ctrl + o' />
      <Dropdown.Item text='Save as...' description='ctrl + s' />
      <Dropdown.Item text='Rename' description='ctrl + r' />
      <Dropdown.Item text='Make a copy' />
      <Dropdown.Item icon='folder' text='Move to folder' />
      <Dropdown.Item icon='trash' text='Move to trash' />
      <Dropdown.Divider />
      <Dropdown.Item text='Download As...' />
      <Dropdown.Item text='Publish To Web' />
      <Dropdown.Item text='E-mail Collaborators' />
    </Dropdown.Menu>
  </Dropdown>
)

to see what this code shows look at this url
https://react.semantic-ui.com/maximize/dropdown-example-dropdown
Please look at the code samples over here for more examples
https://react.semantic-ui.com/modules/dropdown#dropdown-example-dropdown
I have copied the whole example but you just need to use the code which has the commented //------ line. And import like the DropDown like I have imported to get things working
Comment: @If you still need any help feel free to ask
Comment: honestly i still don't know how to implement a html structure like `` using dropdown item or menu. A little bit more clarification will save me lots of time. thanks
Comment: Well sir if you are going to go with the answer that I posted above then I don't think you need to provide your own html. Just give it your classes and labels etc and the rest of the is left for the component

but if you still want to go with your own html then try to load sematic.js like you loaded jquery and do what you are doing right now and see if it works
Comment: if you till need help feel free to ping me


Convert a list from ord into a List

Question: I would like to convert what is given from bin into a list.
What I have:
x = input()
for y in x:
    z = (bin(ord(y)))
    print (z)

What I get:
0b1101000
0b1100101
0b1101100
0b1101100
0b1101111

What I want:
[0b1101000, 0b1100101, 0b1101100, 0b1101100, 0b1101111]

Comment: replace `print(z)` to `mylist.append(z)`
Answer: Use a list comprehension:
z = [bin(ord(y)) for y in x]
print(z)

That is a shortcut for this:
z = []
for y in x:
    z.append(bin(ord(y))]
print(z)

Comment: Good answer. I still like the old style (w/o the list comprehension) for readability, at least for newbies (like myself).
Comment: This worked perfectly thank you. I also feel the same way, it's easier for me to understand when it's written out completely instead of using the shortcut.
Comment: @NucleoNeco: If my answer solved your problem, please consider accepting it by clicking the greyed-out checkmark below the vote count.  That gives me a reward for solving your problem and removes this question from the unanswered list.

Convert a list from ord into a List


Need help ordering a list of functions

Question: List the functions below from lowest order to highest order. If any two or more are of
the same order, indicate which.
$n$, $n^3$, $2^n$, $\ln n$, $n^2$, $\ln^2 n$, $\sqrt n$, $2^{n−1}$, $\ln n$, $e^n$
I made n = 2, plugged in the values and came up with the following order:
$\ln n$, $\ln^2 n$, $\ln n$, $\sqrt n$, $n$, $2^{n-1}$, $n^2$, $2^n$, $e^n$, $n^3$
I doubt this order is correct, I just do not know. Please help.
Comment: What do you mean by lowest to highest?
Comment: Yes lowest to highest
Comment: That does not answer my question. What do you mean when you say you want them ordered lowest to highest? They are not strickly greater/less than each other
Comment: You have ln n in there twice - check if you're missing something (e.g. should one be n ln n or log_2 n or something?)
Answer: If there exists limit
$$
\lim_{n\to+\infty} \dfrac{f(n)}{g(n)}=C,\qquad |C|<\infty,
$$
then we will assume that
functions have the same order, if $0<|C|<\infty$,
function $f(n)$ has lower order than $g(n)$, if $C=0$.
Use these well known limits:
$$
\lim_{n\to+\infty}\dfrac{\ln n}{n^a}=0, \qquad a>0;
$$
$$
\lim_{n\to+\infty}\dfrac{n^a}{b^n}=0, \qquad b>1.
$$
Then, for example,
$$
\lim_{n\to+\infty}\dfrac{\ln n}{\lg n}=\lim_{n\to+\infty}\dfrac{\ln n}{\ln n / \ln 10}=\ln 10\ne 0;
$$
$$
\lim_{n\to+\infty}\dfrac{\ln n}{\ln^2 n}=\lim_{n\to+\infty} \dfrac{1}{\ln n}=0;
$$
$$
\lim_{n\to+\infty}\dfrac{2^n}{2^{n-1}}=\lim_{n\to+\infty} 2=2\ne 0;
$$
$$
\lim_{n\to+\infty}\dfrac{2^n}{e^n}=\lim_{n\to+\infty} \left(\dfrac{2}{e}\right)^n= 0.
$$
So, order is as following:

$\lg n$, $\ln n$ (they have the same order);
$\ln^2 n$;
$\sqrt{n}$;
$n$;
$n^2$;
$n^3$;
$2^{n-1}$, $2^n$ (they have the same order);
$e^n$.
Answer: You are quite correct - your answer is wrong.
I assume that you are talking about Big O notation. To answer the question:

Read the article, your notes and the textbook
Classify the functions by the notation the fall into - to help you have some linear, polynomial, exponential, logarithmic and quasilinier.
Within each classification decide which will grow faster.
Comment: So basically put them in order based on how long each function will run for?
Comment: Not exactly - the Big O notation is based on how long they will "run" (in idealized machines") as $n\to \infty$. As you have already found - this is not the same as $n=2$.
Comment: Not in terms of how long each function will run, but in terms of how long a program of *order* of that function will take to run, as the size of its input grows.

Need help ordering a list of functions


How to customize SlidingDrawer to lock in the middle of the Screen?

Question: Anybody has a sample project or any idea to make a customized Sliding Drawer which is able to lock in the middle of the screen, cover the whole screen, and of course hide at the bottom?
The second, and the third is not a big deal. But the first one, I think a bit of workaround is needed. Any solution?
Thanks
Answer: Using this attribute: android:topOffset.
This attribute means the offset from the top when the drawer was expanded.
Then the only thing worry about would be how to get the screen's height.
Comment: try to describe your answer.  :-)


Find third value

Question: I have a very simple problem but I feel like I am brain-dead.
I cant figure it out how to calculate this in Java:
<code>1321 = 0
1771 = 640
1500 = ?
</code>
Thanks.
Edit:
Sorry for no context. (And english not my first language)
I must basically calculate the value that number 1500 represents.
If 1321 is min (=0) and 1771 is max (=640) where does 1500 fall in (between 0 and 640) ?
I hope I am more clear now :)
Comment: Some context would be very helpful. $1321$ is almost never $0$, and when it is, $1721$ isn't usually $640$. Are you working with modular arithmetic?
Comment: See http://math.stackexchange.com/questions/7497/what-is-wrong-in-my-proof-that-90-95-or-is-it-correct/50512#50512.
Comment: Looks like the question is about linear interpolation between data points $(1321,0)$ and $(1771,640)$,
in particular about how to find $y$ such that $(1500,y)$ would be on the same line.

The answer comes from the equation of the line passing through two known points. Have you seen that in school algebra?
Comment: Um, what? ${}{}$
Comment: I updated my question. I hope I am more clear.
Answer: linear interpolation?
scale x ranges from 1321 to 1771
scale y you want to range from 0 to 640
gradient = (640 - 0) / (1771 -1321)
1500 -1321 = gradient ( x - 0)
x is your answer.
I'm sure you could rearrange this nicely.
(correcting typo)
Comment: i think it is $385$
Answer: i dont know exactly if it is way to solve this problem,but i think about one thing,if $1321=0$ and  $1771=640$
then for calculating  where does fall $1500$,we have to consider what is the difference from min to $1500$ and from $1500$ to max value and make proportion.
if we do so we get
$450/179=640/x$  from this  $x=254$,i  think that we could solve this problem like this way
Comment: thanks very much for commenting on error

Find third value


Don't know why I'm getting a foreign constraint error in sqlite

Question: So I've created these two tables in SQLite:
CREATE TABLE CONFLUENCE_LINKS (
    longLink        TEXT NOT NULL
                         PRIMARY KEY,
    shortLink       TEXT NOT NULL
                         DEFAULT [short link not found yet],
    dateLastUpdated TEXT NOT NULL
                         DEFAULT [last updated date will be added soon]
);

CREATE TABLE LOG_CONFLUENCE_PAGES_TO_FIX (
    shortLink             TEXT    NOT NULL
                                  PRIMARY KEY,
    dateChecked           TEXT    NOT NULL,
    numDaysMissingAltText INTEGER NOT NULL,
    FOREIGN KEY (
        shortLink
    )
    REFERENCES CONFLUENCE_LINKS (shortLink) ON DELETE CASCADE
                                            ON UPDATE CASCADE
);

CREATE TABLE CONFLUENCE_PAGES_MISSING_ALT_TEXT (
    shortLink       TEXT NOT NULL
                         PRIMARY KEY,
    pageName        TEXT NOT NULL,
    hasImages       TEXT NOT NULL
                         DEFAULT FALSE,
    hasAltText      TEXT NOT NULL
                         DEFAULT FALSE,
    imageNamesLinks TEXT NOT NULL,
    FOREIGN KEY (
        shortLink
    )
    REFERENCES CONFLUENCE_LINKS (shortLink) ON DELETE CASCADE
                                            ON UPDATE CASCADE

Then I added a row to CONFLUENCE_LINKS:
INSERT INTO CONFLUENCE_LINKS (longLink) VALUES ("espn.com")

Then I try to remove this row and commit this change using the GUI buttons in SQLiteStudio.   SQL won't remove this row; I get this error instead:
Error while deleting row from table CONFLUENCE_LINKS: foreign key mismatch - "CONFLUENCE_PAGES_MISSING_ALT_TEXT" referencing "CONFLUENCE_LINKS"

I'd kinda understand getting this error if I was deleting data from CONFLUENCE_LINKS (parent table) that was actually getting referenced in CONFLUENCE_PAGES_MISSING_ALT_TEXT (child table).  But CONFLUENCE_PAGES_MISSING_ALT_TEXT contains no data!  So I don't understand why I'm getting this error now.
I'm using Linux Mint 20 btw, if that helps anything.
EDIT
My bad for forgetting to include one of the key table definitions.  I've added it above.
Comment: What's the definition of `CONFLUENCE_PAGES_MISSING_ALT_TEXT`?
Comment: *I'd kinda understand getting this error if I was deleting data from CONFLUENCE_LINKS* but you are deleting from `CONFLUENCE_LINKS`. Also, what is `CONFLUENCE_PAGES_MISSING_ALT_TEXT`?
Comment: It works fine for me: https://dbfiddle.uk/?rdbms=sqlite_3.27&fiddle=3cffb01e8c4884730713dc152bc027eb
Comment: My bad for forgetting to include one of the key table definitions. I've added it above.
Comment: Thanks for referencing dbfiddle.uk @forpas .  I had never heard of that before.  I definitely bookmarked that.
Answer: So I'm unable to replicate the error too, if I run the DELETE statement from the Linux terminal:
$sqlite3 NAME_OF_DB

sqlite> DELETE FROM CONFLUENCE_LINKS WHERE longLink = 'espn.com';

But I do get the error if I delete this row using the GUI buttons in SQLiteStudio (v3.3.3).  At first I thought the issue was with this db manager, so I downloaded and tested a bunch of other db managers.   The error persisted with these other db managers too, which suggests the issue is likely with my code.

Turns out I needed to add an INDEX table too.
Here's that third INDEX table:
CREATE UNIQUE INDEX UX_CONFLUENCE_LINKS_SHORTLINK ON CONFLUENCE_LINKS(shortLink)

Everything is working now!!!
Below are some references that helped me:

Answer from a StackExchange post
SQLite documentation on db indexes
W3Schools page on SQL UNIQUE constraint


Users accessing our email when traveling overseas are seeing strange SPAM behavior

Question: I run technology for an international non-profit, so I have users that could be checking their email from Pennsylvania one day, Santo Domingo the next, and Kabul, Afghanistan, the next week. Recently, I'm seeing a strange behavior - where it appears that their spam filtering (logically on their client - Entourage or Outlook) behaves differently when accessing the email overseas. Does that make any sense at all? Does anyone have any experience like that?
Comment: More info needed. What spam-filtering software? What message infrastructure are you running? What's the change in behavior? Which countries are you based in, and travelling to?
Comment: Define "differently".
Answer: No, it shouldn't be doing anything differently depending on where the client is physically located.  The only reason that they might act differently would be if they weren't able to get updates from the servers while there which would then let the SPAM come in.
Answer: There may be a remote chance that some of the foreign ISP access is running through transparent proxies which may not be that "transparent" where the proxies may be leaving their SMTP header entries in the actual message delivery transaction. Those headers may reflect IP ranges (of the ISPs/their proxies) which have been identified as "problematic" depending on how the spam weighing/computation is derived.
The first point of troubleshooting this further may be to examine the message headers of those mis-classified messages carefully.


Why is it impossible to map every real number to a natural number

Question: Why are there more numbers from [0,1] than all of natural numbers?
How is the new number that you create using Cantors diagonal argument not on the list? If that list contains all the real numbers?
Example:
0 - 0.241251212...
1 - 0.556868362...
2 - 0.5177412125...
3 - 0.251868242...
And by making by adding one to first digit of first number, second digit of second number etc.. we get a number that is not on the list.
Let's call this new number C.
C - 0.3689...
How is it possible that this number C is not on the list? It doesn't feel possible.
I made a new table of numbers that suggest it should be possible to map every single natural number to a real number
0 - 0.000000000...
1 - 0.100000000...
2 - 0.200000000...
3 - 0.300000000...
4 - 0.400000000...
We can keep going like this until we reach 10th (or 11th if we count from 0) number where something interesting happens. 10 should be matched to 0.10 followed by trailing zeros to infinity. But 0.10 is the same as 0.100000000... and we already matched that to 1. We get a free number to match something to! We will use that later.
Now if the real numbers first digit after the decimal point is greater than 0 we can just match it and rest of the digits to a natural number.
427794279... - 0.427794279...
816472849... - 0.816472849...
But there's a problem. What happens when the first digit after the decimal point is equal to 0? What can we map 0.0034052400000... to? That's where those free unmatched numbers come in.
We first write the part after the zeroes which is 340524 we ignore the trailing zeroes. Then for every zero before 340524 we add that many zeroes at the end of the natural number and we get:
34052400 - 0.003405240000...
10 - 0.010000...
100 - 0.0010000...
5000 - 0.00050000...
What's neat about this list is that we can find where on the list every real number is. If we use Cantors diagonal argument on the ordered list starting from 1 we will get 0.211111... which we know is matched to 211111... How ever you change the number it's guaranteed to change it into a number that is on the list.
or even C
C - 0.3689... - 3689...
To make sure this list maps everything after 9th (or 10th) number we match every multiple of 10 to its real number before we got to next power of 10. After that we drop back down and map every number before it using rules above.
9 - 0.9000...
10 - 0.0100...
20 - 0.0200...
...
90 - 0.0900...
11 - 0.1100...
12 - 0.1200...
This all makes sense, so why is it not right? Any counter-example or a mistake that you can find would help a lot.
Thanks!
Comment: How is it possible that the number $C$ is not on the list? Well it's not the first number because it's different in the first decimal place. It's not the second number because it's different in the second decimal place, etc.
Comment: Well actually natural numbers **do** have infinitely many digits. Most of those digits are $0$ though.
Comment: Your approach fails because no natural numbers has infinitely many digits while some real numbers do. For instance $1/3=0.333..$
Comment: You mentioned a number $211111\ldots$. What kind of number is that? Do the digits ever come to an end?
Comment: No, the digits never end. After 2 its a never ending string of 1s.
Comment: Which natural number are you mapping to 1/3? 3333.... with infintely many 3's is not a natural number.
Comment: "3333.... with infintely many 3's is not a natural number." That was the idea, to match it to that number. If 3333... isn't a natural number then that makes my argument invalid. Thanks for pointing that out.
Answer: The idea of Cantor's diagonal argument is the classical method of proof by contradiction. One supposes that there is a list of all real numbers and produces, using a perfectly valid method (i.e., following strictly all the postulated axioms and rules of deduction), a real number that is different from every real number in the list.
This number must be in the list, by hypothesis. Therefore, it must be exactly equal to one of the numbers (that's precisely what belonging to the list means). But that does not happen, so one has a contradiction. As every step is perfectly valid, one concludes that the hypothesis is wrong and there is no injective function from $\mathbb{N}$ to $\mathbb{R}$.
Your idea is not correct because at the beginning of your description, you say
"Now if the real numbers first digit after the decimal point is greater than $0$ we can just match it and rest of the digits to a natural number."
Every natural number consists of a finite string of digits (or an infinite sequence where all but a finite amount of digits are different from $0$), therefore, it is impossible to match the number you mentioned $0,2111 \ldots$, which has an infinite amount of digits equal to $1$, to a natural number, because this natural number would have to have infinitely many digits different from $0$.
Comment: If 2111... with never ending string of 1s is not a natural number then the argument doesn't work. That was a false assumption I had when I made the argument.


Is there a reason why my ArrayFormula is not working in the other cells of my column?

Question: In a Google sheet with form responses, I made an additional column where I want to look up from each submission if the value left of my new column already occurs in a range on another sheet.
So this is going to be a Vlookup formula finally.
Unfortunately, I didn't make it to the Vlookup part yet because the ArrayFormula part is not working.
I started off by looking to the cell value at the left with this formula, which worked, but the ArrayFormula part of it DOESN'T work.
<code>=ArrayFormula(indirect(ADDRESS(ROW(), COLUMN()-1)))
</code>
I know that some functions don't work very well with ArrayFormula,
But I don't see any reason here this should not work because it's only looking to its row and its column.
I hope the image shows the problem well enough
Comment: Indirect() can't be iterated over an array. Maybe there other ways to achieve what you want?
Comment: There seems to be a lot of functions that don't work with ArrayFormula, but I can't find a blacklist of functions to avoid, so I've been doing just try and error with growing frustration. The only way I think I can make it to work is to paste in the formula with a script, triggered at FormSubmit, but this not so reliable I'm afraid, especially because I'll be having, in the  long run, more than 100 forms connected to this one spreadsheet.
Answer: If you just want to repeat the values from the previous column (let's say column A, starting in row 2), you can try in column B (also in row 2)
<code>=Arrayformula(if(len(A2:A), A2:A,))
</code>
Change range to suit. See if that helps?
UPDATE: To repeat the previous column (anywhere you input the formula) try (in row 2)
<code>=offset(A1, 1, column()-2, rows(A1:A))
</code>
To 'limit' the output you can use any number instead of rows(A1:A) or replace it with COUNTA(A1:A)...
Comment: The only consistent thing here is that the reading column is always on the right of the source column. The formula must work regardless of where this pair of columns is located.  This is why I was using  ROW(), COLUMN() so that the formula can determine its own position first.
Comment: I posted a second formula. See if that helps?
Answer: you can do something like this, which will search for specific header across entire sheet and then return values of that column:
<code>=QUERY({INDIRECT("Sheet1!"&
 ADDRESS(1,       MATCH("job ID", Sheet1!1:1, 0), 4)&":"&
 ADDRESS(1000000, MATCH("job ID", Sheet1!1:1, 0), 4))},
 "select * where not Col1 matches 'job ID' and Col1 is not NULL", 0)
</code>

without sheet name:
<code>=QUERY({INDIRECT(
 ADDRESS(1,       MATCH("job ID", 1:1, 0), 4)&":"&
 ADDRESS(1000000, MATCH("job ID", 1:1, 0), 4))},
 "select * where not Col1 matches 'job ID' and Col1 is not NULL", 0)
</code>
Comment: This could be a possible solution. I got your set up working, It reads the headers only in row 1 but this I could change to row 20, this will also be consistent through all my forms. On the other hand, the sheet name can't be hardcoded. I could have a cell on the sheet that holds the sheet name but I'm not sure if I'll get that to work :-(.
Comment: Without a sheetname it will only look at the active sheet? Because every Sheet will have a header named Job ID, just not always on a the same column but always on the same row?   As I have already stated, every cell in the reading (right) column have to be looked up in a known column in another sheet, so including this Vlookup function in your formula will bring me back to an ArrayFormula I believe, or do I see this wrong?


Analyzing seasonality in data

Question: In order to analyze the data in presence of seasonality, I used two methods: Proportional hazard model (Cox model) and time series method (Triple Exponential Smoothing (Holt Winters Method)). Now , my question is that what is the difference between them? How should I know which of them is better for my application?
Answer: Probably neither. You should use your actual data to identify an appropriate model. If you just have a single series you might investigate ARIMA modelling and Intervention Detection procedures. If you have causal series then investigate Transfer Functions/Dynamic Regression and Intervention Detection procedures.
Comment: Thank you for your answer. I used Holt Winters Method because I saw in some references that if we have "seasonality" AND "trend" in our data we cannot use moving average or single smoothing methods...May I know why do you think those two methods are are not useful for my application?
Comment: I am not familiar with promotional hazard BUT I am very familiar with the shortcomings of assuming any particular structure for a model as parameter estimates are based upon a particular model. Let the data suggest the model.. To prove this point take your data and estimate the hw model and the errors from the model . Present the normal summary statistics e.g. variance /r-sq /aic and your forecasts. I will take your data and submit it to a commercial package AUTOBOX and present the results... Then you decide which approach is best for the data.
Comment: Thank you for your suggestion. Regarding ARIMA model, since I am not familiar with that, I have problem with determining p,d and q values for that. Could you briefly help me with that?
Comment: you might want to look at http://www.autobox.com/cms/index.php/blog .There is a discussion and some flow charts that might help.

Analyzing seasonality in data


Hirsch's Differential Topology vs Rudin Functional analysis definition of weak and strong topology.

Question: I'm currently reading through chapter 2 - Function spaces of Hirsch's Differential topology I don't however get a feeling of what exactly it means.
From the book:

A weak topology on a compact-open $C^r$ topology on $C^r(M,N)$ is generated by the sets defined as follows. Let $f \in C^r(M,N)$. Let $(\varphi,U),(\psi,V)$ be charts on $M, N$; Let $K \subset U$ be a compact set such that $f(K) \subset V$; let $0 < \epsilon \leq \infty$. Define a weak subbasic neighborhood
$$
\mathcal{N}(f;(\varphi,U),(\psi,V),K,\epsilon)
$$
to be the set $C^r$ maps $g : M \to N$ such that $g(K) \subset V$ and
$$
\left\lVert D^k(\psi f \varphi^{-1})(x) - D^k(\psi g \varphi^{-1})(x)\right\rVert < \epsilon
$$
for all $x \in \varphi(K), k = 0,\ldots,r$. This means the local representation of $f$ and $g$, together with their first $k$ derivatives, are within  $\epsilon$ at each point of $K$.
The weak topology on $C^r(M,N)$ is generated by these sets; It defines a topological space $C_W^r(M,N)$. A neighborhood of $f$ is thus any set containing the intersection of a finite number of sets of this type.

I was comparing this definition with the one I'm more used to from functional analysis (see Rudin's Functional analysis Chapter 3, section 3.8

Suppose next that $X$ is a set and $\mathcal{F}$ is a nonempty family of mappings $f : X \to Y_f$, where each $Y_f$ is a topological space. Let $\tau$ be the collection of all unions of finite intersections of sets $f^{-1}(V)$, with $f \in \mathcal{F}$ and $V$ open in $Y_f$. Then $\tau$ is a topology on $X$, and it is in fact the weakest topology on $X$ that makes every $f \in \mathcal{F}$ continuous: if $\tau'$ is another topology with that property, then $\tau \subset \tau'$. This $\tau$ is called the weak topology on $X$ induced by $\mathcal{F}$, or more succintly, the $\mathcal{F}$-topology of $X$.

I might be wrong here but the two definitions look completely different to me, there's no resemblance. However while in fucntional analysis is the weak topology is the one that makes certain family of mappings all continuous I struggle to understand what weak topology means in the context of differential topology. To me the two have nothing in common.
Can you clarify and maybe explain what Hirsch is trying to capture with his definition?
Answer: First of all, charts are there because calculus on manifolds is (typically) done by way of focusing on patches small enough that coordinates are well-defined. So let's focus on the flat case.
Let $U\subseteq \mathbb{R}^n$ and $V\subseteq\mathbb{R}^m$ be open subsets, fix $r,s\in \mathbb{Z}_{\geq0}$ with $r\geq s$ and consider the set $C^r(U,V)$ of all $r$-times continuously differentiable functions from $U$ to $V$. We would like to endow $C^r(U,V)$ with a $C^s$-topology of sorts, which should incorporate the first $s$ derivatives when it comes to proximity, the zeroth derivative of a function being the function itself. In other words for two functions $f,g\in C^r(U,V)$, we want
$$f\approx_{C^s} g \iff f \approx g, f' \approx g', f'' \approx g'', ... , f^{(s)}\approx g^{(s)},$$
where $\approx$ means "approximately", and derivatives of functions are certain multilinear functions (e.g. as in Lang's Fundamentals of  Differential Geometry).
We could consider the product topology, which would give the topology of pointwise convergence of each derivative. Or we may use the supremum (i.e. $C^0$-) norm for each one of the derivatives, which would give the topology of uniform convergence. In fact since all the functions on the RHS are continuous if we restrict our attention to compact subsets $K\in\mathcal{K}(U)$ of $U$ the supremum (semi-)norm becomes nicer to deal with, and we get a topology more rigid (= stronger = finer = larger = more expensive = higher resolution = harder convergence) than the product topology and more flexible (= weaker = coarser = smaller = cheaper = lower resolution = easier convergence) than the uniform topology. See the discussion here for further details on this comparison.
To that end define a one parameter family $\mathfrak{g}_\bullet^s$ of seminorms on $C^r(U,V)$ by
$$\mathfrak{g}_\bullet^s:\mathcal{K}(U)\to F(C^r(U,V), \mathbb{R}_{\geq0}),\quad
K\mapsto \left[f\mapsto \max_{k\in\{0,1,...,s\}}\max_{x\in K}\left|f^{(k)}(x)\right|\right].$$
(Here the target is the set of all functions from $C^r(U,V)$ to $\mathbb{R}_{\geq0}$.)
Using this family of seminorms parametrized by compact subsets instead of just one norm (e.g. the supremum norm on the whole open set $U$) gives uniform convergence on compacta (or compact convergence), and the topology $\mathcal{N}^s$ generates is precisely the topology of uniform convergence of the first $s$ derivatives on compacta.
Observe that this is not the unique family of seminorms that does the job that we set forth above (though taking the maximum over the order of derivatives has the benefit of playing nicely with intersection). Then the weak subbasic $C^s$-neighborhoods $\mathcal{N}^s$ of Hirsch would precisely be
$$\mathcal{N}^s: C^r(U,V)\times \mathcal{K}(U)\times ]0,\infty]\to \mathcal{P}(C^r(U,V)), \quad (f,K,\varepsilon)\mapsto \{g\in C^r(U,V)\mid \mathfrak{g}_K^s(f-g)<\varepsilon\}.$$
(Here the target is the set of all subsets of $C^r(U,V)$.)
To generalize this to the manifold case we need to replace $C^r(U,V)$ by $C^r(M,N)$ for $M,N$ two manifolds. But the condition for a function to be in $C^r(M,N)$ is it being in $C^r(U,V)$ where $U\in\operatorname{Chart}(M)$ and $V\in\operatorname{Chart}(N)$, which is why the neighborhood-valued map $\mathcal{N}^s$ now gets two additional parameters $\operatorname{Chart}(M)$ and $\operatorname{Chart}(N)$.

Now let's focus on Rudin's definition of weak topology. Let me rephrase it in a more categorical way (seeing spaces parametrized by functions bothers me; the targets and functions come at the same time, the way I see it).
Consider the forgetful functor $\operatorname{Forget}: \operatorname{Top}\to \operatorname{Set} , (S,\mathcal{T}(S))\mapsto S$, let $X\in \operatorname{Set}$ and consider the comma category $(X\searrow \operatorname{Forget})$. An object in $(X\searrow \operatorname{Forget})$ is a pair $(f,Y)$ where $Y$ is a topological space and $f:X\to\operatorname{Forget}(Y)$ is a function.
For any $(f,Y)\in(X\searrow \operatorname{Forget})$, we could pull back the topology of $Y$ via $f$ (i.e. we could look at preimages; which are denoted by $^\ast$ throughout) and we would get a subset $f^\ast(\mathcal{T}(Y))$ of $\mathcal{P}(X)$. Likewise for any collection $\mathfrak{F}\subseteq(X\searrow \operatorname{Forget})$ we can put all the pullbacks together and consider
$$\bigcup_{(f,Y)\in\mathfrak{F}}f^\ast(\mathcal{T}(Y))\subseteq \mathcal{P}(X).$$
Let us denote by $\mathcal{T}(X,\mathfrak{F})$ the smallest topology of $X$ that contains $\bigcup_{(f,Y)\in\mathfrak{F}}f^\ast(\mathcal{T}(Y))$, i.e.
$$\mathcal{T}(X,\mathfrak{F})=\bigcap\left\{\mathcal{T}\subseteq\mathcal{P}(X)\left\vert \mathcal{T}\supseteq \bigcup_{(f,Y)\in\mathfrak{F}}f^\ast(\mathcal{T}(Y))\mbox{ and }\mathcal{T}\mbox{ is a topology}\right\}\right..$$
There are certain universal properties associated to $\mathcal{T}(X,\mathfrak{F})$ as expected. In particular $\mathcal{T}(X,\mathfrak{F})$ is the smallest topology that makes all maps $f:(X,\mathcal{T}(X,\mathfrak{F}))\to (Y, \mathcal{T}(Y))$, $(f,Y)\in\mathfrak{F}$, continuous. See wikipedia for further categorical musings. Also see the discussion here.

Finally let's put these two things together. We are trying to topologize $C^r(U,V)$, so set $X:=C^r(U,V)$. Here are some families in $(C^r(U,V)\searrow \operatorname{Forget})$ that are worthy of mention in our discussion:

$\mathfrak{F}_1^s:=\{(\mathfrak{g}_{\{x\}}^s,\mathbb{R}_{\geq0})\mid x\in U\}$ (singletons are compact subsets)
$\mathfrak{F}_2^s:=\{(\mathfrak{g}_K^s,\mathbb{R}_{\geq0})\mid K\in\mathcal{K}(U)\}$ (seminorms we defined above)
$\mathfrak{F}_3^s:=\{(\mathfrak{h}_{f,K}^s:=\mathfrak{g}_K^s(\bullet-f),\mathbb{R}_{\geq0})\mid K\in\mathcal{K}(U), f\in C^r(U,V)\}$ (translates of the seminorms in $\mathfrak{F}_2^s$)
$\mathfrak{F}_4^s:=\left\{\left(g\mapsto \max_{k\in\{0,1,...,s\}}\sup_{x\in U}\left|g^{(k)}(x)-f^{(k)}(x)\right|, \mathbb{R}_{\geq0}\right)\mid f\in C^r(U,V)\right\}$
$\mathfrak{F}_5^s:=\left\{\left(D^k,C^0\left(U,\operatorname{Lin}\left({(\mathbb{R}^n)}^{\otimes k}, \mathbb{R}^m\right)\right)\right)\mid k\in \{0,1,...,s\}\right\}$ ($D^k: f\mapsto f^{(k)}$ is the $k$th derivative operator)

In the first four options the targets are topologized in the expected manner. They are somewhat more general in that their analogs apply to more general situations. The final option is making use of differentiation specifically. Here the set $\operatorname{Lin}\left({(\mathbb{R}^n)}^{\otimes k}, \mathbb{R}^m\right)$ of $k$-linear functions from $\mathbb{R}^n$ to $\mathbb{R}^m$ are topologized by the operator norm (say), and the target set is endowed with the compact-open topology (= $\mathcal{N}^0$ topology = topology of uniform convergence on compacta). I have suppressed some topolinear isomorphisms and embeddings here because I think I'm already pushing your patience.
It is straightforward that $\mathcal{T}(C^r(U,V),\mathfrak{F}_1^s)$ is the topology of pointwise convergence of the first $s$ derivatives and that $\mathcal{T}(C^r(U,V),\mathfrak{F}_4^s)$ is the topology of uniform convergence of the first $s$ derivatives.
Here are some observations to compare the remainder (I'll suppress the quantifiers for the sake of sanity):
Observation 1: $\mathcal{N}^s(f,K,\varepsilon) = (\mathfrak{h}_{f,K}^s)^\ast([0,\varepsilon[).$
Observation 2: $|\mathfrak{h}_{f,K}^s(g)-\mathfrak{h}_{f,K}^s(h)|\leq \mathfrak{g}_K^s(g-h).$
Observation 3: $|\mathfrak{g}_K^s(f)-\mathfrak{g}_K^s(g)|\leq \mathfrak{g}_K^s(f-g).$
Observation 4: $\mathfrak{h}_{0,K}^s=\mathfrak{g}_K^s$, provided that $0\in V$.
Observation 5: $\mathcal{N}^s(f,K,\varepsilon)=\bigcap_{k\in\{0,1,...,s\}}(D^k)^\ast(\mathcal{N}^0(f^{(k)},K,\varepsilon))$.
All these observations are straightforward to verify.
Observation 1 shows that the $\mathcal{N}^s$-topology is contained in any topology w/r/t which the $\mathfrak{h}_{\bullet,\bullet}^s$ are continuous, hence
$$\mathcal{N}^s\mbox{-topology } \subseteq \mathcal{T}(C^r(U,V),\mathfrak{F}_3^s).$$
Observation 2 shows that the $\mathfrak{h}_{\bullet,\bullet}^s$ are ($1$-Lipschitz) continuous when the domain is endowed with the $\mathcal{N}^s$-topology, so
$$\mathcal{N}^s\mbox{-topology } \supseteq \mathcal{T}(C^r(U,V),\mathfrak{F}_3^s).$$
Likewise, by Observation 3 the $\mathfrak{g}_\bullet^s$ are ($1$-Lipschitz) continuous when the domain is endowed with the $\mathcal{N}^s$-topology, so
$$\mathcal{N}^s\mbox{-topology } \supseteq \mathcal{T}(C^r(U,V),\mathfrak{F}_2^s).$$
By Observation 4, if $0\in V$, so that the function that is constantly $0$ is in $C^r(U,V)$, then
$$\mathcal{T}(C^r(U,V),\mathfrak{F}_2^s)\subseteq \mathcal{T}(C^r(U,V),\mathfrak{F}_3^s).$$
I believe the assumption that $V$ contains the origin is mild. Indeed, a general $V$ need not contain $0$, but since $V$ is supposed to be a chart of a manifold we could arrange it to contain $0$.
This final inclusion could be strict, provided that $V$ contains a nonzero $y$ and its negative $-y$. The point is that antipodes are not distinguishable by open sets coming from $\mathfrak{g}_\bullet^s$; see the discussion here.
Finally by Observation 5 we have that
$$\mathcal{N}^s\mbox{-topology }= \mathcal{T}(C^r(U,V),\mathfrak{F}_5^s),$$
which I think is the most interesting claim. In words, it says that the $\mathcal{N}^s$-topology on $C^r(U,V)$ is the smallest topology that makes the first $s$ derivatives continuous operators. An alternative reformulation by way of multiindex formalism is in Kelley & Namioka's Linear Topological Spaces, p. 82:

Putting all the inclusions and equalities together we have:
\begin{align*}
\mathcal{T}(C^r(U,V),\mathfrak{F}_1^s)
&\subseteq \mathcal{T}(C^r(U,V),\mathfrak{F}_2^s)\\
&\subseteq \mathcal{N}^s\mbox{-topology }
= \mathcal{T}(C^r(U,V),\mathfrak{F}_3^s)
= \mathcal{T}(C^r(U,V),\mathfrak{F}_5^s) \\
&\subseteq \mathcal{T}(C^r(U,V),\mathfrak{F}_4^s).
\end{align*}
(Of course on top of this we also have a grading w/r/t the order $s$ of derivatives; the higher the order of derivatives the smaller the open sets become. This would give refinements.)
Answer: The two definitions are extremely similar under the right point of view. With the caveat that one doesn't usually use Rudin's definition as stated, since most of the time $Y_f=\mathbb C$. In that case, a basis of the weak topology is given by
$$
\mathcal N(x; f_1,\ldots,f_r; \varepsilon)=\{y:\ |f_j(x)-f_j(y)|<\varepsilon\}.
$$
Comment: Can you elaborate why you say they're similar?
Comment: "Evaluate and make the distance less than $\varepsilon$. Compare the $\mathca N$ I wrote with the one you wrote.
Comment: I think I need to think more about it give your insight. As I still struggle.


Drupal 7 Single Sign On possibilities with the Domain Access Module

Question: The background:
We (currently) have 2000 domain names pointed at a single IP. Drupal inherently has the ability
to use multisite, but for our particular Drupal 7 install we use a module named Domain Access to
delegate sites. The gist is though that Domain Access will not allow cross site logins, but yeah,
we would like our editors to log in once, and have access to all sites.
The question:
Has anyone made any headway with coming up with a single sign on solution with Domain access to date
for Drupal 7? I've been looking closely at two old modules, one no longer maintained (SSO for D6) and
one still maintained (CAS). I'm worried about using CAS I am not sure if it will work the way I intend
it since Domain Access seems to change quite a bit of Drupal(ly) stuff.
We could potentially use facebook, openid, twitter option, but i thing not having able to offer visitors
or customers a unique id across a network of sites is too me a big loss of identity and privacy.
Are there any solutions that are known to date, or information on what to start looking into? Has anyone in
the Drupal community managed to make a solution that I have not been able to find? The only possiblitiy that
I've found was this thread on Domain Access SSO but am uncertain to what version it pertains to (Drupal.
DA, SSO or otherwise). I tried contacting the author multiple times but never received a response. It looks
like the "Solution" was to create a master table set with users and permissions, then share those across the
domains. Unfortunetly (again) SSO on Drupal 7 is not an option.
Any opinions out there on the who what or why would be greatly appreciated, I honestly just need a start point
to get the ball rolling. Thanks everyone
Comment: Just to confirm, by SSO you mean that if a user logs into domain1.com, they would already be logged into domain2.com when Domain Access is in play?  SSO can mean different things to different people, and this is a good question.  Making sure we are all on the same page is necessary for good answers here.
Comment: Yes once they log into domain1 they would essentially be logged in to all our TDLs (Top Level Domains) like domain2.com domain3.com etcetra. My use of SSO is I believe the correct use. Where user authorization data is passed from the primary login point to all other TDLs in our control. Please correct me if I am smudging the term though.
Comment: Yeah, that is the correct term.  I have heard the term used more loosely to refer to multiple systems using centralized credentials (eg, OpenID, AD, LDAP) but requiring users to log into each.
Comment: I know that authentication is strongly used in the inc/session.inc file. This is also where sso works on. Now SSO is not the right approach for domain acces in my eyes, because you are working on a single database. I am also looking for a solution to this.
Answer: See: Comparison of Single Sign On (SSO) Modules
Bakery supports SSO for sites with the same domain (site1.example.com, site2.example.com). Have not tried CAS as you noted above it is an option. You could also use an oauth server to authenticate across domains.


Finding out co-linear points

Question:
How many triangles with positive area can be drawn on the coordinate
  plane such that the vertices have integer coordinates $(x,y)$ satisfying
  $1≤x≤3$ and $1≤y≤3$?

It is easy that we have  nine possible ways to connect the coordinated to make  triangles. But  is there any easy way to get the number of co-nonlinear points?
If you draw for me, it be be really a big help
Answer: Well, there are 9 possible points. So you have ${9\choose 3} = 84$ ways yo choose 3 distinct vertexes. Out of those, $8$ of them would require to select three vertexes aligned (three horizontal lines, three vertical ones and the two main diagonals).
So you have $84 - 8 = 76$ possible triangles.
Comment: "three horizontal lines, three vertical ones and the two main diagonals" how?
Comment: Like this: http://gyazo.com/ab88e53f05cbc7f57ed50428fa8ad059

If all the tree vertexes are on any of this lines, you don't have a triangle.

Finding out co-linear points


Where to place drush in MAMP

Question: I placed drush in MAMP folder outside of htdocs folder and downloaded drupal successfully but obviously to wrong folder. Where should drush be placed to have it work with drupal folder in htdocs folder?
Comment: It may not be obvious for someone unfamiliar with the command line, but this is an osx question. Drush doesn't care where it's installed.
Comment: Well, I feel it is more of a MAMP question because they package the free vs with pro it is hard to tell which version of php to point the alias to and there are currently three in php folder.
Comment: Potentially it is a MAMP question, but that still leaves it off-topic for the site. :)
Answer: I use the drush qd command and add the --root parameter. You can use it to download the Drupal installation into /Applications/MAMP/htdocs
Comment: Actually, I ended up going for mysql instead of lite option in above answer- so placed drush in mamp folder but it is giving me an error and this link http://drupal.org/node/1428638 when I tried the following code from that link it didn't work so still trying to break fee of jail shell.
Comment: What errors are you seeing?
Comment: The drush command 'up' could not be executed.                        [error]
Drush was not able to start (bootstrap) the Drupal database.         [error]
Hint: This may occur when Drush is trying to:
 * bootstrap a site that has not been installed or does not have a
configured database. In this case you can select another site with a
working database setup by specifying the URI to use with the --uri
parameter on the command line. See `drush topic docs-aliases` for
details.
 *  The socket file may be
wrong or the php-cli may have no access to it in a jailed shell.
Comment: It sounds like you are running drush on a folder that has no Drupal installation (Note that I'm saying installation that goes through the actual install process, not just putting the Drupal files there). Use the 'qd' command to install.
Comment: Thanks , radj will do if can't figure this out but in meantime I will persist. I have three versions of php and I need to set path correctly but not sure which one pertains to the free copy of MAMP.
Comment: Sounds complicated. Good luck! :)

Where to place drush in MAMP


Block chord style and appoggiaturas

Question: I'm practicing block chord style using drop 2 voicing. I'm following the scale patterns in Mark Levine Jazz Piano Book, figure 19-8.
I'm using the tune All of Me for practical application.
In a passage like below where the non-chord tones are all un-accented passing tones it seems clear how to use block chords and use a diminished seventh chord on each non-chord tone...

...this is what I'm trying for block chord harmony.

But when the passage has accented appoggiaturas - especially on the first beat of the bar - I'm not sure if I should harmonize that with a diminished seventh chord...

...the basic description of block chord harmonization says use a diminished seventh on melodic non-chord tones, so I'm trying this...

It sounds OK to me. My only gripe is the part where major F goes to minor Fm. When you take the diminished seventh on non-chord tones literally there is no modal change on the harmony between the two chords. There is no change at all, the chords are the same. I suppose this is a judgement call where I can just say the first chord is F6 and treat the melodic D as a chord tone...

Is this how block chord harmony is supposed to work?
Would this be a good treatment of All of Me?
Comment: I tend to agree with you it doesn't work over the F - Fm part. Does Levine require that it be a true dim chord that includes the non-chord tone? For example, could you accompany the initial D with an F#dim (so, really D7)?
Comment: That F (maj or 6) can't be diminished - it stops being major, and sounds like minor, with the b3. Sometimes, a chord need to be left as is. I tend to play it as F6, then Fm6 or Fo in the following bar. Having been very disappointed with Levine's Jazz Theory - so many contradictions - his Piano book lies unopened 5 yrs on, so I'm not about to check what he's doing! Good luck with it !
Comment: @Tim I too don't like Levine's book that much, his enharmonic spellings bother me.  I prefer Jerry Coker's _Jazz Keyboard_.
Comment: @Aaron, after re-reading Levine, he only writes "to use this technique when voicing tunes, look for melodies that move stepwise." His examples from actual jazz performances are on passing and changing tones. I was misunderstanding where to use these dim7 chords.
Answer: I agree with @Max that both these D's should be treated as chord tones over F6 and Fm6 and not appoggiaturas. The durations of these notes are too long to be appoggiaturas in my book. I also think the B over the A7 in your 3rd example should be treated as an A9 with the 9th in the melody for that matter. The Real Book could have been a little more detailed in their chord selection on this tune.
The first two chords in your fifth example work well. The Fo7 chord on beat 4 doesn't work going to the next downbeat because they're both Fo7, you have the same chord where there should be a harmonic change. It also won't work going to an Fm6 because of the A-Ab major to minor changing prematurely on beat 4. Also, because this note is a quarter duration and is followed by both a leap and a harmonic change it is better to harmonize it as some type of F major chord. Here is an idea I think works nicely:

The only difference on beat 4 is staying on the A natural instead of going to an Ab. Hope this is to your liking.
Comment: @MichaelCurtis So you're one of those ambidextrous jazz piano players? Good for you, all great stuff to work on. On a related note to your question, look around online for Barry Harris 6th diminished scale if you haven't seen it before or check this out, you'll really like it: https://cochranemusic.com/barry-harris-6th-dim-scale-diminished
Comment: The whole bar on Fmaj, is the only way with this song. Any hint of an Ab just won't work. +1. And I always play the A chord as A9, 'cos effectively, that's what it is!
Comment: Your point about beat 4 and the change over the bar makes complete sense.
Comment: After re-reading Levine I see he didn't say much about when to use a dim7. From his examples it's only on passing and changing tones. I made the mistake of extending that to _any nct_. "...too long to be appoggiaturas..." I don't think it's duration. With 7th, 9th, and 6/13th all being considered chord tones almost nothing distinguishes an appoggiatura. I guess that term just doesn't make much sense in jazz.
Comment: @MichaelCurtis There are other ways to harmonize non-chord or passing tones. You can use neighboring diatonic, dominant or chromatic chords too. They all have their flavor and work well. Regarding the appoggiaturas, you're right about length, I guess they just didn't seem like that to me. Since jazz uses such extended chords any note longer than a quarter is more often than not harmonized as a chord tone.
Comment: Right, this isn't the only way. I'm also practicing "side stepping" - chromatic neighbor chords - but haven't tried applying it in a tune yet. I'm just getting started. I also try playing tunes with a stride style LH, eventually I want to play a walking bass LH while playing a tune in RH.
Comment: well... aspiring to be that kind of player! I have a long way to go.
Comment: watching the students in the Harris video makes me feel a whole lot better :-)
Comment: @Especially me not being a pianist it is very tough going at first but eventually you get the logic and develop a flow for it. It's a great sound.
Answer: With such a prominent D in the melody, I would consider the "real" chords to be F6 and Fm6, in which case D is not an appoggiatura but a chord tone. Then applying the principles of block voicings yields something like your last example:

Having said that, those diminished chords on the downbeat sound intense in a way that may be desirable in the context of a larger interpretation. However, if I were going to choose the diminished voicings, then I would also write diminished chords in the rhythm section parts to match. In other words, I would consider this a slight reharm.
Having said that, the faster you go, the more the harmonic rhythm tends to flatten out. If your arrangement is up tempo (say, faster than about 190 bpm), then you might treat the D as an appoggiatura after all. As with so much in music, the optimal chord voicings will depend on the context.
Comment: I agree Max, 6th chords, not appogiaturas. I would even take it a step further and consider the A7 in the 4th bar as an A9 with the 9th in the Melody.
Comment: @JohnBelzaguy - yes, I was scratching to find an appoggiatura.

Block chord style and appoggiaturas


Property or method X is not defined on the instance but referenced during render

Question: In console I see following messages:
Property or method Id is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property
How to get rid of it?
<template>
  <v-content>
    <v-container grid-list-md text-xs-center>
      <v-layout v-for="person in people" :key="person.Id" row wrap>
        <v-flex :key="Id" sm1 hidden-xs-only>
          <v-card-text class="px-0">{{ person.Id }}</v-card-text>
        </v-flex>
      </v-layout>
    </v-container>
  </v-content>
<template>

Comment: `:key="Id"` is the culprit. You haven't defined an `Id` in your Vue instance.
Answer: <v-flex :key="Id" sm1 hidden-xs-only>

:key is another syntax for v-bind:key, which is supposed to contain javascript code. In your case, Id is not defined. You probably wanted to use 'Id' string literal.
Use either
<v-flex :key="'Id'" sm1 hidden-xs-only>

or
<v-flex key="Id" sm1 hidden-xs-only>

or define an Id data in your vue instance.


Baby Taylor BT1e didn't make sound at venue. The next day, it was fine

Question: I have asked a few resources and I can't get a good answer.
I was simply doing an open mic at a venue and when I plugged my guitar into their system, no noise came out. The performer just before me plugged in his acoustic-electric and did his gig. When I was up, all I did was transfer the 1/4 cable from his guitar to my guitar. The sound engineer at the venue tried to figure it out but he couldn't, so I eventually borrowed someone else's guitar. My guitar's pre-amp batteries were not dead and I made sure they were fresh. The day after the show, I plugged the guitar into a different PA system and it worked fine. At the venue, the guitar was plugged into their DI box, and then their mixer. This is the pick-up my guitar uses https://www.taylorguitars.com/guitars/acoustic/features/electronics/es-b
My Thoughts Are:

My batteries were good enough to turn on the tuner, but were dying
The fact that my guitar has a pre-amp messed something up. I don't think the previous performer had one.
The settings on the DI box were wrong for my guitar

Do any of you have any idea what happened, and how I can prevent this in the future? Thanks
Comment: We don't know your guitar. We don't know the guitar that worked. We don't know either PA systems, nor the DI box. In my experience, DIs are plug-and-play without many settings. The closest thing I would think of is that the cable wasn't sitting solidly in the jack. It's a big problem with right-angle jacks is that they don't fit in Tele jack cups, but for acoustics shouldn't have that problem.
Answer: In my experience whenever a situation like you describe happens it's always a simple operator error such as the battery was dead or your volume knob was not turned up. I would say that it was the volume knob on your guitar which was turned up by you the next day if you didn't change batteries.
However, since we don't know anything about the equipment or the competence of the people involved, there's no way to know.


Relacionar mais de um valor da mesma linha com outra tabela (Laravel)

Question: sou novo no Laravel e queria saber se tem como resolver meu problema sem ser no PHP puro, ou seja, usando os recursos próprio Laravel. Segue a situação atual e o que desejo fazer:
Tenho uma tabela chamada Departamentos, onde eu incluo o nome do departamento (coluna nome) e 1 ponto focal (coluna pontofocal_id), 1 gestor (coluna gestor_id) e 1 ou mais backups (coluna backup). Ao salvar o registro eu salvo os IDs dos pontofocal, backups e gestores que eu pego da Tabela usuários. Até ai normal, eu uso no meu arquivo App/Departamento o hasOne para a tabela usuários e consigo puxar o nome do usuário pelo ID inserido na tabela Departamentos.
public function pontofocal(){
    return $this->hasOne(Usuario::Class, 'id', 'pontofocal_id');
}

public function gestor(){
    return $this->hasOne(Usuario::Class, 'id', 'gestor_id');
}

public function backups(){
    return $this->hasOne(Usuario::Class, 'id', 'backup');
}

Porém a coluna Backup eu posso salvar mais de um ID no mesmo registro. Separo eles por vírgula.
No meu lista.blade.php eu usei um foreach dentro do outro foreach para pegar o valor do campo backup (exemplo: 1,4,5) para transformar num array contendo os IDS 1, 4 e 5, usando um explode e devolve esta informação para a variável $departameno->backup, para poder usar o relacionamento e pegar o campo name da tabela usuários conforme códio abaixo:
@foreach($departamentos as $departamento)

                        {{ $departamento->nome }}
                        {{ $departamento->gestor->name }}
                        {{ $departamento->pontofocal->name }}
                        @php
                            $arraybackups = explode(",",$departamento->backup);
                        @endphp

                            @foreach($arraybackups as $arraybackup)
                        @php
                            $departamento->backup = $arraybackup;
                        @endphp
                            {{ $departamento->backups->name }}
                            @endforeach

A princípio ele funciona mas parece que ele pega o valor do campo name apenas do primeiro ID e repete para os demais mesmo sendo IDs diferentes. Conforme abaixo:

Ao dar um echo para ver se estou gravando os IDs corretos extraídos do array, eu vejo que sim, estão corretos conforme abaixo. vejam q são IDs diferentes, mas ele me traz sempre o mesmo nome do primeiro ID da linha:

Existe alguma forma para fazer isso que eu quero?
Obrigado!
Comment: Você precisa fazer um junção dessas tabelas... mas, pelo visto como a coluna grava todos os Ids isso não é possivel ... repense as tabelas e guarde a informação de cada id em sua própria linha ... ou seja, guarda tudo no mesmo campo é um grande erro !!!
Comment: Olá Virgilio, obrigado por responder mas você está errado. Em alguns casos esta é a melhor maneira para agilizar o processo e diminuir o tamanho das tabelas. Eu já descobri como fazer o que preciso. Para isso eu usei um inner join das tabelas e no campo que eu preciso buscar os iDs usei o FIND_IN_SET() do MYSQL. Eles faz exatamente o que eu precisava. Ai depois Agrupei os resultados e usei o GROUP_CONCAT no campo que precisava. Tudo resolvido sem necessidade de criar outras tabelas. Abs
Comment: você resolveu o seu problema com duas funções, aí eu pergunto qual foi o custo!? Mas tudo bem em achar uma solução que hoje pode te ajudar e com alguma mudança pode ser prejudicial prefiro ainda utilizar um repositório bem organizado ...
Answer: consegui resolver o meu problema e estou postando aqui como resolvi.
Resolvi usando o FIND_IN_SET() função nativa do MYSQL. Ele busca os valores do campo e cruza com os da outra tabela e retorna tudo em uma linha separada. Ou seja, ele me retorna:
Financeiro   Back Up 01
Financeiro   Back Up 02
E assim por diante. Então depois eu fiz um GROUP BY para agrupar pelo nome do departamento e no campo NAME que traz os nomes do backup eu usei a função GROUP_CONCAT() função do próprio mysql tb.
Espero ter ajudado!
Abs


Obter id ImageView numa GridView

Question: Imagens que quero por na GridView
        private Integer[] imagens= { R.drawable.um, R.drawable.dois, R.drawable.tres, R.drawable.quatro, R.drawable.cinco, R.drawable.seis,
        R.drawable.sete, R.drawable.oito, R.drawable.nove, R.drawable.dez, R.drawable.onze, R.drawable.doze, R.drawable.treze, R.drawable.catorze, R.drawable.quinze};

Aqui é onde coloco as imagens na GridView
public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(250, 250));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(8, 8, 8, 8);
        } else {
            imageView = (ImageView) convertView;
        }

        imageView.setImageResource(imagens[position]);
        return imageView;
    }

Tenho este metodo para sempre que clico num item da GridView ele é suposto criar um Alertdialogo com o id do item que foi clicado
gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View v, int position, long arg3) {
            IdAsString = arg0.getItemAtPosition(position).toString();;
            IdAsString += "_original";

            //Toast.makeText(getApplicationContext(), "Your text", Toast.LENGTH_LONG).show();
            AlertDialog.Builder alert = new AlertDialog.Builder(fotos.this, android.R.style.Theme_Holo_Dialog);
            LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
            vista= inflater.inflate(R.layout.full_image, null);
            alert.setTitle(IdAsString);
            alert.setView(vista);
            alert.show();
        }
    });

O que eu quero é que me sempre que clico numa imagem me de o id dessa imagem. Ex:"um","dois", so quero que me de o id numa string mas este metodo
            IdAsString = arg0.getItemAtPosition(position).toString();

esta a dar este erro
Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference

Answer: No lugar de
IdAsString = arg0.getItemAtPosition(position).toString();;

use:
IdAsString = "" + imagens[position];

Obter id ImageView numa GridView


Single-cell RNA-seq: deep & few or shallow & many?

Question: My lab does a lot of single-cell RNA-seq. Our goals are to find out what cell types are present, characterize their gene activity, and (if possible) understand how the different subpopulations are related to each other (for example through pseudotemporal analysis).
We often wonder which is better: should we sequence many cells at a shallow level, or few cells deeply? There's a paper on this here, but it is completely empirical. I am posting this question because I want to develop intuition via statistical analysis: given a reasonable stochastic model, what would we expect from shallow versus deep sequencing?
To help formulate a stochastic model, suppose a typical mammalian cell has 200,000 RNA molecules, and we detect each molecule with probability 1% (for low coverage) or 2.5% (for medium coverage).
I posted an answer below. I would be interested in answers that improve on mine in the following ways.

Account for correlations between difference genes, or generally follow up on EdM's suggestion to account for natural variability in mRNA levels.
Correct my math, especially the downright incorrect assumption that $\sum_jz_{ij}$ is constant.
Quantify tradeoffs for more interesting target parameters. For instance, if you want to know whether a given cell state transition is continuous or discrete, you might want to test the adequacy of a two-cluster model (say, with K-means) versus a continuous model (say, 1-dimensional PCA). This ought to make the shallow sequencing worse, because higher technical noise will blur the clusters together, even though their centers will still be accurately estimated.

I am not so interested in incorporating domain knowledge about single cell sequencing. For instance, I am aware that deeper sequencing leads to redundancy as the same barcode is detected twice, but that is beyond the scope of my question and it belongs in another discussion.
Comment: Another set of considerations you should add to your question, to get a more useful answer: what is the distribution of expression among different RNA species, and how much do you care about detecting RNA species with low levels of expression?
Comment: The title should probably read "deep & few or shallow & many"?
Comment: @amoeba: indeed. Fixed.
Comment: @EdM: unfortunately, I don't know much about the distribution of mRNA counts, though I'd like to learn more. I care about low-expressed genes, such as transcription factors, enough to want decent cluster-level averages for them.
Comment: Not worth a full answer, but Gaussian mixture models (GMM's) have sample complexities that depend inversely on some power of the total-variation distance between the distributions. This total variation distance decreases with shallow sequencing, because it depends a lot on the variance of a single cell. For GMM's, the sample complexity should go up with shallower sequencing. See this: http://people.csail.mit.edu/moitra/docs/disentangling.pdf
Comment: This paper (Zhang et al "One read per cell per gene is optimal for single-cell RNA-Seq") is worth reading. I plan to integrate it into my answer once I understand it.

https://www.biorxiv.org/content/biorxiv/early/2018/08/28/389296.full.pdf
Answer: Here's an answer, but it makes naive assumptions about the data generating process, it is mathematically incorrect, and it only works with a very simple estimand (group average expression). Throughout this answer, $i$ indexes a cell and $j$ a gene.
Model
Suppose the cells come from a homogeneous population, with mRNA counts varying due to natural stochasticity. (Link is to a tutorial that derives a stochastic model for gene expression from first principles). Suppose the molecule counts for cell $i$, call them $x_i$, have approximately mean $\vec\mu$, variance $\delta \vec\mu$, and zero covariance (each like an overdispersed Poisson). We can sample $y_{ij} \approx Poisson(0.01*x_{ij})$ for $i \in 1 ... 10k$ via shallow sequencing or $z_{ij} \approx Poisson(0.025*x_{ij})$ for $i \in 1 ... 4k$.
Variance decomposition
We know that, for the measurement of mRNA species $j$,
$$\begin{align}Var(y_{ij})
=& Var[E[y_{ij}|x_{ij}]] + E[Var[y_{ij}|x_{ij}]] \\
=& Var[0.01x_{ij}] + E[0.01 x_{ij}] \\
=& 0.01^2\delta\mu_{j} + 0.01\mu_j\\
\end{align}$$.
For $z$, the analogous result is $0.025^2\delta\mu_{j} + 0.025\mu_j$. The first summand can be regarded as biological variance and the second as technical.
Estimation
When we go to estimate $\mu$, it's typically done using "normalized" data: we do the bulk of the exploratory analysis on $\tilde{z_j} = 10,000*z_{i}/\sum_jz_{ij}$ or $\tilde{y_i} = 10,000*y_{i}/\sum_jy_{ij}$. This is not optimal, because deeper-sequenced cells should be given more weight, but I am answering within this framework because this is how most people get things done with single cell data.
Derivation of consequences
Suppose we ignore the variability in $\sum_j y_{ij}$ and $\sum_jz_{ij}$. For all $i$, $\sum_jz_{ij} = 5000$ and $\sum_jy_{ij} = 2000$. (If you can do better than this, I'm interested! Please write your comment or answer below.) To simply estimate mean expression, the technical variances will be equal across strategies. If $\bar z\equiv \sum_i\tilde z_i / 4000$ and $\bar y\equiv \sum_i\tilde y_i / 10000$:
Z:

$Var[\bar z_j] = (1/4000)*Var[\tilde z_{ij}]$
$Var[\tilde z_{ij}] = Var[2*z_{ij}] = 4*Var[z_{ij}]$
$Var[z_{ij}] = 0.025\mu_{j}$ (technical component only)
$Var[\bar z_j] = (1/4000)*0.025*4\mu_j = 2.5\times 10^{-5}\mu_j$ (technical component only)

Y:

$Var[\bar y_j] = (1/10000)*Var[\tilde y_{ij}]$
$Var[\tilde y_{ij}] = Var[5*z_{ij}] = 25*Var[y_{ij}]$
$Var[y_{ij}] = 0.01\mu_{j}$ (technical component only)
$Var[\bar y_j] = (1/10000)*0.01*25\mu_j = 2.5\times 10^{-5}\mu_j$ (technical component only)

The biological component of the variability is lower in the shallow sample: the multiplier over the technical variance is $0.01\delta$, rather than $0.025\delta$.
Summary
This answer indicates that technical variation is equal across samples, but the biological component of the variability is lower in the shallow sample.
Comment: Yes, that is what I meant to post. It's very low-level and probably not useful, except that it gives a mechanistic justification for certain stochastic models of biochemical systems.
Comment: Are you sure the link is correct? The text seems to be about "master equation" in chemistry and does not even contain the word "gene".