Archive

Author Archive

Ubuntu VM on Xen FIX: perl: warning: Setting locale failed.

July 27th, 2010 admin No comments

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

# locale-gen en_US en_US.UTF-8 hu_HU hu_HU.UTF-8

# dpkg-reconfigure locales

Categories: Server, System Tags: ,

Replace blank space in file name

July 8th, 2010 admin No comments

for f in *; do mv “$f” `echo $f | tr ‘ ‘ ‘_’`; done

Categories: Programming, System Tags: ,

Using jQuery with Other Libraries

June 28th, 2010 admin No comments
  • Overriding the $-function
  • Including jQuery before Other Libraries
  • Referencing Magic – Shortcuts for jQuery

var J = jQuery.noConflict();
function init(){
J(“div#sshow”).slideView();
}
J(window).bind(“load”, init );

Categories: Web Tags: , ,

logrotate debug

June 8th, 2010 admin No comments

logrotate -f -v /etc/logrotate.conf

than it will update /var/lib/logrotate/status

Categories: Server Tags: , ,

Interview questions (2)

January 7th, 2010 admin No comments

1) There are integer arrays, A and B. what’s the best way to generate an array which contains all duplicated elements of A and B.
2) There are integer arrays, A and B. how to figure it out if those contain same elements.
3) There many of files in a folder and some of them contains phone numbers. how to find them.
4) Design restaurant reservation system. class design and data structures.

Categories: Algorithm Tags: ,

Spring MVC + Tiles

December 13th, 2009 admin No comments

1. create web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>

2. create action-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="message" />
</bean>

<bean id="testController" class="com.bluewiseinc.erp.common.web.TestController">
<property name="methodNameResolver" ref="methodNameResolver" />
</bean>

<bean id="methodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
<property name="paramName">
<value>med</value>
</property>
<property name="defaultMethodName">
<value>userMain</value>
</property>
</bean>

<!--
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
<property name="cache" value="false" />
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>
-->
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>

<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location">
<value>/WEB-INF/UrlMap.properties</value>
</property>
</bean>
</property>
</bean>

<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles-def.xml</value>
</list>
</property>
</bean>

<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
</beans>

3. create TestController
package com.bluewiseinc.erp.common.web;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class TestController extends MultiActionController {
public ModelAndView testMain(HttpServletRequest request, HttpServletResponse response) throws Exception {
return new ModelAndView("test/test_main", "testMain", null);
}
}

4. UrlMap.properties
## test module mapping
/test/index.do=testController

5. tiles-def.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">

<tiles-definitions>
<definition name="defaultTemplate" template="/WEB-INF/view/tiles/default.jsp">
<put-attribute name="header" value="/WEB-INF/view/tiles/def_header.jsp" />
<put-attribute name="menu" value="/WEB-INF/view/tiles/def_menu.jsp" />
<put-attribute name="footer" value="/WEB-INF/view/tiles/def_footer.jsp" />
</definition>
<definition name="test_main" extends="defaultTemplate">
<put-attribute name="content" value="/WEB-INF/view/test/test_main.jsp"/>
</definition>
</tiles-definitions>

6. message.properties
# Page titles
index.title=Test Spring MVC + Tiles

7. default.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><fmt:message key="index.title"/></title>
<link rel=stylesheet href="${pageContext.request.contextPath}/css/global.css" type="text/css">
<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/global.js"></script>
</head>
<body>
<div id="header">
<div id="headerTitle"><tiles:insertAttribute name="header" /></div>
</div>
<div id="menu">
<tiles:insertAttribute name="menu" />
</div>
<div id="content">
<tiles:insertAttribute name="content" />
</div>
<div id="footer">
<tiles:insertAttribute name="footer" />
</div>
</body>
</html>

Server Configuration Job Log

December 13th, 2009 admin No comments

Dell PowerEdge  SC1420

Dell CERC SATA 1.5/6ch RAID Controller

Windows 2003 / MS SQL 2005 / Accpac ERP

IMG_0506

1. Upgrade system BIOS, raid controller firmware on windows 2003

2. Attach a new hard disk and configure raid 0, virtual drive #1

3. Move all data on current D drive to new attached drive

4. Back up C partition as a image: Clonezilla

5. Reconfigure hard disk 1 & 2 as raid 1, virtual drive #0

6. Restore backed up C drive image to new reconfigured virtual drive #0

Categories: Server, System Tags: , , ,

Linux Server Monitoring Tools

November 4th, 2009 admin No comments

- Network Monitoring
tcptrack
iptraf

- CPU, Memory Monitoring
top
free

- Disk I/O Monitoring
iostat(sysstat)

Categories: Server, System Tags: , , ,

PHP Pear Image_Graph

September 1st, 2009 admin No comments

#apt-get install php-pear

#pear install Numbers_Words-0.16.1
#pear install Numbers_Roman-1.0.2
#pear install Image_Canvas-0.3.1
#pear install Image_Graph-0.7.2

(Download TrueType core fonts from http://corefonts.sourceforge.net/)
cp *.ttf /usr/share/php/Image/Canvas/Fonts

Image_Graph

<?php
require_once '../../includes/include.php';
require_once 'Image/Graph.php';
require_once 'Image/Canvas.php';
date_default_timezone_set('America/New_York');

$customer_id = $_REQUEST[customer_id];
if (!$customer_id) exit();
$customer_data = get_order_customer_report_xy($customer_id);
if (!$customer_data) exit();

$Canvas =& Image_Canvas::factory('png', array('width' => 575, 'height' => 280));

// create the graph
$Graph =& Image_Graph::factory('graph', $Canvas);
// add a TrueType font
$Font =& $Graph->addNew('font', 'DejaVuSans');
$Font->setSize(8);

$Graph->setFont($Font);

// create the plotarea layout
$Graph->add(
Image_Graph::vertical(
Image_Graph::factory('title', array('', 11)),
Image_Graph::vertical(
$Plotarea = Image_Graph::factory('plotarea'),
$Legend = Image_Graph::factory('legend'),
90
),
5
)
);

$Legend->setPlotarea($Plotarea);

// create a grid and assign it to the secondary Y axis
$GridY2 =& $Plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y_SECONDARY);
$GridY2->setFillStyle(
Image_Graph::factory(
'gradient',
array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey')
)
);

list($year, $month) = split('[-.-]', $customer_data[0][1]);
$start=mktime(0,0,0,$month,1,$year);
$today=mktime(0,0,0,date('m'),1,date('Y'));
$interv=12-$month+(12*(date('Y')-$year-1))+date('m')+1;

// create a line plot
$Dataset1 =& Image_Graph::factory('dataset');
$Dataset2 =& Image_Graph::factory('dataset');

$max = 0;
for ($i=0; $i<count($customer_data); $i++) {
if ($max<$customer_data[$i][0]) $max=$customer_data[$i][0];
}
for ($i=0; $i<$interv; $i++) {
$Dataset2->addPoint(date('m/y', mktime(0,0,0,$month,1,$year)), 0);
$month++;
}
for ($i=0; $i<count($customer_data); $i++) {
list($year, $month) = split('[-.-]', $customer_data[$i][1]);
$Dataset1->addPoint(date('m/y', mktime(0,0,0,$month,1,$year)), $customer_data[$i][0]);
}

$Plot1 =& $Plotarea->addNew('bar', array(&$Dataset1));
$Plot1->setLineColor('red');

$Plot2 =& $Plotarea->addNew(
'Image_Graph_Plot_Area',
$Dataset2,
IMAGE_GRAPH_AXIS_Y_SECONDARY
);

$Plot2->setLineColor('gray');
$Plot2->setFillColor('white@0.2');

$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
$labInterv = floor($interv / 13);
$AxisX->setLabelInterval($labInterv);
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY->setTitle('Orders', 'vertical');
$AxisYsecondary =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY);

// output the Graph
$Graph->done();
db_close()
?>

Categories: Programming Tags: , , ,

Mount LVM disk

September 1st, 2009 admin No comments

#apt-get install lvm2

#pvscan
PV /dev/sdb1 VG server-roma lvm2 [136.49 GB / 0 free]
Total: 1 [136.49 GB] / in use: 1 [136.49 GB] / in no VG: 0 [0 ]

#vgscan
Reading all physical volumes. This may take a while…
Found volume group “server-roma” using metadata type lvm2

#vgchange -a y
2 logical volume(s) in volume group “server-roma” now active

#lvscan
ACTIVE ‘/dev/server-roma/root’ [130.91 GB] inherit
ACTIVE ‘/dev/server-roma/swap_1′ [5.58 GB] inherit

#mount /dev/server-roma/root /mnt

Categories: Server, System Tags: , , , ,