Dalla Rosa

0 notes &

Dynamically adding attribute accessors in Ruby

A simple way for adding attribute accessors to a class dynamically:

class MyClass
  def add_attr(name, value)
    self.class.send(:attr_accessor, name)
    instance_variable_set("@#{name}", value)
just call the add_attr method passing the name of the accessor (as a string) and a value that will be assigned to the variable.
You can also turn this in to a module so that you can easily add the functionality to all your classes.
I’m actually using this in a script I made to easily change data in long csv files.
I wanted to be able to convert CSV files into Ruby objects before changing the data, even if the fields change from file to change.
I know some people are gonna say “just use an existing gem or so”, but this is being fun.

Filed under tech ruby programming accessors

1 note &

Fixing garbage text on terminal on Linux and Mac

Sometimes you just happen to cat a binary file and it just messes up your terminal output and all can see and type is garbage.

Normally here you’d just give up and reopen your terminal but here’s another solution: Just type the command below:

 echo -e \\033c

All you’re doing is sending an ESC(033 is the octal version of the ASCII control key “ESC”) + a letter “c” to the console, which is a VT100 command to reset the terminal to its default settings. If you’re curious about other VT100 commands, take a look at this page. You can send them all using

echo -e 

followed by the the codes in ASCII. This works in any VT100 compatible terminal which means that you’re safe to use it on your Linux or Mac machine.

Edit: As some people said in the comments and at G+, you can just use the “reset" command, which is actually doing the above and some more.

To read more about the reset command, check the man pages here.

Filed under linux mac tech terminal vt100 memotoself

0 notes &

plist2ota - Generate OTA Manifests from plists

A friend of mine was in need of a script to automatically generate the OTA Manifests needed to distribute iOS apps internally through the iOS Developer Enterprise License

So I wrote a little Ruby script that uses the plist gem for creating a Ruby Array from the plists information. One limitation I found in the plist gem is that it can’t parse binary plists. Right now I’m working on implementing that in Ruby and see if I can get it added to the gem but, for now, I just added to the package this perl script I found, indicated by this page.

If your plist is a binary one, just convert the plist to XML using the plutil.pl script and then using plist2ota.rb to generate your OTA Manifest. 

The link is here: https://github.com/dallarosa/plist2ota

Requests, issues and sugestions, please use Github’s issues page :)

Filed under plist ota manifest apple ios development tech linux macosx ruby perl

0 notes &

CommandT and Ctrl+S on Mac OS X

One of the best plugins I’ve found for vim is CommandT.  It lets you open files in a very speedy and intuitive way, making it very simple to search files and open them in tabs, splits or vertical splits. Or so it should be. On OS X, opening a file on a new split doesn’t really work. You should be able to do it using the Ctrl-S shorcut but it just doesn’t work.

Today I decided to go after this problem. Looking around the net, I found an article explaining the reason:

 I found a related tip indicating that by default, Terminal.app reserves Ctrl-S for old-fashioned XON/XOFF flow control.

Ok, so the Terminal app doesn’t allow us to use Ctrl-S because it’s a reserved shortcut. What to do?

Simple, just add the lines below in your ~/.bashrc

stty -ixon -ixoff

It will disable the above behavior and free Ctrl-S and Ctrl-Q for use in terminal apps!

Reminder: Just adding that to your bashrc won’t change the settings in the currently open terminal windows. Type the command above on the terminal so you can have the benefits right now, or reopen all your sessions.

Filed under vim macosx commandt terminal tech programming

0 notes &

In the end, it’s all about DNA

Today, I want to talk about company culture, and the best analogy I could find was a child. So bear with me until the end and let’s us not deviate into the field of children psychology.

They way a child is raised by its parents is very important and decisive in its future. Children tend to take in account their parents tastes and way of thinking when molding their own and most of the we can say that they grown to be just like their parents were, for good or for bad.

I believe companies are just the same. The founders way of thinking, their DNA is gonna be what’s going to decide the way a company is going to develop in the future. That DNA will influence the hiring process, it will determine what’s going to be the primary focus of the company and in no time, that will take a life of its own it will become what people generally call the “culture” of the company.

In a house of teachers and academics, you can say it’s very probable that the children will tend to go the academic way and it’s fairly common to find that most singers and musicians were influenced by parents who played instruments or sang in the church choir.  You can see the same phenomenon with companies: The egocentric guy who had an interest in calligraphy and cared for the design of the things created the company that became known for it’s excellency in design and for it’s centrism. The two PhD guys who found a company who is known for it’s focus in engineering, research and experimentation. 

We inherit these ways of thinking and doings things from our parents, but once we’re grown and take our lives into our own hands we might think that maybe that’s not the way we should think, that’s not the way we should act. However, we also find out how hard it is to change our ideas and habits. It’s not uncommon to see cases of domestic violence involve men and women who were either victims or were witnesses of domestic violence in their own homes, by their own parents. In the same way, it’s pretty hard for a company to change its way after years of having a defined mentality. So, it can be very easy for a company who has been focused on sales and sales being it’s primary strength and focus for all its existence to say that it will become a technology company and will make its engineering task force in primary focus. However when that company doesn’t really have many people (or any person at all) with actual engineer experience and  focus in its decision-making department, as its leadership, that vision might as well be impossible, or at best very hard to implement.

I won’t say it’s impossible, nothing is. However, imagine how hard it is to act in a way that just contradicts what you’ve being told to be wrong, or at least not the most correct. Do I root for the Miami Heat or the Hornets? To I focus on sales numbers of technical excellency?  What’s my religion? Do I want a company known for its profitability or for being on the bleeding edge of technology, for offering the best environment for its engineering staff?

Google, Apple and Facebook are making the billions and everyone knows that but for most people in the tech world those companies are synonyms of “Engineering excellence”, “Design Excellence”, “Hacker culture” (Move fast, break things). So, whenever you’re invited to work for a company who doesn’t have an engineering history but who says that it wants to become a company for engineers, remember that in the end it’s its DNA who will really dictate how things work and make sure you understand what that will mean.

Filed under company culture tech