Surface Pro 3 no longer needs custom linux kernel

Good news!

As of Ubuntu 16.04 and linux kernel 4.5, there is no need to create a custom kernel for the SP3. Most things work right away except for the touch pad that needs to be enabled by editing the following file
sudo nano /usr/share/X11/xorg.conf.d/10-evdev.conf
and adding this to the end

Section "InputClass"  
        Identifier "Surface Pro 3 cover"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
        Option "vendor" "045e"
        Option "product" "07dc"
        Option "IgnoreAbsoluteAxes" "True"
EndSection 

I believe that the only thing missing now is multi touch support but I think that is just a small inconvenience

Calculate the Size of Base64.strict_encode64 in Ruby

I was in need to calculate the size of the output of Base64.strict_encode64.
I wanted to get this value to determine if the file was too big to send to an API endpoint.
If the file was too big I didn’t want to spend time processing and trying to send the data.
So I put together this method using a bunch of answers from stack overflow and the article in wikipedia for base64

My method looks like this:
Read more

Build Linux Kernel 4.2.0 for Surface Pro 3

Ubuntu got updated to 15.10 and along came an updated kernel
My previous post will not work with the provided patches so I had to apply the code changes by hand and then roll out my own patch.

Assumptions

  • You have followed the instructions on this post replace with version 15.10
  • Installed Ubuntu or Ubuntu Gnome 15.10
  • Will be using an Ubuntu machine to perform the following steps. I recommend a faster machine than the surface but if you must the surface will be enough
  • You are doing all this in your home directory. It simplifies not having to set permissions.

Read more

Invoking a Rake Multitask in a loop

I am running selenium tests that I launch using a rake task. Recently I wanted to run a bunch on them concurrently every so often. The problem I ran into immediately, was that the tasks were only executed once. It turns out that, when calling a multitask multiple times, you not only have to .reenable the multitask but also have to .reenable each pre-requisite task. This is easily achievable using the following code:
Read more

Building and installing a patched ubuntu kernel for the surface pro 3

Some of you have been asking for this tutorial so I hope this is easy to follow.
I am sort of repeating the instructions here

Assumptions

  • You have followed the instructions on this post
  • Installed Ubuntu or Ubuntu Gnome 15.04
  • Will be using an Ubuntu machine to perform the following steps. I recommend a faster machine than the surface but if you must the surface will be enough
  • You are doing all this in your home directory. It simplifies not having to set permissions.

Read more

Dual boot Gnome Ubuntu 15.04 on a Surface Pro 3

update 6: I have rolled a new kernel surface-pro-3-linux-kernel-4.2.0-34.40

Good news everyone! the latest version of Ubuntu 15.04 works really good with the Surface Pro 3

Things that immediately work

The TypeCover Keyboard
The TypeCover backlight can be adjusted by pressing F1 and F2
The mute button in the TypeCover F3 works
The WiFi is stable now
The Touch Screen works – with gnome you have similar gestures as windows 8 like pulling from the left , etc.
No need to disable the secure boot

Things that don’t work

The touch pad needs some minor set up
The battery is not recognized
Volume buttons don’t work
buttons in the pen still not working
Read more

Guanacotoon, I never thought I would see the day

Most of us that live in the US are familiar with a web comic. We enjoy great quality, fairly regular updates and great diversity. This American experiment is spreading around the world but I never thought this would ever reach my home country.

So I was genuinely happy and impressed when I discovered OB’s World facebook page. This wasn’t just a good quality web comic that was regularly updated but most important it was funny as hell. It has been a while since I have read something that I could relate in such an intimate level.

OB’s cartoons depict life in El Salvador. Although I have been in the US for more than 15 years, their messages resonate deeply within me. I can relate to them, I can remember situations were I had done the same. Ob’s cartoons makes me happy in a way that only hanging out with my cousins do and for that I am thankful.

OB, keep up the good work, you make a lot of us proud!

OB's World

Using Rails 4 engine/plugin helpers across your entire app

Sometimes you need your rails engine/plugins helpers to work across the host app. An example of this is my Gem Paginas. I provide helper methods to generate menu links, since the menus can exist outside the scope of my gem, it was necessary to include these methods in the host app.

It is quite simple to do so, using the Paginas Gem as an example, all you need to do is add this to your host app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  # your code
  helper Paginas::ApplicationHelper

  # your other code
end

Replace Pagians with your Engine/Plugin name, and that’s it! plain and simple

In Development Environment, the engines/plugins are not automatically reloaded every time there are changes to your files. This can cause problems with these helpers specially if they use the engine’s/plugin’s associations.

Getting tinymce-rails to play nice in Rails 4 and Turbolinks

I am using the plugin on a project and I kept having problems loading the editor on for the second time. The problems materialized in two different ways.

  1. On first page view the editor worked as intended, on second page viewed the editor did not show at all
  2. After trying to fix #1, on first page view the editor worked as intended, on second page viewed the editor showed up but all text disappeared and I was unable to type any new text

So I narrowed down the problem to two issues
Read more

TIL some awesome ActiveRecord behaviors in Rails

So I started using rails about 3 months ago and it has been awesome. ActiveRecords was my first experience using ORM. I wish I had started using this a long time ago since using associations makes life so easy.

As you read tutorials, there are many things that are left out. And unless you find them by doing an unrelated search, it is hard to know what else you could be using. This is the case for me with ActiveRecord associations, there are many things that I have learned because I was looking for something and found some nice feature that someone else was having issues with.

For example this is what I learned today. Lets take the following Models:

class Account < ActiveRecord::Base
  has_many :contacts
  accepts_nested_attibutes_for :contacts
end
class Contact < ActiveRecord::Base
  belongs_to :account
end

First I learned that I can do a search of contacts directly from the @account instance var, so if I am in the account#show view and I want to display all the contacts that contain “Manage” in the title, I can do this:

  managers = @account.contacts.where(:title => "manager")

You can get all the contacts for that account

  all = @account.contacts

You can just iterate over the list without assigning it

  @account.contacts.each do |contact|
   do something
  end

This also works backwards. Lets say you are iterating over all the contacts in your contacts#index view and you want to create a link back to the account the contact belongs to. You can easily do that by doing this:

  <% @contacts.each do |contact| %>
    some styling stuff....

    <%= lint_to contact.account.name, account_path(contact.account.id) %>

    some other styling stuff....
  <% end %>

I wish someone had explained to me earlier how stuff like that works, I think it is just so very useful and should be at the top of any tutorial talking about ActiveRecord Associations