Monday, April 23, 2012

C++ cli access Form variables from class

There is a form Form1 which contains int x; and a class MyClass with .h and .cpp files. How can I access the Form1 variable x from MyClass, without passing it using a method? I think something like Form1.x Maybe is it a bad style of programming?
I am just learning..





How do I get the host and port in a Rails applicaiton

Feel pretty dumb with this question.



In a Rails Model, I want to be able to find out the host and port. For example, if I am in a test environment it would return http://localhost:3000/ and if I was in production it would return something like http://my.application.com/?



Is this even possible?



Thanks!



jt





firefox position absolute inside a relative container issue

i am using table for displaying my dynamically generated data depend upon the user input the html structure is looks like below:



<table>
<tr>
<td>.....</td>
<td>.....</td>
<td style="position:relative;"> //like this i set for all td in table
<div style="position:absolute">//like this i set for all div in table
<contents>
</div>
</td>
<td>.....</td>
<td>.....</td>
</tr>
</table>


Here the div is goes to top corner of the body.all these above styles are applied throght the javascript and its working fine in chrome,IE,but not in FF like the image below



![enter image description here][1]


if we change the position of the div to absolute to relative it will align correctly but i am make a hover effect while the user hover the div's for that the positions are important and this issue happens only in firefox





facebook like button pop up - "post to facebook"

I implemented facebook like button.
First problem is following: when i click LIKE facebook button additional window pops up and and asks me if I want to post the article I read on facebook. What is bad about that is how this is presented. it seems that somehow it takes h1 tag that is "behind" it when it pops up. The content inside h1 tag is KATEGORIJE and that is displayed inside facebook pop up. I believe if you look at the picture it will be much more clearer http://tinypic.com/r/f58601/5



The second problem is that I defined facebook open graph meta tags but when I click I like the article I read in the pop up fb window I get: "you like 'ovdje ide naslov'"
i don't know from where I'm getting this. Can't find any line of code where I defined "ovdje ide naslov"





facebook like button pop up - "post to facebook"

I implemented facebook like button.
First problem is following: when i click LIKE facebook button additional window pops up and and asks me if I want to post the article I read on facebook. What is bad about that is how this is presented. it seems that somehow it takes h1 tag that is "behind" it when it pops up. The content inside h1 tag is KATEGORIJE and that is displayed inside facebook pop up. I believe if you look at the picture it will be much more clearer http://tinypic.com/r/f58601/5



The second problem is that I defined facebook open graph meta tags but when I click I like the article I read in the pop up fb window I get: "you like 'ovdje ide naslov'"
i don't know from where I'm getting this. Can't find any line of code where I defined "ovdje ide naslov"





android - fragments flow managing

I have a special flow of fragments in my app, so I need to be able to switch to any fragment, while keeping fragments in memory whenever possible (so if it's tight on memory, it's ok that the fragment will be released).



So far, I've succeeded doing a replace of the current fragment, but the thing is that the previous fragment is always being destroyed, so if I go back to it (using the action bar, for example), it's re-created and that takes some time.



The reason I use fragments instead of activities is the nice usage of the action bar, the ability to put multiple fragments inside the same container, the non-flexible activities-intents usage, etc...



The reason why I don't use the "Back" stack is that I wish to go to any fragment from any fragment, since the flow can change.



Here's a snippet of my code:



Fragment fragment=... ; //get the fragment from cache or create if not available yet...
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.mainActivity_fragmentContainer, fragment).commit();


I have also tried to use ViewPager, but since I don't want to have the sliding effect (which allows you to slide to other fragments) and since one of the fragments already include a viewPager, it's an obstacle. Disabling the sliding effect on the main viewPager somehow disables it on the other one.



BTW, I'm using the android support library for the fragments and not the native API.



my question is:
how can i achieve full control of which fragment to go to , while maximizing speed and avoiding too much memory being used for fragments ?






EDIT:
for now , i use the next workaround :
for the onDestroyView , i take the parent of the created view and remove the created view from there .



for the onCreateView , if i already have the created view from before , i return it .



however , i think it's a very risky thing to do , since i'm not sure of how fragments managing work , so it might cause weird problems . plus ,i'm not sure what will happen if android decides that it has low memory - will it destroy unused fragments (which is good) or will it cause out-of-memory exceptions (which is bad) .





Simulating Google app engine maintenance period in development environment

During scheduled maintenance period outages, the high replication datastore will work normally, but memcache will not be available.



Is there a way this scenario can be simulated in local development environment?



More specifically, can we run dev_appserver.py with memcache disabled to test the maintenance period behavior?



As of now, I go to development console and flush out the memcache after every request, to get a rough idea of how the app behaves during server maintenance. I am hoping there must be some better way to test this scenario.





Simulating Google app engine maintenance period in development environment

During scheduled maintenance period outages, the high replication datastore will work normally, but memcache will not be available.



Is there a way this scenario can be simulated in local development environment?



More specifically, can we run dev_appserver.py with memcache disabled to test the maintenance period behavior?



As of now, I go to development console and flush out the memcache after every request, to get a rough idea of how the app behaves during server maintenance. I am hoping there must be some better way to test this scenario.





Learning Ruby, Looking for Possible Refactoring for If Statement

I've got a few ideas but wanted to get a few other options. Here is the ugly:



    def normal_balance
if type.to_s == 'Asset' or type.to_s == 'Expense'
if contra
"Credit"
else
"Debit"
end
else
if contra
"Debit"
else
"Credit"
end
end
end




android - fragments flow managing

I have a special flow of fragments in my app, so I need to be able to switch to any fragment, while keeping fragments in memory whenever possible (so if it's tight on memory, it's ok that the fragment will be released).



So far, I've succeeded doing a replace of the current fragment, but the thing is that the previous fragment is always being destroyed, so if I go back to it (using the action bar, for example), it's re-created and that takes some time.



The reason I use fragments instead of activities is the nice usage of the action bar, the ability to put multiple fragments inside the same container, the non-flexible activities-intents usage, etc...



The reason why I don't use the "Back" stack is that I wish to go to any fragment from any fragment, since the flow can change.



Here's a snippet of my code:



Fragment fragment=... ; //get the fragment from cache or create if not available yet...
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.mainActivity_fragmentContainer, fragment).commit();


I have also tried to use ViewPager, but since I don't want to have the sliding effect (which allows you to slide to other fragments) and since one of the fragments already include a viewPager, it's an obstacle. Disabling the sliding effect on the main viewPager somehow disables it on the other one.



BTW, I'm using the android support library for the fragments and not the native API.



my question is:
how can i achieve full control of which fragment to go to , while maximizing speed and avoiding too much memory being used for fragments ?






EDIT:
for now , i use the next workaround :
for the onDestroyView , i take the parent of the created view and remove the created view from there .



for the onCreateView , if i already have the created view from before , i return it .



however , i think it's a very risky thing to do , since i'm not sure of how fragments managing work , so it might cause weird problems . plus ,i'm not sure what will happen if android decides that it has low memory - will it destroy unused fragments (which is good) or will it cause out-of-memory exceptions (which is bad) .





Learning Ruby, Looking for Possible Refactoring for If Statement

I've got a few ideas but wanted to get a few other options. Here is the ugly:



    def normal_balance
if type.to_s == 'Asset' or type.to_s == 'Expense'
if contra
"Credit"
else
"Debit"
end
else
if contra
"Debit"
else
"Credit"
end
end
end




Difficulty to transfer Entity instance from server to client

I have an Android client and a Google App Engine Servlet.

And I am transferring objects from client to server by serialization.

Serialization works fine for all the serialized Object in my project,

except to The Entity Object called Profile that I am saving in my JPA DB.

now when I am transferring Profile instance from client to server it works fine

but when I transfer from server to client i get the exception as written below.



I'll add that i don't have code duplication in my code.

Profile class is in Server Project, and Client project contains Server's path.



W/System.err(1104): java.io.InvalidClassException: javax.jdo.identity.LongIdentity; Incompatible class (SUID): javax.jdo.identity.LongIdentity: static final long serialVersionUID =2472141538875317527L; but expected javax.jdo.identity.LongIdentity: static final long serialVersionUID =2940818939440220368L; 


My Enity class is:



@Entity
public class Profile implements Serializable
{
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private int age;
private String email;
private boolean onlineStatus = false;

public Profile() {}

public Profile(int age,String email)
{
super();
this.age = age;
this.email = email;
}

public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}

public String getEmail()
{
return email;
}

public void setEmail(String email)
{
this.email = email;
}

public boolean isOnlineStatus()
{
return onlineStatus;
}

public void setOnlineStatus(boolean onlineStatus)
{
this.onlineStatus = onlineStatus;
}


full stack trace:



04-21 21:04:56.577: W/System.err(1104): at java.io.ObjectInputStream.verifyAndInit(ObjectInputStream.java:2697)
04-21 21:04:56.577: W/System.err(1104): at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1825)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:811)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2039)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:916)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readNewArray(ObjectInputStream.java:1678)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:914)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1291)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:518)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1535)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1443)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2112)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:916)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readNewArray(ObjectInputStream.java:1678)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:914)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1291)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:518)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1535)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1443)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2112)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:916)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
04-21 21:04:56.607: W/System.err(1104): at streetMeet.Client.CustomHttpClient.readObject(CustomHttpClient.java:274)
04-21 21:04:56.607: W/System.err(1104): at streetMeet.Client.CustomHttpClient.executeHttpPost(CustomHttpClient.java:59)
04-21 21:04:56.607: W/System.err(1104): at streetMeet.Client.StreetMeetActivity.connectToServer(StreetMeetActivity.java:154)
04-21 21:04:56.607: W/System.err(1104): at streetMeet.Client.StreetMeetActivity.sendMessageToServer(StreetMeetActivity.java:141)
04-21 21:04:56.607: W/System.err(1104): at map.StreetMapActivity$1.run(StreetMapActivity.java:116)




Difficulty to transfer Entity instance from server to client

I have an Android client and a Google App Engine Servlet.

And I am transferring objects from client to server by serialization.

Serialization works fine for all the serialized Object in my project,

except to The Entity Object called Profile that I am saving in my JPA DB.

now when I am transferring Profile instance from client to server it works fine

but when I transfer from server to client i get the exception as written below.



I'll add that i don't have code duplication in my code.

Profile class is in Server Project, and Client project contains Server's path.



W/System.err(1104): java.io.InvalidClassException: javax.jdo.identity.LongIdentity; Incompatible class (SUID): javax.jdo.identity.LongIdentity: static final long serialVersionUID =2472141538875317527L; but expected javax.jdo.identity.LongIdentity: static final long serialVersionUID =2940818939440220368L; 


My Enity class is:



@Entity
public class Profile implements Serializable
{
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private int age;
private String email;
private boolean onlineStatus = false;

public Profile() {}

public Profile(int age,String email)
{
super();
this.age = age;
this.email = email;
}

public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}

public String getEmail()
{
return email;
}

public void setEmail(String email)
{
this.email = email;
}

public boolean isOnlineStatus()
{
return onlineStatus;
}

public void setOnlineStatus(boolean onlineStatus)
{
this.onlineStatus = onlineStatus;
}


full stack trace:



04-21 21:04:56.577: W/System.err(1104): at java.io.ObjectInputStream.verifyAndInit(ObjectInputStream.java:2697)
04-21 21:04:56.577: W/System.err(1104): at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1825)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:811)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2039)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:916)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readNewArray(ObjectInputStream.java:1678)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:914)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
04-21 21:04:56.592: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1291)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:518)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1535)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1443)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2112)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:916)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readNewArray(ObjectInputStream.java:1678)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:914)
04-21 21:04:56.597: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1291)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:518)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1535)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1443)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2112)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:916)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
04-21 21:04:56.607: W/System.err(1104): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
04-21 21:04:56.607: W/System.err(1104): at streetMeet.Client.CustomHttpClient.readObject(CustomHttpClient.java:274)
04-21 21:04:56.607: W/System.err(1104): at streetMeet.Client.CustomHttpClient.executeHttpPost(CustomHttpClient.java:59)
04-21 21:04:56.607: W/System.err(1104): at streetMeet.Client.StreetMeetActivity.connectToServer(StreetMeetActivity.java:154)
04-21 21:04:56.607: W/System.err(1104): at streetMeet.Client.StreetMeetActivity.sendMessageToServer(StreetMeetActivity.java:141)
04-21 21:04:56.607: W/System.err(1104): at map.StreetMapActivity$1.run(StreetMapActivity.java:116)




C++ cli access Form variables from class

There is a form Form1 which contains int x; and a class MyClass with .h and .cpp files. How can I access the Form1 variable x from MyClass, without passing it using a method? I think something like Form1.x Maybe is it a bad style of programming?
I am just learning..





How to Clone a child of an abstract class in WP7 XNA

I'm working on a game for WP7 with XNA. Here is my structure:



public abstract class enemy
{}


Child elements:



public class genericEnemy : enemy{}
...
public class snake : enemy {}


etc...



In WP7, a lot of things have been moved around and/or removed (especially with Serialization) it seems. Despite much searching, I haven't been able to find a solution. I'm trying to duplicate the child elements.



For example: On loading a level, I pass an array of three different enemies into the loading phase. During loading, I need to duplicate each of those enemies so that 20 of each are flying around doing their own thing during gameplay.



All the solutions I've seen refer to things that are not present in the WP7 library.





How can I achieve this background scroll effect?

I really like the way each background section overlaps each other which scrolling down. I have seen it done a lot:
here is the link : http://www.soleilnoir.net/believein/



Any ideas how to achieve the similar effect?



Thanks





How to Clone a child of an abstract class in WP7 XNA

I'm working on a game for WP7 with XNA. Here is my structure:



public abstract class enemy
{}


Child elements:



public class genericEnemy : enemy{}
...
public class snake : enemy {}


etc...



In WP7, a lot of things have been moved around and/or removed (especially with Serialization) it seems. Despite much searching, I haven't been able to find a solution. I'm trying to duplicate the child elements.



For example: On loading a level, I pass an array of three different enemies into the loading phase. During loading, I need to duplicate each of those enemies so that 20 of each are flying around doing their own thing during gameplay.



All the solutions I've seen refer to things that are not present in the WP7 library.





How can I achieve this background scroll effect?

I really like the way each background section overlaps each other which scrolling down. I have seen it done a lot:
here is the link : http://www.soleilnoir.net/believein/



Any ideas how to achieve the similar effect?



Thanks





Pass a gridview column value to a session using javascript

I have a gridview that contains a list of products. What i am trying to do is using the ItemTemplate is pass the ProductID of the selected item using an Onclick event to a session so i can then lookup that session on another page to avoid having the ProductID shown in the URL.



    <asp:GridView ID="GVProducts" runat="server" 
onselectedindexchanged="GVProducts_SelectedIndexChanged">
<Columns>
<asp:ImageField DataImageUrlField="FileName"
DataImageUrlFormatString="Images/{0}" HeaderText="Image">
<ControlStyle Height="80px" Width="80px" />
</asp:ImageField>
<asp:TemplateField HeaderText="Title" SortExpression="ProductID" >
<ItemTemplate>
<a onclick="javascript:function setSessionVariable(<%#Eval("ProductID")%>)" href="ProductDetail.aspx"><%#Eval("Title")%></a>
</ItemTemplate></asp:TemplateField>

</Columns>
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<RowStyle BackColor="White" ForeColor="#003399" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<SortedAscendingCellStyle BackColor="#EDF6F6" />
<SortedAscendingHeaderStyle BackColor="#0D4AC4" />
<SortedDescendingCellStyle BackColor="#D6DFDF" />
<SortedDescendingHeaderStyle BackColor="#002876" />
</asp:GridView>


Hopefully it is something simple as i am just starting out with javascript but i cant seem to get it to pass to the session.



Thanks





Pass a gridview column value to a session using javascript

I have a gridview that contains a list of products. What i am trying to do is using the ItemTemplate is pass the ProductID of the selected item using an Onclick event to a session so i can then lookup that session on another page to avoid having the ProductID shown in the URL.



    <asp:GridView ID="GVProducts" runat="server" 
onselectedindexchanged="GVProducts_SelectedIndexChanged">
<Columns>
<asp:ImageField DataImageUrlField="FileName"
DataImageUrlFormatString="Images/{0}" HeaderText="Image">
<ControlStyle Height="80px" Width="80px" />
</asp:ImageField>
<asp:TemplateField HeaderText="Title" SortExpression="ProductID" >
<ItemTemplate>
<a onclick="javascript:function setSessionVariable(<%#Eval("ProductID")%>)" href="ProductDetail.aspx"><%#Eval("Title")%></a>
</ItemTemplate></asp:TemplateField>

</Columns>
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<RowStyle BackColor="White" ForeColor="#003399" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<SortedAscendingCellStyle BackColor="#EDF6F6" />
<SortedAscendingHeaderStyle BackColor="#0D4AC4" />
<SortedDescendingCellStyle BackColor="#D6DFDF" />
<SortedDescendingHeaderStyle BackColor="#002876" />
</asp:GridView>


Hopefully it is something simple as i am just starting out with javascript but i cant seem to get it to pass to the session.



Thanks





It isn't a JSONObject. It isn't a JSONArray. What is it?

I have not been working with JSON very long. I have the following response and I'm struggling to understand how to call the details of the "Topic". I thought it was a JSONObject, but Android's logcat is telling me JSONObject["Topic"] not found.



[{"Id":1,"TopicId":1,"UserGuid":"C214ED74-07A7-409E-84FF-AF0457CF581A","Topic":{"Id":1,"AdminUserGuid":"C214ED74-07A7-409E-84FF-AF0457CF581A","Title":"Test Topic 1","AccessType":"public"}}]


Any help is greatly appreciated.





It isn't a JSONObject. It isn't a JSONArray. What is it?

I have not been working with JSON very long. I have the following response and I'm struggling to understand how to call the details of the "Topic". I thought it was a JSONObject, but Android's logcat is telling me JSONObject["Topic"] not found.



[{"Id":1,"TopicId":1,"UserGuid":"C214ED74-07A7-409E-84FF-AF0457CF581A","Topic":{"Id":1,"AdminUserGuid":"C214ED74-07A7-409E-84FF-AF0457CF581A","Title":"Test Topic 1","AccessType":"public"}}]


Any help is greatly appreciated.





DataGridViewRow to DataRow - object reference not set to an instance

What I'm doing (or trying to do) is getting a row from DataGridView and convert it to DataRow, so I can put that DataRow into DataTable. So I searched for examples on the Web,
and people claimed they work just fine, but my doesn't.
This is my code:



DataGridViewRowCollection rows = myDataGridView.Rows;
foreach (DataGridViewRow row in rows)
{
/*(1)*/ DataRow myRow = (row.DataBoundItem as DataRowView).Row;
myDataTable.Rows.Add(myRow);
}


but I get "Object reference not set to an instance of an object." on line (1).





find page number of a string in pdf file in c#

I am developing a pdf reader. i want to find any string in pdf and to know the corresponding page number. I am using iTextSharp.



Thanks in advance





Webcam frame from Aforge always gray image

I am using Aforge .NET framework to get a webcam in my app but I always get an all gray image frame.



            this.videoSource = new VideoCaptureDevice(this.Moniker);
this.videoSource.DesiredFrameSize = GetHighestResolution(this.videoSource.VideoCapabilities);
this.videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame);
this.videoSource.Start();


The vent handler:



    private void videoSource_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
this.outputBox.Image = (Bitmap)eventArgs.Frame.Clone();
}


This should do the trick. DesiredFrameSize is set to the highest value the cam can support.



Any hints why the image is always gray? Even when writing it do disk...





find page number of a string in pdf file in c#

I am developing a pdf reader. i want to find any string in pdf and to know the corresponding page number. I am using iTextSharp.



Thanks in advance





Webcam frame from Aforge always gray image

I am using Aforge .NET framework to get a webcam in my app but I always get an all gray image frame.



            this.videoSource = new VideoCaptureDevice(this.Moniker);
this.videoSource.DesiredFrameSize = GetHighestResolution(this.videoSource.VideoCapabilities);
this.videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame);
this.videoSource.Start();


The vent handler:



    private void videoSource_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
this.outputBox.Image = (Bitmap)eventArgs.Frame.Clone();
}


This should do the trick. DesiredFrameSize is set to the highest value the cam can support.



Any hints why the image is always gray? Even when writing it do disk...





jQuery - changed element won't clone

I have changed the html text of an element, in this case #main_cluster_id_reach_12



$("#main_cluster_id_reach_12").html( '400' ).effect("highlight", {color: '#2a6500'}, 60000 * 5);


That works fine but when I try to clone the container that is holding it(#applications), it doesn't contain the updated html of #main_cluster_id_reach_12 but rather the original text that loaded with the page. Here is how I am cloning it:



var $applications = $('#applications');
var $data = $applications.clone();


What am I doing wrong?



edit: Here is the js and html. I am using jquery 1.7.2



What i am trying to do is update the reach of a group of clusters on a 10 second interval via ajax and then resorting the li items with quicksand ordered by their reach. The updating occurs without problem but quicksand clones the original list, not the updated list. This morning i've been playing with some logging and it appears the cloning is happening before the ajax update completes.



// quicksand sorting plugin
(function($) {
$.fn.sorted = function(customOptions) {
var options = {
reversed: true,
by: function(a) { return a.text(); }
};
$.extend(options, customOptions);
$data = $(this);
arr = $data.get();
arr.sort(function(a, b) {
var valA = options.by($(a));
var valB = options.by($(b));
if (options.reversed) {
return (valA < valB) ? 1 : (valA > valB) ? -1 : 0;
} else {
return (valA < valB) ? -1 : (valA > valB) ? 1 : 0;
}
});
return $(arr);
};
})(jQuery);


$(document).ready(function(){
//loop through all reaches to update
setInterval(function() {
//reach
$("[id^='main_cluster_id_reach_']").each(function(){

//Check for reach updates

//get cluster id first
var cluster_id = parseInt(this.id.replace("main_cluster_id_reach_", ""));

//get cluster reach
$.post("./lib/ajax/meme_cluster_update.php", { cluster_id: cluster_id },
function(data) {

//get reach - new
var new_reach = 0;

new_reach = parseInt(data.ItemReach, 10);

//get reach - old
var reach = $("#main_cluster_id_reach_" + cluster_id).html();

// Format as American input
reach = parseInt(reach.replace(/[^\d\.\-\ ]/g, ''));

//compare new vs old and change cell view
compareReach(cluster_id, reach, new_reach);

}, "json");
});

// get the first collection
var $applications = $('#applications');

// clone applications to get a second collection
var $data = $applications.clone();

var $filteredData = $data.find('li[data-type=app]');

var $sortedData = $filteredData.sorted({
by: function (v) {
return parseFloat($(v).find('span[data-type=size]').text());
}
});

// finally, call quicksand
$applications.quicksand($sortedData, {
duration: 800,
easing: 'easeInOutQuad'
});
}, 10000);

//compare the reaches to update accordingly
function compareReach(cluster_id, reach, new_reach) {
//determine what color to change cells
if(new_reach > reach) {
$(".main_cluster_id_reach_" + cluster_id).html( new_reach ).effect("highlight", {color: '#2a6500'}, 60000 * 5);
}
else if(new_reach < reach) {
$(".main_cluster_id_reach_" + cluster_id).html( new_reach ).effect("highlight", {color: '#990004'}, 60000 * 5);
}
}


html



 <div class="span-24" id='demo'>
<ul id="applications" class="image-grid">
<li data-id="id-210639" data-type="app" class='cluster'>
<div class='cluster_byline'>@awkwardisco</div>
<div class="cluster_padding">
<span class='cluster_headline'>Avengers on Thursday!!!</span>
<br>
<div class="cluster_stats">
<div class="span-2 reach">
<strong>REACH</strong>
<span class="main_cluster_id_reach_210639" data-type="size">26777</span>
</div>
<div class="span-2 retweets">
<strong>RETWEETS</strong>
</div>
<div class="span-2 velocity">
<strong>VELOCITY</strong>
</div>
<div class="span-8 LAST">
<strong>LINKS</strong>
</div>
</div>
</div>
</li>
</ul>
</div>




jQuery - changed element won't clone

I have changed the html text of an element, in this case #main_cluster_id_reach_12



$("#main_cluster_id_reach_12").html( '400' ).effect("highlight", {color: '#2a6500'}, 60000 * 5);


That works fine but when I try to clone the container that is holding it(#applications), it doesn't contain the updated html of #main_cluster_id_reach_12 but rather the original text that loaded with the page. Here is how I am cloning it:



var $applications = $('#applications');
var $data = $applications.clone();


What am I doing wrong?



edit: Here is the js and html. I am using jquery 1.7.2



What i am trying to do is update the reach of a group of clusters on a 10 second interval via ajax and then resorting the li items with quicksand ordered by their reach. The updating occurs without problem but quicksand clones the original list, not the updated list. This morning i've been playing with some logging and it appears the cloning is happening before the ajax update completes.



// quicksand sorting plugin
(function($) {
$.fn.sorted = function(customOptions) {
var options = {
reversed: true,
by: function(a) { return a.text(); }
};
$.extend(options, customOptions);
$data = $(this);
arr = $data.get();
arr.sort(function(a, b) {
var valA = options.by($(a));
var valB = options.by($(b));
if (options.reversed) {
return (valA < valB) ? 1 : (valA > valB) ? -1 : 0;
} else {
return (valA < valB) ? -1 : (valA > valB) ? 1 : 0;
}
});
return $(arr);
};
})(jQuery);


$(document).ready(function(){
//loop through all reaches to update
setInterval(function() {
//reach
$("[id^='main_cluster_id_reach_']").each(function(){

//Check for reach updates

//get cluster id first
var cluster_id = parseInt(this.id.replace("main_cluster_id_reach_", ""));

//get cluster reach
$.post("./lib/ajax/meme_cluster_update.php", { cluster_id: cluster_id },
function(data) {

//get reach - new
var new_reach = 0;

new_reach = parseInt(data.ItemReach, 10);

//get reach - old
var reach = $("#main_cluster_id_reach_" + cluster_id).html();

// Format as American input
reach = parseInt(reach.replace(/[^\d\.\-\ ]/g, ''));

//compare new vs old and change cell view
compareReach(cluster_id, reach, new_reach);

}, "json");
});

// get the first collection
var $applications = $('#applications');

// clone applications to get a second collection
var $data = $applications.clone();

var $filteredData = $data.find('li[data-type=app]');

var $sortedData = $filteredData.sorted({
by: function (v) {
return parseFloat($(v).find('span[data-type=size]').text());
}
});

// finally, call quicksand
$applications.quicksand($sortedData, {
duration: 800,
easing: 'easeInOutQuad'
});
}, 10000);

//compare the reaches to update accordingly
function compareReach(cluster_id, reach, new_reach) {
//determine what color to change cells
if(new_reach > reach) {
$(".main_cluster_id_reach_" + cluster_id).html( new_reach ).effect("highlight", {color: '#2a6500'}, 60000 * 5);
}
else if(new_reach < reach) {
$(".main_cluster_id_reach_" + cluster_id).html( new_reach ).effect("highlight", {color: '#990004'}, 60000 * 5);
}
}


html



 <div class="span-24" id='demo'>
<ul id="applications" class="image-grid">
<li data-id="id-210639" data-type="app" class='cluster'>
<div class='cluster_byline'>@awkwardisco</div>
<div class="cluster_padding">
<span class='cluster_headline'>Avengers on Thursday!!!</span>
<br>
<div class="cluster_stats">
<div class="span-2 reach">
<strong>REACH</strong>
<span class="main_cluster_id_reach_210639" data-type="size">26777</span>
</div>
<div class="span-2 retweets">
<strong>RETWEETS</strong>
</div>
<div class="span-2 velocity">
<strong>VELOCITY</strong>
</div>
<div class="span-8 LAST">
<strong>LINKS</strong>
</div>
</div>
</div>
</li>
</ul>
</div>




DataGridViewRow to DataRow - object reference not set to an instance

What I'm doing (or trying to do) is getting a row from DataGridView and convert it to DataRow, so I can put that DataRow into DataTable. So I searched for examples on the Web,
and people claimed they work just fine, but my doesn't.
This is my code:



DataGridViewRowCollection rows = myDataGridView.Rows;
foreach (DataGridViewRow row in rows)
{
/*(1)*/ DataRow myRow = (row.DataBoundItem as DataRowView).Row;
myDataTable.Rows.Add(myRow);
}


but I get "Object reference not set to an instance of an object." on line (1).