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'))

...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...

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...

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...

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...

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...

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
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...

I use the TypeScript compiler for this, since its output is more minimal than Babel's. The following will transpile all src/*.js files into a file build.js:

npx tsc src/*.js --target ES5 --allowJs --outFile build.js The output will only transpile ES6 syntax. It will not include any polyfills for missing APIs...

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...

makandra dev
select2.org

Select2 comes with AJAX support built in, using jQuery's AJAX methods. ... For remote data sources only, Select2 does not create a new element until the item has been selected...

query: params.term, page: params.page || 1 } } processResults: function (data, params) { return data }, } }); Further reading: https://select2.org/data-sources/ajax

Sometimes you accidentally generate entries in the bash history that you do not want to have there (e.g. commands with credentials). Here's how to remove single entries.

...look at the bash history with the history command. To see e.g. the last 5 entries, use history | tail -n 5: >history | tail -n 5 1994 my-secret-command...

...file, that don't use Ruby's logger utility, it is often useful to sync them. So other process can read the output just in time. Example with enabled sync...

File.read(log_path) #=> "Some log message\nSome other message\n" Example with disabled sync (default) log_path = '/tmp/some_log.log' log_file = File.open(log_path, 'a+') log_file.puts('Some log message')

makandra dev

...image formats like JPG or PNG, each pixel is basically drawn on a fixed size canvas. To display such an image in a different size (say: 1.5 times larger than...

...Monitor) needs to interpolate the color values of missing pixels. The image will appear slightly blurred. This is different for vector graphics like the SVG (Scalable Vector Graphics) format. You...

lucaguidi.com

...was typical approach for object oriented languages, designed in the 90s. A thread is sequence of instructions that can be scheduled and executed in the context of a process. Several...

...at the same time. Ruby’s VM process allocates a memory heap, which is shared and writable by threads. If incorrectly coordinated, those threads can lead to unexpected behaviors...

.../.bashrc to have it always available. Adjust to your needs. Usage $> tab_title # title set to the current directory's name $> tab_title new_title # title set to "new_title...

...Auto-setting the title If you want your title to update each time you change the working directory, put this code after the function definition. # auto-title cd() { builtin cd...

Let's say you want to merge the properties of two JavaScript objects: let a = { foo: 1, bar: 2 } let b = { bar: 3, baz: 4 } let merged = merge(a, b...

...foo: 1, bar: 3, baz: 4 } Depending on your build, there are several ways to implement merge(). When you have ES6 When you have an ES6 transpiler or don't...