Thursday, April 19, 2012

Uploading an image which is within <img> tag to server

Can I upload an image to my web server. I know that, If I have file input in my web page, then I can easily upload it and get it like $_FILE["name"] at my server(PHP). But I am developing a web page for iPad which doesn't expose the file system. But later, this will be handled by using phone gap. But now for the demo sake, I want to show that upload works. So, now assume that I have the path to a file. And I have it in my web page like <img src="path" alt="">



Can I upload this to my server by any means?





Filling form with Datamapper ORM object - Codeigniter

I'm trying to get a form populated by data coming from a Datamapper object.



Here's my controller code:



function find()
{
$sub_list = new Subject();
$data['s'] = $sub_list->all;

$this->load->view('professors/find', $data);

}


In my view I'd want to show a dropdown form with the data coming from that object but I can't make it work.
This code:



<?php echo form_dropdown('accesso', $s);?>


Just show me "Subject" for every field in the db.



Many thanks for the help! I'm sorry for the silly issue!



EDIT: Problem solved!



<?php foreach ($s as $a):?>
<?php $options[$a->name] = $a->name; ?>
<?php endforeach ?>
<?php echo form_dropdown('accesso', $options);?>


Thanks!





wxPython TextCtrl auto detect file/folder path [closed]

Is there a mechanism that detects (highlight and generate mouse event) a file or a folder path in a wx.TextCtrl?
A similar mechanism exists for URL detection (using style = wx.TE_AUTO_URL with wx.TE_RICH).



Example:



"This is an example how I want TextCtrl to detect C:\Temp\Folder\temp.txt as a path."



Thanks,
Omer.





Set Content/Media type - Restlet

How do you set the content type in Restlet (version 2.0 for google app engine)? In this case, I'd like to set the content type to ""text/xml".



I have:



public class SubResource  extends ServerResource {

@Get
public Representation get(Representation representation){

setStatus(Status.SUCCESS_OK);
StringRepresentation sr = new StringRepresentation(getSomeXml());

return sr;
}
}


I'm unsure even if it is a value that is set in the Representation, or if it is set from the ServerResource class the same way that the return code is.



ANSWER:



    StringRepresentation sr = new StringRepresentation(getSomeXml());
sr.setMediaType(MediaType.TEXT_XML);







Unattached git repository?

I have a folder running locally that contains a website. It runs on xampp on my computer quite happily. I know that has been hooked up to git in the past and I continue to add, commit and push my changes through the command line and it all works as all my other git repos do, except they update on my github dashboard online to show when they were last edited etc.



Problem is this one folder, Demo, isn't updating the supposedly connected repo on my github dashboard.. I've made loads of changes and I'm committing it to somehwere but it's not where I expected... its showing the most recent changes being over 4 months ago! Is there any way to easily reconnect the two? I dont' mind losing whatevers in the ghost repo showing on github but I can't lose anything on my local Demo folder. I'm happy enough on git to do the basics but if anything unexpected happens I get terrified I'm going to delete everything!





SQL Datetime Not Equal To Is Not Working

I have a database consisting of a Customer, Product, and Transaction table.



I'm trying to write an SQL statement to list all customers' names and SSN's for those customers who have made no transaction in the year 2000.



The TransactionDate column in the Transaction table is a Date/Time data type (e.g. 2000-12-18 00:00:00).



This is the SQL code I've written:



SELECT DISTINCT CustomerName, Customer.CustomerSSN 
FROM Customer, Transaction
WHERE Customer.CustomerSSN=Transaction.CustomerSSN
AND YEAR(TransactionDate)<>2000;


The not equal to symbol (<>) seems to not be working for some reason. When I change it to an equal sign, it does return the correct result...



Any advice is appreciated.





Connection refused on bluetooth socket.connect() - android

First, I know this issue has been up before but none of the sugested solutions i found solves my problem...



After pairing device with



Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
tmp = (BluetoothSocket) m.invoke(device, 1);


I try to connect using



boolean connected = false;
String cause = "";
for(int i=0; i<3; i++){
try {
mmSocket.connect();
} catch (IOException e) {
Log.e("btact","fail"+i+" - "+e.getMessage());
cause = e.getMessage();
continue;
}
connected = true;
}

if(!connected){
try {
mmSocket.close();
} catch (IOException e2) {
Log.e(TAG, "unable to close() " + mSocketType +
" socket during connection failure", e2);
}

Log.e("----btact----", cause);
connectionFailed();
return;
}


This gives me
fail0 - Connection refused
fail1 - File descriptor in bad state
fail2 - File descriptor in bad state
File descriptor in bad state



Whay may cause this problem and how do I solve it?