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
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.
I’m trying to finish the Go Tour and one of the exercises was to write a Fibonnaci closure, that is, a closure that generates the Fibonnaci sequence.
It was a cool exercise to learn on closure works in Go, so to remind myself of this later, I’ll share it here:
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 :)
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.
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.
"x" is the number you want to rotate. "n" is the number of rotations you want to apply.
While writing this I actually felt how slow python’s math lib is. I’ve wrote this a while ago, but iirc a version I wrote using string operations was actually faster than this.
I managed to get to a pretty fast version later on but it involves caching all functions in local variables, replacing range with xrange and a bunch of other little improvements. I’ll keep this version because it pretty readable and it’s pretty self-explanatory on how to shift rotate numbers.
It was very fun trying to get every little millisecond I could from the code and I might just write a post on the differences of performance for each implementation I did.
result = x
mag_x = len(str(x))
for i in range(0,n):
mag_res = len(str(result))
first = 0 if mag_x > mag_res else int(result/pow(10,mag_res))
tmp = result - first*pow(10,mag_res)
result = tmp*10 + first