WiFi is always on:
21 May 2015
Battery drainage issue on Android
Posted by আলোর ছটা at 11:09 PM 0 comments
Labels: Android
22 October 2010
Problem in KeyBinding constructor in WPF
Basically Implementation#01 and Implementation#02 should be same. But Implementation sometimes gets exception if modifiers = ModifierKeys.None.
So, use the 2nd way of implementation if required.
Posted by আলোর ছটা at 12:15 PM 0 comments
Labels: WPF
07 July 2010
Code : Strip HTML (Remove HTML Tags)
Posted by আলোর ছটা at 10:01 PM 0 comments
Beginner's Unit Testing in C# using NUnit
C# .NET 2.0 Test Driven Development
The above website is helpful for a beginner though some steps could have been clearer.
Posted by আলোর ছটা at 9:55 PM 0 comments
Code : Download a web page
Posted by আলোর ছটা at 9:46 PM 0 comments
26 May 2010
CSS for printing
I'm feeling excited knowing that we can have different css styles for normal web-view and for printing. Say, in your website there is an image which you don't want to be available for printing. You can do so simply adding some css style (display:none) for printing (media="print"). Here is the example
<html>
<head>
<style type="text/css" media="print">
.noPrint{
display: none;
}
</style>
</head>
<body>
Here is the image: <img class="noPrint" src="myPicture.jpg" />
</body>
</html>
Inline css is like below
@media print {
.noPrint{
display:none;
}
}
Posted by আলোর ছটা at 3:59 PM 0 comments
Labels: CSS
02 May 2010
How to integrate SVN with Visual Studio using AnkhSVN
Download
- Download and install TortoiseSVN (http://tortoisesvn.tigris.org/). It is free. (I'm not quite sure if it is a must, but I installed it.)
- Download and install AnkhSVN (http://ankhsvn.open.collab.net/). It is free.
Enable AnkhSVN for source control
- In Visual Studio, select Tools > Options.
- In the Options window, select "Plug-in Selection" under "Source Control".
- Select "AnkhSVN - Subversion Support for Visual Studio" for "Current source control plug-in".
Connect a project to AnkhSVN
- Open the project in Solution Explorer.
- From the File menu in Visual Studio, select Subversion > Change Source Control .
- In the Change Source Control window, select the row containing your project or solution, and click Connect.
- Click Ok
Add a solution to a repository
- Open your solution in the Solution Explorer
- Right-click your solution and select "Add Solution to Subversion". To add specific projects rather than the containing solution, you can select "Add Selected Projects to Subversion" instead. The "Add to Subversion" dialog appears.
- Specify the URL to your Subversion repository.
- To add the solution to a new subdirectory, select the "Create Folder" option, and enter a directory name and log message.
- Select File > Subversion > Pending Changes. select the files you want to commit, write log message and click on Commit.
For more info: http://help.collab.net/index.jsp?topic=/com.collabnet.doc.anksvn_001/action/ankh_getting_started.html
Posted by আলোর ছটা at 11:07 PM 0 comments
Labels: SVN
15 March 2010
Google Groups Bug: Set a banned member to manager
I have found a critical bug in Google Groups!
In google groups, if you set a banned member's membership to manager, then it seems that that user becomes a non-member manager. Then it becomes impossible to change his/her membership type. You cannot even delete / invite that person again. It's a bug and it's from Google!!
There is a remedy though. You have to use firebug.
- In management task, select 'manage members'. Navigate to the user. You'll find that the checkbox beside that user is disabled.
- Using firebug, find the html of that checkbox and remove the disabled attribute [disabled=""]
- Then check the checkbox.
- Set membership to "regular member" and click corresponding ok.
Posted by আলোর ছটা at 1:00 AM 0 comments
Labels: Google Bug
06 March 2010
How to extract rar file in ubuntu?
sudo apt-get install unrar
Posted by আলোর ছটা at 7:53 AM 0 comments
Labels: ubuntu
26 December 2009
Problem in adjusting brightness in HP laptop using ubuntu
I have a HP laptop and I use ubuntu 9.04. I was facing problem to adjust the brightness of the screen through fn+F7 or fn+F8 keys. I found the solution at http://ubuntuforums.org/showthread.php?t=673946. It should be noted here that it worked after restarting my laptop.
Posted by আলোর ছটা at 9:01 PM 0 comments
Labels: ubuntu
21 December 2009
Problem with audio callback at skype in ubuntu
Solution:
- Go to "Options" (Ctrl+O)
- Click on "Sound Devices"
- Select "pulse" for both "Sound Out" and "Ringing"
- For "Sound In", you have to choose your appropriate option. Change the value for "Sound In" and test the sound by clicking on "Make a test call" and following the directions.
Posted by আলোর ছটা at 11:25 PM 1 comments
20 December 2009
How to shrink image size in ubuntu?
* Use imagemagick (sudo apt-get install imagemagick)
* If it is just one directory worth of images use
mogrify -resize 1024x1024 *.jpg
or
mogrify -resize 25% *.JPG
For more information, http://ubuntuforums.org/archive/index.php/t-518662.html
Posted by আলোর ছটা at 3:06 AM 0 comments
08 October 2009
C# : Dynamically adding control with docking works in reverse way
for (int i = 0; i < 5; i++)
{
Label l = new Label();
l.Text = "Label" + (i + 1);
l.Dock = DockStyle.Top;
panel1.Controls.Add(l);
}
The fact is the first control is being drawn at the bottom. So, I solved it with the help of Controls.SetChildIndex() function in the following way.
Solution:
for (int i = 0; i < 5; i++)
{
Label l = new Label();
l.Text = "Label" + (i + 1);
l.Dock = DockStyle.Top;
panel1.Controls.Add(l);
panel1.Controls.SetChildIndex(l, 0);
}
Improved Solution:
In the given solution, what actually happens is that the new control is added at the top (for the style Dock.Top), then it is moved to the bottom. But this change in position may cause unwanted blinking of UI. To avoid this unwanted situation, follow the following steps
- Add the new control with size (0,0)
- Change its index to 0 (upper solution)
- Resize again the control to actual size
for (int i = 0; i < 5; i++)
{
Label l = new Label();
l.Text = "Label" + (i + 1);
l.Dock = DockStyle.Top;
addControlInContainer(panel1, l);
}
public static void addControlInContainer(Control container, Control control)
{
// save actual size
Size tempSize = control.Size;
// Add the new control with size (0,0)
control.Size = new Size(0, 0);
container.Controls.Add(control);
// Change its index to 0
container.Controls.SetChildIndex(control, 0);
// Resize the control to actual size
control.Size = tempSize;
}
Posted by আলোর ছটা at 6:52 PM 0 comments
31 August 2009
Flash for beginners
Just install Adobe Flash CS3. And follow the tutorials below.
- Beginning Game Programming with Flash (Lakshmi Prayaga & Hamsa Suri) : If you are a stranger to CS3, if you cannot even draw object in CS3, then you'll find it useful.
- ActionScript 3.0 Game Programming University (Gary Rosenzweig) : It is a very nice tutorial, specially for programmers.
Posted by আলোর ছটা at 3:20 PM 0 comments
Labels: Flash
25 August 2009
Big Integer Arithmetics Library in JavaScript
- BigInt.add(n1, n2) returns n1+n2
- BigInt.subtract(n1, n2) returns n1-n2 [n1 must be greater than n2]
- BigInt.multiply(n1, n2) returns n1xn2
- BigInt.dividefunction(n1, n2) returns n1/n2 (integer part only)
- BigInt.remainder(n1,n2) returns n1%n2
- BigInt.isALessThanB(a,b) returns a <>
var BigInt =
{
add : function(n1, n2)
{
if(!this.isValidBigInt(n1) || !this.isValidBigInt(n2))
throw "Not a big integer.";
// make all input to string
n1 = n1 + "";
n2 = n2 + "";
var i;
var sum = "";
// reverse them for comfortable indexing
n1 = this.reverse( this.removeLeading0s(n1));
n2 = this.reverse(this.removeLeading0s(n2));
// make both of same length
var large = n1;
var small = n2;
if(n1.length<>
{
large = n2;
small = n1;
}
// pad with 0's
for(i=small.length; i
small += "0";
// start adding
var carry = 0;
for(i=0; i
{
var subSum = this.digitAt(small, i) + this.digitAt(large, i) + carry;
if(subSum <>
{
sum += (subSum + "");
carry = 0;
}
else
{
sum += (subSum - 10) + "";
carry = 1;
}
}
if(carry == 1)
sum += "1";
return this.removeLeading0s(this.reverse(sum));
},
subtract : function (n1, n2)
{
// n1: larger number
// n2: smalelr number
// returns n1 - n2
if(!this.isValidBigInt(n1) || !this.isValidBigInt(n2))
throw "Not a big integer.";
// make all input to string
n1 = n1 + "";
n2 = n2 + "";
var i;
var large = n1;
var small = n2;
large = this.reverse(large);
small = this.reverse(small);
// pad with 0's
for(i=small.length; i
small += "0";
var carry = 0;
var result = "";
for(i=0; i
{
var upDigit = this.digitAt(large,i);
var downDigit = this.digitAt(small, i);
var diff = upDigit - downDigit - carry;
if(diff >= 0)
{
result += (diff + "");
carry = 0;
}
else
{
result += (diff + 10 + "");
carry = 1;
}
}
return this.removeLeading0s( this.reverse(result) );
},
multiply : function(n1, n2)
{
// returns n1 * n2
// make all input to string
n1 = n1 + "";
n2 = n2 + "";
if(!this.isValidBigInt(n1) || !this.isValidBigInt(n2))
throw "Not a big integer.";
var mul = "";
var extra0s = "";
for(var i=n2.length-1; i>=0; i--)
{
var d = this.digitAt(n2,i);
var subMul = this.multiplyByOneDigit(n1, d);
if(i==n2.length-1)
{
mul = subMul;
}
else
{
extra0s += "0";
subMul += extra0s;
mul = this.add(mul, subMul);
}
}
return this.removeLeading0s(mul);
},
divide : function(n1, n2)
{
// returns Math.floor(n1/n2)
// make all input to string
n1 = n1 + "";
n2 = n2 + "";
if(!this.isValidBigInt(n1) || !this.isValidBigInt(n2))
throw "Not a big integer.";
n1 = this.removeLeading0s(n1);
n2 = this.removeLeading0s(n2);
var i;
var divisor = n2;
var result = "";
var rem = "";
for(i=0; i
{
rem += (n1[i]+"");
var iRem = rem;
if(this.isALessThanB(iRem, divisor))
{
result += "0";
}
else
{
var subDiv = this.shortDivide(iRem, divisor) + "";
result += (subDiv + "");
rem = this.subtract(iRem, this.multiply(subDiv, divisor));
}
}
return this.removeLeading0s(result);
},
isALessThanB : function (a,b)
{
if(!this.isValidBigInt(a) || !this.isValidBigInt(b))
throw "Not a big integer.";
// make all input to string
a = a + "";
b = b + "";
a = this.removeLeading0s(a);
b = this.removeLeading0s(b);
if(a.length != b.length)
return a.length <>
for(var i=0; i
{
var dA = this.digitAt(a,i);
var dB = this.digitAt(b,i);
if(dA != dB)
return dA <>
}
return false;
},
remainder : function(n1,n2)
{
// returns n1 % n2
// make all input to string
n1 = n1 + "";
n2 = n2 + "";
var d = this.divide(n1,n2);
return this.subtract(n1, this.multiply(d,n2));
},
shortDivide : function(a, b)
{
// a is less than 10b
var i=0;
while(!this.isALessThanB(a,b))
{
a = this.subtract(a,b);
i++;
}
return i;
},
multiplyByOneDigit : function (n, d)
{
// n: string
// d: number (0-9)
var n = this.reverse(n);
var carry = 0;
var result = "";
for(var i=0; i
{
var m = this.digitAt(n, i) * d + carry;
result += (m%10 + "");
carry = Math.floor(m/10);
}
if(carry > 0)
result += (carry + "");
return this.reverse(result);
},
reverse : function(s)
{
var iLen = s.length;
var strRev = "";
for(var i=iLen-1; i>=0; i--)
strRev += s.charAt(i);
return strRev;
},
digitAt : function(s, i)
{
var c = s[i];
return parseInt(c);
},
removeLeading0s : function(n)
{
n = n + "";
var result = "";
var i=0;
while(n[i] == '0')
i++;
if(i
{
result = n.substr(i);
}
if(result == "")
result = "0";
return result;
},
isValidBigInt : function(n)
{
if(typeof n != "string" && typeof n != "number")
return false;
// make it string (from both number & string)
n = n+"";
if(n.length == 0)
return false;
// check all digits
for(var i=0; i
if(n[i] < '0' || n[i] > '9')
return false;
return true;
}
};
var num1 = "26093683160935360286936021";
var num2 = "4864306873315646901285";
var resAdd = BigInt.add(num1, num2);
var resSub = BigInt.subtract(num1, num2);
var resMul = BigInt.multiply(num1, num2);
var resDiv = BigInt.divide(num1, num2);
var resRem = BigInt.remainder(num1, num2);
var resLess = BigInt.isALessThanB(num1, num2);
Posted by আলোর ছটা at 1:05 AM 0 comments
Labels: JavaScript

