You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Finding something like `if ( ready? && set? ) { fight! };` in Ruby
Right now, the tagline-code-snippet thing on Codebrawl is if ( ready? && set? ) { fight! };. While this looks nice, this is not valid Ruby code.
So, I'm looking for something better. It should be Ruby, and it should look cool. If you have an idea, please fork the Gist and add it to the list below. Thanks! :)
ready? && set? && fight!
if ( ready? && set? ) then fight! end
( ready? && set? ) ? fight! : nil
Minification with newlines using the Rails 3 asset pipeline
Retaining line numbers with the Rails asset pipeline
By default the Rails 3 asset pipeline uses the Uglifier gem to optimize and minify your Javascript. One of its many optimisations is to remove all whitespace, turning your Javascript into one very long line of code.
Whist removing all the newlines helps to reduce the file size, it has the disadvantage of making your Javascript harder to debug. If you've tried to track down Javascript errors in minified Javascript files you'll know the lack of whitespace does make life harder.
Luckily there is a simple solution: to configure Uglifier to add newlines back into the code after it performs its optimisations. And if you're serving your files correctly gzip'd, the newlines add only a small increase to the final file size.
You can configure Uglifier to add the newlines by setting the following in your Rails 3 config/production.rb file:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters