Skip to content

Instantly share code, notes, and snippets.

View rxaviers's full-sized avatar

Rafael Xavier de Souza rxaviers

View GitHub Profile
Create a new directory and copy `index.html` into it. Then, enter the directory and run:
```
bower install jquery#1.x cldr#1.x
wget http://www.unicode.org/Public/cldr/latest/json.zip
unzip json.zip -d cldr
python -m SimpleHTTPServer
```
Point your browser to `localhost:8000` and see the output on your javascript console.
@rxaviers
rxaviers / gist:f3e89211b47bf36fc4a2
Last active August 29, 2015 14:01
Talks about Globalize, Cldr.js, plural and messages

Let's consider the following data.

{
  "main": {
    "en": {
      "units": {
        "long": {
          "per": {
            "compoundUnitPattern": "{0} per {1}"
 },
@@ -6,8 +6,6 @@
*/
(function($) {
-var triggerChangeDelay = 200;
-
$.fn.farbtastic = function (options) {
$.farbtastic(this, options);
return this;
@@ -192,14 +190,7 @@
@rxaviers
rxaviers / README.md
Last active August 29, 2015 14:02
bower: unable to define different versions of the same package on dependencies vs. devDependencies

Differently than npm, bower doesn't allow having different versions of the same package on dependencies vs. devDependencies.

Such scenario isn't very common. But, it's needed on jQuery UI due to testing and demo purposes:

For this simplified testcase, I added a reduced bower.json and a reduced

@rxaviers
rxaviers / gist:ffd019c47804b15ace48
Created June 20, 2014 00:42
Example of missing CLDR errors on cldr.js
Error: E_MISSING_CLDR_ITEM: {"path":"a/b/c/missing/item"}
at createError (/tmp/a/node_modules/cldrjs/dist/cldr.js:83:11)
at validate (/tmp/a/node_modules/cldrjs/dist/cldr.js:99:10)
at Cldr.get (/tmp/a/node_modules/cldrjs/dist/cldr/unresolved.js:164:4)
at repl:1:4
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)

Test commands used in this article: (ref http://wiki.jqueryui.com/w/page/59346425/Release%20Checklist)

cd /tmp
git clone git@github.com:jquery/jquery-release.git
cd jquery-release/
node release.js --remote=rxaviers/jquery-ui

1st trial: Error: npm download.jqueryui.com installation failed due to npm version (1.4.10). Needed update. See trial-a.md.

var Globalize = require( "globalize" );
Globalize.load( require( "./likelySubtags.json" ) );
Globalize.load( require( "./sv-numbers.json" ) );
var sv = Globalize( "sv" );
sv.formatNumber( 123456.78 ); // 123 456,78
sv.parseNumber( "123 456,78" ); // 123456.78. obs: copying pasting the above result.
sv.parseNumber( sv.formatNumber( 123456.78 ) ); // 123456.78
sv.parseNumber( "123 456,78" ); // NaN. obs: typing space myself.
/**
* A simplified HTTP request client that accepts glob patterns v@VERSION
*
* Copyright 2013 Rafael Xavier de Souza
* Released under the MIT license
* https://github.com/rxaviers/request-glob/blob/master/LICENSE-MIT
*
* Date: @DATE
*/
@rxaviers
rxaviers / README.md
Last active August 29, 2015 14:07
Example using cldr-data + to filter CLDR files and fields

Consider we have the following application.

.
├── <my application files>
└── bower.json
// bower.json
{
  "dependencies": {
@rxaviers
rxaviers / README.md
Last active August 29, 2015 14:07
SlexAxton/messageformat.js vs. plural functions

Running test.js fails with

undefined:4
  return a(x);
         ^
ReferenceError: a is not defined
    at Object.i18n.lc.fr (eval at <anonymous> (/tmp/node_modules/messageformat/messageformat.js:1428:13), <anonymous>:4:10)
    at Object.i18n.p (eval at <anonymous> (/tmp/node_modules/messageformat/messageformat.js:1428:13), <anonymous>:9:73)
    at eval (eval at <anonymous> (/tmp/node_modules/messageformat/messageformat.js:1428:13), <anonymous>:10:97)

at Object. (/tmp/mf-test.js:13:13)