Correct way to serialize data outside of an entity using JMSSerializerBundle
I have an entity, which returns all the data I want (from the entity,
anyway). I also want to return some configuration parameters as well, if I
was in a service, controller or anywhere where I had access to the
container I'd simply do:
$this->container->getParameter('my.setting');
However, I obviously don't have (and rightfully so) access to the
container within an entity.
So my question is: how can I add my parameter to the output of the json
that JMSSerializerBundle generates?
Thursday, 3 October 2013
Wednesday, 2 October 2013
Having problems with cocos2d and menus?
Having problems with cocos2d and menus?
I'm having a problem with xcode when making a menu when using the cocos2d
templates. I put this code in:
if( (self=[super init]) ) {
CCMenuItemImage *item = [CCMenuItemImage
itemWithxNormalImage:@"bug.png" selectedImage:@"bug.png" target:self
selector:@selector(doThis:)];
CCMenu *menu = [CCMenu menuWithItems:item, nil];
[self addChild:menu];
}
return self;
-(void)doThis:(id)sender{}
I put the if statement in the -(id) init method in helloworldlayer.m. If
anyone can help that would be greatly appreciated. I'm having the problem
where everything builds correctly, but the picture doesn't show. I have it
copied to my resources, but when I build it, no picture is shown.
I'm having a problem with xcode when making a menu when using the cocos2d
templates. I put this code in:
if( (self=[super init]) ) {
CCMenuItemImage *item = [CCMenuItemImage
itemWithxNormalImage:@"bug.png" selectedImage:@"bug.png" target:self
selector:@selector(doThis:)];
CCMenu *menu = [CCMenu menuWithItems:item, nil];
[self addChild:menu];
}
return self;
-(void)doThis:(id)sender{}
I put the if statement in the -(id) init method in helloworldlayer.m. If
anyone can help that would be greatly appreciated. I'm having the problem
where everything builds correctly, but the picture doesn't show. I have it
copied to my resources, but when I build it, no picture is shown.
Exception on calling getAdapter()
Exception on calling getAdapter()
LinkAdapter is a class which extends the ArrayAdapter.
private static List<LinkData> linkDataList = new ArrayList<LinkData>();
private LinkAdapter la;
la = new LinkAdapter(someLinkDataitmes, getActivity());
ListView lv = (ListView) v.findViewById(R.id.urls);
lv.setAdapter(la);
public class LinkData {
private String name, image, description;
public LinkData(String name, String image, String description){
this.name = name;
this.image=image;
this.description=description;
}
}
Now I later want to update my listview,
ListView lv = (ListView) v.findViewById(R.id.urls);
LinkAdapter mListAdapter = ((LinkAdapter)lv.getAdapter()); // this line is
giving an error.
mListAdapter.add(new LinkData(name_val, image_val, description_val));
mListAdapter.notifyDataSetChanged();
But the code is not working(giving a NullPointerException)
Searched a lot on the internet, but could not find a specific answer to my
problem.
LinkAdapter is a class which extends the ArrayAdapter.
private static List<LinkData> linkDataList = new ArrayList<LinkData>();
private LinkAdapter la;
la = new LinkAdapter(someLinkDataitmes, getActivity());
ListView lv = (ListView) v.findViewById(R.id.urls);
lv.setAdapter(la);
public class LinkData {
private String name, image, description;
public LinkData(String name, String image, String description){
this.name = name;
this.image=image;
this.description=description;
}
}
Now I later want to update my listview,
ListView lv = (ListView) v.findViewById(R.id.urls);
LinkAdapter mListAdapter = ((LinkAdapter)lv.getAdapter()); // this line is
giving an error.
mListAdapter.add(new LinkData(name_val, image_val, description_val));
mListAdapter.notifyDataSetChanged();
But the code is not working(giving a NullPointerException)
Searched a lot on the internet, but could not find a specific answer to my
problem.
Yii - updating a model and using the model to echo data in the view
Yii - updating a model and using the model to echo data in the view
I have the following code for updating a Yii model:
public function actionSettings($id) {
if (!isset($_POST['save_hostname']) && isset($_POST['Camera']) &&
isset($_POST['Camera']['hostname'])) {
$_POST['Camera']['hostname'] = '';
}
$model = $this->loadModel($id);
$model->setScenario('frontend');
$this->performAjaxValidation($model);
if (isset($_POST['Camera'])) {
$model->attributes = $_POST['Camera'];
unset($model->api_password);
if ($model->save()) {
Yii::app()->user->setFlash('success', "Camera settings has
been saved!");
} else {
Yii::app()->user->setFlash('error', "Unable to save camera
settings!");
}
}
$this->render('settings', array(
'model' => $model,
));
}
This works fine, except in my model I have code like this:
<h1>Settings For: <?php echo CHtml::encode($model->name); ?></h1>
The problem is that, even when the user input fails validation, the h1 tag
is having bad input echoed out into it. If the input fails the validation,
the h1 attribute should stay the same.
I can 'reset' the $model variable to what is in the database before the
view is returned, but this then means I don't get any error feedback /
validation failed messages.
Is my only option to have 2 models, one used for handling the form and the
other for sending data to the page? Or does someone have a more elegant
solution?
I have the following code for updating a Yii model:
public function actionSettings($id) {
if (!isset($_POST['save_hostname']) && isset($_POST['Camera']) &&
isset($_POST['Camera']['hostname'])) {
$_POST['Camera']['hostname'] = '';
}
$model = $this->loadModel($id);
$model->setScenario('frontend');
$this->performAjaxValidation($model);
if (isset($_POST['Camera'])) {
$model->attributes = $_POST['Camera'];
unset($model->api_password);
if ($model->save()) {
Yii::app()->user->setFlash('success', "Camera settings has
been saved!");
} else {
Yii::app()->user->setFlash('error', "Unable to save camera
settings!");
}
}
$this->render('settings', array(
'model' => $model,
));
}
This works fine, except in my model I have code like this:
<h1>Settings For: <?php echo CHtml::encode($model->name); ?></h1>
The problem is that, even when the user input fails validation, the h1 tag
is having bad input echoed out into it. If the input fails the validation,
the h1 attribute should stay the same.
I can 'reset' the $model variable to what is in the database before the
view is returned, but this then means I don't get any error feedback /
validation failed messages.
Is my only option to have 2 models, one used for handling the form and the
other for sending data to the page? Or does someone have a more elegant
solution?
Trigger in oracle
Trigger in oracle
account
----------
accno varchar
acctotal number
student
----------
id varchar
fees number
accno varchar
I want to create a trigger which updates 'account' table anytime a record
is deleted from 'student'. It subtracts fees of student from acctotal in
account.
thnx in advance.
account
----------
accno varchar
acctotal number
student
----------
id varchar
fees number
accno varchar
I want to create a trigger which updates 'account' table anytime a record
is deleted from 'student'. It subtracts fees of student from acctotal in
account.
thnx in advance.
Tuesday, 1 October 2013
How to find search criteria2 if criteria1 not displayed in exccel by using VBA
How to find search criteria2 if criteria1 not displayed in exccel by using
VBA
I have a workbook1-->Sheet3 having inputs(Iam providing 24monthdays:110,
125, 210,.......1210, 1225) for Marco.Input will be always Monthdays
regardless of years, on 10th and 25th of every month will receive data. If
mentioned days are not non-business day, suppose if 10th is holiday there
is possibility 11th to till 15th. Same way if 25th is holiday there is
possibility 26th to 30th of every month. Based on above conditions in
sheet1 needs to filter the data Eg: Monthday 110 I will search in sheet1.
Suppose sheet1 don't have data for mentioned "110" there is possibility
till "115"(But Ideally I am providing only 24th days in my input
"sheet3"). Please guide/help me regarding issue make vba.
VBA
I have a workbook1-->Sheet3 having inputs(Iam providing 24monthdays:110,
125, 210,.......1210, 1225) for Marco.Input will be always Monthdays
regardless of years, on 10th and 25th of every month will receive data. If
mentioned days are not non-business day, suppose if 10th is holiday there
is possibility 11th to till 15th. Same way if 25th is holiday there is
possibility 26th to 30th of every month. Based on above conditions in
sheet1 needs to filter the data Eg: Monthday 110 I will search in sheet1.
Suppose sheet1 don't have data for mentioned "110" there is possibility
till "115"(But Ideally I am providing only 24th days in my input
"sheet3"). Please guide/help me regarding issue make vba.
cleanup tmp directory with carrierwave
cleanup tmp directory with carrierwave
I use carrierwave for my images upload, in my form i added a hidden field
for caching like is described in documentation.
= form_for @user, html: {multipart: true} do |f|
%p
= f.label :photo, "your image"
= f.file_field :photo, id: "img"
= f.hidden_field :photo_cache
but the problem is after uploading images and saving record, tmp directory
still having all temporary/caching files.
there is a way to clean up the tmp directory ?
I use carrierwave for my images upload, in my form i added a hidden field
for caching like is described in documentation.
= form_for @user, html: {multipart: true} do |f|
%p
= f.label :photo, "your image"
= f.file_field :photo, id: "img"
= f.hidden_field :photo_cache
but the problem is after uploading images and saving record, tmp directory
still having all temporary/caching files.
there is a way to clean up the tmp directory ?
Calculate tail probabilities from density() call in R stats.stackexchange.com
Calculate tail probabilities from density() call in R –
stats.stackexchange.com
This question concerns how to implement the following problem in R. x =
rnorm(1000) hist(x,freq=FALSE) lines(density(x)) How would you calculate
the upper (or lower) tail probability for a given …
stats.stackexchange.com
This question concerns how to implement the following problem in R. x =
rnorm(1000) hist(x,freq=FALSE) lines(density(x)) How would you calculate
the upper (or lower) tail probability for a given …
Where should the balance be between reputation of a question=?iso-8859-1?Q?=2C_and_the_jugment_of_high_rep_users_and_mods_when_in_com?=es to deleting it=?iso-8859-1?Q?=3F_=96...?=
Where should the balance be between reputation of a question, and the
jugment of high rep users and mods when in comes to deleting it? –...
I'm mostly active in Matlab related questions, and recently I checked the
highest votes for that tag (disclaimer, I have a high ranking question
there too). I have found that the #1 question: What can …
jugment of high rep users and mods when in comes to deleting it? –...
I'm mostly active in Matlab related questions, and recently I checked the
highest votes for that tag (disclaimer, I have a high ranking question
there too). I have found that the #1 question: What can …
Subscribe to:
Comments (Atom)