What characters can be used for up/down triangle (arrow without stem) for display in HTML?

Unicode arrows heads: ▲ – U+25B2 BLACK UP-POINTING TRIANGLE ▼ – U+25BC BLACK DOWN-POINTING TRIANGLE ▴ – U+25B4 SMALL BLACK UP-POINTING TRIANGLE ▾ – U+25BE SMALL BLACK DOWN-POINTING TRIANGLE For ▲ and ▼ use ▲ and ▼ respectively if you cannot include Unicode characters directly (use UTF-8!). Note that the font support for the smaller … 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 understand symbols in Ruby

Consider this: x = :sym y = :sym (x.__id__ == y.__id__ ) && ( :sym.__id__ == x.__id__) # => true x = “string” y = “string” (x.__id__ == y.__id__ ) || ( “string”.__id__ == x.__id__) # => false So, however you create a symbol object, as long as its contents are the same, it will … 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

How to deal with symbol collisions between statically linked libraries?

At least in the case of static libraries you can work around it quite conveniently. Consider those headers of libraries foo and bar. For the sake of this tutorial I’ll also give you the source files examples/ex01/foo.h int spam(void); double eggs(void); examples/ex01/foo.c (this may be opaque/not available) int the_spams; double the_eggs; int spam() { return … Read more

What is the motivation for bringing Symbols to ES6?

The original motivation for introducing symbols to Javascript was to enable private properties. Unfortunately, they ended up being severely downgraded. They are no longer private, since you can find them via reflection, for example, using Object.getOwnPropertySymbols or proxies. They are now known as unique symbols and their only intended use is to avoid name clashes … Read more

How to convert characters to HTML entities using plain JavaScript

With the help of bucabay and the advice to create my own function i created this one which works for me. What do you guys think, is there a better solution somewhere? if(typeof escapeHtmlEntities == ‘undefined’) { escapeHtmlEntities = function (text) { return text.replace(/[\u00A0-\u2666<>\&]/g, function(c) { return ‘&’ + (escapeHtmlEntities.entityTable[c.charCodeAt(0)] || ‘#’+c.charCodeAt(0)) + ‘;’; }); … 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