Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

[Standup][SF] 09/21/12: Get older faster

Tyler Schultz
Friday, September 21, 2012

Interestings

  • Timecop#lens

We just made this pull request to Timecop:

“Add Timecop#lens where time can go FASTER”

Create a new mock_type, :lens which will let time continue, like :travel, but the first argument is a scaling factor which will make time move at an accelerated pace.

https://github.com/jtrupiano/timecop/pull/42

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Ah, ah, ah. Now, that was silly. Wouldn’t you agree, my bats? Ah, ah, ah.

Tyler Schultz
Thursday, September 20, 2012

Helps

  • Slow count after delete_all of millions of records?
  • font icons, Ajax, and IE8

Our application is using Font-Awesome to display some of our icons. One of our modals that has its content loaded via Ajax is rendered in IE8 without any of these icons visible. Clicking any element that contains these icons will make them instantly appear.

Is there a known issue with IE8 not properly applying CSS :before rules to content fetched with Ajax? Or could it be a known issue with how it handles fonts? Any ideas?

Events

  • Ember.js talk @ Zendesk – Tuesday 6:00pm

http://www.eventbrite.com/event/4213815636/efbnen

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

[SF][Standup] 09/19/12: ActiveAdmin vs. RailsAdmin… Arrrggg!

Tyler Schultz
Wednesday, September 19, 2012

Interestings

  • ActiveAdmin after_save

If you are using ActiveAdmin, beware that the after_save callback gets fired both when the model gets saved, and when there are validation errors on the model.

It really behaves like a callback after the model save method gets called, regardless of its return value.

  • Testing RailsAdmin custom actions

Let’s say you’re writing a RailsAdmin custom action, and you want to test it with a request spec.

If the test passes when guard is on, but fails when guard is off, then you’ve forgotten that the RailsAdmin initializer does not run when loading a rake task. It does run as part of bundle exec guard start.

This is a performance ‘optimization’ that RailsAdmin adds.

To turn it back on, so you can test custom actions:

task :default => [:load_rails_admin_initializer]
task :load_rails_admin_initializer do
ENV['SKIP_RAILS_ADMIN_INITIALIZER'] = ‘false’
end

  • International Talk Like a Pirate Day!

Arrrgggggg me mateys! To your pairs you scabrous dogs!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

[Standup][SF] 2012.05.25 – 1 git repo, 2 Procfiles, 2 Heroku Apps, CSS transitions behaving badly

Tyler Schultz
Friday, May 25, 2012

Ask for Help

*”1 git repo, 2 Heroku apps, 2 procfiles? Heroku currently is limited to 1 procfile per repo, so we’ve created a rake task that branches, modifies the procfile and pushes. Do you have a better solution?”

Is it possible to use env variables to parameterize your Procfile?

“Capybara: How can I click on a flash dialog for webcam settings?”

This was solved by right clicking and going into flash settings and enabling this permission always for this domain. Setting this up on headless CI may be more difficult.

“I have CSS transitions that behave differently when ‘user initiated’ vs initiated from a setTimeout or other event.”

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 05/22/2012: [SF] CarrierWave is messy

Tyler Schultz
Tuesday, May 22, 2012

Ask for Help

“CarrierWave is messy leaving files in the tmp directory when running tests. Is rm -rf the best answer?”

Yes!

“While the we love Rails, we don’t need it, we just want its asset packaging features. Some suggest using sprockets. Do you have other suggestions?”

  • jammit
  • grunt

Interesting Things

*Gem Maintainers: use LicenseFinder to save users of your gem the hassle of digging through your gem to figure out what license your gem is distributed under.

*A Pivot had great success using Join.me for remote pairing. Setup was a snap! Others suggest checking out TeamViewer as well.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

[Standup][SF] 11/22/2011: Programmatic select box changes

Tyler Schultz
Tuesday, November 22, 2011

Help!

“How do I choose the value of a select box programmatically? The val function does not seem to do the trick.”

Try setting the desired option as selected and then trigger a change event on the select input.

*”A pair is looking for ‘multi file upload via iframe-transport’ expertise. Specifically uploads in FireFox 3.6.”

Interesting

  • The latest RubyMine EAP has improved code formatting options!
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 09/30/2011: Bulk inserts

Tyler Schultz
Friday, September 30, 2011

Ask for Help

“Our delayed job consumes 2G of memory creating ~20k ActiveRecords in a loop!”

It doesn’t answer why your job is using so much memory, but check out activerecord-import.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 09/28/2011: Epics!

Tyler Schultz
Wednesday, September 28, 2011

Interesting Things

  • Pivotal SF will be hosting a Tracker Users Group meetup tonight. Dan Podsedly will be speaking. He will be seeking feedback for a eagerly awaited feature to be rolled out shortly: Epics! Come and mingle with fellow Tracker users, drink some beer and eat some food.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Android WebView loadData vs loadDataWithBaseURL

Tyler Schultz
Saturday, September 10, 2011

We spent some time trying to figure out why some html content would not load in our app’s WebView. We found trivial html can be loaded into a WebView using the loadData(String, String, String) method. Rendering complex pages with Javascript is a problem. It turns out the loadData() method requires the html to be URI escaped (RTFM? Bah!). There are additional characters that need to be escaped too, requiring some nasty boilerplate.

The simpler solution (workaround?) is to use loadDataWithBaseURL(String, String, String, String, String). Calls to this method do not require escaping. Pass along a garbage base url (or null), and an empty or null history url for success and profit.

webView.loadDataWithBaseURL("blarg://ignored", getData(), "text/html", "utf-8", "");
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Android Image Caching

Tyler Schultz
Saturday, June 18, 2011

Web development spoiled me. Set the src tag on an img tag and away you go. For the most part, browsers just do the right thing and cache these requests. Disappointingly, Android does not come with out of the box support for caching content downloaded from the network. Server apis often require SSL, request headers, support for different HTTP methods, multipart post bodies, etc. requiring the use of the apache http client libraries. These libraries are powerful, but are a bear to work with. As far as I can tell there is no support for caching http responses built into the apache libraries, requiring that you roll your own caching scheme. Images often do not have all these complicated HTTP requirements. They’re usually simple HTTP GET calls. This makes the java.net.* libraries appealing. The java.net libraries come with some handy classes that makes caching a breeze.

Here is a snippet that will cause your request to be pulled from the cache, should it exist. If it doesn’t exist, the retrieved response will be written to the cache.

URL url = new URL("https://pivotallabs.com/images/pivotallabs-logo.png");
URLConnection connection = url.openConnection();
connection.setUseCaches(true);
Drawable drawable = Drawable.createFromStream(connection.getInputStream(), "src");

In the past I tried to use the code above alone and found it didn’t work, and no solutions seemed obvious. The javadocs for URLConnection don’t mention anything about ResponseCache, but there is work to be done there to make it all work. The following example shows using Android’s cache directory to cache the responses. You’ll want to take a moment to read the Android docs about the cache dir. There are guidelines for use of the directory. This looks like a lot of code (Java, Java, Java, Java), but IntelliJ will allow you to cntl-shift-space your way to happiness and write most of it for you.

final String cacheDir = context.getCacheDir();
ResponseCache.setDefault(new ResponseCache() {
    @Override
    public CacheResponse get(URI uri, String s, Map<String, List<string>> headers) throws IOException {
        final File file = new File(cacheDir, escape(uri.getPath()));
        if (file.exists()) {
            return new CacheResponse() {
                @Override
                public Map<String, List<string>> getHeaders() throws IOException {
                    return null;
                }

                @Override
                public InputStream getBody() throws IOException {
                    return new FileInputStream(file);
                }
            };
        } else {
            return null;
        }
    }

    @Override
    public CacheRequest put(URI uri, URLConnection urlConnection) throws IOException {
        final File file = new File(cacheDir, escape(urlConnection.getURL().getPath()));
        return new CacheRequest() {
            @Override
            public OutputStream getBody() throws IOException {
                return new FileOutputStream(file);
            }

            @Override
            public void abort() {
                file.delete();
            }
        };
    }

    private String escape(String url) {
       return url.replace("/", "-").replace(".", "-");
    }
});
</string></string>

This is a simple implementation that pays no attention to the response headers, returns no cached response headers, etc. but I think you get the gist. There is one gotcha: the URI passed into the put method does not contain the path info for the url, it must be retrieved from the URLConnection. Happy caching!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Tyler Schultz

Tyler Schultz
San Francisco

Subscribe to Tyler's Feed

Author Topics

rails (5)
time (2)
css (1)
heroku (2)
javascript (1)
activerecord (1)
android (3)
robolectric (1)
tdd (1)
agile (7)
amazon (1)
default scope (1)
hudson (1)
rspec (1)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >