The goal: Upload several files (virtually big files) to a Rails application without compromising the user experience.
jQuery File Upload + Nginx + Rails (Carrierwave) + Sidekiq
- jQuery File Upload (http://blueimp.github.io/jQuery-File-Upload/)
The goal: Upload several files (virtually big files) to a Rails application without compromising the user experience.
jQuery File Upload + Nginx + Rails (Carrierwave) + Sidekiq
belongs_to association does not automatically save the object. It does not save the associated object either.has_one association, that object is automatically saved (in order to update its foreign key).has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.| $ ruby unique-unordered-pairing-function.rb | |
| Cantor Pairing Function | |
| ----------------------- | |
| <x, y> = (x + y) * (x + y + 1) / 2 + y | |
| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 | |
| + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + | |
| 0 | 0 | 1 | 3 | 6 | 10 | 15 | 21 | 28 | 36 | 45 | 55 | 66 | 78 | 91 | |
A not politically correct assertion of my feelings towards a piece of software:
Note: Repetition builds cynicism, asset_sync isn't bad, but when an asset problem cannot be solved via support it gets escalated to me. Often times someone using asset_sync the problem is due to their use of the library and not from Heroku.
The asset sync gem uploads your assets (images, css, javascript) to S3. From there you can either point browsers to the copy on S3 or use a CDN + the S3 bucket. It's a good idea, and solved a problem at one time.
It is no longer needed and you should now use https://devcenter.heroku.com/articles/using-amazon-cloudfront-cdn instead. So rather than copying your assets over to S3 after they are precompiled the CDN grabs them from your website instead. Here's some reasons why it's better.
| require 'spec/support/grep_matcher' | |
| describe do | |
| disallow_presence_of pattern: "send(.*#", | |
| location: "app/", | |
| description: "Do not use dynamic method invocations", | |
| failure: "Please change dynamic method call to something more sane." | |
| end |
| ## | |
| # by SoAwesomeMan | |
| str =<<-EOS.gsub(/^[\s\t]*|[\s\t]*\n/, '') # no space "\s" for new line "\n"; kill tabs too | |
| select awesome, awesome, awesome, awesome, awesome, awesome, | |
| from rad, rad, rad, rad, rad, rad, rad, rad, rad, rad, rad, | |
| where cool cool cool cool cool cool cool cool cool cool cool' | |
| EOS | |
| # => "select awesome, awesome, awesome, awesome, awesome, awesome,from rad, rad, rad, rad, rad, rad, rad, rad, rad, rad, rad,where cool cool cool cool cool cool cool cool cool cool cool'" | |
| str =<<-EOS.gsub(/^[\s\t]*/, '').gsub(/[\s\t]*\n/, ' ').strip # yes space "\s" for new line "\n"; kill tabs too |
| <?php | |
| /* | |
| * Create New Admin User | |
| * @author Ivan Weiler, Inchoo <web@inchoo.net> | |
| */ | |
| //define USERNAME, EMAIL and PASSWORD and uncomment(#) this 3 lines | |
| #define('USERNAME','inchoo'); | |
| #define('EMAIL','xyz@inchoo.net'); | |
| #define('PASSWORD','inchoo555'); |
Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.
Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.
As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.
Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.
Create droplet of your liking (ubuntu 12.04 x32) Use an xx.04 LTS version
On Digital Ocean, create a DNS entry for your server (xyz.com)
Make sure it has NS records that use digital oceans nameservers