Thursday, 3 October 2013

CakePHP belongsTo not working

CakePHP belongsTo not working

I have a couple of tables in my database:
CREATE TABLE IF NOT EXISTS `team_players` (
`artificialid` int(11) NOT NULL AUTO_INCREMENT,
`team_name_id` int(11) NOT NULL,
`player_id` int(11) NOT NULL,
PRIMARY KEY (`artificialid`)
)
And:
CREATE TABLE IF NOT EXISTS `team_names` (
`id` int(11) NOT NULL,
`name` varchar(50) NOT NULL
)
And I have set up my TeamPlayer model like this:
class TeamPlayerModel extends AppModel {
public $belongsTo = array(
'TeamName',
'Player'
)
);
}
The players table has a field id, but neither of the associations are
working.
I don't really understand why it isn't working, I have something like this
working in another app, pretty much line for line.
Thanks in advance, I really appreciate any help.

Wednesday, 2 October 2013

iOS 7 - XCode 5 - Constraints

iOS 7 - XCode 5 - Constraints

I am trying to learn iOS development, but I need portrait and landscape in
my project. As I set it up, I notice that I am messing everything up. I
may need a bit of help with this.
This is what I need in landscape:
Here it is in landscape:
You see, I've been trying out Auto Layout, but it's been a really bad
experience. How do I make constraints on this?
I need it to fit in Portrait and Landscape, but as soon as I fit it with
either of them, it messes up the other view.
Do you guys have any ideas?

Best way to handle internet authentication pages within iOS app?

Best way to handle internet authentication pages within iOS app?

What is the best way to handle WIFI authentication pages within an iOS app
(often found in free WIFI zones, hotels, etc.) such as within Settings.app
(displays a web view within a modal when user needs to be authenticated)?
I have some ideas for a custom solution such as checking for redirects,
content types, and then displaying a web view to the user, but wondering
if there is an already implemented pre-existing solution.
Background:
iOS 5+ supported
All network requests routed through AFNetworking

Can't get ANSI C code to compile with gcc

Can't get ANSI C code to compile with gcc

I got the following code from "The C Programming Language" written by
Brian Kernighan and Dennis Ritchie. However, it won't compile with gcc:
#include <stdio.h>
#include <string.h>
#define MAXLINE 1000
int getline(char *line, int max);
{
char line[MAXLINE];
int found = 0;
if (argc != 2)
printf("Usage: find pattern\n");
else
while (getline(line, MAXLINE) > 0)
if (strstr(line, argv[1]) != NULL) {
printf("%s", line);
found++;
}
return found;
}
All I get is: error: expected identifier or '(' before '{'.
What am I doing wrong?

Finding any text in a column, then searching above/beneath it then adding a result in another cell

Finding any text in a column, then searching above/beneath it then adding
a result in another cell

Ive had help with this code yesterday and have added another part to it.
Here is the code
Sub findtext()
Dim findtext As Range
For Each findtext In Range(ActiveSheet.Range("C3"),
ActiveSheet.Range("C250").End(xlUp)).Cells
If Len(findtext) > 0 Then findtext.Offset(0, 1) = findtext.Offset(-2, 7)
If Len(findtext) > 0 Then findtext.Offset(0, 2) = findtext.Offset(0,
1) + findtext.Offset(0, 0)
Next findtext
End Sub
This is working great.
My data is in lots of 2 (ie C10 has some data, then so does C11, then
nothing till C25 / C26 etc. I want to put the A in E10 and B in E11 - Then
A in E25 and B in E26
I think I need to find the text in Col C then see if there is text above
it, if there is then that would put the B in E11/E26 etc, and if cell
above text is empty but there is text in the cell below then we add the A
Hope this makes sense otherwise ill try explaining again
Thanks!
Something like this, but this is doing that on every check, so its not
working obvoiusly
If Len(findtext) > 0 Then findtext.Offset(0, 2) = "A"
If Len(findtext) > 0 Then findtext.Offset(1, 2) = "B"
Here is a link for my file:
http://www.megafileupload.com/en/file/456565/example1-xlsm.html
I have also included more notes inside the macro of what I need done

Tuesday, 1 October 2013

Fiddle doesn't work Javascript

Fiddle doesn't work Javascript

http://jsfiddle.net/9zvt6/
var SList = $('.table>div.conChip').sort(function(a,b){
return a.dataset.sid > b.dataset.sid
});
var i = 0;
while(SList.length>i)
{
alert(SList[i].dataset.sid);
i++;
}
If I remove the inner divs the styles and classes everything seems to
work, otherwise it doesn't, what am I missing?

Fragment activity gets destroyed when entering new activity from fragment and going back

Fragment activity gets destroyed when entering new activity from fragment
and going back

I have an activity of type FragmentActivity. Inside I have some content
using view pager, where each scrollable tab is a fragment:
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".OpenStack" >
<!--
This title strip will display the currently visible page title, as
well as the page
titles for adjacent pages.
-->
<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title_strip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#33b5e5"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textColor="#fff" />
</android.support.v4.view.ViewPager>
Inside the fragment I'm opening a new activity when user taps on the item
in the list like this:
Intent myIntent = new Intent(getActivity(), InstanceActivity.class);
getActivity().startActivity(myIntent);
But when i click back in the InstaceActivity to return to the one with
fragments it is destroyed and created again. I have to no idea why that
happens. Should I do something special to keep the FragmentActivity in the
backstack?
It doesn't even help to save the state with:
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString("CONNTOKEN", isConnToken);
outState.putString("NOVAURL", isNovaURL);
}
Because in the oncreate event of the FragmentActivity the
savedInstanceState is NULL when I press back ??