Wednesday, December 29, 2010

Postgres CentOS iptables

# iptables -F
# iptables -L
# service iptables save
# service iptables restart
# iptables -L

references:
[1] http://www.cyberciti.biz/faq/turn-on-turn-off-firewall-in-linux/

Tuesday, December 28, 2010

Postgres CentOS

Install PostgreSql Server

Login as the root user and enter the command:
# yum install postgresql postgresql-server

Start Postgresql

Type the following two command:
# chkconfig postgresql on
# service postgresql start

Connect to Postgresql Server

Connect to server using
# su - postgres

Connect using psql command line tool:
$ psql -d template1 -U postgres

Open TCP port 5432

Finally make sure iptables allows remote access to Postgresql database server:
Open /etc/sysconfig/iptables file:
# vi /etc/sysconfig/iptables
Append following line before COMMIT line to open port 5432:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT

Save and close the file. Restart the firewall:
# service iptables restart

wget http://yum.pgsqlrpms.org/reporpms/8.4/pgdg-centos-8.4-2.noarch.rpm
rpm -Uhv pgdg-centos-8.4-2.noarch.rpm
if don't work see url: http://yum.pgsqlrpms.org/reporpms/8.4

Adds
======
#su postgres
psql -d template1 -U postgres (enter the template1 service database)
alter user postgres with password 'postgres_password'; (run query to change the password)
/sbin/service postgresql restart

nmap -P0 -p 5432 192.168.1.2 (if don't have nmap --> #yum install nmap)
Here are the important lines from pg_hba.conf:
Some where you will have a file called postgresql.conf
#listen_addresses = 'localhost' --> '*' and uncomment


References:
[0]http://www.ixavi.com/2010/01/instalar-postgresql-8-3-en-centos-desde-yum/
[1]http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html
[2]http://www.cyberciti.biz/faq/howto-add-postgresql-user-account/
[3]http://www.postgresql.org/docs/7.4/interactive/sql-alteruser.html
[4] http://www.cyberciti.biz/faq/howto-add-postgresql-user-account/

Wednesday, December 22, 2010

Wednesday, December 15, 2010

Monday, December 13, 2010

FATAL: sorry, too many clients already

Edit postgresql.conf,then on next lines increment values

max_connections = 8
shared_buffers = 16

queries for diagnostic current sessions.

1) Select * from pg_stat_activity;
2) Select count(*) as cnt, usename, current_query FROM pg_stat_activity Group by usename,current_query Order by cnt DESC;

Indice de masa corportal

Indice de masa corporal
http://www.buenasalud.com/tools/bmicalc.cfm

Otro medidor gráfico
http://www.bmivisualizer.com

Pruebas:
[1]
http://www.bmivisualizer.com/body_masses/generate_bmi?utf8=%E2%9C%93&locale=en&body_mass[unit_measurment]=M&body_mass[gender]=Male&body_mass[age]=35&body_mass[height]=1.66&body_mass[feet]=&body_mass[inches]=&body_mass[weight]=76&commit=Calculate+BMI

Thursday, December 02, 2010

SQL Server Analysis Service

Working with Microsoft Analysis Services (SSAS) / MSOLAP / MDX Queries
http://developer.klipfolio.com/developer/cookbook_item/item-64


Running the Analysis Services Deployment Wizard

http://msdn.microsoft.com/en-us/library/ms174817.aspx

Building a SQL Server Analysis Services .ASDatabase file from a Visual Studio SSAS Project
http://agilebi.com/ddarden/2009/05/31/building-a-sql-server-analysis-services-asdatabase-file-from-a-as-project/

Resources
[1] http://sqlsrvanalysissrvcs.codeplex.com/
[2] SQL Server software
http://www.todotegusta.com/2010/05/microsoft-sql-server-2008-r2-standard-edition-x86-y-x64/

Keylogger Apps

Perfect keylogger v1.7.5
http://www.intercambiosvirtuales.org/software/blazingtools-perfect-keylogger-v1-7-5-0-espia-sin-que-se-enteren-lo-que-sucede-en-una-pc

Referencias:
[1]http://www.elhacker.net/Textos1.html

Wednesday, November 24, 2010

C# Smtp Client using gmail account


using System;
using System.Collections.Generic;
using System.Text;

using System.Net.Mail;
using System.Net;

namespace SmtpMail
{
class Program
{

static void Main(string[] args)
{
try
{
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential("compelligencelocal@gmail.com", "xxxxx"),
EnableSsl = true
};
client.Send("myusername@gmail.com", "manager_27@hotmail.com", "test", "testbody");
Console.WriteLine("Sent");
Console.ReadLine();

}
catch (Exception ex)
{
Console.WriteLine( ex.Message );
}

}
}
}

Web Capture

ScreenGrab
https://addons.mozilla.org/es-ES/firefox/addon/1146/

Sunday, November 14, 2010

un-install GRUB from MBR to restore Windows/DOS

HOWTO: How to erase, un-install GRUB from MBR to restore Windows/DOS bootloader
http://linux.koolsolutions.com/2009/06/08/howto-how-to-erase-un-install-grub-from-mbr-to-restore-windowsdos-bootloader/

How to uninstall GRUB
http://www.cyberciti.biz/faq/linux-how-to-uninstall-grub/


Making MBR Backup

mke2fs /dev/fd0 (formating)
dd if=/dev/hda of=/dev/fd0 bs=512 count=1 (dump to floppy)
dd if=/dev/fd0 of=/dev/hda bs=512 count=1 (dump from floppy)

/dev/fd0, replacemente with file or path
hda, sda o SCSI


resources:
[1]Download optional or missing files for Easy Recovery
http://www.easydesksoftware.com/optional.htm

Saturday, November 13, 2010

Keylogger source code

Visual C++
https://github.com/ajayrandhawa/Keylogger/blob/master/Sourcecode.cpp

C#
http://sourceforge.net/projects/superkeylogger/
http://www.elguille.info/colabora/NET2006/drosa_KeyLogger.htm
http://www.c-sharpcorner.com/UploadFile/grusso/KeyLoggerAplicationinCSharp11252005000941AM/KeyLoggerAplicationinCSharp.aspx


resources:
[1] http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/ed63b033-663a-4a20-80a5-a732d31e9486

Friday, November 12, 2010

Postgres DEBUG

Errors and Messages

RAISE level 'format' [, expression [, ...]];

levels-> DEBUG, LOG, INFO, NOTICE, WARNING, and EXCEPTION(raises an error).

format-> string, % is replaced by the next optional argument's string representation.

usages:
RAISE NOTICE 'Calling cs_create_job(%)', v_job_id;
--This example replace % with v_job_id
RAISE EXCEPTION 'Nonexistent ID --> %', user_id;
--This example will abort the transaction with the given error message:


references:
[1] http://www.postgresql.org/docs/8.1/static/plpgsql-errors-and-messages.html

Wednesday, November 10, 2010

NHibernate works without mapping

ISQLQuery query = Session.CreateSQLQuery("SELECT p.*, c.* FROM Product p Left JOIN Product_CustomField c on p.ProductId=c.ProductId");
query.SetResultTransformer(NHibernate.Transform.Transformers.AliasToBean(typeof(Product)));
IList resultList = query.List();

Notes:
Add CusTomField1..5 into Product Class,not need declared in .hbm.xml

Combine with ScalarFields
public class SqlRepository {
...
public IList ListEmployees() {
using (ISession session = _sessionBuilder.GetSession()) {
return session
.CreateSQLQuery(@"
SELECT No_ AS EmployeeNumber, [E-mail Login] AS Username
FROM Employees")
.AddScalar("EmployeeNumber", NHibernateUtil.String)
.AddScalar("Username", NHibernateUtil.String)
.SetResultTransformer(Transformers.AliasToBean())
.List();
}
}
}


Add nHibernate mapping at run time
ISessionFactory sf = new Configuration()
.AddFile("Product.hbm.xml")
.AddFile("Category.hbm.xml")



References:
[1] http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querysql.html
[2] Store procedure http://www.martinwilley.com/net/code/nhibernate/sql.html
[3] Reduced wiring code needed for native sql http://swik.net/Hibernate/Hibernate+GroupBlog/Hibernate+3.1:+Reduced+wiring+code+needed+for+native+sql
[4] AddJoin http://es.efreedom.com/Question/1-1132059/NHibernate-problema-de-AddEntity-y-AddJoin
[5] Native SQL http://knol.google.com/k/fabio-maulo/nhibernate-chapter-14-native-sql/1nr4enxv3dpeq/17#
[6]Fluent NHibernate http://wiki.fluentnhibernate.org/Auto_mapping
[7]Dynamically load .hbm.xml http://www.codeguru.com/forum/showthread.php?t=474322

Wednesday, November 03, 2010

Cubecart:: Deprecated: Function eregi() is deprecated in

The latest versions of PHP 5 have deprecated a few functions, for turn off those messages as seen in CubeCart.

Edit /includes/ini.inc.php
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED));

Wednesday, October 27, 2010

Postgres configuration

classical paths

# vi /etc/postgresql/8.2/main/postgresql.conf
# vi /var/lib/pgsql/data/postgresql.conf
# vi /opt/Postgres/8.4/data/postgresql.conf


Enable Network:

listen_addresses = 'localhost' to listen_addresses = '*'

You must also have appropriate entries in pg_hba.conf for hosts and
authentication type. You could use something like:

#TYPE DATABASE USER ADDRESS METHOD
local all all password
host all all 127.0.0.1/32 password
host all all 192.168.1.0/24 password

Next line allow all ips
host all all 0.0.0.0/0 md5

Thursday, October 21, 2010

Postgres save images


CREATE TABLE images (name text, img bytea);



File file = new File("image.gif");
FileInputStream fis = new FileInputStream(file);
PreparedStatement ps = conn.prepareStatement("INSERT INTO images VALUES (?, ?)");
ps.setString(1, file.getName());
ps.setBinaryStream(2, fis, file.length());
ps.executeUpdate();
ps.close();
fis.close();


setBinaryStream(), transfers a set number of bytes from a stream.
setBytes(), use this method if the contents of the image was already in a byte[].

Retrieving image

PreparedStatement ps = conn.prepareStatement("SELECT img FROM images WHERE name=?");
ps.setString(1, "image.gif");
ResultSet rs = ps.executeQuery();
if(rs.next()) {
byte[] imgBytes = rs.getBytes(1);
}
rs.close();
}
ps.close();


You could have used a InputStream object instead.

Alternatively you could be storing a very large file and want to use the LargeObject API to store the file:


CREATE TABLE imagesLO (imgname text, imgOID OID);

To insert an image, you would use:



conn.setAutoCommit(false); // All LargeObject API calls must be within a transaction

LargeObjectManager lobj = ((org.postgresql.PGConnection)conn).getLargeObjectAPI();

//create a new large object
int oid = lobj.create(LargeObjectManager.READ | LargeObjectManager.WRITE);

//open the large object for write
LargeObject obj = lobj.open(oid, LargeObjectManager.WRITE);

// Now open the file
File file = new File("image.gif");
FileInputStream fis = new FileInputStream(file);

// copy the data from the file to the large object
byte buf[] = new byte[2048];
int s, tl = 0;
while ((s = fis.read(buf, 0, 2048)) > 0)
{
obj.write(buf, 0, s);
tl += s;
}

obj.close();

//Now insert the row into imagesLO
PreparedStatement ps = conn.prepareStatement("INSERT INTO imagesLO VALUES (?, ?)");
ps.setString(1, file.getName());
ps.setInt(2, oid);
ps.executeUpdate();
ps.close();
fis.close();

Retrieving the image from the Large Object:


conn.setAutoCommit(false);

// Get the Large Object Manager to perform operations with
LargeObjectManager lobj = ((org.postgresql.PGConnection)conn).getLargeObjectAPI();

PreparedStatement ps = con.prepareStatement("SELECT imgOID FROM imagesLO WHERE imgname=?");
ps.setString(1, "image.gif");
ResultSet rs = ps.executeQuery();
if (rs.next())
{
int oid = rs.getInt(1);//open the large object for reading
LargeObject obj = lobj.open(oid, LargeObjectManager.READ);

//read the data
byte buf[] = new byte[obj.size()];
obj.read(buf, 0, obj.size());
//do something with the data read here
obj.close();
}
rs.close();
}
ps.close();

JSP Pagination mySQL Postgres

Postgres
select * from ubigeos order by nombre limit 10 offset 0

mySql
select * from ubigeos order by nombre limit 0 , 10

References:
[1] http://www.easywayserver.com/blog/jsp-pagination/
[2] http://www.todoexpertos.com/categorias/tecnologia-e-internet/programacion/java/respuestas/889187/paginacion-con-jsp

dbf tools

Dbf Viewer 2000 v2.02
http://www.megaupload.com/?d=6R0N6G2W

Thursday, October 14, 2010

haar cascading

http://www-personal.umich.edu/~shameem/haarcascade_eye.html

http://note.sonots.com/SciSoftware/haartraining.html

tomcat & servlet resource

Tomcat::configuration of system properties from webapp

SystemPropertiesListener.java
import java.util.Enumeration;
import javax.servlet.*;

public class SystemPropertiesListener implements
javax.servlet.ServletContextListener {
private ServletContext context = null;

public void contextInitialized(ServletContextEvent event) {
context = event.getServletContext();
Enumeration params = context.getInitParameterNames();

while (params.hasMoreElements()) {
String param = (String) params.nextElement();
String value = context.getInitParameter(param);
if (param.startsWith("prefix.")) {
System.setProperty(param, value);
}
}
}

public void contextDestroyed(ServletContextEvent event) {
}
}

web.xml

<context-param>
<param-name>prefix.property</param-name>
<param-value>value</param-value>
<param-type>java.lang.String</param-type>
</context-param>

<listener>
<listener-class>servletUtils.SystemPropertiesHelper</listener-class>
</listener>


Resources
[1] http://stackoverflow.com/questions/372686/how-can-i-specify-system-properties-in-tomcat-configuration-on-startup

[2] http://stackoverflow.com/questions/558502/how-a-servlet-can-get-the-absolute-path-to-a-file-outside-of-the-servlet
[3] http://stackoverflow.com/questions/2194930/tomcat-how-can-i-place-parameters-in-web-xml-and-fetch-them-in-my-application

Wednesday, October 13, 2010

Jasper Report

Ejemplo básico(src)
http://chuwiki.chuidiang.org/index.php?title=Ejemplo_b%C3%A1sico_con_Jasper_Report

Resources
http://abeishbabu.blogspot.com/2009/06/printing-txt-file-directly-to-printer.html
http://www.thatsjava.com/java-core-apis/46844/
http://java.itags.org/java-core-apis/46844/
http://jasperetl.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=34840
http://forums.java.net/jive/message.jspa?messageID=227537
http://www.coderanch.com/t/62982/open-source/Jasper-Report-Text-Exporter
http://helptodeveloper.blogspot.com/2010/02/exporting-jasper-reports-with-save-as.html

Friday, October 08, 2010

Google banner by date

2010-10-08

Web Service tools for Social Networks

Engine for Java Web service
http://enunciate.codehaus.org/

Social Networks Api
hi5
http://api.hi5.com/
Facebook
http://developers.facebook.com/docs/reference/javascript/

Friday, September 24, 2010

Windows XP Inicio rápido

Si no se puede restaurar en la barra la sección de inicio rápido, ejecuta las siguientes lineas:
1) Inicio, Ejecutar regsvr32 /i shell32.dll
2) Inicio, Ejecutar regsvr32 /i browseui.dll

Restaurar Mostrar Escritorio

Abrir la carpeta C:\Documents and Settings\[USER]\Datos de programa\Microsoft\Internet Explorer\Quick Launch.

-------------Desktop.scf--------------
[Shell]
Command=2
IconFile=explorer.exe,3
[Taskbar]
Command=ToggleDesktop
--------------------------------------

Wednesday, September 22, 2010

Spring.NET NHibernate Dynamic ConnectionString

Configuration cfg = new
Configuration().Configure("hibernate.cfg.xml");
cfg.SetProperty("connection.connection_string", "Data
Source=MI_BASE;User ID=ID_USUARIO; Password=PASS_USUARIO");



References
[1] The Spring.NET Framework
http://www.springframework.net/doc-latest/reference/html/index.html
[2] http://gist.github.com/432083 (src-best)
[3] Changing your connection string at runtime with Spring.Net (src)
http://blog.bennymichielsen.be/2009/03/24/changing-your-connection-string-at-runtime-with-spring-net/

[4]How to change a connection string at runtime? (src)
http://forum.springframework.net/showthread.php?t=3390&page=3

[5] Authentication, Impersonation, and Dynamic NHibernate Connection Strings
http://jasondentler.com/blog/2009/11/authentication-impersonation-and-dynamic-nhibernate-connection-strings/
[6] Setting and retrieving the database connectionstring in nHibernate
http://codebetter.com/blogs/peter.van.ooijen/archive/2008/03/07/setting-and-retrieving-the-database-connectionstring-in-nhibernate.aspx

Chat On Line

http://www.chatango.com/

Friday, September 17, 2010

Firefox open multiple private window

    /opt/firefox/firefox-bin --profile $(mktemp -d) --private-window www.google.com www.bing.com