Are you tired of looking at code that looks like this? I know I am!
1 2 3 |
var someVar = 'foo'; $("input[name=" + someVar + "]").val(); $("li[data-foo=" + someVar + "]").val(); |
What’s a better way? My silly little jQuery-where plugin…
1 2 3 |
var someVar = 'foo'; $("input").where("name", someVar).val(); $("li").where("data-foo", someVar).val(); |
It’s a simple chainable jQuery filter plugin which filters by the given attribute with the given value.
admin September 22nd, 2015
Posted In: Projects
Tags: javascript, jquery, plugin
After some consideration, I realized that manually translating a reference system is silly and since having a prefect translation doesn’t really prove anything, I figured it’s time to do some machine translation. One language that we can always perfectly machine translate to, or maybe, one language for which no one will care if translation is correct is… Pig Latin!
Enter xliffPigLatin nodeJS script which will translate the text in your XLIFF files to Pig Latin (en-pl).
1 |
node ./translate {inputFile} {outputFile} |
Demo*: http://laboratorija.com:3000
* if the service is running and if you actually paste in a valid XLIFF file.
Example Input:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<xliff version="1.0"> <file source-language="en" datatype="plaintext" original="messages" date="2011-10-18T18:20:51Z" product-name="my-ext"> <header/> <body> <trans-unit id="headerComment" xml:space="preserve"> <source>The default Header Comment.</source> </trans-unit> <trans-unit id="generator" xml:space="preserve"> <source>The "Generator" Meta Tag.</source> </trans-unit> </body> </file> </xliff> |
Example Output (after a little bit of formatting):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?xml version='1.0' encoding='utf-8'?> <xliff version="1.0"> <file datatype="plaintext" date="2011-10-18T18:20:51Z" original="messages" product-name="my-ext" source-language="en" target-language="en-pl"> <header /> <body> <trans-unit id="headerComment" xml:space="preserve"> <source>The default Header Comment.</source> <target>hetay efaultday eaderhay ommentcay</target> </trans-unit> <trans-unit id="generator" xml:space="preserve"> <source>The "Generator" Meta Tag.</source> <target>hetay eneratorgay etamay agtay</target> </trans-unit> </body> </file> </xliff> |
Updated 10/25/2014: Added output beautification step.
admin October 17th, 2014
Posted In: Projects
Tags: javascript, node, pig latin, xliff
I’m my VERY superficial search, I didn’t find an obvious example of zebra striping with/for/in DustJS, so I wrote this little helper that will return “altRow” or nothing, for alternating rows.
1 2 3 4 |
dust.helpers.altRow = function(chunk, context, bodies, params) { var alt = (context.stack.index %2) ? "" : "altRow"; return bodies.block(chunk, context.push(alt)); }; |
Usage:
1 2 3 |
<tr class="{@altRow}{.}{/altRow}"> <td>...</td> </tr> |
1 2 3 4 5 |
<style> tr.altRow { background: #999; } </style> |
admin May 11th, 2014
Posted In: Misc
Tags: dustjs, javascript, zebra stripes