undefined method `validate_presence_of' for RSpec::ExampleGroups::User::Validations

Question: I am trying to pass my Model Specs for validation but i am not able to get them to pass. I have placed all the validation rules in my Model file as well
app/model/user.rb
class User < ActiveRecord::Base
  has_many :friendships
  has_many :friends, :through => :friendships
  has_many :plans
  has_many :memberships, class_name: "PlanMemebership"
  has_many :notes
  has_many :replies, class_name: "NoteReply"
  has_many :upvotes, class_name: "NoteUpvote"

  validates :first_name, presence: true
  validates :last_name, presence: true
  validates :email, presence: true
  validates :facebook_user_id, presence: true, uniqueness: true
  validates :facebook_user_token, presence: true, uniqueness: true
  validates :token, presence: true, uniqueness: true
  validates :birthday, presence: true
  validates :gender, presence: true

  def name
    first_name + " " + last_name
  end

end

specs/models/user_spec.rb
require 'rails_helper'

describe User, :type => :model do

  context "valid Factory" do
    it "has a valid factory" do
      expect(FactoryGirl.build(:user)).to be_valid
    end
  end

  context "validations" do
    it { should validate_presence_of :first_name }
    it { should validate_presence_of :last_name }
    it { should validate_presence_of :email }
    it { should validate_presence_of :birthday }
    it { should validate_presence_of :gender }
    it { should validate_presence_of :facebook_user_id }
    it { should validate_presence_of :facebook_user_token }

    context "uniqueness" do
      before { create(:user) }
      it { should validate_uniqueness_of :facebook_user_id }
      it { should validate_uniqueness_of :facebook_user_token }
      it { should validate_uniqueness_of :token }
    end
  end
end

spec/factories/users.rb
FactoryGirl.define do
  sequence(:facebook_id) { |n| "#{n}1004453333331" }
  sequence(:facebook_user_token) { |n| "#{n}CAA" + ("X" * 216) }

  factory :user do
    first_name "Ralph"
    last_name "Robot"
    email "email@example.com"
    facebook_user_id { generate(:facebook_id) }
    facebook_user_token

    birthday { Date.current }
    gender "Male"

    token { Token.new.generate }
  end

end

Test Output
Token
  #generate
    returns a 20-byte token

User
  valid Factory
    has a valid factory
  validations
    example at ./spec/models/user_spec.rb:13 (FAILED - 1)
    example at ./spec/models/user_spec.rb:14 (FAILED - 2)
    example at ./spec/models/user_spec.rb:15 (FAILED - 3)
    example at ./spec/models/user_spec.rb:16 (FAILED - 4)
    example at ./spec/models/user_spec.rb:17 (FAILED - 5)
    example at ./spec/models/user_spec.rb:18 (FAILED - 6)
    example at ./spec/models/user_spec.rb:19 (FAILED - 7)
    uniqueness
      example at ./spec/models/user_spec.rb:23 (FAILED - 8)
      example at ./spec/models/user_spec.rb:24 (FAILED - 9)
      example at ./spec/models/user_spec.rb:25 (FAILED - 10)

Failures:

  1) User validations
     Failure/Error: it { should validate_presence_of :first_name }
     NoMethodError:
       undefined method `validate_presence_of' for #<RSpec::ExampleGroups::User::Validations:0x007fc255f7fb88>
     # ./spec/models/user_spec.rb:13:in `block (3 levels) in <top (required)>'

  2) User validations
     Failure/Error: it { should validate_presence_of :last_name }
     NoMethodError:
       undefined method `validate_presence_of' for #<RSpec::ExampleGroups::User::Validations:0x007fc255e9fad8>
     # ./spec/models/user_spec.rb:14:in `block (3 levels) in <top (required)>'

  3) User validations
     Failure/Error: it { should validate_presence_of :email }
     NoMethodError:
       undefined method `validate_presence_of' for #<RSpec::ExampleGroups::User::Validations:0x007fc255ded568>
     # ./spec/models/user_spec.rb:15:in `block (3 levels) in <top (required)>'

  4) User validations
     Failure/Error: it { should validate_presence_of :birthday }
     NoMethodError:
       undefined method `validate_presence_of' for #<RSpec::ExampleGroups::User::Validations:0x007fc255d65398>
     # ./spec/models/user_spec.rb:16:in `block (3 levels) in <top (required)>'

  5) User validations
     Failure/Error: it { should validate_presence_of :gender }
     NoMethodError:
       undefined method `validate_presence_of' for #<RSpec::ExampleGroups::User::Validations:0x007fc255cb7888>
     # ./spec/models/user_spec.rb:17:in `block (3 levels) in <top (required)>'

  6) User validations
     Failure/Error: it { should validate_presence_of :facebook_user_id }
     NoMethodError:
       undefined method `validate_presence_of' for #<RSpec::ExampleGroups::User::Validations:0x007fc255c356f8>
     # ./spec/models/user_spec.rb:18:in `block (3 levels) in <top (required)>'

  7) User validations
     Failure/Error: it { should validate_presence_of :facebook_user_token }
     NoMethodError:
       undefined method `validate_presence_of' for #<RSpec::ExampleGroups::User::Validations:0x007fc255b86a40>
     # ./spec/models/user_spec.rb:19:in `block (3 levels) in <top (required)>'

  8) User validations uniqueness
     Failure/Error: before { create(:user) }
     ActiveRecord::RecordNotUnique:
       PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_users_on_email"
       DETAIL:  Key (email)=(firstname.lastname@example.com) already exists.
       : INSERT INTO "users" ("first_name", "last_name", "email", "facebook_user_id", "facebook_user_token", "birthday", "gender", "token", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING "id"
     # ./spec/models/user_spec.rb:22:in `block (4 levels) in <top (required)>'

  9) User validations uniqueness
     Failure/Error: before { create(:user) }
     ActiveRecord::RecordNotUnique:
       PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_users_on_email"
       DETAIL:  Key (email)=(firstname.lastname@example.com) already exists.
       : INSERT INTO "users" ("first_name", "last_name", "email", "facebook_user_id", "facebook_user_token", "birthday", "gender", "token", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING "id"
     # ./spec/models/user_spec.rb:22:in `block (4 levels) in <top (required)>'

  10) User validations uniqueness
     Failure/Error: before { create(:user) }
     ActiveRecord::RecordNotUnique:
       PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_users_on_email"
       DETAIL:  Key (email)=(firstname.lastname@example.com) already exists.
       : INSERT INTO "users" ("first_name", "last_name", "email", "facebook_user_id", "facebook_user_token", "birthday", "gender", "token", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING "id"
     # ./spec/models/user_spec.rb:22:in `block (4 levels) in <top (required)>'

Finished in 0.13486 seconds (files took 3.99 seconds to load)
12 examples, 10 failures

Failed examples:

rspec ./spec/models/user_spec.rb:13 # User validations
rspec ./spec/models/user_spec.rb:14 # User validations
rspec ./spec/models/user_spec.rb:15 # User validations
rspec ./spec/models/user_spec.rb:16 # User validations
rspec ./spec/models/user_spec.rb:17 # User validations
rspec ./spec/models/user_spec.rb:18 # User validations
rspec ./spec/models/user_spec.rb:19 # User validations
rspec ./spec/models/user_spec.rb:23 # User validations uniqueness
rspec ./spec/models/user_spec.rb:24 # User validations uniqueness
rspec ./spec/models/user_spec.rb:25 # User validations uniqueness

Comment: @Rubyrider sorry. forgot to add the main thing :D
Comment: can you share your test output/logs?
Comment: No problem. Logs are import to find the problem actually.
Comment: please checkout the solution I just wrote.
Answer: Add rspec-rails and shoulda-matchers in your Gemfile:
group :development, :test do
  gem 'rspec-rails', '~> 3.4', '>= 3.4.2'
  gem 'shoulda-matchers', '~> 3.1', '>= 3.1.1'
end

Set your spec/rails_helper.rb to use rspec-rails and shoulda-matchers:
require 'rspec/rails'
require 'shoulda/matchers'

And add in your spec/spec_helper.rb:
Shoulda::Matchers.configure do |config|
  config.integrate do |with|
    with.test_framework :rspec
    with.library :rails
  end
end

Answer: I think you need to add the following to your spec_helper.rb
require 'shoulda/matchers'

Your specs are missing shoulda matcher's methods.
Here is the source. You can check. People complains similar things.
https://github.com/thoughtbot/shoulda-matchers/issues/384
Comment: it had to be the order of it :(
Answer:
Add shoulda-matchers into Gemfile:
group :test do
  gem 'shoulda-matchers', '~> 5.0'
end

Then run bundle install.

Place this at the bottom of spec/rails_helper.rb:
Shoulda::Matchers.configure do |config|
  config.integrate do |with|
    with.test_framework :rspec
    with.library :rails
  end
end

Thats all.
Documentation
Comment: these 3 steps helped me.. Thank you so much.
Answer: Add gem in your gem file :
group :test do
   gem 'shoulda-matchers', require: false
end

/spec/spec_helper.rb
RSpec.configure do |config|
  require 'shoulda/matchers' #add this line in it.
  .....
  ...
end

/spec/rails_helper.rb
#add this code
    Shoulda::Matchers.configure do |config|
      config.integrate do |with|
        with.test_framework :rspec
        with.library :rails
      end
    end


How to get value from modified object in Node.js

Question: how to get modified value of object? index.js is called before index2.js
object.js

var object = {
  size:'5'
};

var setSize = function(size) {
  object.size = size;
}

exports.object = object;
exports.setSize = setSize;

index.js

var obj = require('path/object');

obj.setSize('10');
console.log(obj.object.size); //--> 10

index2.js
I want the result to be 10.

var obj = require('path/object');
console.log(obj.object.size); //--> 5
Comment: require `index.js` for side effects only and it will execute the code in `index.js`.
Comment: thanks! :))) got exactly how I wanted.
Answer: If you run node index.js separately from node index2.js, there is no way for index2.js to "know" what happened in the last process of index.js. You have to apply all your actions in a single process run. As @Andrew Li stated in his comment, you would have to require index.js in your index2.js. Simply requiring it, will have it's code executed and the changes to obj.object will be saved in Nodes module caching mechanism.
var obj = require('path/object');
require('./index');
// code inside index.js gets executed, changing obj.size to '10'
// note that this will also log '10' in the console, since a console.log(obj.size)
// is part of your code in index.js

console.log(obj.object.size) //--> 10

If you need to have index.js and index2.js executed in different processes but still be able to access a coherent value of obj, you need to store that value somewhere outside of the process space, like in a database or in the filesystem.


Upgrading to Ruby 2.0.0 resulted in "Rails is not currently installed on this system"

Question: I recently upgraded from Ruby 1.9.3 to version 2.0.0. To do so, I used the following command:
$ rvm install ruby-2.0.0
$ rvm --default use ruby-2.0.0

It successfully installed and set as default ruby-2.0.0; however, when I enter ruby -v I encounter the error:
Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

I know Rails is installed and, before upgrading my version of Ruby, I ran rails -v which returned my current version.
Attempts to Troubleshoot
I followed the solution found on an earlier post and ran the following commands:
gemsets for ruby-1.9.3-p374 (found in /Users/.../.rvm/gems/ruby-1.9.3-p374)
   (default)
=> global
   rails3tutorial2ndEd

/etc/rvmrc: line 5: install:: command not found
/etc/rvmrc: line 6: update:: command not found

gemsets for ruby-2.0.0-rc1 (found in /Users/.../.rvm/gems/ruby-2.0.0-rc1)
   (default)
=> global

rvm use ruby-2.0.0-rc1@global

However, running rails -v again shows that the issue still persists.
Any help would be greatly appreciated!
Update:
Impatience led me to just re-install Rails which fixed the problem. However, I'm still curious if there was a better way of troubleshooting this without (likely unnecessarily) re-installing Rails.
Answer: Gemsets in RVM are isolated in that they are only available to a single version of Ruby.  As such, you need to re-install the Rails gem after installing a new version of Ruby.
When a version of Ruby is installed via RVM, 2 associated gemsets will be created simultaneously.  One is called "global" and one is called "default".
Ruby versions (and their single associated global gemset) are made active via the rvm use ruby_version_here command.
The default or (potentially multiple) user generated gemsets are made active via the rvm use gemset_name_here command.
Whether a gemset is a global, default, or user generated - it is only available to a single version of Ruby.
Here's a nice blog post covering the topic in a bit more detail.


what's a good technique for building and running many similar unit tests?

Question: I have a test setup where I have many very similar unit tests that I need to run. For example, there are about 40 stored procedures that need to be checked for existence in the target environment. However I'd like all the tests to be grouped by their business unit. So there'd be 40 instances of a very similar TestMethod in 40 separate classes. Kinda lame. One other thing: each group of tests need to be in their own solution. So Business Unit A will have a solution called Tests.BusinessUnitA.
I'm thinking that I can set this all up by passing a configuration object (with the name of the stored proc to check, among other things) to a TestRunner class.
The problem is that I'm losing the atomicity of my unit tests. I wouldn't be able to run just one of the tests, I'd have to run all the tests in the TestRunner class.
This is what the code looks like at this time. Sure, it's nice and compact, but if Test 8 fails, I have no way of running just Test 8.
<code>  TestRunner runner = new TestRunner(config, this.TestContext);

  var runnerType = typeof(TestRunner);
  var methods = runnerType.GetMethods()
     .Where(x =>
       x.GetCustomAttributes(typeof(TestMethodAttribute), false)
       .Count() > 0).ToArray();

      foreach (var method in methods)
      {
       method.Invoke(runner, null);
      }
</code>
So I'm looking for suggestions for making a group of unit tests that take in a configuration object but won't require me to generate many many TestMethods. This looks like it might require code-generation, but I'd like to solve it without that.
Answer: Can you use Data Driven Tests?
http://msdn.microsoft.com/en-us/library/ms182519(VS.80).aspx
You can then exclude rows that previously passed...
Comment: I dunno, looks different than what I'm doing. I need to run the same test (essentially) but share it among many projects. So Data driven tests are similar except for the project-crossing thing that I'm doing.
Comment: Data driven tests would be the way to go.  They're a bit clunky in MSTest but they should still be able to do the job.

The data to pass in to the test will be the name of the sproc you are checking the existence of.  And obviously you'll need multiple data driven tests if you're going to be splitting them across multiple test assemblies - I'd look to making one common method that each test assemblie makes calls to to keep the code DRY.
Answer: My solution to this was to put all the tests in their own assembly, decorate them with attributes then reflect through the assembly to execute the tests. Made more sense than data driven tests.


What are 2-cells (and their horizontal compositions) in the bicategory of spans?

Question: According to this blog and this blog, a 2-cell in Span(C), i.e. a morphism between spans, is a morphism between the two apices such that the 2 triangles commute. Also, horizontal composition of spans is a pullback but what about horizontal composition of 2-cells? its not defined and i can't think of a way to naturally define some morphsim between two pullbacks. I also couldnt find a definition in MacLane's 'Categories for the working mathematician' or nlab. I found a definition here - but their definition of 2-cells seems completely different than in the blogs?
Answer: Suppose given four spans and some morphisms between them:
$$\require{AMScd}\begin{CD}
A@<<<B@>>>C@<<<D@>>>E\\
@VV{\mathrm{id}}V@VVV @VV{\mathrm{id}}V @VVV @VV{\mathrm{id}}V\\
A@<<<B'@>>>C@<<<D'@>>>E
\end{CD}$$
We must define a map $B\times_C D\to B'\times_C D'$ satisyfing some conditions. But the universal property of the pushout guarantees that the diagram
$$\require{AMScd}\begin{CD}
B@>>>C@<<<D\\
@VVV @VV{\mathrm{id}}V @VVV\\
B'@>>>C@<<<D'
\end{CD}$$
induces exactly such a map $B\times_C D\to B'\times_C D'$, such that e.g. the diagram
$$\require{AMScd}\begin{CD}
B\times_C D@>>> B'\times_C D'\\
@VV{\mathrm{proj}}V @VV{\mathrm{proj}}V\\
B @>>> B'
\end{CD}$$
commutes (and similarly for $C$ and the pair $(D,D')$). This allows you to see that our map $B\times_C D\to B'\times_C D'$ indeed satisfies the necessary conditions to be a $2$-morphism between horizontal compositions of spans.
It's by the way true that there is not a single definition of a span category, so it is always good to look up how an author defines it.


Why does the typeof return undefined not string

Question: Why does the typeof return undefined not string
<code>myFunction();
function myFunction(){
var address = '12345, Abuja,Nigeria'
}
console.log('the address is' + typeof  address)
</code>
Answer: The variable address is not defined within the scope of where you are trying to use it. The variable only exists inside the "myFunction" function. If you move the console.log into the function block it should work as you expect.
Comment: @IkennaOguejiofor You're welcome! Please mark the answer as accepted if it solved your problem.


What are the Rudimental Rhythms?

Question: In practical music exams, as well as performing prepared pieces there's also a section on scales and arpeggios. In the lower brass grades for example you might have to prepare two or three major scales, a minor scale (choice of melodic/harmonic/natural) and arpeggios, and be able to play them tongued or slurred.
As you advance through the grades, you're eventually expected to be able to play all major and minor scales, diminished sevenths, dominant sevenths, and be able to play them faster than in the early grades.
So there's an acknowledged list of harmonic rudiments that musicians are expected to master as they progress through the grades.
My question is - is there a list of rhythmic rudiments that players of non-percussion instruments should be expected to master? For instance, most people are Ok playing triplets, i.e. three eighth-notes in the time of two eighth notes. But what about playing four eighth notes in the time of five? Or playing sevens against nines, or whatever.
What would be a good list of rhythmic rudiments to have mastered? Or does the fact that it doesn't appear in music exams mean it's not a useful skill to acquire?
Comment: This depends on the instrument. On a monophonic  instrument like brass, playing "triplets" should not be a big deal - after all, you are expected to be able to play in 6/8 time as well as in 4/4. On the hand, keyboard players often need to play three notes with one hand in the same time as two (or four) notes with the other hand, which is more like the skill that a drummer needs to demonstrate. (And advanced keyboard players need to be able to play "three notes against two" with all the notes in *one* hand, while the other hand is playing another different rhythm!)
Comment: Interesting. Maybe not deemed so important as a lot of music is in more standard timing, and the unusual ones are, well, unusual. With percussion, there's probably more need for these sort of questions in exams to fill the large space where little or no harmonic/melodic stuff could go. Have you checked out LCM., Trinity, ABRSM syllabi?
Comment: @Brian I could, as a percussionist, advise you to take a look the way G.L.Stone organized percussion exercises between his three books, especially paying attention to the third, "Mallet Control", in which his idea about gaining "stick control" is transfered to a melodic instrument, in particular, the xylophone.
Comment: Many thanks for the suggestion Agnes. Would you post an actual answer, giving some idea of the exercises as they increase in complexity? I tried looking for the book you suggested, but I cannot find any site that lets me preview page content.
Comment: There's also the most universal exercise, so banal, it might skip anybody's mind: play progressively: 1 nps (note-per-second), 2 nps, 3 nps, 4 nps, 5 nps, 6 nps, 7 nps, 8 nps, 9 nps - and back down. It's actually all about primes and antiprimes. 4=2x2, 6=2x3, 3x2, 8=2x4, 9=3x3 (Messiaen would disagree). After nine, things stabilise, e.g. 10=2x5, 11=messiaen, 12=2x6, 3x4, 13=messiaen, 14=2x7, 15=3x5 (this IS a tricky one though), 16=4x4, 17=messiaen, 18=2x9 (tricky), 19=messiaen, 20=2x10, 21=3x7, and you get the idea. Which is, you can always simplify. Unless it's the french. Then you're stuck.
Answer: I really wish there were better sources for this.
I made a few of my own for the lack of existing sources.
This may not be exactly what you want, but I took these two concepts as my point of departure:

metric level
rhythmic unit

Both are explained at Wikipedia's Rhythm page.
Metric level

Rhythmic unit

My attempt to combine these two was...

...my intent is to use these for playing on the piano. Of course, it just my own creation. I don't claim these are The rudiments.
Answer: I am a student of the banjo.  My instructor taught me a series of lessons from Ted Reed's famous "Syncopation - Progressive Steps to Syncopation for the Modern Drummer".
Although the lessons are intended for drum, they work fine for a melodic instrument.  The idea is to play a scale using the rhythm in the lesson.  Or, if the rhythm is vexing, even play just a single note until the rhythm is mastered, and then go back to playing scales.
The first half of the book is all non-syncopated rhythms starting with the very simplest rhythms and increasing in complexity; the second half of the book introduces syncopated rhythms which increase in complexity with each lesson.
Each lesson is in two parts.  The first part is repetitive, with each line repeating the same rhythm, for skill building.  The second part is not repetitive; it mixes up the rhythms introduced in the first part.  This is for practicing sight reading of rhythm.
Standard musical notation is used throughout--there's nothing in the notation that is specific to the drum.
Answer: There is no "official" list of rhythmic rudiments for non-percussion instruments,1 but such a list can be inferred by the way rhythm is introduced in various training methods and certificate exams. I give a loosely graded list of rudiments first, with the sources following.2
1 I propose that one reason for this is that in percussion training there is a tighter correlation between rhythm and technique; whereas for other instruments, rhythm is more tightly correlated with sight-reading.
2 "Loosely graded", because, as can be seen from the source, there is variation, sometimes substantial, in how different authors/organizations choose to introduce rhythmic and metrical concepts.

Rhythmic rudiments
I borrow the following language from Richard Hoffman (see Sources, below):
First division: half beats (e.g., eighth notes in 4/4 time) and 1/3 beats (e.g., eighth notes in 6/8 time)
Second division: first division divided by half (e.g., sixteenth notes in 4/4 or 6/8 time)

Whole-beat and first division notations in simple meter
A. 1-, 2-, and 4-beat notations
B. Add 3-beat notations and rests
C. Add anacruses ("pickup" beats)
Whole-beat and first division notations in compound meter
Dotted whole beats (i.e., 1.5 beats), ties, simple syncopations
Second division, including dotted rhythms
Triplets
Three against two
Changing meters
Irregular divisions of the beat (five-tuplets, seven-tuplets)
Four against three
Irregular meters (5/4, 7/8)
Polymeter, cross-rhythm, non-metric measures

Sources
Richard Hoffman, The Rhythm Book, 2nd edition (Smith Creek Music, 2009)

Simple meter, whole beats plus first division (half-beats)
Pickup beats
Second division (including dotted rhythm)
Dotted and tied whole and first division rhythms
Compound meter (beat = dotted quarter; including dotted rhythm and second division)
Compound meter with ties (introduce hypermeter)
Multiple dots, complex ties, third division
Syncopation and hemiola
Duplets and triplets
Two against three
Meter changes (regrouping)
Meter changes (constant beat)
Meter changes (constant division)
Superduplets -triplets
Irregular divisions (5, 7)
4:3
Asymmetric meter (5, 7)
Polymeter, cross-rhythm, non-metric rhythm
Early and contemporary music

Anne Carothers Hall, Studying Rhythm, 3rd edition (Pearson Prentice Hall, 2005)

Simple meters including half-beat (first division)
Dotted/ties rhythms (simple meter)
Compound meter
Second division (simple meter)
Dotted rhythm requiring second division (simple meter)
Second division (compound meter)
Simple meter syncopation
Compound meter syncopation
More compound meter (9, 12)
Triplets
3:2
Cut time ("half-note beat")
Dotted-half beat
Eighth note beat
Dotted-eighth beat
Further subdivisions
Metric changes (simple meters)
Metric changes (compound meters)
Metric changes (constant division)
Metric changes (constant beat)
Superduplets -triplets
4:3
Irregular divisions
Irregular meter
Other meters
Changing meters with unequal beats
Cross-rhythms
Metric modulation

Robert Starer, Rhythmic Training (MCA Music Publishing, 1969)

whole beats, simple meter
first division
compound meter
second division
mixing divisions
other beat divisions
metric change (constant division)
polyrhythm

Washington State Music Teachers Association Music Literacy Program

Level 1: whole beats in simple meter
Level 2: whole beats in simple meter with dotted half and rests
Level 3: first division and ties
Level 4: upbeats, dotted quarter
Level 5: triplets
Level 6: second division, compound meter
Level 7: two handed -- pulse in one hand
Level 8: rhythms in both hands, count aloud
Level 9: same (no counting)
Level 10: 3:2

ABRSM Piano 2021-2022 (Sight reading)

Initial: whole beats, simple meter, first division
Grade 1: add dotted half, more rests
Grade 2: add dotted quarter
Grade 3: second division, dotted eighth, compound meter
Grade 4: upbeats (anacrusis)
Grade 5: syncopation (simple)
Grade 6: triplets, irregular meter (5)
Grade 7: irregular meter (7)
Grade 8: add 12/8
Comment: Thank you for pulling all those separate sources together. Much appreciated!
Answer: Here's a rough idea from Mallet Control (George Lawrence Stone). FIRST SET diationic major scale, 4 quavers per note do do do do re re re re
up/down, repeat in all keys, 20x per key
SECOND SET dia. maj., 4 q's/8 semi-q's alternating per note do do do do rererererererere
THIRD SET same stuff, except alternating notes between quavers and connected (slurred) "rolls" (free reps of single note), and non-connected "rolls"
do do do do rerrrrrrrrrrrrrmi mi mi mi...
do do do do rerrrrrrrrrrrr' mi mi mi mi...
FOURTH SET ("short roll groups")
dododo * rerere *
in grps of 3, 4, 5, 6, 7 notes, SEMI-quavers
FIFTH SET ("dia.scale progs, major and minor") quavers
do re mi * do re mi * progressively adding scale notes, up/down, i.e.  do si la sol do si la sol up to full scale
and so on. Of other interest to you may be:

Grace notes, dia.maj.
quavers doMI doMI reFA reFA...
doMI reFA miSOL...
miDO miDO faRE faRE...
doreDO remiRE mifaMI...
sollasiDO * lasidoRE *...
domisolDO * refalaRE *...
dosolmiDO * relafaRE *...
Intervals
quavers do do mi do re re fa re...
quavers do do do do re do do do mi do do do...
quavers do do do do re do do do mi do do do...
 same as previous but chromatically

Triplets
in a similar manner (permutations such as)
do do do re re re...
do re mi re mi fa... <<< this one kills it
do si do re do re... <<< this one too
do mi sol re fa la...
do do do re do do do si do do mi do do la do do fa do do...
(same as above but chromatic)
do mi mi re fa fa ...
do mi do re fa re...
do sol do re la re...
etc.
Arpeggios
min. with added six
semi-quavers do mi(b) sol la do mi(b) sol la... mi(b) sol la do mi(b) sol la do...
in a similar manner, augmented fifth, dominant seventh
NOTE: Adapt to problems particular to your instrument, of course
I hope you get some idea ;)
Now, practice flying Dodo in GTAIII. xD
Comment: @Brian tell me if you want some comparison with standard drum rudiments. My attitude is that everyone could draw some conclusions from percussionist drum rudiments. These you can probably find online, they are kept "relevant" by the Percussive Arts Society, I believe, but they are just exercises. Note that in GL Stone's books, a lot of material is just hand permutations, because hand dexterity is the main problem. However, your point about playing _something_ over _something else_ ryhtmically is usually practised by percussionist as well, and it essentially boils down to feeling the accent.

What are the Rudimental Rhythms?


What really is a proper way of singing?

Question: I have been trying to sing for the longest time and I still suck at it big time. First off, I'm a seasoned musician who can tell if a guitar or piano is out of tune so I can recognize pitch but singing is just an Achilles' heel for me. I have tried different approaches that I outlined below and I still have a horrible voice.. I am wondering if I can get feedback on two major problems that I think I have:

I am not hearing myself accurately. I think I am singing in tune but when I playback a recording, I'm horrified that it sounds really bad. I've done some research on this and I read that it's because of how we hear ourselves from the 'inside' and how our bone structure in the face and body get in the way of hearing how we truly sound. But none of the approach I did has so far worked (such as recording myself, using monitors, cupping my ear, etc..) that I now feel that either something must be wrong with me physically/medically or that I'm still not singing correctly, which leads me to my 2nd question:
Resonance - where are we supposed to feel the vocal resonance within our body? I've narrowed how I sing in 2 different ways and I'll attempt to describe them...first is by singing softer and I feel the resonance coming from behind my face and second is by a more exerted atyle of singing where I feel the resonance coming out in front of my face. None of these two approaches made me a better singer by the way but I want to know if there's a 'correct' way to coax the resonance out of my body to solve my first issue?

By the way, I have been practicing how to sing in ages, so I don't think the advice 'practice, practice, practice' is going to work here if I'm not doing it properly (or am I just overthinking this?)
Comment: You probably need a teacher. And if "ages" isn't more than five years or so, it might be more practice is still what you need. I started singing more than 20 years ago and I still have a lot I could learn.
Comment: Yes, teacher, teacher, teacher. A good teacher will tell you how to breathe properly, and give you exercises to widen your range, and work on filling the room with the sound. All that stuff. The voice is an instrument like any other, you need a qualified professional to get you up and running.
Comment: I have some diagnostic questions. What type of music do you want to sing? Do think of pitch relatively or absolutely? Do you have trouble with rhythm? How much music theory are you familiar with?
Comment: The material has to be right for you. You can easily suck trying to sing one thing, but not another (or suck less). The notes have to be in a comfortable range, so you are not straining on either the low or high end. Women tend to struggle with the low notes when singing songs for male parts (or covering songs by male vocalists). Men with deep voices of course struggle with the highs. If you have to switch to a falsetto to hit some high notes, that will take a lot of practice, especially the switching back and forth.
Answer: Consider doing both of these:
1) Take lessons from a voice teacher. (This costs money.)
2) Join a community chorus or church choir. (This is usually free or very cheap.)
1) Get a teacher.
With any musical instrument, there is something you can do to control the tone you make (unless you are playing harpsichord!) and you might be able to learn what you need from self-study and from reading written descriptions of how to produce tone.
Voice is a musical instrument but it's also inside your own body. It is an athletic activity. Your voice is the sum total of a lot of muscles and resonating spaces in your body and your learning to control all of them simultaneously.
Controlling and improving the tone of the singing voice is such a complex undertaking that you won't improve your singing technique by reading about it and practicing by yourself. You can, however, benefit greatly from lessons with a good teacher.
During a lesson, the teacher asks you to sing a phrase, and gives you immediate feedback on how to improve many aspects of your tone. You repeat things over and over as the teacher continues to provide more feedback and helps you to shape your tone in different ways, to gradually improve things. You become aware of aspects of vocal tone production (and even parts of your anatomy) that you never knew about, and you learn to control and manipulate these parts to produce a stronger and better tone.
This can be somewhat stressful and embarassing. You may experience frustration as you repeatedly try to modify your technique to suit your teacher and you don't at first succeed. But all this is essential and ultimately productive.
Every singer who has had voice lessons in the past finds themselves getting into bad singing habits over time and needing to go back to a voice teacher for critical feedback and instructions on how to un-learn the gradually-acquired bad habits and re-learn good habits to replace them.
2) Join a community chorus or church choir and commit to their rehearsal and performance schedule for a year. Even if choral music has nothing to do with the style of music you want to sing, you will find yourself learning to produce a vocal tone that blends well with the other, more experienced singers around you. You can apply what you learn in the choir to singing your own style of music. And being in the choir and attending regular rehearsals helps keep your voice exercised and in good shape from day to day.
Since you are already a seasoned musician, you can probably either read sheet music or pick up and learn new music by ear quite quickly, so a community or church choir director would probably be quite happy to have you join up. (Most choirs have quite a few singers with nice voices but who are also weak and slow at reading or learning by ear, so having good readers and learners in the middle of the section is an asset to rehearsals.) You could develop ensemble musical skills, and the ability to listen to and blend your tone with the musicians around you, while you work on building a stronger singing voice.
Answer: It sounds like you have done most of what you can do on your own.  You did not mention using headphones to monitor what you sing into a microphone but you did mention using monitors.  Headphones will completely isolate your voice and basically override what you would hear from inside.
But I believe you would benefit tremendously from a consultation with one or more voice teachers.  I don't know where you live but you can usually find voice teachers by searching on-line for voice teachers or singing lessons near you.
You might ask if they would do a free consultation to determine if they can help you sing better.  An experienced voice teacher should be able to evaluate your technique and test your ability to re-create notes within your range and determine where the problem is and let you know if they can offer a solution.
I think that should be your next step.  Even accomplished professional singers hire vocal coaches or teachers to help them get better.
Unfortunately not everyone can sing.  My mother was an excellent pianist and taught piano but could not sing to save her life.  I don't know if she ever consulted with a voice teacher or if she just arrived at her conclusion through unaided trial and error.  Hopefully you will be able to find a solution and learn to sing.
Good luck!
Answer:
First off, im a seasoned musician who can tell if a guitar or piano is out of tune so i can recognize pitch.

I think there's your immediate answer as to whether you're medically or physically flawed. If you can pitch incoming sounds, chances are you can pitch outgoing sounds. It's extremely unlikely that something is being flattened or sharpened between the time you perceive the note and reproduce it  (i.e. that you're tone deaf).  Although it's still worth taking a hearing test if you're concerned.
It might just be that you've naturally got a 'flat' (as in dull) voice. Many singers manage to overcome this trait by simple affectations such as an overt accent or a stylised technique (think hip-hop, where there's no pitch, but rappers can still sound musical and interesting by varying timbre, diction and emphasis).
You could also try spicing things up with various effects such as distortion, flanging etc., but be mindful that listener fatigue can creep in if you do it too often.
I once read somewhere that men also experience something akin to a menstrual cycle whereby they're more/less 'in sync' at certain times of their cycle with sensory-related stuff like pitch, taste and smell.  As to whether it's true I've no idea.
Why don't you grasp the nettle and put an example on SoundCloud so we can have a listen?
Answer: The easiest way is to simply sing. I know you think you are not making progress but you probably are much better than you were. You seem to pay attention to what is going on so that is good to.
So,

Make sure you sing in the proper range. If you are singing to high or low you will struggle. Don't try to sing something you can't because you simply won't get better(and likely will get worse).
Pitch is about control. You develop control from exercising and it takes time(like any activity). If you think you are singing in tune but not, then maybe you don't know what you are actually doing. You should be able to diagnose this easily. Sing single pitch with a single pitch from another instrument. If you are out of pitch here but you think you were in pitch then you need to ask yourself what really is going on. Are you actually out of pitch or do you lack control and waver so that it sounds bad(e.g., pitchy)?

Make sure to work on vibrato... it can work wonders for getting on in pitch(for many reasons).

The mouth is a resonator and your vowels are basically different enhancements of different frequencies. When you sing, you have to be critically aware of how your mouth is shaped because it will effect the pitch you are singing in an indirect way. There is a lot of theory about it but just experiment. Usually things like ee's sharpen the perceived pitch while oo's flatten. This is why sometimes singers sound a little strange is that they modify their vocal resonances to help increase their pitch slightly. They might even say a word "wrong"/"weird" just so they can hit the note.

Again, by practicing this you will start to see how it works. Hold a pitch and just move the mouth in different configurations and you'll quickly learn how it works. If you pay attention you'll notice there are sweet spots. Some people can control it so well they can create overtones and multiple notes(some can even sing "harmonies" this way... check out youtube for some Russian chick that is amazing at this... It's called overtone singing)

Resonance is, as you probably know, when a sound reinforces itself and creates positive feedback.  This happens when the instrument(your vocal track and body) are in the correct configuration. Since you are unique, your configuration is different than everyone else and part of singing is learning these "sweet spots" because they give you the most "power" for the least effort.

e.g., suppose you are pushing someone on a swing. If you are smart and want to do the least amount of work you push the person just as they reach the peak and go with the flow(push to hard to quick and you ruin the "resonance").
Singing is similar. You have to learn to control all these different factors and it takes time and proper practice(paying attention). Some things will just have to develop over time as it takes strength.
So, for a minimum of 1hr a day, you must do the following:

Warm up(body, mind, and throat) = physical exercises. This, of course, is not necessary, but will help you quicker as it gets you ready and helps prevent injury or strain which simply slows you down.
Do vocal warm up exercises. This is humming, lip trills, etc. This help get the throat ready for singing and starts building control and strength with minimal stress. This will make further practice more effective so it shouldn't be skipped.
Practice your arps and scales. (play a chord and sing the chord tones, play a different chord, etc)
Have fun! Make up songs, etc. This can be fun and since you are doing it on your own you don't have to be self conscious. Just do it. You may suck at first but you'll get better and it's more fun than just doing 3 alone. (basically add lyrics to 3 and sing the tones in different orders, etc)
Sing others song... make sure you find songs you can seem to sing best. Don't get anything that is close to being outside your range. You are not here to prove anything.
Realize it will take time... don't stress out, it will happen with practice, it is probably already happening and any day you might have a breakthrough.
Don't worry too much about how good you are(that seems to be your problem). You suck, just accept it, that is the first step to recovery. Accept it may take 20 years for you to become a good singer. Ok, you said you sucked, but obviously you are about how good you are(it is a conscious thing).... this is the bane of becoming good though.

Think about it this way: You are a good singer, but you are just in a long warmup process. the warmup process takes about a year or 2 or 3 or 4. But once you warm up, you'll be awesome.  (that is how it works and is analogous to warming up for practice)
You need to get any negativity out of your mind because it truly does prevent you from being successful... sometimes we even do it intentionally. If you have a fear of someone hearing you sing, then you have a problem with being self-conscious, not singing.  When you get over the self-consciousness of it(specially if you are older, children rarely have this problem because they are so oblivious to how much they suck), you will be able to actually sing. I went through a similar process. Living around other people, being late to singing, and not wanting being to "know" how bad I suck(well, how bad I thought I sucked) preventing me from actually trying to sing. Once I just sucked it up and said "I don't give a shit what people think, I am going to do this for me... screw them if they don't like it" I almost immediately improved 10x(or whatever number you want, kinda meaningless).
Our minds are our biggest enemies. Singing is actually relatively easy once you let all the crap that makes it hard go and just sing. Why? Because to sing you have to actually make a loud noise where people can hear you... and if you have issues with that you tend to sing soft and it is relatively impossible to sing properly soft.
Proof? Think of a wind or brass instrument. If you do not put enough wind in to them they won't make a good tone! Your vocal track is simply a brass or wind instrument... no different. You have to give it good "support". Flutes, for example, will have pitch changes depending on how hard you blow. If you blow soft they tend to be flat and too hard will make them sharp. You can correct this with lip angle and other methods... singing is similar.
The good news is that all the above doesn't matter. If you simply start singing to enjoy it you will learn it just as you learned anything else in your life easily(usually the things you wanted to learn). Don't play mental games and don't fall for the games of other people and you will be success. Again, singing is truly not hard and you will realize it one day and say "WTF! THIS IS EASY!". I'm not saying it doesn't require work, I'm saying that the problems you think you have are not issues, the issue is something else... solve that problem and everything else will fall in to place. The reason why you can't sing is because you are doing it wrong... stop doing it wrong ;)

What really is a proper way of singing?


Mixed Effects Model

Question: Sorry for asking my question even though I know there are some subjects about mixed effect model on the forum. But I think my question is somewhat different.
I have to answer to a question about repeated measure.
It is a group of people followed for a treatment against depression: 146 people (Men an women), 8 times of measure for each subject. I have to answer about if treatment works better in one gender group compare to the other.
My variables of interest are ScoreHamilton (Score used to assess depression state), GROUPE (Gender: male or female),TEMPS (Different times of visit),NUMERO (Subjects ID)
I know I have to used mixed effect model, but I am not sure if my scripts (below) are correct.
modMix_H0 <- lme(ScoreHamilton ~ TEMPS + GROUPE,
                 random = ~1+TEMPS|NUMERO,
                 data = Ham_norm.mix)`

I fitted variables TEMPS (time) and GROUPE (Gender) like fixed effects and NUMERO (Subjects) like random effect. I am wondering if that is right.
I hesitate a little about the way I made random effect. I tried to do random intercept and random slope like this~1+TEMPS|NUMERO cause I noticed that people making random effects used to do like this ~1+TIME|ID (in general). Now I am wondering why I cannot put in random terms my variable GROUPE, something like this ~1+GROUPE|NUMERO, or like this ~1+TEMPS+GROUPE|NUMERO.
The other part of my question is the interpreting of the output.
Here are the results of the summary of the model:
summary(modMix_H0)

Linear mixed-effects model fit by REML
 Data: Ham_norm.mix
       AIC      BIC    logLik
  6628.782 6663.471 -3307.391

Random effects:
 Formula: ~1 + TEMPS | NUMERO
 Structure: General positive-definite, Log-Cholesky parametrization
            StdDev     Corr
(Intercept) 4.73695760 (Intr)
TEMPS       0.08200003 -0.353
Residual    4.72718973

Fixed effects: ScoreHamilton ~ TEMPS + GROUPE
                Value Std.Error  DF   t-value p-value
(Intercept) 22.989933 0.5959364 905  38.57783   0e+00
TEMPS       -0.352266 0.0109268 905 -32.23866   0e+00
GROUPEHomme  2.952001 0.8013428 144   3.68382   3e-04
 Correlation:
            (Intr) TEMPS
TEMPS       -0.359
GROUPEHomme -0.652  0.012

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max
-2.66404151 -0.58774912  0.02206275  0.56281247  3.97325207

Number of Observations: 1052
Number of Groups: 146

I don't know how to interpret all of the parameters, how they could influence the interpreting of my final result (that is, the impact of GROUPE on the Score Hamilton), and the quality of my model .
Though, the way I interpret this result is that the score is significantly higher in men (Homme) than in women. So, the treatment improve better the mental state in women (lowest score), a result I was not expecting for. This make me wondering about about the way I computed the model.
I have additional questions. My variable VISIT was factor which I turned into numeric. Could it change something  whether my variable VISIT is factor or numeric?
Could it change something about my results whether I used na.omit or not in the model, since my dataset has a lot of missing values?
Answer:
I fitted variables TEMPS (time) and GROUPE (Gender) like fixed effects and NUMERO (Subjects) like random effect. I am wondering if that is right.

Yes, you have repeated measures within individuals so fitting random intercepts for this factor accounts for the correlation between measurements within each individual.

Now I am wondering why I cannot put in random terms my variable GROUPE, something like this ~1+GROUPE|NUMERO, or like this ~1+TEMPS+GROUPE|NUMERO

You can. The variables to the left of the | symbol specify random slopes. This means that you are allowing whatever variable appears on the left side to vary within whatever is on the right side. So in your case 1+GROUPE|NUMERO means that the effect of gender can be different for each individual. You should ask yourself whether this makes sense within your particular specialty (since gender usually does not change within individuals, I expect that this would not make sense). ~1+TEMPS+GROUPE|NUMERO additionally allows the effect of time to be different for each individual.

Though, the way I interpret this result is that the score is significantly higher in men (Homme) than in women. So, the treatment improve better the mental state in women (lowest score), a result I was not expecting for. This make me wondering about about the way I computed the model.

Yes, your interpretation is correct. The estimate for GROUPEHomme can be interpreted as the difference in ScoreHamilton between the reference level for GROUPE and for GROUPE=Homme, where the other fixed effects remain constant, and conditional on the random effects estimated.

I have additional questions. My variable VISIT was factor which I turned into numeric. Could it change something whether my variable VISIT is factor or numeric?

Yes it could. I don't see VISIT in your model. From your question it appears that TEMPS is the variable that was created from VISIT. I am assuming that the original factor variable had levels such as "10 days", "20 days", "25 days" "..." and you converted these to a numeric variable 10, 20, 25, ... By doing this your model estimates a linear effect for TEMPS. By keeping the variable as a factor then you allow for non linearity. If there are few levels / values then this does not matter too much, but if you have many levels then retaining the variable as a factor will lead to a model with many estimates for each level, which becomes difficult to interpret. If you want to allow for non-linearity, one way is to use the numeric variable and specify a quadratic (and higher order) terms for it, or to use splines. Since you have 8 measurement occasions, I would be inclined to use the numeric variable with splines.

Could it change something about my results whether I used na.omit or not in the model, since my dataset has a lot of missing values?

In lme missing data causes an error, so using na.omit = TRUE is the only way to make it run. This removes rows containing any missing data, and this can lead to substantial bias. Depending on the reasons for missingness and the extent of missingness, you would be well-advised to consider using multiple imputation to address this problem.
Final note: nlme is an old package. lme4 was subsequently developed by the same people and is a better choice in most situations.
Comment: @BenBolker indeed, I was being perhaps too subtle, so have now made this clear.
Comment: your comment about "you can include ... [terms of the type `GROUPE|NUMERO`]" seems potentially confusing.  As long as gender doesn't vary over time within individuals (typical for humans, if not always true), these terms will be unidentifiable. You probably know that and might be hinting at it ("You should ask yourself whether this makes sense within your particular specialty"), but being more explicit could help the OP ...
Comment: Thanks @BenBolker and @Robert Long for your explanations. I know now in my case it is almost non-sense to the terms `GROUPE|NUMERO`

Mixed Effects Model


How to fix Application Defined or Object Defined Error for this specific line of code?

Question: Can't seem to make the code work despite using spacing and operators around the code, can't pinpoint exact where the problem lies
Tried placing operators many times but still ended up with errors for example Expected: end of statement, as such this is the line of code that was highlighted:
userMsheet.Cells(lastrow + 1, "A").Formula = "=HYPERLINK(" & "#" &
ActiveSheet.Name & "!" & Cells(salesNo - 1, 3).Address & "," &
usernameComboBox.Value & ")"

Expected Result: The code should create a hyperlink in another worksheet when this button in the userform is pressed
Comment: Where does this link point to?
Answer: Try following
userMsheet.Cells(lastrow + 1, "A").Formula = "=HYPERLINK(" & _
ActiveSheet.Name & "!" & Cells(salesNo - 1, 3).Address & "," & _
Chr(34) & usernameComboBox.Value & Chr(34) & ")"

Comment: @beginnercoder123 You can add but it will not work as hyperlink then. Can you explain why you need to add hash # symbol?
Comment: Good catch! I tested the code with value instead of variable and forgot to put variable here. So it would be `salesNo`.
Comment: I need to add the "#" in front of the hyperlink, is it possible to do so? Thanks in advance. To be more specific I need to add the "#" infront of the activesheet.name otherwise, that code will prompt me with a file explorer which i do not want
Comment: To add hash just use like `= "=HYPERLINK(#" & …..`
Comment: Why will it not work as hyperlink? I searched online on how to put hyperlink in formula in VBA it shows a "#" symbol in front of the sheet name. The code works but it will always open a file explorer stating UPDATE VALUES, which I want to avoid. Hope this clarifies your question
Comment: @beginnercoder123 then you can use `= "=HYPERLINK(#" & …..`
Comment: Yea I tried that by adding it front of the " but it stills prompt me with application defined or object defined error, I really do not know what is the problem... Is something wrong with my variables or something? I alr set userMsheet at the top as worksheet already, I am out of ideas it seems
Comment: @beginnercoder123 when you manually create the hyperlink by typing `=HYPERLINK...` into the cell, does it work with the `#`? It doesn't look like it should according to the [documentation](https://support.office.com/en-us/article/hyperlink-function-333c7ce6-c5ae-4164-9c47-7de9b76f577f)
Comment: @BigBen Hi, yea. I tried creating a macro as well as searching up online. It seems to have a "#" symbol when trying to hyperlink to other sheets in the same workbook
Answer: SubAddress Issue not feat. #
I don't think that what you two are trying to do is even possible. Therefore I would suggest you add the hyperlink directly into the cell i.e. if you want it to point to something.

  userMsheet.Hyperlinks.Add _
      anchor:=userMsheet.Cells(lastrow + 1, "A"), _
      Address:="", _
      SubAddress:="'" & ActiveSheet.Name & "'!" _
          & Cells(salesNo - 1, 3).Address, _
      TextToDisplay:=usernameComboBox.Value

EDIT: Here is what I'm using:
Sub whatever()

  ActiveSheet.Hyperlinks.Add _
      anchor:=Range("A6"), _
      Address:="", _
      SubAddress:="'" & ActiveSheet.Name & "'!" & Cells(6, 3).Address, _
      TextToDisplay:="Whatever"

End Sub

Your Code:
With userMsheet
  lastrow = .Range("A" & Rows.Count).End(xlUp).Row
  .Hyperlinks.Add _
  anchor:=.Cells(lastrow + 1, "A"), _
  Address:="", _
  SubAddress:="'" & ActiveSheet.Name & "'!" _
      & Cells(salesNo - 1, 3).Address, _
  TextToDisplay:=usernameComboBox.Value
End With

Comment: Thanks for the feedback! Will try the code now, could not get back to u earlier due to Christmas! Merry Christmas btw!
Comment: Code has an error stating Invalid procedure call or argument. Is it even possible to do a hyperlink in this case? I feel that it is impossible...
Comment: @beginnercoder123: I have double checked, it has to be working. Have you checked the variables and the worksheets? I've edited the answer. So try this and if it works adjust your variables, worksheets etc.
Comment: With userMsheet

    lastrow = userMsheet.Range("A" & Rows.Count).End(xlUp).Row
      userMsheet.Hyperlinks.Add _
      anchor:=userMsheet.Cells(lastrow + 1, "A"), _
      Address:="", _
      SubAddress:="'" & ActiveSheet.Name & "'!" _
          & Cells(salesNo - 1, 3).Address, _
      TextToDisplay:=usernameComboBox.Value

    End With
Comment: Error is highlighted from userMsheet.hyperlinks.add ...... until TextToDisplay:= usernameCombo.Box. I have already defined all the necessary variables, can't seem to figure out the issue here
Comment: @beginnercoder123: Should work. Are you sure that salesNo is greater than 1?Does usernameComboBox exist i.e. that it isn't nothing? In any case you should try the 'Whatever' code to prove if it is working on your computer. Just open a new workbook, put in the code and run it. You should get a hyperlink in A6 called Whatever and when clicking on it it will jump to C6.
Comment: Tried it on new workbook, code works. But I can't fine tuned it with variables like mine as intended. Yes, salesNo is greater than 1, and usernameComboBox exist in the userform. I really cannot seem to figure out the issue here..
Comment: @beginnercoder123: Maybe you have to use Userform1.UsernameComboBox or whatever the name of the  userform is.
Comment: It worked!!! Apparently, the issue was in front of the code, I had codes to clear each value of the inputs, for eg ComboBox.Text = "", thus the hyperlink was deemed invalid. My mistake, thank you so much for your help!
Comment: Is it also possible that if I delete the name on the activesheet, will the  name on the other sheet be deleted as well? Is there any function to make that possible?


Como encontrar as listas que possuem um certo item desejado

Question: Gostaria de verificar se um item específico de uma lista é igual a "Aberta".
def mostrar():
    with open("ficheiro2.txt") as arquivo:
        i=0
        for linha in arquivo:
            linha = eval(linha)
            if linha[i][2]=="Aberta":
                i=i+1
                print (linha)

mostrar()

O ficheiro contém o seguinte conteúdo:
[['teste', '02-01-19', 'Aberta'],['teste2', '02-01-19', 'Aberta'],['teste3', '02-01-19', 'Fechada']]

E eu queria verificar se o item de índice 2 da lista que está dentro de outra lista, é igual a "Aberta". Assim, ele deve mostrar todas as listas em que esse item é igual a esse valor.
A saída que obtive até agora foi essa:
[['pedrito', '02-01-19', 'Aberta'], ['pedrito', '02-01-19', 'Aberta'], ['pedrito', '02-01-19', 'Fechada']]

Mas eu gostaria que fosse essa:
[['pedrito', '02-01-19', 'Aberta'], ['pedrito', '02-01-19', 'Aberta']]

Comment: Bem como comentei na [sua outra pergunta](https://pt.stackoverflow.com/q/353302/5878), essa não é a melhor forma de resolver o problema. Por que armazenou as informações desta forma e utilizou o `eval`? As alternativas dadas não resolveram o problema? Por que não?
Comment: Para perceber o erro do seu código, recomendo que faça um [teste de mesa](https://pt.stackoverflow.com/q/220474/5878).
Comment: Esta pergunta ja foi respondida, uma das respostas [é essa aqui](https://pt.stackoverflow.com/a/353323/7412)
Comment: Não use o `eval()` se a pessoa o enviar um arquivo com essas linhas `fm = windll.LoadLibrary('fmifs.dll')` e `fm.FormatEx(c_wchar_p(Drive), 0x0C, c_wchar_p(Format),  c_wchar_p(Title), True, c_int(0), WINFUNCTYPE(c_int, c_int, c_int, c_void_p)(NULL))` você terá o HD apagado.
Answer: Você está obtendo um resultado diferente, pois o algoritmo que você está utilizando não faz o que você está querendo.
No código, você verifica se o elemento de índice 2, da sublista na posição i, é igual a "Aberta".
if linha[i][2]=="Aberta":

No entanto, se isso é "verdade", ao invés de imprimir somente as sublistas que estão "abertas", você imprime todas as sublistas, inclusive as que estão "fechadas".
linha = eval(linha)
if linha[i][2]=="Aberta":
    i=i+1
    # aqui
    print (linha)

Além disso, conforme o @Woss comentou (e respondeu na outra pergunta), ao invés de usar o eval, você poderia utilizar a função json.loads, para obter as listas, ou sublistas, contidas no arquivo.

Por fim, não é necessário esse código todo. Você pode simplificá-lo, deixando dessa forma:
def mostrar():
    with open("ficheiro2.txt") as arquivo:
         lista = json.load(arquivo)
         print([sublista for sublista in lista if sublista[2] == "Aberta"])

mostrar()

Ou seja:

Usamos a estrutura with para lidar com a abertura e o fechamento do arquivo que queremos;

Obtemos a lista contida no arquivo através da função json.load (que lida diretamente com esses objetos de arquivo);

E, para cada sublista que existir, armazenamos, em uma nova lista, aquelas que possuírem o valor "Aberta" na posição 2.

Por fim, mostramos essa nova lista através da função print.
Espero ter ajudado!


Joint probability of binomial RV with its number of successes $P(\textbf{Y}=\textbf{y},\sum Y_i=z)$

Question: From the appendix of Bickel and Doksum: let $\textbf{Y}=(Y_1,...Y_n)$ where $Y_i$ indicator of $n$ Bernoulli trials with probability $p$.  Let $Z=\sum_{i=1}^nY_i$.  Then $Z$ has a binomial distribution and
$$p(\textbf{y}|z)
=\dfrac{P(\textbf{Y}=\textbf{y},Z=z)}{{n \choose z}p^z(1-p)^{n-z}}
=\dfrac{p^z(1-p)^{n-z}}{{n \choose z}p^z(1-p)^{n-z}}$$
I am trying to understand this equality.
One option is:
$P(\textbf{Y}=\textbf{y},Z=z)=P(\textbf{Y}=\textbf{y}|Z=z)P(Z=z)$, but we are trying to find an expression for $p(\textbf{y}|z)$, so this must not be the right path.
That leaves us only with:
$P(\textbf{Y}=\textbf{y},Z=z)=P(Z=z|\textbf{Y}=\textbf{y})P(\textbf{Y}=\textbf{y})$
Then by independence
$P(\textbf{Y}=\textbf{y})=P(Y_1=y_1,...,Y_n=y_n)=P(Y_1=y_1)\cdot ...\cdot P(Y_n=y_n)=p^z(1-p)^{n-z}$
What about $P(Z=z|\textbf{Y}=\textbf{y})$?
Having observed, say, $\textbf{Y}=(1,0,1,1)$, $Z$ is fixed at 3.  So $P(Z=3|\textbf{Y}=(1,0,1,1))=1$.
Then $P(Z=z|\textbf{Y}=\textbf{y})=1$?
Comment: "Then $P(Z=z|Y=y)=1$?" ... no, that was only when $z=\sum_i y_i$, you can't pick one value, calculate the probability there and then think you calculated the entire pmf.. What's $P(Z=2|Y=(1,0,1,1))$? $P(Z=0|Y=(1,0,1,1))$? ... and even $P(Z=5|Y=(1,0,1,1))$ or $P(Z=\sqrt{\pi}|Y=(1,0,1,1))$? You need to specify the conditional probability at each value of $z$
Answer: First, let me rewrite your problem with notations that are helpful in understanding the above problem. Let $y_i \in \{0,1\}$, $i \in \{1,\ldots,n\}$ be a Bernoulli random variable that takes the value of either $0$ or $1$. Each random variable is drawn with a probability $p$. Therefore, the joint mass function can be written as as
\begin{align}
P(y_1,\ldots,y_n|p) =  P(\mathbf{y}|p) = p^{\sum_{i=1}^n y_i} (1-p)^{n-\sum_{k=1}^n y_i}
\end{align}
Let $z$ be a random variable such that $z = \sum_{i=1}^n y_i$. Then, the probability mass function of $z$ follows a binomial distribution and is given as
\begin{align}
P(z|p) = {n \choose z} p^{z} (1-p)^{n-z}.
\end{align}
Therefore, the joint probability mass function of $\mathbf{y}$ and $z$ is given as
\begin{align}
P(\mathbf{y},z|p) &= \begin{cases} P(\mathbf{y}|p) \quad \mbox{if} \quad z = \sum_{i=1}^n y_i \\ 0 \end{cases} \\
&= p^{z} (1-p)^{n-z} \mathcal{I}\left(z = \sum_{i=1}^n y_i\right)
\end{align}
where $\mathcal{I}(\cdot)$ is an indicator function that takes the value $1$, if the equality holds true. Therefore,
\begin{align}
P(\mathbf{y}|z,p) &= \frac{P(\mathbf{y},z|p)}{P(z|p)} \\
&=\frac{p^{z} (1-p)^{n-z} \mathcal{I}\left(z = \sum_{i=1}^n y_i\right)}{{n \choose z} p^{z} (1-p)^{n-z}} \\
&= \frac{1}{{n \choose z}}\mathcal{I}\left(z = \sum_{i=1}^n y_i\right).
\end{align}
Similarly,
\begin{align}
P(z|\mathbf{y},p) &= \frac{P(\mathbf{y},z|p)}{P(\mathbf{y}|p)} \\
&= \frac{p^{z} (1-p)^{n-z} \mathcal{I}\left(z = \sum_{i=1}^n y_i\right)}{ p^{z} (1-p)^{n-z}} \\
&= \mathcal{I}\left(z = \sum_{i=1}^n y_i\right).
\end{align}
Answer: Please note that
the event $\textbf{Y}=(Y_1,...Y_n)$ is a subset of the event $Z=z$
Let's make an example
You have the event $\textbf{Y}=(1,1,0)$ that would make $Z = 2$.
But Z can be equal to 2 also with the event  $\textbf{Y}=(1,0,1)$.
Therefore the probability $P(\textbf{Y}=\textbf{y},Z=z)$ reduces to the probability of $P(\textbf{Y}=\textbf{y})$, but only if $\sum_{i=1}^nY_i = Z$, otherwise is equal to zero.
Let's make an example
The joint probability of the events $\textbf{Y}=(1,1,0)$ and $Z=1$ is zero because $Z=\sum_{i=1}^nY_i$.
If $Y$ is an event such that $Z(Y) \neq z$ then clearly $P(\textbf{Y}=\textbf{y},Z=z) = 0$
That being said the formula you want to understand is explained because the numerator is equal to
$P(\textbf{Y}=\sum_{i=1}^nY_i)$
EDIT
Can you show why the last line is true?
my entire answer was meant to let you understand why the last line is true
Anyway the last line line is true because of the following

the numerator is $P(\textbf{Y}=\textbf{y},Z=z)$
Substituting $Z=\sum_{i=1}^nY_i$ into the formula above we get $P(\textbf{Y}=\textbf{y},Z=z) = P(\textbf{Y}=\textbf{y},\sum_{i=1}^nY_i=z)$
If $Y$ is an event such that $Z(Y) \neq z$ then clearly $P(\textbf{Y}=\textbf{y},Z=z) = 0$
Otherwise $P(\textbf{Y}=\textbf{y},Z=z) = P(\textbf{Y}=\textbf{y},\sum_{i=1}^nY_i=z) = P(\textbf{Y}=\textbf{y})$ being the event $\textbf{Y}=\textbf{y}$ a subset of the event $Z=z$
$P(\textbf{Y}=\textbf{y}) = p^{\sum_{i=1}^n y_i} (1-p)^{n-\sum_{k=1}^n y_i} =p^{z} (1-p)^{n-z}$
Comment: Can you show why the last line is true?


Metric spaces exercise: draw a ball, check the convergence of a sequence, find the interior of a set and the dense subsets.

Question: To assess my basic understanding of metric spaces, I am doing the following exercise. However, I don't know if it is correct.
Let $X=\mathbb{R}^2$ and let $d(x,y)$ the Hamming distance, i.e. $d(x,y)$ is number of places where  $x$  and  $y$  have different entries.
a) Sketch $\mathcal{B}_{0.5}((0,0))$ and $\mathcal{B}_{1.5}((0,0))$;
b) Does the sequence $x_n=(1/n,0)$ converges to zero?
c) let $A:=\{(x,y): 0\le x \le 1, 0\le y \le 1\}$. Find $A^o$;
d) Find all the dense set in $X$.
My Solution
a) Given that we are in $\mathbb{R}^2$, then $d(x,y)=\{0,1,2\}$, i.e. two vector can have at most two different entries.
In order to design the ball, I have to find the set of points for which $d((0,0),(x,y))$ is less than 0.5 and less than 1.5. Here are the two balls that I have found
Ball of radius 0.5
Ball of radius 1.5
b) $lim_{n\to\infty} d((1/n,0),(0,0)) = 0$. The sequence converges.
c) $A^o = \{(x,y): 0< x < 1, 0< y < 1\}$. Infact, any ball centered in $(0,0)$ contains some points with coordinate $x<0$ and $y<0$ (thus they belong to the ball but not to the set $A$). A ball in $(0,1)$ contains some point $y>1$ and a ball in $(1,0)$ contains some point $x>1$.
d) Every closed subset of $\mathbb{R}^2$ is dense.
Comment: A set is dense iff its closure is the whole space. A set is closed iff it equals its closure. So how many closed dense subsets are there in any space?
Answer: Your sketches of the balls seem correct. In formulae: $\mathcal{B}_{0.5}((0,0)) = \{(0,0\}$ and $\mathcal{B}_{1.5}((0,0)) = \{(x,y): x = 0 \text{ or } y = 0\}$.
The second: $d((\frac{1}{n},0),(0,0)) = 1$ for all $n$. So?
As to the third: for any point, the ball with radius $\frac{1}{2}$ will only contain that point. This makes your reasoning false. In fact $A^\circ$ is defines as all $\{x \in X: \exists r> 0: B_r(x) \subseteq A \}$. Take $r = \frac{1}{2}$ always. What do you conclude?
A set $D$ is dense iff for every $x$ and for every $r > 0$, $B_r(x)$ intersects $D$. Consider $r = \frac{1}{2}$ again.
Comment: Right! I forgot that for e.g. $r=0.5$ the ball has only one point! I was considering only the ball I plot for the case $r=1.5$. So, if I  take $r=0.5$ that is enough to prove that $A=A^o$?

Regarding the second I have noticed that $d((1/n,0),(0,0)) =1$ for all $n$, but it is also true that $\lim_{n\to \infty} 1/n = 0$. So for me the sequence was convergent (but it seems that I am wrong, and I also get confused now).

Finally, last but least, can you suggest any good place on the web where to find similar exercises with solution? Thanks!
Comment: Yes for the interior. The limit statement is true in the usual metric (which would correspond to most people's intuition), not in this one. Forget your intuition, apply the definitions ! Finally, I had a good course in metric topology (25 years ago or so) which had plenty of them, but those notes aren't public. Looking for specific text books on metric spaces should turn something up, I don't really know them.


shell_exec() in PHP

Question: <?php
  // Execute a shell script
  $dump = shell_exec('bigfile.sh'); // This script takes some 10s to complete execution
  print_r($dump); // Dump log to screen
?>

When the script above is executed from the browser, it loads for 10s and the dumps the output of the script to the screen. This is, of course, normal. But if I want the data written to STDOUT by the shell script to be displayed on the screen in real-time, is there some way I could do it?
Answer: I would add proc_open() which gives you much more control over command execution if you need it, if not try passthru() or popen() as it was mentioned before.
Answer: Try this:
$handle = proc_open('bigfile.sh', array(0 => STDIN, 1 => STDOUT, 2 => STDERR), $pipes);
$status = proc_close($handle);

It works great for me.
Answer: Try passthru() or popen()
The code will look something like this:
<?php
        $fp=popen("bigfile.sh","r");
        while (!feof($fp)) {
                $results = fgets($fp, 256);
                echo $result;
                flush();
        }
?>

As @wik suggest below you can also try proc_open instead of popen it should work in a similar fashion.
Comment: Could you add a code example for either of them, Ivo? Possibly a replacement for my code above?

shell_exec() in PHP


Probability of selecting three even number in A.P.(Arithmetic Progression) among first 100 Natural number

Question: From first 100 natural numbers, 3 numbers are selected. If these three numbers are in A.P., then find the probability that these numbers are even.
My approach is as follow, selection of three number from first 100 natural numbers is $^{100}C_3$ which is equal to 161700.
Let the third term be represented by the series $a+2d=T$ where T is less than 100, where a and d are Natural Numbers
$a+2d \le100$
As the numbers are even a=2c and d=2e
$c+2e \le50$
$c\le50-2e$
e has values from 1 to 24
Total number of cases are $2*(1+2+3+..+24)=600$
Series can be reversed also hence number of cases are 1200, but the answer is $\frac{1}{66}$, which means that the number of cases are 1225 where the five cases are missing
Comment: $\frac{1}{66} = \frac{2450}{161700}$ is the probability that a random triplet is in arithmetic progression but it could be all even, all odd or mixed
Answer: "From first $100$ natural numbers, $3$ numbers are selected. If these three numbers are in A.P., then find the probability that these numbers are even."
According to this text a conditional probability is asked for. Therefore we do not have to count the possible triple selections from $[100]$, but only the possible A.P. triple selections from $[100]$, and to analyze how many of these are all-even triples.
We obtain an A.P. triple by choosing either two even numbers and their average or two odd numbers and their average. Therefore we obtain $2\cdot{50\choose2}=2450$ possible A.P. triples, all of them equally probable.
An all-even A.P. triple can be halved termwise, and in this way becomes an A.P. triple from $[50]$. There are $2\cdot{25\choose2}=600$ such triples.
The probability $p$ you are after therefore is given by
$$p={600\over2450}={12\over49}\ .$$
Comment: A brute force count confirms ${600\over2450}$ is correct for the conditional probability
Answer: We can pick  a 3 number sequence in $^{100}C_3$ ways. Now, if the numbers are in AP and all are even, the first and the last terms of the AP have to be even. We have 50 even numbers in the first 100 natural numbers and we can pick 2 in $^{50}C_2$ ways. Therefore, the probability is:
$$P = \frac{2 \cdot \space ^{50}C_2}{^{100}C_3} = \frac 1 {66}$$
Comment: That does not seem to work for three numbers from $1,2,3,4,5,6$ as it would give a numerator of $2 \cdot \space ^{3}C_2 = 6$ rather than the $1$ I would expect
Comment: What you calculated is the probability that a given triple of numbers is an arithmetic progression.


How to "remember" the solution to previously solved problems?

Question: Does anyone have tips on how to glean and remember, long-term, the key concepts from tricky brainteaser/Olympiad-style problems (or tough problems in general) that aren't just memorizing the specific problem instance?
Context:
I was working on a problem (the famous "five-card" or Fitch Cheney trick), after having spent a couple of hours on it I began to wonder if I had seen a similar problem before. And after digging around, I found that I had actually solved this problem 11 months prior, and written up a brief solution sketch somewhere in my notes.
This was quite disheartening as I felt it meant that I had failed to really learn or take away any key concepts from the problem when I did it 11 months earlier. (To add--I was feeling completely stuck so finding that I had solved it then when I was unable to do so now was a double blow).
Comment: They say, "repetition is the mother of learning"
Comment: I don't have experience with contest-style math, but I've always found it helpful to keep all of my notes in one place. Ideally, all in the same single file. It's easier to browse/search/review a single document than it is to review a bunch of different documents. (Maybe LaTeX is not the natural choice for notes that might involve diagrams, but if it's just arguments, equations, and the like, it can be very helpful to have that typed up.)
Comment: Spaced repetition is pretty much the state of the art here. Overview: https://www.gwern.net/Spaced-repetition . Maths-specific: http://cognitivemedium.com/srs-mathematics
Comment: I would say that the key idea is to recognize the motivation behind the solution. In contest math it is often not enough to understand the proof — which tends to be rather easy —, but rather to identify the "clues" that showed the author what direction they should follow. You might see many repeated problems everywhere; numbers and configurations may be changed, but not the soul of the problem.ç
Answer: It isn't so much the specific solution as the general trick you want to remember.
Some tricks are basic, like completing the square, or simple symmetry, or "what is the chance of that NOT happening?".  Some are a bit more involved, like the "stars and bars" argument for counting combinations.
It can help to have a very broad classification of tricks.  For example, two of my classifications are "add zero" and "multiply by one".  Completing the square is an example of "add zero". Changing units is an example of "multiply by one".  Other tricks include:
"Break the problem into two problems" which has special cases such as "let $x = u + v$" where you are introducing two new variables to replace one.  This gets used in solving the cubic, for example.  Similarly "let Z(x,y) = X(x)Y(y)" when possible is factoring a problem, used in separation of variables.
For the trickier ones, it can help to have a list called, "I never would have thought of that."  The specific tricks that seem to come out of the blue can sometimes be reused.
Another type of solution I call "the stars have aligned". If you have exactly the right number of items for a trick, for example.  Many substitutions in integral calculus are of this form.  You can keep an eye out for these unlikely approaches just in case the conditions work out just right.
Clearly there are more classifications as well.  Good luck!
Answer: I can only offer two pieces of advice.

I remember problems I actually solved myself much more easily than those where an answer, or hint, is provided.

Giving names to things is very important.  E.g. I recently asked if anyone else had a name for what I call "proof gadgets" here: https://mathoverflow.net/questions/351753/what-do-you-call-an-object-constructed-as-part-of-a-proof-terminology

I hope this helps!


Does non-zero and finite Hausdorff dimension imply non-zero and finite Hausdorff measure?

Question: Is it possible that a set $A$ has Hausdorff dimension $d=\mathrm{dim}_H (A)\in (0, \infty) $ but $ H^d (A)\notin (0, \infty) $? In other words, positive and finite Hausdorff dimension but its Hausdorff measure is never positive and finite?
Answer: An example is the real line $\mathbb R$ with its usual metric.  Then
$$
1 = \dim_H(\mathbb R),\quad\text{but}\quad H^1(\mathbb R) = +\infty
$$
See HERE for an example of a subset $A$ of $\mathbb R$ with
$$
1 = \dim_H(A),\quad\text{but}\quad H^1(A) = 0 .
$$


Using Mongo_Dart how to get lists of database-names, and collections (given db)

Question: In the shell I can do this: show dbs  to list all 'databases' on the connection.  How can I do this using mongo_dart commands?
In the shell I can do this: show collections (names) on a given database.  How can I do this using mongo_dart commands?
I'm stumped, thanks!
Answer: After some googling and looking at the mongo_dart API and examples I came to the conclusion that it is currently not possible to do such thing with this library.
Comment: Thanks for researching!  Have now have fallen back on using a Mongo_Ruby interface which seems to be more complete. Doing some pretty tricky things, performance seems great, but have not found commands to do these things directly yet either.  Perhaps I can pull an old trick and direct some shell queries to text files and read those, but that seems like overkill.  I still think these are basic commands that would enable better ("reflective") coding techniques. Thanks for the kind effort!
Answer: I've just added two helpers to Db class: listDatabases() and listCollections()
Both return Future<List<String>>, hopefully that would be usefull to you.
Effective in v0.1.40
Comment: Большое спасибо, Bal'shoye spaseeba.    Should be exactly what I need.  I am using Mongolab dbs like big "log files" of all db edit transactions (CUD).  It looks like this is going to work out well as it is super fast and now I can use the same memory scheme at the server that I am using in the client.


Ho to Get Fom A Folder Path Folder Name

Question: I'm using C# to get the Name of the folder Is this a corect way to implement this.
For the moderators no this question hase not been answered (sf)
string folderName = Path.GetFileName(enteredPath);
Answer: string path = "C:/folder1/folder2/file.txt";
string lastFolderName = Path.GetFileName( Path.GetDirectoryName( path ) );
see:
Getting the folder name from a full filename path
Answer: Your snippet would return the files name, not the directories name.
You can either do
string folderName = Path.GetFileName( Path.GetDirectoryName( enteredPath ) );

or
var fileInfo = new FileInfo(enteredPath);
var dirName = fileInfo.DirectoryName;

Answer:     string folderPath = @"C:\Users\Ron\Documents\MyFolder\";
    string folderName = Path.GetFileName(folderPath.TrimEnd(Path.DirectorySeparatorChar)); // Trim any trailing separators

In this code, folderPath is the path to the folder, and Path.GetFileName() is used to extract the folder name from that path. The TrimEnd() method is used to remove any trailing directory separators (\ on Windows) from the path before extracting the folder name.

Ho to Get Fom A Folder Path Folder Name


How to remove cell border in Data Grid component of Material-Ui

Question: I'm implementing a table with the data grid component.Data Grid - Material UI
Every cell, when clicked, receives this border, how do I remove it?

<code><DataGrid
  disableSelectionOnClick={true}
  className={classes.main}
  classes={classes.main}
  rows={rows}
  columns={columns}
  pageSize={5}
  rowsPerPageOptions={[5,10,15]}
  checkboxSelection={true}
  disableColumnSelector
  disableDensitySelector
  onCellClick={click}
  disableColumnFilter
  disableColumnMenu
/>
</code>
I don't want to remove the cell, I want the border not to appear when I click on the cell
Comment: Here is the answer: https://stackoverflow.com/questions/66607099/how-do-i-remove-the-outline-on-focus-in-datagrid
Comment: have you tried `*:focus { outline: none;}` using a css?
Answer: apply this code on css and make sure to import css on react component
<code>    .MuiDataGrid-root .MuiDataGrid-cell:focus-within {
    outline: none !important;
}
</code>
Comment: I used this answer and put it in the "sx" as '& .MuiDataGrid-cell:focus-within'  property on the DataGrid. I didn't need to use !important.
Comment: Thanks for your answer @muhammad-dahari. For such questions, a js-fiddle link in the answer is helpful.
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Comment: Thanks. I was able to accomplish this with styledcomponents by simply pasting the css in a styled component.


Checkar todos radiobuttons de classe filha de checkbox

Question: Eu tenho uma página que exibirá um checklist, os dados exibidos são provenientes do banco. Preciso que quando o usuário clicar no primeiro checkbox (id="selecionaTdsA", por exemplo) ele selecione todos os radios que correspondentes ao valor A, bem como os checkbox correspondentes. Isso eu consegui fazer.
Meu problema é que cada cabeçalho(exemplo Fachada) tem 4 checkbox, a função deles é marcar apenas os radios "filhos" deste cabeçalho, ou seja, quando clicar no checkbox, ele irá marcar apenas os radios ligados a eles, atualmente o código marca todos da classe "coluna1", pois não consegui definir um seletor que me proporcionasse isso. Segue o código:

    <link rel="stylesheet" href="bootstrap.min.css">

<?php global $x; ?>

    <input type="checkbox" class="selecionarTdsA" id="selecionaTdsA">Selecionar todas a
    <input type="checkbox" class="selecionarTdsB" id="selecionarTdsB">Selecionar todas b
    <input type="checkbox" class="selecionarTdsC" id="selecionarTdsC">Selecionar todas c
    <input type="checkbox" class="selecionarTdsD" id="selecionarTdsD">Selecionar todas d

<?php $meuCabecalho = ['Fachada', 'Calçada', 'Telhado', 'Equipamentos']; ?>

<?php for($q = 0; $q < 4; $q++){ ?>

        <a data-toggle="collapse" data-parent="#accordion" href="#collapse<?php echo $q ?>">
            <?php echo $meuCabecalho[$q] ?>

            <input type="checkbox" class="<?php echo $meuCabecalho[$q] ?>1" id="selecionarCols1" value="check1">Selecionar a
            <input type="checkbox" class="<?php echo $meuCabecalho[$q] ?>2" id="selecionarCols2" value="check2">Selecionar b
            <input type="checkbox" class="<?php echo $meuCabecalho[$q] ?>3" id="selecionarCols3" value="check3">Selecionar c
            <input type="checkbox" class="<?php echo $meuCabecalho[$q] ?>4" id="selecionarCols4" value="check4">Selecionar d

    <div id="collapse<?php echo $q ?>" class="panel-collapse collapse">

             <?php for($a = 0; $a <5; $a++){ ?>

                    Subitem <?php echo $a ?>
                    <input type="radio" name="subcabecalho<?php echo $x ?>" value="a" class="coluna1">a
                    <input type="radio" name="subcabecalho<?php echo $x ?>" value="b" class="coluna2">b
                    <input type="radio" name="subcabecalho<?php echo $x ?>" value="c" class="coluna3">c
                    <input type="radio" name="subcabecalho<?php echo $x ?>" value="d" class="coluna4">d

             <?php  $x++; ?>
             <?php } ?>

  <?php } ?>

Answer: Use o atributo data do JQuery. Com ele você pode adicionar informações a mais nos seus elementos, além dos já usados id's e classes. Você pode, por exemplo, colocar um atributo "data-item" (tem que ser sempre data-{identificador}) nos checkboxes de cada cabeçalho, identificado eles com o números ou da forma que você desejar. Aí nos radios você coloca também atributos data, pra na hora de selecionar quais devem ser marcados, você pode comparar o atributo do checkbox com os dos radios. Ficaria mais ou menos assim:

$(document).ready(function(){
        // Seleciona elementos cuja classe começa com 'subcabecalho-'
  $("[class^='subcabecalho-']").on("change", function(){
   // Pega o atributo data-item do checkbox, pra saber de qual item(cabeçalho) iremos marcar as colunas
            var item = $(this).data("item");
            // Usamos o valor do checkbox pra saber qual coluna será marcada
   var valor = $(this).val();
        // Seleciona todos os radios com a classe radio-item{numero_do_cabecalho} e que tenham o atributo data = valor concatenado com item, ex: a1, b2, d1... E seta a propriedade "checked" de acordo com o que foi marcado no checkbox
     $(".radio-item"+item+"[data-item='"+valor+item+"']").prop("checked", $(this).prop("checked"));
    });

});

Item 1

<input type="checkbox" class="subcabecalho-item1" data-item="1" value="a"> a
<input type="checkbox" class="subcabecalho-item1" data-item="1"  value="b"> b
<input type="checkbox" class="subcabecalho-item1" data-item="1"  value="c"> c
<input type="checkbox" class="subcabecalho-item1" data-item="1"  value="d"> d

  Subitem 1
  <input type="radio" class="radio-item1" data-item="a1" value="a">
  <input type="radio" class="radio-item1" data-item="b1"  value="b">
  <input type="radio" class="radio-item1" data-item="c1" value="c">
  <input type="radio" class="radio-item1" data-item="d1" value="d">

  Subitem 2
  <input type="radio" class="radio-item1" data-item="a1" value="a">
  <input type="radio" class="radio-item1" data-item="b1" value="b">
  <input type="radio" class="radio-item1" data-item="c1" value="c">
  <input type="radio" class="radio-item1" data-item="d1" value="d">

  Subitem 3
  <input type="radio" class="radio-item1" data-item="a1" value="a">
  <input type="radio" class="radio-item1" data-item="b1" value="b">
  <input type="radio" class="radio-item1" data-item="c1" value="c">
  <input type="radio" class="radio-item1" data-item="d1" value="d">

Item 2

<input type="checkbox" class="subcabecalho-item2" data-item="2" value="a"> a
<input type="checkbox" class="subcabecalho-item2" data-item="2" value="b"> b
<input type="checkbox" class="subcabecalho-item2" data-item="2" value="c"> c
<input type="checkbox" class="subcabecalho-item2" data-item="2" value="d"> d

  Subitem 1
  <input type="radio" class="radio-item2" data-item="a2" value="a">
  <input type="radio" class="radio-item2" data-item="b2" value="b">
  <input type="radio" class="radio-item2" data-item="c2" value="c">
  <input type="radio" class="radio-item2" data-item="d2" value="d">

  Subitem 2
  <input type="radio" class="radio-item2" data-item="a2" value="a">
  <input type="radio" class="radio-item2" data-item="b2" value="b">
  <input type="radio" class="radio-item2" data-item="c2" value="c">
  <input type="radio" class="radio-item2" data-item="d2" value="d">

  Subitem 3
  <input type="radio" class="radio-item2" data-item="a2" value="a">
  <input type="radio" class="radio-item2" data-item="b2" value="b">
  <input type="radio" class="radio-item2" data-item="c2" value="c">
  <input type="radio" class="radio-item2" data-item="d2" value="d">

Comment: Era isso mesmo! Muito obrigada, Renato.


How to show the smooth map $f : T^2 \to S^3$ is an orientation-preserving diffeomorphism?

Question:
Let $f : T^2 \to S^3$ be the smooth map of a 2-torus into $S^3$.
  Let $\omega$ be a closed 2-form on $S^3$.
  Show that $$\int_{T^2}f^*\omega = 0.$$

So apparently, if I can use the theorem on Guillemin and Pollack's Differential Topology, so I change $\int_{T^2}f^*\omega$ to $\int_{S^3}\omega$ then I can prove it by Stokes Theorem.

Theorem [Page 168]
  If $f: Y \to X$ is an orientation-preserving diffeomorphism, then
  $$\int_X \omega =  \int_Y f^* \omega$$
  for every compactly supported, smooth $k$-form on $X$ ($k = \dim X = \dim Y$).

However, the problem is, how can I justify $f$ is an orientation-preserving diffeomorphism?
Thank you. :-)
Comment: $T^2$ is $2$-dimensional and $S^3$ is $3$-dimensional, so how can $T^2$ and $S^3$ possibly be homeomorphic, let alone diffeomorphic via an orientation-preserving diffeomorphism?
Comment: Oops, seems I am trying to use the wrong theorem..@BranimirĆaćić
Answer: The first fact you need to know is that every closed $2$-form on $S^3$ is exact. If you're happy with algebraic topology, then this is precisely the fact that $H^2_{\text{dR}}(S^3) = 0$. Hence, $\omega = d\eta$ for some $1$-form $\eta$ on $S^3$.
The second fact you need to know is that taking pullbacks commutes with taking exterior derivatives. Hence,
$$
 f^\ast \omega = f^\ast d \eta = d f^\ast \eta.
$$
Now, applying this last observation, observe that
$$
 \int_{T^2} f^\ast \omega = \int_{T^2} d f^\ast \eta.
$$
So, what is $\partial T^2$, and what does this imply about $\int_{T^2} d f^\ast \eta$?


Purpose of the adfssrv-service

Question: The setup for ADFS 2.0 installs a new service adfssrv in addition to the ADFS website.
What is the purpose of this service? The documentation does not contain any information about it.
Answer: This is the adfs service. This service publishes the endpoints that one communicates with. So when you request federation metadata, the service responds. See ADFS console's service/endpoints for a list of URLs that are handled by this service.
The website is merely used to serve the web pages for /adfs/ls virtual directory for purposes like home realm discovery.
This is a key difference from the old ADFS 1.0 included in-box with the OS. That runs as a web application in IIS. The new version 2.0 is a separate service.

Purpose of the adfssrv-service


How to grant access to salesforce account using sign-in page

Question: I'm working on developing an application that retrieves reports from Salesforce. I aim to create a functionality similar to what can be found on dataloader.io
On this website, they present a Salesforce login page where users are required to provide their email, password, and domain for authentication. It's important to note that the user hasn't configured any specific settings in their Salesforce account, and there are no connected apps set up from the user's end.
After entering these credentials, the website grants access for the user to proceed.

My question is, what type of authentication method is being used in this scenario,
How can I implement the same in my Node.js application?
Answer: There still is "a" connected app in play, you just don't control it. Data loader.io people do, in their own org. Perhaps a simple developer edition.
You say "It's important to note that the user hasn't configured any specific settings in their Salesforce account" but that's not true. On 1st login the user got the consent screen, informing that the app will see email, data, able to do things on behalf of the user, maybe even log in without him using refresh token...
Go to your user's page in setup, where login history is. You'll see the app both in logins and above, in OAuth apps you authorised to access your data. This is also where you can revoke the access + admins have tools to mass block apps.
You don't need to install an app (like say managed package) to use it. Think of it like making my awesome mobile app powered by SF - it'd be very stupid to bundle android/ iOS app with oauth consumer keys and secrets for every org that wishes to use it...
Have a look whether these help: Sitecore - How to get User ID if the user was logged in using external identity provider (Salesforce SSO)
How to access multiple salesforce orgs with same connected app
Comment: Thanks for your explaination, and 100% you are correct. actually my application will be used inside my organization only. not outside. it is for internal use only. thats why i am trying to figure out how to authenticate and sending api to collect the data without adding application id inside connected app for each user.  also i see we are using microsoft SSO to authenticate with SF.
Comment: Make a connected app in production anyway (you can use production key & secret to connect in other org's incl sandboxes). Think if you want 1 dedicated integration user connecting at backend (easy but bit messy when it's time to pull "my accounts" etc) or everybody logging in themselves in the browser (azure active directory doesn't matter, it'll still work). Plan at least 2 buttons in the app that will pull data from SF ∏ and sandboxes. https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_web_server_flow.htm&language=en_US&type=5 is prob best for you


Galois group and intermediate fields for splitting field of $ x^3 -7 $

Question: I'm trying to do the following exercise:
find the Galois group $ G(E/\mathbb{Q}) $, where $ E $ is the splitting field of $ x^3 - 7  $, all its subgroups and the intermediate subfields $ E^H $ (subfields of $ E $ which are fixed by $ H \subset G $).
Of course $ E = \mathbb{Q}(\sqrt[3]{7}, \varepsilon_3)$, where $ \varepsilon_3 $ denotes the primitive root of unity of degree $ 3 $
The degree of this extension is $ 6 $ and I am able to find two automorphisms of $ E/\mathbb{Q} $ which do not commute, hence $ G \simeq S_3 $, since there are only two groups of order $6 $.
I know the subgroup structure of $ S_3 $ - all its proper subgroups are cyclic.
Is there a more elegant way to find all the intermediate subfields other than just checking which elements are fixed by every automorphism?
I'd appreciate some help with that.
Comment: You can show that the Galois group G is $S_3$. It is easy to see that it has degree 6($Q(\sqrt[3]7)$ is real) and $G$ embeds into $S_3$ since it permutes the $3$ roots..
Answer: You know that $x^{3}-7$ is irreducible over $\mathbf{Q}$ so the Galois group acts transitively on the set of roots, so $\mathbf{Q}(\sqrt[3]{7})$,$\mathbf{Q}(\zeta_{3}\sqrt[3]{7})$, $\mathbf{Q}(\zeta_{3}^{2}\sqrt[3]{7})$ are subfields of degree 3. And you know that these correspond to the subgroups of order 2 of $S_{3}$, and $S_{3}$ has exactly three such subgroups. Now $\mathbf{Q}(\zeta_{3})$ is a subfield of degree 2, and hence corresponds to a subgroup of order 3 in  $S_{3}$, and $S_{3}$ has a unique such subgroup.
Comment: Thank you. I'm wondering what happens if I substitute $ \mathbb{Q} $ with $ \mathbb{Q}(i) $. Then the polynomial $ f $ is still irreducible and I think that this (my and your) argument still holds. Am I right or does something crucial change?
Comment: Jup, I still think so, but the subfields will be $\mathbf{Q}(i)(\zeta_{3}) \cdots$


Does X orthogonal to Z and Y orthogonal to Z imply XY orthogonal to Z?

Question: Assume X orthogonal to Z and Y orthogonal to Z (but X and Y potentially correlated), can you conclude T=XY orthogonal to Z ?
Comment: Could you be more specific about what you mean by "orthogonal"?  A result like the one you inquire about is plausible when it means *independent* but otherwise is not.
Answer: No, one cannot conclude that.
Let $ X = \{-1, 0, 1 \}$ with equal probability;
$Y = 2X$;
$Z = X^2$
$Cov(X,Z) = 0 $
$Cov(Y,Z) = 0 $
$Cov(XY,Z) \neq 0 $
Helpful Links:

Linear Independence, Orthogonality, Uncorrelated
This question
Answer: No, assume $Y=X$ be Rademacher distributed, and $Z$ is independent of others having non-zero mean. Then , $E[XYZ]\neq 0$.
Comment: orthogonality does not mean uncorrelated
Comment: This is not a counterexample - $\mathbb{E}[XYZ] - \mathbb{E}[XY] \mathbb{E}[Z] = 0$ in this  case. (Equivalently, $XY$ is a constant, which is of course uncorrelated to anything. Or - $Z$ is independent of $X$ and $Y$, and so of $XY$, and so has to be uncorrelated to $XY$).
Comment: I guess you're right. Also, on re-reading, I find my comment above quite obnoxious. My apologies.
Comment: not at all, it's a discussion
Answer: The answer is No.  Consider this counter-example:
Let $Z$ take on 4 possible values $(2, 1, -1, 2)$ with equal probability of 0.25.
Let $X = 1, 0, 1, \frac12$ when $Z = 2, 1, -1, 2$ respectively. Let $Y = X$.
Easy to show that $Cov(X, Z) = E(XZ) = 0$ and likewise $Cov(Y, Z) = E(YZ) = 0$, but
$Cov(XY, Z) = E(X^2Z) \ne 0$.
Answer: I could be completely misunderstanding this, but consider a book. The spine is orthogonal to the base of the pages, but you can open the book to (almost any angle).


What should I study real analysis or calculus?

Question: So I can do elementary single variable calculus (except series), also I am familiar with $\varepsilon$-$\delta$ definition of the limit, and also read the definition of  Darboux integral, but don't remember it fully. I want to self-study more by myself. And I don't know whether I should choose some not so rigorous calculus book (which maybe includes some multivariable calculus) but which will teach to do examples or some rigorous real analysis book. So what would you suggest me to choose and what book would you suggest?
Thanks in advance.
Comment: Seems like an opinion-based question. Also your requirement is not sufficient in your statement.
Comment: This is much of a personal favor, but I would recommend you learning some multivariable calculus first. There are two reasons. 1. You cannot do mathematics without a strong computation abillity (unless you are Grothendieck). 2. Some part of real analysis would make more sense if you are familiar with multivariable calculus.
Comment: I love Abbot's "understanding analysis"
Answer: I am italian, and the usual program in our university starts more or less directly with Mathematical Analysis. However, in high school we learn basic (really basic) calculus rules.
According to your description, I would suggest to review your knowledge of calculus, and to get acquainted with advanced calculus (functions of several real variables). You should move on to Mathematical Analysis once you know by heart all the besic definitions of calculus (limits, continuity, derivative, integral).
I like Serge Lang's books (published by Springer-Verlag), but the celebrated books by Tom Apostol (three volumes on calculus) could be a good choice. If you feel ready to learn some hard mathematical analysis, with rigorous proofs of everything, you can read Walter Rudin's Principles of mathematical analysis.


Matrices of the form $A=(x_i x_j)_{i,j}$

Question: For some matrices that have a special form (e.g. Vandermonde matrices) there are simple, explicit expressions for their inverse available. A situation I ran into recently deals with matrices of the type $$A=(x_ix_j)_{i,j}=x\cdot x^T $$ where $x$ is a vector in $\mathbb{R}^n$. Are there similar formulas available?
Answer: The rank of $x\cdot x^t$ is at most $1$ because every column is a multiple of $x$, so it's not invertible.