When you trying to instal pkg_add -r nano you see:

pkg_add -r nano
Error: Unable to get ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-9-current/Latest/vim.tbz: 
File unavailable (e.g., file not found, no access)
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-9-current/Latest/vim.tbz:' by URL

This should help you:

Open ~/.cshrc and write at end of file:
setenv PACKAGESITE "ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-9-stable/Latest/"

and save it, and use: source ~/.cshrc

C++ Programmer

Posted: 9 sierpnia 2012 in Programmer
Tagi: ,


Extracting MSI install file

Posted: 24 lipca 2012 in MSI files
Tagi:

To extract content of MSI install file (ex. file.msi):

  • msiexec /a D:tmpfile.msi /qb TARGETDIR=D:tmp

Jak wygenerować certyfikat SSL

Posted: 21 lipca 2012 in Certyfikat, SSL
Tagi: ,

Poniżej skrypt generujący certyfikat SSL:

#!/bin/bash
# 5 lat
days=1825

rm -f /tmp/cert.pem /tmp/cert.key
openssl req -new -x509 -days $days -nodes -out /tmp/cert.pem -keyout /tmp/cert.key

echo "Certyfikat wygenerowany: /tmp/cert.pem /tmp/cert.key"


Uruchamianie Tomcata na dwóch kartach sieciowych:

Przed uruchomieniem serwera Tomcat na dwóch kartach sieciowych należy zrobić kopię zapasową pliku C:Program FilesApache Software Foundationconfserver.xml Następnie w sekcji

Poniżej przedstawiona została konfiguracja serwera Tomcat dla dwóch kart sieciowych (interfejsów sieciowych):

 

<Connector port=”8081″ maxHttpHeaderSize=”8192″
maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″
enableLookups=”false” redirectPort=”8443″ acceptCount=”100″
connectionTimeout=”20000″ disableUploadTimeout=”true” address=”192.168.1.102″/>

<Connector port=”8081″ maxHttpHeaderSize=”8192″
maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″
enableLookups=”false” redirectPort=”8443″ acceptCount=”100″
connectionTimeout=”20000″ disableUploadTimeout=”true” address=”192.168.1.110″/>

 

Jeżeli będziemy potrzebowali ustawić serwer Tomcat dla więcej niż dwóch kart sieciowych „doklejamy” sekcję <Connector>

Parsowanie e-maili w C#

Posted: 6 czerwca 2012 in .NET, C#, Parsing
Tagi: , ,

Poniżej przedstawiam prosty program w konsoli (można go rozbudować czy też dorobić do niego GUI) do parsowania e-maili
napisany w języku C#
using System;
using System.IO;
using System.Collections.Generic;

namespace BatchReader_01 {
        public class Message {
                public static int counter = 0;
                public static Dictionary<string, int> dict = new Dictionary<string, int>();
                public static List<Message> list = new List<Message>();

                int number;
                String mSubject;
                String mData;
                String mFrom;
                public Message(ref StreamReader sr) {
                        list.Add(this);
                        ++counter;
                        number = counter;

                        string strLine;
                        strLine = sr.ReadLine();
                        mData = strLine.Substring(6);
                        strLine = sr.ReadLine();
                        mFrom = strLine.Substring(6);
                        strLine = sr.ReadLine();
                        mSubject = "";
                        while (!strLine.StartsWith("To")) {
                                mSubject += strLine;
                                strLine = sr.ReadLine();
                        }
                        mSubject = mSubject.Substring(9);
                        mSubject = mSubject.Replace('t', ' ');

                        strLine = sr.ReadLine();
                        while (strLine != "------------------------------") {
                                strLine = sr.ReadLine();
                        }

                        if (!mSubject.StartsWith("Re: ")) {
                                dict.Add(mSubject.Replace(" ", ""), number);
                        } else {
                                strLine = mSubject.Substring(4).Replace(" ", "");
                                if (!dict.ContainsKey(strLine))
                                        dict.Add(strLine, number);
                        }
                }
                //
                public void dump() {
                        Console.WriteLine("Messge " + number.ToString()+":");
                        Console.WriteLine("t" + mSubject);
                        Console.WriteLine("t" + mData);
                        Console.WriteLine("t" + mFrom);
                }
                //
                public static void listDump() {
                        foreach (Message obj in list)
                                obj.dump();
                }
                //
                public static void subjectsDump() {
                        // Get a collection of the keys (names).
                        ICollection<String> c = dict.Keys;
                        foreach (String str in c)
                                Console.WriteLine("index: {0}, {1}  {2}", dict[str], list[dict[str] - 1].mSubject, str);
                }
        }

        class Program {
                //-------------------------------------------------------
                public static void Main(string[] args) {
                        try {
                                //List<Message> list = new List<Message>();
                                StreamReader sr = File.OpenText("GDAlgorithms-list Digest, Vol 28, Issue 1.MSG");
                                string strLine;
                                while (null != (strLine = sr.ReadLine())) {
                                        if (strLine.StartsWith("Message:")) {
                                                Message m = new Message(ref sr);
                                                //list.Add(m);
                                        }
                                }
                                sr.Close();

                                Message.subjectsDump();

                                Message.listDump();

                        } catch (FileNotFoundException e) {
                                Console.WriteLine(e.Message);
                        }
                }
                //-----------------------------------------------
        }
}
//---------------------------------------------------------------

Projekt w VS2008 Express Edition (download)

Jak użyjesz kodu w swoim programie to napisz. Tak z ciekawości chciałbym wiedzieć 🙂

Proszę o komentarze i uwagi 🙂


Sometime I have this problem: Access denied for user ‚root’@’localhost’ (using password: NO) I have described solution below:

  • Start the mysql client process using this command (sudo /etc/init.d/mysql start):
    mysql -u root
  • Execute this command to be able to change any password:
    FLUSH PRIVILEGES;

    Then reset/update your password:

    SET PASSWORD FOR root@'localhost' = PASSWORD('password');

    If we have a mysql root account that can connect from everywhere, you should also do:

    UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';

    Alternate Method:

    USE mysql UPDATE user SET Password = PASSWORD('newpassword') WHERE Host = 'localhost' AND User = 'root';

    And if you have a root account that can access from everywhere:

    USE mysql UPDATE user SET Password = PASSWORD('newpassword') WHERE Host = '%' AND User = 'root';
  • Or faster:

USE mysql;
FLUSH PRIVILEGES;
UPDATE user SET Password = PASSWORD(‚dupa’) WHERE Host = ‚%’ AND User = ‚root’;

 

Then stop/restart the mysqld process:

sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
or
sudo /etc/init.d/mysql restart

Copying data between tables:

 

INSERT INTO table SELECT * FROM base2.table;


Copying data between tables including fields list:

 

INSTER INTO client (client_id, word) SELECT 4, word FROM client WHERE client_id = 3;