Linux - change resolution in text mode on LCD screen


if you watch small about 80 chars terminal output in the middle of yours gigantic LCD screen..


you should try to change screen resolution. It depends on your distribution (Fedora, Ubuntu or Red Hat) and boot manager.
I am using Fedora Project 17 on VMWare with GRUB2.
Lets modify /etc/default/grub


#try to set native monitor resolution

GRUB_GFXMODE=1024x768

#force to keep graphic mode

GRUB_GFXPAYLOAD_LINUX=keep


Yes, that's right, modern terminals running text mode over graphic gfxterm

to apply changes lets execute

 
grub2-mkconfig -o /boot/grub2/grub.cfg


and reboot

Now you should see the text in entire screen.


Enjoy!



mysql errno 1251 Client does not support authentication protocol requested by server

mysql errno 1251 Client does not support authentication protocol requested by server
OR
unable to connect database server in my php 4.4.9 script.

I have spent some time before found out that php 4.4 isn't compatible any more with mysqld 5.1
Some thought you can find here. Solution of the problem is simple. You must correct user's password and save it in old style.


mysql> SET PASSWORD FOR
    -> 'some_user'@'some_host' = OLD_PASSWORD('newpwd');

Enjoy!

apache: main default host is not accessible

I have added VirtualHost and can't access main DocumentRoot from httpd.conf :(
According to RTFM

Main host goes away

If you are adding virtual hosts to an existing web server, you must also create a <VirtualHost> block for the existing host. The ServerNameand DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.

Ok, i have added VirtualHost directly to httpd.conf and it doesn't help me at all. Why?
Because above of VirtualHost Directive was Include ..\conf.d\*
Hmmm...  Who says you can't teach a old fox new tricks?...

Just add new config file in conf.d directory and it must be first file.
Let's create conf.d/aaaa_default.conf file with content

#first VirtualHost is default

<VirtualHost *:80>

    ServerAdmin webmaster@firsthost.tdl
    DocumentRoot /var/www/html
    ServerName firsthost.tdl:80
    ServerAlias localhost

    ErrorLog  /var/log/httpd/error_log
    CustomLog /var/log/httpd/access_log common

</VirtualHost>


Whoops!!!! The file is loaded first because name(!) and corresponds to my default path.

Some useful settings in LogFormat are
 %f - local filename
%v - virtualhost name


LogFormat "%v %l %u %t \"%r\" %>s %b %f" common


Please note that i am using apache as httpd rpm from fedora core. Other distributive can be slightly different.

Enjoy!

OTRS Cannot find current script 'httpd' at FindBin.pm


i have installed recent OTRS 3.1 and appears message in error_log Cannot find current script 'httpd' at /usr/share/perl5/FindBin.pm
I have found that exists patched FindBin.pm Version 1.51

Enjoy!

Notepad++ - new User Defined Language (UDL2)


UDL (User Defined Language) is one of most important features in Notepad++.

In v6.2, much better UDL system (UDL2) is provided by Ivan Radic (aka Loreia). Not only many restrictions/limitations in UDL are removed, but also a lot of new features/enhancements are added in UDL2. In fact, you can almost define any language with it.

The key features of UDL2 are:
1. More keyword groups were added (more syntax highlighting can be defined):
  • 3 folding groups
  • 8 keyword groups
  • 2 comment groups
  • 1 number definitons
  • 2 operators groups
  • 8 delimiter sets
2. Multipart keywords are supported (for example: "else if" can be defined as a single keyword)
3. Whitespace is no longer mandatory as keyword separator: Operators, Delimiters and Folding keywords can be recognized with or without whitespace separators.
4. Numbers recognition support is greatly improved (prefix, suffix, range and extra symbols supported).
5. Operators and delimiters can be longer than one character.
6. The same characters can be used as comments AND operators.
7. Comments and delimiters support nesting (even within each other).
8. Improvments to Comments include:
  • Comment folding
  • Comment continuation
  • Comment only start at the beginning of line
9. In the case of several comment pairs defined, comment open symbols match only with comment close symbols of the same order. (for example: /* C comment */, /+ D comment +/, but not /* mixed comment +/)

Source: notepad-plus-plus.org
read more about UDL2...

OTRS default search ticket number

You can enable default search by ticket number in SysConfig with option

OTRS add custom CSS style


Wrong way to add it directly to HTMLHead.dtl file.

Correct way to create new Custom.css file, save it into /var/httpd/htdocs/skins/Agent/default/css/ directory
and add Custom.css item to Loader::Agent::CommonCSS###000-Framework via SysConfig editor.



 Enjoy!

OTRS enable login autocomplete in Firefox


if your username and password weren't filled out with firefox password manager you should remove readonly attribute in Login.dtl file.

Wrong:
<div class="Field"> 

<input type="text" id="User" name="User"  class="W50pcautocomplete="off"  

readonly="readonly" />
</div>


Correct:
<div class="Field"> 

<input type="text" id="User" name="User"  class="W50pc" />
</div>



HOWTO change resolution in linux installer

when I installed fedora core it had wrong autodefined screen resolution and screen was truncated so i can't see buttons and I would like to install in graphic mode :)

I have read manual (RTFM !) and found that I can press Tab on first screen and set resolution as

resolution=1024x768




and buttons are back


Enjoy!

Lookup MX record in C#

Thank you Peter A. Bromberg for great article "Build a C# DNS MX (Mail Exchange) Record Query Class
Original
MSDN


 
using System;
using System.Collections;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace DNS_MX
{
    public class DnsMx
    {
        public DnsMx()
        {
        }

        [DllImport("dnsapi"EntryPoint "DnsQuery_W"CharSet CharSet.UnicodeSetLastError trueExactSpelling =true)]
        private static extern int DnsQuery([MarshalAs(UnmanagedType.VBByRefStr)]ref string pszNameQueryTypes wType,QueryOptions optionsint aipServersref IntPtr ppQueryResultsint pReserved);

        [DllImport("dnsapi"CharSet CharSet.AutoSetLastError true)]
        private static extern void DnsRecordListFree(IntPtr pRecordListint FreeType);

        public static string[GetMXRecords(string domain)
        {

            IntPtr ptr1 IntPtr.Zero;
            IntPtr ptr2 IntPtr.Zero;
            MXRecord recMx;
            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
            {
                throw new NotSupportedException();
            }
            ArrayList list1 new ArrayList();
            try
            {

                int num1 DnsMx.DnsQuery(ref domainQueryTypes.DNS_TYPE_MXQueryOptions.DNS_QUERY_BYPASS_CACHE0refptr10);
                if (num1 != 0)
                {
                    if (num1 == 9003)
                    {
                        list1.Add("DNS record does not exist");
                    }
                    else
                    {
                        throw new Win32Exception(num1);
                    }
                }
                for (ptr2 ptr1!ptr2.Equals(IntPtr.Zero)ptr2 recMx.pNext)
                {
                    recMx (MXRecord)Marshal.PtrToStructure(ptr2typeof(MXRecord));
                    if (recMx.wType == 15)
                    {
                        string text1 Marshal.PtrToStringAuto(recMx.pNameExchange);
                        list1.Add(text1);
                    }
                }
            }
            finally
            {
                DnsMx.DnsRecordListFree(ptr10);
            }
            return (string[])list1.ToArray(typeof(string));
        }

        private enum QueryOptions
        {
            DNS_QUERY_ACCEPT_TRUNCATED_RESPONSE 1,
            DNS_QUERY_BYPASS_CACHE 8,
            DNS_QUERY_DONT_RESET_TTL_VALUES 0x100000,
            DNS_QUERY_NO_HOSTS_FILE 0x40,
            DNS_QUERY_NO_LOCAL_NAME 0x20,
            DNS_QUERY_NO_NETBT 0x80,
            DNS_QUERY_NO_RECURSION 4,
            DNS_QUERY_NO_WIRE_QUERY 0x10,
            DNS_QUERY_RESERVED -16777216,
            DNS_QUERY_RETURN_MESSAGE 0x200,
            DNS_QUERY_STANDARD 0,
            DNS_QUERY_TREAT_AS_FQDN 0x1000,
            DNS_QUERY_USE_TCP_ONLY 2,
            DNS_QUERY_WIRE_ONLY 0x100
        }

        private enum QueryTypes
        {
            DNS_TYPE_MX 15
        }

        [StructLayout(LayoutKind.Sequential)]
        private struct MXRecord
        {
            public IntPtr pNext;
            public string pName;
            public ushort wType;
            public ushort wDataLength;
            public int flags;
            public int dwTtl;
            public int dwReserved;
            public IntPtr pNameExchange;
            public ushort wPreference;
            public ushort Pad;
        }
    }
}

what is notepad 5.1

What is notepad++ ?
Definition of notepad is


Notepad++ is a free (as in "free speech" and also as in "free beer") source code editor and Notepad replacement that supports several languages. Running in the MS Windows environment, its use is governed by GPL License.
Based on the powerful editing component ScintillaNotepad++ is written in C++ and uses pure Win32 API and STL which ensures a higher execution speed and smaller program size. By optimizing as many routines as possible without losing user friendliness, Notepad++ is trying to reduce the world carbon dioxide emissions. When using less CPU power, the PC can throttle down and reduce power consumption, resulting in a greener environment.


Source: http://notepad-plus-plus.org/

Windows 7 autofill login ON OFF

HOWTO disable logon screen on Windows 7 or enable it again? Just type netplwiz in Start menu.
By default user must enter password on logon screen. If you want to remove it you should clean check box and click OK button and vice verse.


Enjoy it!

OTRS: hide -Move- dropdown with ACL

If you want to disable ticket move action for tickets in some states you can use ACL rules. Below you can see an example how to block movement of ticket if ticket is closed.

[Kernel/Config.pm]
        
# Ticket ACL - Disable move for closed
$Self->{TicketAcl}->{'ACL-dont-move'} = {
 # match properties
 Properties => {
  # all closed tickets
  Ticket => {
   State => ['closed', 'closed successful', 'closed unsuccessful', ], 
  },
  
  #disable on AgentTicketZoom page only
  Frontend => {
 Action => [
  'AgentTicketZoom',
 ],
  },
 },

# return possible options (white list)
 Possible => {
  # shouldn't be moved (0)
  Action => {
   AgentTicketMove =>  0,
  },
 }, 

};

Internet Information Services (IIS) 8.0 Express Release Candidate


IIS 8.0 Express is a simple and self-contained version of IIS 8.0 that is optimized for developers

Overview



IIS 8.0 Express enhances your ability to develop and test web applications on Windows by combining the power of IIS 8.0 with the convenience of a lightweight web server like the ASP.NET Development Server (also known as Cassini). IIS Express 8.0 is included with Microsoft WebMatrix, an integrated suite of tools designed to make developing web applications on Windows simple and seamless. IIS 8.0 Express can also be used with Microsoft Visual Studio as a powerful alternative to Cassini. The benefits of using IIS 8.0 Express include:
  • The same web server that runs on your production server is now available on your development computer.
  • Most tasks can be done without the need for administrative privileges.
  • IIS 8.0 Express runs on Windows Vista and all later versions of Windows.
  • Many users can work independently on the same computer.
This package installs only IIS 8.0 Express. For an integrated development experience, also install Microsoft WebMatrix or Microsoft Visual Studio.

more

Visual Studio 2012 RC is now available to download.

Pivot (crosstab) table in C#

How to create pivot table in C# and display it in DataGrid?

NOTE: it is available version 2.0 of PivotTable


It exists well-know solution for pre-sorted and pre-grouped values.
What if we would like to pivot free set? Sample below will pivot any DataTable and produce new summarized DataTable. You can pivot Array or ArrayList also, first you should convert your Array to DataTable and then call Pivot method. Data is ready to display in grid.

     public DataTable Pivot(
            DataTable src,
            string VerticalColumnName,
            string HorizontalColumnName,
            string ValueColumnName ) 
        {

                DataTable dst = new DataTable();
                if (src == null || src.Rows.Count == 0)
                    return dst;

                // find all distinct names for column and row
                ArrayList ColumnValues  = new ArrayList();
                ArrayList RowValues     = new ArrayList();
                foreach (DataRow dr in src.Rows)
                {
                    // find all column values
                    object column = dr[VerticalColumnName];
                    if (!ColumnValues.Contains(column))
                        ColumnValues.Add(column);

                    //find all row values
                    object row = dr[HorizontalColumnName];
                    if (!RowValues.Contains(row))
                        RowValues.Add(row);
                }

                ColumnValues.Sort();
                RowValues.Sort();

                //create columns
                dst = new DataTable();
                dst.Columns.Add(VerticalColumnName, src.Columns[VerticalColumnName].DataType);
                Type t = src.Columns[ValueColumnName].DataType;
                foreach (object ColumnNameInRow in RowValues) {
                    dst.Columns.Add(ColumnNameInRow.ToString(), t);
                }

                //create destination rows
                foreach (object RowName in ColumnValues) {
                    DataRow NewRow = dst.NewRow();
                    NewRow[VerticalColumnName] = RowName.ToString();
                    dst.Rows.Add(NewRow);
                }

                //fill out pivot table
                foreach (DataRow drSource in src.Rows) {
                    object key = drSource[VerticalColumnName];
                    string ColumnNameInRow = Convert.ToString(drSource[HorizontalColumnName]);
                    int index = ColumnValues.IndexOf(key);
                    dst.Rows[index][ColumnNameInRow] = sum(dst.Rows[index][ColumnNameInRow], drSource[ValueColumnName]);
                }

                return dst;
        }

        dynamic sum(dynamic a, dynamic b) {
            if (a is DBNull && b is DBNull)
                return DBNull.Value;
            else if (a is DBNull && !(b is DBNull))
                return b;
            else if (!(a is DBNull) && b is DBNull)
                return a;
            else
                return a + b;
        }
Proof:
            object DBNULL = DBNull.Value;
            DataTable src = new DataTable();
            DataTable dst = null;

            src.Columns.Add("City", typeof(string));
            src.Columns.Add("Product", typeof(string));
            src.Columns.Add("Value", typeof(float));
            
            src.Rows.Add("City A", "Product 1", 1.2f);
            src.Rows.Add("City C", "Product 2", 0.3f);
            src.Rows.Add("City A", "Product 1", 1.0f);
            src.Rows.Add("City B", "Product 3", 2.2f);
            src.Rows.Add("City B", "Product 1", 1.5f);
            src.Rows.Add("City A", "Product 2", 0.8f);
            src.Rows.Add("City A", "Product 4", 1.1f);

            PivotTable test = new PivotTable();
            dst = test.Pivot(src, "City", "Product", "Value");

            CollectionAssert.AreEqual(new object[] { "City A", 2.2f,    0.8f,   DBNULL, 1.1f   }, dst.Rows[0].ItemArray);
            CollectionAssert.AreEqual(new object[] { "City B", 1.5f,    DBNULL, 2.2f,   DBNULL }, dst.Rows[1].ItemArray);
            CollectionAssert.AreEqual(new object[] { "City C", DBNULL,  0.3f,   DBNULL, DBNULL }, dst.Rows[2].ItemArray);


Enjoy!

C# (c sharp) function list


C# has no functions in the ordinary sense. So you if you are looking for absolute value you can't call abs() any more and should use static method from Math class!

Math.Abs(foo_bar);

So you can forget right now about function and find some useful methods of class which grouped in namespaces.

Namespace overview you will find here. Base classes are collected in System namespace. And useful list and hashes are located in System.Collections namespace.

Enjoy!

how to change proxy in samsung galaxy android



changing proxy settings on android smartphones (samsung, galaxy, htc, etc)


EN: Wireless & networks Wi-Fi settings Proxy Settings and  Manual

DE: WLAN Einstellungen > Menütaste: Erweitert > Proxy/Port


RU: Беспроводные сети Настройки WiF  >  Настройка сети  >  Настройки прокси-сервера и Ручные




get asp.net sources


ASP.NET is a free web framework for building great web sites and applications.
This site is the home of the ASP.NET MVCWeb API, and Web Pages source code. If you want to use the released versions of these products to develop your applications, visit http://www.asp.net to find official installers, documentation, tutorials, samples, and videos.
These products are actively developed and supported by the Microsoft ASP.NET team in collaboration with a community of open source developers. Together we are dedicated to creating the best possible platform for web development.

Enjoy!

HOWTO: Repair Logitech M325 Mouse

FixIt says that you will find single screw under CE label. It isn't always true.