meld – syntax coloring

October 11, 2007

meld is a visual diff/merge tool for Linux. To enable syntax for some other extensions/mime types, edit file /usr/lib/meld/filediff.py

def set_highlighting_enabled(buf, fname, enabled):
extmap = {
...
  "pl": "application/x-perl",
  "pm": "application/x-perl",
  "Makefile": "text/x-makefile",
  "mk": "text/x-makefile",
  "js": "application/x-javascript",
  "sql": "text/x-sql"

remote desktop/vnc in kubuntu

October 11, 2007

krfb keeps crashing when I try to VNC to my Kubuntu box. The solution is below. I do it differently but adapt it as needed.

 * Install x11vnc:sudo apt-get install x11vnc

* Create a vncpassword if you haven't already:

mkdir ~/.vnc
x11vnc -storepasswd ~/.vnc/passwd

* Create your config file in ~/.x11vncrc to look something like this:

forever
localhost
rfbauth /home//.vnc/passwd
display :0

#You can use rfbport to specify a different port (default is 5900).
#Remove localhost if you plan on connecting from a second computer
#more info: man x11vnc

* Create a file "~/.kde/Autostart/x11vnc" with the following contents:

#!/bin/bash
/usr/bin/x11vnc &

* Set the executable permissions on the autostart file:

chmod +x ~/.kde/Autostart/x11vnc

At this point you need to log out of KDE and back in to test your setup. I use SSH with port forwarding to establish my remote connections. That topic is beyond the scope of this document though. If you do not use port forwarding you will need to remove the "localhost" line from your .x11vncrc file.

Source: https://bugs.launchpad.net/ubuntu/+source/kdenetwork/+bug/39046

video ram for storage

October 11, 2007

Interestingly you can use unused video memory as storage (… for swap) in Linux. Slashdot article pointed out it might be slow for AGP cards. Linky: http://gentoo-wiki.com/TIP_Use_memory_on_video_card_as_swap and http://hedera.linuxnews.pl/_news/2002/09/03/_long/1445.html

Source: http://hardware.slashdot.org/hardware/07/10/11/1424247.shtml

bash/svn stuffs

August 30, 2007

- remove unknown files

$ svn st | grep “^?” | while read svnaction file\

do

rm -frv $file

done

- or

$ svn st | sed ‘s/^? *//’ | xargs rm -frv

emulation, virtualization, for free & more

January 25, 2007

Been there, done that 

Others

How to fix Security Validation errors in Sharepoint asp.net page

January 22, 2007

Problem: I got “The security validation for this page is invalid” when submitting web form

For reasons of security, Microsoft Windows SharePoint Services by default does not allow you to make posts from a Web application to modify the contents of the database unless you include security validation on the page making the request. Two kinds of security validation can be used, depending on whether the code on the page applies globally to a virtual server or Windows SharePoint Services deployment, or to a single site or site collection within the deployment.

Security Validation Type 1:

Updating data for a site or site collection. Two steps to be performed.

Step 1:

Add a page directive and a FormDigest control to the page making the request. The following directive registers the Microsoft.SharePoint.WebControls namespace:

<%@ Register Tagprefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls”
   Assembly=”Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral,
   PublicKeyToken=71e9bce111e9429c” %>

Step 2:

Include a FormDigest control within the form as follows:

<form id=”Form1″ method=”post” runat=”server”>
   <SharePoint:FormDigest runat=”server”/>
   <asp:Button id=”Button1″ style=”Z-INDEX: 101; LEFT: 282px; POSITION: absolute;
      TOP: 282px” runat=”server” Text=”Button”></asp:Button>
</form>

Inserting this control on an ASPX page generates a security validation, or message digest, to help prevent the type of attack wherein a user is tricked into posting data to the server without knowing it. The security validation is specific to a user, site, and time period and expires after a configurable amount of time. When the user requests a page, the server returns the page with security validation inserted. When the user then submits the form, the server verifies that the security validation has not changed. For more information about this control, see the FormDigest class.
Security Validation Type 2:

Updating global data

Web applications that use methods of the Microsoft.SharePoint.Administration namespace, such as for creating or deleting sites and for global administrative customizations, require a different security validation. Add the following code to the .vb r .cs file in an application:

SPGlobalAdmin globalAdmin = new SPGlobalAdmin();
Context.Items[SPGlobalAdmin.RequestFromAdminPort] = true;
Page.RegisterHiddenField(“__REQUESTDIGEST”, globalAdmin.AdminFormDigest);

This security validation uses the AdminFormDigest property of the SPGlobalAdmin class to insert a message digest on the page in the browser, registering the digest as a hidden field through the RegisterHiddenField method of the System.Web.UI.Page class. In addition, the RequestFromAdminPort field specifies that the context of the request is through the administrative port

Source: MSD2D

Gas – which is good, tips, etc…

January 20, 2007

Grades of Gasoline
So I asked him what’s the benefit of having midgrade, or 89 octane, gasoline? No cars ask that the minimum octane level should be 89…most say the car needs a minimum of 87 or 91 octane. He reported two reasons.

1. Psychologically, people think 89 is better than 87 because it has a higher octane number. Partially true, but not quite. People think 89 is better because they think it is a cleaner gas and/or will help your car engine run cleaner and smoother. All is false, except the last point, which is semi-true. A higher octane gas does not clean your engine better…the cleaning agents are due to the additives, which is normally added in all grades. If you car only requires 87 gas, putting in 89 won’t make your engine cleaner. For the most part, it won’t even make your car run smoother, unless you have a very old car. This leads to the 2nd point.

2. He added that the ONLY time you ever need to use grade 89 gasoline is if you have a really old car, and the car starts knocking. The engine may need a higher octane to reduce the knocking due to the compression ratio. If 89 doesn’t get rid of the engine knocking, you will be forced to use 91 octane and above. Most cars these days have knock sensors that prevent knocking if a lower octane is used, so you shouldn’t experience knocking at all. Since that is the case, using 89 octane will not help your car at all. Only two octanes are needed, 87 and 91.

 Additives
I wrote about additives in my previous article Tips to Save Gas in point number 1. I wanted to know how important these additives are, and if they really do what they are supposed to do, which is keep your engine clean. This is what he had to say.

The additives are important because they really do clean your engine. Examples are Chevron’s Techron and Shell’s V-Power. BUT, it is NOT NEEDED EVERYTIME. This means, you DON’T have to put in gas with these cleaning additives everytime you fill up. It won’t hurt your car if you do, but also isn’t necessary to put it in so frequently. He told me that you only need to use these types of gas every once in a while. For example, you can put in gas from Costco or other gas stations, then every month or two, put in gas from the big companies such as 76, Shell, Chevron, etc. This will ensure that your car engine will stay clean, AND you will save big bucks by not using big gas companies which usually charge more than others.

How To (Cars): Tips to Save Gas

3. Instead, let go of the gas pedal and allow your car to coast and naturally slow down due to friction.

4. Have your windows down if you are driving below 40 mph, and use your A/C with the windows up if you are driving over 40 mph.

5. Keep your tires inflated to its proper pressure.

7. Remove all unwanted things in your trunk and back seat. 

Sources:
http://ramblingnews.blogspot.com/2007/01/random-tips-truth-on-gas.html
http://ramblingnews.blogspot.com/2006/11/how-to-save-gas.html
http://ramblingnews.blogspot.com/2006/12/how-to-more-ways-to-save-gas-part-ii.html

Link: http://www.toptiergas.com

Updating webparts in the GAC without using IISReset

January 18, 2007

  When deploying new versions of Webparts to the GAC, the general recommendation is to subsequentially run IISReset, since Sharepoint will not reload GAC-dlls as it would, had they been deployed to /bin.

However, for a production system this is a bit drastic (as it will cause all users to experience the dreaded “Service Unavailable” while IIS restarts), so I have been looking for alternatives.

It turns out that in order to reload a GAC-dll, all that is needed is to force an application pool recycle for the application pool Sharepoint is running within (default is MSSharePointPortalAppPool).
This can be accomplished using the MMC, or by running the following script (useful for webpart installers).

 Option Explicit
 '*** spsapppoolrecycle.vbs
 '*** Script to recycle Sharepoint Portal Server application pool
 '*** For use when deploying updated version of Webparts in the GAC
 '*** Author: Michael Christensen, mac@landscentret.dk
 '*** Provided AS IS with no warranties
 '*** Heavily based on this posting by David Wang:
 '*** http://tinyurl.com/4k26n
 Const WEBSITEID = 1
 Dim objApp
 Dim AppPoolId
 Dim objAppPool
 Set objApp = GetObject("IIS://localhost/w3svc/" & WEBSITEID  & "/root")
 AppPoolId = objApp.AppPoolId
 WScript.Echo "AppPoolID: " & AppPoolId
 Set objAppPool = GetObject( "IIS://localhost/w3svc/AppPools/" + AppPoolId )
 objAppPool.Recycle()
 WScript.Echo "AppPool recycled."

The script assumes that Sharepoint is installed on the virtuel server with ID 1. This will usually be the case, otherwise the actual ID could probably be determined programmatically.

Source: http://dotnetforum.dk/blogs/mac/archive/2005/07/18/65920.aspx

Manage windows services with sc

December 6, 2006

Sharepoint – email to all site’s users

November 30, 2006

Save file as c:\Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\LAYOUTS\1033\email.aspx. It’ll be accessible from http://portal/sites/***/_layouts/1033/email.aspx, ie. append /_layouts/1033/email.aspx to the Url. On the top, import the required classes


 <%@ Page language=”C#”     %>
<%@ Register Tagprefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”Utilities” Namespace=”Microsoft.SharePoint.Utilities” Assembly=”Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Import Namespace=”Microsoft.SharePoint” %>
<%@ Import Namespace=”System.Text” %>
<%@ Register Tagprefix=”WebPartPages” Namespace=”Microsoft.SharePoint.WebPartPages” Assembly=”Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<% SPWeb spWeb = SPControl.GetContextWeb(Context); %>

 Then somewhere get the users and generate links

<%
StringBuilder emails = new StringBuilder();
foreach (SPUser user in spWeb.SiteUsers)
{
 if (user.Email != null && user.Email.Length > 1)
 {
  emails.Append(user.Email + “;”);
 }
}
%>
<a href=”mailto:<%=emails.ToString()%>” mce_href=”mailto:<%=emails.ToString()%>” >Send email to…</a>
<a href=”mailto:?cc=<%=emails.ToString()%>” mce_href=”mailto:?cc=<%=emails.ToString()%>” >send email cc…</a>

Don’t forget to dispose the objects

<%
spWeb.Dispose(); emails = null;
%>

Sample file: email.aspx

Remote Desktop / Terminal Services Tip

November 21, 2006

If I can’t gain access to a server using Terminal Services because both sessions are used up (happen quite often). I can use another server to check the status of the first one. As long as the logged in user has administrative rights on the non-accessible machine I would run this:

qwinsta /server:12.12.12.12

Where 12.12.12.12 is the IP address or name of the non-accessible machine.

This will display something like this:


> qwinsta /server:12.12.12.12
SESSIONNAME USERNAME ID STATE TYPE DEVICE
console 0 Conn wdcon
rdp-tcp 65536 Listen rdpwd
rdp-tcp#470 Bob 1 Active rdpwd
rdp-tcp#471 Jane 3 Active rdpwd

Now I know that Bob and Jane are the two that are logged in. Since Jane left the office 20 minutes ago I know that she forgot to log off. I don’t know where Bob is but I only need one session so I’ll ignore him for now.

To disconnect Jane’s session I would type this:

rwinsta /server:12.12.12.12 3

Notice the 3 which is the session ID I found from using qwinsta above.

Source: Managing Terminal Services Sessions Remotely

Royal TS: Easy Remote Desktop Connections. Better than Windows’ Remote Desktop MMC snap-in. Free and even come with source code (C#.NET)

visionapp Remote Desktop. vRD is a tool which allows the management of RDP connections to servers.

Useful Firefox 2 Extensions

November 11, 2006
  • All-in-One Gestures
  • NoScript
  • OpenDownload
  • Paste and Go
  • PDF Download
  • Stop-or-Reload button
  • Super DragAndGo
  • Aavark

Url: https://addons.mozilla.org/


Follow

Get every new post delivered to your Inbox.