makandra dev

...Invoked Function Expessions (or IIFEs) to prevent local variables from bleeding into an outside scope: (function() { var foo = "value"; // foo is scoped to this IIFE })(); In Coffeescript an IIFE looks...

(-> foo = "value" # foo is scoped to this IIFE )() There is also a shorthand syntax with do: do -> foo = "value" # foo is scoped to this IIFE

jQuery is still a useful and pragmatic library, but chances are increasingly that you’re not dependent on using it in your projects to accomplish basic tasks like selecting elements...

...styling them, animating them, and fetching data—things that jQuery was great at. With broad browser support of ES6 (over 96% at the time of writing), now is probably a...

...with more than one developer should always consider to enforce code review even for small changes to improves the overall code health of the system. Here are some guidelines that...

...perfect pull request Google Google's Engineering Practices documentation Modern Code Review: A Case Study at Google Thoughtbot Thoughtbot' Code Review Guideline

...model inherits from others or uses many concerns / traits, it might be hard to see in the code which validators it has. But fortunately there's a method for that...

...UniquenessValidator:0x00007f55f1417e88 @attributes=[:name], @klass=UserGroup (call 'UserGroup.connection' to establish a connection), @options={:case_sensitive=>true, :scope=>:partner_id}>, #<ActiveModel::Validations::NumericalityValidator:0x00007f55f1415200 @attributes=[:user_count_limit], @options={:greater_than...

There are several gems that make it easy to read and process xlsx files. Parsing the entire file at once however is error-prone since each cell is transformed to...

...formatted but empty cells. As of today, I found two promising alternatives that provide a stream-based access to spradsheet rows: Roo supports multiple spreadsheet types like ODS or CSV...

...code from your repository. In order to do so, Capistrano connects to your repository server from the application server you're deploying to with SSH. For this connection you can...

...use two SSH keys: the user's ~/.ssh/id_rsa [default] the very same key you used for connecting to the application server - forwarded automatically to the git repository.

class Foo def bar(argument) 'Hello' + argument end end module FooExtensions def bar super(' in my') + ' World' end end class Foo prepend FooExtensions # the only change to above: prepend...

medium.com

...end up with web page bloat. But loading a webpage is much more than shipping bytes down the wire. Once the browser has downloaded our page’s scripts it then...

...dive into this phase for JavaScript, why it might be slowing down your app’s start-up & how you can fix it. The article author also tested 6000+ production sites...

...as expected with your Unpoly app. This is because your app only has a single page load when the user begins her session. After that only fragments are updated and...

...up.compiler('[track-for-analytics]', function($element) { var url = $element.attr('track-for-analytics') || location.pathname; ga('set', 'page', url); ga('send', 'pageview'); }); Finally look for containers that represent trackable content, and give...

makandra dev
github.com

...an attacker might be able to use this to inject javascript code into the source code of your page. The linked github page is a collection of common markdown XSS...

...which is handy for writing tests. Producing arbitrary links: [Basic](javascript:alert('Basic')) [Local Storage](javascript:alert(JSON.stringify(localStorage))) [CaseInsensitive](JaVaScRiPt:alert('CaseInsensitive')) [URL](javascript://www.google.com%0Aalert('URL'))

solnic.eu

...duplication from the code is a seemingly easy task. In many cases it is pretty straight-forward – you look at similar bits of code and you move them to a...

...in other places. Right? No, not really. It is true that code that looks similar might be an indicator that there’s a duplication but it’s not the definitive...

lesscss.org

...run by your web browser. As any JavaScript, you include a link to the script in your HTML, and…that’s that. LESS is now going to process LESS code...

icelab.com.au

...formatting. Headers, paragraphs, lists, it’s all good. What about the formatting of text in single-line text fields? If our form entry is a single line, that’s usually...

PostgreSQL and ActiveRecord have a good support for storing dynamic attributes (hashes) in columns of type JSONB. But sometimes you are missing some kind of validation or lookup possibility (with...

...plain attributes you can use Active Record's built-in validations and have your schema.rb). One approach about being more strict with dynamic attributes is to use JSON Schema validations...

...call model.save! after recreating versions. uploader.recreate_versions! does not update the model with the stored filename...

require 'logger' log = Logger.new('log/mylog.log') log.info 'Some information' log.debug 'Debugging hints' log.error StandardError.new('Something went wrong') Logger does a number of things well: Message type (info / debug / error...

Log entries are timestamped Writing log output is synchronized between threads Logged errors are printed with full backtraces If you don't like the output format, you can...

justinfrench.com

...behavior of deprecated code in your Ruby project, the warning messages littered throughout your spec output is incredibly noisy. You could silence all warnings with ::ActiveSupport::Deprecation.silenced = true, but you...

...dependencies. It’s tempting to remove the tests altogether (the code will be burned soon too, right?), but I figured out something a little nicer a little while back in...

makandra dev
feedjira.com

...was missing some features on Ruby's RSS::Parser that I found in Feedjira: Speed Does not break on slightly malformed RSS feeds (like a missing length attribute on an...

github.com

An unresponsive service can be worse than a down one. It can tie up your entire system if not handled properly. All network requests should have a timeout.

...You should avoid Ruby’s Timeout module. The default is no timeout, unless otherwise specified. Enjoy...

makandra dev
chrome.google.com

When you're facing a somewhat complex Google Analytics setup and want to find out what's happening, you can use this Chrome extension. It's much simpler than other...

...like "Google Tag Assistant") and does just one job and does it well. To see what's happening, you need to open your developer console...

pivotaltracker.com

The team is responsible for building great software—that’s it. It’s the only thing the team is responsible for and it’s the only thing that they actually...

...control. In other words, the development team is committed to quality software...

timeless.judofyr.net

...unknown, technique in Ruby. For certain types of problems (e.g. when you have a set of rules) this gives you such an elegant way of describing the solution. There’s...

...no meta programming or monkey patching involved, it’s short and sweet and best of all: it’s very intuitive...

jamesgolick.com

Trample is a more flexible load simulator. Instead of a static list of urls, trample's configuration language is ruby. Using ruby's blocks (lambda functions), it's possible to...

blogs.concedere.net

The goal of modelling is to produce something substantially simpler than the world. This is achieved not through endlessly inventing new types and relationships -- in fact, it's just the...

...s by eliminating entities and restricting types that we get a model that's simpler than the world and thus useful...