Estrutura de Diretórios Linux

Uma pequena referência:

/bin Arquivos binários (“executáveis”) de comandos essenciais do sistema.
/boot Arquivos de boot (inicialização; boot-loader; grub, lilo); kernel.
/dev Dispositivos (devices) de entrada/saída: floppy, hardisk, cdrom, usbs
/etc Arquivos de configuração e scripts de inicialização.
/home Diretório local (home) de usuários.
/lib Bibliotecas e módulos compartilhados com freqüencia
/mnt Diretório de montagem de dispositivos, sistemas de aquivos e partições
/opt Para instalação de programas não oficiais da distribuição
/proc Diretório virtual (RAM) onde rodam os processos ativos
/root Diretório local do superusuário (root)
/sbin Arquivos de sistema essenciais (binários do superusuário).
/tmp Arquivos temporários gerados por alguns utilitários
/usr Arquivos de usuários nativos da distribuição.
/usr/local Para instalação de programas não oficiais da distribuição
/usr/src Arquivos fontes do sistema necessarios para compilar o Kernel
/var Arquivos de log e outros arquivos variáveis

Advice: Never link directly to a Microsoft page

Is it only me or nobody can reliably link to a Microsoft site without ending with a broken link less than two weeks after?

Also, adding to the fact that their search engine is totally utter crap, once you hit a dead link the only option left is to ask Google for that missing page. Well, whenever I feel like referencing Microsoft’s site again, I think I’ll just link to a Google query for the page title instead.

CheckGroupBox Control

checkgroupbox

Have you ever needed a GroupBox with a internal CheckBox for enabling/disabling its contents readily draggable from your Visual Studio Toolbox?

Well, making this control is rather simple, and, indeed, many people should have done it already. But not a lot of them decided it was worth sharing their code with others. So this post is aimed at the very very beginner to C# and to System.Windows.Forms. But, if you are a newcomer to C# and just want its very best, I really advice you to take a look in Windows Presentation Foundation (WPF) rather than in Windows.Forms. Forms is better suited for lightweight or conventional applications needing a common interface, for those that can bear a lack of visual appeal in exchange for simplicity and fewer headaches with the user interface. Also if you plan to support older Windows versions or even other operating systems and architectures through Mono, then I fear you have no option but to use Windows.Forms.

using System;
using 
System.Drawing;
using 
System.ComponentModel;
using 
System.Windows.Forms;

namespace cSouza.Utils.WinForms
{

    /// <summary>
    ///   Enumerates possible actions to be performed by a
    ///   CheckGroupBox whenever its Check state changes.
    /// </summary>
    
public enum CheckGroupBoxCheckAction
    {
        None, Enable, Disable,
    }

    /// <summary>
    ///   Represents a Windows control that displays a frame around
    ///   a group of controls with an optional caption and checkbox.
    /// </summary>
    
public class CheckGroupBox : System.Windows.Forms.GroupBox
    {

        private CheckBox m_checkBox;
        private bool 
m_contentsEnabled = true;
        private 
CheckGroupBoxCheckAction m_checkAction =
            
CheckGroupBoxCheckAction.Enable;

        /// <summary>
        ///   Initializes a new instance of CheckGroupBox class.
        /// </summary>
        
public CheckGroupBox()
        {
            
this.SuspendLayout();

            this.m_checkBox = new CheckBox();
            this
.m_checkBox.AutoSize = true;
            this
.m_checkBox.Location = new Point(80);
            this
.m_checkBox.Padding = new Padding(3000);
            this
.m_checkBox.Checked = true;
            this
.m_checkBox.TextAlign ContentAlignment.MiddleLeft;
            this
.m_checkBox.CheckedChanged += new EventHandler(CheckBox_CheckedChanged);
            this
.Controls.Add(this.m_checkBox);

            this.ResumeLayout(true);
        
}

        #region Public Properties
        
/// <summary>
        /// Gets or sets a value indicating whether the
        /// CheckGroupBox is in the checked state.
        /// </summary>
        
[Category(“Appearance”)]
        [DefaultValue(
true)]
        
public bool Checked
        {
            
get return this.m_checkBox.Checked}
            
set this.m_checkBox.Checked = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether the controls
        /// contained inside this container can respond to user
        /// interaction.
        /// </summary>
        
[Category(“Behavior”)]
        [DefaultValue(
true)]
        
public bool ContentsEnabled
        {
            
get return this.m_contentsEnabled}
            
set
            
{
                
this.m_contentsEnabled = value;
                this
.OnContentsEnabledChanged(EventArgs.Empty);
            
}
        }

        /// <summary>
        /// The text associated with the control.
        /// </summary>
        
public override string Text
        {
            
get return this.m_checkBox.Text}
            
set this.m_checkBox.Text = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating how a CheckGroupBox
        /// should behave when its CheckBox is in the checked state.
        /// </summary>
        
[Category(“Behavior”)]
        [DefaultValue(CheckGroupBoxCheckAction.Enable)]
        
public CheckGroupBoxCheckAction CheckAction
        {
            
get return this.m_checkAction}
            
set
            
{
                
this.m_checkAction = value;
                this
.OnCheckedChanged(EventArgs.Empty);
            
}
        }

        /// <summary>
        /// Gets the underlying CheckBox control contained
        /// in the CheckGroupBox control.
        /// </summary>
        
[Category(“Misc”)]
        
public CheckBox CheckBox
        {
            
get return this.m_checkBox}
        }
        
#endregion

        #region Event Handling
        
/// <summary>
        /// CheckGroupBox.CheckBox CheckedChanged event.
        /// </summary>
        /// <param name=”e”></param>
        
protected virtual void OnCheckedChanged(EventArgs e)
        {
            
if (this.m_checkAction !CheckGroupBoxCheckAction.None)
            {
                
// Toggle action depending on the value of checkAction.
                //   The ^ means a xor operation. The xor operation
                //   acts as a inversor, inverting the second operand
                //   whenever the first operand is true.

                this.ContentsEnabled =
                    
(this.m_checkAction == CheckGroupBoxCheckAction.Disable)
                     ^ 
this.m_checkBox.Checked;
            
}
        }

        /// <summary>
        /// ContentsEnabled Changed event.
        /// </summary>
        /// <param name=”e”></param>
        
protected virtual void OnContentsEnabledChanged(EventArgs e)
        {
            
this.SuspendLayout();
            foreach 
(Control control in this.Controls)
            {
                
if (control != this.m_checkBox)
                {
                    
// Set action for every control, except for
                    //  the CheckBox, which should remain intact.
                    
control.Enabled = this.m_contentsEnabled;
                
}
            }
            
this.ResumeLayout(true);
        
}

        private void CheckBox_CheckedChanged(object sender, EventArgs e)
        {
            
this.OnCheckedChanged(e);
        
}
        
#endregion

    }
}

As usual, just create a new empty class inside your project and copy & paste this code inside it. Press F6 to build your current solution and then you’ll be able to select CheckGroupBox using the Toolbox of the Visual Designer Editor of Visual Studio. Feel free to change the namespace name (or anything else) if you wish.

The End of The Earth?

ZZ2B58355E

The first attempt to circulate a beam in the Large Hadron Collider (LHC) will be made on 10 September.

Let’s just hope everything works fine… Because otherwise the entire world may be sucked into the first human-created black hole!

Update: The test has finished and…. we are still alive! Well, for the while, at least! Thats because the experiment did not actually collide any particles yet, it just served to test the creation of the clockwise and counter-clockwise beams, without crossing each other. The Cern team hasn’t yet announced when it will start smashing particles together, but low-energy collision may happen as soon as the next few days.

Update 2: The countdown has started again. The deadline is now October 21, 2008!

Note: It’s obvious the Large Hadron Collider will not “create a mammoth black hole that will swallow up the earth“. While it may look as a giant device in our human eyes, in universe terms it lacks even the tiniest fraction of the power needed to create such – still hipothetical – black holes. The countdown exists because a lot of things may change in the way we comprehend the universe. Things that till today have only been predicted by theory may finally be observed in the real world.

Google Desktop on Windows x64

google-desktop

Google Desktop now offers a command line flag to force installation on 64 bit machines. Just install with

 googledesktopsetup.exe /force

If you don’t wanna deal with the command line, just right click the setup executable, then click “Create Shortcut“. Right-click the newly created shortcut, select properties, then add the /force to the end of the target path text box. Hit ok and finally double click it. Voilà!

Google Desktop used to work on 64 bit Windows (like Windows XP x64 Edition and Windows Vista 64 bit), but ceased installing some months ago. I have used Google Desktop normally on my desktop before, but I got surprised when a newer version went out simply telling me it wouldn’t install because Google Desktop wasn’t anymore supported on my platform, leaving me with no software at all. I don’t know exactly to which extent the “not supported” definition goes, but, for now, the software has been running just well. The Google Desktop Help Center reports that certain features may not work correctly, so you have been warned.

Nossa! O Google Chrome travou. Deseja reiniciá-lo agora?

Simplesmente não consigo entrar nas configurações do Chrome sem crashar o browser. Talvez seja porque estou rodando Windows XP x64 Edition, ou porque, logo na instalação, quando o setup avisava que estava prestes a importar as configurações do Internet Explorer, cliquei no link azul “Alterar preferencias de importação” [ou algo assim] e o setup simplesmente fechou e sumiu, sem mais nem menos.

Achei legal o espanto na mensagem de erro. Nossa! Ainda bem que é beta =P