Thursday, 3 October 2013

awk - split only by first occurrence

awk - split only by first occurrence

i have a line like:
one:two:three:four:five:six
and i want to use awk to get $1 to be one and $2 to be
two:three:four:five:six
i know i can get it by doing sed before. that is to change the first
occurrence of : with sed then awk it by the new delimiter.
i want to know if there is an option to get awk to behave this way
so something like:
awk -F: '{print $1,$2}'
will print:
one two:three:four:five:six
i will also want to do some manipulations on $1 and $2. so i dont want
just to substitute the first occurrence of :

Wednesday, 2 October 2013

How to use LUA to parse a Property file

How to use LUA to parse a Property file

I need help on a small LUA script that needs to parse a property file and
generate an array using string key. Here's what I tried to do;
file = assert(io.open("/root/test.prop", "r"))
property = {}
for line in file:lines() do
for key, value in string.gmatch(line, "(.-)=(%w+)") do property[key] =
value end
end
For some unknown reason only the first pair of key value is added to the
table. Since I,m new to LUA, can somebody give an hint.

Based on Generic

Based on Generic

Question #1:
How would I return the default value of a type passed in to the
GetDefaultValue function. For example, passing in an
int would yield 0, a string would yield null, etc.
How would I constrain the type passed in to the GetDefaultValue function
to a class with a parameterless constructor
that implements IDisposable?
How would I instantiate an instance of the above type to return from the
GetDefaultValue function?
What other approaches could I use to do the same thing as #2 and #3, but
without generics?
public class GenericsExample
{
public static T GetDefaultValue()
{
}
}
// return ???
throw new NotImplementedException();

this code works fine on ie 10 but not on chrome and firefox (javascript/ajax portion)

this code works fine on ie 10 but not on chrome and firefox
(javascript/ajax portion)

this code works fine on IE10 but on chrome and firefox the slider is not
displayed .....everything else works fine
zip link:
https://docs.google.com/file/d/0B5TtGpU9w1RVZWpsYzF6YWRmWWc/edit?usp=sharing
<!DOCTYPE html>
<!-- Website template by freewebsitetemplates.com -->
<html>
<head>
<meta charset="UTF-8">
<title>Welcome To India</title>
<link rel="stylesheet" href="css/style.css" type="text/css">
<script src="jquery-1.10.2.min.js"></script>
<script src="jquery.cycle.all.js"></script>
<script type="text/javascript">
$('#slider').cycle({
fx: 'turnRight',
speed: 'slow',
next: '#next',
prev: '#prev'
});
</script>
</head>
<body>
<div id="background">
<div id="page">
<div id="header">
<div id="logo">
<a href="index.php"><img src="" alt="LOGO" height="112" width="118"></a>
</div>
<div id="navigation">
<ul>
<li class="selected">
<a href="index.php">Home</a>
</li>
<li>
<a href="about.php">Discover India</a>
</li>
<li>
<a href="forum.php">Forum</a>
</li>
<li>
<a href="tripplanner.php">Trip Planner</a>
</li>
<li>
<a href="holidays.php">Holidays</a>
</li>
<li>
<a href="news.php">Cuisines</a>
</li>
<li>
<a href="contact.php">Contact</a>
</li>
</ul>
</div>
</div>
<div id="contents">
<div id="adbox">
<div id="wrapper">
<div id="container">
<div class="controller" id="prev"></div>
<div id="slider">
<img src="Best-Heavy-Bike-Image-960x720.jpeg" width="100%"
height="100%" alt="bike">
<img src="Jumping-Cute-Dophin-Image-960x720.jpg" width="100%"
height="100%" alt="dolphin">
<img src="Nikon-D800-Skeleton-Image.jpeg" width="100%" height="100%"
alt="nikon">
</div>
<div class="controller" id="next"></div>
</div>
</div>
<h1>Enjoy the holidays in India</h1>
<p>
<a href="index.php">Welcome To India</a> About India <a
href="forum.php">Forum</a>.
</p>
</div>
<div id="main">
<div class="box">
<div>
<div>
<h3>Latest Blog</h3>
<ul>
<li>
<h4><a href="news.php">Popular Monuments</a></h4>
<p>
all popular monuments listed here
</p>
</li>
<li>
<h4><a href="news.php">Popular Tourists Spots</a></h4>
<span>May 29, 2023</span>
<p>
all popular tourist places are listed here
</p>
</li>
</ul>
</div>
</div>
</div>
<div id="testimonials" class="box">
<div>
<div>
<h3>History</h3>
<p>
History of india <span>- <a href="index.php">Welcome To India</a></span>
</p>
</div>
</div>
</div>
</div>
<div id="sidebar">
<div class="section">
<a href="rooms.jpg"><img src="images/rooms.jpg" alt="Img"></a>
</div>
<div class="section">
<a href="tripplanner.php"><img src="images/dive-site.jpg" alt="Img"></a>
</div>
<div class="section">
<a href="holidays.php"><img src="images/food.jpg" alt="Img"></a>
</div>
</div>
</div>
</div>
<div id="footer">
<div>
<ul class="navigation">
<li class="active">
<a href="index.php">Home</a>
</li>
<li>
<a href="about.php">Discover India</a>
</li>
<li>
<a href="forum.php">Forum </a>
</li>
<li>
<a href="tripplanner.php">Trip Planner</a>
</li>
<li>
<a href="holidays.php">Holidays</a>
</li>
<li>
<a href="news.php">Cuisines</a>
</li>
<li>
<a href="contact.php">Contact</a>
</li>
</ul>
<div id="connect">
<a href="http://www.facebook.com/" target="_blank"
class="facebook"></a> <a href="http://www.twitter.com/"
target="_blank" class="twitter"></a> <a
href="http://www.googleplus.com/" target="_blank"
class="googleplus"></a>
</div>
</div>
<p>
© 2013 by Roy
</p>
</div>
</div>
</body>
</html>

#EANF#

#EANF#

Quick question. I was wondering is there any way to just build an app made
in WL6, without the need to deploy to the server?
I know that in Cordova you can simply just run: cordova build android in
terminal, but I can't seem to find an option on the WL IDE to do this...
I'm just wanting to test the UI standalone without server functionality.
Rather than waiting for a deployment each time (I know it doesn't take too
long but just looking to save a little time).
Any help would be much appreciated.
Thanks in advanced.

Tuesday, 1 October 2013

Golang : functional programming in Go

Golang : functional programming in Go

I tried something I did in Javascript. But it says
http://play.golang.org/p/qlWLI03Dnl
package main
import "fmt"
import "regexp"
import "strings"
func swapit(str string) string {
var validID = regexp.MustCompile(`[a-z]|[A-Z]`)
return validID.ReplaceAllString(str, func(${0}, ${1}, ${2}) string {
return (${1}) ? strings.ToUpper(${0}) : strings.ToLower(${0})
})
}
func main() {
fmt.Println(swapit("hello wOrld."))
// HELLO WoRLD.
}
I also tried this removing ? : syntax but still does not work.
http://play.golang.org/p/mD6_78zzo1
Does really go not support this? Do I just give up and just bruteforce
each character to change cases?
Thanks a lot

Maintain data in redirection between different URLs in spring controller

Maintain data in redirection between different URLs in spring controller

I have just started to learn Spring MVC. So, sorry if my beginner level
irritates you.
To have my question short and clear i am using following simple code example.
i have two functions in two different spring MVC controllers. In first
controller, i am having:
@RequestMapping("/first")
public String first(Model model){
model.addAttribute("user", "User Name");
return "redirect:/second";
}
In second controller i am having:
@RequestMapping("/second")
public String second(){
return "myView";
}
Actually the first is redirecting to the second. Bt in my view(html), when
i try to get model's value like:
<h1>Welcome! ${user} <h1> //code in html to get user object
It shows empty.
So my question is how to transfer data when you are redirecting between
two requests in spring MVC. what is the best solution to achieve this. Can
i achieve this by Model or some other approach is there...? Thanks in
advance

Dell PowerEdge 750 (Wake-On-Lan)

Dell PowerEdge 750 (Wake-On-Lan)

How do I make (WOL) Wake-On-Lan work ? I've tried everything now, all I
see is green blinking power light when server is off. There is no
additional options for "Wake On Lan" or power state. Any ideas ? Does this
Dell PowerEdge 750 support WOL at all ?

Zimbra cluster drbd pacemaker auto start script

Zimbra cluster drbd pacemaker auto start script

I had to deploy a active/passive cluster for my zimbra server. And I
followed this tutorial
At "Automatic launch of Zimbra on the nodes", it said about bTactic script
and link for it. But this link died.
I'm not master of linux script and don't want to write this script again.
So anyone have this script or have other way instead of it?
Thank so much!!