Wednesday

Gvim editor tutorial: moving back trough changes


The changelist remembers the position of every change that can be undone.
You can move back and forwards through the changelist using the commands:
g;
g,


You can view the contents of the changelist by running the command:
:changes

Vim also maintains a jumplist,
remembering each position to which the cursor jumped, rather than scrolled.
You can move backwards and forwards through the jumplist with the commands:

ctrl-O
ctrl-I

You can view the contents of the jumplist by issuing the command:
:jumps

you can follow the keyword under the cursor with the command (ctags required):
ctrl-]

see also:
* :help changelist
* :help :changes
* :help jumplist
* :help :jumps
* :help jump-motions

more...

Friday

Visual Studio Mercurial,GIT,SVN links

Mercurial:
* free hosting : http://mercurial.selenic.com/wiki/MercurialHosting
* VisualHG: a plugin for Visual Studio: http://sharesource.org/project/visualhg/
* Windows Explorer client: http://tortoisehg.bitbucket.org/
GIT:

* Free hosting: http://git.wiki.kernel.org/index.php/GitHosting
* GitExtensions: a Visual Studio plugin http://code.google.com/p/gitextensions
* Windows Explorer client: http://code.google.com/p/tortoisegit/
SVN:

* VisualSVN server FREE installer: http://www.visualsvn.com/server/
* AnkhSVN plugin for Visual Studio: http://ankhsvn.open.collab.net/
* Windows Explorer client: http://tortoisesvn.tigris.org/

more...

Wednesday

How can I make yes/no questions is a batch file?


mplayer.exe -cache 1024 -speed 1.66 %1
SET /P ANSWER=Do you want to delete %1 file (Y/N)?
echo You chose: %ANSWER%
if /i {%ANSWER%}=={y} (goto :yes)
if /i {%ANSWER%}=={yes} (goto :yes)
goto :no
:yes
rm -f %1
exit /b 0
:no
echo file wasn't deleted
exit /b 1

more...

EventHandler event in usercontrol

First, we create a new, simple EventUserControl, with this code in it:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="EventUserControl.ascx.cs" Inherits="EventUserControl" %>

Page title:
<asp:TextBox runat="server" ID="txtPageTitle" />
<asp:Button runat="server" ID="btnUpdatePageTitle" OnClick="btnUpdatePageTitle_Click" Text="Update" />


All just text and server controls that we know. In the CodeBehind, it looks a bit like this:
public partial class EventUserControl : System.Web.UI.UserControl
{
private string pageTitle;
public event EventHandler PageTitleUpdated;

protected void btnUpdatePageTitle_Click(object sender, EventArgs e)
{
this.pageTitle = txtPageTitle.Text;
if(PageTitleUpdated != null)
PageTitleUpdated(
this, EventArgs.Empty);
}

public string PageTitle
{
get { return pageTitle; }
}
}



We have defined a pageTitle container variable and a property for it. Then we have a new thing, an event. As you can see, it's defined much like any other kind of field, but it is a bit different. The theory about is explained in the C# tutorial, so we won't get into that here.
In the Click event of our button, we set the pageTitle field. Then we check if PageTitleUpdated, our event, is null. If it's not, it means that we have subscribed to this event somewhere, and in that case, we send a notification by calling the PageTitleUpdated as a method. As parameters, we send this (a reference to the UserControl it self) as the sender, and an empty EventArgs parameter. This will make sure that all subscribers are notified that the pageTitle has just been updated.

Now, in our page, I've declared our UserControl like this:
<%@ Register TagPrefix="My" TagName="EventUserControl" Src="~/EventUserControl.ascx" %>


And inserted it like this:
<My:EventUserControl runat="server" ID="MyEventUserControl" OnPageTitleUpdated="MyEventUserControl_PageTitleUpdated" />

As you can see, we have defined an event handler for the PageTitleUpdated event like if it was any other server control. In the CodeBehind of our page, we define the simple event handler for the UserControl event like this:
protected void MyEventUserControl_PageTitleUpdated(object sender, EventArgs e)
{
this.Title = MyEventUserControl.PageTitle;
}





more...

Tuesday

use editor to type text into firefox

there is Firefox add-on that allows to exit to type text in your favorite editor and then move to browser:
It's All Text!
more...

Friday

howto create and call json webservice in asp.net example

1.Add to webservice method this tag System.Web.Script.Services.ScriptService(),
so it will be looking like this:

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Web.Script.Services
Imports WebControlLibrary
Imports Ubill.Business
Imports System.ComponentModel

<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> <System.Web.Script.Services.ScriptService()> _
Public Class AtlasHub
Inherits System.Web.Services.WebService


<WebMethod(True)> _
Public Function AdvanceCustomerDelete(ByVal CustomerID As String) As String
Return cachefactory.AdvanceCustomerDelete(CustomerID)
End Function

End Class




2.On aspx page add this script manager binding :

<asp:ScriptManager runat="server" ID="scriptManagerId">
<Scripts>
<asp:ScriptReference Path="~/common/AtlasHub.js" />
</Scripts>
<Services>
<asp:ServiceReference Path="~/common/AtlasHub.asmx " />
</Services>
</asp:ScriptManager>



3.AtlasHub.js is javascript file those contains maintenance functions:


// Business functions
// // -------------------------------------------
function AdvanceCustomerDelete( customerID , onSuccessAdvanceCustomerDelete){
YouBillWeb.AtlasHub.AdvanceCustomerDelete(customerID,onSuccessAdvanceCustomerDelete,onTimeOut,onFailed);
}

// Maintenance functions
// -------------------------------------------
// This is the callback function invoked if the Web service
// succeeded.
// It accepts the result object, the user context, and the
// calling method name as parameters.
function OnSucceededWithContext(result, userContext, methodName)
{
var output;

// Page element to display feedback.
var RsltElem = document.getElementById("ResultId");

var readResult;
if (userContext == "XmlDocument")
{

if (document.all)
readResult =
result.documentElement.firstChild.text;
else
// Firefox
readResult =
result.documentElement.firstChild.textContent;

RsltElem.innerHTML = "XmlDocument content: " + readResult;
}

}

// This is the callback function invoked if the Web service
// succeeded.
// It accepts the result object as a parameter.
function onSuccess(result, eventArgs)
{
// Page element to display feedback.
var RsltElem = document.getElementById("ResultId");
RsltElem.innerHTML = result;
}

function OnSucceeded(result, eventArgs)
{
// Page element to display feedback.
var RsltElem = document.getElementById("ResultId");
RsltElem.innerHTML = result;
}


// This is the callback function invoked if the Web service
// failed.
// It accepts the error object as a parameter.
function onFailed(error)
{
// Display the error.
var RsltElem = document.getElementById("ResultId");
RsltElem.innerHTML =
"Service Error: " + error.get_message();
}

function onTimeOut(error)
{
// Display the error.
var RsltElem = document.getElementById("ResultId");
RsltElem.innerHTML =
"Service Error: " + error.get_message();
}

if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();

more...

Tuesday

no-ip script in python

change username/password/host in this script below

import urllib
import time
import sys
import string

f = urllib.urlopen('http://my-user-name:-mypass@dynupdate.no-ip.com/nic/update?hostname=myhost.no-ip.org')
sug = f.read()
f.close()
print sug

here are additional on no-ip API documentation:
request sample

protocol description

response codes

more...

Saturday

ssl certificate sec_error_untrusted_issuer

I had problem with the expired or not valid certificates in almost all application on my computer: Firefox, pidgin, Internet Explorer.
The cause was : date on my computer was set wrong and it thought I was years in the past!
Once I fixed the date and time, all of these problems vanished.

more...

Wednesday

how to show hide div in asp.net

1.add this javascript function:


<script type="text/javascript">
function showHideExcel(){
thisElement=document.getElementById('overlayExcel')
if (!thisElement) return;
if(thisElement.style.visibility == "visible"){
thisElement.style.visibility = "hidden";
}else {
thisElement.style.visibility = "visible";
}
}
</script>



2.add this div to asp.net code


<div id="overlayExcel" name="overlayExcel" style="visibility:hidden;position:absolute; top: 120px; left: 900px;background-color:white;display:block;">
<div style="padding: 3px; background-color: #CCCCCC; border: 1px solid #666666;">
<table border="0" border="0" cellspacing="0" cellpadding="0" >
<tr><td height="30">Start Date:&nbsp;</td> <td><asp:TextBox ID="txtExcelStartDate" runat="server" /></td></tr>
<tr><td height="30">End Date:&nbsp;</td> <td><asp:TextBox ID="txtExcelEndDate" runat="server" /><br></td></tr>
<tr><td height="30" colspan="2"><asp:Button ID="btnExcelMe" runat="server" Text="Open Excel Report" OnClick="OpenExcelReport" />
<input type=button value="Cancel" onclick="showHideExcel();"></td>
</tr>
</table>
</div>
</div>



that's it.
more...

imagemagic add text to image

rem different types of text annotations on existing images rem cyan yellow orange gold rem -gravity SouthWest rem draw text and anno...