I tried the option of students.item["http://www.myurl.com"].comments.data.length. However, the item["http://www.myurl.com"] call is not working.
If I take out the URL from JSON object and write the iterator with students.comments.data, it works.
Here is my code, any help highly appreciated.
var students = {
"http://www.myurl.com":{
"comments":{
"data" : [
{
"id": "123456778",
"from": {
"name": "XYZ",
"id": "1000005"
},
"message": "Hey",
"can_remove": false,
"created_time": "2012-09-03T03:16:01+0000",
"like_count": 0,
"user_likes": false
}
]
}
}
}
var i=0
var arrayObject = new Array();
alert("Parsing 2: "+students.item["http://www.myurl.com"].comments.data.length);
for(i=0;i<students.item["http://www.myurl.com"].comments.data.length;i++)
{
alert("Parsing 1: "+i);
arrayObject.push(students.item["http://www.myurl.com"].comments.data[i].id);
arrayObject.push(students.item["http://www.myurl.com"].comments.data[i].message);
arrayObject.push(students.item["http://www.myurl.com"].comments.data[i].created_time);
}
I was psyched about the possibility of using SQLite as a database solution during development so that I could focus on writing the code first and dynamically generating the db at runtime using NHibernate's ShemaExport functionality. However, I'm running into a few issues, not the least of which is that it seems that SQLite requires me to use Int64 for my primary keys (vs, say, Int32 or Guid). Is there any way around this?
I have an Action that basically adds an item to a cart, the only way the cart is known is by checking the cookie, here is the flow of logic, please let me know if you see any issue...
/order/add/[id] is called via GET
action checks for cookie, if no cookie found, it makes a new cart, writes the identifier to the cookie, and adds the item to the database with a relation to the cart created
if cookie is found, it gets the cart identifier from the cookie, gets the cart object, adds the item to the database with a relation to the cart found
so it's basically like...
action add(int id){
if(cookie is there)
cart = getcart(cookievalue)
else
cart = makecart()
createcookie(cart.id)
additemtocart(cart.id, id)
return "success";
}
Seem right? I can't really thing of another way that would make sense.
I have a site that plays a stream. I perform an AJAX call to the server once a person presses a button.
<input type="submit" class="play" data-type="<?php echo $result_cameras[$i]["camera_type"]; ?>" data-hash="<?php echo $result_cameras[$i]["camera_hash"]; ?>" value="<?php echo $result_cameras[$i]["camera_name"]; ?>">
This prints out a bunch of buttons that the user can select. This is processed by the following code:
<script>
$(document).ready(function(){
$(".play").click(function(){
var camerahash = $(this).data('hash');
var cameratype = $(this).data('type');
function doAjax(){
$.ajax({
url: 'index.php?option=streaming&task=playstream&id_hash=<?php echo $id_hash; ?>&camera_hash='+camerahash+'&format=raw',
success: function(data) {
if (data == 'Initializing...please wait')
{
$('#quote p').html(data);
setTimeout(doAjax, 2000);
}
else
{
if (cameratype == "WEBCAM" && data == 'Stream is ready...')
{
$('#quote p').html(data);
window.location = 'rtsp://<?php echo DEVSTREAMWEB; ?>/<?php echo $session_id;?>/'+camerahash;
}
else if (cameratype == "AXIS" && data == 'Stream is ready...')
{
$('#quote p').html(data);
window.location = 'rtsp://<?php echo DEVSTREAMIP; ?>/<?php echo $session_id;?>/'+camerahash;
}
else
{
$('#quote p').html(data);
}
}
}
});
}
doAjax();
});
});
</script>
The server returns the messages such as Stream is ready.... My problem is that everything is working great except on additional button clicks. Specifically when they get success (video plays) and they exit back out, they don't get any other messages if they click another button. It is as if the click event is not triggered. Do I need to be doing something to the click handler to respond?
We have several document libraries where users upload reports daily. I have to make a page that shows specific documents (getting them by their filename) from these document libraries with each documents last modified date.
What is the easiest way to do this?
I am receiving a lot of deadlocks in my big web application.
http://stackoverflow.com/questions/2941233/how-to-automatically-re-run-deadlocked-transaction-asp-net-mvc-sql-server
Here I wanted to re-run deadlocked transactions, but I was told to get rid of the deadlocks - it's much better, than trying to catch the deadlocks.
So I spent the whole day with SQL profiler, setting the tracing keys etc. And this is what I got.
There's a Users table. I have a very high usable page with the following query (it's not the only query, but it's the one that causes troubles)
UPDATE Users
SET views = views + 1
WHERE ID IN (SELECT AuthorID FROM Articles WHERE ArticleID = @ArticleID)
And then there's the following query in ALL pages:
User = DB.Users.SingleOrDefault(u => u.Password == password && u.Name == username);
That's where I get User from cookies.
Very often a deadlock occurs and this second LINQ TO SQL query is chosen as a victim, so it's not run, and users of my site see an error screen.
I read a lot about deadlocks... And I don't understand why this is causing a deadlock.
So obviously both of this queries run very often. At least once a second. Maybe even more often (300-400 users online). So they can be run at the same time very easily, but why does it cause a deadlock? Please help.
Thank you
Lets say I have the following mapping:
<hibernate-mapping package="mypackage">
<class name="User" table="user">
<id name="id" column="id">
<generator class="native"></generator>
</id>
<property name="name" />
<property name="age" />
</class>
</hibernate-mapping>
Is it possible to select the oldest user (that is age is maximal) using Criteria in Hibernate?
I can imagine that i could do this with 2 selects. (first select total number of users and then order the entries descending by age and select the first entry). But is it possible with a single select?
Thank you
Palo
I've implemented 2 QComboBoxes with one having items manually inserted every time and another one having items inserted with a list (I'm using Python )
But when i attempt to get the current value of Combobox , it returns None .
I proceeded as specified in this question :
I referred this
i have provided wat i've coded ."command" and "option" are QComboBoxes ( Pardon me for bad style) Is there any mistake in Indexes ?
self.command.insertItem(1,'Convert')
self.command.insertItem(2,'Compose')
self.command.insertItem(3,'Animate')
self.option.insertItems(268,list)
and retrieval :
self.selected_com=self.command.itemData(self.command.currentIndex())
self.selected_opt=self.option.itemData(self.option.currentIndex())
I am using .net Windows Forms i need to maintain some date to check the condition. so i have to maintain it up to user logged out?
like session in asp.net
how can i do this?(note it should not expires until the user logged out)
I can not figure out why my code does not filter out lists from a predefined list.
I am trying to remove specific list using the following code.
data = [[1,1,1],[1,1,2],[1,2,1],[1,2,2],[2,1,1],[2,1,2],[2,2,1],[2,2,2]]
data = [x for x in data if x[0] != 1 and x[1] != 1]
print data
My result:
data = [[2, 2, 1], [2, 2, 2]]
Expected result:
data = [[1,2,1],[1,2,2],[2,1,1],[2,1,2],[2,2,1],[2,2,2]]
Suppose i want to store 3 lines in a file both in python and C++ .
I want to store it like this
aaa
bbb
ccc ..
But i am giving ccc input first then bbb then aaa. How will I traverse the file from bottom to top and also store from bottom to top/?
Assume that I have a text file separated by colons. I understand how to display the entire text file or any specific column using awk. However, what I want to do is to get the awk output and then display it by adding my own text using a shell script? For example, assume that my text file is:
England:London:GMT
USA:Washington:EST
France:Paris:GMT
What I want to do is to display this input into the below format:
COUNTRY: England
CAPITOL: London
TIMEZONE: GMT
COUNTRY: USA
CAPITOL: Washington
TIMEZONE: EST
COUNTRY: France
CAPITOL: Paris
TIMEZONE: GMT
If I use as below, I get no error, no output.
Why does p:panelGrid not work with ui:repeat?
Note : I don't want to use c:forEach because of the I already face a lot of JSF issue.
<p:panelGrid>
<ui:repeat value="#{MyBean.dataList}" var="data">
<p:row>
<p:column>
<h:outputText value="#{data.name}"/>
</p:column>
<p:column>
<h:outputText value="#{data.description}"/>
</p:column>
</p:row>
</ui:repeat>
</p:panelGrid>
MyBean.java
public List<Data> getDataList(){
List<Data> result = new ArrayList<Data>();
result.add(new Data("Name 1", "Description 1"));
result.add(new Data("Name 2", "Description 2"));
result.add(new Data("Name 3", "Description 3"));
result.add(new Data("Name 4", "Description 4"));
return result;
}
Expected output with primefaces
I'm working on a first symfony project, i am using the sfWidgetFormTextareaTinyMCE widget for a form tinymce text area. It works fine, but while retrieving from database, instead of showing me the formated text, i have the <strong>,<p>,<br>tags in the text. help me please
I have a small class that I call Viewer. This class is supposed to view the proper layout of each page or something like that...
I have a method called getFirstPage, when called the user of this method will get a setting value for which page is currently set as the first page. I have some code here, I think it works but I am not really shure that I have done it the right way:
class Viewer {
private $db;
private $user;
private $firstPage;
function __construct($db, $user) {
$this->db = $db;
if(isset($user)) {
$this->user = $user;
} else {
$this->user = 'default';
}
}
function getFistPage() {
$std = $db->prepare("SELECT firstPage FROM settings WHERE user = ':user'");
$std->execute(array(':user' => $user));
$result = $std->fetch();
$this->firstPage = $result['firstPage'];
return $this->firstPage;
}
}
My get method is fetching the setting from databse (so far so good?). The problem is that then I have to use this get method to set the private variable firstPage. It seems like I should have a set method to do this, but I cannot really have a set method that just fetch some setting from database, right? Because the user of this object should be able to assume that there already is a setting defined in the object...
How should I do that?
At MIX it was announced that WCF RIA Services supports OData Endpoint on the server now. But is there a good way to use a real OData Server in the WCF RIA Services Tooling as an endpoint or is that just an option for the team to say that are supporting the standard, too?
Hey, can someone please show me how i can write the output of OnCreateFile to a GUI? I thought the GUI would have to be declared at the bottom in the main function, so how do i then refer to it within OnCreateFile?
using System;
using System.Collections.Generic;
using System.Runtime.Remoting;
using System.Text;
using System.Diagnostics;
using System.IO;
using EasyHook;
using System.Drawing;
using System.Windows.Forms;
namespace FileMon
{
public class FileMonInterface : MarshalByRefObject
{
public void IsInstalled(Int32 InClientPID)
{
//Console.WriteLine("FileMon has been installed in target {0}.\r\n", InClientPID);
}
public void OnCreateFile(Int32 InClientPID, String[] InFileNames)
{
for (int i = 0; i < InFileNames.Length; i++)
{
String[] s = InFileNames[i].ToString().Split('\t');
if (s[0].ToString().Contains("ROpen"))
{
//Console.WriteLine(DateTime.Now.Hour+":"+DateTime.Now.Minute+":"+DateTime.Now.Second+"."+DateTime.Now.Millisecond + "\t" + s[0] + "\t" + getProcessName(int.Parse(s[1])) + "\t" + getRootHive(s[2]));
Program.ff.enterText(DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + "." + DateTime.Now.Millisecond + "\t" + s[0] + "\t" + getProcessName(int.Parse(s[1])) + "\t" + getRootHive(s[2]));
}
else if (s[0].ToString().Contains("RQuery"))
{
Console.WriteLine(DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + "." + DateTime.Now.Millisecond + "\t" + s[0] + "\t" + getProcessName(int.Parse(s[1])) + "\t" + getRootHive(s[2]));
}
else if (s[0].ToString().Contains("RDelete"))
{
Console.WriteLine(DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + "." + DateTime.Now.Millisecond + "\t" + s[0] + "\t" + getProcessName(int.Parse(s[0])) + "\t" + getRootHive(s[1]));
}
else if (s[0].ToString().Contains("FCreate"))
{
//Console.WriteLine(DateTime.Now.Hour+":"+DateTime.Now.Minute+":"+DateTime.Now.Second+"."+DateTime.Now.Millisecond + "\t" + s[0] + "\t" + getProcessName(int.Parse(s[1])) + "\t" + s[2]);
}
}
}
public void ReportException(Exception InInfo)
{
Console.WriteLine("The target process has reported an error:\r\n" + InInfo.ToString());
}
public void Ping()
{
}
public String getProcessName(int ID)
{
String name = "";
Process[] process = Process.GetProcesses();
for (int i = 0; i < process.Length; i++)
{
if (process[i].Id == ID)
{
name = process[i].ProcessName;
}
}
return name;
}
public String getRootHive(String hKey)
{
int r = hKey.CompareTo("2147483648");
int r1 = hKey.CompareTo("2147483649");
int r2 = hKey.CompareTo("2147483650");
int r3 = hKey.CompareTo("2147483651");
int r4 = hKey.CompareTo("2147483653");
if (r == 0)
{
return "HKEY_CLASSES_ROOT";
}
else if (r1 == 0)
{
return "HKEY_CURRENT_USER";
}
else if (r2 == 0)
{
return "HKEY_LOCAL_MACHINE";
}
else if (r3 == 0)
{
return "HKEY_USERS";
}
else if (r4 == 0)
{
return "HKEY_CURRENT_CONFIG";
}
else return hKey.ToString();
}
}
class Program : System.Windows.Forms.Form
{
static String ChannelName = null;
public static Form1 ff;
Program() // ADD THIS CONSTRUCTOR
{
InitializeComponent();
}
static void Main()
{
try
{
Config.Register("A FileMon like demo application.", "FileMon.exe", "FileMonInject.dll");
RemoteHooking.IpcCreateServer<FileMonInterface>(ref ChannelName, WellKnownObjectMode.SingleCall);
Process[] p = Process.GetProcesses();
for (int i = 0; i < p.Length; i++)
{
try
{
RemoteHooking.Inject(p[i].Id, "FileMonInject.dll", "FileMonInject.dll", ChannelName);
}
catch (Exception e)
{
}
}
}
catch (Exception ExtInfo)
{
Console.WriteLine("There was an error while connecting to target:\r\n{0}", ExtInfo.ToString());
}
}
}
}
Well, not my server. My friend found it and sent it to me, trying to make sense of it. What it appears to be is a PHP IRC bot, but I have no idea how to decode it and make any sense of it.
Here is the code:
<?eval(gzinflate(base64_decode('some base 64 code here')))?>
So I decoded the base64, and it output a ton of strange characters, I'm guessing either encrypted or a different file type, like when you change a .jpg to a .txt and open it.
But I have no idea how to decode this and determine its source. Any help?
I am going to be implementing a small custom CMS for a website. I was wondering if there are any more popular methods for implementing pagination using OOP. Thanks!
I have 'n' number of data which has to be added to a label field which in turn has to be added to hfm.I am setting the single data in to label field as :
final LabelField desc = new LabelField("", LabelField.FOCUSABLE);
final LabelField desc1 = new LabelField("", LabelField.FOCUSABLE);
Vector data = (Vector) listEvent.get(keys);
for (int i = 0; i < data.size(); i++) {
EventData ee = (EventData) data.elementAt(i);
String Summary= ee.getSummary();
if (time.getText().equals(sTime)) {
desc.setText(Summary);
}
else{
desc1.setText(Summary);
}
}
HorizontalFieldManager horizontalFieldManager_left18 = new HorizontalFieldManager() {
horizontalFieldManager_left18.add(desc1);
vfm.add(horizontalFieldManager_left18);
vfm.add(new SeparatorField());
HorizontalFieldManager horizontalFieldManager_left17 = new HorizontalFieldManager() {
horizontalFieldManager_left17.add(desc);
vfm.add(horizontalFieldManager_left17);
vfm.add(new SeparatorField());
In the above code i loop over vector and set the data into labelfield and adding the label to hfm later.
Now the case is the vector data has more than one summary data,and the data is getting overridden in labelfield,i need to keep 'n' number of summary data into lablefield and add to new hfm.
Hi there
I have Telerik grid within a Telerik grid. Due to I have a different view between insert and edit mode, so as per suggested I have to use UserControl instead. Inside this control, it could have another Telerik grid plus bunch of ASP.NET textboxes. This thing works well.
My dilemma is this:
Scenario 1: Handling the save in the user control - OnClick event
I have a button to save this. I need to get the value of the "selected grid" so I am using this snippet below and again works well.
foreach (GridDataItem dataItem in radgrdTariffNetworkDistributorRateItems.SelectedItems)
{
string ID = dataItem.OwnerTableView.DataKeyValues[dataItem.ItemIndex]["SupplierRateItemID"].ToString();
}
But then how do I get the id of the parent grid where this control sit? I use the following this event to save: protected void bttnNetworkTariffReviewItemInsert_Click(object sender, EventArgs e) the e of course not the right one though?!?!?
GridDataItem parentItem = (GridDataItem)e.Item.OwnerTableView.ParentItem;
string reviewID = parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["ID"].ToString();
Scenario 2: Handling the save in the page instead (OnInsertCommand on the master grid)
With this approach works well to get id of the grid etc BUT I am having a problem to get selected grid in the UserControl and plus couple controls value. How do I make this feasible?
Logically, I should handle this at the user control level to save but again because the user control relying on the child grid I am having trouble to get this value.
I am appreciated your suggestion.