Posts Tagged ‘syntax’

stdClass Object problems

Monday, August 23rd, 2010

I’m struggling to parse the below data using PHP. An API returns it, and I’ve tried various syntaxes. How do I return the data in a non-object way? Or, what’s the syntax to call the data using the stdClass?

Could I convert this to one data based array, or even two? I’m lost when it comes to object-based data sets.

stdClass Object
(
    [0] => stdClass Object
        (
            [district] => stdClass Object
                (
                    [state] => NY
                    [number] => 29
                )

        )

    [1] => stdClass Object
        (
            [district] => stdClass Object
                (
                    [state] => NY
                    [number] => 26
                )

        )

)

When i create the object on my own, and then do a var_dump, I get this:

object(stdClass)#8 (2) {
  [0]=>
  object(stdClass)#4 (1) {
    ["district"]=>
    object(stdClass)#5 (2) {
      ["state"]=>
      string(2) "NY"
      ["number"]=>
      string(2) "29"
    }
  }
  [1]=>
  object(stdClass)#6 (1) {
    ["district"]=>
    object(stdClass)#7 (2) {
      ["state"]=>
      string(2) "NY"
      ["number"]=>
      string(2) "26"
    }
  }
}

stdClass Object problems

Monday, August 23rd, 2010

I’m struggling to parse the below data using PHP. An API returns it, and I’ve tried various syntaxes. How do I return the data in a non-object way? Or, what’s the syntax to call the data using the stdClass?

Could I convert this to one data based array, or even two? I’m lost when it comes to object-based data sets.

stdClass Object
(
    [0] => stdClass Object
        (
            [district] => stdClass Object
                (
                    [state] => NY
                    [number] => 29
                )

        )

    [1] => stdClass Object
        (
            [district] => stdClass Object
                (
                    [state] => NY
                    [number] => 26
                )

        )

)

When i create the object on my own, and then do a var_dump, I get this:

object(stdClass)#8 (2) {
  [0]=>
  object(stdClass)#4 (1) {
    ["district"]=>
    object(stdClass)#5 (2) {
      ["state"]=>
      string(2) "NY"
      ["number"]=>
      string(2) "29"
    }
  }
  [1]=>
  object(stdClass)#6 (1) {
    ["district"]=>
    object(stdClass)#7 (2) {
      ["state"]=>
      string(2) "NY"
      ["number"]=>
      string(2) "26"
    }
  }
}

display jquery returned data correctly

Monday, August 23rd, 2010

hi…i’ve been a prototype user for a few years, and now for several reasons, i’m moving to jquery.. but still have yet familiarize myself with jquery’s syntax.. my question is

how do I convert this prototype code to jquery correctly?

new Ajax.Updater('displayArea', 'shoutbox.php', { method:'post',
    parameters: {action: 'display', some_data: some_data}
});

and here’s what i did:

$.post("shoutbox.php", {action: "display", some_data: some_data}, function(data){$("#displayArea").text(data);},"html");

i got the exact return result from jquery and prototype, but the problem is, when jquery updates the “displayArea”, it’s not quite what I expected. the returned data has some html codes in it, and instead of displaying a new line for the html tag ‘br’, jquery just display the ‘br’ in plain text. what i means is it’s displaying html codes, and that’s not what I want. hope you all get what i meant….

thanks

markup text parser like stackoverflow’s formatter in Objective-C

Sunday, August 22nd, 2010

Hi,

I’m in the process of creating a markup editor in Objective C. I require the following functionality:

  • Recognise the demarcation of a block eg **block**
  • Delete the start and end “tags” eg “The next text is **bold**” becomes “The next text is bold”
  • Determine the start and end positions of the marked-up text in the new context: “The next text is bold”

Edit:
As I may expand the syntax in the future (it will be very limited at the moment), it is important that parsing be top-down such that the start and end positions of the text always correspond with the resulting text. For this reason regex may not be the best solution.

What is the best way to do this?

Need help understanding MVVM Tutorial, RelayCommand & Use of lambdas

Sunday, August 22nd, 2010

i am reading this tutorial

i don’t understand what the below code is trying to do. 1st, the syntax reminds me properties, but with add/remove instead.

but what is CommandManager.RequerySuggested?

It delegates the event subscription to
the CommandManager.RequerySuggested
event. This ensures that the WPF
commanding infrastructure asks all
RelayCommand objects if they can
execute whenever it asks the built-in
commands

public event EventHandler CanExecuteChanged
{
    add { CommandManager.RequerySuggested += value; }
    remove { CommandManager.RequerySuggested -= value; }
}

also, save command is configured with lambdas. 1st, there are 2 param variables. will they conflict? i cannot just do something like RelayCommand(this.Save(), this.CanSave) or is there no such syntax.

_saveCommand = new RelayCommand(param => this.Save(),
                                param => this.CanSave );

Webpart is not refreshed when closing a JQuery popup window

Sunday, August 22nd, 2010

Hi I have created two user controls(Say uc1.ascx and uc2.ascx). I have wrapped second user control(uc2.ascx) as a DIV in first user control(uc1.ascx), to populate uc2.ascx as a JQUERY modal popup. I have created a Webpart(class file) where I specifed the first user control path. Now in an aspx page, I have added this webpart as a webpart zone. The syntax loks somethng like this.

<Webpart manager></Webpartmanager>

<WebpartZone>

<Zonetemplate>

<cc1:Customer…>

</ZonTemplate>

</WebpartZone>

In my first user control(uc1.ascx), I have gridview. Now when I clik on a button in a webpart, a JQuery modal popup comes where I fill the details and after saving the details, the popup closes. But the webpart is not refreshed due to which I am not able to get the updated data in the grid view.

Can any one know how to resolve this?

How can I refresh a particular webpart when I have multiple webparts in the same page in order to get updated data?

Is there a template hiearachy in WordPress similar to Django?

Sunday, August 22nd, 2010

I’m a veteran Django programmer and a newbie in WordPress. In Django, we have the concept of templating such that I can create File1 which contains some html blocks that can be overriden by child File2. We are using {block block1} syntax in Django. This makes re-use in django very easy. In PHP (WordPress) do we have the same concept? I want to make File1 and override some of its html blocks by File2.

batch file loop

Sunday, August 22nd, 2010

I want the syntax for FOR loop in batch file,windows

How to create a process by a “LPTHREAD_START_ROUTINE lpStartAddress” alike argument?

Sunday, August 22nd, 2010

I want to create a process with syntax similar to the following,except that I don’t want to create a thread?

     hThread = CreateThread(
        NULL,              // no security attribute
        0,                 // default stack size
        InstanceThread,    // thread proc
        (LPVOID) hPipe,    // thread parameter
        0,                 // not suspended
        &dwThreadId);      // returns thread ID

But I’ve checked the reference for CreateProcess and a sample :

BOOL result = ::CreateProcess(
  L"C:\Windows\NOTEPAD.exe",
  NULL,
  NULL,
  NULL,
  FALSE,
  NORMAL_PRIORITY_CLASS,
  NULL,
  NULL,
  &startupInfo,
  &processInformation
);

It seems I must specify an existing executable to create a process? How can I create one by a callback similar to InstanceThread ?

Eclipse Flash Builder 4: Syntax customization?

Saturday, August 21st, 2010

Using Flash Builder 4 (FB), is there a way to customize syntax highlighting for variable scope (member, parameter, local)?

I’ve heard this is possible in other Eclipse plugins and wondering if it is possible with FB or if not is there an easy way to add it manually?

Cheers,
Jono