## Thursday, April 19, 2012

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:

### Sorting Listbox Items VB

So I have two listboxes. Listbox1 gathers files from a directory and I have an add button to add selected files from Listbox1 over to Listbox2.

Is there a way to manually sort these items? Maybe with an up down buttons?

The reason I'd like to sort/reorder is I'll have a process that will run those selected files and each file will have to produce another file unqiue to the filename.

A quick example would be process FILE1.txt and produce FILE1.pdf, etc.

Is there an easier way to accomplish the sort/reorder?

### ASP.NET Localize

A simple question. I have a site with localization (with .resx files) and when i need to insert localized text i use a code like this:

<asp:Localize Text="<%\$ Resources: MyResource, Default_BannerHomeTitle %>" runat="server">SOME_TEXT_HERE_OR_NOT?</asp:Localize> 

The question is if anyone knows what's the utility of the text between the asp:Localize tag -> "SOME_TEXT_HERE_OR_NOT?"

The real value come from the .resx file and the text "SOME_TEXT_HERE_OR_NOT?" is obviusly deleted when the page is rendered.

Is this text used in some situation? or is never used?

### Instead of Session variable where i can save my temp data in mvc?

I have created a mvc3 application.
Currently saving submit form value into Session as i need to do some stuff on that before
save changes to database.

Is there any other good way to store temp data in mvc like ViewState?

### Error when I try to create an .accdb file in C#

This is my code that creates an .accdb file if it can't find one :

Catalog cat = new CatalogClass(); string createStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|/saveDB.accdb;"; cat.Create(createStr); Table tbl = new Table(); tbl.Name = "saveDB"; tbl.Columns.Append("ID", DataTypeEnum.adGUID); tbl.Columns.Append("Tensiune", DataTypeEnum.adDouble); tbl.Columns.Append("Frecventa", DataTypeEnum.adDouble); tbl.Columns.Append("Rezistenta", DataTypeEnum.adDouble); tbl.Columns.Append("Inductanta", DataTypeEnum.adDouble); tbl.Columns.Append("Capacitate", DataTypeEnum.adDouble); tbl.Columns.Append("Elemente", DataTypeEnum.adVarWChar, 25); tbl.Columns.Append("Tip", DataTypeEnum.adVarWChar, 25); cat.Tables.Append(tbl); System.Runtime.InteropServices.Marshal.FinalReleaseComObject(tbl); System.Runtime.InteropServices.Marshal.FinalReleaseComObject(cat.Tables); System.Runtime.InteropServices.Marshal.FinalReleaseComObject(cat.ActiveConnection); System.Runtime.InteropServices.Marshal.FinalReleaseComObject(cat); 

But when I run it in the program i get this runtime error :

System.Runtime.InteropServices.COMException (0x80004005): Not a valid file name.    at ADOX.CatalogClass.Create(String ConnectString) 

I can't figure what's the problem with the file name, so if anyone has any idea, please help.

### Java speed access array index versus temp variable

What is faster in Java. Accessing an array index directly multiple times, or saving the value of the array index to a new variable and use this for following compution?

acces index

if ((shape.vertices[0].x >= fromX && shape.vertices[0].x <= toX) || // left side of shape in screen     (shape.vertices[0].x <= fromX && shape.vertices[0].x + shape.width >= fromX) || // right side of shape in screen     (shape.vertices[0].x >= fromX && shape.vertices[0].x + shape.width <= toX)) { // shape fully in screen      // ... } 

temp variable

float x = shape.vertices[0].x; float y = shape.vertices[0].y; if ((x >= fromX && x <= toX) || // left side of shape in screen     (x <= fromX && x + shape.width >= fromX) || // right side of shape in screen     (x >= fromX && x + shape.width <= toX)) { // shape fully in screen          // ...     } 

### Make asset pipeline act like production on development

I am experiencing some problems with assets on production: missing ones, stuff compiled into the wrong files (javascript for "/admin" getting compiled into the frontend code and so on). Most of the assets come from engines. I want to debug and optimize this.

For that, I need to precompile, serve and fail on my development environment just like it is done on production.

I have added some lines to my config/development.rb:

  config.serve_static_assets = true   config.assets.precompile += %w( store/all.js store/all.css admin/all.js admin/all.css ) # @TODO: clean up, and optimize.   config.assets.compile = false 

Running this with rake RAILS_GROUPS=assets RAILS_ENV=development assets:precompile gives me all the assets and the manifest.yml in public/.

But then the server fails:

Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError in Spree/home#index  Showing /xxxx/app/views/spree/shared/_head.html.erb where line #13 raised:  favicon.ico isn't precompiled 

favicon.ico isn't precompiled. But it is! Its there, in the public dir, in manifest.yml, and I can fetch it with the browser (or wget): http://localhost:3000/assets/favicon.ico.

NOTE Favicon is simply the first asset called. If I strip out favicon, the problem simply surfaces with the next asset, being "all.js", or, when that is stripped, "all.css", and so on. I can strip it untill "footer_bg.png", and it will then fail there. Again: the problem is not favicon, but the fact that the development environment does not see the precompiled assets at all.

What more is needed to get development asset pipeline similar to production?

EDIT: More explicit explanation that favicon is not the problem, merely a symptom.

### serach product with their specifications filter

I have a table that contain products with their specifications.i created a sample of data in http://sqlfiddle.com/#!2/15575/1 .I want create search form that users can search products by their specifications.for example user search laptop with RAM=2 and VGA=512 or VGA=1.
this example:
result: 1525,1535,k5,k6

### Skip the cell and the content of a DataTemplateColumn in a DataGrid

I am trying to tab through a datagrid, but at the end of the row I have a template column that is taking in a tab. I have set the datagrid cell style to not focusable and istabstop = false, but it still seems to be going into the content. Is there a property for a TemplateColumn that will have it be skipped by tabbing completely?

Thanks

### How to exclude one table from drop-and-create-tables with Ecliselink?

I use Eclipselink 2.3.2 and want to know, if there is an way to exclude a single table/entity to be excluded from ddl-generation strategy drop-and-create-tables? I need to preserve the content of this table, while all other tables should be droped and been created complete new.

The reason is that the domain model is under heavy development so there are changed all and everywhere. But one single table (containing postal codes) should be preserved, because they are needed for development, and it takes to long to insert them all at every server start.

I know one way is to use two different persistence units. But this would cause some other trouble, so this not my preferred way.

Summary: Does anybody know a way to exclude a single table from droping while all other tables get droped and been recreated at each server start with ecliselink 2.3.2 (and Glassfish 3.1.2 )?