0

SSH Reverse Tunneling

Hari yang x berapa memberansangkan walapun banyak keje siap hari ni.
Hari ni aku nak cerita sikit pasal SSH Remote Tunnling. Aku buat ni sebab aku nak masuk ke Linux board aku yang aku remote site tapi dia x de public ic untuk access direct. So kena la buat ssh reverse tunneling.

Dekat Controller :
ssh -R 2000:127.0.0.1:22 root@remoteserver.com

Dekat PC aku pulak kena buat 2 connection.

1st untuk buat poft forwarding port ke local port.
ssh -L 90:127.0.0.1:2000 root@remoteserver.com

jadi aku dah buat tunneling port 90 (pc aku) ke port 2000 kat remote server --> controller port 22.

Jadi, untuk masuk ke console controller aku tu :
ssh root@127.0.0.1 -p 90

jadi boleh la aku masuk ke console controller aku tu dan buat la apa-apa yang aku nak buat.
0

.NET Licensing

I'm going to put the license component in my .Net program and considering the license for developer and run time.Microsoft already provide several licensing model in .NET such as Registry or Lic File.As for me, I'm prefer to use WMI with a propitiatory algorithm such as encryption to generate the license as I can generate an unique license key for each computer.

This how we could do that :

For Developer (Design Time) :

if (System.ComponentModel.LicenseManager.CurrentContext.UsageMode ==
System.ComponentModel.LicenseUsageMode.Designtime)
{
throw new System.Exception("Design Time License Required");
}



For run time :


if (System.ComponentModel.LicenseManager.CurrentContext.UsageMode == System.ComponentModel.LicenseUsageMode.Runtime)
{
throw new System.Exception("Run Time License Required");
}


For more details you can refer to these links :

  1. http://www.developer.com/net/net/article.php/11087_3074001_1/Applications-Licensing-using-the-NET-Framework.htm
  2. http://msdn.microsoft.com/en-us/library/fe8b1eh9.aspx
0

How to display your web site logo on the address bar and in the favorites list

Source : http://www.chami.com/tips/internet/110599I.html

Want to make your web site standout in crowded favorites lists in browsers and address bars? How about displaying your logo next to links to your site.
First, you have to create a logo for your site; a very tiny logo to be specific. The size of the logo should be 16x16 pixels and it should be saved as a Windows icon file (logo.ico for example). If your image editor doesn't support saving files in Windows icon format, you can use the following online tool or download an icon editor from a shareware site.

Once you have an icon file with your logo, you're ready to take the final step. Following methods will work in Explorer 5.x and higher without having any negative effects on other browsers.
Method 1
This is the easiest method to implement and it will work regardless of the particular page on your site users choose to add to their favorites list. Don't worry if you don't have access to your web site root; take a look at the next method.
If you have access to the root of your web site, simply save your icon file as "favicon.ico" there. For example, if your web site is "www.chami.com", your icon file should be available at "www.chami.com/favicon.ico". The web browser will look for favicon.ico whenever your site is added to the favorites list and if it is found at the root of your web site, the icon will appear next to the link to your site.
Method 2 If you don't have access to the root of your web site, you have to add the following tag to your web page so that the browser will know where to look for your icon. Unlike before, this time you can save the icon under any name ending with ".ico" We'll use the name "logo.ico" and assume that your web site is under the directory "~your_directory".

<link rel="SHORTCUT ICON" href="/%7Eyour_directory/logo.ico">



Above tag should be inserted in-between the and tags.
By the way, you can specify multiple logos for multiple pages using the second method. Simply save your icons using unique names, such as logo1.ico, logo2.ico, logo3.ico for example, and replace "logo.ico" in the above HTML code with the name of the icon you want to use for any particular page.
0

innodb_file_per_table

innodb_file_per_table
Source : http://capttofu.livejournal.com/11791.html

In a previous post, I was trying to figure out the most optimal way to switch from two large innodb table space files to using innodb_file_per_table to take advantage of some of the benefits of this setting. I had one part of it solved, which was to stop MySQL, add innodb_file_per_table to the my.cnf, then restart, perform a "no-op" alter of "ALTER TABLE t1 ENGINE=InnoDB" which would cause the table to be re-created an it's own .ibd file. The remaining problem was how to be able to resize the huge table space files after converting all the tables to a smaller size (in my case from 10GB to 10MB).

Someone suggested a better way:

1. Alter all innodb tables to MyISAM
2. Stop the server
3. Add innodb_file_per_table to my.cnf
4. Change innodb_data_file_path to new settings (10MB tablespaces) in my.cnf
5. Move all innodb files (logs, data) to a backup directory
6. Restart MySQL
7. Alter all tables converted to MyISAM back to InnoDB

This works great! I think using ALTER vs. dumping the data is the fastest way, for me at least.
0

InnoDB Tablespace Size

InnoDB Tablespace Size
Source :http://optimmysql.blogspot.com/2007/07/innodb-tablespace-size.html

Unlike MyISAM where data for individual tables is stored in their respective files, InnoDB stores data in a tablespace. By default, there is one single tablespace and data of all the databases is stored in one file. This file has data dictionary, tables, as well as indexes in it. There is a global parameter innodb_data_file_path that defines this tablespace file. It has a syntax like ibdata1:256M:autoextend, this means at the beginning a file of size 256 MB will be created and then whenever the data size exceeds this, the file will be auto-extended. The innodb_autoextend_increment variable defines in MB's that by how much each increment should be.

Let's see how well can we play around:

  1. Inserts: Suppose you have too many inserts and InnoDB is extending the file too frequently. It makes sense to increase the value of innodb_autoextend_increment. Say we increase it to 16MB, then obviously the number of attempts to autoextend tablespace comes down by a factor of 2, hence performance. But beware before you take it too easy and increase the value too much. There is a big trap, we will come to it shortly.
  2. Deletes: Here is the trap. You have a 10 GB tablespace (after too many autoextends), delete some 5 GB data (data + indexes) and think now the tablespace is 5 GB. Wrong, InnoDB doesn't have the notion of giving back space to the file system. Though, it will make sure to use the freed up space for further inserts. So, this method directly cannot be used to free disk space. So, in case you have data which you can get rid of, get rid of quickly before the next autoextend is done. One thing that can be done to reclaim space is to use OPTIMIZE TABLE frequently enough on tables that have high volume of inserts and deletes. But again remember, MySQL locks a table during the time OPTIMIZE TABLE is running. Another Gotcha, right? OPTIMIZE TABLE does several other things for which it makes sense to run it, though not that frequently. I will be posting a blog soon on it.
  3. Separate Files per Table: InnoDB provides this option where data (data + indexes) for each table can be stored in a separate file through a global variable innodb_file_per_table. Though still a shared tablespace will be created for storing the likes of data dictionary et al. But still this approach makes sense as having data in small chunks (separate files) will improve the scope of managing them well and may increase performance in general.
  4. Fixed Tablespace size: One way to work around with the tablespace file size problems is to fix the tablespace size (remove autoextend) to an extrapolated value. So, when you hit the limit, you know it is time to cleanup. This is not that viable with all the applications, as extrapolation is not always possible. And also it increases the complexity of the application, which then needs to take care of all such error conditions and not lose any data.

So, where does this end? You need to figure out what your data is, how critical it is, what all you want to do with it, what all you want your data to do. Then take some of the following steps.

  1. Move to MyISAM: For all the tables (or even databases), for which you feel data is not that critical to have transactions et al, move them to MyISAM. So, for the problem we can't solve completely, we destroy the problem.
  2. Separate Tablespace: Its a lot easier to maintain 10 small problems than a single big one.
  3. Delete data/OPTIMIZE TABLE: Figure out how soon you can get rid of data. You actually don't need to delete data as it is. Transfer it to a MyISAM table, compress the file and archive it somewhere else and then delete it from the main table. Likewise there are many ways to do it. Run OPTIMIZE TABLE frequently enough so that it doesn't bother your reads and writes too much and also it doesn't take too much time to run.

Hope this blog was helpful to you. Keep posting your comments.

1

C# Clone Image

Aku tengah buat image processing program ada masalah masa clone image. Image yang dah asal yang dah diclone dan diproses turut menjejaskan image asal. Jadi aku cari jumpa code ni :


public static Image cloneImage(Image srcImage){
if (srcImage == null) return null;
Bitmap copy = new Bitmap(srcImage);
using (Graphics g = Graphics.FromImage(copy))
{
g.DrawImage(srcImage,new Rectangle(0, 0, srcImage.Width, srcImage.Height));
}
return copy;
}
0

Compact Framework Load Image

Biasanya aku guna image.fromFile je untuk load image, tapi tak de pulak dalam compact framework. Kena pakai bitmap (ada 2-3 cara). Aku tunjuk satu je la ek.

private void loadLogo() {
  String logoFile = Utils.getCurrentDirectory() + "\\logo.jpg";
  System.IO.FileStream fs=new System.IO.FileStream(logoFile,System.IO.FileMode.Open);
  picLogo.Image = new Bitmap(fs);
  fs.Close();
}
 
Copyright © peyotest