1. Download or grab a local PDF of an eBook that I want to read
2. Use an online converter for PDF to ePub (such as Online Convert)
3. Sign up at Fastr to upload the ePub version
4. Download the fastr app
5. Sign into the account (via mobile)
6. Profit! Start using RSVP on eBooks
I am not affiliated with Spritz or Fastr.io in any way. Just a developer that almost recreated the wheel. I found this (albeit complicated) solution while doing technical research.
There’s still an opportunity to simplify the process. I don’t think that Amazon will accommodate RSVP anytime soon.
Meaning is more dispersed in books than articles, which is why I feel that eBooks are the best use of this technology.
What else? Hit me up on Twitter (@DruRly)
People often use
%:p:h to retrieve their current path in vim.
You can use
:set acd to automatically perform this task.
acd is shorthand for
autochdir. With this option set, you will always be placed on the same path as your current file.
Commands such as
:tabedit reveal that your path is no longer static, instead it inherits from your current file’s path.
For more information, run
Yesterday I had an issue using AngularJS’s
$http.jsonp method to fetch data from a separate API service which I built.
It turns out that the issue was with my API and not the client.
I had to add cross-domain JSONP support.
1 2 3
Source: JSONP in Rails
Timerizer gives you Rails-like time helpers without Rails.
> Time.now #=> 2013-07-10 12:31:50 -0400 > 5.days.ago #=> 2013-07-05 12:31:43 -0400
Libraries such as these become increasingly important as developers adopt a (only use what I need) approach to development.
While building an API with Sinatra, you can use Timerizer without regretting your decision to forgo the weight of a Rails app.
I recently messed up my
.vimrc file while trying to add some productivity hacks.
It took a major scare for me to invest the effort in figuring out how to symlink my .vimrc file. I needed version control.
Here are the summarized steps that I took:
$ cd $ mv .vimrc .vim/ #=> Move your .vimrc file into the .vim/ directory $ cd .vim/ $ git init $ git add . $ git commit -m "First Commit" #=> Get your .vim/ directory under version control $ cd $ ln -s ~/.vim/.vimrc .vimrc #=> Go to your home directory and symlink the version controlled .vimrc
Yesterday I received a great question regarding one of my posts on using
around hooks in Rspec.
I’m interested as to what use you would personally use this for.
Can you recommend any use in particular you like?
Below I demonstrate two use cases for
VCR automatically stores HTTP responses to prevent your tests from hitting the network each time.
I love VCR but despise the effort required to name each cassette. I took an idea from Ryan Bates and decided to use
around hooks to have these cassettes automatically named.
Typical VCR Setup:
1 2 3 4 5 6 7 8
The typical VCR setup requires that you name the file where the HTTP response will live. I’m too lazy to accept this.
My VCR Setup:
1 2 3 4 5 6
I simply pass
:vcr after the description for automatic file naming. This is accomplished by using
around hooks in my
spec_helper.rb file. Check out the code below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
These integration tests are making API calls. VCR captures and replays the response on subsequent test runs.
The code above allows me to pass
:vcr to the example when I want the HTTP response captured by VCR.
I have also used
around hooks for proxing in my tests. If you want to do any type of scale testing with real data, you can mask your IP to collect the information.
Here’s the typical setup for doing such a thing:
1 2 3 4 5 6 7
1 2 3 4
spec_helper.rb file that allows me to do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
I have also combined these hooks to store the response of a proxied request.
1 2 3 4 5 6
Thanks for the great question Brett!
I ran into a
bower issue while running
grunt test on a new yeoman/angular project.
The error read:
"app/bower_components/angular/angular.js" does not match any file."
I noticed that I didn’t have a
bower_components directory but I did have a
I changed my
karma.conf.js file to watch
components and waited for something to blow up.
I was able to run
grunt test without any issues. This has been working for a couple of days without any side effects.
$ git diff diff --git a/karma.conf.js b/karma.conf.js index ffd77ce..f4ca129 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -7,8 +7,8 @@ basePath = ''; files = [ JASMINE, JASMINE_ADAPTER, - 'app/bower_components/angular/angular.js', - 'app/bower_components/angular-mocks/angular-mocks.js', + 'app/components/angular/angular.js', + 'app/components/angular-mocks/angular-mocks.js', 'app/scripts/*.coffee', 'app/scripts/**/*.coffee', 'test/mock/**/*.coffee',
I received this error while writing controller tests for an API.
ActionController::UnknownFormat was introduced with Rails 4 and has not been well documented yet.
Here’s how I resolved the issue.
1 2 3
1 2 3
You may still face an
ActiveModel::ForbiddenAttributesError but that’s a different issue requiring that you address strong_params.
Haml support isn’t built into yeoman so I had to practice a bit of hackery to get my preferred setup.
It took about a hour to figure this out but infrastructure tasks are worth the effort.
Here are some notes from the process:
About the Gruntfile:
Load grunt-haml in
1 2 3
Add a task inside of
1 2 3 4 5 6
haml file extensions for livereload
1 2 3 4 5 6 7 8 9 10 11
haml file targets
1 2 3 4 5 6 7 8 9 10 11 12
It would be nice to have dynamic file targeting.
Check out this thread for more information.
“You need to have Ruby and Compass installed and in your system PATH for this task to work.”
I received this error while generating a yeoman project. This message is extremely confusing for Mac users because they already have Ruby installed.
gem install compass to get past this issue.
I decided to use yeoman for a new AngularJS project and ran into this issue when generating a project with
yo angular [APPNAME].
If you have exhausted the path solutions or identified that you do not have a path issue. Ensure that you have yeoman installed.
Well all know about
after_each but you can also wrap your tests in blocks for VCR cassettes or proxying requests.
This can be accomplished within your
spec_helper.rb or a specific file.
... config.treat_symbols_as_metadata_keys_with_true_values = true config.around(:each, :two_times) do |example| 2.times do example.call end end ...
Tests are wrapped when
:two_times is passed in.
... it "confirms the obvious", :two_times do 15.should == 15 end ...
Within a spec file:
... describe "around filter" do around(:each) do |example| puts "around each before" example.run puts "around each after" end it "gets run in order" do puts "in the example" end end ...
I’m super late to the party but I recently found out how to enable iPhone emojis.
Check out this post for instructions.
Version 0.3.0 introduces some new features:
1. Multiple Gem Support
$ gemrat rspec capybara sidekiq #=> gem 'rspec', '2.13.0' added to your Gemfile. #=> gem 'capybara', '2.1.0' added to your Gemfile. #=> gem 'sidekiq', '2.12.4' added to your Gemfile. #=> Bundling...
2. Usage (Help)
$ gemrat --help OR gemrat -h Gemrat Add gems to Gemfile from the command line. Usage: gemrat [GEM_NAME] [OPTIONS] Options: -g [--gemfile] # Specify the Gemfile to be used. Defaults to 'Gemfile'. -h [--help] # Print these usage instructions.
3. Gem not found - Error Handling
$ gemrat im_not_real Unable to find gem 'im_not_real' on Rubygems. Sorry about that.
I published a gem earlier this week which allows developers to add gems to their Gemfile from the command line. The utility of Gemrat lies in it’s ability to grab the latest version of a gem and lock it into your Gemfile.
$ gemrat sinatra #=> gem 'sinatra', '1.4.3' added to your Gemfile. #=> Bundling... $ gemrat rspec #=> gem 'rspec', '2.13.0' added to your Gemfile. #=> Bundling...
Lately I’ve been taking a service oriented approach to developing software. This means that I build smaller apps which depend on each other rather than having a huge monolithic codebase.
This approach lends itself to reusability, polyglot programming, and it gives me more chances to implement lessons learned from previous applications.
The service oriented approach also carries some debt. I’m often wrangling dependencies as I rebuild infrastructures. Developers working on monolithic apps with lots of legacy code can go days or weeks without adding dependencies. This is usually not the case in service oriented architectures.
The manual process of adding gems usually involves searching for the latest version of a gem then adding the gem and it’s version to the Gemfile. This process calls for a browser and text editor.
The same result can now be accomplished by running
$ gemrat gem_name from your command line.
I use this tool on a daily basis. Solving my own problems and sharing solutions with the world is extremely gratifying work.
Here’s a basic pattern for running Sinatra with Puma.
1 2 3 4
The next time that you run
ruby app.rb, it will use Puma instead of WebBrick.
“Please point sidekiq to a Rails 3 application or a Ruby file to load your worker classes with -r DIR|FILE.”
I received this error while attempting to use Sidekiq in a Sinatra app. To solve this problem, use the
-r option to point Sidekiq to your main Sinatra file.
1 2 3
-r option is also used by
pry to preload dependencies.
pry -r ./app.rb gives you access to all our your methods in
app.rb without the need to require it via console.