Skip navigation
1 2 3 4 Previous Next

Emilio Moretti's Blog

49 posts

Advanced Vi

Posted by emilio.moretti Sep 27, 2011

Switching between multiple files

(Check an even easier wasy using Vim >7 below!)

Open multiple files at once with e.g. vi main.pl maintenance.pl and then hop between them with:

:n

:prev

and see which file are open with  :args

You can also create a split screen view using :sp <filename>

or :sp and then execute :n to open the next file

 

You can also use tabs (introduced in Vim 7)

Opening multiple files in several tabs:

vim -p file1 file2 file3

You can switch between tabs with :tabn and :tabp (or use the GUI!!), With :tabe <filepath> or :tabnew <filepath> you can add a new tab; and with a regular :q or :wq you close a tab. If you map :tabn and :tabp to your F7/F8 keys you can easily switch between files.

Of course, you can open an empty tab just by typing :tabnew or :tabe (there is no need to use a filename to open a new file )

 

Using buffers

http://www.bo.infn.it/alice/alice-doc/mll-doc/linux/vi-ex/node23.html

> If you have a lot of files open in Vim, how do you switch to the one >
you want in the easiest fashion?

:help buffer

:b N


or

:b filename

Next buffer:

:bn

Previous

:bp

To open a split screen use any of the previous commands but add an "s" in front of it. ie:

:sb 2

If there are not that many files and you don't have Vim 7 you can also split your screen in multiple files: :sp <filepath>. Then you can switch between splitscreens with Ctrl+W and then a arrow key in the direction you want to move.

 

Mixing tabs and buffers

To retab all files in buffer list

:tab sball

Sabe demasiado

Posted by emilio.moretti Jul 14, 2011

Alguna vez se tomaron el trabajo de buscar toda la info que google sabe sobre nosotros? Los siguientes links les van a mostrar la información sobre sus cuentas de gmail almacenada en sus servidores junto con un detalle especificando si es pública o no.

https://www.google.com/dashboard/

Estos son todos los contactos con los que nos relaciona, directa o indirectamente:

http://www.google.com/s2/search/social?hl=es#socialconnections

¡Escalofriante!

In summary:

If your email server requires an Exchange proxy, you are doomed. You will need Davmail.

Else{

use synaptic to install"evolution-mapi", which adds Exchange MAPI protocol support to Evolution.

}

 

http://www.petenetlive.com/KB/Article/0000378.htm

http://atomicvindaloo.com/?p=340

  1. Forward from localhost (7374) to the guest (4444):

    VBoxManage modifyvm "MyCustomVM" --natpf1 "guestselenium,tcp,,7374,,4444"
  2. Connect to the guest using localhost:7374

As a virtual machine environment user, I regularly create ‘base’ images of machines that I can reuse – a base Windows Server 2003 environment, or SQL Server 2005 environment for example. That way, when I need a new machine, I can simply create a copy of the virtual disk and add any additional software I need, saving myself valuable time creating new virtual environments.

With VMWare’s various offerings, copying a virtual disk is easy: copy the disk in Windows Explorer and add it to a newly created VM; VMWare will detect that the disk was a copy and create a new unique identifier (UUID) for the disk before adding it to the VM. Easy and painless. Not so with VirtualBox.

With VirtualBox, copying a virtual disk is a bit of a pain. If you copy the disk in Windows Explorer and try and use it in a new VM, VirtualBox will have a hissy fit and display the error shown below. A bit of a ‘wordy’ way to say that it already knows about this disk, don’t you think?

VirtualBox - Add Copied Virtual Disk - Duplicate UUID Error

The publicised way around this is to use the command-line VBoxManage CloneHd tool, however there is another – secret and undocumented – way to clone a disk: the setvdiuuid tool. Lets look at these two methods in detail.

Cloning a Virtual Disk – The ‘Supported’ Method

Cloning a disk is (IMHO) a clunky and Unix-y type way of creating a duplicate disk. We need to invoke the CloneHd command of the VBoxManage tool, supplying the disk to clone and the name of the new ‘cloned’ disk. In its simplest form, you would do something like this at the command-line:

VBoxManage clonehd "DiskToClone.vdi" "ClonedDisk.vdi"

The VBoxManage tool will chug away and clone the disk for you, creating a new UUID in the process:

virtualbox-clonehd-2

The cloned disk can now be used on a new VM without incurring the ‘I already know about this disk’ error.

Copying a Disk – The ‘Unsupported’ Method

The alternative to the CloneHd tool is an undocumented option available in VBoxManage – the setvdiuuid command. As the command help states: ‘This is a development tool and shall only be used to analyse problems. It is completely unsupported and will change in incompatible ways without warning’. Because of this, let me add a little disclaimer: I don’t accept any responsibility if you completely destroy your VM using this procedure. Having said that, it appears to work without issue, so I’m more than happy to use it myself – just make sure that you take a backup of you virtual disk before using it if necessary.

To use the tool, simply create a copy of the virtual disk’s VDI file in Windows Explorer; open the Windows command-line and issue the setvdiuuid command for the newly copied disk:

VBoxManage internalcommands setvdiuuid "CopiedDisk.vdi"

The tool will create a new UUID and assign it to the disk:

virtualbox-setvdiuuid

The new copied disk can now be used on a new VM without incurring the ‘I already know about this disk’ error.


Read more: http://www.modhul.com/2009/06/17/how-to-clone-or-copy-a-virtualbox-virtual-disk/#ixzz1PGJMvLXr

http://srackham.wordpress.com/cloning-and-copying-virtualbox-virtual-machines/

Ifyou've ever typed a command at the Linux shell prompt, you've probably already used bash—after all,it's the default command shell on most modern GNU/Linux distributions. The bash shell is the primary interface to the Linux operating system—it accepts, interprets and executes your commands,and provides you with the building blocks for shell scripting and automated task execution.

bash's unassuming exterior hides some very powerful tools and shortcuts. If you're a heavy user of the command line, these can save you a fair bit of typing. This document outlines ten of the most useful tools:

 

1. Easily recall previous commands

bash keeps trackof the commands you execute in a history buffer, and allows you to recall previous commands by cycling through them with the Up and Down cursor keys.For even faster recall, "speed search" previously-executed commands by typing the first few letters of the command followed by the key combination Ctrl-R; bash will then scan the command history for matching commands and display them on the console.Type Ctrl-R repeatedly to cycle through the entire list of matching commands.

 

2. Use command aliases

Ifyou always run a command with the same set of options, you can have bash create an alias for it. This alias will incorporate the required options, so that you don't need to remember them or manually type them every time. For example, ifyou always run ls with the -l option to obtain a detailed directory listing, you can use this command:

 

bash> alias ls='ls -l'

To create an alias that automatically includes the -l option. Once this alias has been created, typing ls at the bash prompt will invoke the alias and produce the ls -l output.

You can obtain a list of available aliases by invoking alias without any arguments, and you can delete an alias with unalias.

 

3. Use filename auto-completion

bash supports filename auto-completion at the command prompt. To use this feature, type the first few letters of the file name, followed by Tab. bash will scan the current directory, as well as all other directories in the search path, for matches to that name. If a single match is found, bash will automatically complete the filename for you. If multiple matches are found, you will be prompted to choose one.

 

4. Use key shortcuts to efficiently edit the command line

bash supports a number of keyboard shortcuts for command-line navigation and editing. The Ctrl-A key shortcut moves the cursor to the beginning of the command line, while the Ctrl-E shortcut moves the cursor to the end of the command line. The Ctrl-W shortcut deletes the word immediately before the cursor, while the Ctrl-K shortcut deletes everything immediately after the cursor. You can undo a deletion with Ctrl-Y.

 

5. Get automatic notification of new mail

You can configure bash to automatically notify you of new mail, by setting the $MAILPATH variable to point to your local mail spool. For example, the command:

 

bash> MAILPATH='/var/spool/mail/john'
bash> export MAILPATH

Causes bash to print a notification on john's console every time a new message is appended to john's mail spool.

 

6. Run tasks in the background

bash lets you run one or more tasks in the background, and selectively suspend or resume any of the current tasks (or "jobs"). To run a task in the background, add an ampersand (&) to the end of its command line. Here's an example:

 

bash> tail -f /var/log/messages &
[1] 614

Each task back-grounded in this manner in assigned a job ID, which is printed to the console. A task can be brought back to the foreground with the command fg jobnumber, where jobnumber is the job IDof the task you wish to bring to the foreground. Here's an example:

 

bash> fg 1

Alist of active jobs can be obtained at any time by typing jobs at the bash prompt.

 

7. Quickly jump to frequently-used directories

You probably already know that the $PATH variable lists bash's "search path" - the directories it will search when it can't find the requested file in the current directory. However, bash also supports the $CDPATH variable,which lists the directories the cd command will look in when attempting to change directories. To use this feature, assign a directory list to the $CDPATH variable, as shown in the example below:

 

bash> CDPATH='.:~:/usr/local/apache/htdocs:/disk1/backups'
bash> export CDPATH

Now,whenever you use the cd command, bash will check all the directories in the $CDPATH list for matches to the directory name.

 

8. Perform calculations

bash can perform simple arithmetic operations at the command prompt. To use this feature, simply type in the arithmetic expression you wish to evaluate at the prompt within double parentheses, as illustrated below. bash will attempt to perform the calculation and return the answer.

 

bash> echo $((16/2))
8

9. Customize the shell prompt

You can customize the bash shell prompt to display—among other things—the current username and host name, the current time, the load average and/or the current working directory. To do this, alter the $PS1 variable, as below:

 

bash> PS1='\u@\h:\w \@> '
bash> export PS1
root@medusa:/tmp 03:01 PM>

This will display the name of the currently logged-in user, the host name, thecurrent working directory and the current time at theshell prompt. You can obtain a list of symbols understood by bash from its manual page.

 

10. Get context-specific help

bash comes with help for all built-in commands. To see a list of all built-in commands, type help. To obtain help on a specific command,type help command, where command is the command you need help on. Here's an example:

 

bash> help alias

...some help text...

Obviously,you can obtain detailed help on the bash shell by typing man bash at your command prompt at any time.

 

11. Execute several commands in a single line

Use the double-ampersand operator in bash to provide conditional execution:

  $ cd mytmp && rm *

Two commands separated by the double ampersands tells bash to run the first command and then to run the second command only if the first command succeeds (i.e., its exit status is 0). This is very much like using an  if statement to check the exit status of the first command in order to protect the running of the second command:

  cd mytmp
  if (( $? )); then rm * ; fi

The double ampersand syntax is meant to be reminiscent of the logical and operator in C Language. If you know your logic (and your C) then you’ll recall that if you are evaluating the logical expression A AND B, then the entire expression can only be true if both (sub)expression A and (sub)expression B evaluate to true. If either one is false, the whole expression is false. C Language makes use of this fact, and when you code an expression likeif (A && B) { ... }, it will evaluate expressionAfirst. If it is false, it won’t even bother to evaluateBsince the overall outcome (false) has already been determined (by A being false).

So what does this have to do with bash? Well, if the exit status of the first command (the one to the left of the &&) is non-zero (i.e., failed) then it won’t bother to evaluate the second expression—i.e., it won’t run the other command at all.

If you want to be thorough about your error checking, but don’t want if statements all over the place, you can have bash exit any time it encounters a failure (i.e., a non-zero exit status) from every command in your script (except in while loops and if statements where it is already capturing and using the exit status) by setting the -e flag.

  set -e
  cd mytmp
  rm *

Setting the -e flag will cause the shell to exit when a command fails. If the cd fails, the script will exit and never even try to execute the rm * command. We don’t recommend doing this on an interactive shell, because when the shell exits it will make your shell window go away.

 

 

Sources:

http://www.techrepublic.com/article/master-the-linux-bash-command-line-with-these-10-shortcuts/5827311

http://www.devshed.com/c/a/BrainDump/Better-Command-Execution-with-bash/

Instalan el plugin para firefox:

http://reloadevery.mozdev.org/

 

Abren el mail y con el click derecho en cualquier parte de la página van a ReloadEvery -> Custom -> 3:30

Y listo. La sesión se va a mantener activa. Ojo que son 3 minutos 30 segundos, ni 4 min, ni 5. Tienen que ser asi o sino en algún momento justo da el timing y cierra la sesión igual. 3:30 is the sweet spot.

 

Parece de gusto pero es más rápido que configurar cualquier cliente de correo, y además tiene la ventaja de que abrir un tab de firefox es mucho menos resource hungry que abrir un cliente de correos y dejarlo en background.

We’ve all had days where we get stuck. We stare at a problem for hours, trying to find the most perfect solution, not wanting to commit until we’re completely certain that our approach is flawless. Invariably we spend more time searching for a solution than we’d spend implementing a slightly flawed one.

But, it HAS to be perfect, right?

 

Well, actually it doesn’t need to be perfect. It just needs to solve the problem! Trying to get everything perfect is a pretty good indicator that you are suffering from “Code Paralysis” (or “Analysis Paralysis").

 

The analogy I use for this kind of mental behaviour is that we are standing at the base of the mountain, walking around it trying to find the perfect route to climb all the way to the top in one go. However our mountain is huge and it’s not possible to see clearly all the way to the very summit. So how can we possibly derive the perfect route from the ground? Are we destined to spend all our time walking around in circles, trying in vain to find the perfect starting point for our perfect ascent? No! What we need to do is find a spot that looks favourable and start climbing.

It’s not likely that we’ll reach the summit from our initial climb, but it is likely that we’ll learn a lot more about the parts of the mountain we can’t see from the ground. We might find that the path which starts out easy ends up running into an impassable overhang or ravine. We might see that a path which initially looks unfavourable leads to a much easier climb further up. Eventually, after a number of attempts at climbing the mountain, hopefully we’ll find a route that leads us to the summit. Even then, as we stand atop our newly conquered mountain, its likely that we’ll spot an otherwise hidden path which would have been twice as easy to traverse as the one we climbed.

 

The curse of experience is that we begin to see that a lot of mountains have the same rough shapes and features. So when we chance upon a mountain that sits outside our previous climbing strategies, we can easily become paralysed by not having a pre-determined plan for effortlessly scaling our problem. It can be initially frustrating to have to resort back to our original climbing strategies, especially when deadlines or bad weather are moving in. However I often find that, once I overcome my initial “Analysis Paralysis”, it’s often the most enjoyable type of climbing there is.

Pick a spot that looks favourable and start climbing!

 

 

http://altdevblogaday.org/2011/03/14/mountain-climbing/

http://www.c2.com/cgi/wiki?AnalysisParalysis

Leyendo el resumen de noticias encontré un artículo que se titulaba "Por qué mi computadora es tan lenta?" y como cualquier usuario de Linux instintivamente respondí "mi computadora no es lenta". Para mi sorpresa la respuesta del artículo difería ampliamente: "Porque la usás... y necesita mantenimiento"... a lo que largué mi carcajada y me pregunté... qué clase de sistema andaría más lento por usarlo? la computadora debería estar prendida por años brindando servicios sin que haya pérdidas de memoria, ni su performance decaiga, porque en caso contrario el sistema operativo tendría fallas y eso no es aceptable... o acaso tolerarían que su auto tuviese que ser detenido y vuelto a poner en marcha cada 5 cuadras? La respuesta seguramente es no y en el caso de una PC es exactamente lo mismo (aunque muchos intenten disuadirnos y convencernos de lo contrario).

 

Sin más que una gran sonrisa en mi cara, continué leyendo el artículo y encontré que los síntomas de una PC que requería mantenimiento eran los siguiente (lamento postearlos en inglés):

 

  • Popups
  • Stutter or lag when starting a program
  • Excessive startup time
  • Mouse or PC becomes momentarily stuck often
  • Icons change for unknown reason
  • Desktop suddenly flickers or new programs appear
  • Your Internet Homepage changes or you have connection problems

(Lo leo y todavía me sigo riendo...)

Ahi fue cuando me di cuenta de que se trataba el artículo. Era simplemente un artículo que hablaba del nefasto sistema operativo Windows.

 

Para aquellos que sigan siendo felices usandolo pero que lamentablemente tienen que compartir la PC con otras personas en sus hogares, les dejo el artículo para que gasten su valioso tiempo tuneando su PC para volverla casi rápida otra vez:

http://www.techwarelabs.com/three-steps-to-a-faster-computer-pc/

Todavía está en etapa de "review". a ver si es cierto. si se puede refutar. si le encuentran algún error... etc. Esperemos que no pase como con http://en.wikipedia.org/wiki/Perepiteia que es un invento genial, al que nadie le da bola (significaría la caida del monopolio de la energía. una total locura)

 

 

Sin más preámbulo:

http://romvf.wordpress.com/2011/01/19/open-letter/

http://science.slashdot.org/story/11/01/20/1546206/Polynomial-Time-Code-For-3-SAT-Released-PNP

 

An anonymous reader writes "Vladimir Romanov has released what he claims is a polynomial-time algorithm for solving 3-SAT.  Because 3-SAT is NP-complete, this would imply that P==NP.  While there's still good reason to be skeptical that this is, in fact, true, he's made source code available and appears decidedly more serious than most of the people attempting to prove that P==NP or P!=NP.  Even though this is probably wrong, just based on the sheer number of prior failures, it seems more likely to lead to new discoveries than most.  Note that there are already algorithms to solve 3-SAT, including one that runs in time (4/3)^n and succeeds with high probability.  Incidentally, this wouldn't necessarily imply that encryption is worthless:  it may still be too slow to be practical."

 

Es open source:

https://github.com/anjlab/sat3

El viernes llegó de buenos aires un modem MUY económico que me había encargado para reemplazar el que entregan en comodato los de Acerca porque para mi era ese el problema del lag en los juegos y el límite de sólo poder descargar 1 archivo y que todo lo demás me de timeout.

 

El resultado fue MUY satisfactorio. Parece como si hubiese contratado otro servicio.

 

Dejo el link a mi blog con la explicación por si alguien más sufrió problemas de latencia alta, o de conexión en general:

 

http://resumiendooo.blogspot.com/2010/12/reducir-lag-con-acerca-junin.html

Has this ever happened to you? You're merrily typing away in some application, minding your own business, when-- suddenly-- a dialog pops up and steals the focus from you.

Example of a dialog stealing focus from an application

At best, your flow is interrupted. You'll have to switch back to the  window that you were using, figure out where you were, and resume your  work.

But it can be worse. So, so much worse. If you happen to be typing  something that can be interpreted as an action by that dialog-- and  remember, pressing the space bar is the same as clicking a button when  it happens to have the focus -- you could suddenly and very much  accidentally be in a world of pain. Like this poor, unfortunate soul,  who recently posted a plaintive comment to my XP Automatic Update Nagging post.

 

Great news! Microsoft developed a solution to this problem! Microsoft's  most talented programmer figured out how to make "Reboot later" mean  "Reboot when user says reboot". It only took some tweaking to 1 line of  code, 180 days for approvals from 80 managers, 80 resource files for  different languages, and 18 days for testing in one of the languages. It  worked.

The programmer opened a SourceSafe^H^H^H^H^H^H^H^H^H^H^H Team Foundation  window in order to check in the fix. An expert programmer, she was used  to using the keyboard. She didn't click her mouse on the "OK" button,  she just hit the Enter key.

The "Reboot now" / "Reboot later" prompt flashed so briefly, she  didn't even notice it. She thought she hadn't pounded the Enter key hard  enough. Looking at Team Foundation's "OK" button still waiting  there for her to hit the Enter key to check in her work, she hit the  Enter key again.

The check in started. The check in got killed while her workstation  rebooted. There we remain today, with the check in half-in and half-out,  unusable, with no good copy of the code. So that's why the fix was  never released.

 

It's a perfect example of how stealing the user's focus can lead to catastrophic results if the user is particularly unlucky. Unfortunately, this burden falls heaviest on us keyboarders.

Another classic example is the IE download notification window, which  loves to pop up, steal the focus, and tell you the great news: your  download is complete! Oh, and your newly downloaded file is copying to  its destination! Hooray! Unfortunately, this very same download  notification dialog also contains a "Cancel" button. Guess which  button just so happens to have the focus when this pops up? Why you'd  want to cancel a download after it is complete is a mystery to me, but  I've inadvertently pressed the space bar on this dialog more than once.

Stealing focus from the user is never acceptable. I can't imagine any circumstance where this would be desirable or even defensible behavior. Modal dialogs are bad enough,  but this is even worse-- it's almost a system modal dialog, so  self-important that all work must cease as the user is forced to pay  attention to whatever earth-shattering message it urgently has to  deliver. It's an extreme form of stopping the proceedings with idiocy. I'm not the first person to complain about this, of course. Fellow members of the "Don't Steal My Focus" club wrote about this back in 2002, again in 2005, and a few months ago. It's not exactly an unknown or new problem. So why do we have to keep talking about it and dealing with it? What gives?

The strange thing is, there are provisions built into the operating  system to protect us from badly written, focus stealing applications.  The ForegroundLockTimeout registry setting is expressly designed to prevent applications from stealing focus from the user. The OS  silently converts that inappropriate focus stealing behavior into  friendlier, less invasive taskbar button flashing, which is the subject  of the ForegroundFlashCount registry setting.

I've seen this work. Most of the time, it does work. This setting  is enabled by default in Windows XP and Vista. And yet, applications  are occasionally able to steal the focus from me and screw up my flow.  I'd say it happens a few times a week on average. It's perplexing. I'm  wondering if it's because badly behaved programmers abuse the "Always on  Top" window flag in a misguided attempt to get the user's attention.  I suppose as long as there are bad programmers, there will be some  unorthodox way they can devise to steal the focus from the user. At some  level, sufficiently advanced incompetence is indistinguishable from  malice. Maybe we'd have better luck educating programmers on the evils  of focus stealing and, more generally, the futility of unnecessary notifications the user isn't going to read anyway.

But in the meantime, please don't steal my focus. I'm using it right now. Really. I am.

 

http://www.codinghorror.com/blog/2007/12/please-dont-steal-my-focus.html

Airline labor unions often have debates so  convoluted that we tend to find them just aggravatingly myopic and  selfish, but then it goes to another level.

 

The newest example is what happened in Argentina over the weekend, where Buenos Aires was effectively shut down because two douchebag Aerolineas Argentinas pilots from two different unions got into a fist fight with each other.  Instead of saying something like "yeah, our pilots probably shouldn't  have done that," their respective unions threw temper tantrums and went  on strike to protect them.


The result: the airline had to be shut down. Argentina's  chief domestic airport, Aeroparque Jorge Newbery, had to be closed. The  country's top international airport, Ezeiza International Airport, tried  to handle the overload, and more or less failed. Tens of thousands of travelers saw their flights moved or canceled. Hundreds of thousands saw their travel weekend become a disaster.

 

Apparently these two pilots flying the same plane, and one  brought a camera into the cockpit to document something that the other  didn't think should be documented. A fight broke out and the pilots were  duly dragged from the cockpit by security. Putting aside questions like  "wow, how long must they have been fighting for security to get there,"  this is where things got fun. And by fun we mean "exactly like a grade  school playground."

 

Since each of these pilots were on a union team, both unions immediately went on an emergency strike to ensure that neither pilot get punished. In fairness that's what unions are supposed to do:  protect their members, even when those members might deserve to be  fired. Which is fair enough, except it sent the country's largest  airline into a complete shutdown. Airports around the country went into  total disarray, and even freeways became clogged with people going back  and forth from their flights. To top everything off, this morning  unionized flight attendants from LAN Argentina then went on a "surprise strike" - the AP's language, not ours - because of  work rule violations that may or may not actually exist.

 

And because of that, Buenos Aires, an Alpha World City, the  second largest metropolitan area in all of South America, couldn't  function over the weekend.

 

 

http://www.jaunted.com/story/2010/11/15/135137/64/travel/How+the+Dumbest+Airline+Strike+Ever+Shut+Down+Argentina+Over+the+Weekend

DailyTech noticed that Microsoft has launched a new testimonial-based advertising campaign to attack  open-source software. The software giant's ad claims using OpenOffice  can lead to bad grades, and insinuates that open source software is  unreliable and has higher support costs.

The video then  jumps to select industry sources complaining that OpenOffice increased  their support costs and was unreliable, compared to Microsoft's Office  suite.  It also complains that OpenOffice is slow, requires additional  training, has poor support for macros in its Spreadsheet software, and  features poor document conversions to-and-from word.

And the ad also targets a group that frequently makes use of OpenOffice  due to budget reasons -- students.  Tisome Nugent, a public school  teacher comments, "I've had students that have turned in files that  they've converted from OpenOffice with formatting problems that affect  their grade negatively."

One commenter even blasts "open-code" in general, while another recalls  he and his co-workers breathing a "collective sigh of relief" when his  workplace ditched OpenOffice.

find ./ -type f -exec sed -i 's/OldString/NewString/g' {} \;