## Monday, May 21, 2012

### 3n+1 challenge at UVa

I'm having trouble running the "3n+1 Problem" from the "Programming Challenges" book.

I've tried every solution in Java I could find on google (even the ones on Stack Overflow), and not a single one works, they all report a "Wrong answer". I also found a working C++ solution, translated it to Java, and same thing: "Wrong answer".

I'm using the template from Programming Challenges for Java submissions, and I could swear my algorithm is right, the only possible problem I can think of is in the code for reading the input or writing the output, but I can't figure it out. Here's my code, any help would be greatly appreciated:

``class myStuff implements Runnable {      @Override     public void run() {         String line = Main.ReadLn(128);         while (line != null) {             process(line);             line = Main.ReadLn(128);         }     }      private void process(String line) {          String[] data = line.split("\\s+");          if (data.length == 2) {             int low = Integer.parseInt(data[0]);             int high = Integer.parseInt(data[1]);             int max = low < high ? findMax(low, high) : findMax(high, low);             System.out.println(low + " " + high + " " + max);         }      }      private int findMax(int low, int high) {         int max = Integer.MIN_VALUE;         for (int i = low; i <= high; i++) {             int length = cycleLength(i);             if (length > max)                 max = length;         }         return max;     }      private int cycleLength(int i) {          long n = i;         int length = 1;          while (n > 1) {             n = ((n & 1) == 0) ? n >> 1 : 3*n + 1;             length++;         }          return length;      }  }  // java program model from www.programming-challenges.com class Main implements Runnable {     static String ReadLn(int maxLength) { // utility function to read from         // stdin, Provided by Programming-challenges, edit for style only         byte line[] = new byte[maxLength];         int length = 0;         int input = -1;         try {             while (length < maxLength) { // Read untill maxlength                 input = System.in.read();                 if ((input < 0) || (input == '\n'))                     break; // or untill end of line ninput                 line[length++] += input;             }              if ((input < 0) && (length == 0))                 return null; // eof             return new String(line, 0, length);         } catch (java.io.IOException e) {             return null;         }     }      public static void main(String args[]) { // entry point from OS         Main myWork = new Main(); // Construct the bootloader         myWork.run(); // execute     }      @Override     public void run() {         new myStuff().run();     }  } ``

### How to set WindowsClientCredential.AllowedImpersonationLevel under WinRT?

I try to request a Sharepoint webservice from an MetroStyleApp. The Sharepoint returns an error (Exception from HRESULT: 0x80131904). After some googleing I found, that the problem is, that the credentials don't get passed to the SQL-Server. In an normal (Win32) Application I would set `WindowsClientCredential.AllowedImpersonationLevel` to `Delegation`. But there is no property like this under WinRT. How to solve this problem?

### Cannot read remote private queue

I'm trying to get MSMQ 5 working on my two Windows Server 2008 R2 virtual machines.
I can send to local and remote private queues, and I can read from local private queues.
I can't read from remote private queues.

I've read a number of suggestions, especially the ones summarised by John Breakwell at MSMQ Issue reading remote private queues (again).

• Turned off firewalls on both machines.

• Ensured that Everyone and AnonymousLogon have full control of the queues. (If I take away AnonymousLogon access, then I can't remotely send to the queue, and the message ends up with "Access is denied" on the receiving machine.)

• Allowed Nonauthenticated Rpc on both machines.

• Allowed NewRemoteReadServerAllowNoneSecurityClient on both machines.

the sending code fragment is:

``        MessageQueue queue = new MessageQueue(queueName, false, false, QueueAccessMode.Send);         Message msg = new Message("Blah");         msg.UseDeadLetterQueue = true;         msg.UseJournalQueue = true;         queue.Send(msg, MessageQueueTransactionType.Automatic);         queue.Close(); ``

The receiving code fragment is:

``   queueName = String.Format("FormatName:DIRECT=OS:{0}\\private\$\\{1}",host,id);    queue = new MessageQueue(queueName, QueueAccessMode.Receive);    queue.ReceiveCompleted += new ReceiveCompletedEventHandler(receive);    queue.BeginReceive(); ``

...

``    public void receive(object sender, ReceiveCompletedEventArgs e)     {         queue.EndReceive(e.AsyncResult);         Console.WriteLine("Message received");         queue.BeginReceive();     } ``

My queueName ends up as `FormatName:DIRECT=OS:server2\private\$\TestQueue`

When I call beginReceive() on the queue, I get

``Exception: System.Messaging.MessageQueueException (0x80004005)    at System.Messaging.MessageQueue.MQCacheableInfo.get_ReadHandle()    at System.Messaging.MessageQueue.ReceiveAsync(TimeSpan timeout, CursorHandle cursorHandle, Int32 action, AsyncCallback callback, Object stateObject)    at System.Messaging.MessageQueue.BeginReceive() ``

I've used Wireshark on Server1 to look at the network traffic. Without posting all the detail, it seems to go through the following stages. (Server1 is trying to read from a queue on Server2.)

• Server1 contacts Server2, and there is an NTLMSSP challenge/response negotiation. A couple of the responses mention "Unknown result (3), reason: Local limit exceeded".

• Server1 sends Server2 an rpc__mgmt_inq_princ_name request, and Server2 replies with a corresponding response.

• There's some ldap exchanges looking up the domain, then a referral to ldap://domain/cn=msmq,CN=Server2,CN=Computers,DC=domain which returns a "no such object" response.

• Then there's some SASL GSS-API encrypted exchange with the LDAP server

• Then connections to the ldap server and Server2 are closed.

I've tried enabling Event Viewer > Applications and Services Logs > Microsoft > Windows > MSMQ > End2End. It shows messages being sent, but no indication of why trying to receive is failing.
How can I debug this further?

### How to catch touch event of an dialog when it is clicked outside

Actually i have `Dialog` in my activity, what i want is suppose the dialog is open, then on Touch of outside dialog i want to dismiss the dialog and at the same time i want to call a function which do some update in my activity.

Initially i used `MyDialog.setCanceledOnTouchOutside(true);` But these will only dismiss and in my case, at the same time i want to call some functions whenever user click outside of dialog. So what should i do, I know that if i can extend the `Dialog` class and override its `onTouchEvent` method then it will be solved but in my case my class already extends Activity class and in java we can't extend more then one class..

### What's the difference between calloc & malloc followed by a memset?

What's the difference between calloc & malloc followed by a memset? If I replace all calls to calloc with a malloc followed by a memset, will it be the same?

If that is the case, then why are two functions malloc & calloc seperately provided?

### An empty DataTable with column names from SharePoint 2010 List

I am developing a project in SharePoint 2010.

My requirement is to get an empty DataTable but with column names in it from SharePoint List.

The .GetDataTable() method returns only if it has a value.

So basically I need a structure of the list in a DataTable.

### In Eclipse m2e, how to reference workspace project?

How can I reference another workspace project using Eclipse m2e?

Do I have to add a project dependency in the project setting? But in that case the dependency is not shown in the pom.

If I set them in the pom, it will not reference the project in workspace but reference the jar in the local repository. Quite annoying, anyone can help?

### Get total time difference between two dates using php

Here i mention two times with its date

2008-12-13 10:42:00

2010-10-20 08:10:00

I want to get total time difference in (h:m:s) format

### SQL Query - How to remove null and replace with blank

Here is my query:

``SELECT ename, sal, comm FROM EMP WHERE comm IS NULL ORDER BY sal DESC; ``

I would like to replace the `NULL` result in the `comm` column with a blank space. I have been told to under `SELECT, write NULL(comm,' ')`, however this comes up with an error, saying invalid number. The query works if I have `NULL(comm, 0)`, returning with 0 in the column.

From my understanding this means I can only have a number value in this column, however I want the blank space. Is someone able to please give me some guidance?

### Node.js: Using multiple moustache templates

I'm trying to break a moustache template up into various components so I can reuse them, and get the assembled text returned through node.js. I cannot find anyone that has done this.

I can return must ache pages imply with:

``function index(request, response, next) {     var stream = mu.compileAndRender('index.mu',          {name: "Me"}         );     util.pump(stream, response); } ``

I just cannot figure out how to render a template and use it in another template. I've tried rendering it separately like this:

``function index(request, response, next) {     var headerStream = mu.compileAndRender('header.mu', {title:'Home page'});     var headerText;      headerStream.on('data', function(data) {        headerText = headerText + data.toString();     });      var stream = mu.compileAndRender('index.mu',                 {             heading: 'Home Page',             content: 'hello this is the home page',             header: headerText         });     util.pump(stream, response); } ``

But the problem is that the header is not rendered before the page and even if I get that to happen. The header is seen as display text rather than html.

Any help appreciated.

### dispatcherservlet does not wire model to view

I made a model from a controller and return to dispatcherservlet. It looks like there is no problem

in model since I double checked output by system.out.println. for viewname string, I double checked

an actual directory name which is "WEB-INF/views/hello.jsp".

but I believe dispatcher servlet does not adapt model to a view since browser does not displayed

a model value which should be displayed. It would be easier to understand what I am going through

if I put my code here. so... here is my code.

web.xml

``<context-param>     <param-name>contextConfigLocation</param-name>     <param-value>         /WEB-INF/spring/appServlet/spring-servlet.xml     </param-value> </context-param> ``

spring-servlet.xml

``<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd" > <context:annotation-config/> <bean name="/hello" class="com.spring.toby.HelloController"/> <bean id="HelloSpring" class="com.spring.toby.HelloSpring"></bean>   </beans> ``

and controller java file

``public class HelloController implements Controller{  @Autowired HelloSpring helloSpring; public ModelAndView handleRequest(HttpServletRequest request,         HttpServletResponse response) throws Exception {     // TODO Auto-generated method stub     String name = request.getParameter("name");     String msg = this.helloSpring.sayHello(name);     System.out.println(msg);     Map<String, Object> model = new HashMap<String, Object>();     model.put("msg", msg);     return new ModelAndView("WEB-INF/views/hello.jsp", model); } } ``

and bean file

``public class HelloSpring { public String sayHello(String name){     return "Hello " + name; } } ``

can anybody tell me what am I doing wrong? thanks in advance.

### Characters allowed in php array keys?

I have some php array keys that are populated with a lot of weird characters.

Is this allowed? Are there any constraints to what I cannot use?

### Animate UILabel text size increase and decrease

I want to apply animation on UILabel text. I write the code to increase font size in animation block but animation is not applied.

``[UIView beginAnimations:nil context:nil/*contextPoint*/];     monthsOnBoard.font=[UIFont fontWithName:@"digital-7" size:150];     daysOnBoard.font=[UIFont fontWithName:@"digital-7" size:150];     hoursOnBoard.font=[UIFont fontWithName:@"digital-7" size:100];     minutesOnBoard.font=[UIFont fontWithName:@"digital-7" size:100];     secondsOnBoard.font=[UIFont fontWithName:@"digital-7" size:100];     [UIView setAnimationDelegate:self];     [UIView setAnimationDelay:0.5];     [UIView setAnimationDuration:1];     [UIView setAnimationRepeatCount:4];     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];     [UIView commitAnimations]; ``

### How does the array stored in memory?

I have a simple program which initializes an array as:

``int a[]={10,20,30,40,50};  char *p;  p=(char*)a; ``

Now I want to access the value at each byte through pointer `p`. For that I need to know how does the array stored in memory(stack or heap)?

### Is it possible to localize CalendarView or DatePicker?

My users' calendar is Persian calendar. I have an algorithm to change date and time between western and Persian calendar. I want to use CalendarView or DatePicker for my users for selecting dates. Is it possible to localize CalendarView and DatePicker for supporting my local calendar?

### How to Pass Variables Into PHP Ajax Handler Script?

I have a small ajax php application, which outputs data from a mysql db into a table. The rows are links, which when clicked will call an ajax function, which in turn will call another php file, which displays a different query from the same database in a layer without reloading the page.

I would like to know how to synchronize queries between both php files. So when I click on a row in the base page, the layer will be expanded to include additional information, or indeed the whole query.

I was thinking I could do this by having the primary key in the first query for the table, however I don't want it displayed and was wondering if there was a better approach to this?

### How to communicate between content script and the panel

How does the communication between a panel and a content script happen? How can we dynamically update the panel content from content script? The content script accesses the DOM of the page loaded. Now every time when there is a DOM change in the webpage that should be shown in the panel. How can we do this? Can anyone explain with an example?

### Set and get Notes field in CRM 2011 Javascript

I need to set the Notes field to the Notes field value in other entity in CRM 2011 form. So, I need to know how get and set the Notes field using Javascript. And I'm not able to get the name of Notes field inside the section as you can seen in the below image.

### GitHub Organization Repo + Jenkins (GitHub Plugin) integration

I have an organization on GitHub with private repositories. I also have Jenkins set up running on port 8080 on a server, with the GitHub plugin installed. I've created an account on GitHub for my jenkins user, which resides in the owners group.

I'm trying to trigger a job on jenkins when a change is pushed to my development branch (or master branch, neither seem to be working).

When I look at the GitHub Hook Logs in Jenkins, it says that Polling has not run yet. When I go to "Manage Jenkins", the GitHub plugin says my account is Verified when I test it.

Any insight on how to configure this? I have multiple repositories I'd like to work with, so deploy keys don't seem like the solution to me.

### Load UIImage from file using grand central dispatch

I'm trying to load images in the background using gcd. My first attempt didn't work:

``dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW,0), ^{   dispatch_async(dispatch_get_main_queue(), ^{     // create UI Image, add to subview   }); }); ``

commenting out the background queue code and leaving just the main queue dispatch block didn't work:

``dispatch_async(dispatch_get_main_queue(), ^{   // create UI Image, add to subview }); ``

Is there some trick to doing ui stuff inside a gcd block?

In response to mattjgalloway's comment, I'm simply trying to load a big image in a background thread. Here's the full code that I tried originally:

``dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW,0), ^{      UIImage* img = [[UIImage alloc] initWithContentsOfFile: path];      dispatch_async(dispatch_get_main_queue(), ^{         imageView = [[[UIImageView alloc] initWithImage:  img] autorelease];        imageView.contentMode = UIViewContentModeScaleAspectFill;        CGRect photoFrame = self.frame;        imageView.frame = photoFrame;        [self addSubview:imageView];    });  }); ``

I simplified it so that I was running everything inside the main queue, but even then it didn't work. I figure if I can't get the whole thing to work in the main queue, no way the background queue stuff will work.

### put jpg data from xmlhttprequest into <img /> tag

here is some part of my code

``xmlhttp.open("GET", theUrl, true); document.imglive.innerHTML = '<img src="data:image/jpeg,' + xmlhttp.responseText + '"/>'; ``

that don´t seem to work.
i also tried

``document.imglive.src= xmlhttp.responseText; ``

that neither worked

I checked some of the asked questions here but none of the answers where helping at this porblem.

### Problem with Icon.png (Icon specified in the Info.plist not found under the top level app wrapper: Icon.png (-19007))

I'm putting together a universal app and I have the icons in my project, but I keep getting a warning from the compiler in regards to Icon.png.

I followed the instructions at http://developer.apple.com/library/ios/#qa/qa2010/qa1686.html but still get the above error.

I've tried doing the following:

Putting the icons in the Shared group and adding them according to the plist according to the tech note.
Changing the icon paths to add Shared/ to them to point to the shared folder.

Creating a Resources group (which the tech note fails to point out that XCode doesn't create a Resources Group for a universal app) and moving them into that (I removed the "Shared/" prefixes from the plist.)

Moving the icons to the top level of the project.

I've also double-checked the icon sizes and they are all correct, as well as the names of each.

Anything I might have missed?

### Using hover while showing/hiding areas

Have a question about showing/toggling div

Is there a way to add a click function to this script that will allow the hover to work and show the element that has been clicked? The link to this example has a hover working. I would like to be able to click a square and have it remain selected. There is an event that fires upon lick that will show media in another area of the screen. The area's graphis should remain selected because it corresponds to the other media and let's a person know what they clicked. If there is another way this should be set up, I am completely open.

http://jsfiddle.net/Baybook/WGP99/38/

### Static Virtual workaround in GSL

Hello I am trying to write a small program to simulate dynamical systems using the differential equation package from the GNU Scientific Library. The problem is not specific to the GSL but I am just giving you all the details

In the current design I want to have an abstract `Experiment` class, where all the complex functions will be called by the gsl library. The dynamics of the explicit system will be defined by two functions, i.e., func and jacob, that define the specific motion equations and the jacobian respectively. Thus, I want to do all the simulation in the `Experiment` class and only override the two virtual functions with the specific class which will be inherited by the `Experiment`.

The problem I have is that as virtual these methods do not compile

`error: argument of type 'int (Experiment::)(double, const double*, double*, void*)' does not match 'int (*)(double, const double*, double*, void*)'`

If I make these two functions static the program compiles but I am losing the functionality that I want to achieve for specific problems.

Apparently, they cannot be both static and virtual, so does anyone know any workaround to this problem? Are there any suggestions to better approach it?

### Conditionally wrapping content in Razor using

Using Razor I want to conditionally wrap some content in a `<span>` element based on a boolean property of my model. My guess is that I will need to use Templated Razor Delegates, but I'm finding it tricky to get them right.

My model goes something like:

``public class Foo {     public bool IsBar { get; set; } } ``

and in my view I'd like to be able to use something similar to:

``<a href="/baz">     @Html.WrapWith(Model.IsBar, "span", @This content may be wrapped, or not) </a> ``

where it would render:

``<!-- Model.IsBar == True --> <a href="/baz">     <span>This content may be wrapped, or not</span> </a>  <!-- Model.IsBar == False--> <a href="/baz">     This content may be wrapped, or not </a> ``

### Update empty column with calculated values from SELECT statement?

I have a table, 6 columns, the 6th column is empty but the other 5 have data. I used the 4th and 5th columns to calculate a value and then I wish to insert this value into the 6th column.

How do I link my Select statement which creates the values for the 6th column to the

"UPDATE Table_Name SET Column6 = "

part of my SQL statement.

I will also have to make sure the correct rows get updated with the correct values by using the primary ket of Columns 1 to 4

### how to take screen shot and that screen shot save in album

I am working on application of greeting cards in I have taken screen shot and save in gallery so give any suggestion and source code which apply in my code

### Sending an array from websocket to clients

I'm having an issue sending an array from the backend js to the client side.

I've tried the following on the server side:

``for (var i=0; i < clients.length; i++) {     clients[i].send(clients); } ``

``for (var i=0; i < clients.length; i++) {     clients[i].send(JSON.stringify(clients)); } ``

• also using json.stringify on the client side aswell

``for (var i=0; i < clients.length; i++) {     clients[i].send(clients.join('\n'))); } ``

• again I've tried this method on the client side aswell.

Unfortunately, none of the above solutions worked, The JSON.stringify method obviously didn't work on the serverside due to JSON.stringify being a browser method however the other methods returned either `[object Object]` or `"[object Object]"`

How can I send the array `clients` to client side, or even if I can encode it into JSON and then send it over and parse it on the client side.

Really all I need is to send the contents over to the client side, but I have no clue how to do so haha

Any ideas are appreciated :)

### what's the diff among cflgs sse options of -msse, -msse2, -mssse3, -msse4 rtc..? and how to determine?

as for the GCC cflags options: -msse, -msse2, -mssse3, -msse4, -msse4.1, -msse4.2. Are they exclusive when using or could be in parallel?

My understanding is that the choosing which to set depends on whether the target arch, which the program will run on, supports or not, is this correct?

If so, how could I know what sse my target arch supports? In Linux, I cat /proc/cpuinfo, but what if mac or Windows?

Thanks!

### What is E in floating point?

What is `E+3`? What exactly happens here? Can we use this approach in other data types or can we only use it in floating points?

``static void Main(string[] args) {     double w = 1.7E+3;     Console.WriteLine(w); } ``

Output: 1700

### Recursive Bubble Sort

I am having some trouble with this. We basically have been asked to create two versions of a program that will sort an array of 50 items then display the largest numbers in LED's. I have got it working using a basic bubble sort and it displaying. My issue is when I have to do this using recursion. Unfortunately my knowledge on recursion is very limited as I missed the lecture on it -.- He has also not put the notes online. I have had a long google however still can't get my head around it. So I ask a few things. Firstly, could someone explain recursion in relation to a bubble sort using sedo code. Secondly, am I completely wrong with my attempt.

``int numbers[49];  void setup() {                   pinMode(12, OUTPUT);   pinMode(11, OUTPUT);   pinMode(10, OUTPUT);   pinMode(9, OUTPUT);   pinMode(8, OUTPUT);   pinMode(7, OUTPUT);   pinMode(6, OUTPUT);   pinMode(5, OUTPUT);   Serial.begin(9600); }  void loop() {   resetLEDLow();   genNumbers();   sortNumbers();   displayNumber();   delay(5000); }  void resetLEDLow() {   digitalWrite(12, LOW);   digitalWrite(11, LOW);   digitalWrite(10, LOW);   digitalWrite(9, LOW);   digitalWrite(8, LOW);   digitalWrite(7, LOW);   digitalWrite(6, LOW);   digitalWrite(5, LOW); }  void genNumbers() {   for( int i = 0 ; i < 50 ; i++ )   {     numbers[i] = random(256);   } }  void sortNumbers() {   int sizeOfArray = sizeof(numbers)/sizeof(int);   int check = 1;   if( check != 0 )   {     check = 0;     for( int i = 0 ; i < sizeOfArray ; i++ )     {       for ( int j = 1 ; j < sizeOfArray ; j++ )       {         if( numbers[j-1] > numbers[j] )         {           int temp = numbers[j-1];           numbers[j-1] = numbers[j];           numbers[j] = temp;           check++;         }       }     }     sortNumbers();   } }  void displayNumber() {       int i = 12;    int a = numbers[49];    Serial.println(numbers[49]);    while ( a > 0 )    {      int num = a % 2;      a = a / 2;      if( num == 1 )      {        digitalWrite(i, HIGH);      }else{        digitalWrite(i, LOW);      }      i--;    } } ``

I know that code does not work as when it loops round count is reset to 1 so the condition will never be true thus meaning it will loop round forever and ever. So, what do I need to change or is what I am doing not really recursion at all?

Really need some help with this, got my brain going round and around.

### Compare a string from \$_GET with a string from an array

This has been frustrating me, because I'm pretty new to PHP and am sure I'm missing something very basic about the nature of the language. But why oh why won't this work?

``\$tag = \$_GET['id']; \$openfile = fopen(\$files[\$i], "r"); \$tagsraw = fgets(\$openfile); \$tag_array = explode(",",\$tagsraw); foreach (\$tag_array as \$a) {     if (\$a == \$tag) {         echo \$a." matches ".\$tag;     } } ``

EDIT: The file-opening works fine, by the way; `print_r()` shows that `\$tag_array` populates how it's meant to.

### Tooltips (Titles) in "XUL Browser" content are not working?

I'm developing a plugin for FireFox.

I've an `XUL Deck` which contains an `XUL Browser`.

Unfortunately, whenever the page displayed in the browser has an HTML `title` attribute, the `title` will not work for any element !

PS, the `title` HTML attribute is used to display a tooltip for the HTML element.

How to solve this ?

### How to redirect a fully encoded url htaccess?

to

http://www.site2.com/history

Tried many different rules, bot non worked.

Need help with this

### how is absolute path of <a href="..."/> determined?

I have an html deep inside my directory structure inside `c:\`. one line there is this:

``<link type="text/css" rel="stylesheet" href="/s/2036/21/2/_/download/superbatch/css/batch.css" media="all"> ``

When I hover over the link, it shows `file:///C:/s/2036/21/2/_/download/superbatch/css/batch.css` as the link address. I want it to interpret to actual location which is `file:///C:/Users/name/folder1/...some folders/s/2036/21/2/_/download/superbatch/css/batch.css`

What changes are needed to make?

P.S: please change the title to something better if this one is not expressive enough.

### clear contents of a jTable

I have a jTable and it's got a table model defined like this:

``javax.swing.table.TableModel dataModel =       new javax.swing.table.DefaultTableModel(data, columns); tblCompounds.setModel(dataModel); ``

Does anyone know how I can clear its contents? Just so it returns to an empty table?

### List html and float IE

Normally I always manage to find a solution to my CSS problems, but this one is driving me crazy.

I'm trying to place my list correctly on Wordpress (sidebar widget).
(I tried `div`s, but that still doesn't work under IE.) So here is the HTML code and some screenshots

``<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Document sans nom</title> <style type="text/css"> html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {     margin:0;     padding:0;     border:0;     outline:0;     font-size:100%;     vertical-align:baseline;     background:transparent;     list-style:none; } #header_wrap {     display:block;     width:930px;     height:80px;     padding:0 15px; } #header_wrap #logo {     background:url(images/logo.png) no-repeat;     width:238px;     height:31px;     float:left;     margin:10px 0 0 0; } #header_menu {     display:block;     float:right;     text-align:right; } #header_menu ul {     display:inline; } #header_menu li {     display:inline; } #header_menu h2 {     display:none; } .clear {     clear:both; } .widget_text, icl_languages_selector, #lang_sel, .widget_pages, #pages, .widget_wp_shopping_cart, #sliding_cart, .widget_search {     float:right; } .widget_pages, .widget_search {     clear:right; } </style> </head> <body> <div id="header_wrap">   <div id="logo"></div>   <div id="header_menu">     <li class="widget icl_languages_selector" id="language-selector">       <div id="lang_sel">         <ul>           <li><a class="lang_sel_sel icl-fr" href="#"> <img alt="fr" src="./flags/fr.png" class="iclflag"/> * </a> </li>           <li class="icl-en"> <a href="/?lang=en"> <img alt="en" src="./flags/en.png" class="iclflag"/>* </a> </li>         </ul>       </div>     </li>     <li class="widget widget_text" id="text-3">       <div class="textwidget">Bienvenue sur TEST</div>     </li>     <li class="widget widget_pages" id="pages-4">       <h2 class="widgettitle">Pages</h2>       <div id="pages">         <ul>           <li class="page_item page-item-201"><a title="Sign in" href="/?page_id=201">Sign in</a></li>           <li class="page_item page-item-19"><a title="Mon compte" href="/?page_id=19">Mon compte</a></li>         </ul>       </div>     </li>     <li class="widget widget_wp_shopping_cart" id="shopping-cart">       <h2 class="widgettitle">Shopping Cart</h2>       <div class="shopping-cart-wrapper" id="sliding_cart"><span class="gocheckout"> <a href="/?page_id=17">Panier d'achats <span class="items"> <span class="cartcount"> (0 </span> <span class="numberitems">objet(s) dans votre panier)</span> </span> </a> </span> </div>     </li>     <li class="widget widget_search" id="search-3">       <h2 class="widgettitle">Search</h2>       <ul class="search_wrap">         <form id="searchform" enctype="application/x-www-form-urlencoded" method="get" action="#">           <input type="text" value="" class="query" id="s" name="s"/>           <input type="submit" value="Search" class="submit" id="searchsubmit"/>           <input type="hidden" name="lang" value="fr"/>         </form>       </ul>     </li>   </div> </div> </body> </html> ``

screenshots:
http://img689.imageshack.us/i/finaltestprev.jpg/
http://img713.imageshack.us/i/finalprevu.jpg/

### Inconsistent behaviour in CKEditor using Jquery mobile in Safari on iOS5.1

http://demo.goseamless.co.za/cktest/ - this link contains an example of code with the bug

try typing in the editor on an iOS device, then move the cursor around by
tapping in a different place in the editor. and carry on typing, the
editor stops responding, then closing the keyboard and tapping again to
edit allows you to type.

Also the Next/Previous buttons on the iOS on screen key board ignore the
editor when "tabbing" through controls

### JSTL: remove last item from array

Was wondering if it's possible to remove the last item from an array using JSTL? Currently I'm using c:url to append parameters (from an array) to a hyperlink. I want to be able to remove the last parameter as well...

Here is the code for the c:url to append parameters

`` <c:url value="search" var="url">     <c:param name="q" value="\${q}"/>     <c:if test="\${fn:length(fq) > 0}">     <c:forEach var="field" items="\${fq}">         <c:param name="fq" value="\${field}"/>     </c:forEach>     </c:if> </c:url> ``

### GridLayout from support library does not show 2 rows on Android 2, onChildVisibilityChanged Error

Has anybody gotten the support library to render a grid layout correctly in Android 2? Instead of 2 rows and columns I get a single row on the screen and see this error in the logcat output:
Android GridLayout Could not find method android.support.v7.widget.ViewGroup.onChildVisibilityChanged

The same exact layout is working on Android4 -> ICS when I change the layout tag from
android.support.v7.widget.GridLayout to GridLayout

Could this be some issue with the setup? I have the gridlayout_v7 library project in the Android tab of my Eclipse project properties and the v.13 jar is on the build path.

The xml layout that is failing is pasted below. I added the layout rows and columns explicitly in the image button tags in an effort to work around the problem. If anybody has a working example that runs on Android 2 with the support library, please share. If you have it working, I would appreciate your help to get mine going.
Thanks and regards!

``<android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:columnCount="2"  android:rowCount="2" android:gravity="center_vertical"  android:layout="@drawable/bg_test_main" >  <ImageButton android:id="@+id/btnSentence" android:layout_row="0" android:layout_column="0" android:src="@drawable/testa_btn" android:contentDescription="@string/spin_fill_in" android:background="@android:color/transparent" /> <ImageButton android:id="@+id/btnAudio" android:layout_row="0" android:layout_column="1"     android:src="@drawable/testb_btn" android:contentDescription="@string/audio_quiz" android:background="@android:color/transparent" /> <ImageButton android:id="@+id/btnPickWord" android:layout_row="1" android:layout_column="0" android:src="@drawable/testc_btn" android:background="@android:color/transparent" android:contentDescription="@string/def_pick_word" />  <ImageButton android:id="@+id/btnPickDef" android:layout_row="1" android:layout_column="1" android:src="@drawable/testd_btn" android:background="@android:color/transparent" android:contentDescription="@string/pick_def" />  </android.support.v7.widget.GridLayout> ``

### Use of LINQ on Arbitrary Tables

I love LINQ esp. LINQ to SQL. The use of LINQ for static tables (where the structure of the table is known before hand) is great.

I now have a list of tables where I only know the Table Name (as a string). I also know that each row in the table would have an ID/Primary Key(int) and a number of undetermined columns whose datatypes are varchar/string. I can get the names of the columns using SMO.

I am wondering what is the best way to query these columns e.g. run a distinct on each of them? LINQ to SQL seems to be pretty efficient by converting the query directly to SQL. I would prefer not to write the SQL by hand.

Thank you,
O. O.

### How do I make TWebBrowser keep running JavaScript after an error?

I'm having some troubles with javascript error handling in WebBrowser on Delphi 2010.

I'm using WebBrowser with enabled silent property. Seems OK, but there is one issue on sites with buggy scripts: it seems like part of script after error doesn't executes. Results of some script slightly differs from IE.

Do you have any idea how this issue can be solved?

### Using Microsoft.Data.Services.Client.dll instead of System.Data.Services.Client.dll causes issues with Azure.StorageClient

We have a project that uses WCF 5.0 and the WindowsAzure SDK.

There are two references Microsoft.Data.Services.Client.dll and System.Data.Services.Client.dll and they are in conflict. If I remove the System DLL (as per this) I am unable to use the windowsAzure SDK. If I remove the Microsoft DLL I am unable to take advantage of the new features of WCF specifically OData version 3.0.

After I remove the System DLL reference:

cannot convert from
'System.Data.Services.Client.SaveChangesOptions [c:\Program Files
(x86)\Microsoft WCF Data
Services\5.0\bin.NETFramework\Microsoft.Data.Services.Client.dll]' to
'System.Data.Services.Client.SaveChangesOptions'

The best overloaded method match for
'Microsoft.WindowsAzure.StorageClient.TableServiceContext.SaveChangesWithRetries(System.Data.Services.Client.SaveChangesOptions)'
has some invalid arguments

The type 'System.Data.Services.Client.DataServiceContext' is defined
in an assembly that is not referenced. You must add a reference to
assembly 'System.Data.Services.Client, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'.

If I remove the reference to Microsoft.Data.Services.Client and add reference to System.Data.Services.Client then we get no errors - we also get no WCF 5.0!

### Bash declaratively defining a list to loop on

In bash I frequently make scripts where I loop over a list of strings that I define.

e.g.

``for a in 1 2 3 4; do echo \$a; done ``

However I would like to define the list so that it contains spaces and with out a separate file:

e.g. (BUT THIS WILL NOT WORK)

``read -r VAR <<HERE list item 1 list item 2 list item 3 ... HERE  for a in \$VAR; do echo \$a; done ``

The expected output above (I would like):

``list item 1 list item 2 list item 3 etc... ``

But you will get:

``list item 1 ``

I could use arrays but I would have to index each array. How do others declaratively define lists in bash with out using separate files?

### How to setup a 3-column layout using pisa xhtml2pdf

I have a list of items that I want to layout in three columns. The list is pretty long (using a 3-column layout might take 5 pages). The conditions are as follows:

1. The first page has a header that is about 200px in height and 100% in width. After the heading in the first page, the page should start displaying the list in 3-columns.

2. "Middle and last" pages dont contain any header.

3. Last page contains an image.

I tried to give a margin-top for the second and third frames, the first page looks right but the "middle" pages don't. The margin-top gets applied to all pages.

Help will be appreciated.

### How to sort a observablecollection(of String)

All I need is a simple way to sort the strings in the collection. I can't find anything online. Everybody is using lamda expressions which I don't think works for just a string collection?
Thanks,

``   Public Property FilterCollection As New ObservableCollection(Of String)    From d In FilterCollection Order By (Function(d) d)() ``

### IE Compatibility mode creates issues with XPages DateTimePicker

Per Hendrik suggested a fix for the strange stretched dialog problems in IE with xPage extensions.

Fixing "stretched" XPage extension library Name Picker in IE?

This worked great and fixed the problem. But it creates an issue with the DateTimePicker. With compatibility mode in place the calendar for the DateTimePicker displays but is immediately closed. I have put together a demo here:

`` <xp:this.beforeRenderResponse>     <![CDATA[#{javascript:  if (context.getUserAgent().isIE()) {     var response = facesContext.getExternalContext().getResponse();     response.setHeader("X-UA-Compatible", "IE=8"); }}]]> </xp:this.beforeRenderResponse>     <xp:inputText id="inputText1">     <xp:dateTimeHelper id="dateTimeHelper1"></xp:dateTimeHelper>     <xp:this.converter>         <xp:convertDateTime type="date"></xp:convertDateTime>     </xp:this.converter> </xp:inputText>   ``

### MYSQL export Value and NOT ID

I have a MYSQL database table with a field that contains information like below...

``ID: 1 with a VALUE: Apple  ID: 2 with a VALUE: Orange  ID: 3 with a VALUE: BANANA ``

I wish to export the data VALUE, but currently can only pull out the ID.
For example, I want to export the words "APPLE", "ORANGE" etc - meaningful names, and NOT just "1", "2" etc.

My actual query line thus far....

``SELECT ID,time,quote,media,pack FROM database_table_name ``

The issue is the 'pack' field renders the id numbers, not the real names on export. Any ideas how to access the real names instead??

### Need hints on seemingly simple SQL query

I'm trying to do something like:

``SELECT c.id, c.name, COUNT(orders.id) FROM customers c JOIN orders ON o.customerId = c.id ``

However, SQL will not allow the COUNT function. The error given at execution is that c.Id is not valid in the select list because it isn't in the group by clause or isn't aggregated.

I think I know the problem, COUNT just counts all the rows in the `orders` table. How can I make a count for each customer?

### PHP - Proper way to extend class

I am currently working on a mini 'framework' and I am having some difficulties. I'm attempting this in order to strengthen my understanding of basic concepts utilized in most MVC's (At least from what I have seen). So yes, I do understand that using a framework may be easier and not everything that I am doing is ideal. I am just trying to learn more.

So I have 2 files that I am currently working with.

FrontController.php

``<?php    class FrontController {     public function __construct() {         \$this->go(); // RUNS GO FUNCTION UPON LOADING     }      public function go() {                   \$url = \$_SERVER['REQUEST_URI']; // GRABS URL         \$action = explode("/", \$url); // SPLITS UP URL INTO SECTIONS          \$object = ucfirst(\$action[2]) . "Controller"; // SETS 2ND SECTION OF URL TO UPPERCASE AND IDENTIFIES THE CONTROLLER         \$file = APP_DIR . "/" . \$object . ".php"; // IDENTIFIES THE FILE THAT WILL BE USED          if(!is_file(\$file)){ // DETERMINES IF FILE EXISTS             \$this->fail(); // IF NOT, FAILS         } else {             require_once \$file; // IF EXISTS, PULLS IT IN             \$method = ucfirst(\$action[3]); // THE 3RD SECTION OF THE URL IS THE METHOD             \$controller = new \$object(); // CREATE INSTANCE OF THE IDENTIFIED OBJECT              if(!method_exists(\$controller, \$method)){ // DETERMINES IF METHOD EXISTS IN THE CLASS                 \$this->fail(); // IF NOT, FAILS             }              \$controller->\$method(); // RUN METHOD             exit(0);         }     }      public function fail() {         echo "<h1>Failure</h1>"; // FAILURE MESSAGE     } } ``

/application/BaseController.php

``<?php    class BaseController {     public function __construct() {         \$this->session();     }      public function session() {         session_start();         \$_SESSION['is_logged_in'] = 1;         echo "hi";     } } ``

So what I would like to be able to do is extend the BaseController with the FrontController. I figured that extending the BaseController would allow me to add common functionality to my entire application. The problem is that I am not certain how to do this properly. I know that I need to 'require' BaseController.php into FrontController.php somehow, but I have seen many different ways and I want to know which is most correct.

What I have tried is simply adding 'require_once("/application/BaseController.php");' to the top of FrontController.php and then extending the FrontController class, but this isn't working (blank page), and from what I have read, it is not the best way.

I read into __autoload() but I do not understand how to use it effectively. Do I just put this at the top of my FrontController.php file and extend my class after that?

So, to summarize, I would like to extend my FrontController class (and other future classes, when necessary) with my BaseController. I would just like some advice for how to accomplish this task effectively. It may even be possible that the way I have this thought out is ass backwards, and if that is the case, please let me know!!