Thursday, 3 October 2013

Changing progressbar level

Changing progressbar level

I have a simple activity that is suppose display a progress bar with
different fill levels. This activity with the progress bar is display
after a student undertake a practice test on my mobile application. So the
progess bar would show if the student passed showing all blue with the
color filling it. if it is an average performance. The color is half
filled in green. If it is a poor performance the color is completely red
with a slight color fill.
My little code to set fill color is below but it not working
if(grade.equals("passed")){
setProgress(100);
}
else{
setProgress(50);
}

Wednesday, 2 October 2013

how to undo hijacked files in clearcase?

how to undo hijacked files in clearcase?

I have this strange hijacked file in my snapshot view. when I undo it, it
doesn't go away. Is there a way to un-hijack it. I already tried
undo-hijacked but didn't work. I should see .keep file if it unhijacked
but didn't see any. Also tried to check out and uncheck out but this file
still remains as hijacked.
Thanks for any help !!

Multiple Variable Assignment from Single Hash Ruby

Multiple Variable Assignment from Single Hash Ruby

Hello All This seems like a day 1 question, And I feel like I've had it
working before, but for some reason I'm at a loss. But I'm trying to have
an Array assign a value to two variables.
test = "hello, my,name,is,dog,how,are,you"
testsplit = test.split ","
testsplit.each do |x,y|
puts y
end
I would think that it would print my is how you
but it appears the values only get passed to x and not to y. When i run
this code y comes back as empty.

How to pass an ID from a repeater row to a nested gridview?

How to pass an ID from a repeater row to a nested gridview?

QUESTION
If you have a gridview inside a repeater, how do you pass a primary key ID
to the gridview where the primary key relates to the repeaters item
template row?
I am currently attempting to do this by using a hiddenfield that contains
the PK and a control parameter to detect it and bind it to the gridview.
CURRENT ERROR
Could not find control 'hidPK' in ControlParameter 'PK'.
ABBREVIATED CODE
<asp:Repeater ID="rpt" RunAt="Server">
<ItemTemplate>
<asp:HiddenField ID="hidPK" runat="server" Value='<%#
DataBinder.Eval(Container.DataItem, "PK") %>'/>
<asp:GridView DataSourceID="sqlSource"></asp:GridView>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="sqlSource" RunAt="Server"
SelectCommand="spPopulateGridview" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter Type="Int32" Name="PK" DefaultValue="0"
ControlID="hidPK"/>
</SelectParameters>
</asp:SqlDataSource>

Tuesday, 1 October 2013

Spring Data REST: Silent failure when adding entity relationship

Spring Data REST: Silent failure when adding entity relationship

Fellow Spring Data REST enthusiasts, I am running my Spring Data REST 1.1
application, and I am attempting use curl to add an entity relationship
using the "text/uri-list" Content-type, as described in the link:
Example-API-usage-with-curl.
curl -v -d "http://localhost:8080/simplemvc/rest/enemies/3" -H
"Content-Type: text/uri-list"
http://localhost:8080/simplemvc/rest/heroes/1/defeatedEnemies
Unfortunately, although the server returns "201 Created", the body
contains an empty JSON object, and the entity relationship does not get
created:
{
"links" : [ ],
"content" : [ ]
}
I would expect to see a SQL UPDATE being executed, but analyzing the SQL
reveals that only SELECT statements occur:
Hibernate: select hero0_.HERO_ID as HERO1_1_0_, hero0_.name as name2_1_0_
from HERO hero0_ where hero0_.HERO_ID=?
Hibernate: select defeateden0_.HERO_ID as HERO4_1_1_,
defeateden0_.ENEMY_ID as ENEMY1_0_1_, defeateden0_.ENEMY_ID as
ENEMY1_0_0_, defeateden0_.description as descript2_0_0_,
defeateden0_.HERO_ID as HERO4_0_0_, defeateden0_.name as name3_0_0_ from
ENEMY defeateden0_ where defeateden0_.HERO_ID=?
Hibernate: select enemy0_.ENEMY_ID as ENEMY1_0_1_, enemy0_.description as
descript2_0_1_, enemy0_.HERO_ID as HERO4_0_1_, enemy0_.name as name3_0_1_,
hero1_.HERO_ID as HERO1_1_0_, hero1_.name as name2_1_0_ from ENEMY enemy0_
left outer join HERO hero1_ on enemy0_.HERO_ID=hero1_.HERO_ID where
enemy0_.ENEMY_ID=?
Interestingly, if I "manually" add a relationship by executing a SQL
statement in my database client:
UPDATE ENEMY SET HERO_ID = 1 WHERE ENEMY_ID = 1;
and then execute the curl statement:
curl -v -H "Accept: application/json"
http://localhost:8080/simplemvc/rest/heroes/1/defeatedEnemies
I get a JSON representation that demonstrates -- via hypermedia links --
that Spring Data REST recognizes the one-to-many relationship between the
Hero and Enemy entities:
{
"links" : [ ],
"content" : [ {
"name" : "Red Ghost",
"description" : "Likes to chase",
"links" : [ {
"rel" : "self",
"href" : "http://localhost:8080/simplemvc/rest/enemies/1"
}, {
"rel" : "enemy.enemy.hero",
"href" : "http://localhost:8080/simplemvc/rest/enemies/1/hero"
} ]
} ]
}
This is an existing Spring MVC app to which Spring Data REST is being
added, using the following article as a guide:
Adding-Spring-Data-REST-to-an-existing-Spring-MVC-Application
I have tried using both H2 and MySQL databases with the same result. Below
are my JPA entities, Spring Data JPA Repositories, application context,
and web.xml:
Hero.java
@Entity
@Table(name = "HERO")
public class Hero {
@TableGenerator(
name="heroGen",
table="ID_GEN",
pkColumnName="GEN_KEY",
valueColumnName="GEN_VALUE",
pkColumnValue="HERO_ID",
allocationSize=1)
@Id
@GeneratedValue(strategy=TABLE, generator="heroGen")
@Column(name = "HERO_ID")
private Integer id;
@Column
private String name;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy
= "hero")
private Set<Enemy> defeatedEnemies;
...
}
Enemy.java
@Entity
@Table(name = "ENEMY")
public class Enemy {
@TableGenerator(name="enemyGen",
table="ID_GEN",
pkColumnName="GEN_KEY",
valueColumnName="GEN_VALUE",
pkColumnValue="ENEMY_ID",
allocationSize=1)
@Id
@GeneratedValue(strategy=TABLE, generator="enemyGen")
@Column(name="ENEMY_ID")
private Integer id;
@Column
private String name;
@Column
private String description;
@ManyToOne
@JoinColumn(name = "HERO_ID")
private Hero hero;
...
}
HeroRepository.java
@RestResource(path = "heroes")
public interface HeroRepository extends CrudRepository<Hero, Integer> {
}
EnemyRepository.java
@RestResource(path = "enemies")
public interface EnemyRepository extends CrudRepository<Enemy, Integer> {
}
root-context.xml includes:
<jpa:repositories base-package="com.simple.simplemvc.repositories" />
<bean id="restConfig"
class="org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration"/>
web.xml includes:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<servlet>
<servlet-name>rest-dispatcher</servlet-name>
<servlet-class>org.springframework.data.rest.webmvc.RepositoryRestDispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>rest-dispatcher</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
Any ideas? Thanks!

On success of ajax post, how to send a POST request with JQuery .load() method

On success of ajax post, how to send a POST request with JQuery .load()
method

After a successful Ajax post, I would like the template associated with
POST in the handler to be rendered with JQuery's .load() method. The GET
request keeps getting called after a successful POST ...so the template
associated with GET is getting rendered instead of the one associate with
POST. Thanks for any hints you can give.
Javascript:
$(function() {
$(".topic_submit").click(function() {
var topic = $("#topic").val();
refresh = 'false'
$.ajax({
type: "POST",
url: "/mentorlist",
data: {'topic': topic},
success: function(dataString) {
$('#mentor_list').load('/mentorlist');
console.log('**mentor_list div updated via ajax.**');
}
});
return true;
});
});
HTML Form:
<form id="topic_search_form" name="topic_search_form" action="">
Topic: <input id ="topic" type="text" name="topic" size="60"
placeholder="Search by Keyword" />
<input type="submit" class="topic_submit" name="topic_submit"
value="Search" >

Camera not working but camera light is on when trying to use it

Camera not working but camera light is on when trying to use it

I can't use my camera in Google hangout, I can share desktop in Google
Hangout and it works fine but camera never works, it looks like this

I have also tried using Cheese and i also just get a back screen. The
light beside my camera is on when using Google Hangout or Cheese.
Does anyone know how to fix this?

Integral of natural log function using substitution

Integral of natural log function using substitution

$$\int_{2} ^{4}\dfrac{dx}{x(lnx)^2}$$
Here is what I did:
$$u=lnx, du=\dfrac{dx}{x}$$
$$\int_{2} ^{4}u^{-2}du$$
$$(-1)u^{-1} |_{2}^{4}$$
$$-\dfrac{1}{lnx}|_{2}^{4}$$
$$-\dfrac{1}{ln4} + \dfrac{1}{ln2}$$
However the answer in the back of my textbook says that the answer is
$\dfrac{1}{ln4}$. I have went over my work a couple of times and I cannot
see what I did wrong. Could someone please explain what's wrong here?
Thank you.

Monday, 30 September 2013

Are Fresnel lenses widely used for solar electricity=?iso-8859-1?Q?=3F_If_not=2C_why_not=3F_=96_physics.stackexchange.com?=

Are Fresnel lenses widely used for solar electricity? If not, why not? –
physics.stackexchange.com

I was just wondering why Fresnel Lenses are not widely used in the
production of solar electricity. Their use there would mean that you could
produce heat within a fraction of a second, up to a few …

What's going on with "Potential Stack Overflow Revenue Models"? – meta.stackoverflow.com

What's going on with "Potential Stack Overflow Revenue Models"? –
meta.stackoverflow.com

There is a deleted question that has been linked to by this post, and from
the title, it seems to be of historical significance. However, I don't
have 10k, so I will need someone else to read it for …

Hotkey control keycodes confusion

Hotkey control keycodes confusion

HKM_GETHOTEKY returns virtual key code and modifiers but they're not the
same as the ordinary virtual key codes? What is the purpose of HOTKEYF_EXT
and how do i use it?
If i press F5 the hotkey control returns 0x74 which is VK_F5, but when i
press the right arrow key, it returns 0x27 which is VK_RIGHT and the
HOTKEYF_EXT bit is set on the modifier. If i use HKM_SETHOTKEY with
VK_RIGHT as virtual key and no modifiers, it shows "Num 6"
I find this very strange and I need to be able to pass any virtual keys to
the hotkey control window, and therefore i need to understand this
HOTKEYF_EXT modifier.

simple coursor adapter with sqlite database and custmize listview

simple coursor adapter with sqlite database and custmize listview

i m confused here where is the actual error .i want to display the record
from sqlite db in to listview using simple coursor adapter .there is no
fild like _id in my sqlite databas !! but the error is regarding that,
which i mention below: Error:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.blundell.tut/com.blundell.tut.ui.phone.update_page}:
java.lang.IllegalArgumentException: column '_id' does not exist
my java files are mention here..thanx in advance and if any suggestion
then plz comment it.
update_page.java
public class update_page extends Activity
{
DatabaseHandler db = new DatabaseHandler(this);
public String tableName = db.TABLE_CONTACTS;
public String databaseName = db.DATABASE_NAME;
public String task_name = db.KEY_TASK;
public String dt = db.KEY_DATETIME;
private ArrayList<String> results = new ArrayList<String>();
private ArrayList<String> results2 = new ArrayList<String>();
Intent op_intent;
SQLiteDatabase database;
ListView myview;
Cursor c;
String o_name,o_no1;
//String o_id1 = null;
HttpClient client;
Integer op_id,status;
String url;
Context ctx;
Intent myintent;
final MainActivity act = new MainActivity();
public void onCreate(Bundle savedInstanceState)
{
ctx=this;
database = act.getInstance().openOrCreateDatabase("contactsManager",
SQLiteDatabase.CREATE_IF_NECESSARY, null);
Toast.makeText(getApplicationContext(), "Database is open",
1500).show();
final String[] columnsone={"id","task_name","date_time"};
String[] columnstwo={"task_name","date_time"};
int to[] = {R.id.lbl_task,R.id.lbl_datetime};
c = database.query("contacts", columnsone, null, null, null,
null, null);
status=c.getCount();
if(status==0)
{
AlertDialog.Builder alertDialogBuilder = new
AlertDialog.Builder(ctx);
// set title
alertDialogBuilder.setTitle("No task are created !!");
// set dialog message
alertDialogBuilder
.setMessage("Click cancle to exit!")
.setCancelable(false)
.setNegativeButton("Cancle",
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface
dialog,
int id) {
// if this button is clicked, just
close
// the dialog box and do nothing
dialog.cancel();
myintent = new
Intent(update_page.this,MainActivity.class);
startActivity(myintent);
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
else
{
Toast.makeText(getApplicationContext(), "records are
available in courser", 1500).show();
if(c!=null)
{
Toast.makeText(getApplicationContext(), "in courser",
1500).show();
SimpleCursorAdapter adapter=new
SimpleCursorAdapter(this.ctx,R.layout.update_listview,
c, columnstwo, to);
Toast.makeText(getApplicationContext(), "records are in
list", 1500).show();
myview.setAdapter(adapter);
}
}
update_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<!-- <ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#404040"
android:fillViewport="true" > -->
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.68"
android:divider="#000000"
android:dividerHeight="2dp"
android:background="#404040">
</ListView>
<!-- </ScrollView> -->
</LinearLayout>
**update_listview.xml**
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/lbl_task"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="Medium Text"
android:textColor="#1E90FF"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/lbl_datetime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>

Sunday, 29 September 2013

There is no build provider registered for the extension '.dll'.

There is no build provider registered for the extension '.dll'.

I'm trying to reference to a .dll file from a .aspx web page. However, I
get the following error:
Description: An error occurred during the parsing of a resource required
to service this request. Please review the following specific parse error
details and modify your source file appropriately.
Parser Error Message: There is no build provider registered for the
extension '.dll'. You can register one in the
<compilation><buildProviders> section in machine.config or web.config.
Make sure is has a BuildProviderAppliesToAttribute attribute which
includes the value 'Web' or 'All'.
Source Error:
Line 2: <%@ Page Title="" Language="C#"
MasterPageFile="CSharpBPTestMaster.master" AutoEventWireup="true"
CodeFile="CSharpBPTest.aspx.cs" Inherits="Button" Debug="true"%>
Line 3:
Line 4: <%@ Register tagprefix="blnc" tagname="Balanced"
src="bin/Debug/BalancedTest.dll" %>
Line 5:
Line 6:
Source File:
/preview/1/balanced-csharp-master/src/BalancedTest/CSharpBPTest.aspx
Line: 4
I'm not sure what I'm doing wrong. I build the .csproj file. I have the
following in bin\Debug\:
Balanced.dll
Balanced.pdb
BalancedTest.dll
BalancedTest.pdb
Here is my CSharpBPTest.aspx:
<%@ Page Title="" Language="C#"
MasterPageFile="CSharpBPTestMaster.master" AutoEventWireup="true"
CodeFile="CSharpBPTest.aspx.cs" Inherits="Button" Debug="true"%>
<%@ Register tagprefix="blnc" tagname="Balanced"
src="bin/Debug/BalancedTest.dll" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<form id="form1" runat="server">
<div>
<asp:Button ID="button1" runat="server" Text="Submit"
OnClick="Button_Command"/>
<br />
<br />
<br><asp:label id="warningLabel" Text="" ForeColor="Red"
runat="server"/><br>
<br />
</div>
</form>
</asp:Content>
And in my C# file, I "import" the project like this (at the top):
using Balanced;
I want to be able to use this compiled .dll file on my C# side. The
Balanced.dll is an external library. It just came with the files and a
.csproj file. I did a build and now I'm trying to use this Balanced.dll
file. Am I missing something? I'm sorry if this is a bad question. I'm new
to asp.net and csproj.

bash backup script error

bash backup script error

So I'm writing a simple backup script that when called will either back up
a specific file or all the files in my current directory into my backup
directory. This is my script
#!/bin/bash
#verify if $1 is empty, if so, copy all content to backup directory
if [ -z "$1" ] then
$files=ls
#Looping through files
for file in $files
do
cp $file ../backup/
done
#else copy files specified
else
$files=ls $1
#Looping through files
for file in $files
do
cp $file ../backup/
done
fi
and the only error I'm getting is: ./backup: line 7: =ls: command not found
I'm not sure why the script won't recognize ls as a command. Any ideas?

How to synchronize different java programs to access a common resource

How to synchronize different java programs to access a common resource

I am trying to synchronize instances of a class that access a common
resource(database). This can be done by using notify and wait() but i need
to know that if different java programs are using this class for creating
instances than how can synchronize them. Thank you

Saturday, 28 September 2013

Forward Declaring enum class not working

Forward Declaring enum class not working

In State.h I have
namespace States
{
enum class ID : unsigned int;
}
In State.cpp I have
namespace States
{
enum class ID : unsigned int
{
NullID = 0,
MainMenuID,
GamePlayID,
}
}
The problem is that any class that includes State.h has the forward
declaration, but I can't use any actual enum within a cpp file, like
States::ID::MainMenuID . The error says...
/home/lee/Projects/SuddenAwakening/Source/Game.cpp:24: error: 'MainMenuID'
is not a member of 'States::ID'
I'm running LinuxMint15KDE, g++ 4.7, and I am using c++11 features in
other parts like nullptr, unique_ptr, ect..., so it's not that I forgot
the compiler flag for c++11.

Incorrect return type from an ArrayList of an ArrayList

Incorrect return type from an ArrayList of an ArrayList

I have an array list of an array list that should be full of Integers, but
when I try to compile the program, I get an error stating that it cannot
add numbers to it because of incompatible operand types Object and Int.
Any help would be appreciated!
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class main{
public static void main(String[] args){
int ntt = 20;
ArrayList<Integer> Factors = new ArrayList<Integer>();
ArrayList<List> FactorsList = new ArrayList<List>();
ArrayList<Integer> Occurences = new ArrayList<Integer>();
System.out.println("Smallest Multiple of Numbers
1-20\n---------------------------------\n\nSearching...");
for(int i = 2; i <= ntt; i++){
FactorsList.add(isPrime(i));
}
for(int i = 2; i <= ntt; i++)
for(int j = 0; j < FactorsList.size(); j++)
for(int k = 0; k < FactorsList.get(j).size();k++){
if(FactorsList.get(j).get(k)==i){
Occurences.set(i, i+1);
}
}
}
static List<Long> isPrime(long num){
List<Long> ar = new ArrayList<Long>();
for(long count=2;count<=num;count++){
while(num%count == 0){
ar.add(count);
num /= count;
}
}
return ar;
}
}

The checkbox value printing twice when checkbox checked in in tree view

The checkbox value printing twice when checkbox checked in in tree view

I am new to pythin programming.I need to implement tree view with
checkbox. Below is the code for tree view with checkbox:
import Tix
class View(object):
def __init__(self, root):
self.root = root
self.makeCheckList()
def makeCheckList(self):
self.cl = Tix.CheckList(self.root, browsecmd=self.selectItem)
self.cl.pack()
self.cl.hlist.add("CL1", text="checklist1")
self.cl.hlist.add("CL1.Item1", text="subitem1")
self.cl.hlist.add("CL2", text="checklist2")
self.cl.hlist.add("CL2.Item1", text="subitem1")
self.cl.setstatus("CL2", "on")
self.cl.setstatus("CL2.Item1", "on")
self.cl.setstatus("CL1", "off")
self.cl.setstatus("CL1.Item1", "off")
self.cl.autosetmode()
def selectItem(self, item):
print item, self.cl.getstatus(item)
def main():
root = Tix.Tk()
view = View(root)
root.update()
root.mainloop()
if __name__ == '__main__':
main()
There is a problem if a checkbox is checked the value of checkbox gets
printed twice for single checkin.
Can anyone please help me to solve the issue such that the value has to be
printed once for single checki.

how to use json array key to javascript variable

how to use json array key to javascript variable

i am try json_encode($updateArray);
and this is call by ajax and after ajax success
return me json string on responseText something like this type

{"title":"superAdmin","id":"50"}
now i want to use this two key
like

var text = title;
var id = id;
who can i user this two to as diff. variable.
thanks.

Friday, 27 September 2013

Clarification on simulation engine for real time multiplayer network game

Clarification on simulation engine for real time multiplayer network game

I've been doing some reading about the various forms of multiplayer that
exist today. In a nut shell, I believe the industry standard way involves
the following:
Running the physics for each client on the client machine/device
Sending the input data of this physics to the server (could be another
client running a 'server' session along with their own client data)
Server processes this data to determine if the client is making legitimate
moves, and if not, forces the client to sync to it's instructions (Rubber
banding).
Server forwards historic data from other clients to each client for
simulation.
Effective result from each clients perspective, is playing themselves in
the present, while seeing the other clients in the past.
Hit detection is performed on the server by 'rewinding' the game state to
see if at the time stamp an event occurred, where the affected players
were at that point in time.
Presently, I use a pure dead-reckoning system. Inputs are collected from
each client and physics calculated on each client. This works, however
units quikcly get out of sync and rubber band because the dependency on a
players previous position/speed/orientation is not high enough. AKA: they
are free to change directions and speed quickly and often.
With that being said, how do I solve this?
Is my client simulator effectively supposed to collect several data points
for each player and interpolate the rendering between those nodes? (IE:
each client has multiple data points about all the other clients historic
positions).
As such, my client's simulator drawing player B, would have positions X0,
X1, X2, X3 in a queue at time 0. Between the transition of Time 0 -> Time
1, I know the starting relevant values (location, speed, orientation, etc)
and where he should be come Time 1.
Is the solution to interpolate these values between these known historic
times and data points?
Thanks!
Ryan