Thursday, 3 October 2013

KVM Ethernet bridge flaky connection and delay

KVM Ethernet bridge flaky connection and delay

libvirt 0.9.10 qemu-kvm CentOS 6, STP enabled bridge. One guest has very
unreliable connection. OS is Win Vista, connection shows ip4 Internet
connected but often 100% packet loss pinging gateway. I run tcpdump on
host when pinging gateway from guest and I dont see the icmp requests
until seconds after the ping timeout. Guest uses br0
bridge name bridge id STP enabled interfaces
br0 8000.90b11c106fec yes em1
vnet0
vnet1
virbr0 8000.525400b7455a yes virbr0-nic

Wednesday, 2 October 2013

Euler character of etale finite cover

Euler character of etale finite cover

Let $\pi: \tilde{X} \to X$ be an etale finite cover, then why the Euler
character has relation:
$$\chi(\tilde{X},\mathcal{O}_{\tilde{X}})=\deg(\pi)\chi({X},\mathcal{O}_{{X}}).$$
I try to use Riemann-Roch, but do not know how to relate Chern characters
and Todd class of them.
Besides, I found a similar question on topological setting.

Intersect not giving expected results

Intersect not giving expected results

In the below code if I iterated over L3 I would expect to have 2 results
available. However it only has one result and that result is the objTest
with a Id = 9. I thought it should be a result set with two objtest s' Id
= 9 and Id = 10.
class Program
{
public class objTest
{
public int Value { get; set; }
public bool On { get; set; }
public int Id { get; set; }
}
class PramComp : EqualityComparer<objTest>
{
public override bool Equals(objTest x, objTest y)
{
return x.Value == y.Value;
}
public override int GetHashCode(objTest obj)
{
return obj.Value.GetHashCode();
}
}
static void Main(string[] args)
{
List<objTest> L1 = new List<objTest>();
L1.Add(new objTest { Value = 1, On = true ,Id =1});
L1.Add(new objTest { Value = 2, On = false ,Id =2});
L1.Add(new objTest { Value = 3, On = false, Id = 3 });
L1.Add(new objTest { Value = 4, On = false ,Id =4});
L1.Add(new objTest { Value = 5, On = false ,Id =5});
List<objTest> L2 = new List<objTest>();
L2.Add(new objTest { Value = 6, On = false ,Id =6});
L2.Add(new objTest { Value = 7, On = false ,Id=7});
L2.Add(new objTest { Value = 8, On = false,Id =8 });
L2.Add(new objTest { Value = 1, On = true,Id =9 });
L2.Add(new objTest { Value = 1, On = true, Id =10 });
var L3 = L2.Intersect(L1, new PramComp());
}
}
So I have made a mistake with my code if I want to return the two results
Id=9 and Id=10. Could someone tell me where my mistake is?

Why System.currentTimeMillis() generate incorrect long value?

Why System.currentTimeMillis() generate incorrect long value?

It was discussed too many times, I know, but I can't get why the
milliseconds generated by mine:
System.currentTimeMillis();
Or by:
Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTimeInMillis()
Are not equal to what I see on http://www.epochconverter.com/?
What I need is to merely generate a String of concrete format, but I've
found out the milliseconds aren't right.
Just in case here is how I do it:
private static final String DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
public static String getCurrentTimestamp() {
long time = System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN);
String lastModifiedTime = sdf.format(time);
Logger.logVerbose(TAG, "Generated timestamp is " + lastModifiedTime);
return lastModifiedTime;
}
What I finally get is just a local time, but I need the only time which is
pure UTC without conjunction with my timezone.
I've even checked it with SQLite (using the SELECT
strftime('%s',timestring);) and got the correct milliseconds. Why then I
got it incorrectly generated by those two statements I posted above?
Thanks a lot in advance.

WCF WebFaultException ExceptionDetail

WCF WebFaultException ExceptionDetail

I'm creating a WCF service that returns data in JSON Format. I'm trying to
figure out how to best handle exceptions and I'm trying to use the
WebFaultException class to return an exception detail message in the
response, which can later be outputted to the user.
A simple Test of this method I am trying is as follows
The WCF Service method
<WebInvoke(Method:="POST",
ResponseFormat:=WebMessageFormat.Json)>
<OperationContract()>
Public Function Test() As Object
Throw New WebFaultException(Of String)("Message Details",
Net.HttpStatusCode.NotFound)
End Function
From what I found searching for answers to this questions, you should give
the service a behaviorconfiguartion which sets
includeExceptionDetailInFaults to true.
My Web.Config
<service name="WebserviceExceptionTest.Service"
behaviorConfiguration="behavior">
<endpoint address=""
behaviorConfiguration="WebserviceExceptionTest.ServiceAspNetAjaxBehavior"
binding="webHttpBinding"
contract="WebserviceExceptionTest.Service" />
</service>
<serviceBehaviors>
<behavior name="behavior">
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
Unfortunately, this appears to not do the trick for me and the response
still does not include the exception detail, the JSON string looks like
this:
{"ExceptionDetail":null,"ExceptionType":null,"Message":"Not
Found","StackTrace":null}
Does anyone have any idea of what it is I am doing wrong, or am I just
entirely on the wrong path? Thanks!

Tuesday, 1 October 2013

Naive Bayes and Logistic Regression Error Rate

Naive Bayes and Logistic Regression Error Rate

I have been trying to figure out the correlation between the error rate
and the number of features in both of these models. I watched some videos,
and the creator of the video said that a simple model can be better than a
complicated model. So I figured that the more features I had the greater
the error rate would be. This did not prove to be true in my work, and
when I had less features the error rate went up. I'm not sure if I'm doing
this incorrectly, or if the guy in the video made a mistake. Can someone
care to explain? I also am curious how features relate to Logistic
Regression's error rate as well.

jQuery round number to 2 decimal places

jQuery round number to 2 decimal places

I have a little problem that I can't seem to get my head round...
I have figure that I need to find what the VAT element of it would be, I
have the following jQuery which works but it doesn't fix it to 2 decimal
places.
var ThreeMonthPriceFinal = "99.29";
var ThreeMonthPriceVAT = ThreeMonthPriceFinal * 0.2.toFixed(2);
alert(ThreeMonthPriceVAT);
It works out the VAT correctly but adds lots of recurring digits that i
don't need... I can't round it up as with VAT you not really supposed to.
http://jsfiddle.net/Xg4Qs/
The Jfiddle shows £19.858000000000004 I need this to show 19.86, i've
tried the following but it rounds it up to the whole amount not just 1p.
var ThreeMonthPriceVAT = Math.round(ThreeMonthPriceFinal * 0.2).toFixed(2);
Can anyone help me?

Can abstract nonsense be helpful here?

Can abstract nonsense be helpful here?

Here a question for those among you, who teach homotopics/Algebraic
Topology at University. I encountered some questions that were quite easy
to solve in category hTop instead of Top (example 1, example 2). In my
answers I said that familiarity with categories was necessary to
understand. Can answers like that really be helpful to the student? If not
then I should stop with it. The student must be central in my thinking
when I answer a question. It must be not be a way just to expose my
knowledge (my flesh is weak).
You know the best what is helpful for your students. So I ask you.

what is the best way to keep updated more than 75 windows servers?

what is the best way to keep updated more than 75 windows servers?

After virtualising our server infraestructure, in the last two years the
number of windows servers has grown from aprox. 20 to 75, mainly by
migrating every service of our corporation to his own vm, but we also are
deploying new applications that require one or more servers.
In the old times, keeping windows updated take me only 1 hour to do this
(boring) task, but now it's coming really time-consuming and also
error-prone (too many servers ,some of them are clusters or nbl, and
others have services that depends in other servers, that expect the other
server is online when it's restarted, so you can't reboot all at one
time).
Our workflow is the following:
1- Someone aproves in WSUS the updates of the month after little testing.
2- One time every month, on Friday evening, when almost isn't anyone
working, I start the boring task of log in every server, wuauclt
/detectnow, click to download updates, click to install, reboot (keeping
in mind what other servers are rebooting at the moment), log in again,
check if is any pending update after reboot, etc etc.
I searched in internet and I didn't find anything that can help me in this
task, I tried to make a c# app that manage all of this without manually
login every server, but wuapi.dll is unable to download/install in remote.
So, I think this has to be a common problem, what other people do? As you
can expect, we can't leave updates to install automatically or reboot when
automatic updates want.

Monday, 30 September 2013

How to specify the SSL port with command line curl?

How to specify the SSL port with command line curl?

I'm trying to test the SSL connexion on one of my servers. The server is
behind a LB so it's listening for SSL connexions on the port 8090.
I have use the --resolve option to test when talking to the LB which
listens on port 443.
curl --resolve 'myservice.com:443:1.1.1.1' 'https://myservice.com'
but when I do:
curl --resolve 'myservice.com:8090:2.2.2.2' 'https://myservice.com:8090'
curl simply ignores the port and goes with 443. Of-course, this causes the
DNS cache to miss and I end-up using the public DNS IP...
* Added myservice.com:8090:2.2.2.2 to DNS cache
* About to connect() to myservice.com port 443 (#0)
* Trying 3.3.3.3...
* Connected to myservice.com (3.3.3.3) port 443 (#0)
How can I force curl to use the port 8090 for an SSL connexion?
Thanks.

$m ( \{ x : f(x) > 0 \} ) = 0 \implies f = 0 $ almost everywhere

$m ( \{ x : f(x) > 0 \} ) = 0 \implies f = 0 $ almost everywhere

Suppose $f$ is non-negative measurable function. Put $E = \{ x : f(x) > 0
\} $.
Say $m(E) = 0$. In other words, $E$ is null set. Then does it follow that
$f = 0 $ almost everywhere ?

App crashes when switching between fragments - both have a GoogleMap

App crashes when switching between fragments - both have a GoogleMap

I managed to make it work, but when I switch the fragments the app crashes.
another thing that I want, Is to make the fragment show exactly in the
state the user left it.
What I mean is that I don't want to make a new instance of the fragment
every single time the user clicks the button that switches to it.
the FragmentActivity:
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
public class Fragments extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragments);
Add fragment = new Add();
FragmentTransaction transaction = getSupportFragmentManager()
.beginTransaction();
transaction.add(R.id.fragment_place, fragment);
transaction.commit();
}
public void onSelectFragment(View view) {
Fragment newFragment;
if (view == findViewById(R.id.add)) {
newFragment = new Add();
} else if (view == findViewById(R.id.map)) {
newFragment = new MainActivity();
} else {
newFragment = new Add();
}
FragmentTransaction transaction = getSupportFragmentManager()
.beginTransaction();
transaction.replace(R.id.fragment_place, newFragment);
transaction.addToBackStack(null);
transaction.commit();
}
}
The Logcat:
09-30 18:41:09.918: W/dalvikvm(18931): threadid=1: thread exiting with
uncaught exception (group=0x40ed5300)
09-30 18:41:09.968: E/AndroidRuntime(18931): FATAL EXCEPTION: main
09-30 18:41:09.968: E/AndroidRuntime(18931):
android.view.InflateException: Binary XML file line #255: Error inflating
class fragment
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.view.LayoutInflater.inflate(LayoutInflater.java:489)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
com.example.free.Add.onCreateView(Add.java:141)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.support.v4.app.Fragment.performCreateView(Fragment.java:1478)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1460)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.os.Handler.handleCallback(Handler.java:615)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.os.Handler.dispatchMessage(Handler.java:92)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.os.Looper.loop(Looper.java:137)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.app.ActivityThread.main(ActivityThread.java:4931)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
java.lang.reflect.Method.invokeNative(Native Method)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
java.lang.reflect.Method.invoke(Method.java:511)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
dalvik.system.NativeStart.main(Native Method)
09-30 18:41:09.968: E/AndroidRuntime(18931): Caused by:
java.lang.IllegalArgumentException: Binary XML file line #255: Duplicate
id 0x7f07001d, tag null, or parent id 0x0 with another fragment for
com.google.android.gms.maps.SupportMapFragment
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
09-30 18:41:09.968: E/AndroidRuntime(18931): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
09-30 18:41:09.968: E/AndroidRuntime(18931): ... 21 more
What's the problem here?

Javascript using xml in ckeditor

Javascript using xml in ckeditor

xml file: Common glossary sense would*7*having students read and write
blogs,suggest that the abundance of digital texts
My cursor points sense would7. 1) i want to take the length of para from
starting point(common) to sense would7. 2)i also have to take next paras
content and append to the previous onehaving students read and write
blogs,
Like This: Common glossary sense would7 having students read and write
blogs,suggest that the abundance of digital texts

Sunday, 29 September 2013

Centering navmenu within a div

Centering navmenu within a div

I have a drop down nav menu that I need to be centered within a div but
text-align: center isn't working for me.
The site is at http://www.joekellywebdesign.com/churchsample1/index.html
<div id="navmenudiv">
`<ul id="navmenu">`
`<li><a href="index.html">Home</a></li>`
`<li><a href="about.html">About Us</a>`
`<ul class="sub1">`
`<li><a href="introduction.html">Introduction</a></li>`
` <li><a href="whoweare.html">Who We Are</a></li>`
`<li><a href="staff.html">Staff</a></li>`
`</ul>`
`</li>`
`<li><a href="services.html">Services</a>`
`<ul class="sub1">`
`<li><a href="sundaymorning.html">Sunday
Morning</a></li>`
`<li><a href="sundayevening.html">Sunday
Evening</a></li>`
`<li><a href="wednesday.html">Wednesday Evening</a></li>`
`</ul> `
`</li>`
`<li><a href="resources.html">Resources</a></li>`
`<li><a href="contact.html">Contact Us</a></li>`
`<li><a href="news.html">News and Events</a></li>`
`</ul>`
`</div>`
The css is at http://www.joekellywebdesign.com/churchsample1/css/styles.css
navmenudiv {
z-index:60;
margin: -30px 0;
height:50px;
background-color:#5340BF;
top:40;position:
relative;
text-align:center;
}

Java syntax issues

Java syntax issues

I would like to say I'm new to Java, so I'm wallowing in a lot of suck.
I'm trying to do a Josephus problem, but I'm not allowed to use code
snippets from other people. With this in mind, I have 27 errors in my
code, but can't figure out how to fix it. Would you wonderful people
explain to me why it won't compile. I want to see if my logic is flawed,
but I can't test it because it won't compile. Any other tips to make me
not suck so bad are more than welcome! Here is my code: import
java.util.*;
public class Josephus
{
public class Link
{
public int num;
public Link next;
public Link (int d)
{
num = d;
next = null;
}
}
public class Main
{
Scanner in = new Scanner(System.in);
System.out.println("How many players");
int numPlayers = in.nextInt();
Link first, last;
first = last = new Link (1);
for(int k=2; k<=numPlayers; k++)
{
last.next = new Link(k);
last = last.next;
}
last.next = first;
System.out.println("How many skips");
int m = in.nextInt();
for (int g=0; g<numPlayers; g++)
{
for (int k=0; k<=m; k++);
{
last = last.next;
}
last.next;
last = last.next;
}
}
}

techniques in low latency financial softwares

techniques in low latency financial softwares

Coming from a video game industry background, I just wondered about common
techniques those are being used in low latency ( as processing time , not
network latency or distributed time ) softwares for financial / HFT
softwares.
Yes , I know that definitely premature optimisation is devil, however in
particular , I wondered whether techniques used in AAA game engines are
being utilised , those are :
Multithreaded software architecture & multiprocessors ( for ex OpenMP or
SPUs ) & usage of SIMD for base 3d maths libraries
CPU cache friendly programmig against cache misses , load hit store etc ->
fitting data struct size to cache , organising datastructures as either
SoA or AoS , pre-fecthing data to your cache
data alignment for fast CPU fetchs
implementing a memory pool/pre allocated custom heap system to avoid OS
heap manager costs also things like memory fragmentation
minimising file system access etc, for instance if there is a need for
database using an in-memory system like SQLite etc
Are things like these being used there as well ?

where should I save the VM data/instance in a MVVM design?

where should I save the VM data/instance in a MVVM design?

I'm new to MVVM in a WPF project. As to my understanding, the View is the
objects created by xaml files (window, grid, usercontrol). The Model is my
data. The View-Model is some other object instance.
I have defined all the VM classes, but my questions is where is the best
place to instantiate the VM instance? to be more specific, where should I
declare the VM member variable and call the new() function?
Currently I defined a static member variable of the VM and declare it
inside my usercontrol. The VM should be accessed by several Views and
that's why I declared it as static.
It's kind of ugly, I think, from the Object Oriented design, because I'm
using static or global variables.
So what's the common place to declare VM instances?

Saturday, 28 September 2013

Why does this c program crashe?

Why does this c program crashe?

I want to make a list of , for example 10 sentences that are entered
through the keyboard. For getting a line I am using a function getline().
Can anybody explain why does this program crash upon entering the second
line? Where is the mistake ?
#define LISTMAX 100
#define LINEMAX 100
#include <stdio.h>
#include <string.h>
void getline(char *);
int main ()
{
char w[LINEMAX], *list[LISTMAX];
int i;
for(i = 0; i < 10; i++)
{
getline(w);
strcpy(list[i], w);
}
for(i = 0; i < 10; i++)
printf("%s\n", list[i]);
return 0;
}
void getline(char *word)
{
while((*word++ = getchar()) != '\n');
*word = '\0';
}

Repeating JS function

Repeating JS function

I'm trying to have this function repeat at the end of it's cycle. I tried
assigning the function to a variable and calling the variable in the
callback, but that failed. I tried wrapping this function in a setInterval
function, still couldn't get it to work.
How do I get this function to run an infinite loop and repeat itself?
$("span.text-change").typed({
strings: ["First sentence.", "Second sentence."],
typeSpeed: 30, // typing speed
backDelay: 500, // pause before backspacing
callback: function () {
// do stuff
}
});
This is the plugin: Typed JS

LISP Changing a global variable value in a local function

LISP Changing a global variable value in a local function

I am a novice in the field of lisp... i am writing a code to solve the 8
puzzle in bfs...
I want to store the visited lists in a global list and change its value
regularly from within a function... (defparameter vlist nil) (defun
bfs-core(node-list) (let (cur-node tmp-node-list) (if (null node-list) NIL
(progn ; (if (= 1 (length node-list)) (setq cur-node (car node-list))
(setq tmp-node-list (cdr node-list)) (if (goalp cur-node) cur-node ((setq
vlist (append cur-node vlist)) (bfs-core (append tmp-node-list (expand
cur-node)))))) ) ) )
The defparameter one is my global variable... and witjin the function i
want to change its value with setq... i have also used defvar, setf,set
and all possible combinations..... Can anyone help me out????

Placing a textview on top of imageview in android

Placing a textview on top of imageview in android

I have a listview, that has a single imageview which is scrollable vertically
I am trying to place a textview on top of Imageview
Both the views must be visible



Is it possible ?
If yes, How to do it programmatically ?
What changes should i need to make ?



list_view_item_for_images.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/flag"
android:layout_width="fill_parent"
android:layout_height="250dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
It gives a output like below

How to do something like below

note :: Dish 1 & 2 are textviews

Friday, 27 September 2013

Pulling specific terms in wordpress template

Pulling specific terms in wordpress template

I am trying to create a two different portfolios on a Wordpress site by
creating two templates, as I need each portfolio to have a different
background color and logo. I am attempting to edit the current filterable
portfolio template. I can see the it is pulling in the term 'skill', which
I label each project with (i.e. ads, logos, etc.) and would like to limit
which skills it pulls in. One portfolio will be a design portfolio pulling
in the skills ads, logos, collateral, pro bono, and the second portfolio
will pull in another set of specific skills. Could someone please help me
with how to pull in specific skills? I have included the current
filterable portfolio code. Thank you in advance.
<?php
/**
* Template Name: Portfolio - Filterable
* Description: Template to display filterable portfolio items
*/
get_header();
$portfolio_title = stag_get_option( 'portfolio_title' );
$portfolio_subtitle = stag_get_option( 'portfolio_subtitle' );
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<header class="page-header page-header--portfolio">
<?php if( ! empty( $portfolio_title ) ) echo "<h1
class='blog-title'><span>{$portfolio_title}</span></h1>"; ?>
<?php if( ! empty( $portfolio_subtitle ) ) echo "<p
class='blog-subtitle'>{$portfolio_subtitle}</p>"; ?>
</header>
<ul class="portfolio-filter">
<li class="button filter" data-filter="all"><?php _e('All',
'stag'); ?></li>
<?php
$terms = get_terms('skill');
$count = count($terms);
$i = 0;
if($count > 0){
foreach($terms as $term){
echo "<li class='button filter'
data-filter='{$term->slug}'>{$term->name}</li>";
}
}
?>
</ul>
<section id="portfolio-filter" class="grids portfolio-items">
<?php
$args = array(
'post_type' => 'portfolio',
'posts_per_page' => -1,
);
$the_query = new WP_Query( $args );
if( $the_query->have_posts() ) :
while( $the_query->have_posts() ): $the_query->the_post();
if( ! has_post_thumbnail() ) continue;
get_template_part( 'content', 'portfolio' );
endwhile;
endif;
wp_reset_postdata();
?>
</section>
</main><!-- #main -->
</div><!-- #primary -->

UIPageViewController Page Color?

UIPageViewController Page Color?

I have a UIPageViewController that is working fine.
I am using a texture for the page that is off white. This is all fine,
except the back of the page is white which makes it look strange.
I can set the doubleSided property to YES and then use my texture for the
other side of the page. But then I loose the front of the page partially
showing through to the back.
So, is there anyway to set the page color of the backside with the
doubleSided property set to NO?

onClick transition and toggle visibility on div element jQuery

onClick transition and toggle visibility on div element jQuery

Here I want to create a dropdown form with transition effect on click of
element, onClick it triggers the transition but when I click again it
doesn't triggers the transition instead it just hides the div element....
Demo: http://tryitnow.net16.net/
See below:
function:
<script>
$(function() {
$("#login").click(function() {
var visi= $(".User-Login").css('visibility');
if(visi=="visible") {
$(".User-Login").toggleClass("box-colap");
$(".User-Login").css('visibility','hidden');
}
else {
$(".User-Login").css('visibility','visible');
$(".User-Login").toggleClass("box-change");
}
});
});
html:
<table class="MainMenu" style="width:100%;background-color:white"
align="center">
<a href="#">Home</a>
&nbsp;
&nbsp;
</td>
<td>
<a href="#">How It Works </a>
</td>
<td>
<a href="#"> Features</a>
</td>
<td>
<a href="#"> Why Us </a>
</td>
<td>
<a href="#"> Sign Up </a>
</td>
<td>
<a id="login" href="javascript:void(0);"> Login </a>
</td>
</table>
css:
.User-Login {
visibility:hidden;
position:absolute;
left:1150px;
background:black;
-webkit-transition: height 2s ease;
-moz-transition: height 2s ease;
-o-transition: height 2s ease;
-ms-transition: height 2s ease;
transition:, height 2s ease;
overflow:hidden;
height:10px;
top:90px;
}
.box-change {
height: 250px;
}
.box-colap {
height:10px;
}

curl put 411 required length

curl put 411 required length

I am trying to do a curl put with php using the below code. I am getting a
response from the server.
411 Length Required nginx/1.2.3
Here is the code:
curl_setopt($crl, CURLOPT_HTTPHEADER, array('Content-Type:
application/json','Content-Length:115'));
curl_setopt($crl, CURLOPT_POSTFIELDS,$data);
curl_setopt($crl, CURLOPT_PUT, true);
curl_setopt($crl,
CURLOPT_URL,"http://someurl.com?version=2.0&access_token=$access_token&response_format=json");
curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($crl, CURLOPT_VERBOSE, true);
curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, $timeout );
why is the length not getting noticed?

Movgin a solr instance to a test server

Movgin a solr instance to a test server

I am currently in the process of moving a drupal site over to a test
environment on another server and the site includes a Solr 3.5
installation (running with Tomcat 6 on a Cent OS server).
I've already set up the Tomcat servlet and the Drupal site on another
CentOS box, but I am wondering about the Solr installation and what I need
to do to bring it over. So far it is not working and I am having trouble
identifying what all needs to be changed for the new environment.
On the production server, the Solr files are in the Drupal home directory,
so they were brought over when I brought over the Drupal files. But what
will I need to change to recognize the new server and the Tomcat servlet
(which I am sure is configured just a little bit differently on the dev
server in terms of where it is located etc.).
Or is it better to do a fresh Solr install and just bring over a few key
files from the production server?

Japanese text Insert to MYSQL via Ajax ,inserted invalid charters

Japanese text Insert to MYSQL via Ajax ,inserted invalid charters

I have an issue with insert 'Japanese' text to Mysql via Ajax ,in my table
there is some invalid charters. But if I insert same text via normal form
submission it inserted 'Japanese' text correctly

Thursday, 26 September 2013

overloaded function with argument evaluation error

overloaded function with argument evaluation error

So I'm learning C++ and I have to create an overloaded function and from
that take the largest number from a set of numbers. This works with 2
numbers but when I comment out the call to the function for 2 numbers and
try the one with 3 numbers it gives me a ton of errors. I need a fresh
pair of eyes to look at my code and see what I am doing wrong.
#include <iostream>
using namespace std;
// function prototypes
double max(double numberOne, double numberTwo);
double max(double numberOne, double numberTwo, double numberThree);
int main()
{
int numberOne,
numberTwo,
numberThree;
// user input
cout << "Input number 1: " << endl;
cin >> numberOne;
cout << "Input number 2: " << endl;
cin >> numberTwo;
cout << "Input number 3: " << endl;
cin >> numberThree;
cout << "The largest of " << numberOne << " and " << numberTwo << ": "
<< max(numberOne, numberTwo) << endl;
cout << "The largest of " << numberOne << ", " << numberTwo << ", and
" << numberThree << ": " << max(numberOne, numberTwo, numberThree) <<
endl;
return 0;
}
// function declarations
double max(double numberOne, double numberTwo) {
// if number one is greater than number two return that
// otherwise return numberTwo as the greater value
if (numberOne > numberTwo) {
return numberOne;
} else {
return numberTwo;
}
}
double max(double numberOne, double numberTwo, double numberThree) {
// compare 1 and 2 to see which is greater
if (numberOne > numberTwo) {
if (numberOne > numberThree) {
// 2 is greater return it
return numberOne;
} else {
// else 3 is greater return that
return numberThree;
}
} else {
if (numberTwo > numberThree) {
// 2 is greater return it
return numberTwo;
} else {
// else 3 is greater return that
return numberThree;
}
}
}

Wednesday, 25 September 2013

Using setInterval into another Setinterval

Using setInterval into another Setinterval

Hi Friends i want to run my code with only using one setInterval function.
Currently I am using two setInterval's to achieve my goal can we get same
result with using only one 'setInterval' for your reff pleaase go to this
link http://jsfiddle.net/msUyh/ and i have also mentioned my code below
script
setInterval(function () {
$('div').css('display', 'none');
}, 5000);
var num = 2;
$('div').append('1<br/>')
setInterval(function () {
if (num <= 5) {
$('div').append(num + '<br/>')
num++;
}
}, 1000)
CSS
body, html{height:100%;}
div
{
position:absolute;
width:100%;
height:100%;
background:#000;
display:block;
font:15px Arial, Helvetica, sans-serif; color:#fff;
}
HTML
<div></div>

Thursday, 19 September 2013

Jquery UI Tabs -- Content is not refreshed

Jquery UI Tabs -- Content is not refreshed

I am running into a weird behavior and would like to get your inputs. I
spent half of the day figuring this out and trying various options but no
luck.
This is MVC.
I have 2 Tabs.
General and Profile.
On top right of this page I have a dropdown list with list of profiles for
this user.
By default, once user's signin, they are shown the General Tab, and on
click of Profile I make a call to get the profile details like first name,
lastname, etc and display them.
While user is on the profile tab, they can select a different profile from
the dropdownlist on top.
The problem is when a profile is selected from the dropdown I make an ajax
call and then display the contents in this profile tab. Due to some reason
this content never shows up and it always displays the old profile data. I
thought it might be caching the data but the cache is set to false for
both these tabs. The profile tab doesn't refresh at all even though I when
I debug the cshtml file I see latest data coming through but it doesn't
render.
Any help would be appreciated.
Thanks.

attr_accessor breaks 2 of my methods in Rails

attr_accessor breaks 2 of my methods in Rails

I have a User model. One of its attributes is a string called :access
which can be either nil, "admin", or "active".
Now inside the User model I have the following methods:
def admin?
self.access == "admin"
end
def active?
self.access == "active"
end
They work fine. But if I add attr_accessor :access to the model something
breaks. My admin? and active? methods no longer work. When I go into rails
console and get a User out of the database I can see that user =
User.find(7) shows access is set to "admin". But if I type user.access it
returns nil. user.admin? returns false.

Javascript functions not fetching data on load

Javascript functions not fetching data on load

I'm having an issue with the code I have provided below and I'm new to
Javascript and Jquery. What the code is supposed to do is on load it
fetches a number for "unread notifications" then places that number in a
div called notes_number. Then it should read the number from notes_number
and depending on if the number is more than 0 it will show the div called
notes_signal.
I do this on load, every 5 seconds, and then whenever the notifications
button is pressed. The code isn't working because on load it doesn't put a
number in the notes_number div. Also the other occurrences aren't working.
At one point I thought it was working but now I can't figure out what's
up. Here's the code:
//THIS IS TO CHECK WHEN THE PAGE COMES UP
$("#notes_number").load("getnumber.php");
if(document.getElementById("notes_number").innerHTML > 0){
var elem = document.getElementById("notes_signal");
elem.style.display = "";
}
if(document.getElementById("notes_number").innerHTML == 0){
var elem = document.getElementById("notes_signal");
elem.style.display = "none";
}
//THIS IS TO CHECK EVERY 5 SECONDS
window.setInterval(function(){
$("#notes_number").load("getnumber.php");
if(document.getElementById("notes_number").innerHTML > 0){
var elem = document.getElementById("notes_signal");
elem.style.display = "";
}
if(document.getElementById("notes_number").innerHTML == 0){
var elem = document.getElementById("notes_signal");
elem.style.display = "none";
}
}, 5000);
//THIS IS TO CHECK WHEN THE BUTTON IS PRESSED
function toggleDiv(divId) {
$("#"+divId).show();
$(document).ready(function(){
$("#myContent").load("getnotes.php?page=<? echo $page; ?>");
});
$("#notes_number").load("getnumber.php");
if(document.getElementById("notes_number").innerHTML > 0){
var elem = document.getElementById("notes_signal");
elem.style.display = "";
}
if(document.getElementById("notes_number").innerHTML == 0){
var elem = document.getElementById("notes_signal");
elem.style.display = "none";
}
}

Don't allow spaces in TextBox asp.net

Don't allow spaces in TextBox asp.net

I am trying to avoid spaces in the Textbox and prevent the user to enter
any spaces. I tried
<ajaxToolkit:FilteredTextBoxExtender ID="Filteredtextboxextender2"
runat="server"
FilterType="Custom" InValidChars=" "
TargetControlID="tx_username">
</ajaxToolkit:FilteredTextBoxExtender>
but it didn't work. Is there any other solutions ?

Multiple Transition mixin

Multiple Transition mixin

I just want to implement a basic mixin for the transitions, this is my code:
transition()
transition arguments
-webkit-transition arguments
Until i use this mixin with a single property all is working fine, but
when i try to do something like this:
a
transition(color 1s, text-shadow 1s)
My output is:
a {
transition: color 1s text-shadow 1s;
-webkit-transition: color 1s text-shadow 1s;
}
no commas are added... any suggestions?

Unable to serialize the session state?

Unable to serialize the session state?

We have reasonably large scale application and recently experiencing
issues with random logouts. Upon investigation we've found app pool is
recycling after physical memory limit of (1GB)is reached. I m now trying
to save session state in out of process as below
<sessionState mode="StateServer"
stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false"
timeout="20"/>
After changing the session state mode to "StateServer" and running the
asp.net state service on server. I m getting the following error message
"Unable to serialize the session state. In 'StateServer' and 'SQLServer'
mode, ASP.NET will serialize the session state objects, and as a result
non-serializable objects or MarshalByRef objects are not permitted. The
same restriction applies if similar serialization is done by the custom
session state store in 'Custom' mode."
Apparently i have to mark session related objects with [Serializable]
attribute but the application is quite big. Is there a way around this
issue?
thanks

how to install html agility pack and add a reference to the dll on Windows Vista

how to install html agility pack and add a reference to the dll on Windows
Vista

I have downloaded HTML Agility pack, and after extracting I can see that
there are sub folders with name NET 20, NET 40, NET 40 Client, NET 45,
sl3-wp, sl4-windowsphone71, sl5, winrt45.
I have downloaded Microsoft Visual 2010. Sadly, I cannot proceed further(
i.e., I cannot install Html agility pack in Vista and add a reference to
the dll. I am new in the use of HTML Agility pack and I have the code
prepared by my friend to run. Will be much thankful if you could provide
some insights. Thanks

Wednesday, 18 September 2013

Splitting a string into 3 strings each with its own delimiter JAVA

Splitting a string into 3 strings each with its own delimiter JAVA

I am working on code where i need to split a string into 3 different
parts, each part would need its own delimiter to get the individual part
out. I am not good with regex and the tutorials i have looked at dont
really explain this well. So if you could push me in the right direction
and if you have an answer explain each part of it that would be great!.
My input is
1 imported bottle of perfume at 27.99
1 bottle of perfume at 18.99
1 packet of headache pills at 9.75
1 box of imported chocolates at 11.25
My desired output is to have 3 strings for each.
"1" "imported bottle of perfume" "27.99"
Code:
String pattern = "[(\\d)][(\\w)][(\\d)]";
String[] splits = data[i].split(pattern);

trying to make JS practice snippet on cloud9 [on hold]

trying to make JS practice snippet on cloud9 [on hold]

Hello now i'm on some JS class
and i made a snippet but a button is not work
plz help me and give me a tip there is something wrong or i need learn
Thank you
here is link if you have cloud9 id https://c9.io/hyunhee26/lab3
//lap3
html
<!DOCTYPE html>
<html>
<head>
<title>This is Lab3 by Hyunhee Shin</title>
<link rel='stylesheet' type='text/css' href = 'style.css'>
<script type="text/javascript" src="js.js"></script>
<script
src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<div id="mainContent">
<h1>Be a quiz <br> king!</h1>
<p>Enjoy your five <br> quizzes. </p>
<button id="clickButton" class="buttonStyle">click me</button><br>
</div>
</body>
</html>
//js.js
var question= ['When is the first day of spring? (MM/DD)',
'Who is the president in the U.S.A now? (last name)',
'What is the shortest month?',
'What is the largest city in Texas?',
'How many colors does a rainbow has?'];
var answer= ['03/21', 'Obama', 'February', 'Houston', '7'];
function quizStart() {
for (var i = 0 ; i < 5 ; i++) {
document.write(question[i] + '<br>');
var userChoice = prompt(question[i]);
if (userChoice === answer[i]){
document.write(userChoice + '<br>' + 'Good job!' + '<br><br>');
} else {
document.write(userChoice + '<br>' + 'Sorry! That is not a
correct answer.' + '<br><br>');
}
}
}
function yeah(){
document.getElementById("clickButton").onClick = "quizStart()";
}
//style.css
body{
background-color: yellowgreen;
}
#mainContent {
font-family: Arial, Helvetica, sans-serif;
font-size: xx-large;
font-weight: bold;
background-color: yellowgreen;
border-radius: 4px;
padding: 10px;
text-align: center;
}
.buttonStyle {
border-radius: 4px;
border: thin solid #F0E020;
padding: 5px;
background-color: #F8F094;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
font-weight: bold;
color: #663300;
width: 75px;
}
.buttonStyle:hover {
border: thin solid #FFCC00;
background-color: #FCF9D6;
color: #996633;
cursor: pointer;
}
.buttonStyle:active {
border: thin solid #99CC00;
background-color: #F5FFD2;
color: #669900;
cursor: pointer;
}

How tranferir cookie TWebBrowser to Indy in Delphi-xe4 mobile (ios)?

How tranferir cookie TWebBrowser to Indy in Delphi-xe4 mobile (ios)?

I'm trying to create a system that uses "Facebook Login" to authenticate.
For this I am using TWebBrowser to login and TidHttp to "POST" and "GET".
But how do I transfer cookie TWebBrowser to Indy? thank you very much

Rails 3 route helpers in model not respecting sub-URI

Rails 3 route helpers in model not respecting sub-URI

Using Rails 3.2.13.
I've got Nginx and Unicorn setup to serve a Rails application from a
sub-URI. I have some views where I need to send links to resources, so I'm
using a path helper from with a model:
def to_exhibit()
return {
:label => self.id,
:name => self.name,
:edit_path =>
Rails.application.routes.url_helpers.edit_vehicle_path(self),
}
end
This will produce a URL like http://localhost:8080/vehicles/10/edit, but
what I really want is http://localhost:8080/app/vehicles/10/edit (where
/app is my sub-URI). This works fine when calling edit_vehicle_path
directly from a view. I hacked around this problem previously by creating
my own helper:
module ApplicationHelper
def self.sub_uri_path(path)
root = Rails.application.config.relative_url_root
return '%s%s' % [ root, path ]
end
end
config.relative_url_root is defined in my config/environment files. This
works, but there has to be a proper way to do it, plus I don't want to
have to maintain this when I inevitably forget about it a year from now.

What is moduleclass_sfx about?

What is moduleclass_sfx about?

I saw this $params->get('moduleclass_sfx') in one of the custom modules
and found it is also part of the core code as well. Wondering what this is
about? Could not find any links to any Joomla documentation on the google
search hence not sure what exactly this is about?

MVC: should view talk with model directly?

MVC: should view talk with model directly?

earlier, many developer hold the opinion that view should not communicate
with model directly, like most framework do.
and then, this opinion seems to be wrong, I find some articles, these
articles say that view can communicate with model directly.
http://r.je/views-are-not-templates.html
http://www.tonymarston.net/php-mysql/model-view-controller.html
Model, View, Controller confusion
and
How should a model be structured in MVC?
most of these articles quotes a block from wikipedia,
Model–view–controller, the quotes is:
A view queries the model in order to generate an appropriate user
interface (for example the view lists the shopping cart's contents). The
view gets its own data from the model. In some implementations, the
controller may issue a general instruction to the view to render itself.
In others, the view is automatically notified by the model of changes in
state (Observer) that require a screen update.
ah, it's from wikipedia, such a authoritative site, it must be right!
but now, when I open the wiki link of MVC
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller, the
page has be edited on September 14 this year(the year 2013), and the
sentence above has gone.
the new definition for view is:
A view requests from the model through the controller the information that
it needs to generate an output representation to the user.
now I'm confused again, the new definition says the view should request
data from the model through the controller...
should the view access model directly on earth?

how to assign a value of space in c++

how to assign a value of space in c++

In c++, ascii characters has a default value. Like ! has a value of 33,
"," has also a value of 44 and so on.
inside my text file "hehe.txt" is. ;!,.
#include <iostream>
#include <fstream>
int main(){
std::ifstream file("hehe.txt");
if(file.eof())return 0;
char ascii;
while (file>>ascii) {
std::cout<<(int)ascii << " ";
}
system("pause"
}
Output is 59 33 44 46.
What if i have space between the characters? How may I give it a value?
Lets say the space has a value of 32. Suppose I added space after the last
character ;!,. the output must be 59 33 44 46. Hope someone could give me
an idea how to do it.

Selecting of specific distinct rows based on the column that used GROUP BY in mysql

Selecting of specific distinct rows based on the column that used GROUP BY
in mysql

This are the records of my table:
item_code | qty
001 1
001 1
002 2
002 2
003 2
004 1
005 1
This is my code for SELECTING distinct item_code and total count of qty
based on GROUP BY qty:
select distinct(item_code), count(qty) as qty from imp_inv group by item_code
and this is the result:
item_code | qty
001 2
002 4
003 2
004 1
005 1
What I am struggling for is that how can I select an item_code with a
where clause of qty, this is what I tried:
select distinct(item_code), count(qty) as qty from imp_inv where qty = 2
group by item_code
and this is the result:
item_code | qty
002 2
002 2
003 2
The code above is only selecting the item_code that has the qty of 2, What
I want is to select an item_code based on its total count of the qty, This
is the result of what I want to have:
item_code | qty
001 2
003 2
Hope you all understand my question, Thank you for your help.

Tuesday, 17 September 2013

Rename image name to datetime stamp

Rename image name to datetime stamp

How do i change the codes so that the image's name will be save as date
time stamp?
Button buttonTakePicture;
final int RESULT_SAVEIMAGE = 0;
/** Called when the activity is first created. */ @Override public void
onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.camera_layout);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
getWindow().setFormat(PixelFormat.UNKNOWN); surfaceView =
(SurfaceView) findViewById(R.id.camerapreview); surfaceHolder =
surfaceView.getHolder(); surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
controlInflater = LayoutInflater.from(getBaseContext()); View
viewControl = controlInflater.inflate(R.layout.camera_control, null);
LayoutParams layoutParamsControl = new LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
this.addContentView(viewControl, layoutParamsControl);
buttonTakePicture = (Button) findViewById(R.id.takepicture);
buttonTakePicture.setOnClickListener(new Button.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
camera.takePicture(myShutterCallback, myPictureCallback_RAW,
myPictureCallback_JPG); } });
LinearLayout layoutBackground = (LinearLayout)
findViewById(R.id.background); layoutBackground.setOnClickListener(new
LinearLayout.OnClickListener() { public void onClick(View arg0) { // TODO
Auto-generated method stub buttonTakePicture.setEnabled(false);
camera.autoFocus(myAutoFocusCallback); } }); }
AutoFocusCallback myAutoFocusCallback = new AutoFocusCallback() { public
void onAutoFocus(boolean arg0, Camera arg1) { // TODO Auto-generated
method stub buttonTakePicture.setEnabled(true); } };
ShutterCallback myShutterCallback = new ShutterCallback() { public void
onShutter() { // TODO Auto-generated method stub
} };
PictureCallback myPictureCallback_RAW = new PictureCallback() { public
void onPictureTaken(byte[] arg0, Camera arg1) { // TODO Auto-generated
method stub
} };
PictureCallback myPictureCallback_JPG = new PictureCallback() { public
void onPictureTaken(byte[] arg0, Camera arg1) { // TODO Auto-generated
method stub /* * Bitmap bitmapPicture =
BitmapFactory.decodeByteArray(arg0, 0, * arg0.length); */
Uri uriTarget = getContentResolver().insert(
Media.EXTERNAL_CONTENT_URI, new ContentValues());
OutputStream imageFileOS; try {
imageFileOS = getContentResolver().openOutputStream(uriTarget);
imageFileOS.write(arg0);
imageFileOS.flush();
imageFileOS.close();
Toast.makeText(CameraActivity.this,"Image saved: " +
uriTarget.toString(),Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace(); } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); }
camera.startPreview(); } };
public void surfaceChanged(SurfaceHolder holder, int format, int width,int
height) { // TODO Auto-generated method stub if (previewing) {
camera.stopPreview(); previewing = false; }
if (camera != null) { try {
camera.setPreviewDisplay(surfaceHolder);
camera.startPreview();
previewing = true; } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); } } }
public void surfaceCreated(SurfaceHolder holder) { // TODO Auto-generated
method stub camera = Camera.open(); }
public void surfaceDestroyed(SurfaceHolder holder) { // TODO
Auto-generated method stub camera.stopPreview(); camera.release(); camera
= null; previewing = false; } }

Knockout Mapping reading JSON

Knockout Mapping reading JSON

Just starting with KnockOut Mapping to read some JSON (using Google Books
API) , but can't seem to get it to work. No errors report, but nothing is
displayed. Probably a simple issue I overlooked, but thanks for the
review.
Markup....
<body>
<h2>Find Cat in the Hat</h2>
<div>
<input id="booksearch" />
</div>
<div>
<table>
<thead>
<tr>
<th>Volumes</th>
</tr>
</thead>
<tbody data-bind="foreach: model.items">
<tr>
<td data-bind="text: model.id"></td>
</tr>
</tbody>
</table>
</div>
<input id="btnTest" type="button" value="button" />
</body>
<script src="/Scripts/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="/Scripts/knockout-2.2.0.js"></script>
<script src="/Scripts/knockout.mapping-latest.js"></script>
Jquery....
$(document).ready(function () {
//Knockout Test
$('#btnTest').click(function () {
var url =
"https://www.googleapis.com/books/v1/volumes?q=the+Cat+In+The+Hat";
var viewModel = {};
$.getJSON(url, function (data) {
viewModel.model = ko.mapping.fromJSON(data);
ko.applyBindings(viewModel);
});
});
});

Calculating distance between two points represented by lat,long upto 15 feet accuracy

Calculating distance between two points represented by lat,long upto 15
feet accuracy

I have converted the formula into Java provided here. But accuracy is a
problem. We are using GPS coordinates.
We are using iPhone provided GPS location that is upto 10 decimal point
accuracy.
/*
* Latitude and Longitude are in Degree
* Unit Of Measure : 1 = Feet,2 = Kilometer,3 = Miles
*/
//TODO 3 Change Unit of Measure and DISTANCE_IN_FEET constants to Enum
public static Double calculateDistance(double latitudeA,double
longitudeA,double latitudeB,double longitudeB,short unitOfMeasure){
Double distance;
distance = DISTANCE_IN_FEET *
Math.acos(
Math.cos(Math.toRadians(latitudeA)) *
Math.cos(Math.toRadians(latitudeB))
*
Math.cos(Math.toRadians(longitudeB) -
Math.toRadians(longitudeA))
+
Math.sin(Math.toRadians(latitudeA))
*
Math.sin(Math.toRadians(latitudeB))
);
return distance;
}
And then I use Math.round(distance); to convert to long.

Searching a directory for folders and files using python

Searching a directory for folders and files using python

I have a directory structure like the one given below.
MainFolder
|
[lib]
/ | \
[A] [B] [C] -- file1.so
| | file2.so
file1.so file1.so
file2.so file2.so
I'm trying to look for the 'lib' folder in that structure which might not
be there at times. So I'm using the following to check for the presence of
the 'lib' folder:
if os.path.isdir(apkLocation + apkFolder + '/lib/'):
If lib folder exists, then I carry on to search the folders inside 'lib'.
I have to store the names of the folder A,B and C and look for the files
ending with '.so' whose path should be stored as
/lib/A/file1.so,/lib/A/file2.so and so on.
if os.path.isdir(apkLocation + apkFolder + '/lib/'):
for root, dirs, files in os.walk(apkLocation + apkFolder):
for name in files:
if name.endswith(("lib", ".so")):
print os.path.abspath(name)
This gives me an out
file1.so
file2.so
file1.so
file2.so
file1.so
file2.so
Desired output:
/lib/A/file1.so
/lib/A/file2.so
/lib/B/file1.so
/lib/B/file2.so
/lib/C/file1.so
/lib/C/file2.so
and also the folders A,B and C are to be saved separately.

JS XRegExp Replace all non characters

JS XRegExp Replace all non characters

My objective is to replace all non letters/numbers in a string. All
occurences of - should not be replaced also. I have used for this the
XRegExp plugin but it seems I cannot find the magic solution :) I have
tryed like this :
var txt = "Ad ÑÒÈÍÃ (ALI) - Englishmen In New York";
var regex = new XRegExp('\\p{^N}\\p{^L}',"g");
var b = XRegExp.replace(txt, regex, "")
but the result is : AÑÒÈÍ(AL EnglishmeINeYork ... which is kind of weird
If I try to add also the condition for not removing the '-' character
leads to make the RegEx invalid.

How to create a Singleton

How to create a Singleton

Today in my interview one interviewer asked me to write a Singleton class.
And i gave my answer as
public class Singleton {
private static Singleton ref;
private Singleton() {
}
public static Singleton getInstance() {
if (ref == null) {
ref = new Singleton();
}
return ref;
}
}
suddenly he told me this is old way of writing the class. Can any one
please help me why he told like that. i will be very obliged.

Sunday, 15 September 2013

Not able to install pThread on Windows Xampp

Not able to install pThread on Windows Xampp

I am trying to install pThread on Xampp (Windows 7) as follows:
My PHP version information: 5.4.7 VC9 x86

I have downloaded php_pthreads-0.0.45-5.4-ts-vc9-x86.zip
Then I added pthreadVC2.dll to C:\xampp\php and php_pthreads.dll to
C:\xampp\php\ext
In php.ini, I have added extension=php_pthreads.dll
Restarted Apache server and received following error:


Any suggestions on why this is not working?

Find out UITableViewCellStyle from initWithCoder: or elsewhere

Find out UITableViewCellStyle from initWithCoder: or elsewhere

I'm trying to create a generic UITableViewCell subclass, which has a
slightly different fonts for the titleLabel and detailLabel depending on
the style of the cell being used.
Prior to using storyboard prototypes, this was alright, as I was using
initWithStyle:identifier: however I've now updated the app to use the
storyboard prototypes, which of course uses initWithCoder:
Is there a way I can find out the style of the cell that interface builder
has set or can't this be done? I know I can override the text styles in IB
itself, but I'd like to make it a bit more generic so I don't have to do
that for every view

Saving objects with Java

Saving objects with Java

I have a question about the following code. I create three instances of my
Player class, and then I save them to a file.
Player a = new Player(1, "asd");
Player b = new Player(2, "asd");
Player c = new Player(3, "asd");
try {
FileOutputStream fos = new FileOutputStream("Game.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(a);
oos.writeObject(b);
oos.writeObject(c);
oos.close();
} catch (IOException e) {
e.printStackTrace();
}
What happens with Game.ser? Is this a file that's actually created, or is
it just within the program? If not, where is it located? I don't find it
in any project folder.
The program works fine. Im just wondering about where the objects are saved.

ArrayList constructor and use in methods

ArrayList constructor and use in methods

Hi I am a novice n just learning java. I was studying ArrayList n came
accross this code for example {CODE1}. I would like to use the same code
but add a ArrayListDemo constructor n create methods such as displayList
and removeElement. I tried to find such examples but i did not understand
them.
This is the code that i tried {CODE2} With my modifications please tell me
where m going wrong.
***CODE1 {Example Code}****
import java.util.ArrayList;
public class AraryListDemo {
public static void main(String[] args) {
ArrayList al = new ArrayList();
System.out.print("Initial size of al : " + al.size());
System.out.print("\n");
//add.elements to the array list
al.add("C");
al.add("A");
al.add("E");
al.add("B");
al.add("D");
al.add("F");
al.add(1,"A2");//inserts objects "A2" into array at index 1
System.out.print("size of al after additions " + al.size());
System.out.print("\n");
//display the array list
System.out.print("contents of al: " + al );
System.out.print("\n");
//Remove elements from the array list
al.remove("F");
al.remove(2);
System.out.print("size of after deletions : " + al.size());
System.out.print("\n");
System.out.print("contents of al:" + al);
}
}
********CODE 2 {My Modifications}*************
class ArrayListDemo
{
ArrayList<String> al;//variable declared
ArrayListDemo() throws IOException//try constructor for this
{
al = new ArrayList<String>();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("\n Enter Student Names");
for(int i=0;i<=5;i++)// will dispaly
{
al.add(br.readLine());
}
}
void dispList(ArrayList <String> al)
{
System.out.println("\n Display Student Names");
for(String str : al)
{
System.out.println("\t Name : "+str+"\n");
}
}
}
class DisplayArrayList
{
public static void main(String []args) throws IOException
{
ArrayList <String> al = new ArrayList <String>();
ArrayListDemo e = new ArrayListDemo();
e.dispList(al);
}
}

How to get testcase status in @Aftertest in testng

How to get testcase status in @Aftertest in testng

How i can get test case status in @AfterTest annotation of TestNg. I need
to take some actions if test cases pass or fail in @AfterTest.
@AfterTest(alwaysRun=true)
public void teardown(ITestContext test) throws Exception {
String testcase = test.getCurrentXmlTest().getParameter("id");
}

How do i test content-scripts in chrome extensions automatically?

How do i test content-scripts in chrome extensions automatically?

I programmed a chrome extension which parses various site informations
through content scripts. Now every other month one of the websites i
support change their html layout, move to another address etc. And so i
have to update my extension.
With 14 supported website (growing) with 5-7 properties each its just too
much to do by hand. Is there a way to automatically run my js functions in
the context of the websites and check the result?
I tryed it with iframes, but that didnt work cause of the same origin policy.

Trouble understanding how to pick constants to prove big theta

Trouble understanding how to pick constants to prove big theta

So I'm reading Introductions to Algorithms and sometimes I wish it would
be a little bit more friendly with how it explains topics. One of these
topics is proving big-theta.
I understand that the definition of BigTheta is as follows:
BigTheta(g(n) = f(n) if there exists positive constants c1, c2, and n0
such that 0 <= c1g(n) <= f(n) <= c2g(n) for all n>= n0.
In other words, for f(n) and g(n), f(n) can be bounded by c2g(n) from
above and bounded below by c1g(n).
So the example in the book goes:
Show that 1/2(n^2) - 3n = BigTheta(n^2)
From the definition of big theta:
c1n^2 <= 1/2(n^2)-3n <= c2n^2
CLRS begins by dividing by the largest order term of n which is n^2 to get
c1 <= 1/2 - 3/n <= c2
From here we split the problem into two parts, the right-hand inequality
and the left-hand inequality.
On the right hand side: CLRS chooses c2 >= 1/2 because for n>1, (1/2 -
3/n) can never be less than 1/2 since 3/n goes to 0 as n goes to infinity.
Now this is where I start to get lost.
On the left hand side: CLRS chooses c1 = 1/14. (Not sure why) and n>=7.
I'm not sure what the significance of these choices is. At n=<6, (1/2-3/n)
becomes negative. But why 1/14 for c2? I'm just not sure how they arrived
at solving the left hand side and the book doesn't really explain it well
for me.

Saturday, 14 September 2013

Incompatible types in argument

Incompatible types in argument

When I compile my code with The Checker Framwork it complains:
incompatible types in argument.
found : null
required: @NonNull String
for the first argument of:
ResultSet rs = connection.getMetaData().getColumns(null, schemaName,
tableName, null)
I know that DatabaseMetadata.getColumns() allows a null catalog (the first
argument). How do I tell the Checker Framework as much?

PHP 5.3.24 hashing options

PHP 5.3.24 hashing options

I am working on a website for a friend who is using Godaddy for their web
hosting. Currently Godaddy's most recent PHP version offered is 5.3.24. I
would really like to use bcrypt to hash user passwords for this site, but
my understanding from doing some research is that you need to have at
least PHP version 5.3.7 to use bcrypt. Can anyone suggest my best/most
secure options for hashing password using PHP 5.3.24? Thanks :) I

c++ 2 dimensional array

c++ 2 dimensional array

int main ()
{
int line,column,i,j;
int sortir = 1;
float nbr;
cout << "The number of column :";
cin >> column;
cout << "The number of lines: ";
cin >> line;
float matrice [column][line]; //creating my 2d array
for(i=0;i <= line;i++) //asking the user to put the numbers he wants in
the 2d array
for(j=0;j <= column;j++){
cout << "Enter a number";
cin >> nbr;
matrice[j][i] = nbr;
}
system("PAUSE");
return 0;
}
lets say i do an array of line = 1 and column = 1 which makes (memory
zones) [0,0] [0,1] [1,0] [1,1].Lets say the user inputs these following
numbers :
[0,0]=1
[0,1]=2
[1,0]=3
[1,1]=4
when i want to show the user what he inputed at the end of the programe :
the zone [0][1] and [1][0] show the same number?
cout << matrice[0][0] = 1
cout << matrice[0][1] = 3 <-- why the f***
cout << matrice[1][0] = 3 <--His my for loop good?
cout << matrice[1][1] = 4

Using Selenium Webdriver how to connect remote database and run test cases from local machine through eclipse

Using Selenium Webdriver how to connect remote database and run test cases
from local machine through eclipse

I am using selenium web driver java built , editor is eclipse. For testing
one of our website I am using Data driven testing by fetching data from
MySQL database.
I dumped the development server database to my local machine and installed
that dumped data in my machine xampp and able to connect to database and
proceed through the testing process.
To connect to my local machine database i am using this connection string
String url1 ="jdbc:mysql://localhost:3306/databasename";
String dbClass = "com.mysql.jdbc.Driver";
Class.forName(dbClass).newInstance();
Connection con = DriverManager.getConnection(url1, "root", "");
Statement stmt = (Statement) con.createStatement();
Now I need to connect to connect to our original development server
database which is in remote server.
Can any one suggest me how to connect to the remote server database and
what changes are needed to be done in the connection string ? what to put
in the host name ? and how I can run my test cases from my local machine
while connecting to remote server database.
Please provide some suggestion

can not the mysqli error

can not the mysqli error

I create a form that insert fist name last name and phone but i have this
error and can't figure out where it is can't execute query.You have an
error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '' at line 1
here is my php code 1st file named displayPhone.php
<!DOCTYPE html>
<html>
<?php
$labels=array("first_name"=>"First Name",
"last_name"=>"Last Name",
"phone"=>"Phone");
?>
<body>
<h3>please enter your phone number below</h3>
<form action='savePhone.php' method='POST'>
<?php
//loop that displays the form field
foreach($labels as $field =>$value)
{
echo "$field <input type='text' name='$field' size='65'
maxlenghth='65'/>";
}
echo "<input type='submit' value='submit phone number'/>";
?>
second file named savePhone.php
<?php
$labels=array("first_name"=>"First Name",
"last_name"=>"Last Name",
"phone"=>"Phone");
?>
<body>
<?php
foreach($_POST as $field =>$value)
{
if(empty($value))
{
$blank_array[]=$field;
}
elseif(preg_match("/name/i",$field))
{
if(!preg_match("/^[A-Za-z' -]{1,50}$/",$value))
{
$bad_format[]=$field;
}
}
elseif($field=="phone")
{
if(!preg_match("/^[0-9)( -]{7,20}(([xX]|(ext)|(ex))?[
-]?[0-9]{1,7})?$/",$value))
{
$bad_format[]=$field;
}
}
}
if(@sizeof($blank_array)>0 or @sizeof($bad_format)>0)
{
if(@sizeof($blank_array)>0)
{
echo "<p>input";
foreach($blank_array as $value)
{
echo "$labels[$value]";
}
echo "</p>";
}
if(@sizeof($bad_format)>0)
{
echo "<p>invalid format";
foreach($bad_format as $value)
{
echo $labels[$value];
}
echo "</p>";
}
//redisplay form
echo "<hr/>";
echo "enter phone number";
echo "<form action='$_SERVER[PHP_SELF]' method='POST'>";
foreach($labels as $field =>$label)
{
$good_data[$field]=strip_tags(trim($_POST[$field]));
echo "$label <input type='text' name='$field' size='65'
maxlength='65' value='$good_data[$field]'/>";
}
echo "<input type='submit' value='submit phone number'/>";
exit();
}
else
{
$user='root';
$host='localhost';
$password='root';
$dbname='pet';
$cxn=mysqli_connect($host,$user,$password,$dbname) or die("can't
connect to server");
foreach($labels as $field =>$value)
{
$good_data[$field]=strip_tags(trim($_POST[$field]));
if($field=="phone")
{
$good_data[$field]=preg_replace("/[)(
.-]/","",$good_data[$field]);
}
$good_data[$field]=mysqli_real_escape_string($cxn,$good_data[$field]);
}
$query="INSERT INTO data (";
foreach($good_data as $field =>$value)
{
$query.="$field,";
}
$query.= ") VALUES (";
$query=preg_replace("/,\)/",")",$query);
$result=mysqli_query($cxn,$query) or die ("can't execute
query.".mysqli_error($cxn));
echo "<h4>member inserted </h4>";
}
?>
</body>
my database name 'pet' table name 'data'. the table contains 3 part
first_name, last_name, and phone all are varchar type

C# Text to HTML

C# Text to HTML

What I'am doing is Loading some Strings From database , I'am doing that
fine . I read it and Convert it to HTML ... kinda .. using this code :
private string StripHTML(string source)
{
try
{
string result;
// Remove HTML Development formatting
// Replace line breaks with space
// because browsers inserts space
result = source.Replace("\r", " ");
// Replace line breaks with space
// because browsers inserts space
result = result.Replace("\n", " ");
// Remove step-formatting
result = result.Replace("\t", string.Empty);
// Remove repeating spaces because browsers ignore them
result = System.Text.RegularExpressions.Regex.Replace(result,
@"( )+",
" ");
// Remove the header (prepare first by clearing attributes)
result = System.Text.RegularExpressions.Regex.Replace(result,
@"<( )*head([^>])*>", "<head>",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"(<( )*(/)( )*head( )*>)", "</head>",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
"(<head>).*(</head>)", string.Empty,
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// remove all scripts (prepare first by clearing attributes)
result = System.Text.RegularExpressions.Regex.Replace(result,
@"<( )*script([^>])*>", "<script>",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"(<( )*(/)( )*script( )*>)", "</script>",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
//result = System.Text.RegularExpressions.Regex.Replace(result,
// @"(<script>)([^(<script>\.</script>)])*(</script>)",
// string.Empty,
//
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"(<script>).*(</script>)", string.Empty,
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// remove all styles (prepare first by clearing attributes)
result = System.Text.RegularExpressions.Regex.Replace(result,
@"<( )*style([^>])*>", "<style>",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"(<( )*(/)( )*style( )*>)", "</style>",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
"(<style>).*(</style>)", string.Empty,
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// insert tabs in spaces of <td> tags
result = System.Text.RegularExpressions.Regex.Replace(result,
@"<( )*td([^>])*>", "\t",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// insert line breaks in places of <BR> and <LI> tags
result = System.Text.RegularExpressions.Regex.Replace(result,
@"<( )*br( )*>", "\r",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"<( )*li( )*>", "\r",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// insert line paragraphs (double line breaks) in place
// if <P>, <DIV> and <TR> tags
result = System.Text.RegularExpressions.Regex.Replace(result,
@"<( )*div([^>])*>", "\r\r",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"<( )*tr([^>])*>", "\r\r",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"<( )*p([^>])*>", "\r\r",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// Remove remaining tags like <a>, links, images,
// comments etc - anything that's enclosed inside < >
result = System.Text.RegularExpressions.Regex.Replace(result,
@"<[^>]*>", string.Empty,
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// replace special characters:
result = System.Text.RegularExpressions.Regex.Replace(result,
@" ", " ",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"&bull;", " * ",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"&lsaquo;", "<",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"&rsaquo;", ">",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"&trade;", "(tm)",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"&frasl;", "/",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"&lt;", "<",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"&gt;", ">",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"&copy;", "(c)",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
@"&reg;", "(r)",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// Remove all others. More can be added, see
//
http://hotwired.lycos.com/webmonkey/reference/special_characters/
result = System.Text.RegularExpressions.Regex.Replace(result,
@"&(.{2,6});", string.Empty,
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// for testing
//System.Text.RegularExpressions.Regex.Replace(result,
// this.txtRegex.Text,string.Empty,
// System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// make line breaking consistent
result = result.Replace("\n", "\r");
// Remove extra line breaks and tabs:
// replace over 2 breaks with 2 and over 4 tabs with 4.
// Prepare first to remove any whitespaces in between
// the escaped characters and remove redundant tabs in between
line breaks
result = System.Text.RegularExpressions.Regex.Replace(result,
"(\r)( )+(\r)", "\r\r",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
"(\t)( )+(\t)", "\t\t",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
"(\t)( )+(\r)", "\t\r",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
result = System.Text.RegularExpressions.Regex.Replace(result,
"(\r)( )+(\t)", "\r\t",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// Remove redundant tabs
result = System.Text.RegularExpressions.Regex.Replace(result,
"(\r)(\t)+(\r)", "\r\r",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// Remove multiple tabs following a line break with just one tab
result = System.Text.RegularExpressions.Regex.Replace(result,
"(\r)(\t)+", "\r\t",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// Initial replacement target string for line breaks
string breaks = "\r\r\r";
// Initial replacement target string for tabs
string tabs = "\t\t\t\t\t";
for (int index = 0; index < result.Length; index++)
{
result = result.Replace(breaks, "\r\r");
result = result.Replace(tabs, "\t\t\t\t");
breaks = breaks + "\r";
tabs = tabs + "\t";
}
// That's it.
return result;
}
catch
{
MessageBox.Show("Error");
return source;
}
}
the problem is , that some Strings contains HTML colors for example :
<#D80000>StackOverFlow is a nice forum
What I want to do is to convert that HTML color to Color for the Text that
Come after the HTML color , means "StackOverFlow is a nice forum Become
with Red or what ever the Color is (color always X)
PS : It's on a tooltip ... what I 'am doing after Loading from Database :
string XZ = StripHTML(XZSecond);
Invoke(new MethodInvoker(delegate { tp.SetToolTip(OMG[i], Name + "\r" +
XZ.Replace("Text", "").Replace("Text", "")); }));
Thank you in advance , I hope I'll found some help .

Client/Server WCF Chat

Client/Server WCF Chat

I'm Hosting WCF Service on the localhost and the client is running in the
same host, it works well when running both on the same machine but when I
install the client in another machine and trying to connect to the server
it fails ... here is the configuration file for the server:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="wsDualBinding">
<security mode="None" />
</binding>
</wsDualHttpBinding>
</bindings>
<diagnostics>
<messageLogging logEntireMessage="true" />
</diagnostics>
<behaviors>
<serviceBehaviors>
<behavior name="Metadata">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="Metadata"
name="ChatService.ChatManager">`
<endpoint address="duplex"
binding="wsDualHttpBinding"
bindingConfiguration="wsDualBinding"
contract="ChatService.IChat" />`
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />`
<host>
<baseAddresses>
<add baseAddress="http://localhost:2525/chat/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>

Friday, 13 September 2013

how to stop quartz warn loggers

how to stop quartz warn loggers

Console is getting filled with Quartz WARN loggers all the time and it's
really annoying to developers who work in the project to find other logger
messages in console.
[2013-09-14 11:18:35,142] WARN
{org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class
lk.gov.elg.admin.action.detain.DetainJob for property 'system-id'
[2013-09-14 11:18:35,142] WARN
{org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class
lk.gov.elg.admin.action.detain.DetainJob for property 'end-at'
[2013-09-14 11:18:35,143] WARN
{org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class
lk.gov.elg.admin.action.detain.DetainJob for property 'cron-expression'
[2013-09-14 11:18:35,144] WARN
{org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class
lk.gov.elg.admin.action.detain.DetainJob for property 'start-at'
[2013-09-14 11:18:35,144] WARN
{org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class
lk.gov.elg.admin.action.detain.DetainJob for property 'scheduled-job-id'
[2013-09-14 11:18:35,144] WARN
{org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class
lk.gov.elg.admin.action.detain.DetainJob for property 'size'
[2013-09-14 11:18:40,086] WARN
{org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class
lk.gov.elg.admin.action.detain.DetainJob for property 'GNS'
[2013-09-14 11:18:40,087] WARN
{org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class
lk.gov.elg.admin.action.detain.DetainJob for property 'limit'
[2013-09-14 11:18:40,087] WARN
{org.quartz.simpl.PropertySettingJobFactory} - No setter on Job class
lk.gov.elg.admin.action.detain.DetainJob for property 'tenantId'
I Google and find a way to do but it didn't give the solution.
<logger name="org.quartz">
<level value="info" />
</logger>
We are using log4j.xml instead of log4j.properties.
Here is the snapshot of log4j.xml file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true"
xmlns:log4j="http://jakarta.apache.org/log4j/">
<!--
Read
http://logging.apache.org/log4j/docs/api/org/apache/log4j/DailyRollingFileAppender.html
for more information on DaliyRollingFileAppender configuration
options.
-->
<appender name="error" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="/elg/logs/scandium-error.log"/>
<param name="Threshold" value="error"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p - [%t]
[%x] %m%n"/>
</layout>
</appender>
<appender name="debug" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="/elg/logs/scandium-debug.log"/>
<param name="Threshold" value="trace"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p [%t] -
%c{1} [%x] - %m%n"/>
</layout>
</appender>
<appender name="info" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="/elg/logs/scandium-info.log"/>
<param name="Threshold" value="info"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p %c{1} -
[%t] [%x] %m%n"/>
</layout>
</appender>
<appender name="trace" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="/elg/logs/scandium-trace.log"/>
<param name="Threshold" value="info"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p %c{1} -
[%t] [%x] %m%n"/>
</layout>
</appender>
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="info"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %c{1} - [%t]
[%x] %m%n"/>
</layout>
</appender>
<category name="com.opensymphony.xwork2.ognl.OgnlValueStack">
<priority value="error"/>
<appender-ref ref="error"/>
<appender-ref ref="console"/>
</category>
<root>
<priority value="trace"/>
<appender-ref ref="info"/>
<appender-ref ref="trace"/>
<appender-ref ref="debug"/>
<appender-ref ref="error"/>
<appender-ref ref="console"/>
</root>
<logger name="org.quartz">
<level value="info" />
</logger>
</log4j:configuration>
Please help to sort out the issue. Thanks in advance.