Thursday, 3 October 2013

Propel toArray Mechanics in Doctrine?

Propel toArray Mechanics in Doctrine?

I was using Propel for a long time and now I want to try Doctrine. In My
Propel days I used PropelObjectCollection::toArray (for a collection) or
PropelObject::toArray() for a single record to convert the PropelObject
via array to json.
In my company we override the toArray method to store virtual columns in
the array and then the json string. For example:
public function toArray() { $arr = parent::toArray(); $arr['full_name'] =
$this->getFullName(); // full_name isnt part of the table, it's just a
getter return $arr; }
When I turn this into json i have my full_name property in my json and
then in my Extjs store Object (we use extjs).
Now I wanna try doctrine, but doctrine doesn't seem to allow this. Can i
override a function or property in my doctrine class, or can I do this by
annotations, is it possible to generate a json with propertys
('first_name', 'last_name', 'full_name') if my Doctrine class only has the
properties $first_name, $last_name and no $full_name or is there a work
around to achiev the same?
Thanks for your help

Wednesday, 2 October 2013

Execute a event manually in javascript

Execute a event manually in javascript

I have a class:
function x()
{
this.initialize = function () { }
this.filterSelection = function (event, ui) { /* code */ }
}
I hook filterSelection method to other items through:
$(item).on("click", this, this.filterSelection );
When filterSelection is called, the event.data points to the instance of
my class.
Now I need to call filterSelection manually from within the initialize()
method.
How can I do this which setting the correct parameters?

Numbering Theorems and subsections

Numbering Theorems and subsections

I want the numbering of theorems to follows the section/subsection
counters so I use
\newtheorem{thm}{Theorem}[subsection]
But when I write a theorem in a section before any subsection the
numbering follows the numbering of theorems in the previous section.
Here is an example. I would like the numbering to be as written in the
body of the theorems.
\documentclass[11pt,a4paper]{article}
\usepackage{amsthm}
\renewcommand{\thesubsection}{\arabic{subsection}}
\newtheorem{thm}{Theorem}[subsection]
\begin{document}
\section{Section 1}
\subsection{Subsection 1.1}
\begin{thm}Thm 1.1.1.\end{thm}
\section{Section 2}
\begin{thm}Thm 2.0.1.\end{thm}
\subsection{Subsection 2.1}
\begin{thm}Thm 2.1.1.\end{thm}
\end{document}

Tuesday, 1 October 2013

Checking if a User's Input is in Range and is an Integer (Java)

Checking if a User's Input is in Range and is an Integer (Java)

I am working on a project (a game) and one of the requirements is to have
warnings if they enter an option outside of the range (1-8) and if they
enter a character. If the user enters an invalid number, the menu appears
and asks them again which option they would like. If they enter a
character, the program should ask them to enter an integer and ask for
input again. This is what I have so far. It correctly identifies a number
out of range and recalls the menu. It also identifies a character (invalid
input), but does open input for the user to enter a correct option. How
can I check both conditions?
Thanks, Tyler
int userChoice = scnr.nextInt();//<-- use this variable
if (userChoice.hasNextInt() == false)
{
System.out.println("Error: Menu selection must be an
integer! Please try again:");
}
// Variable used for storing what the user's main menu choice
if (0 > userChoice || userChoice > 8)
{
System.out.println("Error: Invalid Menu Selection.");
System.out.println("");
System.out.println("Available Actions:");
System.out.println("(1) Print Market Prices");
System.out.println("(2) Print Detailed Statistics");
System.out.println("(3) Buy Some Sheep");
System.out.println("(4) Buy a Guard Dog");
System.out.println("(5) Sell a Sheep");
System.out.println("(6) Sell a Guard Dog");
System.out.println("(7) Enter Night Phase");
System.out.println("(8) Quit");
System.out.println("What would you like to do?");
userChoice = scnr.nextInt();
}

Microsoft Fakes Crashes On Build

Microsoft Fakes Crashes On Build

I'm trying to add Stubs using Microsoft Fakes to an internal project.
Every time I build, I get a popup saying fakes.x86.exe has stopped
working. When I tell it to "debug the project", it shows me that it's
hanging on a call to StringHelper.ToHexString.
I've tried searching Microsoft.com, but all I found was a year-old thread
where someone else had the same issue.
I've got VS 2012 update 2, but I'm upgrading to update 3 at the moment to
see if that makes a difference.

Kali Linux Install Error [on hold]

Kali Linux Install Error [on hold]

I just downloaded Kali Linux Mini. I am trying to install it but keep
getting this error./p pimg src=http://i.stack.imgur.com/CtLEs.png
alt=enter image description here/p pNow I know what your thinking...How
can this idiot not know this? Well I do know the answer, but the file
cabinet in my brain is locked and I lost the key. So for now the answer
escapes me. /p pAs you can see from the image above, my courser is
pointing to the file in question. It is clearly right there... So please,
can someone tell me what I am doing wrong... /p pThanks, and if you find
my key, strongPLEASE/strong return it!/p

Searching for a mile counter / wide-square numbers font – graphicdesign.stackexchange.com

Searching for a mile counter / wide-square numbers font –
graphicdesign.stackexchange.com

I am in need of a font with numbers that look like this: Does anyone know
of a font with numbers like these?