RSSAmplifier

Blog

break the bit

A place for technology and programmer happiness. Written by Miha Rebernik.

breakthebit.orgRSS feed ↗20 posts

Latest posts

The next episode

And it’s official: I’ve joined Coinbase full-time in sunny San Francisco. It’s been a hell of a ride so far, we’ve started many companies and projects — from OdpiralniCasi with David to joining Y Combinator and founding DoubleRecall and Dubjoy with Robert , Rok and Rok . Oh and then there’s the Timekiwi episode . As I look back it’s clear these were some of the best years so far…

Up your security on Amazon AWS

If you make use of Amazon’s cloud infrastructure, you should take several security measures to ensure you’re not having company managing your data and servers. Two-factor authentication If you don’t know what two-factor authentication is, it’s simply a way of gaining access to services that involves two stages of authentication and usually two means of authentication. An excellent example of this…

Fixing MissingRequiredValidatorError when upgrading to Paperclip 4

I’ve recently upgraded the gems in my Rails app and I was now running the latest paperclip 4.x . I was soon notified that file uploads were no longer functioning. Upon closer examination I found that the uploads were failing with this exception: Paperclip::Errors::MissingRequiredValidatorError (Paperclip::Errors::MissingRequiredValidatorError): app/controllers/issues_controller.rb:18:in `document'…

Real-time tech support with Olark

Foreword We came a long way since we started the public beta testing of Dubjoy , the video voice-over solution in the browser. We’re targeting a pretty specific public: Language Service Providers, voice actors, voice talents, translators and interpreters. This is mostly a non-technical blend, that like most people, can’t help you efficiently debug, reproduce or describe problems as they occur. We…

How to increase volume in a video without re-encoding the video

So today’s quick tip is a bit off-topic. It’s about video. I needed for a reliable, fast and non-destructive way to increase gain on a video’s audio track. I found it in using the ffmpeg tool, which is a swiss army knife for dealing with video and audio files. It’s conveniently cross-platform and works wonders. To increase the volume of the first audio track for 10dB use: ffmpeg -i inputfile…

Simplest web server with one line of Ruby

Today when developing some more client-side code for Dubjoy I again had the need of quickly loading a HTML file through a web server. I was more than delighted to stumble upon this post . It describes a Ruby one-liner that launches a thin web server that serves the current directory: ruby -rrack -e "include Rack; Handler::Thin.run Builder.new { run Directory.new '' }" If you don’t have thin…

How to start with Backbone.js: A simple skeleton app

Prerequisites You need a solid knowledge of JavaScript, familiarity with Backbone, Ruby, HAML, SASS and CoffeeScript to find this writeup useful. Also, I’m developing on a Mac and have not tested this on other platforms. Although, I do not see any reason why it shouldn’t work. 1. Philosophy Part of the success of Rails was the conventions and its predefined directory tree. While looking…

How to directly upload files to Amazon S3 from the client

Why you need this? You don’t want your heavy-weight data to travel 2 legs from Client to Server to S3, incurring the cost of IO and clogging the pipe 2 times. Instead, you want to ask your server to give your client one-time permission to upload your data directly to S3. The process is still 2 legged, but heawy-weight data travels only on 1 leg. On Amazon S3 this is implemented with CORS (Cross…

How to record audio in Chrome with native HTML5 APIs

Two weeks ago a new version of Chrome was released. Google switched from the default Adobe’s Flash Player to an in-house developed version called “ Pepper Flash ”. Unfortunately Pepper Flash has a problem with audio recording , resulting in distorted audio on almost all Macs. This happened right in the middle of our efforts to build the Dubjoy Editor, a browser-based, easy to use tool for…

Spine.js vs Backbone.js

Differences and similarities explained nicely by hjortureh : Spine and Backbone are two Javascript MVC frameworks that look very similar on the surface but under the hood there are key differences. The purpose of this article is to highlight these differences and hopefully make it easier to choose which framework fits your needs. The basics Backbone is written in Javascript and was created by…

Simplistic Google Apps for your domain verification with Rails 3 routes

… or how you can use Rails 3 routes to output an arbitrary string of text. A wonderful conceptual win of Rails 3 is that routes are now a truly simple component (if you don’t mind the regular expressions) . They are only mapping URLs to Rack endpoints. Google Apps FYD offers verification of your domain by uploading a static HTML file to the site’s root, and putting the verification code into it.…

Fixing NoMethodError with the Instagram strategy and omniauth

Problem I was pretty disappointed when realizing that the instagram strategy of omniauth is somewhat broken. Soon I got irritated enough to go dig in and try fixing it. The exact exception is: You have a nil object when you didn’t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.+ The stack trace goes into the depths of the Ruby standard library…

JavaScript equivalent of Array#to_sentence from Rails

I’m constantly finding myself lacking some cool Ruby extensions from Rails when I’m head to toes in some JavaScript. One of those is the excellent Array#to_sentence . It’s a cool way of quickly transforming an array into a string, with a natural language feel to it. Array.prototype.to_sentence = function() { return this.join(", ").replace(/,\s([^,]+)$/, ' and $1') } Example: [1, 2, 3, 4,…

JavaScript remove element from array

So today I was looking for a remove method for Arrays in JavaScript. Sort of a reverse of the Array#push . I’ve scrabbled one together and it goes like this: Array.prototype.remove = function(element) { this.splice(this.indexOf(element), 1) } So you could use it like this: var a = []; a.push(4); => [4] a.push(6); => [4, 6] a.push(24); => [4, 6, 24] a.remove(6); a => [4, 24] Comment here or fork…

Stripping HTML tags from a string in JavaScript

Here’s a clever one, I didn’t come up with it, but I sure want to disseminate it further. Why bother with regular expressions and stuff when the browsers are more than suitable for the job: String.prototype.strip_html = function() { var tmp = document.createElement("DIV"); tmp.innerHTML = this; return tmp.textContent || tmp.innerText; } Monkey-patch the String class to have a…

Fixing database.yml file missing at Rails assets precompilation

Today I was porting some of my apps from Rails 3 to 3.1 to learn the process and be ready for porting the real apps at a later time. I love the asset pipeline idea and the precompilation of assets at deploy time. This is something I always wanted, but was to lazy to do for all but the biggest projects. It’s pretty easy to do this now considering you have the latest Capistrano gem . Just add load…

Using HTML5 geolocation API to get the distance of the visitor from me

As I mentioned a couple of months back, I revamped my site that represents me online. One of the coolest features I employed over there was locating the visitor with GeoIP, pulling my current location from Google Latitude with a clever hack to bypass all the API security shenanigans and displaying a distance of the visitor from me. I try to use the site as an excuse to play with the cutting-edge…

Sinatra CSS/SASS wildcard route

Here’s a short one. If you’re doing some quick hacking in Sinatra and suddenly need more than one stylesheet processed with SASS you can use this catch-all route: get '/*.css' do content_type 'text/css', :charset => 'utf-8' sass params[:splat].join.to_sym end If you see a better way to do this, fork and improve .

Rails 3 boot times 50% faster with Ruby 1.9.3

As you’ve probably heard before, the combination of Rails 3 and Ruby 1.9 slowed down Rails boot times considerably, almost to the pain point. A little scouring on the internets gave me hope, since the kind Aussie rubyist Xavier was on the job . Unfortunately at the time I was reading that post my rvm wasn’t happily compiling my ruby-head so I gave up as I had work to do. Now that Ruby…

Ruby 1.9 and the new hash syntax

I knew that Ruby 1.9 added a new syntax for hashes, I just never seem to start using it, because the old one is baked in so hard. The old one, we’re all familiar with is: new_hash = {:simon => "Talek", :lorem => "Ipsum"} This is all nice and dandy, but it could be simpler and cleaner. Check out the Ruby 1.9 style, it sort of resembles JSON: new_hash = {simon: "Talek", lorem: "Ipsum"} But now…