I have an Issue Building the Filament Repository in Android Studio

Question: Screenshot
 I'm new using Filament. I've been trying to build the repository Google Filament but; it gives me an error every time I try to build it.
These are the errors: CMake Error at /Users/tomas/AndroidStudioProjects/06.Filament/android/gltfio-android/CMakeLists.txt:109 (add_library):
Cannot find source file:
/Users/tomas/AndroidStudioProjects/06.Filament/out/android-release/filament/include/gltfio/materials/uberarchive.h
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
.hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc
Can someone help me to resolve this issues? I can give more information if; it's needed. [ScreenShot][1]

   [![ScreenShot of Android Studio][2]][2]
Comment: Welcome to StackOverflow. [Please don't use screenshots for code/errors](https://meta.stackoverflow.com/q/285551/295004). You should at least mention which [build process](https://github.com/google/filament/blob/main/BUILDING.md) you are following and on what platform (Linux/Windows/Mac).
Answer: If you check the CMakeLists.txt Line 90 you will see that it is referring to ${FILAMENT_DIR}/include/gltfio/materials/uberarchive.h
$FILAMENT_DIR itself is set to `$FILAMENT_DIST_DIR defined at Line-4
The thing is, I've been searching through the releases to find the $GLTFIO_DIR which contains that file to no avail, commenting out the line (the original Line 90) will lead to missing references for the uberarchive functions


How to say that something is a function?

Question: I have the following writing problem: Let's say that $f,g\colon A \rightarrow B$ are given functions and I want to proof that $h = (f,g) \colon A \times A \rightarrow B \times B$ is a function.
Formally, I have to take $(a,b),(a,c)\in h$ and show that $b = c$. But $(a,b) ,(a,c) \in (f,g)$, then what? How can I formally conclude that $h$ is a function? I can't find the argumment. I hope that this is not a silly question.
Thanks in advance.
Answer: Usually, one has to check the good definition of a given function, since $A \times A$ could have diferent representatives for the same element. (For example, if your domain is $\Bbb{Z_4}$, here, $\bar{0}=\bar{4}=\bar{8}$ where the $\textit{bar}$ indicates the class). Now what does good definition of a function mean? Well, that for a given element in your domain, there is a unique element in the image which corresponds to it. Mathematically speaking,
given $f:A \to B$, then $f$ is a well defined function if $a,a' \in A$ such that $a=a'$ then $f(a)=f(a')$.
So how can you check for good definition in this case?
Well you have to get $(a,b),(a',b') \in A \times A$ such that $(a,b)=(a',b')$ and verify that $h((a,b))=h((a',b'))$ which in this case is true, since both $f$ and $g$ are said to be functions.
Comment: I feel like you're muddying the explanation by bringing up equivalence classes.  The original question doesn't refer to them.  Also, I think your version of the definition of function clouds the issue, because it makes proving the original statement seem tautologous.  In fact, you can't write "$f(a)$" until you know $f$ is a function.
Answer: I take it you're using this as your definition of function:

A subset $h \subset X \times Y$ is a function if, whenever $(x,y)$ and $(x,y')$ are in $h$, then $y=y'$.

This problem is complicated by the multiple set products, but if you work through it carefully, it's just a definition chase.  ["Just" is in the eye of the beholder.  With work, this kind of argument becomes routine.] The relation $h$ between $X = A\times A$ and $Y = B\times B$ is defined by
$$
   h = \left\{((a_1,a_2),(b_1,b_2)) \mid (a_1,b_1)\in f,\ (a_2,b_2)\in g\right\}
$$
or, if you want,
$$
   h = \left\{((a_1,a_2),(b_1,b_2)) \mid f(a_1) = b_1,\ g(a_2) = b_2)\right\}
$$
Suppose that $(x,y)$ and $(x,y')$ are in $h$.  Then $x = (a_1,a_2)$, $y=(b_1,b_2)$, and $y' = (b_1',b_2')$ for suitable elements of $A$ and $B$, respectively.  Then
\begin{align*}
    (x,y) \in h &\implies (a_1,b_1) \in f \text{ and } (a_2,b_2) \in g \\
    (x,y') \in h &\implies (a_1,b_1') \in f \text{ and } (a_2,b_2') \in g \\
\end{align*}
Since $f$ is a function, we know $b_1 = b_1'$.  Since $g$ is a function, we know $b_2 = b_2'$.  Therefore $y=y'$.  Thus $h$ also satisfies the definition of function.


ValidationException in Sagemaker pipeline creation

Question: I am new to Sagmaker. I am creating a pipeline in sagemaker where I initialize the number of epochs as a pipeline parameter. But when I upsert, it shows this error.
Check the following code for reference, please.
epoch_count = ParameterInteger(name="EpochCount", default_value=1)
pipeline = Pipeline(
name=f"a_name",
parameters=[
    training_instance_type,
    training_instance_count,
    epoch_count,
    hugging_face_model_name,
    endpoint_instance_type,
    endpoint_instance_type_alternate,
],
steps=[step_train, step_register, step_deploy_lambda],
sagemaker_session=sagemaker_session,

)
Error - ---
---------------------------------------------------------------------------
ClientError                               Traceback (most recent call last)
<ipython-input-54-138a517611f0> in <module>
----> 1 pipeline.upsert(role_arn=role)

/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/pipeline.py in upsert(self, role_arn, description, tags, parallelism_config)
    217         """
    218         try:
--> 219             response = self.create(role_arn, description, tags, parallelism_config)
    220         except ClientError as e:
    221             error = e.response["Error"]

/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/pipeline.py in create(self, role_arn, description, tags, parallelism_config)
    119             Tags=tags,
    120         )
--> 121         return self.sagemaker_session.sagemaker_client.create_pipeline(**kwargs)
    122
    123     def _create_args(

/opt/conda/lib/python3.7/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
    389                     "%s() only accepts keyword arguments." % py_operation_name)
    390             # The "self" in this scope is referring to the BaseClient.
--> 391             return self._make_api_call(operation_name, kwargs)
    392
    393         _api_call.__name__ = str(py_operation_name)

/opt/conda/lib/python3.7/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
    717             error_code = parsed_response.get("Error", {}).get("Code")
    718             error_class = self.exceptions.from_code(error_code)
--> 719             raise error_class(parsed_response, operation_name)
    720         else:
    721             return parsed_response

ClientError: An error occurred (ValidationException) when calling the CreatePipeline operation: Cannot assign property reference [Parameters.EpochCount] to argument of type [String]

Answer: I replace
epoch_count = ParameterInteger(name="EpochCount", default_value=1)

with
epoch_count = ParameterString(name="EpochCount", default_value="1")

And it works. Maybe we can only use an integer in pipeline parameters from the sagemaker notebook. But epoch_count is being used in the docker container, which is not directly something of Sagemaker, and that's my understanding.


computational considerations on the regression problems

Question: I am reading Elements of Statistical Learning and read the following claim from the text (page 93, Chapter 3.7):
Least squares fitting is usually done via the Cholesky decomposition of the matrix $\mathbf{X}^T\mathbf{X}$ or a QR Decomposition of $\mathbf{X}$. With $N$ obserations and $p$ features, the Cholesky decomposition requires $p^3 + Np^2/2$ operations, while the QR decomposition requires $Np^2$ operations.
I understand Cholesky and QR decompositions individually, but I do not understand where this claim came from. Please help.
Comment: The results look very very simply, since they are of polynomial form. But I really am stumped as to where these originate.
Answer: You probably should just trust the book unless you're really interested.
Nevertheless, this, plus plenty more to help you understand numerical considerations for least squares, is covered in G.W. Stewart 'Matrix Algorithms: Volume 1: Basic Decompositions'. Chapters 3 and 4 respectively for Cholesky and QR.  All that you wanted to know, a lot that you didn't even realize you want to know, and some you probably would be just as happy not knowing.


Is it really necessary to learn the Number System in Music?

Question: I've been playing the bass for several years now and want to learn how to play jazz. I started out learning classical music because before the bass, I played the violin, so it just came easier for me. In my quest to learn as much as I can about playing jazz, I've come across sites like this that heavily encourage using a number system for learning music. So they say things like 2, 5, 1.
But, I just don't see the point of labeling sounds with numbers instead of using note letters. If you have relative pitch (which I have) you already know the relationship of the notes that you're hearing. Having to change my entire thought process for labeling just seems unnecessary. Am I missing something?
For anyone in here that plays jazz, do you use a numbering system? And in your honest opinion, do I really need to learn this system?
Comment: I don't get it.  I looked at the site you linked to, but couldn't find an example of the numbering scheme you were talking about.  Are these numbers the same as Roman numerals for chords?  Are they scale degrees?  Or what?
Comment: @aparente001 - scroll down a bit 18" should find that section.
Comment: You clearly are missing some stuff, if your relative pitch, that mean you don't know the absolute note? It mean you can only tell the difference like a chord change which is precisely the thing which is numbered. You know it's a 2-5-1, but you don't know if it C or the absolute notes cause that is absolute pitch
Comment: also a chord progression is more to it. Or even a melody we all recognize melodys like happy birthday that is relative pitch. But a lot would not recognize that if it is precisely in c major or a different key until heard relative
Comment: That what numbers are. It's like saying the name of a song, and we all know the song. It that simple.
Comment: @Tim - Can you be more specific?
Comment: @aparente001 -click on  top left on 1st page, Goes to 'number system'. Admittedly uses RN rather than Arabic numbers, but there's some explanation of chords there. Jazzers will simply use Arabic rather than Roman.
Comment: @tim - I know the Roman numeral system.  Thanks for clarifying.  It makes sense.  When one talks about chords using their numerical function within the tonality (like II-V-I), the Roman and Arabic numbers sound exactly the same!
Comment: You do not need to learn anything, knowledge is a luxury not a necessity.
Answer: As a bassist who has played predominantly jazz for decades I can say understanding and being comfortable with the number system is necessary if you want to progress to be an advanced player. Here are just a few reasons why:

It allows you to associate chord progressions to any key and be able to transpose songs quickly and easily.

It is a standard and accepted method of communication between jazz musicians, i.e.: "Does this blues have a 2-5-1 or a 5-4-1 turnaround?"

It is part of the vocabulary for the understanding of jazz harmony and theory.

If I were to think about it more I'm sure I could come up with a few more reasons.
Now that's not to say that it is all a numbers game. We must still be able to relate to notes and chords on a letter system as well and know our 12 keys and cycle of 5ths intimately. As a jazz musician if I'm playing say "Take the A Train" in C I am thinking of the letter chords:

  C / / / |  / / / / | D7 / / / |   / /  / / |
Dm7 / / / | G7 / / / |  C / / / | Dm7 / G7 / ||

At the same time I am thinking:
I - II7(or V/V) - IIm7 - V7 - I - IIm7 - V7
If I have to play it in Ab it's easy:
Ab-Bb7-Bbm7-Eb7 etc.
EDIT: It has been rightfully pointed out to me by @Lazy that my answer focuses solely on the harmonic aspects of the numerical system. My reason for this is because harmony is so much more often discussed as numbers than melody by jazz musicians. However I do think the numerical system for melody is just as important to learn and understand. There however is a bit of a vagueness to using the numerical system for melody in jazz. The reason I say that is conceptually some musicians may choose to use the numerical system based on the key of the song, i.e. in the key of G, A,B,C is 2,3,4. In the same key over an Am chord some may choose to think of those 3 notes as 1,2,3 of Am. The reason for that is jazz musicians are primarily improvisers. There are many different improvisational concepts but among the most used is to think of notes as the chord and passing tones of the chord being played and not the scale degrees of the key. I am among those who conceptualize melody based on the individual chords. Take "All The Things You Are". It starts on the VIm chord with a 1 in the melody. To me it is a 3 in the melody of the VIm chord. It helps tie in the melody to the improvisation much better to me. That's not to say it's right or better then the other system, just another way of looking at things. This is something to be aware of and keep in mind.
Bottom line, knowing the number system will benefit you for the reasons listed above AND it will make you a better musician in the long run.
Comment: @JazzNeophite My pleasure, good luck on your journey. If you don't think of both then you're limited to playing and understanding things in the key you learn the song in. If the first chord in "All The Things You Are" is just an Fm to you, you will be able to play the song in Ab, maybe even very well but you won't understand the beauty of the harmonic progression it contains, VIm-IIm-V7-Imaj7-IVmaj7 modulation to the M3, etc. This song is hard enough to transpose even when you know it well but knowing the chord relationships in all the keys it works through is a HUGE help.
Comment: Thanks so much John Belzaguy! That makes a lot of sense. This really helped me knowing that jazz musicians think both at the same time!
Comment: Just to clarify: Using numbers for chord analysis is not a Jazz thing, but common practice in music analysis for well over 200 years. What this is talking about is using numbers for actual notes. So in C major the melody `c e f a` would be `1 3 4 6` when harmonically we'd just consider this as `I IV`. So this is in fact some sort of streamlined relative base solfeggio.
Comment: @Lazy Yes of course using numbers for harmony predates and is not exclusive to jazz. However, when jazz players refer to numbers they are talking about harmony, not melody. The OP did mention single notes but his example implies a ii V I progression. When referring to melody it's common to say "5th" instead of "5", i.e. it starts on the 5th and ascends diatonically to the 3rd.
Comment: @JohnBelzaguy Don't worry, When non-jazz players refer to number they usually mean harmony as well. But the page linked by the OP clearly uses the numbers for melody.
Comment: @Lazy He does discuss melody in his numbers article but alsd chords as well with the Roman numeral system:  https://posidovega.com/number-system-in-music The number system is very useful for both melody and harmony in any style but mostly applied to harmony in jazz.
Comment: @JohnBelzaguy Yes. But I'm pointing this out as your answer solely focuses on harmonic analysis, while the question does not. And this is by no means intended as critique, but as a remark.
Comment: @Lazy thank you for you comments. I have elected to edit my answer and include a section on the use of the numeric system applied to melody  as typically used in jazz.
Answer: Necessary, no, but the number system has become the de facto common language for jazz players. It's convenient, because it describes sounds regardless of the key. Naming the chords/notes themselves is comparatively cumbersome. There is only one "ii-V-I", but there are twelve "Dm7-G7-CM7", "Ebm7-Ab7-DbM7", etc.
If I say to another jazz player "go to the VI chord here" or "this is a ii-V", then it doesn't matter what key we're in, or even if we've transposed the piece, that player understands what sound I'm referring to.
Actually, a stronger statement: if you want to play jazz with anyone beyond a beginning experience level, then yes, you need to learn the numerical language.
Comment: Yes, and it is also more immediately informative about the _structural_ function of the harmony, even if there's a small extra step to see what notes to play.
Comment: Thanks Aaron and Paul Garrett! I didn't expect to see such a fast response in here. That makes sense what you all are saying. I just have to put in the work now.
Comment: @Lazy Neither John nor I are writing about harmonic analysis. However, Roman numerals are absolutely standard communication tools in jazz for specifying chord changes. The OP is generally asking about [this article](https://posidovega.com/number-system-in-music), which is about Roman numerals for this purpose.
Comment: @Aaron As I stated in my comment to John: This here is not about roman numeral harmonic analysis (which is by no means a Jazz thing), but about specifying melodies as scale degrees. Of course the rationale stays the same, it makes transposing easier (but at the same time complex music much harder, which is no problem, because it is Jazz and Pop and no sort of complex music).
Answer: From a jazz perspective - although a lot of pop musos benefit from it - it just makes life a lot more simple. You probably are half way there already. Knowing I (1), IV (4) and V (5) of most keys.
Saying to the band 'This has a 1 6 4 5 intro' should mean everyone just jumps straight in, rather than having to say, in key C 'Intro's C Am F G', or key E♭ 'Intro's E♭ Cm A♭ B♭'. It should be almost a given!
Yes, it's pretty well an extension of NNs, which has been around for about 70-odd yrs now, a sort of extension of the RN analysis,but not for analysis purposes, purely for playing. And in jazz, using different keys is commonplace. No need to remind the players that 6 is minor - it's expected, etc.  And simple!
Comment: Would you include a brief explanation of your abbreviations NN and RN?
Comment: @aparente001 - Nashville Number System, and Roman Numeral Analysis.
Answer: It's very useful to know, and if you have good relative pitch, it's a no-brainer - it's just understanding how to verbalize and write down the relationships between pitches that you already understand. It doesn't take much effort.
Answer: I play bass in worship team of our church for several years. I have to say it is necessary.
I was learning modern piano when I was 8, it was a quick lesson that teach you only in number system, no classic piano stuff. Since then, I was trained to read notes by listening to the melody. I can write down the notes, like 1-1-5-5-6-6-5, for do-do-sol-sol-la-la-sol no mater what key it is. This might make me confused when reading notes in absolute pitch, but the relative notes that I memorized in number system make me easy to change key to suit vocal guy's demand.
If you can sing out do-do-sol-sol-la-la-sol when listen to Twinkle, Twinkle Little Star, then the number system is easy to learn for you.
Comment: This seems to imply, that numbers are used instead of note names, whereas the other answers take for granted, that they represent chords. I share the latter assumption but I also admit, that the question should have stated this more clearly.
Comment: I took melody as example, but I also interpret the chord from music as number in my head. I play bass this way, instead of using A G D. Chords in number make the structure of progress clear and easy to change the key. The question did not state that clear, but as a bass player, we know that between the main chords, there is tons of melody to fill in.
Comment: OP's example of 2-5-1 can only be chords - but on bass, you'd root them initially, so same thing. Certainly not melody!
Answer: You use the numbering for two main reasons:

To show the relative relationship of chords, because those relationships function the same regardless of what key you are in. ii V I is basically doing the same thing harmonically whether it's Dm G C or Fm Bb Eb, etc. etc. Numerically we know that progression is roots moving by descending fifths.
The numbers tell us about chords relative to the tonic. If I write a progression C G, it isn't immediately clear what the functions of the chords are. It could be C: I V or G: IV I. Using the numbers clears up that ambiguity. A C chord isn't just a C chord. C: I is a tonic chord while G: IV is a subdominant chord. Within the context of a key a tonic chord and subdominant chord feel and sound totally different!

Jazz and classical musicians use this system.
If you don't want to learn it, you will be missing a major part of a musician's harmonic vocabulary. Conversations about harmony can be really tedious when someone doesn't know the common terms.
Comment: And numbers are shorter words, that roll off the tongue better, than "dominant," "subdominant," etc.
Answer: As @John-Belzaguy noted, the number system is efficient and enables musicians to communicate and change keys quickly.
Another reason to use it: it's commonly encountered in studio work and professional rehearsals, both of which may bypass traditional notation entirely.


DrRacket : How to get the position of a value in a list

Question: I am trying to get a list of positions of a value in a list in Intermediate Student Language.
For instance I wish a list of positions for value "A" in the following list
(list false A false false false false A false false false )
The output must be something like
(list 1 6)
Comment: You need to include code you've already tried and what the result of that was (e.g. there was an error (include it), the output differed from what was expected (include it), etc).
Answer: Well there are a few things we can quickly understand, the first is that you're going to need to recurse through your initial list, and the second is that you're going to need to keep an accumulator list, and somehow have a notion of what element of the first list you're looking at, so we can also add a counter.
So,
; listsearch : (listof Any) Any -> (listof Int)
;   Searches a list for val and returns a list of indexes for occurrences of val in lst
;   (listsearch '(1 2 1 3 4 1) 1) => '(0 2 5)
(define (listsearch lst val)
  (local [(define (helper lst acc counter)
            (cond [(empty? lst)             acc]
                  [(equal? val (first lst)) (helper (rest lst)
                                                    (cons counter acc)
                                                    (add1 counter))]
                  [else                     (helper (rest lst) acc (add1 counter))]))]
    (reverse (helper lst empty 0))))

I've added a local because the counter should be present, but we want the actual function to be tidy, so the call is simply requiring a list and a value.
This simply goes through the list one by one, and makes three checks

Is the list empty? Return my accumulated list (base is empty)
Is the first item in the list my value? Start again but add that value to my accumulator and add one to my counter
Is the first item in the list something else? Start again but add one to my counter

This results in a backwards list, so we reverse it at the end.
That's it! :)
Answer: I'll give you some hints to solve this problem, it's much better if you reach a solution by your own means. Fill-in the blanks:
; position procedure
;    lst: input list
;    ele: the searched element
;    idx: initial index, starts in 0
(define (position lst ele idx)
  (cond (<???>       ; if the input list is empty
         <???>)      ; then we're done, return the empty list
        (<???>       ; if the current element equals the one we're looking then
         (cons <???> ; build output list, cons the index where we found it
               (position <???> ele <???>))) ; and advance the recursion
        (else                               ; otherwise
         (position <???> ele <???>))))      ; just advance the recursion

Notice that the idx parameter is necessary to keep track of the index we're currently over, starting at zero. When the recursion advances, you must advance both the input list and the index. Don't forget to test the procedure:
(position '(false A false false false false A false false false) 'A 0)
=> '(1 6)


Define a resource of Service module, But 'access callback' cannot work

Question: This following is my resource:
For clearly read, I delete some line.
/**
 * Implementation of hook_services_resources().
 */

function baidu_push_services_services_resources() {
  $resources = array();

  $resources['message']['actions']['send'] = [
    'file' => array(
      'type' => 'inc',
      'module' => 'baidu_push_services',
      'name' => 'baidu_push_services',
    ),
    'access callback' => '_message_access',
    'callback' => 'baidu_push_services_send',
    'args' => array(
      array(
        'name' => 'uid',
        'type' => 'string',
        'source' => 'data',
        'optional' => FALSE,
      ),
  ];

  return $resources;
}

In order to test my 'access callback' function will be invoked, I always return FALSE in my 'access callback' function:
function _message_access($op = 'view', $args = array()) {
  return FALSE;
}

But when I try to use curl command line to test with no SESSION and no Token, but It work!(return the right result to me), Did that mean 'access callback' not be invoked?
So I try to use drush cc all to clear cache, But still above problem.
Comment: Are you working with a permission hook? Are you calling curl with authentication or can your service be accessed by anonymous? I'm guessing it's a permission problem?
Answer: Is your access callback in the same file? If not, you'd have to add: "access callback file" to your definition, and point to it.
I'd also clear cache within Drupal, as I've seen drush cc all not always clear all caches.
Also, I'd name-space your access callback function, as it could be conflicting with something else in the system. _message_access is a pretty generic name. You should rename it to: _baidu_push_services_message_access().
Otherwise, your syntax looks correct.
Or, if you solved your issue, perhaps post it in here, to help others.
Comment: thanks for your help, I am try to re-download new drupal and services module, and put my code in, but still not work. So, I am consider i should switch to another language/framework?
Comment: access callback in the same file? yes!


$p(x|\theta)$ in predictive distribution vs likelihood function in bayes

Question: I have doubts over the use of $p(x|\theta)$ in the bayesian context which I would like to clarify. In baye's theorem, the likelihood is considered a function of $\theta$, this means that $x$ is fixed and $\theta$ varies.
In the predictive distribution, $x$ is random and $\theta$ is fixed since the predictive distribution tries to average the distribution of $x$ over all possible values that $\theta$ can take.
Is my understanding of $p(x|\theta)$ in these 2 context correct ?
Answer: The likelihood function $p(x|\theta)$ is a function of your data. This means that your $x$ is fixed and you want to check which value of $\theta$ is the most probable for your data, i.e. which value of $\theta$ maximized your $p(x|\theta)$.  $p(x|\theta)$ is the conditional distribution of $x$, and yes it can be seen as a function of $\theta$, but not as a distribution of $\theta$.
For the predictive distributions of $x$, you have two cases, the prior and the posterior predictive.
The posterior predictive is defined as
$$p(x|Data)=\int_{\Theta}p(x|\theta)p(\theta|Data)d\theta$$
In this case, you can consider your $x$ as a random quantity, because you define a (marginalized in terms of $\theta$) conditional distribution for $x$. However, I believe that you cannot consider $\theta$ fixed because it doesn't take certain values. You have to let $\theta$ take values all over the domain that the posterior distribution of $\theta$ is defined. As you said it tries to average over all possible values of $\theta$, so I assume that also $\theta$ has to be random.


What are all the possible right and left inverses for $f$?

Question: Define a function $f:ℕ→ℕ$ by $f(n)=n-1$  for $n≥2$, and $f(1)=30$. What are all possible right  and left inverses for f?
My intuition tells me that it has to do with injectivity and surjectivity. But I have problem figuring it out.
Comment: Hint: write down the conditions $(l \circ f)(n) = n$ (resp. $(f \circ r)(n) = n$_ for a left (resp. right) inverse of $f$ and then try to solve the equations using the definition of $f$ to find out what $l$ and $r$ would have to do.
Answer: Observe that $f(31)=f(1)=30$, so the function is not injective. However, the function is surjective (onto) because we can have $f(k+1)=k$.
A left inverse $g:\mathbb{N} \rightarrow \mathbb{N}$ would be such that $g(f(n))=n$. Should such a function exist, then $g(f(31))=31$ and $g(f(1))=1$, but by the remark above $g(f(31))=g(f(1))$. So NO left inverse can exist.
A right inverse $h:\mathbb{N} \rightarrow \mathbb{N}$ would be such that $f(h(n))=n$. Can you try the right inverse now?
Comment: @JanetWang you mean surjective implies **right inverse exists**. For uniqueness, say there exists $k$ which is also a right inverse of $f$, then $f(g(n))=f(k(n))$ for all $n$. This implies $g(n)-1=k(n)-1$ for all $n$. Consequently, $g$ and $k$ are same functions.
Comment: Hi, I understand that f is surjective, therefore left inverse definitely exists. However, does this mean that there exists infinite number of h(n)? For sure that h(n) = n+1 is a right inverse, but I am confused about whether it is unique or not.
Comment: Thank you very much. One last question, if we find the right inverse $h$ of $f$, then f becomes the left inverse of h. How do we know how many left inverses are  there for h? By checking its bijectivity first?


Draw a guide line between piano staves in LilyPond

Question: I am trying to reproduce a piano score in LilyPond. It has a straight dash line between a grace note in one staff and a chord in another. I tried using <code>\change Staff</code>, but it either breaks the grace notes, or notes horizontal position, or makes the chord in another staff look small as grace notes.
The picture shows the desired effect.
MWE (without the dash line):
<code>\version "2.20.0"
\language "italiano"

\score {
  \new PianoStaff <<
    \new Staff = "RH" \relative do' {
        \time 3/4
        mi'16 la mi re
        \appoggiatura {
            re32 % need a line from this re down to the second chord in the LH
            mi
        } re8 mi re4
    }
    \new Staff = "LH" \relative do' {
        \time 3/4
        \clef bass
        <fa, la mi'> <fa la re> <<
        {
            re'8 do
        } \\
        {
            <fa, la>4
        }
        >>
    }
  >>
}
</code>
Answer: This is quite fiddly. I'd do below. There really might well be an easier way to do this.
Line created with VoiceFollower which is used for part writing like fugues and the voice changing staves.
Need to create hidden notes which give reference to start x and y, and end x and y of VoiceFollower.
Changed position of VoiceFollower and appoggiatura slur to avoid collision.
Separated the main changes into two variables (makes sense anything more than a line, put it as a variable):

visibileAppoggiaturaSlurAdjust (I was getting confused with the hidden one so made sense call it visible), and
lineGoesDown (that's obvious what it's doing!)

Changed chords in same voice in LH because it just made sense.
<code>\version "2.20.0"
\language "italiano"

visibileAppoggiaturaSlurAdjust = \shape #'((0.3 . 0.2) (0.15 . 0.15) (0 . 0.15) (0.2 . 0.2)) Slur

lineGoesDown = {
           \change Staff = "RH"
           \override VoiceFollower.style = #'dashed-line
           \override VoiceFollower.bound-details = #'((right (attach-dir . -0.5) (padding . 0)) (left (attach-dir . -1) (padding . 0)))
           \showStaffSwitch
           \hideNotes \stemDown
           \appoggiatura { \once \override Slur.stencil = ##f  re16 }

           \change Staff = "LH" re,4
           \hideStaffSwitch \unHideNotes \stemUp
}

\score {
 \new PianoStaff <<
   \new Staff = "RH" \relative do' {
       \time 3/4
       mi'16 la mi re
       \appoggiatura {
           \visibileAppoggiaturaSlurAdjust
           re32 % need a line from this re down to the second chord in the LH
           mi
       } re8 mi re4
   }
   \new Staff = "LH" {
       \time 3/4
       \clef bass
       <<
         \relative do'' {

           s4
           \lineGoesDown
           re8 do |

         }
         \\
         \relative do {

          <fa la mi'>4 <fa la re>  <fa la> |

         }
       >>
   }
 >>
}
</code>
Produces:

This second one produces desired output for a repeat of the second bar where there was a bug of the voicefollower being on when it should be off but would later go back on again!
<code>\version "2.20.0"
\language "italiano"

visibileAppoggiaturaSlurAdjust = \shape #'((0.3 . 0.2) (0.15 . 0.15) (0 . 0.15) (0.2 . 0.2)) Slur

lineGoesDown = {
           \hideStaffSwitch
           \change Staff = "RH"

           \override VoiceFollower.style = #'dashed-line
           \override VoiceFollower.bound-details = #'((right (attach-dir . -0.5) (padding . 0)) (left (attach-dir . -1) (padding . 0)))
           \showStaffSwitch
           \hideNotes \stemDown
           \appoggiatura { \once \override Slur.stencil = ##f  re16 }

           \change Staff = "LH" re,4
           \unHideNotes \stemUp
           \once \omit VoiceFollower

}

\score {
 \new PianoStaff <<
   \new Staff = "RH" \relative do' {
       \time 3/4
       \repeat unfold 2 { mi'16 la mi re
       \appoggiatura {
           \visibileAppoggiaturaSlurAdjust
           re32 % need a line from this re down to the second chord in the LH
           mi
       } re8 mi re4
       }
   }
   \new Staff = "LH" {
       \time 3/4
       \clef bass
       \repeat unfold 2 {
       <<
         \relative do'' {

           s4
           \lineGoesDown
            re8 do |
           \change Staff = "RH"
           \hideStaffSwitch

         }
         \\
         \relative do {

          <fa la mi'>4 <fa la re>  <fa la> |

         }
       >>

       }
   }
 >>
}
</code>
Comment: Hopefully ok now. Take a look at the 2nd code. Would need to use `\change Staff = "RH"` and `\hideStaffSwitch`, one after the other. Need to reset and force a staff switch and hide staff switch outside of the variable otherwise it just continues. Works for me
Comment: Thanks! LilyPond is not for the faint of heart :).
Comment: You're welcome! LP very adaptable and there's some really nice answers on Music Stack Exchange about it!
Comment: This code has a problem I cannot solve. If I use it in two bars in a row, it connects the last do8 in the LH of the first bar to the invisible re16 in the RH of the second. I removed the macro and just copy&pasted your code and started playing with the placement of \hideStaffSwitch. Nothing helps. Is it a bug in LilyPond? Or it seems like \showStaffSwitch shows the VoiceFollower for the note preceding the switch as well.
Comment: Thanks! In the real score the bars of course are different. A single `\change Staff = "RH"` in the end of the first block solved the issue. Weird.


How to factor out $B \in \mathbb{R}^{n \times n}$ from $B + A_1BA_1 + A_2BA_2 + A_3BA_3?$

Question: Suppose $A_1, A_2, A_3 \in \mathbb{R}^{n \times n}$ are diagonal matrices where $A_1 + A_2 + A_3 = I_{n \times n}$. Suppose $B \in \mathbb{R}^{n \times n}$ is a symmetric matrix. Is it possible to factor out $B$ from $$B + A_1BA_1 + A_2BA_2 + A_3BA_3?$$
Comment: well if $A_1=O,A_2=O,A_3=I$, then $B + O + O +B=2B$ certainly B is factored out no matter what is is.
Comment: You will be able to determine the diagonal elements of $B,$ but off diagonals elements may not be determined, if you allow  some negative entries in $A_i$
Answer: Let $x_k, y_k$ denote the first two diagonal entries of the matrix $A_k,$ $k=1,2,3.$ Then $x_1+x_2+x_3=1$ and $y_1+y_2+y_3=1.$ The $(1,2)$ entry of the sum $B+A_1BA_1+A_2B_2+A_3BA_3$ is equal
$$b_{12}[1+x_1y_1+x_2y_2+x_3y_3]$$ If the sum in the square bracket vanishes, the entry $b_{12}$ cannot be evaluated. This does not occur when $x_k,y_k\ge 0.$ But if we allow negative values, then we may take
$$x_3=y_3=0,\quad x_1=-1, \ x_2=2,\quad y_1=1, \ y_2=0$$ and the entry $b_{12}$ cannot be determined.
Comment: No. The $(ij)$ term of the sum is equal $b_{ij}(1+d_{i,1}d_{j,1}+d_{i,2}d_{j,2}+d_{i,3}d_{j,3})$ where $d_{i,k}$ denote the diagonal entries of $A_k,$ $k=1,2,3.$
Comment: +1, doesn't $b_{12}$ show up in other terms of $B + A_1BA_1 + A_2BA_2 + A_3BA_3$ though?
Answer: Notice $B$ can be taken out common if $B$ commutes with $A_1$,$A_2$,$A_3$, that is $A_1B=BA_1$, $A_2B=BA_2$, $A_3B=BA_3$. and since $A_1,A_2,A_3$ are diagonal matrixes, if $B$ is also diagonal matrix then then it will commute with $A_1,A_2,A_3$.
Comment: If $A_1B = (BA_1)^T$, $A_2B = (BA_2)^T$, and $A_3B = (BA_3)^T$, does that help with anything?
Comment: What does $t(BA_1)$ here means
Comment: no it's not possible to take out $B$ in all cases.


The identity link not used for binary response

Question: Questions: The identity link is the standard one with normal responses but is not often used with binary or count responses. Why do you think this is?
My idea:  The range for a linear predictor, and the range of the identity link applied to a binomial probability or to a Poisson mean. I am kinda confused
Comment: It's to map the real line to a range of plausible values of the parameter of the response distribution. Instead of $Poisson(-1)$, the $log$ link gives us $Poisson(e^{-1})$.
Comment: @Dave What do mean by Poisson(-1)?
Comment: See  https://stats.stackexchange.com/questions/139917/r-binomial-family-with-identity-link
Answer: If you use the identity link for the binary data, then your regression equation would be
$$
{\rm Pr}(Y_i|x_i)\equiv p_i = \beta_0 + \beta_1 x_i.
$$
Without any restriction on the coefficients, RHS can range in real-line (for example, a negative value). Since this does not make any sense for probability $p_i$, we transform it so that $g(p_i)$ takes its value in $[-\infty, \infty]$.


MuseScore: Change all notes to auto velocity

Question: In MuseScore, you change the velocity (volume) of a note by right-clicking it, selecting note properties and changing the velocity. I want to make the velocity type on all of the notes auto (somehow, I don't know how, they're all set to user at 110 velocity). I could manually go through each note and reset the velocity to auto. However, with five staves and 100+ measures, it's not really practical to change each note to auto one by one. Even if I selected multiple notes at a time, it would still be tedious and time consuming.
Is there any practical way to change all of the notes in a score to auto velocity?
Comment: Sorry I'm not answering your question but you can find all the help on the MuseScore forum at http://musescore.org/en/forum Repost your question there and you'll find that the MuseScore community is very friendly and helpful.
Answer: After an hour or so of composing and trying different things, I found my solution:

Right click any note head and click Select > All Similar Elements
Right click any note and select Note Properties...
Set velocity type to auto
Click Ok
Comment: This answer from 9 years ago was my salvation today, thank you so much for this, @American Luke from the past :) There were some changes in current version. For point 2, go to View > Object Controller (F8). For point 3, find "Playback" section and reset velocity type and value
Comment: I am using MuseScore 3.6.2 and I don't see an Object Controller, but I do see an Inspector, but then, it has Velocity as "Offset" or "User" and it can be set to a hard value or I suppose if it is Offset, that means a delta (plus or minus the value)... but I don't see an auto there


Wordpress htaccess not working with subdirectory

Question: i have directoryoffering-pages in my domain
offering-pages/.htaccess code is
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./index.php [L]
</IfModule>
# END WordPress

i access dashboard of wordpress and only the home page of my website.
when i go to other page like http://domain/offering-pages/offerings-for-students/ it display the content of domain/index.php
Comment: Did you accidentally wrote `offering-page` instead of `offering-pages`?
Comment: ya its offering-pages not offering-page
Comment: `RewriteRule ./index.php [L]` - There should be a space between `.` and `/index.php` (otherwise this directive won't do anything helpful). However, this .htaccess file assumes your site is in the document root (doesn't WordPress itself manage this?). If this .htaccess file is in a subdirectory then one way to "fix the .htaccess file" is to remove the slash prefix on the `RewriteRule` substitution ie. `RewriteRule . index.php [L]` and remove the `RewriteBase` directive entirely.
Answer: Try this script and change domain and subdomain according to their names and also post wordpress related question to wordpress.stackexchange
RewriteEngine On

# rewrite subdomains to separate folder
RewriteRule ^subdomain/ - [L]

RewriteCond %{HTTP_HOST} !^www\.domain\.com$
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com$
RewriteRule ^(.*)$ subdomain/$1 [L]
# or if you want to rewrite sub.domain.com/test to /subdomain/sub/test
#RewriteRule ^(.*)$ subdomain/%1/$1 [L]

# force www
RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R]

# BEGIN WordPress
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./index.php [L]
# END WordPress

Answer: Did you install Wordpress in the offering-pages directory? If so, you need to change index.php to point to your directory where Wordpress is installed.
From:
require(dirname(__FILE__) . '/wp-blog-header.php');

To:
require(dirname(__FILE__) . '/offering-pages/wp-blog-header.php');

Comment: it not work give error:- failed to open stream: No such file or directory in
Comment: You didnt answer my question. Yes or no, did you install Wordpress in another subdirectory different than the root?
Comment: Move the .htaccess file to the root of your website, not in the subdirectory.
Comment: i have moved .htaccess its give :- /index.php was not found on this server.
Comment: You also need to change the Wordpress Address URL to http://www.yoursite.com/offering-pages and the Site Address to http://www.yoursite.com in the Dashboard config
Comment: i have moved index.php and edit to :-require(dirname(__FILE__) . '/offering-pages/wp-blog-header.php');
Comment: its work properly But i have my php webite on root folder and it has already index.php and i have to put wordpress on root/offering-pages
Comment: The modified index.php must be in the root folder of your website. The .htaccess file must be in the root folder of your website. For example, if it is on Apache, the root of your website is something like public_html/yourwebsite
Comment: I have to step away. I wrote about this a few years ago on my website. You can learn more about setting up Wordpress in its own folder here: http://kobashicomputing.com/running-wordpress-on-wamp-server
Answer: SOLVED!!!
The top site's custom Permalinks (anything other than "Plain") clash with the subdirectory site's custom Permalinks (anything other than "Plain").
Both cannot be set to be custom (without a complicated solution).
To fix (and not get "Invalid JSON response" when modifying or creating Posts and Pages), simply delete the top site's .htaccess file (in the root directory usually under public_html).
And to prevent future clashes, go to the top site's site Settings > Permalinks in WordPress and change the setting to Plain, delete any Category and Tag Base, and click SAVE.  When you click SAVE, a new .htaccess file is created or the old one is overwritten for that directory (and Plain actually means an empty .htaccess file or no setting).
This means that you won't be creating pages and posts with pretty URLs from the top site (for that specific site you'll have to use an auto-generated post or page url like example.com/?p=123 instead of example.com/postname).
Antonio Robateau


Is it possible to foreign key on bulk_create() Django?

Question: I have the need to create many EVENT objects at once and subsequently create many ARCHIVED_EVENT objects that have a foreign key to their corresponding event.
My code looks like something like this:
events = []
archivedEvents = []
for _ in range(1000):
    event = Event(name="Test")
    archivedEvent = ArchivedEvent(event_id=event.id)
    archivedEvents.append(archivedEvent)
    events.append(event)

Event.objects.bulk_create(events)
ArchivedEvent.objects.bulk_create(archivedEvents)

Unfortunately all Archived Events created here have a NULL foreign key to an EVENT. I understand that the primary key for an object is not generated until it is saved to the database. But I save the events before creating the archived events. Am I missing something? Should I refresh the cache before bulk creating the archived events?
Answer: event.id won't be created unless it does through bulk_create(). Probably you can use another loop to create ArchivedEvent. Like this:
events = []
archivedEvents = []

for _ in range(1000):
    event = Event(name="Test")
    events.append(event)
events = Event.objects.bulk_create(events)

for event in events:
    archivedEvent = ArchivedEvent(event_id=event.id)
    archivedEvents.append(archivedEvent)
ArchivedEvent.objects.bulk_create(archivedEvents)

This solution works for Postgresql as per documentation. If you have other databases, then try like this:
events = []
archivedEvents = []

for _ in range(1000):
    event = Event(name="Test")
    events.append(event)
Event.objects.bulk_create(events)

events = Event.objects.all().order_by('-id')[:1000][::-1]
for event in events:
    archivedEvent = ArchivedEvent(event_id=event.id)
    archivedEvents.append(archivedEvent)
ArchivedEvent.objects.bulk_create(archivedEvents)

To avoid race conditions, you can pre-generate primary keys, then use them. For example:
last_event_id = Event.objects.last().id + 1000 # getting last event id and adding thousand to avoid duplicates.

events = [x+last_event_id for x in range(1000)]
archivedEvents = []

for e in events:
    event = Event(name="Test",pk=e)
    events.append(event)
    archivedEvent = ArchivedEvent(event_id=e)
    archivedEvents.append(archivedEvent)

Event.objects.bulk_create(events)
ArchivedEvent.objects.bulk_create(archivedEvents)

Comment: This did not work, the archived events still have NULL as their event_id.
Comment: Have you considered the race conditions with this approach? If Event objects were created between the bulk_create() and the query, everything breaks horrendously. Is the best option really to save() individually?
Comment: It appears the race condition continues. If the view that runs this code is called twice at the same time, all hell breaks loose.
Comment: then this beats the purpose of using bulk create here. this code is not suppose to be used with view rather in a management command or shell. So, As Ludovico suggested, you should use individual save().
Comment: because event.id has a value now.
Comment: what database are you using? as per documentation, it should work in postgresql.
Comment: I am using MySQL
Comment: then you need to make a query to get last thousand items and iterate through them. I have updated the answer.
Comment: Please see the updated answer. again this is not tested in MySQL
Comment: Ok, back to the stoneage-saves it is. Thank you for your time.
Comment: In this case, you need put this inserting logic in a transaction and with a lock to avoid race condition. See my answer.
Answer: Here is a solution to avoid race condition with db's lock based on @ruddra's other database solution. Hope this can help you.
from django.db import transaction

with transaction.atomic():

   # lock first row to avoid race condition
   # note: first row of Event table must have content,
   #       if not, you need use other tables's not empty row to add lock.
   Event.objects.select_for_update().first()

   # just @ruddra's mysql solution
   events = []
   archivedEvents = []

   for _ in range(1000):
       event = Event(name="Test")
       events.append(event)
   Event.objects.bulk_create(events)

   event_ids = Event.objects.values_list('id', flat=True).order_by('-id')[:1000][::-1]
   for event_id in event_ids:
       archivedEvent = ArchivedEvent(event_id=event_id)
       archivedEvents.append(archivedEvent)
   ArchivedEvent.objects.bulk_create(archivedEvents)

Comment: What exactly is happening here? Why are we locking the first row?
Comment: It's just a lock provided by db to avoid race condition, you can use any other table row. Usually, I use first row as the lock.  See [select-for-update](https://docs.djangoproject.com/en/3.0/ref/models/querysets/#select-for-update)
Comment: Hmm, perhaps this lock technique would take more time than single saves() as this view could now run simultaneously but not really as some threads would need to wait.
Comment: I don't think so. Eventually all data need to wait lock at db level when insert. See [Which is faster: multiple single INSERTs or one multiple-row INSERT?](https://stackoverflow.com/questions/1793169/which-is-faster-multiple-single-inserts-or-one-multiple-row-insert), although the view now run simultaneously, it can handle the request more fast. Anyway, for the time cost, you'd better have a test.


How do I draw an elliptic curve?

Question: I can draw a circle using a compass.
I can draw an ellipse using two focal points and a loop of string.
I think that you can draw an arbitrary conic with a "generalized" compass for which the pencil can slide in and out as it is rotated.
What instruments and devices can draw elliptic curves?
Comment: I wonder why people are upvoting this facetious answer..
Comment: Elliptic curves such as $y^2=x^3-x$ have two components. Could a device plot both components?
Answer: This thesis looks like it may be of considerable interest.
Answer: I have an answer, for a limited case, and it is not pretty. Elliptic curves have the form:
$y^2= x^3 + ax +b$
Suppose $b=0$ and $a < 0$
$y^2= x(x^2 + a)$
$y= \sqrt{x}\sqrt{x^2 + a}$
You can construct $\sqrt{x}$ as shown here.

And, $\sqrt{x^2 + a}$  with $a < 0$ is the distance from (x, -a) to the origin.
We have two constructible lengths so just construct their product:

...and you have y.
Comment: That's quite neat but am I right in thinking it only lets us construct a single point at a time rather than tracing out part of the curve?
Comment: Yes. This would be quite tedious. Though, there may be some way of streamlining it. The constructions have so many similarities. I've added some images to show this.

How do I draw an elliptic curve?


run javascript every 24 hours

Question: I want to run a piece of javascript every 24 hours for each specific user? This is to clear HTML5 local storage, how would I run this script every 24 hours for each user when they are logged in?
Answer: The best way would be to to store an additional value in local storage that is the last time you cleared it.
Each page view, you simply check that value and if the last time was > 24 hours ago, you clear the local storage and set the last clear time to now.
<code>(function () {

  var lastclear = localStorage.getItem('lastclear'),
      time_now  = (new Date()).getTime();

  // .getTime() returns milliseconds so 1000 * 60 * 60 * 24 = 24 days
  if ((time_now - lastclear) > 1000 * 60 * 60 * 24) {

    localStorage.clear();

    localStorage.setItem('lastclear', time_now);
  }

})();
</code>
Put this in a JS file that is added only when the current user is logged in.
Here is an example using a module named 'sample':
<code>/**
 * Implements hook_init().
 */
function sample_init() {
  global $user;

  // User with uid 0 is anonymous/logged out, any uid greater is logged in.
  if ($user->uid > 0) {
    drupal_add_js(drupal_get_path('module', 'sample') . '/js/sample.js');
  }
}
</code>
Comment: this is cool but I want to clear it at midnight of each day.
Answer: The simplest way to perform a periodic execution of a javascript code is to use setTimeout(functionname() , time in millisecond) function. Write a function say func() and write the javascript code you want to run in the function and at last use setTimeout() function..
e.g.
<code>function func() {

.....
........
line of code....
......
.....

setTimeout(function(){
  func(arguments if any);
},24*60*60*60);
}
</code>
For customizing this for each user you may use php code to check for user authenticity.Hope This helps..
Comment: SetTimeout is for short timeouts, not for this use case. This script stops running when the user closes the browser (tab), so when the user comes back after 24 (or more) hours, the timeout starts over again.

run javascript every 24 hours


What Is Active db in CodeIgniter?

Question: What Is Active db in CodeIgniter
I have been searching but I am not getting answer in this question?
Please answer me.
Comment: Hit [the manual](https://codeigniter.com/docs) not SO
Comment: In that manual i am not getting active db
Comment: Its called active record so try here https://www.codeigniter.com/userguide2/database/active_record.html Is google banned in your country
Comment: As what RiggsFolly said but here is the active record for CI3 but changed name http://www.codeigniter.com/user_guide/database/query_builder.html
Answer: I think it's Active Record not Active DB. Active Record is a One kind of design pattern used for retrieve, insert, and update your database with minimal scripting. You will find more about this in the bellow link
https://www.codeigniter.com/userguide2/database/active_record.html
Comment: http://www.codeigniter.com/user_guide/database/query_builder.html And this for CI3

What Is Active db in CodeIgniter?


Placement coordinates of bitmapData in AS3

Question: i've programatically created a vector graphic (rect), repositioned the graphic, and set up an MOUSE_MOVE eventListener to trace color information of the graphic using getPixel().  however, the bitmapData is placed at 0,0 of the stage and i don't know how to move it so that it matches the graphic's location.
var coloredSquare:Sprite = new GradientRect(200, 200, 0xFFFFFF, 0x000000, 0xFF0000, 0xFFFF00);
coloredSquare.x = 100;

addChild(coloredSquare);

var coloredSquareBitmap:BitmapData = new BitmapData(coloredSquare.width, coloredSquare.height, true, 0);
coloredSquareBitmap.draw(coloredSquare);

coloredSquare.addEventListener(MouseEvent.MOUSE_MOVE, readColor);
function readColor(evt:Event):void
    {
    var pixelValue:uint = coloredSquare.getPixel(mouseX, mouseY);
    trace(pixelValue.toString(16));
    }

Answer: Use the square's transformation matrix (which contains the translation as well) as the second parameter of the draw() method
e.g.
coloredSquareBitmap.draw(coloredSquare,coloredSquare.transform.matrix);

Comment: hi george.  i had tried that but the mouse event is lost on the right half of the coloredSquare.  it seems to work only for the left half.
Comment: +1. although `concatenatedMatrix` is better, since it works in all cases, an not just if the parent has no transformation applied.
Comment: oh i see my mistake now. you did actually answer the question but my mouse event was causing errors. thanks.
Answer: Use
var pixelValue:uint = coloredSquare.getPixel(coloredSquare.mouseX, coloredSquare.mouseY);

That way the mouseX / mouseY will be local to the coloured square and thus the bitmap duplicate .
Answer: I do not fully understand the problem or the code. Maybe this helps:
coloredSquareBitmap.draw(coloredSquare, coloredSquare.transform.concatenatedMatrix);


Can the determinant of an integer matrix with $k$ given rows equal the gcd of the $k\times k$ minors of those rows?

Question: I'm interested if the following is true:

Let $n> k\geq1$ be integers, let $A\in\mathbb Z^{k\times n}$ and denote the $\binom nk$ $k\times k$ minors of $A$ by $A_1,\ldots,A_N$.
  Then the equation
  $$\left|\begin{array}{c}A\\\hline X\end{array}\right|=\gcd(A_1,\ldots,A_N)$$
  always has a solution $X\in\mathbb Z^{n-k\times n}$.

This is a generalisation of Can the determinant of an integer matrix with a given row be any multiple of the gcd of that row? (which is the case $k=1$). For $\style{text-decoration:line-through}{k=n}$ and $k=n-1$ the above conjecture is also (obviously) true.
Note that, as in the linked question, finding the minimal positive value of that determinant is equivalent to finding the minimal hypervolume of an $n$-dimensional simplex whose vertices are in an integer lattice and $k+1$ vertices are fixed.
Idea: The case $\gcd(A_1,\ldots,A_N)=1$ may follow from Elementary proof that if $A$ is a matrix map from $\mathbb{Z}^m$ to $\mathbb Z^n$, then the map is surjective iff the gcd of maximal minors is $1$
Answer: This follows from the Smith normal form and so holds for any PID: Smith-normal form preserves the gcd of minors of size $k$ for all $k\leq n$ (in particular, the determinant). This can be seen from Cauchy-Binet's formula.
It suffices to go to Smith normal form to obtain a matrix of the form
$$QAP=\begin{pmatrix}D&0\end{pmatrix}$$
with $D$ diagonal of size $k\times k$ and determinant equal to the gcd of $k\times k$ minors of $A$. Extend it in a trivial way:
$$\begin{pmatrix}D&0\\0&I_{n-k}\end{pmatrix}$$
and apply the inverse change of bases that gave the smith normal form to obtain
$$\begin{pmatrix}Q^{-1}&0\\0&I_{n-k}\end{pmatrix} \cdot \begin{pmatrix}D&0\\0&I_{n-k}\end{pmatrix} \cdot P^{-1} = \begin{pmatrix}A\\X\end{pmatrix}$$
for some $X$ (equal to the last $n-k$ rows of $P$).
Comment: Nitpick: gcd in a PID is defined only up to scaling by invertible elements, whereas gcd in $\mathbb {Z} $ is nonnegative by definition. So, be careful with $k=n $ in the original question.
Comment: You're right. If $k<n$ we can multiple the last row by any invertible, if $k=n$ we can't. Edited the question.


How to set Infiniband port from INIT to ACTIVE

Question: I have the following setup. 7 Nodes, let's say they are called gauss1 to gauss7. I have a stable connection between gauss1 to gauss6. Just gauss7 is making trouble.
# ibnodes
Ca  : 0x0002c90300f2eef0 ports 2 "gauss1 mlx4_0"
Ca  : 0x0002c90300f2ef20 ports 2 "gauss2 mlx4_0"
Ca  : 0x7cfe900300be5350 ports 1 "gauss3 mlx4_0"
Ca  : 0x7cfe900300be5170 ports 1 "gauss4 mlx4_0"
Ca  : 0x7cfe900300be51a0 ports 1 "gauss5 mlx4_0"
Ca  : 0x248a070300d8f5c0 ports 1 "gauss6 mlx4_0"
Ca  : 0xec0d9a03002baf50 ports 1 "gauss7 mlx4_0"

So all nodes seem to be registered on the switch. The port state is for gauss1 to gauss6 on ACTIVE. Just on gauss7 I have the port state INIT.
ibv_devinfo on gauss7 says:
hca_id: mlx4_0
    transport:          InfiniBand (0)
    fw_ver:             2.42.5000
    node_guid:          ec0d:9a03:002b:af50
    sys_image_guid:         ec0d:9a03:002b:af53
    vendor_id:          0x02c9
    vendor_part_id:         4099
    hw_ver:             0x0
    board_id:           MT_1100120019
    phys_port_cnt:          1
        port:   1
            state:          PORT_INIT (2)
            max_mtu:        4096 (5)
            active_mtu:     4096 (5)
            sm_lid:         3
            port_lid:       9
            port_lmc:       0x00
            link_layer:     InfiniBand

I have installed opensm on gauss7 as well and it says it's in STANDBY:
Feb 02 20:15:36 gauss7 opensm-launch[355306]: Using default GUID 0xec0d9a03002baf51
Feb 02 20:15:36 gauss7 OpenSM[355309]: Entering DISCOVERING state
Feb 02 20:15:36 gauss7 opensm-launch[355306]: Entering DISCOVERING state
Feb 02 20:15:36 gauss7 OpenSM[355309]: Entering STANDBY state
Feb 02 20:15:36 gauss7 opensm-launch[355306]: Entering STANDBY state

My Question: How can I set the port on gauss7 to ACTIVE and have a connection between all 7 nodes?
Comment: Double check cabling by changing the connection of e.g. `gauss6` with `gauss7`. If the problem switches to `gauss6` it is a bad cable or port on the switch or just reinsert the cable. If the error stays with `gauss7` investigate on the server and power it off and on again. `opensm` does not need to run on each node and there can be only one active, the other opensm instance are STANDBY.
Comment: The physical port says `LinkUp`. Doesn't this mean that the physical connection is ok? The problem is btw that I can't access gauss7 from every other server (gauss1-gauss6) Between all nodes is a physical infiniband switch.
Answer: A reboot of gauss7 solved the issue.


jQuery UI: Horizontal slider goes too far right

Question: I changed the appearance of the horizontal slider in jQuery UI to make it large and round, which looks great except the slider goes too far when you move it all the way to the right!

http://jsfiddle.net/RXFn6/
How can this be remedied?
HTML

Slider

JavaScript
$(function() {
    $( "#slider" ).slider({
        range:"min",
        value:50
    });
});

CSS
/*! jQuery UI - v1.10.3 - 2013-06-30
* Copyright 2013 jQuery Foundation and other contributors Licensed MIT */

.ui-widget-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.ui-slider {
    position: relative;
    text-align: left;
}
.ui-slider .ui-slider-handle {    width:50px;
    height:50px;
    background:url(../images/slider_grabber.png) no-repeat; overflow: hidden;
    position:absolute;
    top: -4px;
    border-style:none;  }
.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0;
border-radius: 33px 0 0 33px;
}

.ui-slider-horizontal { height: 2.5em; border-radius: 100px !important }
.ui-slider-horizontal .ui-slider-handle { margin-left: -.6em; z-index: 9000; max-width: 95% !important;
border-radius: 100px;}

.ui-slider-horizontal .ui-slider-range {
    top: 0;
    height: 100%;
}
.ui-slider-horizontal .ui-slider-range-min {
    left: 0;
}
.ui-slider-horizontal .ui-slider-range-max {
    right: 0;
}

.ui-widget select,
.ui-widget textarea,
.ui-widget button {
    font-family: Lucida Grande,Lucida Sans,Arial,sans-serif;
    font-size: 1em;
}
.ui-widget-content { border: 1px solid #a6c9e2; background: #daa; color: #222222; }
.ui-widget-content a {
    color: #222222;
}
.ui-widget-header { border: 1px solid #4297d7; background: #ada; color: #ffffff; font-weight: bold; border-radius: 33px 0  0 33px; min-width: 33px;}
.ui-widget-header a {
    color: #ffffff;
}

/* Interaction states
----------------------------------*/
.ui-state-default,
.ui-widget-content .ui-state-default,
.ui-widget-header .ui-state-default {
    border: 1px solid #c5dbec;
    background: #dfeffc url(images/ui-bg_glass_85_dfeffc_1x400.png) 50% 50% repeat-x;
    font-weight: bold;
    color: #2e6e9e;
}
.ui-state-default a,
.ui-state-default a:link,
.ui-state-default a:visited {
    color: #2e6e9e;
    text-decoration: none;
}
.ui-state-hover,
.ui-widget-content .ui-state-hover,
.ui-widget-header .ui-state-hover,
.ui-state-focus,
.ui-widget-content .ui-state-focus,
.ui-widget-header .ui-state-focus {
    border: 1px solid #79b7e7;
    background: #d0e5f5 url(images/ui-bg_glass_75_d0e5f5_1x400.png) 50% 50% repeat-x;
    font-weight: bold;
    color: #1d5987;
}
.ui-state-hover a,
.ui-state-hover a:hover,
.ui-state-hover a:link,
.ui-state-hover a:visited {
    color: #1d5987;
    text-decoration: none;
}
.ui-state-active,
.ui-widget-content .ui-state-active,
.ui-widget-header .ui-state-active {
    border: 1px solid #79b7e7;
    background: #f5f8f9 url(images/ui-bg_inset-hard_100_f5f8f9_1x100.png) 50% 50% repeat-x;
    font-weight: bold;
    color: #e17009;
}
.ui-state-active a,
.ui-state-active a:link,
.ui-state-active a:visited {
    color: #e17009;
    text-decoration: none;
}

Comment: unfortunalte you have to add a wrapper around slider and applay padding on it
Answer: Fixed it:
http://jsfiddle.net/RXFn6/3/
Here are the steps for resolving this issue:

Wrap slider in a div
Remove background and border from .ui-widget-content
Add background and border from (2) to wrapper div created in (1)
Set border-radius on wrapper, if necessary
Increase padding-right on wrapper until slider no longer looks like it goes off the track


Sequelize query include and logic

Question: I have three tables: Article, Tag and ArticleTag. An article could have multi tags and a tag could be belongs to multi articles through ArticleTag. Tag has a name property.
I want query all the article which has tags tag1 and (tag2 or tag3) and (tag4 or tag5).
The following query doesn't work.
Article.findAll({
    where: {},
    include: [
        {
            model: Tag,
            where: {
                [Op.and]: [
                  { name: 'tag1' },
                  { name: { [Op.or]: ['tag2', 'tag3'] } },
                  { name: { [Op.or]: ['tag4', 'tag5'] } },
                ]
            }
        }
    ]
})

Answer: I think having and group_by will get you the expected result ( Please do read comments in below code also ) :
Article.findAll({
    where: {},
    include: [
        {
            model: Tag,
            where: {
                [Op.or]: [ { name: 'tag1' }, { name: 'tag2' }] // change from and to or
            }
        }
    ]
    group : ['articles.id','tags.id'] , // might need to change table name as per yours
    having : {
        db.sequelize.where(db.sequelize.fn('count', db.sequelize.fn('DISTINCT', db.sequelize.col('articles.id'))),2)
    }
});

For updated question just change or block within where :
[Op.and]: [
    { name: 'tag1' },
    { name: { [Op.or]: ['tag2', 'tag3'] } },
    { name: { [Op.or]: ['tag4', 'tag5'] } },
]

Comment: Thanks for your answer, it answer my question but don't solve my problem. Maybe I need update my question.
Comment: There is a `having` filter which only accepts data with 2 distinct tags. In the update question, it seems that it is hard to determine this number(2).

Sequelize query include and logic


Floating asides to each side of a section?

Question: I have two aside tags. One aside tag needs to be floated to the right, the other needs to be floated the left. They're both on the correct sides but the section won't let the asides go next to it, they are still below it.
Here's the html:
http://pastebin.com/BHtdYZfD
Here's the css:
http://pastebin.com/jhfLNNfS
Maybe, I left something out in the code. Any help would be greatly appreciated!
Comment: You certainly left something out of the question ... a jsFiddle, which would be infinitely more helpful than pastebin.
Answer: Here you go: just change the HTML-code a little bit like this:

                <hgroup>

San Joaquin Valley Town Hall

Celebrating our 75th Year

                </hgroup>

Event change for November 16

SJV Town Hall is pleased to announce the addition of award-winning author Andrew Ross Sorkin.
                The appearance of previously scheduled speaker, Greg Mortenson, has been postponed.

2011-2012 Speakers

October 19, 2011
Jeffrey Toobin

November 16, 2011
Andrew Ross Sorkin

January 18, 2012
Amy Chua

February 15, 2012
Scott Sampson

Our Mission

San Joaquin Valley Town Hall is a non-profit organization that is run by an all-volunteer board of directors. Our mission is to bring nationally and internationally renowned, thought-provoking speakers who inform, educate, and entertain our audience! As one or our members told us:

"Each year I give a ticket package to each of our family members. I think of it as the gift of knowledge...and that is priceless."

Speaker of the Month

Fossil Threads in the Web of Life

February 15, 2012
Scott Sampson

What's 75 million years old and brand spanking new? A teenage Utahceratops! Come to the Saroyan, armed with your best dinosaur roar, when Scott Sampson, Research Curator at the Utah Museum of Natural History, steps to the podium. Sampson's research has focused on the ecology and evolution of late Cretaceous dinosaurs and he has conducted fieldwork in a number of countries in Africa.

Read more. Or meet us there!

Our Ticket Packages

Season Package: $95

Patron Package: $200

Single Speaker: $25

© 2012, San Joaquin Valley Town Hall, Fresno, CA 93755

and then remove those CSS rules in section:
clear: left;
clear: both;


Django Query with and without comma

Question: I have a .csv file with only one column (name) and multiple rows containing strings formatted like:

"name, surname"
"name surname"

I loop through this file and check if they exist in my database
the only problem is that in my database, everything is formatted like:

"name, surname"

so the query without a comma could not be found unless I do something like this:
Model.objects.filter(name__search=row["name"])

But this takes a very long time to load..
is there any other way?
Comment: Have you tried Replace function on annotated field? You could replace ' ' with ', ' and then query on that annotated field but I don't know if it would be any faster
Answer: Have you tried with contains? See https://docs.djangoproject.com/en/4.0/ref/models/querysets/#contains-1
It may be faster if you do:
Model.objects.filter(name__contains=row["name"])

You can also try to use icontains if you want to search for case-insensitive text. See https://docs.djangoproject.com/en/4.0/ref/models/querysets/#icontains
If none of this alternatives work for you, another option would be to update the save method in your Model so you can save the data in the format you like and get consistent results there.

Django Query with and without comma


multiple submit button

Question: I have two submit buttons in two field .
My problem is that if I press ENTER from the field 2 of textfield , Submit 1  gets triggered instead of trigger submit 2.
but submit handler works perfectly for both submit button when it is clicked.
Comment: check this http://stackoverflow.com/questions/4501890/handle-multiple-submit-buttons-in-drupal-form-api
Comment: i tried that too,but not getting.
Answer: This is native browser functionality, you are going to need to use JavaScript to circumvent and add your own behavior

multiple submit button


Gráfico multindex pandas

Question: Olá,
Tenho o seguinte dataframe:
Onde tenho um período de 3 anos.

Eu gostaria de estar plotando um gráfico do VALOR agupado por mês e ano, eu fiz da seguinte forma, mas não deu certo.
df.groupby(['MES','ANO','VALOR']).sum().plot()

onde estou errando?
Obrigado!
Answer: Qual o resultado que você deseja? A ordem de agregação altera o resultado final:
df.groupby(['ANO','MES'])['VALOR'].sum().plot(kind='line')

Comment: ah sim, deu certo, obrigado. Agora cai em um outro problema, que seria na geração do gráfico.
queria plotar no eixo Y a coluna VALOR e no Eixo X as colunas [ano e mes] ordenadas, porém não ficou da forma que eu queria, eu teria que criar um novo tópico para ajuda?

Gráfico multindex pandas


When should I use the [:] to append the result?

Question: I have two code examples, both of which work the same:
class Solution(object):
    def permute(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        m = len(nums)
        ans = []
        def solve(lst, tmp):

            if len(tmp) == m:
                ans.append(tmp)

            for i in range(len(lst)):
                solve(lst[:i]+lst[i+1:], tmp + [lst[i]])

        solve(nums, [])

        return ans

and this one:
class Solution(object):
    def permute(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        ans = []
        l = len(nums)
        def solve(tmp, c):
            """ why should I use tmp[:] here? instead of tmp?"""
            if len(tmp) == l:
                ans.append(tmp[:])
            for i in c:
                if c[i] > 0:
                    tmp.append(i)
                    c[i] -= 1
                    solve(tmp, c)
                    c[i] += 1
                    tmp.pop()
        solve([], Counter(nums))

        return ans

For the line I highlight, if I change it from tmp[:] to tmp, then it will be a list of empty list?
I want to know when should I append a copy of list, and when should I just append the tmpo list?
Comment: copy to a new list so that changes to original list won't affect the new.
Comment: so for the first one why I dont need to do a copy?
Answer: When you do tmp.append(i), you're implicitly modifying the reference of that list that would be stored inside of ans. When you do a copy, that wouldn't happen
For the first answer, the addition is returning a new list, not appending directly to tmp
To get a similar behavior, you'd have to do
tmp += [lst[i]]
solve(lst[:i]+lst[i+1:], tmp)

Comment: can I say that addition is different from ```append()```? it will create a new list?
Comment: That's correct.


\_tfq_simulate_ops.so not found while import tensorflow_quantum

Question: Trying import of initial libraries related to tensorflow_quantum:
import tensorflow as tf
import tensorflow_quantum as tfq

import cirq
import sympy
import numpy as np

Getting error in 2nd line:

  File "Path_to_anaconda_site_packages\tensorflow_core\python\framework\load_library.py", line 61, in load_op_library
    lib_handle = py_tf.TF_LoadLibrary(library_filename)

NotFoundError: Path_To_Tensorflow_Quantum\core\ops\_tfq_simulate_ops.so not found

Comment: import tensorflow as tf
import tensorflow_quantum as tfq  #error in this line

import cirq
import sympy
import numpy as np
Comment: Is this your full code
Comment: Solution by TFQ team here: https://github.com/tensorflow/quantum/issues/180
Answer: This is the solution provided by the Tensorflow team, it worked for me.
!pip install tensorflow-gpu==2.1.0
!pip install cirq==0.7.0 pathos==0.2.5 tensorflow-quantum==0.2.0

Answer: Do following steps:
!pip uninstall tensorflow
!pip install tensorflow

then restart runtime to import the packages.It works.
Comment: Your answer seems to assume that the OP is using Jupyter. I see no indication that this is actually the case. Anyway, `pip --upgrade` would probably make more sense than uninstalling and reinstalling.
Answer: This might be something that would be worth raising as an issue on the TensorFlow Quantum Github here (https://github.com/tensorflow/quantum/issues). Without much information on the platform your are using or even what python version you have it might be hard to diagnose the problem here, but a quick fix you could try might be that you have an older version of TensorFlow installed. TensorFlow Quantum requires tf == 2.1.0.
pip install --upgrade pip
pip install --upgrade tensorflow

If that doesn't do it, then it might be worth opening an issue on github and giving a few more details on there :)


How do you create multiple box-shadow values in LESS CSS

Question:
Read This
There are several "correct" answers. Since this question gets a lot of traffic, I figured I should keep up with what (I think) the best answer is (based on the LESS documentation) as the LESS project matures, and change my accepted answer accordingly.

I'm using LESS and I haven't been able to find a fix for allowing multiple CSS3 box-shadows.  I have the following mixin:
.box-shadow(@arguments) {
    -webkit-box-shadow: @arguments;
    -moz-box-shadow: @arguments;
    box-shadow: @arguments;
}

and I'm attempting this:
.box-shadow(
    inset 0 0 50px rgba(0,0,0,0.3),
    0 0 10px rgba(0,0,0,0.5);
);

This works in normal CSS3, but fails when running from a LESS file.  I've read somewhere that the comma separating the 2 shadows is what causes the issue in the LESS parser.
Does anyone know how to make this work?  The only workaround I can think of is creating an additional CSS file that contains my multiple box-shadow properties.
Comment: right now your solution `.box-shadow(
    inset 0 0 50px rgba(0,0,0,0.3),
    0 0 10px rgba(0,0,0,0.5);
);` works as desired (tested with less2css.org).
Comment: see my answer for full explanation.
Comment: My older answer was updated as well to further help avoid confusion
Comment: [This](http://stackoverflow.com/questions/11013528/using-undefined-number-of-arguments-in-less-mixins/26155408#26155408) answer has another method (Option 3) to do this with the latest Less features and offers a bit more flexibility. If you wish to, I will customize that answer for box-shadows and post here.
Answer: This works with newer LESS versions:
.box-shadow(2px 2px 3px rgba(0,0,0,.4), 0px 0px 5px rgba(0,0,0,.8););
                                  // this semicolon is important! ^

And this uglier version works even with older LESS versions:
.box-shadow(~"2px 2px 3px rgba(0,0,0,.4), 0px 0px 5px rgba(0,0,0,.8)");

Update:
LESS evolved, so this answer was updated and is now correct again. Thanks Michał Rybak
Comment: This is more flexible yes, but still requires alot of messing around with RGBA values, when it can be done so much easier with the proper use of mixins. I still agree that this is the right answer for the time being.
Comment: But how do I add a darken function for example instead of the rgba color?
Comment: for even more recent version, check my answer.
Answer: It should work just fine. I've used it before. Try with this mixin:
.box-shadow (@shadow1, @shadow2: transparent 0 0 0 ) {
    -moz-box-shadow: @shadow1, @shadow2;
    -webkit-box-shadow: @shadow1, @shadow2;
    box-shadow: @shadow1, @shadow2;
}

And then:
.box-shadow(inset 0 0 50px rgba(0,0,0,0.3), 0 0 10px rgba(0,0,0,0.5));

Comment: This is only two... The fun part is adding a limitless amount of box-shadows. Ultimately this is not all that helpful.
Comment: I was using something similar, but only passing in one argument (the overall box-shadow values).  Since the argument had a comma, I guess it assumed that I was passing in 2 arguments.  Didn't think about that.  Thanks.
Answer: LESS strips the comma. So the @arguments value becomes:
inset 0 0 50px rgba(0,0,0,0.3) 0 0 10px rgba(0,0,0,0.5);

Which is invalid as a box-shadow.
Instead, do this when you want a comma:
@temp: inset 0 0 50px rgba(0,0,0,0.3), 0 0 10px rgba(0,0,0,0.5);

.box-shadow(@temp);

Answer: The best solution is to make separate overloads for each number of shadows. Less handles the proper overload resolution:
.box-shadow(@shadow1) {
    -webkit-box-shadow: @shadow1;
    -moz-box-shadow: @shadow1;
    box-shadow: @shadow1;
}

.box-shadow(@shadow1, @shadow2) {
    -webkit-box-shadow: @shadow1, @shadow2;
    -moz-box-shadow: @shadow1, @shadow2;
    box-shadow: @shadow1, @shadow2;
}

.box-shadow(@shadow1, @shadow2, @shadow3) {
    -webkit-box-shadow: @shadow1, @shadow2, @shadow3;
    -moz-box-shadow: @shadow1, @shadow2, @shadow3;
    box-shadow: @shadow1, @shadow2, @shadow3;
}

.box-shadow(@shadow1, @shadow2, @shadow3, @shadow4) {
    -webkit-box-shadow: @shadow1, @shadow2, @shadow3, @shadow4;
    -moz-box-shadow: @shadow1, @shadow2, @shadow3, @shadow4;
    box-shadow: @shadow1, @shadow2, @shadow3, @shadow4;
}

.box-shadow(@shadow1, @shadow2, @shadow3, @shadow4, @shadow5) {
    -webkit-box-shadow: @shadow1, @shadow2, @shadow3, @shadow4, @shadow5;
    -moz-box-shadow: @shadow1, @shadow2, @shadow3, @shadow4, @shadow5;
    box-shadow: @shadow1, @shadow2, @shadow3, @shadow4, @shadow5;
}

EDIT:
Ok, I'm still learning about LESS, but it appears that will actually mixin ALL of the overloads in certain situations, instead of the one with the most applicable parameter list, so you may get varying results. I've since revised my mixins so that they're named box-shadow-2 or box-shadow-3, to match the expected number of parameters. I'll revise my answer once I figure out what's going on / have a better solution.
Comment: I have tested the functionality and it works great...  http://codepen.io/mikemclin/pen/cHtfu
Comment: yes but this is unnecessary, and an incorrect way compared to the solution ".box-shadow(~"inset 0 0 50px rgba(0,0,0,0.3), 0 0 10px rgba(0,0,0,0.5)");"  from a programming perspective for so many reasons.
Comment: @Neo -- Not necessarily. Dropping long regions of code inside strings kills basically all services provided by your IDE/editor, which IMO is far worse than any downside. Any duplicated code will be removed by an intelligent CSS minifier anyways.
Comment: @neo - Unless I'm mistaken, your suggestion couldn't perform a task like this in one step... `.box-shadow(0 0 10px darken(@red, 20%), 0 0 10px lighten(@green, 20%))`.  But the answer I selected can. Please advise if I'm overlooking something.
Answer: .box-shadow (@shadow1) {
    -webkit-box-shadow: @shadow1;
    -moz-box-shadow: @shadow1;
    -ms-box-shadow: @shadow1;
    -o-box-shadow: @shadow1;
    box-shadow: @shadow1;
}
.box-shadow (@shadow1, @shadow2) {
    @temp: @shadow1, @shadow2;
    .box-shadow(@temp);
}
.box-shadow (@shadow1, @shadow2, @shadow3) {
    @temp: @shadow1, @shadow2, @shadow3;
    .box-shadow(@temp);
}

Comment: Not sure this was the answer for this question, but it was the answer for MY question!! :-)
Answer: This question is kind of out-of-date, as for now your solution actually works.

However, I'll try to explain why, because many people seem to be unaware of that:
Actually passing a list of comma-separated arguments to a mixin is pretty simple: just use semicolon (;) instead of comma in mixin call.
From LESS documentation:

Parameters are either semicolon or comma separated. It is recommended to use semicolon. The symbol comma has double meaning: it can be interpreted either as a mixin parameters separator or as css list separator. Using comma as mixin separator makes it impossible to use comma separated list as an argument.
Semicolon does not have such limitation. If the compiler sees at least one semicolon inside mixin call or declaration, it assumes that arguments are separated by semicolons. All commas then belong to css lists.

Mixin definition uses well-known, regular syntax:
.box-shadow(@params) {
  -webkit-box-shadow: @params;
  -moz-box-shadow: @params;
  box-shadow: @params;
}

But mixin call should use semicolons to separate arguments. If semicolons are used, commas are no longer treated as separators and are passed to mixin without problems:
.box-shadow(
  inset 0 0 50px rgba(0,0,0,0.3), 0 0 10px rgba(0,0,0,0.5);
);

Note that if (as in the case above) only one list is passed, you have to use semicolon at the end, too.
Check out my answer regarding multiple backgrounds to see how mixin call should look with multiple parameters, some of which are comma-separated lists.
Answer: Here is another solution(which I prefer more):
Use e() string function. Ex: e("S1, S2") will return S1, S2 without quotes.
Long example:
Definition:
.c3_box-shadow(@val){
    -webkit-box-shadow: @val;
       -moz-box-shadow: @val;
            box-shadow: @val;
}

Usage:
.box-shadow( e("inset 0 1px 0 rgba(255,255,255,.4), inset 0 -1px 0 rgba(255,255,255,.2)") );

Output:
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.4), inset 0 -1px 0 rgba(255,255,255,.2);
-moz-box-shadow: inset 0 1px 0 rgba(255,255,255,.4), inset 0 -1px 0 rgba(255,255,255,.2);
box-shadow: inset 0 1px 0 rgba(255,255,255,.4), inset 0 -1px 0 rgba(255,255,255,.2);

Reference: http://lesscss.org/functions/#string-functions-e
Comment: Nope, this is not the recommended solution for the up-to-date Less. The recommended way is given in the question itself and in @Michał Rybak answer.
Comment: @seven-phases-max, it just doesn't work for me if I use the semicolon. I have no idea why.
Comment: "just doesn't work for me" is barely an excuse to recommend the outdated hack as a "simple and powerful solution". AFAIK the "semicolon" way works even in ancient Less versions like 1.3.3 as well as in outdated ports like lessphp or dotless. There's nothing wrong in `~""` itself but it should not be used as a "no brainer".
Comment: OK, my bad. I've updated my answer and added a reference to the function used in example.
Comment: Well, `e()` is just an alias for `~""` so nothing really changed. After all this ~"" method is already in @storypixel answer given 2 years ago so...
Comment: This was working for me and I thought it will be nice to share with others. I've googled for a solution like this and I was about to use the accepted answer from this thread, but I don't really need all this code. I just need a function to replace 3 lines -prefix- w/h one, nothing else. So this is how I do it and to allow LESS process it I've used ~ sign, now I've updated it with the recomended function from LESS docs. I've edited my post and said that this is my preference and probably other will apreciate my answer. That's all, end of story. P.S. I haven't seen @storypixel's answer, sorry.
Comment: "I've googled for a solution like this and I was about to use the accepted answer from this thread" - yet again, please read the question itself and @Michał Rybak answer. The solution is *the same 3 lines* of code.


DSoma utilizando o formulário como fonte

Question: Halp!
Eu preciso que um campo texto no meu formulário mostre a soma de um determinado campo, onde o formulário é a fonte utilizando um critério.
Eu consigo que o DSoma execute com o código abaixo. No entanto, como a fonte é a tabela, o resultado não atualiza conforme eu vou filtrando meu formulário.
<code>=DSoma([valor_total];[t_registros];[t_cat_entradas_saidas_ID]=1)
</code>
Não consegui descobrir uma forma de referenciar o formulário no campo 2 do DSoma.
É Possível?
Existe alguma forma de contornar via VBA? De repente dentro do procedimento de filtragem do formulário?

Seção de seleção e filtro

Campo texto Receitas
Comment: Eu pensei em utilizar o procedimento que filtra o formulário para inserir o DSoma no campo texto com os critérios do filtro. No entanto não sei como inserir o DSoma na fonte de controle do campo texto via VBA.
Answer: Consegui descobrir como resolver o problema.
Alimentei meu campo texto via VBA mesmo.
<code>Dim txtReceitas AS Currency
Dim txtDespesas AS Currency

txtReceitas = Nz(DSum("[valor_total]", "t_registros", strWhere & "AND [t_cat_entradas_saidas_ID] = 1"), 0)
Me.txt_Receitas = txtReceitas

txtDespesas = Nz(DSum("[valor_total]", "t_registros", strWhere & "AND [t_cat_entradas_saidas_ID] = 2"), 0)
Me.txt_Despesas = txtDespesas
</code>
Super simples, mas como conheço pouco de VBA me bati pra achar a resposta.


Is it possible HandlerAttribute intercept when i implement a interface that use it?

Question: Let's me show first the scenario that is working:
I have a HandlerAttribute that is working with AOP using InterfaceInterceptor that i register like this way:
public void RegisterType<TInterface, TClass>()
        where TClass : TInterface
{
    // My UnityContainer
    this.container.RegisterType<TInterface, TClass>(new ContainerControlledLifetimeManager())
        .Configure<Interception>()
        .SetDefaultInterceptorFor<TInterface>(new InterfaceInterceptor());
}

The interface that has the HandlerAttribute:
public interface IService<TId, TEntity>
    where TId : IEquatable<TId>
    where TEntity: AbstractEntity<TId> // Class that has a Id
{
    [DatabaseTransaction] // The HandlerAttribute
    void Update(TEntity entity);
}

So, i create the MyService that implements IService, and i register using the method RegisterType. So, after that i call the Resolve method from myContainer passing the IService, and i use the service with my method Update intercepted by my DatabaseTransactionAttribute:
public class MyService : IService<int, MyEntity>
{
}

After:
RegisterType<IService, MyService>()

All ok until i create the interface IMyService, that implements IService, and MyService implementing IMyService. I do the same step to register and resolve the IMyService interface mentioned above...
public class IMyService : IService<int, MyEntity>
{
}

public class MyService : IMyService
{
}

After:
RegisterType<IMyService, MyService>()

the problem is, when i call the Update method in the second case, my DatabaseTransactionAttribute doesn't intercept the method anymore, anyone knows why?

I found this question that is in some way, related: Can a C# class inherit attributes from its interface?
So, i have to re-declare in the interface that implements the interface that has the attribute? Oo
The interceptor only works if the attribute is in the interface that is registered in the unity container?
Answer: AFAIK:

The interceptor only works if the attribute is in the interface that
  is registered in the unity container?

Yes

So, i have to re-declare the attribute in the interface that implementsextends the
  interface that has the attribute?

Yes


How to make Cognito User Pool Email attribute mutable without destroying the pool?

Question: After reading the docs and playing around with aws cli I was unable to find a way of updating mutability of email.
Does anyone has something handy to make it work?
Answer: From the user pool settings documentation:

An administrator with proper AWS account permissions can change the user's email and also mark it as verified.

Just to double check, it is email and not username, right?

The preferred_username attribute provides users the experience of changing their username, when in fact the actual username value for a user is not changeable.
Comment: Unfortunately CDK doesn't allow to modify mutability on the email after pool has been created. This is limitation imposed by AWS design.


Independence between innovations and variance in an ARCH model

Question: Let $\epsilon_n$ denote a real-valued discrete-time stochastic process of residuals, the ARCH($p$) specification is given by
\begin{equation} \label{1.1}
\epsilon_n=Z_n\sqrt{\sigma_n}
\end{equation}
\begin{equation}\label{1.2}
\sigma_n=\alpha_0+\sum \limits_{i=1}^p\alpha_i\epsilon_{n-i}^2\,,
\end{equation}
where $\alpha_0, \alpha_1, \dots,\alpha_p$ are scalar parameters to be estimated, $\mu_n$ is the fitted model. $Z_n$, are a sequence of independent, identically distributed random variables with mean zero and variance one.
Now, can we say that $E(Z_n^2\sigma_n)=E(\sigma_n)$, since $E(Z_n^2)=1$?
Comment: No problem. Do you have answer regarding this one?
Comment: @Anna Please check if the answer below is satisfying for you.
Answer: Yes, you can say that, but you perhaps need to be a bit clear as to why that result holds. In other words, $\mathbb{E}[Z_n^2 \sigma_n] = 1\cdot\mathbb{E}[\sigma_n] $ because $\sigma_n$ is actually a function of the previous values of the process, i.e. $\sigma_n = \sigma_n(\epsilon_{n-1},\ldots,\epsilon_{n-p}) $, and $Z_n$ is by definition assumed to be independent of the previous values of the process, i.e. independent of $\epsilon_{n-1},\epsilon_{n-2},$ etc.
Comment: Finally. +1 now :)
Comment: The first equality (the "middle step") does not mean independence, it only means zero covariance.
Comment: You are absolutely right. My transgression was due to the fact that in Econometrics courses (where a question such as this one would usually pop up), there is a common, even if simply practical, motive where no covariance and independence are conflated. However, the set of dependent variables with zero covariance is, of course, non-empty :)
Comment: Great. I am a little confused by your formulation, though. I guess you wanted to say that even though the first equation happens to hold it cannot be used in a proof, and so you propose an alternative proof. Do I get you right?
Comment: And you were completely correct in being confused, because my claim was in itself wrong (I have thus completely changed the answer). $Z_n$ *is* indeed independent from $\sigma_n$, and by design at that, since it's assumed in the model specifications that $Z_n$ is independent to the $\sigma$-algebra $\mathcal{F}_{n-1}$ generated by the process up to time $n-1$. Thank you for noticing my mistake.
Comment: OK, so now you say that $Z_n$ is independent of previous values of $\epsilon$, but what about $Z_n$ vs. $\sigma_n$? The latter is what actually matters. You might have gotten the answer right, but I still think the formulation could be improved.
Comment: Agreed. I hope the current answer addresses your last point.
Comment: @Anna then please accept the answer :)


Proving a mod b < a/2 when a > b > 0

Question: Suppose that $a \gt b \gt 0$.  How can one prove that $a$ mod $b \lt a/2$?
I understand why is that happening: if $a$ mod $b \gt a/2$ that means that $a/b \lt a/2$ and $a/b$ has enough "space" to get inside the $a$ mod $b$ one more time, since $a$ mod $b \gt a/2$.  This is a contradiction to the division result.
What is the formal proof for that? I couldn't find it anywhere.
Comment: I think you're missing a condition.  For instance $(2 \mod 3) = 2$ and this is not less than $\frac22$.
Comment: sorry , assuming that a>b
Comment: I'd consider three cases: $b<\frac{a}{2}$; $b>\frac{a}{2}$ and $b=\frac{a}{2}$.
Comment: I still have no direction where even start proving it..
Comment: You should begin with defining $a$ mod $b$ if you want a rigorous proof.  You seem to mean the remainder left when $a$ is divided by $b$ (both positive integers).  I've added the assumption that $a \gt b$ to your Question, per your Comment.
Answer: Let $a=bk+r$ with ($a$ mod $b$)$=r$.
We have to prove $r \lt a/2$ or we can change it to:
$$a-bk \lt a/2 \iff bk \gt a/2 \iff bk \gt  (bk+r)/2 \iff bk>r \quad \text{ (1) } $$
Because $r \lt b$, so (1) is correct. (QED)
Answer: Hint: Use the facts that $(a \mod b)<b$ and that $(a\mod b)\le a-b$ (this second inequality holds in the case that $a\ge b$).
Comment: yes, I can see. I'll just sum the 2 equation and divide by 2. but how 2 get to these 2 equations?
Comment: ok I can see everything now . thank you very much!
Answer: Let $a>b>0$ and write $a\bmod b=r$. This means $0\le r<b$ and $a=bq+r$ for some $q>0$. Suppose $r>a/2$; then you have
$$
a<2r<2b
$$
that can be written
$$
a<2a-2bq<2b
$$
because $r=a-bq$.
This in turn gives
$$
\begin{cases}
a>2bq\\
a<b(q+1)
\end{cases}
$$
What condition on $q$ can you derive?

Proving a mod b < a/2 when a > b > 0