How to count instances of character in SQL Column

This snippet works in the specific situation where you have a boolean: it answers “how many non-Ns are there?”. SELECT LEN(REPLACE(col, ‘N’, ”)) If, in a different situation, you were actually trying to count the occurrences of a certain character (for example ‘Y’) in any given string, use this: SELECT LEN(col) – LEN(REPLACE(col, ‘Y’, ”))

What is the purpose of the ‘@’ symbol in CSS?

@ has been around since the days of @import in CSS1, although it’s arguably becoming increasingly common in the recent @media (CSS2, CSS3) and @font-face (CSS3) constructs. The @ syntax itself, though, as I mentioned, is not new. These are all known in CSS as at-rules. They’re special instructions for the browser, not directly related … Read more

Why use symbols as hash keys in Ruby?

TL;DR: Using symbols not only saves time when doing comparisons, but also saves memory, because they are only stored once. Ruby Symbols are immutable (can’t be changed), which makes looking something up much easier Short(ish) answer: Using symbols not only saves time when doing comparisons, but also saves memory, because they are only stored once. … Read more

Is there a literal notation for an array of symbols?

Yes! This is possible now in Ruby 2.0.0. One way to write it is: %i{foo bar} # => [:foo, :bar] You can also use other delimiters, so you could also write %i(foo bar) or %i!foo bar! for example. This feature was originally announced here: http://www.ruby-lang.org/zh_TW/news/2012/11/02/ruby-2-0-0-preview1-released/ It is mentioned in the official documentation of Ruby here: … Read more

Enums in Javascript with ES6

Is there a problem with this formulation? I don’t see any. Is there a better way? I’d collapse the two statements into one: const Colors = Object.freeze({ RED: Symbol(“red”), BLUE: Symbol(“blue”), GREEN: Symbol(“green”) }); If you don’t like the boilerplate, like the repeated Symbol calls, you can of course also write a helper function makeEnum … Read more

Is there Unicode glyph Symbol to represent “Search” [closed]

There is U+1F50D LEFT-POINTING MAGNIFYING GLASS (🔍) and U+1F50E RIGHT-POINTING MAGNIFYING GLASS (🔎). You should use (in HTML) 🔍 or 🔎 They are, however not supported by many fonts (fileformat.info only lists a few fonts as supporting the Codepoint with a proper glyph). Also note that they are outside of the BMP, so some Unicode-capable … Read more

What is the colon operator in Ruby?

:foo is a symbol named “foo”. Symbols have the distinct feature that any two symbols named the same will be identical: “foo”.equal? “foo” # false :foo.equal? :foo # true This makes comparing two symbols really fast (since only a pointer comparison is involved, as opposed to comparing all the characters like you would in a … Read more

How to change facet labels?

Here is a solution that avoids editing your data: Say your plot is facetted by the group part of your dataframe, which has levels control, test1, test2, then create a list named by those values: hospital_names <- list( ‘Hospital#1’=”Some Hospital”, ‘Hospital#2’=”Another Hospital”, ‘Hospital#3’=”Hospital Number 3″, ‘Hospital#4’=”The Other Hospital” ) Then create a ‘labeller’ function, and … Read more

Placing Unicode character in CSS content value [duplicate]

Why don’t you just save/serve the CSS file as UTF-8? nav a:hover:after { content: “↓”; } If that’s not good enough, and you want to keep it all-ASCII: nav a:hover:after { content: “\2193”; } The general format for a Unicode character inside a string is \000000 to \FFFFFF – a backslash followed by six hexadecimal … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)