Wednesday, April 18, 2012

Can sphinx link to documents that are not located in directories below the root document?

I am using Sphinx to document a non-Python project. I want to distribute ./doc folders in each submodule, containing submodule_name.rst files to document that module. I then want to suck those files into the master hierarchy to create a spec for the entire design.



I attempted to include files in the master project_spec.rst document toctree like this:

.. toctree::
:maxdepth: 2

Module 1 <../../modules/module1/docs/module1>

However this error message results:

WARNING: toctree contains reference to nonexisting document u'modules/module1/docs/module1'

Is it not possible to use ../ in a document path somehow?

Magento Wishlist - Remove item

I've built a custom script to add and remove items to the wishlist using AJAX. Adding products is not a problem but I can't figure out how to remove an item. The Magento version is

The script is in /scripts/ and looks like this:

include_once '../app/Mage.php';


$type = (!isset($_GET['type']))? 'add': $_GET['type'];
$id = (!isset($_GET['id']))? '': $_GET['id'];

$session = Mage::getSingleton('core/session', array('name'=>'frontend'));
$_customer = Mage::getSingleton('customer/session')->getCustomer();

if ($type != 'remove') $product = Mage::getModel('catalog/product')->load($id);

$wishlist = Mage::helper('wishlist')->getWishlist();

if ($id == '')

if ($type == 'add')
elseif ($type == 'remove')
$wishlist->updateItem($id,null,array('qty' => 0));

$products = Mage::helper('wishlist')->getItemCount();
if ($type == 'add') $products++;
if ($type == 'remove') $products--;

$result = array(
'result' => 'success',
'type' => $type,
'products' => $products,
'id' => $id

echo json_encode($result);
catch (Exception $e)
$result = array(
'result' => 'error',
'message' => $e->getMessage()
echo json_encode($result);

So when I request the script with "remove" as $type and the wishlist item id as $id I get the following error:

Fatal error: Call to a member function getData() on a non-object in /[magento path]/app/code/core/Mage/Catalog/Helper/Product.php on line 389

When I look at the function updateItem() in /app/code/core/Mage/Wishlist/Model/Wishlist.php it expects a "buyRequest", but I can't figure out what that is.

Weird linker error linking to opencv... "LNK1107: invalid or corrupt file: cannot read at 0x2E8"

This OpenCV build was working for me a few nights ago. I am trying to run the example 'grabcut.cpp' file given with the OpenCV examples and so I set up a quick project and brough the cpp file in. Then, I set up all of the standard configurations and got this error on building.

error LNK1107: invalid or corrupt file: cannot read at 0x2E8


What does this mean? Have I done something wrong?

Display all items in wishlist on 1.6

On the customers side the wishlist only displays 3 products, is there a way to display all of their products in their wishlist like in the admin? We are using Magento 1.6.

Targetting WCF Web Api Message Handler at specific requests

Is it possible to target DelegatingHandlers (message handlers) in WCF Web Api at specific requests (as is possible with an operation handler) or are message handlers global. By that I mean they are called for every request.

Javascript library for a "Universal Wishlist" type bookmark-button?

Amazon has a Universal Wishlist button which can be added to the browser bookmarks bar, then pressed on any website and it sends the details of the page the user is currently looking at to Amazon. Amazon then pull out the product details out of the page and add the product to the user's wish list.

Do any libraries exist to replicate this (or similar) functionality for my own site? I could probably replicate it by copying Amazon's code using javascript, but don't want to waste my time if there already exists a library to do this or something similar that I can adapt. I'm also not really sure what this type of bookmark-button is called so it's difficult to google for.


Is there a way to change content offset via Core Animation on UIScrollView with reusing views?

EDIT: I got some progress, so I have simplified and narrowed the problem: I have created new question, which is more clearer and more understandable I hope

I have very large horizontally scrolling UIScrollView, which is reusing its subviews. When user scrolls left, the rightmost view is moved to the leftmost position and its content is updated. Similarly when user scrolls right, the leftmost view is moved to the rightmost position and its content is updated. Similarly like in UITableView. This works nicely using scrollviewDidScroll: delegate method.

Now I need to change offset programatically, but with custom animation behaviour (inertia and bounce back to the final position).

To prototype this, I use

[UIView animateWithDuration:contentOffsetCADuration 
[self setContentOffsetNoDelegateCalls:contentOffset animated:NO];
completion:^(BOOL finish){
dispatch_async(dispatch_get_main_queue(), ^{
[timer invalidate];

where I animate content offset with disabled delegate callback, so that views are not messed during animation. But I need something to simultaneously reuse and reposition them.

My solution is to create timer and call scrollViewDidScroll: manually so that reusing works as usual, parallel to animation. But it simply does not work - nothing is reused and scrollview's content after animation is in the same state as before animation -> formerly visible pages are moved out of screen.

So the question narrows down how to move subviews and update their content during animation?

Or maybe there might be completely different way doing this ...

How to sort the entire gridview rows by the datetime column?

  • There's a gridview on my asp page and sqldatasource to bind the data
    table info to gridview.

  • I have 6 columns:

  • First column is called ID : type : int, increment by one , primary

  • The other columns are name,age etc..

  • The last column is called Added : type : datetime .

I need to add a button or dropdownlist doesn't matter where I can sort the entire gridview rows by the DateTime Column.

How do I speed up a site? [closed]

I've recently built a website that uses a lot of javascript and especially jquery but a few pages are very slow to load and I didn't know if there was anyway I could speed that up. I've tried loading the images first using a script I found here: but that didn't make any difference.
The page I'm having the biggest problem with is this one: although this page is also very slow:
I'd be really grateful if anybody could give any advice or pointers to help with this please. Thanks

C# interface with implementation without abstract class?

I am writing a library and I want to have an interface

public interface ISkeleton
IEnumerable<IBone> Bones { get; }
void Attach(IBone bone);
void Detach(IBone bone);

The Attach() and Detach() implementation actually should be the same for every ISkeleton. Thus, it could essentially be:

public abstract class Skeleton
public IEnumerable<IBone> Bones { get { return _mBones; } }

public List<IBone> _mBones = new List<IBone>();

public void Attach(IBone bone)

public void Detach(IBone bone)

But C# doesn't allow multiple inheritance. So among various issues, users have to remember to inherit from Skeleton every time they want to implement Skeleton.

I could use extension methods

public static class Skeleton
public static void Attach(this ISkeleton skeleton, IBone bone)

public static void Detach(this ISkeleton skeleton, IBone bone)

But then I need to have

public interface ISkeleton
ICollection<IBone> Bones { get; }

Which I do not want, because it is not covariant and users can bypass the Attach() and Detach() methods.

QUESTION: Must I really use an abstract Skeleton class or are there any or tricks and methods?

NoMethodError in Shop#new

Im pretty new to Ruby but now i get an error when i try to at an barber to my database.

I get the following error:

NoMethodError in Shop#new

Showing /Users/Augus/Rails/Barbershop/app/views/shop/new.html.erb where line #3 raised:

undefined method `barbers_path' for #<#:0x105bfe360>
Extracted source (around line #3):

1: <H1>New barber</H1>
3: <%= form_for @barber do |f| %>
4: <%= f.text_field :name %> <br />
5: <%= f.submit %>
6: <% end %>

I really dont know what im doing wrong.

My shop_controller.rb:

  def new
@barber =

My view new.html.erb:

<H1>New barber</H1>

<%= form_for @barber do |f| %>
<%= f.text_field :name %> <br />
<%= f.submit %>
<% end %>

<%= link_to 'Back', shop_path %>

And i do got this in my routes:

  resources :shop

How to configure eclipse for C programming

I've installed an eclise for C/C++ developers.
But unable to compile the code. It doesn't get #include saying: unresolved inclusion
I wonder if I have to make some addtional configuration.
Please advise.

Assembly MIPS not returning right value

I have this C code:

#include <stdio.h>

int BubbleSort(int *v);

int main()
int x1=4,x2=2,x3=10,x4=1,x5=6;
printf("The value of f is: %d\n", PolyCalc(x1,x2,x3,x4,x5));
return 0;

int BubbleSort(int *array){
int i,j,changes = 0,inPosition, size = 5;
for (i = 1; i < size; i++)
inPosition = 0;
for(j = 0; j < size - i; j++)
if(array[j] > array[j+1])
int temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
inPosition = 1;
return changes;

This is what I want to do.

1 - Calculate PolyCalc (PolyCalc is codded in Assembly - Will post code below)

2 - From the assembly PolyCalc code, jump to the C BubbleSort function and receive the return in the assembly code

3 - On the Assembly code, print the number of changes that BubbleSort made until the array was sorted

4 - Return the PolyCalc resulting value to the C code and make the final printf.

This is my Assembly code:

01          .data
02 print: .asciiz "Where made %d changes until the array was sorted\n"
03 .text
04 .globl PolyCalc
06 PolyCalc:
09 lw $8, 16($29) # Goes to the stack and gets x5
10 addi $29,$29, -4 # Reserve space on the stack
11 sw $31,0($29) # Stores the ra of the caller on the stack
13 # Calculate this f = 2(x1+x2)(x3-3x4x5)
15 add $10,$4,$5 # Adds x1 and x2
16 mul $10,$10,2 # Multiply by 2 the sum of x1 and x2
17 mul $11,$7,$8 # Multiply x4 e x5
18 mul $11,$11,3 # Multiply by 3 the multiplication of x4 by x5
19 sub $11,$6,$11 # x3 minus the previous result
20 mul $10,$10,$11 # Makes the final product
23 ##### Will add some code one this space later #######
37 move $2, $10 # Moves the the return value
38 fim:
40 lw $31,0($29) # Loads the return address of the caller
41 addi $29,$29,4 # Restores stack pointer

If I compile both my main.c and prog.s I get this output

The value of f is: -96 So the first part is OK. Not only it's calculating the value as it should but also returns the value to my main.c and main.c prints the result.

Second part.
Create a print on assembly. Added this code to the previous one.

29      #Prints the number of changes on BubbleSort
30 la $4,print
31 move $5,$10
32 lw $25,%call16(printf)($28)
33 jalr $25

Running this the output is

Where made -96 changes until the array was sorted

The value of f is: 1

I can see now that the print is working ok. Although It's not printing the number of changes made on BubbleSort it´s printing the correct value that I've passed to printf.

The last printf it's not working as expected. If I change 33 jalr $25 to 33 j $25 it prints The value of f is: 50. So this is my first question:

Q1 - Why it's not returning the right value (-96) to my main.c?

Did not change nothing on my register $10 so it should return the right value...

Made this changes to the code:

10      addi    $29,$29, -8     # Reserve space on the stack
11 sw $31,4($29)
22 sw $10,0($29) # Stores on the stack the value calculated on the above lines
35 lw $10,0($29) # Restores PolyCalc value
40 lw $31,4($29)
41 addi $29,$29,8 # Restores stack pointer

And gives this:

Where made -96 changes until the array was sorted

Bus error

Made this:

10      addi    $29,$29, -8     # Reserve space on the stack
11 sw $31,0($29)
22 sw $10,4($29) # Stores on the stack the value calculated on the above lines
35 lw $10,4($29) # Restores PolyCalc value
40 lw $31,0($29)
41 addi $29,$29,8 # Restores stack pointer

Now it works but I quite understand why. The output is:

Where made -96 changes until the array was sorted

The value of f is: -96

Q2 - Why does the second solution work and not the first one?

Final step. Since the assembly code is returning the correct value to main.c and the print function is working as expected inside the assembly code, just have to call from my prog.s the BubbleSort function on main.c.

Made this:

24      la  $4,0($4)        # Stores in  `$4` the address of the first parameter 
25 j BubbleSort # Calls bublesort
26 move $14,$2 # Moves to `$14` the number of changes made
31 move $5,$14 # Print the number of changes

It gives:

Segmentation fault

Final attempt. Thought this way. Since 09 lw $8, 16($29) # Goes to the stack and gets x5gets x5 give it a try and made 08 la $15,0($29) believing that the address of the first element of the array was here. Changed 24 la $4,0($4) to 24 la $4,0($15) and running this gives:

The value of f is: 6

So no segmentation fault but still not correct.

Q3 - What am I doing wrong? How can I call bubblesort inside my assembly code?

change() fires only when losing focus

I currently using the change function from jQuery. The change event is only fired when i click outside the textfield. So when i insert a text in my textbox nothing is happening but when i lose the focus on the textfield the event fires.
No i want to fire the event without having to click outside the textfield.

this is my code:

crmAccount = jQuery(this).val();
lijstAccounts = [];

url: "http://localhost/papa/jQuery/development-bundle/demos/autocomplete/searchAccounts.php?jsonp_callback=?",
dataType: 'jsonp',
jsonp: "jsonp_callback",
data: {
featureClass: "P",
style: "full",
maxRows: 12,
name_startsWith: jQuery(this).val()
success: function( data ) { data, function( item ) {
{ result : textext.itemManager().filter(lijstAccounts, query) }
return {
label: item.label,
value: item.value


Process.Start not working on live site

Im trying to open the email client after a user accepts a disclaimer in a popup box whenever they click email someone. It works on local but will not work on live.

public void btnEmail_click(object sender, EventArgs e)

Flex command issue

I'm having problems with converting .css file into .swf, if i run the flex commad through the shell it's working, but unfortunately through php it's not working.

$tm = time();
$file_n = $_FILES["file"]["name"];
$path = "";
if ($_FILES["file"]["type"] == "text/css") {
if ($_FILES["file"]["error"] > 0) {
return "Error has occured: " . $_FILES["file"]["error"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"])) {
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $tm . "_" . $file_n);
$path = "upload/" . $tm . "_" . $file_n;
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
$path = "upload/" . $file_n;

$paths = explode(".", $path);
exec("mxmlc ".$file_n);
$parr = array('path' => $paths[0].".swf");
$jurl = json_encode($parr);
echo $jurl;
echo "Sorry not supported file type!";

Displaying and editing HTML code in a DataGridView

I have a DataGridView that is bound to a DataSet. The DataSet has its data from an XML file. In the XML file there is one element that contains basic html data (only <p> and <strong>):

<?xml version="1.0" encoding="utf-8"?>
<desc><![CDATA[[<p>Some <strong>text.</strong></p>]]></desc>

When I have a DataGridView that has a column bound to this field desc the html gets displayed as string with its tags (<p>Some <strong>text.</strong></p>). When I save this xml back, the tags are converted to their html entities.

How can I display the html code as rich text in the textbox ("Some text.")? I guess I need to make a custom richtextbox column type here but I'm a little bit stuck as beginner. Furthermore the text should be editable with a richtexteditor.

Can someone give me some help on this?

sending emails from localhost and online

I know how to send email through smtp in code in c#

if i set a gmail smtp it works fine in localhost
but when i upload and make it online then gmail ( settings dont work. i have to change settings everytime to ( at godaddy after uploading

Now my question is! Is there any way i can find out if im on localhost in code or online then change the settings dynamically im storing my settings in db
my working code is

mm.LoadByPrimaryKey(4);//get body , subject etc from db
mc.LoadByPrimaryKey(1);// get settings from db (host, from , port etc)

var maTo = new MailAddress(strEmail, userName);
var mMailMessage = new MailMessage
Subject = mm.Subject,
Body = strBody,
IsBodyHtml = true,
Priority = MailPriority.High,
From =new MailAddress(mc.AdminEmailAddress),
DeliveryNotificationOptions= DeliveryNotificationOptions.OnFailure
var mSmtpClient = new SmtpClient
UseDefaultCredentials = false,
Host = mc.Host,
Credentials = CredentialCache.DefaultNetworkCredentials,
DeliveryMethod = SmtpDeliveryMethod.Network};

i dont want to change my settings everytime, wether im online or developing in localhost environment

i want this flow and how do i know my application is online or localhost in code behind

if(myconnection ==localhost) then fetch gmail credentials 
else if (myconnection==online) then fetch godaddys credentials

Magento - Accessing a customer's wishlist

I would like to be able to load a customer's wishlist and return the product id's of the products within the list

I am using:

$wishList = Mage::getSingleton('wishlist/wishlist')->loadByCustomer($customer);
$wishListItemCollection = $wishList->getItemCollection();

The problem is that the arrays in the Item Collection are protected and I can't find any methods to extract the data.

Is there another way to do this?

My Sms BroadCast Receiver works fine with Emulator but not on LG P500 phone with 2.2

I just want a working sms broadcast receiver on phone. This code works fine on emulator but not on phone.

Read somewhere motorola uses the action android.provider.Telephony.WAP_PUSH_RECEIVED and not android.provider.Telephony.SMS_RECEIVED
Not sure whats the case with LG.So included it but not working on phone. Any Help is appreciated.

package com.aaj;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import android.util.Log;
import android.widget.Toast;

public class SMSBroadcastReceiver extends BroadcastReceiver {

private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
private static final String WAP_PUSH_RECEIVED = "android.provider.Telephony.WAP_PUSH_RECEIVED";
private static final String TAG = "SMSBroadcastReceiver";

public void onReceive(Context context, Intent intent) {
Log.i(TAG, "Intent recieved: " + intent.getAction());

if (intent.getAction().equals(SMS_RECEIVED) || intent.getAction().equals(WAP_PUSH_RECEIVED) ) {

Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[])bundle.get("pdus");
final SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < pdus.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
if (messages.length > -1) {
Log.i(TAG, "Message recieved: " + messages[0].getMessageBody());
String msg=messages[0].getMessageBody();
String no= messages[0].getOriginatingAddress();

Toast.makeText(context, msg, 1000).show();
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("5556", null,no+": "+ msg, null, null);

Here is my manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"/>
<uses-permission android:name="android.permission.RECEIVE_MMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.WRITE_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_WAP_PUSH"/>

android:label="@string/app_name" >
<receiver android:name="SMSBroadcastReceiver">
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
<action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED"/>



matlab: read subsection of an image

I have a sequence of large images I would like to load into matlab and then apply some processing too. Due to the images size, reading them in takes a long time, and fills the computer memory very fast.

However, I am only interested in the middle section of the images, a region of about 100 by 100 pixels or so.

Is there a way to only read in that section of the image, therefore saving time, and memory?

Currently I am using:

ROIx = 450:550;
ROIy = 650:750;
image = double( imread( filename ) );
image = image(ROIx, ROIy);

However, imread() loads the whole image, and this takes a long time. Is there a way only to read the part I am interested in?

(One procedure would be to go through and crop each image into a smaller one and resave it. But I would prefer not to crop the images).


Magento add pager toolbar to wishlist

Is it possible to use the catalog collection pager for the wishlist, and if so how can I implement this into the wishlist?

iOS - Storyboards - Link the same UITableViewController to 2 different UITabBarControllers

I'm working on a navigation style iOS app using Xcode 4.3.2, SDK v5.1 and storyboards. The user can take several routes through the app but there is one particular table view scene that is used whichever route is taken. I therefore just want to have this scene defined once, but be visible as a tab page in more than 1 different tab bar controllers. The storyboard designer allows these relationships to be defined, but when the app is run the table view scene only appears as a tab button in the tab bar controller that it was most recently connected to.

Am I trying to achieve the impossible? I would have thought if storyboard lets me connect everything up then it should be achievable.

Many thanks,

checking memory_limit in PHP

I'm need to check if memory_limit is at least 64M in my script installer. This is just part of PHP code that should work, but probably due to this "M" it's not reading properly the value. How to fix this ?

echo "<phpmem>";
if(key_exists('PHP Core', $phpinfo))
if(key_exists('memory_limit', $phpinfo['PHP Core']))
$t=explode(".", $phpinfo['PHP Core']['memory_limit']);
echo "<val>{$phpinfo['PHP Core']['memory_limit']}</val><ok>$ok</ok>";
echo "<val></val><ok>0</ok>";
echo "<val></val><ok>0</ok>";
echo "</phpmem>\n";

drawing sine wave using opencv

I want to draw a sine wave on a image using openCV. I developed the following code, but the output is not coming as expected:

#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "opencv/cv.h"
#include "opencv/highgui.h"
void main()
double y[100];
float x;



IplImage *grf = cvCreateImage( cvSize( 200, 200), IPL_DEPTH_8U, 1 );

for(int x=0;x<100;x++)
cvLine(grf , /* the dest image */
cvPoint(x, y[x]), /* start point */

cvPoint(x+1, y[x+1]), /* end point */
CV_RGB(255, 0, 0), /* the color; green */
2, 4, 0); /* thickness, line type, shift */


cvNamedWindow("img", CV_WINDOW_AUTOSIZE);
cvShowImage("img", grf);

I have verified the values coming in y array is correct, and plotted these y values using MATLAB. The MATLAB plot is coming a sine wave. Can you tell me why i am not getting correct plot using above code.

My output plot of sine wave is coming as below: you can see I am just getting a horizontal line instead of the sine wave. Any help regarding this?

enter image description here

UIPickerView NSUnknownKeyException

I've seen a lot of similar questions but none of them solve my problem or made the solution clear to me. I've a made a nib file with a UIPickerView.
When I run the application I get this error.

Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<UIApplication 0x68633e0> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key pickerview.'

My ViewController.h

#import <UIKit/UIKit.h>
#define CATEGORY 0
#define VALUES 1

@interface ViewController : UIViewController <UIPickerViewDelegate , UIPickerViewDataSource> {
NSDictionary* dictionary;
NSArray *keys,*values;
IBOutlet UIPickerView *pickerview;
@property (retain,nonatomic) NSArray *keys, *values;
@property (retain,nonatomic) NSDictionary *dictionary;
@property (retain,nonatomic) UIPickerView *pickerview;

My ViewController.m

#import "ViewController.h"

@implementation ViewController
@synthesize keys,values,dictionary;
@synthesize pickerview;

-(void)dealloc {
[keys release];
[values release];
[dictionary release];
[pickerview release];
[super dealloc];

- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];

#pragma mark - View lifecycle
- (void)viewDidLoad
NSBundle* bundle = [NSBundle mainBundle];
NSString* str = [bundle pathForResource:@"testlist" ofType:@"plist"];
NSDictionary* tempd = [[NSDictionary alloc] initWithContentsOfFile:str];
self.dictionary = tempd;
[tempd release];
self.keys = [dictionary allKeys];
self.values = [dictionary objectForKey: [keys objectAtIndex:0]];
[super viewDidLoad];

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 2;

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
if (component == CATEGORY) {
return keys.count;
return values.count;

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
if (component == CATEGORY) {
NSArray* tvalues = [dictionary objectForKey:[keys objectAtIndex:row]];
self.values = tvalues;
[pickerview selectRow:0 inComponent:VALUES animated:YES];//Xreiazetai?
[pickerview reloadComponent:VALUES];

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
if (component == CATEGORY) {
return [keys objectAtIndex:row];
return [values objectAtIndex:row];

- (void)viewDidUnload
[super viewDidUnload];

- (void)viewWillAppear:(BOOL)animated
[super viewWillAppear:animated];

- (void)viewDidAppear:(BOOL)animated
[super viewDidAppear:animated];

- (void)viewWillDisappear:(BOOL)animated
[super viewWillDisappear:animated];

- (void)viewDidDisappear:(BOOL)animated
[super viewDidDisappear:animated];

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);


I made sure that dataSource , delegate outlets of the Picker are pointing to the File's Owner as also the picker view referencing outlet.

list operations using list comprehension

I have a list.

a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]

I want to use list comprehension & wanted to create output as :

output1 = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]

('value', 1)
('value', 2)
('value', 20)

I can create output1 and output2 using for loop but I dont have idea that how I can use list comprehension for the same.

If any one knows this, kindly let me know.

thanks in advance.

Printing UL LI nested in Foreach Loop

i have an array structure like

[members] => Members List | 26
[member.php?id=3] => John | 26-26
[member.php?id=4] => Alice | 26-26
[member.php?id=5] => Michel | 26-26
[news] => News details | 45
[alerts] > Alerts | 32

i traverse this using foreach loop. i want to print the Whole list as UL LI. The Members List will be an LI but when its childs comes (memeber.php?id=*) etc then it should inherit UL LI. I want the child to be in a nested LIs


$counter = 0;
foreach($array as $key => $values)
if($counter == 0)
echo "<ul>";
if($key != "" && $key != "END")
echo "<li>".$values."</li>";
if($key == "END")
echo "</ul>";

Android change view from other thread

I wrote a code to download an image from internet. And i have to show it in a ImageView which is dynamically created.

And i am getting an error that Only the original thread that created a view hierarchy can touch its views. I know i have to write a handle but how can i do that?


Here is my code :

public class ResimCek implements Runnable {

int resimID = 0;

public ResimCek(int parcaID) {
// store parameter for later user
resimID = parcaID;

public void run() {

int resID = getResources().getIdentifier(Integer.toString(resimID) , "tag", getPackageName());
ImageView resim = (ImageView) findViewById(resID);

Drawable image = ImageOperations(getBaseContext(),"" + Integer.toString(resimID) + ".jpg" ,"I" + Integer.toString(resimID) + ".jpg");

// I AM GETTING ERROR HERE ******************
resim.setImageDrawable(image); // *************************

private Drawable ImageOperations(Context ctx, String url, String saveFilename) {
try {
InputStream is = (InputStream) this.fetch(url);
Drawable d = Drawable.createFromStream(new URL(url).openConnection().getInputStream(),saveFilename);
return d;
} catch (MalformedURLException e) {
return null;
} catch (IOException e) {
return null;

public Object fetch(String address) throws MalformedURLException,IOException {
URL url = new URL(address);
Object content = url.getContent();
return content;
private void MalzemeEkle(String malzemeKodu, String malzemeTanimi) {
ImageView parcaresmi = new ImageView(this);
Runnable r = new ResimCek(Integer.parseInt(malzemeKodu));
new Thread(r).start();


I'm quite a newbie in PHP and today I discovered DOTNET class.

So I studied manual, surfed the web to find some example and finally wrote my test app:

  1. Created a new DLL using Framework 4.0 Client Profile

  2. Signed the assembly with a strong name key

  3. Marked assembly as COM-Visible

This is the test code I wrote

using System;

namespace CSharpCOM
public class CSharpCOMClass
public string Base64(string s)
return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(s));

I compiled the assembly and then registered in GAC (gacutil /if fullpath\CSharpCOM.dll).

If I use gacutil /l CSharpCOM I see

La cache di assembly globale contiene gli assembly seguenti:

csharpcom, Version=, Culture=neutral,
PublicKeyToken=beb607ae770f5750, processorArchitecture=MSIL

Numero di elementi = 1

So everything seems ok.

Then wrote this basic php:

$csclass = new DOTNET("CSharpCOM, Version=, Culture=neutral, " .
echo $csclass->Base64("Test string"),"\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";

Whatever I try, loading page hosted in Apache (http://localhost/test01/dotnet.php) I always get

Caught exception: Failed to instantiate .Net object [CreateInstance]
[0x80070002] Impossibile trovare il file specificato.

Translation could be: unable to find specified file

Just another thing: using some example (a very basic one here) I read that my assembly (when registered) should be found on %windir%\assembly, but I'm only able to find it in %windi%\Microsoft.NET\assembly\GAC_MSIL\CSharpCOM\v4.0_1.0.0.0__beb607ae770f5750: is this correct? Why don't I have it on first directory?

More: if I create another framework project and try to add a .NET reference I can't find my assembly: is this related to the fact I'm not able to load this assembly from PHP?

Last note: I tried it on Windows XP Professional SP3 32bit and on Windows Seven Enterprise 64bit


This works: $form = new DOTNET('System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089', 'System.Windows.Forms.Form');