Category Archives: Uncategorized

vim replace multiple spaces with tab

xxxx            xxxx xxxxxxxxxxx
yy              y y yyyyyy
zzzzzzzzzz      zzzzzzzzzzz zzz zzz

Change the consecutive spaces with a tab so it looks like this
:%l
xxxx^Ixxxx xxxxxxxxxxx
yy^Iy y yyyyyy
zzzzzzzzzz^Izzzzzzzzzzz zzz zzz

:%s/ \+/^I/

SQL Server 2008: Forgot to add an administrator account?

Or should I say: SAP installation script didn’t add your account as a SQL admin and now you’re locked out…

Follow this instructions:

http://blogs.ameriteach.com/chris-randall/2009/12/11/sql-server-2008-forgot-to-add-an-administrator-account.html?printerFriendly=true

Basically, stop SQL, and with an admin command prompt go to C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn

Start SQL in single user with
sqlservr.exe -m

Open another console and run
sqlcmd -s instance -e

Create your user with
create login [domain\user] from windows
go

Grant yourself some nice permissions
exec sp_addsrvrolemember @loginname=’domain\user’, @rolename=’sysadmin’
go

Close the command prompt. Press control-c in the console running the single user engine and close it.

Restart the SQL service and log in…

How to increase volume in Windows

Excellent tip!!!

http://www.nextofwindows.com/sound-volume-not-loud-enough-here-is-how-you-can-boost-it/

The article contains images showing the steps, and these are the basic steps:

1. Right-click on the speaker icon at your system tray, and choose Playback devices, which opens up Playback tab in Sound dialog box.

2. Right-click the device, and choose Properties.

3. In Speakers properties window, go to Enhancements, and check “Loudness Equalization” option.

 

My Windows 8.1 does not have the policy editor gpedit.msc so how can I change the stupid thumbnails file-in-use policy?

These posts show how to fix the problem using gpedit.msc

http://www.sitepoint.com/switch-off-thumbs-db-in-windows/

And this site shows where in the registry are the policies stored

http://gpsearch.azurewebsites.net/#2645

So for this policy User Configuration\Administrative Templates\Windows Components\File Explorer\, this is the registry key HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer, and this is the value of the key: NoThumbnailCache

Simple Input Dialog In C#

Muhammad's Blog

Have you ever tried looking for a Input Dialog box in C#? I did recently and fully expecting something similar to the MessageBox.Show() found out that there wasn’t one. So I browsed the web for a quick solution, and did’nt find exactly what I wanted so I decided to make my own. Here is how I did it for those of you facing the same problem.

Just to be clear, my goals were :

  • Simple looking dialog, with caption, description, and a textbox.
  • Option to press ok and also cancel out.
  • Easy way to return the value.

Okay lets start, create a form named InputDialog.cs with the following code in InputDialog.Designer.cs but make sure you rename the namespace to your own :

Now you should have a form that looks like this :

Newly created input dialog

Now this form needs some code behind it to function, so clear everything behind it and paste…

View original post 36 more words

Windows – Take ownership of files or folders

This POS problem has happened to me on several occasions [attaching my Win 7 C: drive to my new Win 8 laptop; attaching a Windows 2008 drive (on VMware) to another server] and seems that there’s no way to fix it from the GUI.

http://answers.microsoft.com/en-us/windows/forum/windows8_1-security/access-denied-error-applying-security-info/e8d77b3f-3e46-489b-bb55-80a7423a45e2

a.     In the start menu search Command Prompt or “CMD”.

b.     From the results, right click Command Prompt and Click Run as Administrator.

c.    At the command prompt, type “takeown /f <foldername> /r /d y” without quotes and then press ENTER. (Replace <foldername> with the path of the folder).

d.    Then, type “icacls <foldername> /grant administrators:F /T” without quotes and hit enter. (Replace <foldername> with the path of the folder).

Invalid Postback or callback argument . Event validation is enabled using in configuration or in a page. For security purposes, this feature verifies that arguments to Postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the Postback or callback data for validation.

I was getting this error when pressing the asp:Button that was inside the asp:UpdatePanel. The code was in a Web User Control

      <asp:TemplateField HeaderText="Fecha Expiración" SortExpression="FechaExp" ItemStyle-HorizontalAlign="Center" >
         <ItemTemplate>
            <asp:Button ID="btnExpComFecha" runat="server" Text="[+]" style="background-color: Transparent"
                BorderStyle="None" ToolTip="Mostrar u ocultar la fecha de expiración del documento"
                CommandName="ExpComFecha" CommandArgument="<%# CType(Container,GridViewRow).RowIndex %>" />
            <asp:UpdatePanel ID="panFecha" runat="server" Visible="False">
               <ContentTemplate>
                  <asp:Calendar ID="calFechaExp" runat="server" FirstDayOfWeek="Monday" CellPadding="1"
                     SelectedDate='<%# IIf(IsDBNull(Eval("FechaExp")), DateTime.MinValue, Eval("FechaExp")) %>'
                     VisibleDate='<%# IIf(IsDBNull(Eval("FechaExp")), DateTime.Now, Eval("FechaExp")) %>' >
                  </asp:Calendar>
                  <asp:Button ID="btnUpdFecha" runat="server" Text="Actualizar" CommandName="ActualizarFecha"
                     CommandArgument="<%# CType(Container,GridViewRow).RowIndex %>" />
               </ContentTemplate>
            </asp:UpdatePanel>
         </ItemTemplate>
      </asp:TemplateField>

I fixed it with this code, that I based on this http://www.dotnetspider.com/resources/29004-A-control-with-ID-button-could-not-be-found.aspx


    Private Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
      Dim oScriptManager As ScriptManager = ScriptManager.GetCurrent(Me.Page)
      For Each oRow As GridViewRow In Me.grdDocumentosSuplidor.Rows
         Dim oButton As Button = DirectCast(oRow.FindControl("btnUpdFecha"), Button)
         oScriptManager.RegisterPostBackControl(oButton)
      Next
   End Sub

Another option was to use an asp:LinkButton, that doesn’t have that problem…