Coffeescript and CakePHP - cakephp

Is there an easy way to use Coffeescript with CakePHP? Rails has Barista, but I haven't been able to find anything similar for CakePHP. Ideally, something transparent that would compile the coffeescript to javascript on-demand, and only when it has changed.
Google results for CakePHP & Coffeescript turn up a lot of talk over a clash between the cake command, but not much in the way of using them together. Has anyone found anything? Or maybe ideas on how I might implement such a plugin myself?

I know this isn't the answer you're looking for, but I usually handle this with a build script, either in Bash or Rake (yes, Rake, its great for building PHP projects too), which compiles, concats and compresses my .coffee files for production. While in development I use coffee -w to compile the .coffee files on the fly.
You could automate this further by adding a post-commit hook to Git or Subversion if you like.
You should be able to extend Mark Story's Asset Compress plugin to do the compiling on the fly as well.

You may want to look at kohana-coffeescript, which to my knowledge is the only project that does what you want in PHP. Although the project is nominally for the Kohana framework, it should be fairly easy to fork it and adapt it to CakePHP.

Related

Flutter Application localization approaches

This article shows 2 approaches for implementing the localization for Flutter apps
https://flutter.io/docs/development/accessibility-and-localization/internationalization
One is using creating files for the l10n and other is simple and direct.
I see that the l10n with the intl dependency is little bit complicated and frustrating for creating files for each lang and 2 terminal commands
and if I need to add a new term I have to go through the commands and files creations.
But anyway both work.
Is one is better than the other?
The variant using the intl package makes it easy to work with translate https://translate.google.com/toolkit.
If you want to use the same code for a web client tree-shaking will work better with this approach for smaller download sizes. I don't think this makes much difference in Flutter.
The downside as you mentioned is, that it needs more boilerplate to get going.

Is there a way I can use angular-generator without yeoman?

Basically what I want is a scaffolding tool (without bower and other stuff that it comes with) and controller, service/factory generators.
Yeoman is great but I was wondering if there's anything minimalist cli out there for angular.
Well, if all you want is a base angular app structure, that is called a boilerplate. There are a few available:
https://github.com/angular/angular-seed
https://github.com/ngbp/ngbp
https://github.com/angular-app/angular-app
However, you seem to also want a controller, service/factory generator. This will always require:
some kind of task runner (like Grunt)
or an IDE that supports templates.
Since you don't seem to like grunt (grunt IS AWESOME), these IDEs might help you...
Eclipse supports template, you can find some here
IntelliJ's PHPStorm or WebStorm have a feature called Live Templates which, IMHO, are far better than eclipse. You can find some premade templates here, but is easy to roll your own, as explained in this tutorial.
If you want a command line interface but not Yeoman's, you might want to have a look at the "Generation" section of this collection. As of today, it has one option that uses Lineman and two that made their own CLI, but they use bower. Anyway, if what you're looking for exists, it should be in there somewhere.

Angular.js beginner: Is Yeoman scaffolding the wrong way to go?

I am trying to add Angular to my arsenal and just started playing around with it this weekend. Looks cool!
In one of the videos done by Google, the guy recommended Yeoman. I'm watching another tutorial video on it now as well: https://www.youtube.com/watch?v=rqdRXqeqgZs
However, it looks like it generates everything (even writes tests for you??). In the video above, to generate a route he ran yo angular:route myroute which generated the controller, route, view, and test. I mean it's great that I get to see the structure, but I wrote like 0 lines of code.
Perhaps I should just start off with something like this where the file structure is way simpler but at least I have to write more lines of code? https://github.com/davidb583/white-angularjs-app
For a beginner, which do you recommend for a first project?
For a beginner to AngularJS, don't check out Yeoman. It's a very useful tool remember, but before you use it, understand why it was built.
Start off with AngularJS's tutorial - it is one of the best tutorials out there. It tells you all that you need to know to explore off on your own. I started out with that and at the end of it, I just loved the entire framework.
I did not start off with Yeoman until building 2-3 applications using AngularJS. Once you do this, you figure out some common tasks that you carry out for every AngularJS application.
That's where Yeoman comes in. Rather than doing the same thing again and again for each application you use Yeoman to automate a lot of stuff. Once you know the why of using Yeoman, you will understand the how of using it.
Without having worked in AngularJS sufficiently, do not try to use Yeoman. You will enjoy the tool but then you will be left wondering how to work with AngularJS without it.
My 2 cents.
To smalls app, Yeoman is awesome. But you will know his limits when you will want to split your app into modules.
with yeoman, you will have a structure like that:
scripts/
controllers
controller1.js
controller2.js
...
directive/
...
But In large app you probably want to have:
scripts/
controllers
userModule
controller.js
myOtherModule
controller.js
...
directive/
...
And for that, you need to create manually all the files.
My advice is to always start with yeoman but use their route/directive/etc generator only at the begining of your project.
For the tests, it only generate a file and a very simple test, ofcourse you need to modify it, to cover your whole app.
In addition Yeoman provide you a lot of tools with grunt like minifications of your assets, a jshint to use the best coding practices, etc.

Using qooxdoo desktop without having to "build" it

in qooxdoo desktop you usually have to develop using the SDK and then "build" your app.
Is there a way to generate something like a qooxdoo.js file with the whole library inside so that you can script script it as you like (like jqueryui or dojo)?
Actually it could be nice to have every widget loaded at runtime like dojo's require("dojo.button") but both the approaches would be nice, just avoiding the build phase.
I hope the question is understandable :)
Thank you everybody!
Don't use the output of the build job to run your code as you develop - as among other things - will minify your code and make debugging very difficult.
If you want to code freely without needing to rebuild when you reference new classes then source-all is the build job for you.
In the root directory of your application, type:
python generate.py source-all
If will include the entire framework in the HTML file generated (you'll find it under source/index.html). This would work well if you are composing the UI from scratch and referencing many new qooxdoo widgets with each browser refresh.
If you add a completely new class of your own, you will need to run the source-all job again to include it.
I use the source build job however for a few reasons:
Habit: source-all didn't exist when I started using qooxdoo
Speed: You can notice a bit of lag it when you refresh the browser to view
your app
References: For a mature app, enough of the framework is
included in the application and its rare to add a new reference and
when you do, its probably in a new class of your own which would
require a re-run of the source job anyway.
I suggest you also look at Default Action Jobs as all the possibilities are explained in detail. Hope this helps.
Please check that thread for a detailed answer: http://qooxdoo.678.n2.nabble.com/Using-qooxdoo-desktop-without-having-to-build-it-td7585015.html;cid=1387453759247-228

Developing and debugging Sencha apps without sencha's paid services

I started working with sample sencha apps. I find it really hard to find typo and errors in my code.
I added the eclipse plugin for auto-complete during coding. Buts its a trial version just like the sencha architect. Am really confused on how the sencha app should be developed.
I want to know the tools that sencha developers are using so that I can deploy and debug effeciently.
Thanks in advance.
The workflow / tools choice when developing an application is a subjective matter so I'm going to talk about my experience, having been a Sencha Touch developer for the last year.
I find it really hard to find typo and errors in my code.
...
Am really confused on how the sencha app should be developed.
This is not a matter of tools in my opinion. Sencha Touch has an unavoidable steep learning curve. You should start with simple examples, and you could ask here when you have specific programming issues (I personally found Sencha Touch forums less useful than stackoverflow).
The most important thing is understanding the basics concepts:
Sencha Touch class system (http://www.sencha.com/learn/sencha-class-system),
How Sencha implements MVC (http://docs.sencha.com/touch/2.2.1/#!/guide/controllers)
(http://docs.sencha.com/touch/2.2.1/#!/guide/views),
Sencha Touch Layouts (http://docs.sencha.com/touch/2.2.1/#!/guide/layouts),
Sencha Touch Components (http://docs.sencha.com/touch/2.2.1/#!/guide/components)
Also all of these guides will be very useful, make sure you understand them and learn to use Sencha Docs, which definetely has some obscure, non explained properties, but should still be your main resource when developing a Sencha Touch app.
Debugging will always be tricky, unfortunately sometimes setting the wrong property on a Component, or misunderstanding how a Component is meant to work, ends up with some obscure var is not defined error. Do not fear to check Sencha Touch source code when this happens, code is well written and usually easy to understand.
Here the tools to use are again Sencha Touch Docs (when hovering on a class title you can examine directly its source code, plus your browser debugging console. Use frequent console.debug() messages, and when something weird happens inside framework classes stop execution with debugger; and step inside source code).
Now back to your question: I have been using the following tools:
NetBeans,
Chrome DevTools,
Chrome Ripple Extension,
Sencha Command (optional)
Compass CSS authoring framework
a couple shell scripts
The IDE is a matter of personal choice, Netbeans has some nice Javascript suggestions: it highlights variables when they are used but not defined in the current scope, or defined but not used, which really helps a lot against typos. It is very heavy in terms of memory usage. I guess Eclipse, or even a lighter one could be equally good.
Chrome is kinda a forced choice if you are on Windows, their DevTools are excellent, make sure you master them, they will be your main working tools. Once again: lot of RAM helps.
Ripple is an invaluable extension that allows you to test your mobile app on different devices and if you are using Phonegap for native deployment it emulates a part of its API on the browser.
Compass is the tool suggested by Sencha to compile their sass files. There is a detailed tutorial on how to setup compass on Sencha Docs.
I have been using Sencha Command but it's not strictly necessary, if you don't care about resources minification (but you should) you will not miss much about it. If you are developing a native app you can make up for the lack of Sencha Command deploy function with a simple shell script that copies html/js/css resources to the assets folder of your Phonegap project.
Another script activates automatically compass watch on the /resources/sass folder at startup, to avoid having to manually do that each time.
Just my two cents, hope it helps.
Anubis covered majority of the bee knees in hand coding Sencha Touch.
I'd like to add a couple more cents into the kitty.
My personal preference for IDE is Sublime Text. Searching through entire projects of code for anything, I've not seen an equal for effectiveness and speed. You can customise everything - especially colours and keybindings. It also has a ludicrous wealth of plugins, including working in correlation to Chrome, as well as Github.
SENCHA GUIDES
Miami Coder Tutorials - great collection of practical tutorials which will help you understand development patterns faster than most other guides. Great for starters.
Figleaf Training can be a little unconventional, but a great free means of learning Sencha Touch and almost everything it is capable of. Great for starters too.
Druck IT - solid collection of guides and ST information. Has links to many other useful sites such as these listed.
Mitchell Simoens - Mitchell is Sencha staff, a quality coder, and his site has some great advice and snippets to help learn. This is where you'll truly learn how to code ST well. Helps towards getting a grasp, but mainly for mid+ knowledge.
Ladysign - one of the Sencha Trainers. Has content that clears up "how to" in many facets other sites and books never even mention. Quality information. This info will get you above basic and flesh out your knowledge and understanding.
Modus Create - Jay Garcia is one of the devs of ST. Modus Create is his enterprise, which contains some useful guides within the blog.
Custom Font Icons - complete guide for 2.2. Very useful.
There's a few other sites that were incredible sources of tidbits through to information on how to code ST professionally. These links above will help immensely though. Above all, read the source code. It is very well documented, as well as being an example in itself of how to use the code. I have learnt ludicrous amounts this way.
GRUNT (with NPM/Node.js)!
Use Grunt! This will automate the vast majority of what you want to do. For example, typing "grunt" in the command line could jshint/jslint your code, concatenate all .js files together, all css files together (including all the compass joy), obfuscate, compress, run a comprehensive set of unit tests (especially Phantom), output to desired location, then add a cherry on top by refreshing your browser window. Add in the grunt watch plugin, and it'll do that every time a file is saved in defined directories. Any bugs in your code - you get accurate specific line numbers where it is broken.
The beauty of grunt is extended by optional alternate commandlines for different tasks. Also, you can specify in the package.json file of a few kB the precise list of plugins you wish to use with the gruntfile you've created, saving megabytes of file transfer. NPM can process that file, and download and install all that is required to operate. Makes for fast setup on another computer.
Side note: Touch Node has come of age. This permits all ST's class structure to develop your serverside javascript.
Want to include Sencha Cmd?
Sencha Cmd (finally) does do a decent job of collecting only the dependent classes from the full library.
grunt-sencha-build
grunt-senchacmd
Alternative for Sencha Cmd
Extend Grunt with Matt Goldspink's grunt-sencha-dependencies which works for both ST and ExtJS, or use grunt-sencha-resolver - this latter one I haven't used.

Resources