Archive for May, 2010

Upload PDF to a WordPress Post

Posted in post on May 30th, 2010 by Aditya – Be the first to comment
Simplest way to add PDF, or possibly any other random file type, into WordPress post.
  1. Add new post.
  2. Click “Add Media” button.
  3. Using the file selection thing, select your PDF and click the upload button.
  4. After it uploads, you’ll have this new section that shows a Title, Caption, Description, and Link URL. You can fill those field depending on your preference.
  5. Click “Insert into Post”.
  6. Link to PDF can be seen on the post

SQMI_Saver_Awards

CanonAuthorizedDealers

http://struts.apache.org/2.1.8.1/docs/tu…

Posted in Uncategorized on May 30th, 2010 by Aditya – Be the first to comment

http://struts.apache.org/2.1.8.1/docs/tutorials.html

http://struts.apache.org/2.1.8.1/docs/guides.html

http://struts.apache.org/2.x/docs/home.html

Writing code on your WordPress post

Posted in post on May 30th, 2010 by Aditya – Be the first to comment

While WordPress blog doesn’t allow you to use potentially dangerous code on your blog, there is a way to post source code for viewing. I am using plugin called SyntaxHighlighter Evolved – made using SyntaxHighlighter JavaScript package by Alex Gorbatchev, the plugin used officially by wordpress.com.

I do not know how different the ‘evolved’ version of the plugin differs from the original but 66k people cannot be that dumb.

SyntaxHighlighter Evolved allows you to easily post syntax-highlighted code to your site without loosing it’s formatting.

For a live demo, please see my previous post.

Plugin Usage
Just wrap your code in

[language]

, such as

1

or


1

For a list of supported languages (all widely used languages are supported), please go to http://alexgorbatchev.com/wiki/SyntaxHighlighter:Brushes

struts.xml needs parameter to be in sequence

Posted in post on May 30th, 2010 by Aditya – 1 Comment

For some reason, I do whatever tutorial on Struts exception handling http://struts.apache.org/2.1.8.1/docs/exception-handling.html and yet the Struts giving me that obscure error message at package nodes.

It is said

The content of element type “package” must match “(result-types?,interceptors?,default-interceptor-ref?,default-
action-ref?,default-class-ref?,global-results?,global-exception-mappings?,action*)”.

I have no idea what is it until I see the tutorial mentions that I need to add two important nodes which I gladly copy pasted.

   <global-exception-mappings>
	<exception-mapping exception="org.apache.struts.register.exceptions.SecurityBreachException" result="securityerror" />
	 <exception-mapping exception="java.lang.Exception" result="error" />
   </global-exception-mappings>

  <global-results>
        <result name="securityerror">/securityerror.jsp</result>
  	<result name="error">/error.jsp</result>
   </global-results>

It took me 15 minutes to figure out that the tutorial gives me the wrong sequence of nodes. I need to do global-result before global-exception-mappings. Making the correct sequence to be:

  <global-results>
        <result name="securityerror">/securityerror.jsp</result>
  	<result name="error">/error.jsp</result>
   </global-results>

   <global-exception-mappings>
	<exception-mapping exception="org.apache.struts.register.exceptions.SecurityBreachException" result="securityerror" />
	 <exception-mapping exception="java.lang.Exception" result="error" />
   </global-exception-mappings>

and based on the above mentioned error notification and seeing the tutorial sample file, I could piece up the final struts.xml. In case you are lazy bum who do not want to download that extra 3.5 mb zip files and (assuming you follow the tutorial faithfully), the final struts.xml at the end of the day should be

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

	<constant name="struts.devMode" value="true" />
	<constant name="struts.custom.i18n.resources" value="global" />

	<package name="basicstruts2" extends="struts-default">

		<!--
			setup the default-stack exception mapping interceptor so that any
			exceptions not caught by this application will be logged and then
			handled by the global exception mapping
		-->

		<!--
			You can configure the Struts 2 framework to log any uncaught
			exceptions. To enable logging of the exceptions being handled by the
			Struts 2 framework you must specify some parameter values in
			struts.xml. If you examine the ExceptionMappingInterceptor class API
			there are three parameter values you can set to enable logging
			(logEnabled), the log level to use (logLevel), and the log category
			(logCategory) to specify in the log message. To set these parameter
			values for all actions that use a specific stack of interceptors in a
			package include the following in struts.xml just after the opening
			package node.
		-->
		<interceptors>
			<interceptor-stack name="appDefault">
				<interceptor-ref name="defaultStack">
					<param name="exception.logEnabled">true</param>
					<param name="exception.logLevel">ERROR</param>
				</interceptor-ref>
			</interceptor-stack>
		</interceptors>

		<default-interceptor-ref name="appDefault" />

		<!--
			To enable global exception handling you need to add two nodes to
			struts.xml: global-exception-mapping and global-results. For example
			examine struts.xml from the Exception Handling code download
			(http://code.google.com/p/struts2-examples/downloads/list).
		-->

		<global-results>
			<result name="error">/error.jsp</result>
			<result name="securityerror">/securityerror.jsp</result>
		</global-results>

		<global-exception-mappings>
			<exception-mapping
				exception="org.apache.struts.register.exceptions.SecurityBreachException"
				result="securityerror" />
			<exception-mapping exception="java.lang.Exception"
				result="error" />
		</global-exception-mappings>

		<action name="causesecurityexception" class="org.apache.struts.register.action.Register"
			method="throwSecurityException">
			<result>/register.jsp</result>
		</action>

		<action name="causeexception" class="org.apache.struts.register.action.Register"
			method="throwException">
			<result>/register.jsp</result>
		</action>

		<action name="causenullpointerexception" class="org.apache.struts.register.action.Register"
			method="throwNullPointerException">
			<result>/register.jsp</result>
		</action>

		<!--
			If you need to handle an exception in a specific way for a certain
			action you can use the exception-mapping node within the action node.
		-->

		<action name="actionspecificexception" class="org.apache.struts.register.action.Register"
			method="throwSecurityException">
			<exception-mapping
				exception="org.apache.struts.register.exceptions.SecurityBreachException"
				result="login" />
			<result>/register.jsp</result>
			<result name="login">/login.jsp</result>
		</action>

		<action name="index">
			<result>/index.jsp</result>
		</action>

		<action name="hello"
			class="org.apache.struts.helloworld.action.HelloWorldAction" method="execute">
			<result name="success">/HelloWorld.jsp</result>
		</action>

		<action name="register" class="org.apache.struts.register.action.Register"
			method="execute">
			<result name="success">/thankyou.jsp</result>
			<result name="input">/register.jsp</result>
		</action>

		<action name="registerInput" class="org.apache.struts.register.action.Register"
			method="input">
			<result name="input">/register.jsp</result>
		</action>
	</package>

</struts>

Photoshoot locations in Carnegie Mellon University

Posted in post on May 30th, 2010 by Aditya – Be the first to comment

Being somewhat historical and rustic, there are several interesting places around CMU for you to take pictures.

Uniquely CMU

  • The Fence
  • Walk to the sky
  • Green pasture in front of Hamerschlag’s tower
  • Pauch Bridge

Indoor

  • UC Black Chairs
  • Some study room
  • Some lecture hall

Building related

  • Staircase in some fancy building
  • Brick wall pattern
  • Mellon Institute pillar

Struts on Eclipse could not get refreshed

Posted in post on May 30th, 2010 by Aditya – Be the first to comment

Often when I am doing coding on java, most changes I have made seldom appear instantly. To make it faster, the following steps (in order / combination) might be working.

  1. Right click on the project –> “Build Project”
  2. Stop tomcat, clean the server
  3. Restart

Get into Apple Store Customer Service Chat

Posted in post on May 26th, 2010 by Aditya – Be the first to comment

I found this trick to get in touch with Apple cs representative through live chat in case you want to ask some simple question. Be aware that those people work in web chat have almost no power and do not have as much power as people with phone number. But hey… at least you only need to wait for average 30 seconds compare to xyz minutes when calling them through that 1-800 number.

1. go to product page, order anything
2. add to cart
3. and magically ‘Live Chat’ link appears beneath that 1-800 number

Stupid apple

Negotiation Class #2

Posted in post on May 25th, 2010 by Aditya – Be the first to comment

Some pointer

  • do research, know what you want
  • the more you negotiate, the more comfortable you become.
  • start from bottom -> top (decision maker, manager, customer retention instead of customer service)
  • pleasant demeanor for win-win result “I want to help”
  • success may not be desired come – success is asking
  • people tend not to ask for themselves – receiving “no” is more personal in this case of when ask for other as the “no” is less personal
  • More face time = less rejection
  • before negotiation, research on reasons why people say no and how to respond
  • expect “NO” several times
  • Anchoring: if you do not know, do not put the number first.
  • Acknowledge disadvantages before proceeeding
  • “Can you do better than that” “Could you work with me?”
  • Customer retention vs. Customer service
  • Pitfall of 5 styles of negotiation = wrong time and wrong usage and overdependence on one style
  • Know “wish” “want” “walk” price -> establish reference point to avoid sellers or buyers remorse
  • ZOPA – negotiation is about adjusting preference point
  • BATNA
  • Do not be a MALCONTENT
  • shirt / office convey power. Try to negotiate in neutral or advantageous place

Three Rules of Win-Win Negotiation

Posted in post on May 25th, 2010 by Aditya – Be the first to comment

I obtain this material from my recently attended “Negotiation” class in CMU. Digressing a bit, the class is wonderful. The professor (Jared I think) can really deliver the material. And the wealth of experience from class mates are simply fabulous. Some of my take from my May 24th class is the three rules of win-win negotiation – which based on this belief that there is indeed EXIST in every negotiation the chance that both parties could win from negotiation. In short, here they are:

  1. Change the behavior from adversarial to cooperative
  2. Develop trust by listening
  3. Explore options for mutual satisfactions

Some pointer for each rules

Change behavior from adversarial to cooperative

  • Do not adopt other hostility
  • Position yourself as partner than negotiator
  • Try to understand point of view by asking and listening
  • Create atmosphere of cooperation
  • Avoid right and wrong arguments
  • Understand that gaining satisfaction for both party is important
    • Go beyond other negotiator’s position
    • Ask question
    • Try to satisfy

Develop trust by listening

  • 70% listening + 30% talk
  • Ask probing question
  • People do not like contradiction, lean toward validation – allow others to express their stand before reposition your stand as addition to the others.
  • Do not interrupt
  • Understand position
  • Do not contradict

Explore options for mutual satisfaction

  • Focus on solving the problem – use “WE” instead
  • Brainstorm for options for outcome
  • Do research, build area where they are more agreeable
  • Break agreements into parts
  • Find as many agreements as possible.

Notice the most common pattern: ask. Indeed to get into win-win situation, negotiator needs to spend extra effort in seeking out and finding out more about your counterparts. The idea is that both parties must come to a realization that the  size of the pie is not constant. More can be done to expand the pie.

Some pointers I should jot down on some ways to expand the pie

  • breakdown the common niche target
  • break all assumptions
  • explore for possible convenience factor

    Increase Max Upload Size on WordPress

    Posted in post on May 20th, 2010 by Aditya – Be the first to comment

    The problem comes when I try to set up client’s WordPress environment. In short, my client wish to create a podcast blog but WordPress somehow could not accept file beyond certain size – saying ‘This file is too big. Your server upload max filezie is xyz M‘.

    The hosting that my client is using Bluehost shared hosting. A decent hosting with c-panel interface and various other stuff – most importantly, Bluehost allows modifying php.ini file which will be useful in solving above mentioned problem

    My workaround involves creating default php.ini file and modify it accordingly.

    1. From CPANEL, go to Bluehost PHP Configuration (or any CPANEL PHP configuration.)
    2. Click INSTALL DEFAULT PHP.INI – This will copy the master php.ini to your public_html directory named “php.ini.default”. We can then edit the file with any custom directives your scripts require.
    3. Select ‘PHP5 (single php.ini)’ option
    4. Use anything within your means, rename PHP.INI.DEFAULT created at PUBLIC_HTML directory into PHP.INI
    5. Use whatever means necessary to change these following lines into:
      • post_max_size = 100M
      • file_uploads = On
      • upload_max_filesize = 100M
      • max_execution_time = 300
    6. The above configuration will enable me/my client to increase the maximum upload size to 100MB.
    7. Save! And you are done

    I have tried solution offered by http://simplercomputing.net/2009/02/13/fix-php-max-upload-size-wordpress/ but could not work.

    In any case, since I could have find solution that serve me well.