Saturday, 31 August 2013

This is 2013. C++11 and C++14 is on us. But why still no dedicated IDE for C++?

This is 2013. C++11 and C++14 is on us. But why still no dedicated IDE for
C++?

I'm 26 years old. C++ is nearly 35 years old.
I'm really baffled at seeing the evolution of C++ in my 15 years of
programming. I started with Turbo C blue screen in late 90's to vim in
early 2000's. From there, I have moved on to Java, Python and Ruby. All
beautiful languages having extensive set of IDE's which makes programming
in these languages easy and fun.
But As for C++. With it's latest iteration in C++11 and coming iteration
C++14, There's still no full fledged, dedicated Editor which full support
for latest standard and documentation of libraries and intellisense. This
is really ironic, since today, almost every language have extensive
toolsets.
C++ is not as easy to learn. An IDE will surely go a long way getting new
programmers on-boarding process easy to a great extent.
If anyone knows any reason behind it, please edify us.

Convert long NSString to NSNumber

Convert long NSString to NSNumber

I am unable to reliably convert longer NSString to NSNumber. Specifically,
I am converting MPMediaEntityPropertyPersistentID as a string to a
NSNumber Sometimes it works, usually it doesn't.
Conversion code:
NSString *keke = [jsonArray objectForKey:@"next"];
NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber *persistentIDasNumber = [f numberFromString:keke];
Here is an example of a successful string to number conversion:
String: 3813955856659208324
Number: 3813955856659208324
And here is an unsuccessful conversion:
String: 12790162104953153719
Number:1.279016210495315e+19
It's close but what is happening at the end? Is it too large?

How to learn Perl language

How to learn Perl language

what learning resources can u suggest?
do u know any place i can find perl exercises, wich can help to get educated.
with reading material let say on the perl.org. how can i experience,
practice, learn?
so far I've read perl.org registered on linda.com and currently watching
tutorials.
See, the problem is, i donrt have this connection between watching the
lesson, and applying in to the task. when they talk on the video, its
simple, - when trying do to slightly different thing, its totally
different code.
anyway im looking for some exercises may be. anything you can suggest. so
far i have this but not quite utisfied with it

MFC Debug Assertion Failed

MFC Debug Assertion Failed

I have a "Debug Assertion Faled" error. Is there some suggestions for
solving this problem? I tried hotfix and I updated VS 2008 to Service Pack
1 but it didn't helped.I installed VS 2012 too, and I switched proprties
tu "Use Multi-Byte Character Set". Thanks in advance.

Finding repetitive substrings

Finding repetitive substrings

Having some arbitrary string such as
hello hello hello I am I am I am your string string string string of strings
Can I somehow find repetitive sub-strings? In this case it would be
'hello', 'I am' and 'string'.
I have been wondering about this for some time but I still can not find
any real solution. I also have read some articles concerning this topic
and hit up on suffix trees but can this help me even though I need to find
every repetition e.g. with repetition count higher than two?

Should Solr be used as read-only database?

Should Solr be used as read-only database?

I am going to build a website. It's kind of a magazine that allows users
all over the globe to access. The data might grow extremely large. I am
using mySQL database as core database to perform read/write operations
such as add new users, add new article, and so on. Since the data in the
core database might be extremely large, I'm thinking using Apache Solr as
a read-only database (I'm using Solr as a search engine anyway) to read
data each time a user view an article, user profile, and so on.
Is that a good approach in pratice? what are pros and cons?

facebook comments in django: url unreachable warning

facebook comments in django: url unreachable warning

So, I have this small django blog (django newbie here) I have made (as per
thr tutorials of django) and I then decided to add facebook comments to
this. So, I went to the plugin page of facebook and did a "get code". Now,
my page looks like so:
<body>
{% block facebookcomments %}
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src =
"//connect.facebook.net/en_GB/all.js#xfbml=1&appId=375557716230123";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
{% endblock facebookcomments %}
and then, in the places where I need the comments to show up, I first
declare the meta content required by facebook like so:
{% block metacontent %}
{{ block.super }}
<meta property="og:site_name" content="first django blog" >
<meta property="og:type" content="website" >
<meta property="og:title" content="{{ detailobject.title|truncatechars:50
}}" >
{% if "None found" not in detailobject.blog_desc %}
<meta property="og:description" content="
{{ detailobject.blog_desc|truncatechars:100 }}" >
{% else %}
<meta property="og:description" content="
blog description goes here {{ detailobject.title|truncatechars:100 }}" >
{% endif %}
<meta property="og:url" content="{{ request.build_absolute_uri }}" >
<meta property="og:image" content="{% static
'docs/assets/ico/fbcomments.png' %}" >
{% endblock metacontent %}
and finally, the comments plugin is initialized like so:
<div class="fb-comments"
data-href = "{{ request.build_absolute_uri|urlencode:"" }}"
data-width = "600"
data-num-posts = "10"
colorscheme = "light">
</div>
..the problem is, on everypage I have facebook comments, I get an annoying
message at the bottom of the comments plugin saying:
"Warning URL "...." is unreachable"
where "..." is the URL of the page.
I have tried debugging it to no effect (there are no error or warning
messages for the page on fb debugger - initially it said it needed og:url
etc.. once I fixed them, I see no errors/warning on fb debugger, but the
warning still remains).
I am totally confused now how to get rid of this error. The funny thing is
that I do not get this warning on my devel environment - but get this in
production type environment.
I would really appreciate if anyone could guide me in the right direction
to solve this issue. I am beginning to think that I am not using the FB
Javascriot SDK correctly - not sure if all I need is the JS code above or
if I need to include it as shown here

Friday, 30 August 2013

JmDNS : Discover the same service on Multiple devices

JmDNS : Discover the same service on Multiple devices

I am trying to use JmDNS to discover the services. I am able to discover
the service using the Sample Code given at the
When I add a service listener and invoke the addServiceListener, it
properly identifies the service. But, I have the same service running on
more than one device. Now, I am wondering how I will be able to get the
list of all the IP Address on which the service is running. I am only able
to get the IP Address of one the devices.
And also what is the difference between JmDNS and JmmDNS?

Thursday, 29 August 2013

Intervlan Communication not happening

Intervlan Communication not happening

I am in the process of testing my network implementation, during that
inter vlan communication is not happening.
Steps i have followed: 1.Created vlan 10 and 11 with below ip address
interface Vlan-interface1 ip address 172.16.0.65 255.255.255.192 #
interface Vlan-interface10 ip address 172.16.0.129 255.255.255.224 #
interface Vlan-interface11 ip address 172.16.0.161 255.255.255.192
The abpve IP's will be the default gateway of two host .
I am able to reach Switch from both hosts but not host to host.
Kindly help me

Wednesday, 28 August 2013

how to use wso2 esb with cxf?

how to use wso2 esb with cxf?

Is it possible to deploy CXF Web Services in wso2 ESB ?
Currently I have started referring documentation of wso2 from WSO2 User
Guide and I want to deploy an existing CXF Web Service to ESB. So any
information on this will be very helpful.

New to sqlite and database work, how do I do this query?

New to sqlite and database work, how do I do this query?

I have a project I am working on and I am wanting to create a query that
involves two tables from my database as pictured below.

What I want from the query is if DMN_LIST_COLS on the DOMAIN data table
equals 1 I want to retrieve all the values from DMV_VALUE_1 of the
DOMAIN_VALUE data table. What is the correct format for this query?
I know the query below is incorrect but how do I change this?
SELECT DMV_VALUE_1 FROM DOMAIN_VALUE WHERE DMN_LIST_COLS='1' FROM DOMAIN

Broken links on Virtual host site

Broken links on Virtual host site

I am running Ubuntu 12.04 and i have setup my LAMP stack successfully. I
have set up my Virtual Host to run on mysite.local
i have pulled the repo on Git and everything works fine, when I access the
url I get the home page, however when I click on ~quite a lot~ of links i
am informed the file isn't present on the server even though the files are
present in my directory (/var/www)
Does anyone have any idea why this is?

How to do a second query using the results of a previous query

How to do a second query using the results of a previous query

Ok I need to count how many sales has made each of the sell agents of the
company, so I do This...
SELECT agentID, AgentName, COUNT(*) as total_sales FROM sales GROUP BY
agentID
This works perfectly, how ever It does not show the agents that had 0 sells.
So I need to perform a
SELECT agentID FROM agents
and the do a query of each result, so I can count how many sales had that
agent. I hope I explain it.
(I can do the loop in PHP, how ever Im wondering if is possible to do
directly in MySQL)
Regards

remove Cookie using jquery not working

remove Cookie using jquery not working

I have two cookies in my JS file and I want to remove them.
I have tried the code below but it is not working
$.removeCookie('filter', { path: '/Home/' });
$.removeCookie('Pfilter', { path: '/Home/' });
I have also tried the below for null cookies, but this is also not working.
Thanks for the help
$.cookie('filter',null, { path: '/Home/' });

NSDate showing null always

NSDate showing null always

I am using ns date concept in my application. In one of my classes I have
set the nsdate date for a date instance and I use it in the next class. It
works perfect for me but if I use that date its giving me 5.30 hrs before
time so I used a date formatter to change it but I'm getting a null
response.
NSLog(@"update date=
%@",pullToRefreshManager_.pullToRefreshView.lastUpdateDate);
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
[dateFormat setTimeZone:timeZone];
[dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *str=[NSString
stringWithFormat:@"%@",pullToRefreshManager_.pullToRefreshView.lastUpdateDate];
NSLog(@"Str== %@",str);
NSDate *date = [dateFormat dateFromString:[NSString
stringWithFormat:@"%@",str]];
NSLog(@"exact date= %@",date);
Pls help
Thanks in advance

Tuesday, 27 August 2013

Fastest way to create this matrix in R

Fastest way to create this matrix in R

I have two vectors r and s. I want to find the outer difference of these
two arrays and not be negative like the following
r = rnorm(100000)
s = c(0.02, 0.04, 0.3, 0.43, 0.5, 0.7, 0.8, 0.9)
res = t(pmax(outer(r, s, "-"), 0))
system.time({
res = t(pmax(outer(r, s, "-"), 0))
})
## system elapsed
## 0.05 0.00 0.05
or
system.time({
x = pmax(r - rep(s, each = length(r)), 0)
res = matrix(x, nrow = length(s), byrow = TRUE)
})
## system elapsed
## 0.05 0.00 0.05
How can I get faster the result x in R?

How to remove the annoying Reconnect to Face messages from Win8?

How to remove the annoying Reconnect to Face messages from Win8?

In Win 8 it seems that it is assumed that everyone is a facebook user. For
a multitude of reasons I avoid facebook but win8 is constantly prompting
me to reconnect to facebook, bot under people and messaging. Is there a
way to delete these connections or attempts at connections?

Create numbers with their factorization

Create numbers with their factorization

I would like to define a function factors(a,b) that returns all the
numbers between a and b along with their prime factorizations. I can just
factorize each number using an external module but that is very slow she
you do millions on them.
The numbers a and b will typically have 10 to 15 digits.

Is There Any File Operation Queue Libraries

Is There Any File Operation Queue Libraries

Currently, I'm working on a TFS source download project for our project
branch build. We have many branches, but don't want to spend too much disk
space to hold all the source code. (Even for a single branch the source
code is too much.) So, we have an app to download source code from one TFS
branch.
Due to the svn-style of TFS, you cannot seamlessly switch between
branches. All source code need to be fetched before switching branch. Our
strategy is: update current workspace to branch point, and fetch change
set by change set.
However, this yield to many duplications, since the TFS downloading API
downloads the entire file, and if one file is modified several times, it
will be downloaded once and once again. (Situation is getting worth if
forward integration happens.)
What come into my mind is to queue all these download/delete file
operations, remove duplicated operations, and only apply the latest
operation to local disk.
I'm wondering if there's any library can do this, something like:
FOQueue.CreateFile(file1, (path) => DownloadFromTFS(path));
FOQueue.CreateFile(file2, (path) => DownloadFromTFS(path));
FOQueue.DeleteFile(file1); // OK, file1 will not be
downloaded
// since latest operation
is deletion.
FOQueue.CreateFile(file3, ...);
FOQueue.DeleteFolder(parentOfFile3); // file3 will not be
downloaded since
// its parent folder is
deleted.
FOQueue.Flush(); // Only file2 is downloaded.
Thanks in advance!

How Do I see changes made to kernel Module

How Do I see changes made to kernel Module

I am New to Linux kernel , I have Module running on my Linux Machine and
can see it using lsmod command ,Now I made some changes(added some printk)
to this moudule ,recompiled again and got the .ko again.Now I did rmmod to
remove this module(some other modules also which are using this module)
and did insmod xxx.ko and reboot the system .
Now where Do I see the statements added using printk ,I tried to see using
dmesg grep | "SPI RW"
But couldn't find anything .Could anybody let me know what I am doing
wrong here??

Organic tabs plugin open parent page

Organic tabs plugin open parent page

I'm using the organic tabs plugin -
http://css-tricks.com/4530-organic-tabs/ - and need a bit of help.
Is there a way for nav li to open a page on the site rather than a
submenu. For example, if you click on 'Practice' it redirects you to
http://www.claguelondon.co.uk/practice/ and the correct page is
highlighted.
HTML
<div id="example-one">
<ul class="nav">
<li class="nav-one"><a href="#home"
class="current">Home</a></li>
<li class="nav-two"><a href="#projects">Projects</a></li>
<li class="nav-three"><a href="#practice">Practice</a></li>
<li class="nav-four"><a href="#news">News</a></li>
<li class="nav-five last"><a href="#contact">Contact</a></li>
</ul>
<div class="list-wrap">
<ul id="home">
<li></li>
</ul>
<ul id="projects" class="hide">
<li><a href="http://www.claguelondon.co.uk/project-i">Project
I</a></li><br />
<li><a href="http://www.claguelondon.co.uk/project-ii">Project
II</a></li><br />
<li><a
href="http://www.claguelondon.co.uk/project-iii">Project
III</a></li><br />
<li><a href="http://www.claguelondon.co.uk/project-iv">Project
IV</a></li><br />
<li><a href="http://www.claguelondon.co.uk/project-v">Project
V</a></li>
</ul>
<ul id="practice" class="hide">
<li></li>
</ul>
<ul id="news" class="hide">
<li></li>
</ul>
<ul id="contact" class="hide">
<li></li>
</ul>
</div> <!-- END List Wrap -->
</div> <!-- END Organic Tabs (Example One) -->
CSS
/* Nav
------------------------------------------------------------ */
ul.nav {
float: left;
width: 150px;
}
#example-one {
background: #FFFFFF;
}
#example-one .nav {
overflow: hidden;
}
#example-one .nav li {
width: 97px; float: left;
}
#example-one .nav li.last {
margin-right: 0;
}
#example-one .nav li a {
display: block;
color: #999999;
font-size: 10px;
text-align: left;
border: 0;
text-decoration: none;
}
#example-one .nav li a:hover {
background-color: #FFFFFF;
}
#example-one ul {
list-style: none;
}
#example-one ul li a {
display: block;
padding: 0 0 4px 0;
color: #999999;
}
#example-one ul li a:hover, #example-one ul li a:focus {
background: #FFFFFF;
color: #000000;
}
#example-one ul li:last-child a {
border: none;
}
#example-one li.nav-one a.current, ul.featured li a:hover {
background-color: #FFFFFF;
color: #000000;
}
#example-one li.nav-two a.current, ul.core li a:hover {
background-color: #FFFFFF;
color: #000000;
}
#example-one li.nav-three a.current, ul.jquerytuts li a:hover {
background-color: #FFFFFF;
color: #000000;
}
#example-one li.nav-four a.current, ul.classics li a:hover {
background-color: #FFFFFF;
color: #000000;
}
#example-one li.nav-five a.current, ul.classics li a:hover {
background-color: #FFFFFF;
color: #000000;
}
.hide {
position: absolute;
top: -9999px;
left: -9999px;
}
/* Sub Nav
------------------------------------------------------------ */
ul#projects.hide {
display: inline-block;
}
ul#projects li {
font-size: 10px;
display: inline-block;
}
ul#projects li a {
text-decoration: none;
padding: 0px;
}
ul#projects li a:hover {
color: #000000;
}

Monday, 26 August 2013

How to get all the results with "google map" with writing a little python script?

How to get all the results with "google map" with writing a little python
script?

Open page "http://ditu.google.cn". Then I type in search box "school Newyork"
I was thinking of writing a little python scriptI to get all the search
results saved like this:
SchoolName
Address
Telephone
site
I'm trying to get these informations with BeautifulSoup. The problem is
that there are ten results in one page. I don't know how to change to
"Next Page" with Python. Is there any way to get all the results?

Os X - Why do I need to turn on WiFi to determine closest location

Os X - Why do I need to turn on WiFi to determine closest location

Why do I need to turn on WiFi to determine my closest location?
For some reason, my mac won't get the latest time from the NTP server if I
am plugged into Ethernet. What could possibly be different between my
wireless and my Ethernet?

removing the featured image from the post

removing the featured image from the post

This is a twentytwelve wordpress child theme, and it's located at
www.travelwithcastle.com
I'd very much like to delete the enormous preview pic that shows up on top
of the actual post page. It's the feature pic I chose to be the preview
pic for the homepage. I love the picture, but that picture is already
within the post content, so there is no need for it appear above the post
as well.
I took at look at content.php, thinking that would be the place to look,
but I'm a little stumped. Perhaps I'm misunderstanding the code, but it
seems to me that any change I make there will also affect the actual
preview of the post on the homepage. I thought I was removing the image
for example by deleting the thumbnail, but that removed the image
completely from the homepage preview. Can anyone explain how I can
instruct the site to not show the preview pic at the top of the post,
while keeping it on the homepage as a preview? Perhaps I need to structure
the files differently?
to be clear, the picture i choose as the featured image for the post (the
one that shows up on the homepage preview) also shows up at the top of the
actual post, before the title. I'd like it not to be there since it's
already in the post content.
I did peruse your past questions, and while a lot of very similar
questions are asked, this one is not.
Many thanks.
Kelly
content.php is posted here for your reference:
<?php
/**
* The default template for displaying content. Used for both single and
index/archive/search.
*
* @package WordPress
* @subpackage Twenty_Twelve
* @since Twenty Twelve 1.0
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
<div class="featured-post">
<?php _e( 'Featured post', 'twentytwelve' ); ?>
</div>
<?php endif; ?>
<header class="entry-header">
<?php the_post_thumbnail(); ?>
<?php if ( is_single() ) : ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php else : ?>
<h1 class="entry-title">
<a href="<?php the_permalink(); ?>" title="<?php echo
esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve'
), the_title_attribute( 'echo=0' ) ) ); ?>"
rel="bookmark"><?php the_title(); ?></a> <br><?php
the_date(); ?>
</h1>
<?php endif; // is_single() ?>
<?php if ( comments_open() ) : ?>
<div class="comments-link">
<?php comments_popup_link( '<span
class="leave-reply">' . __( 'Leave a reply',
'twentytwelve' ) . '</span>', __( '1 Reply',
'twentytwelve' ), __( '% Replies', 'twentytwelve' ) );
?>
</div><!-- .comments-link -->
<?php endif; // comments_open() ?>
</header><!-- .entry-header -->
<?php if ( is_search() || is_home() ) : // Display Excerpts for Search and
Homepage ?>
<?php else : ?>
<div class="entry-content">
<?php the_content( __( 'Continue reading <span
class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div
class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after'
=> '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endif; ?>
<?php if ( is_singular() && get_the_author_meta( 'description'
) && is_multi_author() ) : // If a user has filled out their
description and this is a multi-author blog, show a bio on
their entries. ?>
<div class="author-info">
<div class="author-avatar">
<?php echo get_avatar( get_the_author_meta(
'user_email' ), apply_filters(
'twentytwelve_author_bio_avatar_size', 68 ) ); ?>
</div><!-- .author-avatar -->
<div class="author-description">
<h2><?php printf( __( 'About %s', 'twentytwelve'
), get_the_author() ); ?></h2>
<p><?php the_author_meta( 'description' ); ?></p>
<div class="author-link">
<a href="<?php echo esc_url(
get_author_posts_url( get_the_author_meta(
'ID' ) ) ); ?>" rel="author">
<?php printf( __( 'View all posts by %s
<span class="meta-nav">&rarr;</span>',
'twentytwelve' ), get_the_author() ); ?>
</a>
</div><!-- .author-link -->
</div><!-- .author-description -->
</div><!-- .author-info -->
<?php endif; ?>
</footer><!-- .entry-meta -->
</article><!-- #post -->

joomla 3 custom module class name

joomla 3 custom module class name

Running Joomla 3.1.5
I created a very simple module and I can't find anywhere in the module
options where to add a class name. This was easy in earlier versions of
Joomla; there was a "Menu Class Suffix" field under "ADVANCED OPTIONS."
How do I add a class name to my custom module? Thanks for the answers.

NServiceBus IoC Serialization Exception

NServiceBus IoC Serialization Exception

I am using a "custom" object builder (Autofac) so I can re-use the
registration of many types that I have done in a common assembly. When I
run the service, hosted within NServiceBus.Host.exe, I get the following
error:
SerializationException was unhandled:
Type 'Autofac.Core.Registration.ComponentNotRegisteredException' in
assembly 'Autofac, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=17863af14b0044da' is not marked as serializable.
This seems odd to me because NServiceBus uses Autofac by default and
doesn't have this same issue.

Model field not displaying in Django Admin

Model field not displaying in Django Admin

I have a Django project hosted on heroku
I added a new slug field to model
from django.db import models
class Category(models.Model):
name = models.CharField(max_length=30)
slug = models.SlugField(unique=True)
def __unicode__(self):
return self.name
migrated it using south on heroku. Checked the heroku postgresDB as well
for added field. All fine...
Opened Admin. No slug field showing...
added slug to fields[] in admin.py. Still not showing. Here is admin.py
from django.contrib import admin from models import Category
class CategoryAdmin(admin.ModelAdmin): fields = ('name', 'slug')
admin.site.register(Category, CategoryAdmin).
I even did a heroku restart... No change. What can be done to show it ?

Bootstrap Tabbable Issue

Bootstrap Tabbable Issue

I have a html page as B.html with tab navigation. I made tabs tabbable in
my html page as below.
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active"><a href="#tab1" data-toggle="tab">Section 1</a></li>
<li><a href="#tab2" data-toggle="tab">Section 2</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
<p>I'm in Section 1.</p>
</div>
<div class="tab-pane" id="tab2">
<p>Howdy, I'm in Section 2.</p>
</div>
</div>
</div>
I have another html page as A.html. In A.html page, there are 2 a tags as
T1 and T2. When i click T1, i need to redirect to B.html and show content
own to Tab 1 and When i click T2, i need to redirect to B.html and show
content own to Tab 2.
I have tried as below.
<a href="http://www.abc.com/B.html#tab1">T1</a>
<a href="http://www.abc.com/B.html#tab2">T2</a>
But this not worked. it always select tab1. How can i solve this ?

Ajax request returning full page code

Ajax request returning full page code

I'm having a bit of an issue with an ajax call on a site I've just taken
over.
I've used similar calls before on other sites so not sure if it's a plugin
restriction or conflict but any ideas are welcome!
The call is returning the full content of the page rather than the content
the id of the post which is what I expected. I have added an alert to the
js before the ajax call and the "thisPost" var is set correctly. I've
tried a variety of different methods but none seem to let me return the
post_id as a json object. In the end the return will be a json object with
more details than just the post_id but cut it down till I get it working.
functions.php
function add_calendar_scripts(){
if (is_page_template('template-eventsplanner.php') ) {
wp_register_script('calendar', ( get_bloginfo('template_url') .
'/js/calendar.js'), array ('jquery'));
wp_enqueue_script('calendar');
wp_localize_script( 'calendar', 'MyAjax', array( 'ajaxurl' =>
admin_url( 'admin-ajax.php' ) ) );
}
}
add_action('wp_head', 'add_calendar_scripts');
function get_full_event_callback(){
global $wpdb;
$response = array();
$post_id = intval($_POST['posted']);
$response[] = array('id'=>$post_id);
$result = json_encode($response);
echo "post_id";
die();
}
add_action( 'wp_ajax_nopriv_get_full_event', 'get_full_event_callback' );
add_action( 'wp_ajax_get_full_event', 'get_full_event_callback' );
calendar.js
jQuery(document).ready(function() {
var container = jQuery('body'),
scrollTo = jQuery('.today');
container.animate({
scrollTop: scrollTo.offset().top - container.offset().top +
container.scrollTop() - 120
});
Shadowbox.init({
skipSetup: true
});
jQuery('.event_box').click( function(){
var pretext = "<h1>Davis Track Hire Job Information</h1>";
var thisPost= jQuery(this).data("event");
var contents, pdf_button;
var data = {
action: 'get_full_event',
dataType: 'json',
posted: thisPost,
};
jQuery.post(MyAjax.ajax_url, data, function(response) {
if(response!=0){
contents = pretext.concat(response);
pdf_button = "<a href='#'>Link to PDF to follow</a>";
// open a welcome message as soon as the window loads
Shadowbox.open({
content: contents.concat(pdf_button),
player: "html",
title: "Event Details",
height: 600,
width: 500
});
}
});
});
});

Sunday, 25 August 2013

Camel: disable polling messages

Camel: disable polling messages

i am using camel to setup some routing using the file and jms-queue
components. The problem that i am having is the i cannot disable polling
messages sent to the console.
Tryed multiple ways to disable these messages by setting the logging
level(runLoggingLevel = OFF) on the routes, trace = false on the context,
set a logger on the routes and a few others but nothing works.
A message from the file component looks like this:
2013-08-26 09:34:47,651 DEBUG [Camel (camelContextOrder) thread #0 -
file://order-import/order-in] o.a.c.c.f.FileConsumer Took 0.001 seconds to
poll: order-import\order-in
And a messsage from the jms queue:
2013-08-26 09:34:46,281 DEBUG [ActiveMQ Journal Checkpoint Worker]
o.a.a.s.k.MessageDatabase Checkpoint started.
2013-08-26 09:34:46,403 DEBUG [ActiveMQ Journal Checkpoint Worker]
o.a.a.s.k.MessageDatabase Checkpoint done.

GVIM : how to change the color of the text via ( /root/.vimrc ) file?

GVIM : how to change the color of the text via ( /root/.vimrc ) file?

Currently in
/root/.vimrc
i have
:colorscheme desert
set guifont=Monospace\ 11.5
in both cases i didn't know how to find these values, so others told me
about it.
in other words i do not know how to set the color of text to "#cccccc" for
example.

selectnav list item with a span inside

selectnav list item with a span inside

I'm using selectnav
and it works great, but I have a menu with a description span inside the
list item. So my menu items look like this
<li><a href="somelink.html">Chapter Here <span>description
here</span></a></li>
selectnav returns the list item as Chapter Heredescriptionhere but I want
to remove that description span. How do I strip out that description span
so selectnav returns just Chapter Here .
Hope that makes sense.
Thank you. :)

Remove a value from hashmap based on key

Remove a value from hashmap based on key

I'm braindead right now. I've been coding for several hours now, and I
can't figure out the simplest things anymore.
So I have a HashMap
public HashMap<String, String> frozen = new HashMap<String, String>();
and I want to remove a value from it depending on the key. So lets say I
put in these
frozen.put("1", "1_1");
frozen.put("1", "1_2");
I want to remove only one of the values, not the whole keyset.
How would I go about doing this? If you still didn't understand, this
non-existing method should explain it.
frozen.remove("1", "1_2");
Obviously that doesn't exist, but that's what I want.
Thanks in advance.

Saturday, 24 August 2013

Message Framing Protocol Failing Under Strenuous Conditions

Message Framing Protocol Failing Under Strenuous Conditions

I am using the open-source networking library called Griffin.Networking to
develop a program that allows me to monitor remote computers.
The author includes a sample binary protocol called
Griffin.Networking.Protocols.Basic. The purpose of this protocol is to
effectively serialize any outgoing messages and build any incoming
messages.
I am experiencing problems with the Message Builder when the network is
under a lot of stress. The client application attempts to send a 300kb
message every 250 milliseconds or so.



I appreciate that many of you will not be familiar with the library but
that does not mean you cannot answer my question. The author has done an
excellent job of making everything very loosely coupled which allows me to
quickly explain the specific part of the library I am having trouble with.
When incoming data is read from the internal TCP buffer into the
application's managed buffer, the managed buffer and the number of bytes
read are passed to a method called HandleRead
protected override void HandleRead(IBufferSlice slice, int bytesRead)
{
if (_messageBuilder.Append(new SliceStream(slice, bytesRead)))
{
object message;
while (_messageBuilder.TryDequeue(out message))
{
TriggerClientReceive(message);
}
}
}
This HandleRead method effectively feeds the message builder the incoming
data. If the incoming data forms an entire message (maybe more) then the
message builder will successfully proceed to dequeue the messages and
raise an appropriate event. If the incoming data does not form an entire
message then the message builder will maintain it's state (i.e. the data
we have already read and how much data is left to read) until the
application makes another successful read.



The MessageBuilder class itself is as followed. Please excuse the long
segment of code. The code is available on GitHub here.
Note that I modified the code presented here slightly for formatting
purposes. Also note that I replaced the JsonSerializer with the
BinaryFormatter and that is reflected in my code sample
public class BasicMessageBuilder : IMessageBuilder
{
private readonly byte[] _header = new byte[Packet.HeaderLength];
private readonly Queue<Packet> _messages = new Queue<Packet>();
private int _bytesLeft = Packet.HeaderLength;
private Packet _packet;
private Func<IBufferReader, bool> _parserMethod;
public BasicMessageBuilder()
{
_parserMethod = ReadHeaderBytes;
}
public bool Append(IBufferReader reader)
{
while (_parserMethod(reader))
{
}
return _messages.Count > 0;
}
public bool TryDequeue(out object message)
{
if (_messages.Count == 0)
{
message = null;
return false;
}
var packet = _messages.Dequeue();
return true;
}
public void Reset()
{
_messages.Clear();
_packet = null;
_bytesLeft = Packet.HeaderLength;
_parserMethod = ReadHeaderBytes;
}
protected virtual bool ReadHeaderBytes(IBufferReader stream)
{
var bytesLeftInStream = stream.Count - stream.Position;
var bytesToCopy = bytesLeftInStream < _bytesLeft
? bytesLeftInStream
: _bytesLeft;
stream.Read(_header, 0, bytesToCopy);
_bytesLeft -= bytesToCopy;
if (_bytesLeft > 0)
return false;
_packet = CreatePacket(_header);
_bytesLeft = _packet.ContentLength;
_parserMethod = ReadBodyBytes;
return true;
}
protected virtual bool ReadBodyBytes(IBufferReader reader)
{
var bytesLeftInStream = reader.Count - reader.Position;
var bytesToCopy = bytesLeftInStream < _bytesLeft
? bytesLeftInStream
: _bytesLeft;
reader.CopyTo(_packet.Message, bytesToCopy);
_bytesLeft -= bytesToCopy;
if (_bytesLeft > 0)
return false;
_packet.Message.Position = 0;
_messages.Enqueue(_packet);
_packet = null;
_bytesLeft = Packet.HeaderLength;
_parserMethod = ReadHeaderBytes;
return true;
}
protected virtual Packet CreatePacket(byte[] header)
{
var message = new Packet
{
Version = _header[0],
ContentLength = BitConverter.ToInt32(header, 1)
};
if (message.Version <= 0)
throw new InvalidDataException();
if (message.ContentLength <= 0)
throw new InvalidDataException();
message.Message = new MemoryStream(message.ContentLength);
return message;
}
}



When the client application sends relatively large messages in quick
succession the MessageBuilder.CreatePacket() method throws an
InvalidDataException.
I really don't know what is wrong but I do have a suspicion.
I believe that the MessageBuilder is reading header bytes when it should
be reading body bytes and because of this, the incoming data it perceives
to be a header will be invalid and an exception will be thrown. I cannot
explain this behaviour though
I do not believe lock will help here. This doesn't appear to have anything
to do with multiple threads accessing the same resource. I tested this by
writing the current thread's ID to a trace log.
I thought that perhaps the asynchronous call back was being called in
quick succession and that was going to cause the MessageBuilder to confuse
its' state but it is my understanding that every call will be executed in
sequential order because the message builder code is synchronous.
What I find to be interesting (and confusing) is that the client
application can send a few hundred 300kb messages (often more, sometimes
less) before the server application crashes.
This is not an urgent problem. I wrote my own MessageBuilder that operates
completely differently and everything works fine. I would like to solve
this conundrum as to why the aforementioned MessageBuilder fails though.
Could anybody help me understand the problem here?

How to run curl after building it on shared host

How to run curl after building it on shared host

I have a shared hosting account with GIT installed. I have installed the
latest version of Curl from source at github (
https://github.com/bagder/curl ). ( The directions are in the document
GIT-INFO in the repository ) in my shared hosting account . After all that
I realized I don't know how run it! Can Anyone tell me what the file path
to the executable is? I see hundreds of files with 'curl' in them when I
search for curl. A small example:
/curl/lib/libcurl.vers.in
/curl/lib/libcurl_la-curl_darwinssl.o
/curl/lib/libcurl.def
/curl/lib/libcurl_la-amigaos.o
/curl/lib/libcurl_la-inet_pton.lo
/curl/lib/libcurl_la-multi.lo
/curl/lib/libcurl_la-curl_threads.lo
/curl/lib/libcurl_la-non-ascii.lo
/curl/lib/libcurl_la-curl_threads.o
/curl/lib/curl_addrinfo.c
/curl/lib/libcurl_la-hostip4.lo
/curl/lib/libcurl_la-rawstr.lo
/curl/lib/libcurl_la-llist.lo
/curl/lib/libcurl_la-share.lo
/curl/lib/libcurl_la-http_negotiate.lo

dynamic remove row wont work, only removes first row and not others

dynamic remove row wont work, only removes first row and not others

When i try to remove the first row it works but as i add more rows i cant
delete them. For some reason i can only remove the first row.
here is my html
<table class="pretty property_units" style="width:800px;">
<thead>
<tr>
<th>Bedroom</th>
<th>Bathroom</th>
<th>Square Feet</th>
<th>Price</th>
<th>Available</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr class="rows">
<td><input type='text' name='bedroom[]' value='0'
class='input-small'></td>
<td><input type='text' name='bath[]' value='0' class='input-small'></td>
<td><input type='text' name='sqrt[]' value='0' class='input-small'></td>
<td><input type='text' name='price[]' value='0' class='input-small'></td>
<td>
<select name='avail[]' class='input-small'>
<option value='yes'>Yes</option>
<option value='no'>No</option>
</select>
</td>
<td><button type="button" class="btn btn-danger btn-small
removeRow">remove</button></td>
</tr>
</tbody>
</table>
<button type="button" class="btn btn-small btn-primary addrow">add
row</button>
here is my js
<script type="text/javascript">
$(document).ready(function() {
$(".addrow").click(function() {
var tblrow = $('table.property_units tr.rows:last').clone();
$("table.property_units tbody").append(tblrow);
});
$(".removeRow").click(function() {
$(this).closest("tr").remove();
return false;
});
});
</script>

Is there a correlation between the scale of the project and the strictness of the language?

Is there a correlation between the scale of the project and the strictness
of the language?

Explaining the difference between strictness of languages and paradigms to
a colleague of mine, I ended up asserting that:
Tolerant languages, such as dynamic and interpreted languages, are used
best for prototypes and small projects or medium-size web applications.
When choosing elegant dynamic languages such as Python or JavaScript with
Node.js, the benefits are:
Fast development,
Reduced boilerplate code,
Ability to attract young, creative programmers who flee "corporate
languages" like Java.
Statically typed/compiled languages are best for applications which
require higher strictness such as business-critical apps or apps for
medium to large-size apps.
Well-known paradigms and patterns developed for decades,
Ease of static checking,
Ability to find many professional developers with decades of experience.
Strict languages such as Haskell, Ada or techniques such as Code contracts
in C# are better for systems which favor safety over flexibility (even if
Haskell can be extremely flexible), such as life critical systems and
systems which are expected to be extremely stable. The benefits are:
Ability to catch as many bugs as possible at compile time,
Ease of static checking,
Ease of formal proofs.
However, by looking at the languages and technologies used for large-scale
projects by large corporations, it seems that my assertion is wrong. For
example, Python is successfully used for large systems such as YouTube or
other Google applications which require an important amount of strictness.
Is there still a correlation between the scale of the project and the
strictness of the language/paradigm which should be used?
Is there a third factor that I've forgotten to take in account?
Where am I wrong?

How do I clean my hob?

How do I clean my hob?

I am using a Creda Capri hotplate hob (possibly this one [pdf]).
The problem is the area around the burners has became too dirty, with
sticky burns. Here's a photo:

I have tried using Dettol Spray Power And Pure Kitchen but was unable to
remove the stains. What I can do?

Overrriding destructor of std:exception

Overrriding destructor of std:exception

The following program does not compile in g++ 4.4 if line 8 is commented.
Why? It seems that when I override std::exception constructor, I must
override its destructor as well. What's the reason for this?
#include<iostream>
#include<exception>
using namespace std;
class A : public exception {
public:
A(string msg) : _msg(msg) {}
//~A() throw(){}; // line 8
const char* what() const throw() { return _msg.c_str();}
private:
string _msg;
};
int main()
{
}
The compilation error is:
error: looser throw specifier for 'virtual A::~A()'

Friday, 23 August 2013

Linear combination of homogeneous polynomials

Linear combination of homogeneous polynomials

Let $f_1=1,f_2,\cdots, f_k$ be homogeneous polynomials and $F$ be product
of linear forms in $\mathbb{R}[x_1,\cdots, x_n]$ such that
$0=deg(f_1)=d_1<deg(f_2)=d_2,\cdots,deg(f_k)=d_k, deg(F)=d$. What is
condition of $f_1,\cdots, f_k$ so that there exists homogeneous
polynomials $g_1,\cdots, g_k$ with $deg(g_i)=d-d_i$ satisfying :
$$\sum_{i=1}^k g_i.f_i=F ? $$
For example, if $f_1=1, f_2=y, F=(x+y)(x+y+z)$ then $g_1=x(x+y+z),
g_2=x+y+z.$

How to load UIImage to UICollectionView from an array of UIImage

How to load UIImage to UICollectionView from an array of UIImage

So after saving UIImage to a NSMutableArray from ImagePickerController I
want to load the images to UICollectionView, however the cells are not
displaying anything even though the array isn't nil.
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
[_imgs addObject:image];
[picker dismissModalViewControllerAnimated:YES];
[self.collectionView reloadData];
NSLog(@"%d", [_imgs count]);
//[self viewDidLoad];
}
- (UICollectionViewCell *)collectionView:(UICollectionView
*)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
Icon *icon = [collectionView
dequeueReusableCellWithReuseIdentifier:@"ICON" forIndexPath:indexPath];
UIImageView *recipeImageView = (UIImageView *)[icon viewWithTag:100];
recipeImageView.image = [UIImage imageNamed:[self.imgs
objectAtIndex:indexPath.row]];
icon.image = (UIImage*)[self.imgs objectAtIndex:indexPath.row];
[icon.deleteButton addTarget:self action:@selector(delete:)
forControlEvents:UIControlEventTouchUpInside];
#pragma mark - delete for button
return icon;
}
@implementation Icon
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
UIView *insetView = [[UIView alloc]
initWithFrame:CGRectInset(self.bounds, 300, 400)];
self.image = [[UIImage alloc]init];
UIImageView *img =[[UIImageView alloc]initWithImage:self.image];
[self.contentView addSubview:insetView];
[insetView addSubview:img];
self.layer.shouldRasterize = YES;
I created a class called ICON class to wrap the cells.

General-purpose, open-source tree vizualizer

General-purpose, open-source tree vizualizer

I consistently implement an ITreeNode interface on all my tree structures.
It would be excellent to have a vizualizer available when debugging that
would display a tree structure in a treeview. Apart from writing my own
from scratch, is there any open source vizualizer out there that could be
adapted to recognize my ITreeNode interface?

Using package managers create and rollback system state

Using package managers create and rollback system state

I have a server which is meant to test multiple deployment scenarios all
driven by packages installed over RPMs.
Is there a way to abstract the RPMs in a system so that i can switch rpm
context? For example:
Test A:
postrgre -> postegresql 3.x ,
java -> sun jdk 5.x
hadoop version -> 1.X
python version -> 3.0
Test B:
psql = postgresql 2.x
java -> sun jdk
hadoop version -> 2.X
python version -> 2.7
So clearly, what is needed is
1) Some perfect snapshot of system state before installing RPMs.
2) Some way to create Test environment A from RPMs
3) A way to roll back to (1) after running Test A
4) Some way to create Test environment B from RPMs
5) A way to again roll back to (1) to start the system over.
One option is virtualization, however this environment needs to run on
real hardward. Another option is raw shell scripts - but this doesn't
gaurantee universal recovery of raw, pure system state.

window dot open hides half the newly opened window

window dot open hides half the newly opened window

I am trying to open a new window after an on click event but i am having a
problem. Half of the opened window is hidden on the right most side of the
desktop, i am having to drag it so i could see it.
This is my code :
if ($j==0){echo "<a
onclick=\"window.open(this.href,'','resizable=yes,location=no,scrollbars=yes,dependent=yes,width=1000,height=900,status');
return false\"
href='display_offer_GP.php?CodeOfferReflet=$row[7]&CodeOfferArtemis=$row[8]'><img
id='m_$i'BORDER=0 src=\"images/loupe.gif\" ></a>&nbsp;
" ;
Any thoughts on why this is happening ? thank you
EDIT: i don't to find a solution for this because that i know how to do,
what i want is to understand why is this happening ?

Set file to be opened automatically when opening a C# solution in Visual Studio

Set file to be opened automatically when opening a C# solution in Visual
Studio

I changed the name of my folder which holds my project. Now when i open
the project in Visual Studio, no files open automatically. It is important
that i submit this project very professionally. Is there a way that i can
make my Form.cs file show automatically in VS when the project is opened,
as it does by default if you do not change the project folder name?

Thursday, 22 August 2013

How to refresh Div content on button click

How to refresh Div content on button click

I have a Telerik grid in a Div. During page operation this grid binds
dynamically and holds temporary data. On a 'Save' button click, i am
hiding telerik grid. This Telerik grid appears through partial view. On
'Save' button click I am not reloading or refreshing the page. So, the
problem is that when my next transaction happens, the telerik grid does
not appears. Because it is in hide mode. Hence i want to reload or refresh
that particular 'Div' without reloading whole page. Is it possible. Any
guidance?

jquery toggle content by header

jquery toggle content by header

for the following HTML:
<h1 id="t1">First Title</h1>
<p class="contents" id="c1">First Content</p>
<h1 id="t2">Second Title</h1>
<p class="contents" id="c2">Second Content</p>
<h1 id="t3">Third Title</h1>
<p class="contents" id="c3">Third Content</p>
<!-- etc... -->
I'd like to use jquery to slideToggle the content for each specific
header. Ie: clicking on id="t2", I'd like "c2" to toggle.
Thanks for your suggestions or code!

I want to send dial 1 after receiving phone call in android

I want to send dial 1 after receiving phone call in android

I want to send dial 1 after receiving phone call in android
I already implemented function that is receiving phone call service in
android app. But I don't know how to send dial number 1. Please help me.

Has Gmail just dropped the option to send mail through your own SMTP servers?

Has Gmail just dropped the option to send mail through your own SMTP servers?

On my current gmail account, I have added an other email account I own to
send email though my own smtp servers. This is easy to do in Settings >
Accounts > Add another email address you own, in two steps:
http://i.imgur.com/bdCsEuW.png
But I have just opened a new gmail account, and I can't do the same. I can
only send "on behalf of" somebody else, but I can't add my own SMTP
servers, because the button Next step of the first form has vanished...
http://i.stack.imgur.com/GRZKI.png
Did I miss something or did google really drop the support for external
SMTP servers?
(Sorry for the links to the pictures, I do not have enough reputation to
post the images directly. Can somebody do this for me?)

How portable is relying on sizeof for structures without padding

How portable is relying on sizeof for structures without padding

In code I have to maintain, some array serialization (e.g. std::vector<T>)
happens roughly the following way: there is an array_t structure without
padding:
#pragma pack(push, 1)
template <typename T, uint32_t N>
struct array_t
{
typedef T value_type;
static uint32_t const max_length = N;
uint32_t length;
value_type data[max_length];
value_type const & operator[](uint32_t k) { return data[k]; }
value_type & operator[](uint32_t k) { return data[k]; }
template <typename Container>
void from_container(Container const & c)
{
std::copy(c.begin(), c.end(), &(*this)[0]);
length = c.size();
}
template <typename Container>
Container to_container() const
{
return Container(&(*this)[0], &(*this)[length]);
}
};
#pragma pack(pop)
And when such datatypes need to be sent over the network, what happens is
(very simplified):
template <typename T>
char * serialize(T const & data)
{
void * buf = std::malloc(sizeof(T));
std::memcpy(buf, &data, sizeof(T));
return reinterpret_cast<char *>(buf);
}
std::string const s("This is some string");
typedef array_t<char, 64> arr_str;
arr_str serial;
serial.from_container(s);
char * buf = serialize(serial);
network.send(buf); // frees the memory as well
And on the other end this method is called:
template <typename T>
T deserialize(char * ptr)
{
T data;
std::memcpy(&data, ptr, sizeof(T));
std::free(ptr);
return data;
}
arr_str deserial = deserialize<arr_str>(buf);
We do not need to argue that this is not the best way of serializing
objects. What concerns me now: how portable is that? The comments of these
methods say that this is guaranteed to work on every x86/x64 system - is
that claim true?

innerHTML not working in any browser

innerHTML not working in any browser

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>css demo</title>
</head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
(function(){
var html = '<p>';
html += 'Hello World';
html += '</p>';
$(document.body).innerHTML = html;
//document.body.innerHTML = html;
})
</script>
<body>
</body>
</html>
$(document.body).innerHTML = html; // jQuery one is not working either.
document.body.innerHTML = html; // normal JS trying to query DOM is not
working either.
What's the actually issue here?. I know while using jQuery we don't need
to use innerHTML to append the HTML thing, just was trying and learning it
out.

Wednesday, 21 August 2013

How to redirect(pipe) a log file to console?

How to redirect(pipe) a log file to console?

I have a log file, which can only be appended to. I want to pipe this log
file to console, so that once new data comes to the log file, the console
also reflects the new piece of data. When there is no data to be appended,
the console should block there waiting for updates.
It's like a proxy server, redirecting file updates to console.
How to achieve this using bash?
Thank you.

R openNLP could not find function sentDetect()

R openNLP could not find function sentDetect()

I am using a few packages (webmining, sentiment, openNLP) to extract some
sentences about a stock JPM, but running in the following error:
Error in eval(expr, envir, enclos) : could not find function "sentDetect"
Here is the codes I used and I made sure that all packages are installed.
I checked the "corpus" variable and it is "a corpus with 20 text
documents". I also used "library(help=openNLP)" to list all the functions
in the package "openNLP" but did not find "sentDetect" in the list.
library(XML)
library(tm)
library(tm.plugin.webmining)
library(tm.plugin.sentiment)
library(NLP)
library(openNLP)
stock <-"JPM"
corpus <- WebCorpus(GoogleFinanceSource(stock))
sentences <- sentDetect(corpus)
Here is the running environment. Is it possibly related to the R 3.0.1
version (too new for openNLP) or 64-bit Windows system?
R version 3.0.1 (2013-05-16) -- "Good Sport" Copyright (C) 2013 The R
Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64
(64-bit)
Thank you very much.
Weihong

splitting strings with operator relative to paranthesis

splitting strings with operator relative to paranthesis

I want the following strings to be splitted by the (relative to the pairs
of paranthesis) outest operator (in this case: '+'):
1: "((20 + 20) + a)"
2: "(20 + ((20 + 20) + 20))
The results should be like this:
1: "((20 + 20) " and " a)"
2: "(20 " and " ((20 + 20) + 20))"
Thanks for your help! :)

EJB 3 transactions and synchonization

EJB 3 transactions and synchonization

Using EJB 3, two threads will try to run this code (that is inside a
stateless session bean). Both threads are able to pass through the if
statement and print out the statement.
userTransaction.begin(); //userTransaction is of class UserTransaction
myEntity = entityManager.find(MyEntity.class, id); //entityManager is of
class EntityManager
if (myEntity.getStatus() != "DONE") {
myEntity.setStatus("DONE");
entityManager.merge(myEntity);
System.out.println("Only one thread should be running this");
}
userTransaction.commit();
I've tried setting the transaction isolation level to serializable with no
success:
org.hibernate.Session session = (org.hibernate.Session)
entityManager.getDelegate();
session.connection().setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
Maybe I'm using the wrong approach.

SQL Server 2008 getting rows from this date to this date

SQL Server 2008 getting rows from this date to this date

i really couldnt get it.
code- select * from Bill_Detail where DateTimeofBilling>'8/18/2013
12:00:00 PM' and DateTimeofBilling<'8/20/2013 12:00:00 AM'
psudocode- select all from Bill_Detail where DateTimeofBilling greater
than 8/18/2013 and DateTimeofBilling less than 8/20/2013.
i need to get the rows from the date 8/18/2013 to 8/20/2013 but the code
returns nothing.
i think this is enough explanation for this . can anyone help?

Perl Queue and Threads abnormal exit

Perl Queue and Threads abnormal exit

I am quite new to Perl, especially Perl Threads. I want to accomplish:
Have 5 threads that will en-queue data(Random numbers) into a Thread::queue
Have 3 threads that will de-queue data from the Thread::queue.
The complete code that I wrote in order to achieve above mission:
#!/usr/bin/perl -w
use strict;
use threads;
use Thread::Queue;
my $queue = new Thread::Queue();
our @Enquing_threads;
our @Dequeuing_threads;
sub buildQueue
{
my $TotalEntry=1000;
while($TotalEntry-- >0)
{
my $query = rand(10000);
$queue->enqueue($query);
print "Enque thread with TID " .threads->tid . " got $query,";
print "Queue Size: " . $queue->pending . "\n";
}
}
sub process_Queue
{
my $query;
while ($query = $queue->dequeue)
{
print "Dequeu thread with TID " .threads->tid . " got $query\n";
}
}
push @Enquing_threads,threads->create(\&buildQueue) for 1..5;
push @Dequeuing_threads,threads->create(\&process_Queue) for 1..3;
Issues that I am Facing:
The threads are not running as concurrently as expected.
The entire program abnormally exit with following console output:
Perl exited with active threads: 8 running and unjoined 0 finished and
unjoined 0 running and detached Enque thread with TID 5 got
6646.13585023883,Queue Size: 595 Enque thread with TID 1 got
3573.84104215917,Queue Size: 595
Any help on code-optimization is appreciated.

Tuesday, 20 August 2013

The minimal divisible extension

The minimal divisible extension

For a prime number $p$, $F_{p}$ is the p-adic number groups and $J_{p}$ is
the p-adic integer groups. Is $F_{p}$, the minimal divisible extension of
$J_{p}$?

After the initial installation of Ubuntu, Ubuntu will boot up but only show the desktop background. Any idea why?

After the initial installation of Ubuntu, Ubuntu will boot up but only
show the desktop background. Any idea why?

After the initial installation of Ubuntu (where everything works fine),
Ubuntu will boot up but only show the desktop background (doesn't ask me
to log in). Any idea why?
I can still press ctrl+alt+f1 to get to terminal if needed. (I also have
OpenSSH installed) My current theory is it is a graphics card problem
(because that always seems to be the problem). If it matters, this happens
with both a full install of Ubuntu and with a Wubi install, but it does
not happen with a virtualbox install.
Currently my system is made up of: AMD 8350, GTX 660, 24 GB of ram, 1 TB
HDD, 128 GB SSD, 500 GB HDD. I have tried installing Ubuntu on all 3 of
them, and it does not work on any of them.

How can I see the package name of the app that is installed on my phone?

How can I see the package name of the app that is installed on my phone?

There are many pre-installed apps on my Note II. Some are Google apps,
some are Samsung apps. Other apps, I don't actually know. I was hoping I
could fulfill my curiosity by checking the package name to see if it
starts with one of com.samsung. or com.google. or android.? Unfortunately,
I can only seem to find the display name which could be something as
simple as Clock or Camera or Email.
So, what's one of the easier ways to see the package name of a specific
installed or running Android app? I am on Android 4.1.2.

any one using mupdf in their winrt app

any one using mupdf in their winrt app

i'am using mupdf component in mywindows 8 app .but when i tried to upload
it on store it saying supported api failed how to avoid this.(it prompting
to mupdf references file ) when i remove that dll file my app is not
running)
hear is my error code
windows 8 Supported API test FAILEDenter link description here

How can I read multiple files faster?

How can I read multiple files faster?

in my program I want to read several text files (more than ~800 files),
each with 256 lines and their filenames starting from 1.txt to n.txt, and
store them into a database after several processing steps. My problem is
the data's reading speed. I could speed the program up to about twice the
speed it had before by using OpenMP multithreading for the reading loop.
Is there a way to speed it up a bit more? My actual code is
std::string CCD_Folder = CCDFolder; //CCDFolder is a pointer to a char array
int b = 0;
int PosCounter = 0;
int WAVENUMBER, WAVELUT;
std::vector<std::string> tempstr;
std::string inputline;
//Input
omp_set_num_threads(YValue);
#pragma omp parallel for private(WAVENUMBER) private(WAVELUT)
private(PosCounter) private(tempstr) private(inputline)
for(int i = 1; i < (CCD_Filenumbers+1); i++)
{
//std::cout << omp_get_thread_num() << ' ' << i << '\n';
//Umwandlung und Erstellung des Dateinamens, Öffnen des Lesekanals
std::string CCD_Filenumber = boost::lexical_cast<string>(i);
std::string CCD_Filename = CCD_Folder + '\\' + CCD_Filenumber +
".txt";
std::ifstream datain(CCD_Filename, std::ifstream::in);
while(!datain.eof())
{
std::getline(datain, inputline);
//Processing
};
};
All variables which are not defined here are defined somewhere else in my
code, and it is working. So is there a possibility to speed this code a
bit more up?
Thank you very much!

Android getStringExtra problems

Android getStringExtra problems

I am passing a string from one activity to the other. I pass the text
"maglist". When i log the string in the next activty it says "maglist" as
it should do. BUT, if i do an if statement which asks if the string =
"maglist" then is just goes to the else when it should be true. Il show
you:
First Activity:
Intent intentRefresh = new Intent(getApplicationContext(),
com.fieldandrurallife.media.InternetRefresh.class);
String list = "maglist";
intentRefresh.putExtra("from", list);
intentRefresh.putExtra("cat", cat);
startActivity(intentRefresh);
Second Activity:
Intent iB = getIntent();
String from = iB.getStringExtra("from");
if(from == "maglist"){
Log.d("refresh", "From = " + from);
} else {
Log.d("refresh", "dident work" + from);
}
I get the LOG of "dident work maglist" when it should be "maglist"
Confused. Thanks in advanced.

Fixing the size of ingredient in the tables' cells

Fixing the size of ingredient in the tables' cells

I have created a table as follows:
\documentclass{article}
\usepackage{array,booktabs}
\usepackage{colortbl}
\usepackage{xcolor}
\begin{document}
\newcolumntype{L}{@{}>{\kern\tabcolsep}l<{\kern\tabcolsep}}
\begin{table}[htp]
\caption{Indicators for sustainable transportation \citep{r2}}
\label{tab: ind}
\centering
\footnotesize\setlength{\tabcolsep}{2.5pt}
\begin{tabular}{@{} l L L L @{} >{\kern\tabcolsep}l @{}} \toprule
\emph{Objective} & \emph{Indicator} & \emph{Direction} &&& \\\midrule
\emph{Economic} & & & & \\
\rowcolor{black!3}[0pt][0pt] Transport diversity & Mode split: portion of
travel made by walking, cycling, rideshare, public transit and telework &
More is better \\
\emph{Social} & & & & \\
\rowcolor{black!6}[0pt][0pt] Health and fitness & Percentage of population
that regularly walks and cycles & More is better \\
\rowcolor{black!8}[0pt][0pt] Non-motorized transport planning & Degree to
which impacts on non-motorized transport are considered in transportation
modeling and planning & More is better \\
\emph{Environmental} & & & & \\
\rowcolor{black!10}[0pt][0pt] Resource efficiency & Non-renewable resource
consumption in the production and use of vehicles and transport facilities
& Less is better \\
\rowcolor{black!12}[0pt][0pt] Climate change emissions & Per capita fossil
fuel consumption, and emissions of CO2 and other climate change emissions
& Less is better \\
\rowcolor{black!14}[0pt][0pt] Noise pollution & Portion of population
exposed to high levels of traffic noise & Less is better \\
\bottomrule
\hline
\end{tabular}
\end{table}
\end{document}
And the output is presented as:

As you can see part of the table in out of the border. The problem is
caused because the cell's texts are long.
How can I fix it, automatically?

Monday, 19 August 2013

select a random button from array

select a random button from array

I have to hide one of mine four UIButtons, randomly selected, BUT
Excepting one.
for this, I created a NSMutableArray, and added all button there, as
following example:
rand_btns = [[NSMutableArray alloc] initWithObjects: _bt1, _bt2, _bt3,
_bt4,nil];
No, each button has its own tag: _bt1 has tag 1, _bt2 has tag 2, and so...
Please, any ideas? I want to hide one random button, but excepting a
button which has tag equal to my: int Level.
I want to use this for a Quiz App.
So, my int Level is from 1-4 random number, when one of mine four buttons
has tag equal to mine int Level, that button should be excepted from
hiding.

Trouble with referencing a javascript variable using jquery

Trouble with referencing a javascript variable using jquery

I'm trying to animate a div element so that it changes its width. The
problem is that I want it to change its width to a variable that's stored
in a .js file and I'm not sure how to get it to recognize it.
My HTML code:
<section style="width:100%; height:120px; clear:both;" >
<section class="campaign_statistics" style="background-color:#EFEFEF;">
<?php include('progress_chart.php'); ?>
</section>
</section>
Uses include for that php file which contains:
if ($blog_id == 9)
echo
'
<script>
var percent = String(businessProgress.getPercent());
document.write(businessProgress.toString());
</script>
'
;
I defined the variable percent to be referenced in jquery. The .js file
has an object that I made that stores some variables and I made getters to
get their info when needed. The toString() method:
this.toString = function(){
var string = '<div class="campaign_progress" style="width:0%;"> <div
class="campaign_percentage_bar">' + String(this.getPercent()) + '%
Percent Unit Progress</div> <div class="campaign_dollars">$' +
mySlice(this.getCurrent()) + '<span class="goal"> of $' +
mySlice(this.getGoal()) + '</span></div></div>';
return string;
}
Basically builds the div element that I want to animate. The width is set
at 0% and when my jquery is called in the header:
<script>
$(document).ready(function() {
$(".campaign_percentage_bar").animate({width:String(percent)+'%')},
5000);
});
</script>
This is how I'm referencing that variable. I have the script calls in my
header, so that all should be ok. If you can give any suggestions or if I
need to clarify more or give more info, please comment.

Can't access saved game!

Can't access saved game!

A mate of mine was over this weekend and had a go of borderlands 2 - after
he started a new game I can't access my saved game.
I've been on the 'saved data utility' part and the save file is still
there, but I can't access it. I've tried deleting all the other
Borderlands 2 save games and copied the file to the online storage, but
when I start the game I don't get the option to continue the game, just
start a new one.
Does anyone have any ideas?

How to get DI to work in Prism/MEF with a simple class

How to get DI to work in Prism/MEF with a simple class

I understand how DI works in Prism when you have an IModule. However, many
of my classes where I want DI are not modules, they are plain old classes.
If I use the [Import] statement, I never see any injection occur. If I
decorate the class with IModule, I get injection. If anyone is familiar
with the Prism 4.1 Quickstarter, I'm using the 'ModularityWithMef.Desktop'
to demonstrate the problem. I've added this class to the 'ModuleA'
project:
Class1.cs:
namespace ModularityWithMef.Desktop
{
using System;
using System.ComponentModel.Composition;
using ModuleTracking;
public class Class1
{
private IModuleTracker moduleTrackerField;
[Import(typeof(IModuleTracker))]
public IModuleTracker ModuleTracker
{
get
{
return this.moduleTrackerField;
}
set
{
this.moduleTrackerField = value;
}
}
}
}
The setter is never hit. If I decorate it with an [Export] statement, I
can hit the setter, but then I get a message that I need to provide an
'Initialization()' method for any class decorated with an [Export]
attribute. What am I missing here? I see the advantage of using attribute
based DI, but I can't imagine that I have to turn every class I use into
an IModule.

How to find class that contains main method in a package/jar using reflection?

How to find class that contains main method in a package/jar using
reflection?

I am using dynamic class loading which requires the main class for loading
the classes. If i input the package/jar i want to get the class name that
contains main method? Is it possible with Reflection? or is there any
other API?
Thanks in Advance..

Sunday, 18 August 2013

How to judge an object Have been released

How to judge an object Have been released

How to judge an object Have been released?
If the UITableViewCell have been moved out screen, kkcell object will been
autoreleased by UITableView.
When the audiPlayer finished, program will run to " [kkcell
stopSpeakAmination]", this time
the program will crack.
How can i judge an object Have been released?
I also use
if(kkcell)
or
if(kkcell!=nil)
but still crack. my god:( Help me......
KKTableViewCell *kkcell;
(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player
successfully:(BOOL)flag{
[kkcell stopSpeakAmination];
playing=NO;
}

How to boot Ubuntu 606.2 LTS (Dapper Drake) on a Mac G4 Powerbook

How to boot Ubuntu 606.2 LTS (Dapper Drake) on a Mac G4 Powerbook

Does anyone know how to boot Ubuntu 6.06.2 LTS (Dapper Drake) to a Mac g4
Powerbook? I am getting a new Laptop in about 6 months and don't know what
to do this one. I know what version of Ubuntu I need (Mentioned above),
but when I used a DVD+WR Disk I burned with 6.06.2 LTS. It just spits the
disk right out. I cannot get a different kind of disk at the moment. I
just used I Flash Drive installed with the image, but it will not show up
on the boot menu (By pressing alt/option on startup).
Can anyone provide me with a solution to this?

Doesn't accept the list index?

Doesn't accept the list index?

I have this peice of code:
n = int (input ('Enter the Number of Players: '))
m = [[j] for j in range (0, n)]
all_names= []
i = 0
while n > 1:
m[i] = input('Player {0}: '.format (i+1))
all_names.extend ([m[i]])
if m[i][0] != m[i-1][-1]:
b= m.pop (i)
n = n-1
if all_names.count (m[i]) == 2:
n = n-1
b= m.pop (i)
i = i+1
It says the index is out of range (second if clause) but I dont get it, why?

The small dihedral groups $D_1$ and $D_2$.

The small dihedral groups $D_1$ and $D_2$.

In M. Artin's book Algebra he wrote:
But I think this visualisation $D_1$ and $D_2$ is inconsistent and
confusing, because I guess $D_n$ could be associated with a subgroup of
$S(\{1, \ldots, n\})$, i.e. permutations of the $n$ vertices, but in the
case of the $1$-gon there is just one permutation, the identity, and in
the case of the $2$-gon there are just two (identity and one
transposition). Furthermore by a reflection of the $2$-gon in the
horizontal axis it gets projected onto itself (every vertex stays where it
is), so this reflection is actually the identity, and not a separate
element $r \ne 1$. Or does I miss something? Could it be consistent to
look at $D_1$ and $D_2$ in this way?

asmlibrary with OpenCV and MinGW

asmlibrary with OpenCV and MinGW

I am trying to compile code which uses asmlibrary (by Yao Wei) with MinGW
(gcc/g++ 4.7.2), Windows 7, Eclipse CDT (Kepler) , without success. I can
compile same library, windows port (asmlibrary.dll) with MVSC, and author
also published three files (cygasmlibrary-4.dll, libasmlibrary.a,
libasmlibrary.dll.a) which supposedly should work with gcc. When I try to
comppile code which uses asmlibrary, I got this error:
13:06:05 **** Rebuild of configuration Release for project
AsmLibrarySDK_FIT ****
Info: Internal Builder is used for build
g++ "-IC:\\OpenCV246PC\\build\\include" -O3 -Wall -c -fmessage-length=0 -o
demo_fit.o "..\\demo_fit.cpp"
g++ "-IC:\\OpenCV246PC\\build\\include" -O3 -Wall -c -fmessage-length=0 -o
video_camera.o "..\\video_camera.cpp"
g++ "-IC:\\OpenCV246PC\\build\\include" -O3 -Wall -c -fmessage-length=0 -o
vjfacedetect.o "..\\vjfacedetect.cpp"
..\vjfacedetect.cpp: In function 'bool detect_all_faces(asm_shape**, int&,
const IplImage*)':
..\vjfacedetect.cpp:85:11: warning: variable 'pt1' set but not used
[-Wunused-but-set-variable]
..\vjfacedetect.cpp:85:16: warning: variable 'pt2' set but not used
[-Wunused-but-set-variable]
g++ "-LC:\\OpenCV246MinGW\\x86\\lib" "-LC:\\asmlibraryFaceXpress" -o
AsmLibrarySDK_FIT.exe vjfacedetect.o video_camera.o demo_fit.o
-lopencv_calib3d246 -lopencv_contrib246 -lopencv_core246
-lopencv_features2d246 -lopencv_flann246 -lopencv_gpu246
-lopencv_highgui246 -lopencv_imgproc246 -lopencv_legacy246 -lopencv_ml246
-lopencv_nonfree246 -lopencv_objdetect246 -lopencv_photo246
-lopencv_stitching246 -lopencv_video246 -lopencv_videostab246 -lasmlibrary
demo_fit.o:demo_fit.cpp:(.text.startup+0x4c9): undefined reference to
`_imp___ZN10asmfitting12ASMSeqSearchER9asm_shapePK9_IplImageibi'
demo_fit.o:demo_fit.cpp:(.text.startup+0x638): undefined reference to
`_imp__InitShapeFromDetBox'
demo_fit.o:demo_fit.cpp:(.text.startup+0x21c): undefined reference to
`_imp__InitShapeFromDetBox'
demo_fit.o:demo_fit.cpp:(.text.startup+0x286): undefined reference to
`_imp___ZN10asmfitting8Fitting2EP9asm_shapeiPK9_IplImagei'
demo_fit.o:demo_fit.cpp:(.text.startup+0x442): undefined reference to
`_imp___ZN10asmfitting12ASMSeqSearchER9asm_shapePK9_IplImageibi'
demo_fit.o:demo_fit.cpp:(.text.startup+0x58c): undefined reference to
`_imp__InitShapeFromDetBox'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe:
demo_fit.o: bad reloc address 0x0 in section `.ctors'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe:
final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
I asked author about this and he replied to me as follows:
just link like libasmlibrary.a not -lasmlibrary
what I don't understand. Even if I try from command line, g++ won't accept:
C:\Users\Nenad\eclipseCDT\opencv2cookbook\AsmLibrarySDK_FIT\Debug>g++
"-LC:\\OpenCV246MinGW\\x86\\lib" "-LC:\\asmlibraryFaceXpress" -o
AsmLibrarySDK_FIT.exe vjfacedetect.o video_camera.o demo_fit.o -l
opencv_calib3d246 -lopencv_contrib246 -lopencv_core246
-lopencv_features2d246 -lopencv_flann246 -lopencv_gpu246
-lopencv_highgui246 -lopencv_imgproc246 -lopencv_legacy246 -lopencv_ml246
-lopencv_nonfr
ee246 -lopencv_objdetect246 -lopencv_photo246 -lopencv_stitching246
-lopencv_video246 -lopencv_videostab246 libasmlibrary.a
(error is same as on top of post) if I try to put -libasmlibrary.a (the of
course) I got:
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe:
cannot find -llibasmlibrary.a
libasmlibrary gives me g++: error: libasmlibrary: No such file or directory
and so on...
As far as I know the only correct way to link this library would be to use
-lasmlibrary but then it produces the error mentioned at the top.
BTW, even if I don't include that library at all, I got this error anyway.
Then I asked author again, and he replied to me:
Code like this g++ a.c -o test libasmlibrary.a -lopencv_library
And even if I do that way (or at least I think I understood him) it yields
same result. Of course I even copied (cygasmlibrary-4.dll,
libasmlibrary.a, libasmlibrary.dll.a) into debug directory.
g++ "-LC:\\OpenCV246MinGW\\x86\\lib" "-LC:\\asmlibraryFaceXpress" -o
AsmLibrarySDK_FIT.exe vjfacedetect.o video_camera.o demo_fit.o
libasmlibrary.a -lopencv_calib3d246 -lopencv_contrib246 -lopencv_core246
-lopencv_features2d246 -lopencv_flann246 -lopencv_gpu246
-lopencv_highgui246 -lopencv_imgproc246 -lopencv_legacy246 -lopencv_ml246
-lopencv_nonfree246 -lopencv_objdetect246 -lopencv_photo246
-lopencv_stitching246 -lopencv_video246 -lopencv_videostab246
Settings in Eclipse itself are as follows:


Probably this is a newbie question, but I am totally stuck with this. What
should I do to make it compile?

SQLite syntax error in create table method

SQLite syntax error in create table method

logcat says thare is a SQLite error near the word "table" in the database
class here. I looked over this code and I don't see any ayntax arrors , am
i missing something?
Database class
public class Database {
public static final String DATABASE = "tester";
public static final int DATABASE_VERSION = 1;
public static final String TABLENAME = "table";
public static final String _ID = "_id";
// collumns
public static final String SAMPLE = "sample";
private static final String SCRIPT_CREATE_TABLE =
"CREATE TABLE IF NOT EXISTS " + TABLENAME + " (" + _ID + " INTEGER
PRIMARY KEY AUTOINCREMENT, " +
SAMPLE + " TEXT)";
SQLiteDatabase sqLiteDatabase;
SQLiteHelper sqLiteHelper;
Context context;
public Database(Context c){
context = c;
}
public void openToRead() throws android.database.SQLException {
sqLiteHelper = new SQLiteHelper(context, DATABASE, null,
DATABASE_VERSION);
sqLiteDatabase = sqLiteHelper.getReadableDatabase();
}
public void openToWrite() throws android.database.SQLException {
sqLiteHelper = new SQLiteHelper(context, DATABASE, null,
DATABASE_VERSION);
sqLiteDatabase = sqLiteHelper.getWritableDatabase();
}
public void close(){
sqLiteHelper.close();
}
public void deleteDB(){
context.deleteDatabase(DATABASE);
}
public void insert(){
ContentValues contentValues = new ContentValues();
contentValues.put(SAMPLE, "TEST ONE");
sqLiteDatabase.insert(TABLENAME, null, null);
}
public String get(){
String returnString = "";
Cursor cursor = sqLiteDatabase.query(TABLENAME, new
String[]{SAMPLE}, null, null, null, null, null);
if(cursor!=null){
cursor.moveToFirst();
returnString =
cursor.getString(cursor.getColumnIndex(SAMPLE));
}
return returnString;
}
public class SQLiteHelper extends SQLiteOpenHelper {
public SQLiteHelper(Context context, String name,
CursorFactory factory, int version) {
super(context, name, factory, version);
}
// onCreate of the SQLiteOpenhelper only called if the
database does not already exist
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(SCRIPT_CREATE_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion,
int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " +
SCRIPT_CREATE_TABLE);
onCreate(db);
}
}
}
MainAcivity class
public class MainActivity extends Activity {
TextView textViewOne;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textViewOne = (TextView) findViewById(R.id.textView1);
Database db = new Database(this);
db.openToWrite();
db.insert();
db.close();
db.openToRead();
String getStr = db.get();
db.close();
textViewOne.setText(getStr);
}
}

Saturday, 17 August 2013

How to enable Normal Scrolling on MacBookPro 10.8.3?

How to enable Normal Scrolling on MacBookPro 10.8.3?

Small or incremental scrolling on my MBP OSX 10.8.3 using an external
mouse is extremely slow to a crawl. How do I configure my mouse to a
Normal Scroll mode where every scroll is the same and creates fast scrolls
in the window?

AttributeError: module object has no attribute "Series". Code works in iPython

AttributeError: module object has no attribute "Series". Code works in
iPython

This is going to be downvoted, and trolled to no end.
Submodules aren't implicitly imported, and must be explicitly declared,
but I'm making an explicit call to the pd.Series submodule, aren't I?
Regardless, shouldn't import pandas as pd allow for pd.Series to be
called? The following code works flawlessly in iPython, but fails when
executed from a script.
#!/usr/bin/env/python2.7
# -*- coding: utf-8 -*-
import pandas as pd
import numpy as np
counts = pd.Series([632, 1638, 569, 115], index=["Firmicutes",
"Proteobacteria", "Actinobacteria", "Bacteroidetes"])
Results in:
tyler@machine ~/src/stats $ python pandas.py
Traceback (most recent call last):
File "pandas.py", line 3, in <module>
import pandas as pd
File "/home/tyler/src/stats/pandas.py", line 6, in <module>
counts = pd.Series([632, 1638, 569, 115], index=["Firmicutes",
"Proteobacteria", "Actinobacteria", "Bacteroidetes"])
AttributeError: 'module' object has no attribute 'Series'
Where have I gone wrong?

Which operation I should use to work with this string?

Which operation I should use to work with this string?

I have a string "1, 5, 10-14" How can I get this situation:
NSString MyString;
NSString value1, value2;
NSMutableArray value3;
MyString = "1, 5, 10-14";
//Some operations that I needed
value1 = "1";
value2 = "5";
value3[0] = "10";
value3[1] = "11";
value3[2] = "12";
value3[3] = "13";
value3[4] = "14";
Thanks!

VS2012 MSBuild: Publish a Web Application Project with Existing Publish Profile

VS2012 MSBuild: Publish a Web Application Project with Existing Publish
Profile

In the Visual Studio 2012 Build menu, there's a Publish command. In this
you can establish profiles which are saved as .pubxml files in the
Properties folder of the Project. I have one such profile that's a simple
file copy operation - it just compiles the site and dumps it to a folder.
How can I use msbuild at the command line to publish a compiled web
application to a folder?



What I've tried
I've tried the example from this question:
After Publish event in Visual Studio
And the changes and examples given here:
http://www.digitallycreated.net/Blog/59/locally-publishing-a-vs2010-asp.net-web-application-using-msbuild
The latter seems to get closest, but it causes every library Project the
.csproj I'm attempting to publish from to throw an error:
Project "MainProj.csproj" (1) is building "ReferencedProj.csproj" (2) on
node 1 (default targets).
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(609,5):
error : The OutputPath property is not set for project
'ReferencedProj.csproj'. Please check to make sure that you have specified
a valid combination of Configuration and Platform for this project.
Configuration='Staging' Platform='AnyCPU'. You may be seeing this message
because you are trying to build a project without a solution file, and
have specified a non-default Configuration or Platform that doesn't exist
for this project. [ReferencedProj.csproj]
Done Building Project "ReferencedProj.csproj" (default targets) -- FAILED.
This approach is very similar to what's suggested in this answer:
http://stackoverflow.com/a/7077178/176877
The crucial difference may be that I'm in Visual Studio 2012, rather than
VS2008 or 2010.

Why is only the text clickable in this div?

Why is only the text clickable in this div?

I am trying to create a div that is a button by putting an anchor inside a
div.
HTML
<div class="div1" style="width:300px;">
<a href="#">hello</a>
</div>
CSS
.div1 {
background-color:red;
color:white;
margin:5px;
border-width:5px;
border-style:solid;
padding:10px;
border-radius:5px;
text-align:center;
background: #494949 !important;
}
JSFiddle: http://jsfiddle.net/BzFyS/
I think it is not working because osomething simple I am missing with
positioning. Any tips?
Thanks

How can I use my vmware virtual machine in my network?

How can I use my vmware virtual machine in my network?

I want to use my virtual machine(created in vmware) in my network? how can
I do that?
PS : I am using NAT connection in vmware, as you know we have several
network adapters in vmware virtual machine but I Don't know what are their
meaning(NAT,auto bridge,...)? please explain me what they are? and ...

Detecting touch devices from css

Detecting touch devices from css

I have a web page where I use the :hover psuedo-class just a few places,
because I don't want to clutter the interface.
Obviously, on touch devices I must remove the :hover, so I do the following:
all.css:
.button {
display: block;
}
hover.css:
.button {
.display: none;
}
.frame:hover .button {
.display: block
}
Does CSS offer any way to activate the hover definitions only on touch
devices?
I know you can test for "TouchEvent" in JavaScript, or do crazy regular
expression matches on the User Agent string on the server, but can CSS do
it?
(If it is not possible with CSS, what would you do with JavaScript? Simply
append the hover definitions into the <style> tag after doing the test?)

Friday, 16 August 2013

java String constructor logic

java String constructor logic

I was trying to understand how a java String was implemented.The jdk7
source code below shows a check for originalValue.length > size .I cant
figure out how/when it would come true.I tried to use eclipse debugger on
some java String creation statements,but this check was never true.Is it
possible to devise a String argument which would make this check true?
public final class String{
/** The value is used for character storage. */
private final char value[];
/** The offset is the first index of the storage that is used. */
private final int offset;
/** The count is the number of characters in the String. */
private final int count;
/** Cache the hash code for the string */
private int hash; // Default to 0
/**
* Initializes a newly created {@code String} object so that it
represents
* the same sequence of characters as the argument; in other words, the
* newly created string is a copy of the argument string. Unless an
* explicit copy of {@code original} is needed, use of this
constructor is
* unnecessary since Strings are immutable.
*
* @param original
* A {@code String}
*/
public String(String original) {
int size = original.count;
char[] originalValue = original.value;
char[] v;
if (originalValue.length > size) {
// The array representing the String is bigger than the new
// String itself. Perhaps this constructor is being called
// in order to trim the baggage, so make a copy of the array.
int off = original.offset;
v = Arrays.copyOfRange(originalValue, off, off+size);
} else {
// The array representing the String is the same
// size as the String, so no point in making a copy.
v = originalValue;
}
this.offset = 0;
this.count = size;
this.value = v;
}
...
}