Sunday, 1 September 2013

Swing - text input and ouput to text area

Swing - text input and ouput to text area

I want to make simple GUI with Swing, which will have 2 input text fields
and a button.
Based on the input the program will fetch name/rol-no/age/emailid from
table and need to show into a text area below in the same screen. The text
area should be scrollable. I want input/output to be in the same screen.
Could some one tell which layout will be ideal for this?
---------------------------------------------------------------------------
School(label1):textfield1____
class(label2):textfield2____
SUbmit(Button1)
name(label2) roll-no(label3) age(label4) email-id(label5)
row-1 -----
row-2 ----
row-3 ----
row-4 ----
..
..
row-nth ---
----------------------------------------------------------------------------

Solr web interface query with hyphen

Solr web interface query with hyphen

I have a schema created by haystack for indexing books and authors in Solr
4.3 When performing a search, all works fine except for search-terms
including a hyphen.
I know you must escape them by using a backslash but even with the solr
web interface i am not able to find the correct docs.
As illustrated in the screenshots below, there is an author named Ukiyo-E
which can be found by using full_name:(ukiyo). When entering
full_name:(ukiyo-e) or full_name:(ukiyo-e), i can't find anything.

ext.NET accordion is not working correctly (MVC)

ext.NET accordion is not working correctly (MVC)

Could someone please point me in the right direction here, I've spent
hours on this!
I am trying to create a West region Container that contains an image fixed
in height, with an accordion control below that takes up the rest of the
vertical space.
Every time I try this, the accordion control does not work properly. It
renders with the top node expanded, and all the other nodes jammed up
together (not at the bottom). Also, when you start using the accordion, it
just seems to stop reacting to user clicks completely. My suspicion is the
way I am laying out the control (I am new to ext.NET).
I have created a class that supplies to the view the ext.NET control. The
function that returns the West region returns an ext.NET Container.
ext.Image image = new ext.Image
{
ImageUrl = "~/resources/images/welcome-screens.png",
Height = 200,
};
ext.Container outer = new ext.Container
{
Border = true,
Region = ext.Region.West,
Width = 200,
Split = true
};
outer.Items.Add(image);
ext.Panel acc = new ext.Panel
{
Title = "ACCORDION PANEL",
Layout = ext.LayoutType.Accordion.ToString()
};
acc.Items.Add(new ext.Panel { Title = "TEST1", Items = { new
ext.Panel { Title = "a" }, new ext.Panel { Title = "b" } }
});
acc.Items.Add(new ext.Panel { Title = "TEST2", Items = { new
ext.Panel { Title = "c" } }});
acc.Items.Add(new ext.Panel { Title = "TEST3", Items = { new
ext.Panel { Title = "d" } }});
acc.Items.Add(new ext.Panel { Title = "TEST4", Items = { new
ext.Panel { Title = "e" } }});
acc.Items.Add(new ext.Panel { Title = "TEST5", Items = { new
ext.Panel { Title = "f" } } });
outer.Items.Add(acc);
Any pointers or advice would be really welcome. Thanks.

Saturday, 31 August 2013

Using ConcurrentHashMap efficiently?

Using ConcurrentHashMap efficiently?

I have a Android Application whose core component is a
HashMap<String,float[]>. The System is having high concurrency. e.g here
are the following three situations I have which occur frequently and they
are highly overlapping in nature
Iterate through all the keys in the hashmap and do some operation on its
value(read only operations).
Add new key,value pairs in the Hashmap.
Remove Certain keys from the Hashmap.
I do all these operations in different threads and thus am using a
ConcurrentHashMap since some inconsistency in retrievals doesnt matter.
e.g While iterating the map,if new entries are added then it doesnt matter
to not read in those new values immediately as I ensure that next time
they are read .
Also while removing the entries I am recreating the iterator everytime to
avoid "ConcurrentModificationException"
Suppose , there is a following hashmap(i.e ConcurrentHashmap)
ConcurrentHashMap<String,float[]> test=new ConcurrentHashMap<String,
float[]>(200);
Now for Retrieval I do the following
Iterator<String> reader=test.keySet().iterator();
while(reader.hasNext())
{
String s=reader.next();
float[] temp=test.get(s);
//do some operation with float[] temp here(read only
operation)
}
and for removal I do the following
boolean temp = true;
while (temp) {
for (String key : test.keySet()) {
temp = false;
if (key.equals("abc")) {
test.remove(key);
temp = true;
break;
}
}
}
and when inserting in new values I simply do
test.put("temp value", new float[10]);
I am not sure if its a very efficient utilisation. Also it does matter not
to read in removed values(however I need efficiency ,and since the
iterator is again created during the function call,its guaranteed that in
the next time I don't get the removed values)so that much inconsistency
can be tolerated?
Could someone please tell me an efficient way to do it?

PHP simple html insertion on a large switch statement

PHP simple html insertion on a large switch statement

In bootstrap 3 we have this <li> class set to active in order to display
the current page highlighted on the navbar
<li class="active">
<a href="linkaddress.html">Link</a>
</li>
the problem is when you are including the menu via include
'includes/header.php'; on all your pages. i cant figure out how to put
together a switch statement on the $actual_link and bring back some sort
of call to insert the class active in the right place. this my so far
attempt and im honestly stuck because i feel there is a better way. how
can i can i put the li class to active with this switch
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$HTTPHost = $_SERVER[HTTP_HOST];
switch($actual_link)
{
case "http://{$HTTPHost}/index.php" ||
"http://{$_SERVER[HTTP_HOST]}/admin.php?edit_home":
echo '<title>'..'</title>';
echo '<meta name="description" content="'..'">';
break;
case "http://{$HTTPHost}/warrants.php" ||
"http://{$_SERVER[HTTP_HOST]}/admin.php?edit_warrants":
echo '<title></title>';
echo '<meta name="description" content="'..'">';
break;
case "http://{$HTTPHost}/faq.php" ||
"http://{$_SERVER[HTTP_HOST]}/admin.php?edit_faq":
echo '<title></title>';
echo '<meta name="description" content="'..'">';
break;
case "http://{$HTTPHost}/aboutus.php" ||
"http://{$_SERVER[HTTP_HOST]}/admin.php?edit_aboutus":
echo '<title></title>';
echo '<meta name="description" content="'..'">';
break;
}
?>

Express + Angular routing causing infinite loop + crash

Express + Angular routing causing infinite loop + crash

I'm work on a Node app using Express as well as Angular. I'm using Angular
for routing and have my routes setup like so:
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/', {
templateUrl: '/partials/main'
//controller: 'IndexController'
}).when('/discover', {
templateUrl: '/partials/discover'
}).when('/user/home', { //HERES THE PROBLEM CHILD!!!!!
templateUrl: '/partials/user/home'
}).otherwise({
redirectTo: '/'
});
}]).config(['$locationProvider', function ($locationProvider) {
$locationProvider.html5Mode(true);
}]);
Now, whenever I try and call /user/home -- The page goes into an infinite
loop and keeps reloading the controller. I can see in the node console
that the page was called from partials/user/home which definitely contains
a Jade file. I've checked other posts, most of them are solved with ass
the / in the beginning of the partials path, that didn't help here. The
page loads fine if I transfer home.jade into the /partials directory with
no sub directory. Any ideas?

Troubles with variables and Define()

Troubles with variables and Define()

So I've created many projects prior to this one without issue, but I'm
encountering a weird problem when it comes to accessing variables that
were Define()'d in my config.php. As an example, in index.php (without any
content) I have:
<!DOCTYPE html>
<html>
<?php require "config.php";
include PARTIALS."/head.php"; ?>
<body>
<?php include PARTIALS."/header.php"; ?>
<div id="content">
</div>
<?php include PARTIALS."/footer.php"; ?>
</body>
</html>
The head, header, and footer files are all properly included. However, if
I try to echo PARTIALS or SITE_ROOT, I get an error:
Notice: Use of undefined constant SITE_ROOT - assumed 'SITE_ROOT' in
C:\xampp\htdocs\robinson\partials\header.php on line 9
My config.php is as follows:
<?php
session_start();
ini_set( "display_errors", true);
define('SITE_ROOT', "http://localhost/robinson");
define('PARTIALS', SITE_ROOT."/partials");
define('DB_HOST', "localhost" );
define('DB_NAME', "local");
define('DB_USER', "localuser" );
define('DB_PASS', "localpass" );
?>
As I mentioned, I've created many test projects that follow the exact same
logic. And the weird part is that the pages are being properly included,
so the variable is "working" to an extent. I've compared my code against
"functioning" projects and haven't found any differences, so can anybody
explain what the issue might be?
Related Question
Assuming I don't route every page through index.php, is there a best way
to include config.php? I really don't want to have to manually change
pathnames to it in every subsequent page, nor include it on each of those
pages. So is there a best practice when it comes to doing this?
Thanks in advance.