[Sharepoint] – DataContext with custom URL

No Comments

Hello,

One of these days I had to do some bugfixing on a Sharepoint project which used the Microsoft.SharePoint.Linq.DataContext class.

While trying to access a SPList belonging to Site Collection another Site Collection I always add an “Invalid Url Exception” right from the contructor, and other times I had exceptions when accessing the objects.

var context  = new DataContext(otherSiteColUrl);
 


The problem is that inside, the constructor, the URL is only taken into account if we have no HttpContext. If we do have one, the context URL (which means, the current site url) the custom url passed on the constructor is ignored.
More

[TIP - Sharepoint] – CAML Query – Filtering Boolean fields

No Comments

A few days ago I needed to build a CAML query that return all the items which have changed since the last execution. I have a Yes/No (boolean) field called “HasChanged” that when the item is changed turns to “True”.

The query would be something like this:

<Query>
   <Where>
       <Eq>
         <FieldRef Name="HasChanged" />
         <Value Type="Boolean">true</Value>
      </Eq>
   </Where>
</Query>


The truth is that this query will not work as you might think. For Sharepoint, Yes/No fields are represented by 1 and 0. As so, the query has to be like:
More

[.NET] Access Embedded Resource File

No Comments

Sometimes it’s necessary to embed a resource file in the assembly in order to make the distribution easier, or to protect the resource file.

In order to set the resource as embedded, it’s necessary to change the “Build Action” to Embedded Resource:



More

Updating the UI from a background thread on Android

3 Comments

Whenever it’s needed to perform some heavy/slow task on a mobile application, it’s a good practice to perform that specific operation on the background, using a thread. So far so good, but sometimes it’s necessary to update the UI from this background thread. If you ever tried to access an UI element from a background thread, you have already noticed that an exception is thrown.

Let’s assume that the method “doSomeHardWork()” does something really heavy and that the method “updateUI()” updates the interface.

Let’s see how can we update the interface from the background thread:


More

[Trick] MySQL – Order string as number

3 Comments

Sometimes you have to store numbers in text format. This is not a good practice, but sometimes there is no other option.

When you perform an “order by” this field,you can get something like this:

1
10
11
111
12
2
20
3

More

Cool tooltips with Tooltipsy – How to use them with a jquery dialog

No Comments

One of these days I discovered this wonderful JQuery plugin which allows us to create some cool tooltips with jquery.

The credits go to Brian Cray for creating this great plugin.

The usage is simple. All you have to do is to download the javascript file from the plugin website and then apply the plugin to you object. By default, the plugin shows on the tip content the title of the object, but this can easily be overridden by using the “content” attribute, and passing the desired html.
More

Using an enum on a FluentNHibernate mapping [C#]

1 Comment

One of these days I needed to map a C# class to a database table using FluentNHibernate. So far so good….
But then I got stuck as one the class properties was an enum.

As it turns out, there is no automatic mapping to enums.

The solution is to use a Custom Type and let FluentNHibernate know that that specific property has a custom type.
How can that be achieved?

More

Aptana Studio 3 – A great Open Source IDE

No Comments

It’s not easy to choose the right tools for our work. Today I’ll talking about the Aptana Studio 3.0.

Aptana Studio is an IDE based in Eclipse (built in java, thus multiplatform). I currently use Aptana Studio as my Rails IDE under Mac OS X and the experience, so far, has been great.

The syntax highlighting, the autocomplete ( among many other features ) turn this IDE into a productivity buster.You can download it here.

Including features such as GIT integration, built-in terminal, deployment wizard, integrated ruby debugger, its an excellent choice for web development.
More

How to use reCaptcha Validation on Ruby On Rails

No Comments

Security should always be an issue when it comes to computer applications.
Web applications and websites are even more exposed, so likely every weak spot will be exploited someday.

For years, web forms have been used by robots, spreading spam on most websites.

Captcha appeared in order to verify if the user accessing the form is human or not. It does that by showing an image with a text. The image cannot be converted into text by any OCR mechanism, but the human user is still able to read.

So how can we use recaptcha (www.recaptcha.net) with rails?
More

How to check/uncheck checkbox with jquery

1 Comment

JQuery is a great framework and a great help bringing some eye-candy and interface richness into our webapps.

Like me, most of the web developers  don’t have the chance of learning JQuery from the top to the bottom, and all that’s left is a step-by-step approach, where the learning comes from specific needs on the current project.

Let’s see how we can check, uncheck and see the checkbox state with jquery.
More

Older Entries