Github: Search for a repo you've starred
Want to find that repo you've starred some time ago again? Here's where to search for it.
An alternative way to browse and search through your starred repos is Astral, where you'll see the Readme for each repo in a split screen.
How to circumvent Firefox's "Document expired" page in Selenium tests
When navigating back to a page that was received from a POST request, undesired side effects may happen. Therefore, modern browsers try to keep users from doing so, i.e. Firefox 24 displays an error page explaining what's wrong. If the user presses "Try Again", it shows an additional alert asking whether the user is certain.
Solution
If you need to circumvent this protection, e.g. to test that your application behaves correctly despite being misused, do this:
page.execute_script 'history.back()'
page.execute_script 'retryThis(this)...
ImageMagick: Cropping images
ImageMagick takes a string with several options when cropping an image. See the command line options for how to provide the expected image geometry for details.
Note that ImageMagick tends to preserve the original aspect ratio of the source image automatically.
Examples:
-
crop 200x200
means Maximum values of height and width given, aspect ratio preserved. -
crop 200x200!
means Width and height emphatically given, original aspect ratio ignored.
flag-icon-css: Scalable country flags
Use it like this for inline icons:
<span class="flag-icon flag-icon-de"></span> Germany
They also work as block elements:
<div class="flag-wrapper">
<div class="flag flag-icon-background flag-icon-de"></div>
</div>
Falsehoods programmers believe about addresses
Addressing is a fertile ground for incorrect assumptions, because everyone's used to dealing with addresses and 99% of the time they seem so simple. Below are some incorrect assumptions I've seen made, or made myself, or had reported to me.
Jasmine 2 cheat sheet for RSpec lamers
In the tradition of our PostgreSQL cheat sheet for MySQL lamers, here is a cheat sheet for Jasmine when you're used to RSpec.
Note that Jasmine syntax has changed with Jasmine 2, so if you're using Jasmine 1.x you might instead want to use an older cheat sheet.
Expectations
# RSpec
expect(foo).to.eq("value")
expect(foo).to_not eq("value")
# Jasmine
expect(foo).toBe("value")
expect(...
Jasmine: Reset the location when testing code that uses pushState / replaceState
When testing code that uses pushState / replaceState, your browser will appear to navigate away from http://localhost:3000/specs
(or wherever you run your Jasmine tests). This is inconvenient, since reloading the document will no longer re-run the test suite.
To remedy this, copy the attached file to a place like spec/javascripts/helpers
and #= require
it from your tests. It will store the current location before every test and reset if afterwards (using location.replaceState
).
velesin/jasmine-jquery
This jasmine plugin helps with testing DOM manipulation in two ways:
- It gives you DOM-related matchers like
toBeVisible()
ortoHaveCss(css)
- It gives you a function to load HTML from fixture files. Without this you would have to manually add elements to
<body>
and clean up afterwards.
Installing the typhoeus Rubygem on Ubuntu 14.04
Make sure you have libcurl3-dev
installed:
sudo apt-get install libcurl3-dev
gem install typhoeus
Cucumber: More patience for Selenium features
When running Selenium features with parallel_tests, some browser-server interaction might take longer than usual and the impatient Capybara will not wait enough to see results.
Put the attached file into features/support/
to make Capybara more patient in scenarios tagged @javascript
.
How to upgrade Cucumber on Rails 3+
-
Run
bundle update cucumber capybara cucumber-rails
to update to the newest versions. -
Backup your
features/support/path.rb
to be able to add your own paths again after the cucumber installation script in step 4. -
Backup your
features/support/env.rb
file to be able to reintegrate parts like your blueprints setup:ENV["RAILS_ENV"] ||= "cucumber" require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') require 'spec/support/blueprints'
-
Run `$ rails generate cucumber:install --capyba...
yaronn/blessed-contrib
Build dashboards using ascii/ansi art and javascript
Awesome!
Making Sass talk to JavaScript with JSON | CSS-Tricks
Crazy hack. Might be useful one day.
The code required has since been extracted into a library.
puppet: Beware of the Fake False!
The condition for an if statement has to resolve to a boolean true/false value. However, all facts are strings, and all non-empty strings — including the string "false" — are true. This means that facts that are “false” need to be transformed before Puppet will treat them as false.
AngularJS: Binding to Perl-style getter/setters functions
Angular 1.3+ has an alternative getter/setter pattern: You can bind ng-model
to an accessor function. This is a function that is either a getter (when it gets no arguments) or a setter (when it gets the new value as an argument):
$scope.name = function(newName) {
return angular.isDefined(newName) ? (_name = newName) : _name;
}
You need to bind this function with ng-model
and `ng-model-options="{ getterSette...
Testing focus/blur events with Cucumber
This is a problem when using Selenium with Firefox. We recommend using ChromeDriver for your Selenium tests.
This setup allows to test focus/blur events in Cucumber tests (using Selenium). For background information, see How to solve Selenium focus issues.
Cucumber step definition:
# This step is needed because in Selenium tests, blur events are not triggered
# when the browser has no focus.
When /^I unfocus the "(.*?)" field to trigger ja...
Magnific Popup: Responsive jQuery Lightbox Plugin
Responsive Lightbox JavaScript that just works.
You can use it for single images or a gallery. Animations are optional.
pgcli - Postgres command line interface
A CLI for working with Postgres databases. Ships with auto-completion and syntax highlighting.
jQuery: Get a promise for the end of an animation
The API is a little confusing because animate
returns a reference to the element to enable chaining.
But you can do this:
$element.animate(...);
$element.promise().then(function() { ... });
Make jQuery.animate run smoother with almost no code changes
jQuery comes with .animate()
that lets you transition some CSS selectors:
function floatIn($element) {
$element.css({ 'opacity': 0, 'margin-top': 200px });
$element.animate({ 'opacity': 1, 'margin-top': 0 }, { duration: 500 });
}
The animation is implemented using setInterval
and Javascript. This works great, but it's not as smooth as a CSS transition.
Fortunately the animate
API can be mapped almo...
Databound
Databound provides Javascript a simple API to the Ruby on Rails CRUD.
Tries to expose a full model CRUD as an API. Not sure if this is useful for more refined requirements.
Angular: Binding strength in ngRepeat (aka operator precedence)
When you have an ngRepeat directive that uses track by
, be sure to move the track by
instructions to the very end of your statement, i.e. behind any filters.
Broken
Consider the following:
ng-repeat="child in category.children track by child.name | orderBy:'name'"
This will silently skip ordering; here is how AngularJS sees it (parentheses inserted to display binding strength):
ng-repeat="child in (category.children track by (child.name | orderBy:'name'))"
Working
Moving track by
to the end will correctly...
Researching a new form of HTTP caching optimization - Phusion BlogPhusion Blog
Interesting approach to caching responses directly in the HTTP server, based on the value of an individual cookie.
No word yet how to force cache-invalidation.
thoughtbot/bourbon
Bourbon is a library of pure Sass mixins that are designed to be simple and easy to use. No configuration required. The mixins aim to be as vanilla as possible, meaning they should be as close to the original CSS syntax as possible.
The mixins contain vendor specific prefixes for all CSS3 properties for support amongst modern browsers. The prefixes also ensure graceful degradation for older browsers that support only CSS3 prefixed properties.