RubyFlow : The Ruby Community Blog

Home   Submit   Sign Up   Log In   leaders   Twitter   RSS Feed  
 

flyerhzm — 95 posts

http://huangzhimin.com

synvert is a very interesting project we are working on now, it can parse your ruby source code, find out old deprecated ruby code and then automatically replace them with new better syntax ruby code according to predefined rules.

We already define 4 snippets (predefined rules),

1. use FactoryGirl short syntax, e.g. replace FactoryGirl.create(:post) with create(:post)
2. convert dynamic finders, e.g. replace User.find_all_by_login_and_active('name', true) with User.where(login: 'name', active: true)
3. use strong_parameters, remove attr_accessible in models and add def xxx_params; end in controllers
4. automatically upgrade rails 3.2 to rails 4.0

synvert is still in alpha stage, any suggestions or pull requests are welcome.
upgrade to capistrano3  blog.huangzhimin.com
I just wrote a new blog post upgrade to capistrano3, it was a big change.
rails_best_practices 1.14.0 released  rails-bestpractices.com
I just released rails_best_practices 1.14.0, adding default_scope is evil check, see more here.
it's my new blog post, http://huangzhimin.com/2013/06/18/how-to-upload-and-download-large-files-on-heroku-with-s3/
My talk at RedDotRubyConf 2013: building asynchronous apis
There are many ruby / rails conferences every year, like RubyConf, RailsConf and JRubyConf, a lot of great sessions. I built an ios app named ConferencesBox which collects ruby and rails conferences' videos and slides, so that you can watch them on your iphone or ipad, try it now.
The most popular redis failover solution for ruby is redis_failover based on ZooKeeper, I implemented another automatic redis master/slave failover solution, called redis-sentinel, which is based on Redis Sentinel.
newrelic-grape released  huangzhimin.com
I released newrelic-grape gem to add newrelic instrumentation into grape, the micro frameword for creating REST-like APIs. I also wrote a blog post to introduce.
I shared my story to fix a ruby symbol memory leak in grape gem, it also told you one way to detect the memory leak.
JRuby at OpenFeint - a JRuby migration success story
rails_best_practices 1.12.0 released  rails-bestpractices.com
I just released rails_best_practices 1.12.0, it added NotRescueExceptionCheck, see more here.
switch_user 0.9.0 released  huangzhimin.com
switch_user 0.9.0 released, it provides a convenient way to switch current user that speeds up your development and reproduce user specified error on production, check out the release post, thank Luck Cowell for great contributions
newrelic-rake 1.0 released  huangzhimin.com
If you are using newrelic and you have some background jobs (like cron jobs) calling rake tasks, be sure to checkout newrelic-rake 1.0 gem, it adds the newrelic instrument to your rake tasks. and here is my post to show you some screenshots.
avoid using rubyzip  huangzhimin.com
I just posted a new blog avoid using rubyzip, it's a real story on our project, it tells you using zip shell instead of rubyzip can reduce a lot of allocated objects and save much gc time.
rails_best_practices 1.11.0 released  rails-bestpractices.com
I just released rails_best_practices 1.11.0, it's a big improvement, including code analyzer module extraction and disabling some checkers by default, check out details here.
I'm working on extracting code analyzer module from rails_best_practices gem these days, now it's on github, code_analyzer. And here is the document teaching you how to use it.
I just wrote a new post Split your cap tasks into different files, which shows you a way to organize your cap tasks cleaner and reusable.
rolling out with feature flags  rails-bestpractices.com
I just wrote a new post rolling out with feature falgs, it allows you release features with turn on/off switchers, you can use it for a/b testing, performance verification and solve external dependencies.
how to write a jruby gem  huangzhimin.com
Here are my serial posts to introduce how to write a jruby gem.

part 1 and part 2
I just released jruby-memcached 0.5.0, it fixes increment/decrement issue, adds Memcached::ATimeoutOccurred error and exception_retry_limit. Check out more details here
I just released jruby-memcached 0.4.0. Now it runs as a daemon thread, adds a rails cache_store, and makes full use of jruby annotations. Check out more details here
I just released jruby-memcached 0.3.0, I have rewritten it by pure java code, about 10%-20% faster than 0.2.0, check out details here
I just released jruby-memcached 0.1.0 gem, fastest memcached client in jruby, and it is compatible with evan's memcached gem, which is the fastest memcached client in MRI, check it out here
rails_best_practices 1.10.0 released  rails-bestpractices.com
rails_best_practices gem 1.10.0 released, it added 3 new checkers, HashSyntaxCheck, LongLineCheck and UseParenthesesInMethodDefCheck, check out more here
If you are using workling and newrelic, be sure to checkout newrelic-workling 1.0 gem, and my post
I just released rails-brakeman.com, it is an online service to find security issues in your rails projects, it works based on Justin's great gem brakeman.

Rails developers always write code fast, but sometimes they leave some security issues in their rails project. Do you still remember mass assignment issues from github? Using rails-brakeman service can help you find out potential security issues before pushing them on production.
bullet is designed to help you reduce the number of db queries, I just released gem bullet 4.0.0, it supports mongoid now, I also wrote a post to tell you the details.
use after_commit  rails-bestpractices.com
Most developers use AR callbacks after_create/after_update/after_destroy to generate background job, expire cache, etc., but they don't realize these callbacks are still wrapped in database transaction, they probably got unexpected errors on production servers. I wrote a post to suggest you that you should use after_commit for those callbacks that no need to execute in one transaction.
I just created a new post master slave replication in rails to introduce maser slave replication, how to use in rails, and the solution to replication lag.
bullet 2.3.0 released  huangzhimin.com
bullet is a gem to help you increase your application's performance by reducing the number of sql requests it makes. bullet 2.3.0 got 10% performance improved for activerecord 3.0.12, it works much faster, bullet for ar 3.1.4 is 48% faster than for ar 3.0.12, and for ar 3.2.2 is 40% faster than for ar 3.0.12, check out the changelog here.
It has been a long time coming, but switch_user 0.7.0 finally supports restful_authentication. switch_user gem provides a convenient way to switch current user that speeds up your development and reproduce user specified error on production.
I just released a gem multiple_mailers, it extends actionmailer to allow one smtp account per mailer class. I also wrote a blog post to explain.
rails_best_practices 1.9.0 released  rails-bestpractices.com
I just released rails_best_practices 1.9.0, it adds "protect mass assignment" check, helps you avoid being hacked like github, check out the changelog here
rails_best_practices 1.8.0 released  rails-bestpractices.com
I just released rails_best_practices 1.8.0, it adds not use time_ago_in_words check, provides better foreign key and routes analyzer, etc., check out the changelogs here
Not use time_ago_in_words  rails-bestpractices.com
Rails provides helper method time_ago_in_words to calculate the time distance, but it's not good, we should use client side solution instead, Not use time_ago_in_words
I moved two repositories rails_best_practices and rails-bestpractices.com from my personal account to railsbp organization on github, https://github.com/railsbp/rails_best_practices and https://github.com/railsbp/rails-bestpractices.com
rails_best_practices 1.7.0 released  rails-bestpractices.com
I just released rails_best_practices 1.7.0, it supports slim template engine and mongomapper now, check out the changelogs here
I just released bullet 2.1.0, bullet helps you to kill N+1 queries and unused eager loading, it's a long delay but finally it support rails 3.1.
rails_best_practices 1.6.0 released  rails-bestpractices.com
I just launched rails_best_practices 1.6.0, it adds remove unused methods in helpers check, add mercurial support, check out the changelogs here
rails_best_practices 1.5.0 released  rails-bestpractices.com
I just launched rails_best_practices 1.5.0, it supports mongoid and cells, implements a better erb parser, check out the changelogs here
rails_best_practices 1.4.0 released  rails-bestpractices.com
I just launched rails_best_practices 1.4.0, it adds RemoveUnusedMethodsInControllersCheck, check out the changelogs here.
rails_best_practices 1.3.0 released  rails-bestpractices.com
I just launched rails_best_practices 1.3.0, it adds new option --with-git to display git commit and git author in html format and enable RemoveUnusedMethodsInModelsCheck by default, check out the changelogs here.
use cells to abstract view widget  rails-bestpractices.com
I just wrote a post use cells to abstract view widgets, it tells you how cells gem make your view code more reusable, testable and cacheable.
optimize db migration  rails-bestpractices.com
I just wrote a post optimize db migration to merge/optimize db migrations for production deployment.
rails_best_practices 1.1.0 released  rails-bestpractices.com
I have released rails_best_practices 1.1.0, adding "restrict auto-generated routes" check, check out the release announcement.
simple_cacheable gem  rails-bestpractices.com
I just released simple_cacheable gem, it provides the cache apis for find(id), find_by_xxx, instance method and association, here is an introduction blog post.
I just released rails_best_practices gem 1.0.0, rewriting the parser by ripper, which perfectly supports ruby 1.9 (json hash), version 1.0.1 fix an error about line number of constant node, release note is here. I also wrote a blog post use ripper instead of ruby_parser to share my knowledge.
I have released rails_best_practices 0.9.0 and 0.10.0, adding "remove empty helpers" and "remove tab" checks, check out the gem here.
rails_best_practices 0.9.0 released  rails-bestpractices.com
I just released rails_best_practices 0.9.0, it supports remove empty helpers check, see more here.
Post jobs on rails-bestpractices.com  rails-bestpractices.com
I'm glad to say that job board has been added to rails-bestpractices.com, you can post ruby/rails related jobs on it, it's free now. I hope companies can find good rails developers and rails developers can find good rails jobs on it, it's a win-win.
I just wrote a post split route namespaces into different files, it makes your routes much easier to maintain.
rails_best_practices 0.8.0 released  rails-bestpractices.com
I just released rails_best_practices 0.8.0, it supports simplify render in views check and simplify render in controllers check, and fix a few bugs, see more here.
rails_best_practices 0.7.4 released  rails-bestpractices.com
rails_best_practices 0.7.4 released, it brings SchemaPrepare, which makes reviews more accurate, see more here.
I have written a serial of posts to introduce my experience how to upgrade mongoid from 2.0.0.beta.19 to 2.0.0.rc.7, check them out here.
rails_best_practices 0.7.2 released  rails-bestpractices.com
I just released rails_best_practices 0.7.2, it allows writing your own check list, I believe you will like it, see more here.
My recent blog post tells you how I migrated authentication system from authlogic/authlogic-connect to devise/omniauth for rails-bestpractices.com
rails_best_practices 0.7.0 released  rails-bestpractices.com
I just released rails_best_practices 0.7.0, it adds remove trailing whitespace check and use multipart/alternative as content_type of email check support, I also did some refactorings and added better html output support. See more changelogs here.
I have rewrited my custom blog, using jekyll and disqus, so the first new blog post introduce how to use jekyll and some extensions/plugins, and alos two scripts to migrate old posts to jekyll and migrate old comments to disqus
I just released mongoid-eager-loading 0.3.0, I fixed a big issue and made it work well with latest mongoid, it gives a great performance improvement for queries with association.
Develop and Autotest your rubygem  rails-bestpractices.com
I just wrote two articles to share my experience to develop and autotest a rubygem, one is Using bundler and rvm to build a rubygems and the other is Autotest your rubygem, hope they are helpful to you.
rails_best_practices 0.6.0 released  rails-bestpractices.com
I just released rails_best_practices 0.6.0, I did a lot of refactorings, created rdoc webiste and google group, check out the announcement here.
comment your magic code  rails-bestpractices.com
My recent post Comment your magic codes, it said you have to write comments for your metaprogramming codes to make it easy to read for other developers, and it also gives two good comment examples.
Simplify render in views  rails-bestpractices.com
my recent post Simplify render in views shows you the more simplified syntax for render helper which introduced from rails 2.3.
remove trailing whitespace  rails-bestpractices.com
my recent post remove trailing whitespace tells you don't make noises in git commits.
Use memoization  rails-bestpractices.com
This is my new post Use memoization to speed up function calls, and in the comments, I also give a short description about the memoize internal implementation in rails.
rails_best_practices 0.5.0 released  rails-bestpractices.com
I have released rails_best_practices 0.5.0, it adds the use query attribute checker.
Inspired from hobo, switch_user provides a convenient way to switch current user that speeds up your development, so that you don't waste your time to logout, login and input email (login) or password any more. It can help you reproduce the user specified error in production as well.
I just released my new gem mongoid-eager-loading, adds the eager loading feature for mongoid.
Select specific fields for performance  rails-bestpractices.com
I wrote an article Select specific fields for performance, it tells you that selecting specific fields can speed up the query and save memory for you.
I have released rails_best_practices 0.4.5, it adds the use say_with_time in migrations checker.
Use query attribute  rails-bestpractices.com
I have wrote an article Use query attribute, it gives you a hint that you should use query attribute to simplify check if ActiveRecord's attributes exist or not.
I have released rails_best_practices 0.4.4, it adds the dry bundler in capistrano check.
I have released rails_best_practices gem 0.4.1, it uses rvm and bundler to setup the development and test environment, adds progressbar and colored output for analyzing result.
Generate polymorphic url  rails-bestpractices.com
I have wrote an article Generate polymorphic url, it gives you a hint that you should use the polymorphic_path/polymorphic_url to simplify the polymorphic url generation.
Use batched finder for large data query  rails-bestpractices.com
I have wrote an article Use batched finder for large data query, it tells you how to save memory when querying large data.
DRY bundler in capistrano  rails-bestpractices.com
I have wrote a article DRY bundler in capistrano, it just gives you a notice that there are built-in capistrano tasks existed in Bundler 1.0.
Put scripts at the bottom  rails-bestpractices.com
I wrote an article Put scripts at the bottom, it is a small trick, but really helpful to speed up the pages render. I also give an example for adding a tweet button on your pages
Fetch current user in models  rails-bestpractices.com
I wrote an article Fetch current user in models, you may know it, but this technique is useful for new comer.
http://rails-bestpractices.com added a new feature, asking for best practices, it allows users to ask for a best practice about any rails-related work, such as "How to detect N+1 queries?" and "How to upload a large file with progress bar?". Then everyone can post your answer with your own best practice solution to the questions. Check it here.
I wrote an article Use STI and polymorphic model for multiple uploads, it provides a flexible and reusable solution for multiple uploads by using paperclip.
I have released rails_best_practices 0.4.0, rails_best_practices is a code metric tool for rails codes, from 0.4.0, it can check the rails3 codes better.
In addition, if you want to add your rails best practices into the gem, please post your best practices on http://rails-bestpractices.com
I wrote an article about using multipart/alternative as content_type of email. Rails uses plain/text as the default content_type for sending email, you should change it to multipart/alternative that email clients can display html formatted email if they support and display plain text email if they don't support html format. Check it here.
rails-bestpractices.com is now launched  rails-bestpractices.com
I'm glad to say http://rails-bestpractices.com is now launched. It's a website that provides the best practices to write rails codes and anybody can share his/her practices. It's also the home page of rails_best_practices gem. ihower is also the administrator who is the presenter of Rails Best Practices presentation. Welcome to share your practices here.
I just released bullet 2.0.0.beta.3 gem, which is aimed to kill N+1 queries and unused eager loadings. It is compatible with rails 3.0.0.beta4 now. With sriedel's help, a lot of refactors are done, and xmpp notification is added. Enjoy it!
I have released resque-restriction 0.2.0, which is mainly contributed by @wr0ngway, fixing some bugs and adding customized identifier for resque queue. I also added an example on README.markdown about how to restrict facebook wall posts 40 times per user per day.
I have a few repositories on github. Several of them have issues, but it's not convenient for me to browse the issues from one repository to another. So I build a website Github Issues to fetch all my issues on github in one page after I type my github username.
resque-restriction  github.com
I have posted a resque plugin, resque-restriction. It will limit the execution number of certain jobs in a period time and execute the exceeded jobs at the next period. It is especially useful when a system has an email invitation resque job, because sending emails too frequently will be treated as a spam. For example, resque-restriction can restrict the email invitation job not execute more than 1000 times per day, 100 times per hour and 30 times per 300 seconds.
css sprite best practices  huangzhimin.com
I have written a post css sprite best practices. Following the practices, you will be saved from dull css sprite job. It also tells you how to automatically do the css sprite job by using my css_sprite gem.
I just released twitter_connect gem. It popups a window to authenticate twitter oauth, like facebook connect, which is especially suit for the application in iframe or you don't want user leave your website. There is also a demo, check it here
I just upgraded bullet gem to version 2.0 beta, which supports rails3 beta. Bullet gem helps you to kill N+1 queries and unused eager loading.
I just launched seo_checker, which checks your website if it is seo. It mainly checks the url, title and descripion of web page according to the sitemap.
RubySlide.com  rubyslide.com
RubySlide.com, inspired by RubyTu.be, gathers all the latest Ruby slides and presentations in one convenient place!
I have forked metric_fu and add rails_best_practices to it. rails_best_practices is a great gem to check your rails app codes and give you some good suggestions for better rails codes. Check the flyerhzm-metric_fu for your rails app.
ihower introduced his Rails Best Practices presentation before, my rails_best_practices gem is used to automatically check your rails app files according to his presentation.
The flyerhzm-bullet gem is designed to help you increase your application’s performance by reducing the number of queries it makes. It will watch your queries while you develop your application and notify you when you should add eager loading (N+1 queries) or when you’re using eager loading that isn’t necessary.
It also provides some notification, such as javascript alert, browser console.log, bullet log, rails log and growl.

I think you will really like it.