@marcosserpa / Marcos Serpa

coding and cooking

Getting local date with Swift

marcosserpa

Here we will see how easy is to get the local date with swift, programming in your app or just using the Playground. I suggest you to use the Playground to test this code and play with the possibilities.

 

import Foundation // If you are using the Playground, you will need to import the Foundation framework

var date = NSDate() // NSDate creates objects that represents a single point in time
let dateFormatter = NSDateFormatter() // NSDateFormatter creates string representations of NSDate objects

dateFormatter.timeStyle = NSDateFormatterStyle.MediumStyle  // From Apple Reference, "Specifies a medium style, typically with abbreviated text, such as 'Nov 23, 1937' or '3:30:32 PM'".
dateFormatter.dateStyle = NSDateFormatterStyle.MediumStyle  // From Apple Reference, "Specifies a medium style, typically with abbreviated text, such as 'Nov 23, 1937' or '3:30:32 PM'".
dateFormatter.timeZone = NSTimeZone(// Get the...

Read more

Asset Pipeline and Heroku with Rails 4

marcosserpa

When I made this blog, I encountered a very common problem to all that develop with Rails 4 and deploy app to Heroku: Asset Pipeline. My assets was not working at all and the trivial methods of resoluting the problem was not working too.

Finally, googling and searching ways to resolve the situation, I found a good solution, using the 'rails_12factor' gem. Before getting your hands dirty with this attempt, I recommend you to read the basics of deploying to Heroku you Rails 4, from Heroku dev center. If it does not resolve your problem, then try the following steps:

  • Add the gem to your Gemfile

group: production do
   gem ‘rails_12factor’
end

  • Add the code below to config/environments/production.rb

config.serve_static_assets = true
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'

config.assets.compile = true # in more recents versions after Rails 4.1.x, this may need to be inserted in config/initializers/assets.rb

Now,  push...

Read more