I'm frequently using the following to get the second to last value in an array:
$z=array_pop(array_slice($array,-2,1));
Am I missing a php function to do that in one go or is that the best I have?
is there any way to create a custom css value for a component and have it available to the skin class that component is using? for example, if i define this in a css file:
s|Panel{
skinClass: ClassReference("PanelSkin");
myCustomValue: #CCCCFF;
}
is there a way to make myCustomValue available in the PanelSkin ?
I need help because I want to create a gameover screen that display score. However, there's an error that prevent me from transferring the score from theplayclass.as to thegameoverclass.as. Are there ways to pass a value to another movieclip without causing any errors.
I refer the source code from this website : http://www.emanueleferonato.com/2008/12/17/designing-the-structure-of-a-flash-game-as3-version/
Here's the error
C:\Users\xxx\Downloads\Migrate\test\theplayclass.as, Line 54, Column 41 1067: Implicit coercion of a value of type theplayclass to an unrelated type main.
main.as
package
{
import flash.display.MovieClip;
import flash.events.Event;
public class main extends MovieClip
{
public var playClass:theplayclass;
public var gameOverClass:thegameoverclass;
public function main()
{
showWin();
}
public function showWin()
{
playClass = new theplayclass(this);
addChild(playClass);
}
public function showGameOver()
{
gameOverClass = new thegameoverclass(this);
addChild(gameOverClass);
removeChild(playClass);
playClass = null;
}
}
}
theplayclass.as
package
{
import flash.display.MovieClip;
import flash.events.*;
public class theplayclass extends MovieClip
{
private var mainClass:main;
var gameScore:Number;
var gameOverScore:thegameoverclass;
public function theplayclass(passedClass:main)
{
mainClass = passedClass;
scoreText.text ="0";
gameScore = 0;
win.addEventListener(MouseEvent.CLICK, showwinFunction);
next.addEventListener(MouseEvent.CLICK, showgameoverFunction);
addEventListener(Event.ADDED_TO_STAGE, addToStage);
addEventListener(Event.ENTER_FRAME, changeScore);
}
public function addToStage(e:Event):void
{
this.x = 0;
this.y = 0;
}
private function showwinFunction(e:MouseEvent):void
{
gameScore+=50;
}
private function changeScore(e:Event):void
{
scoreText.text =""+gameScore;
}
public function showgameoverFunction(e:MouseEvent)
{
mainClass.showGameOver();
gameOverScore = new thegameoverclass(this);
gameOverScore.setTextScore(gameScore);
}
}
}
thegameoverclass.as
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.*;
public class thegameoverclass extends MovieClip
{
var mainClass:main;
var scorePoints:Number;
public function thegameoverclass(passedClass:main)
{
mainClass = passedClass;
finalScore.text = "test";
}
public function setTextScore(textToSet:Number)
{
finalScore.text = ""+scorePoints;
}
}
}
I have a view that I'm trying to setup an Index for. One of the select columns for the view executes a user-defined function that has a return value of varchar(250). However, when I try to setup an Index on that column, I see a size of nvarchar(4000). Why is that and will that cause a problem if I continue to setup my index?
Surprised that i havent been able to find this myself, but anyway. Let's say i use my web user control like this:
<myprefix:mytag userid="4" runat="server">Some fancy text</myprefix:mytag>
How would i be able to access the text inside the tags from its codebehind? Was expecting it to be exposed through this.Text, this.Value or something similar.
I have some code like this
function doSomething(){
Jquery.ajax(type: "POST",
url: "HelloWorld",
success: function (msg) {
if(msg.d =="Hello World")
{
return true;
}else
{
return false;
}
}
);
}
i want to know something based on which the return value of the succes function.
Can somebody help?
Hi Guys,
I've written a kind of navigation system for pedestrians. The only thing is, that I need a criterion to finish the navigation.
My values are gives as lat/long pairs.
What would you assume would be a good value to say, both positions are equal/near enough to tell the user that he has reached the goal?
Please keep also in mind, that it's idfficult to say "directly equal", because GPS modules may have variances...
greetz from europe,
poeschlorn
I'm using oracle express and in my application i would insert a time-stamp value in my table:
$marca = date('y-m-d H:i:s');
$query = " INSERT INTO SA_VERSIONE
( ID_ACCETTAZIONE, MARCA_TEMPORALE, TESTO, FIRMA, MEDICO)
VALUES
('$id', '$marca', '$testo', '$firma', '$medico')
";
$stid = oci_parse($conn, $query);
oci_execute($stid);
but when execute it return:
Warning: oci_execute() [function.oci-execute]: ORA-01843: mese non valido in ...
and say that the month is not valid
I Need to select a category from a list box with no of items on it. eg. Videos(29). I need to select this and in the next loop it will be "Videos(30)","Videos(31)" etc..
Tried the followings
Addselection with "//option[@value='4641']",
Storeselectedoption,
selenium.click,
selenium.doubleclick etc..
Is there an method for programatically (in T-SQL) retrieving the maximum (and minimum) value of a datatype? That it would act like float.MaxValue in C#.
I would like to use it in some selection when the parameter does not equal any actual values in the database, so I would use something like
declare @min float
declare @max float
/*fill @min and @max, can be null if undefined*/
select * from foo
where bar between isnull(@min,0 ), isnull(@max,max(float)/*magic*/)
Thanks
I've got a Jlist inside a JScrollPane and I've set a prototype value so that it doesn't have to calculate the width for big lists, but just uses this default width.
Now, the problem is that the Jlist is for some reason replacing the end of an element with dots (...) so that a horizontal scrollbar will never be shown.
How do I disable with "wrapping"? So that long elements are not being replaced with dots if they are wider than the Jlist's width?
I've reproduced the issue in a small example application. Please run it if you don't understand what I mean:
import javax.swing.*;
import java.awt.*;
public class Test
{
//window
private static final int windowWidth = 450;
private static final int windowHeight = 500;
//components
private JFrame frame;
private JList classesList;
private DefaultListModel classesListModel;
public Test()
{
load();
}
private void load()
{
//create window
frame = new JFrame("Test");
frame.setSize(windowWidth, windowHeight);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
//classes list
classesListModel = new DefaultListModel();
classesList = new JList(classesListModel);
classesList.setPrototypeCellValue("prototype value");
classesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
classesList.setVisibleRowCount(20);
JScrollPane scrollClasses = new JScrollPane(classesList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
for (int i = 0; i < 200; i++)
{
classesListModel.addElement("this is a long string, does not fit in width");
}
//panel
JPanel drawingArea = new JPanel();
drawingArea.setBackground(Color.white);
drawingArea.add(scrollClasses);
frame.add(drawingArea);
//set visible
frame.setVisible(true);
}
}
Even if you force horizontal scrollbar, you still won't be able to scroll because the element is actually not wider than the width because of the dot (...) wrapping.
Thanks in advance.
CALORIES = \
{ 'Beef' : 200, \
'Chicken' : 140, \
}
class Food():
__slots__ = (
'cal' # Calories
)
def mkFood( name ):
"""Create and return a newly initialized Food item"""
result = Food()
result.cal = calorie in dict(CALORIES[1])
return result
Is that a proper way to the value of the target item in Calories? Like getting 200, 140, such like that.
result.cal = calorie in dict(CALORIES[1])
I would like to quickly retrieve the median value from a boost multi_index container with an ordered_unique index, however the index iterators aren't random access (I don't understand why they can't be, though this is consistent with std::set...).
Is there a faster/neater way to do this other than incrementing an iterator container.size() / 2 times?
I have a DataGridView which is filling from Table in SQL Server Database. One of it's columns is "price".
Type of column in DGV is automatically sets as Decimal.
In some cases I need to write in cells of this column text like "none", instead of price.
How can I do it?
DGV.Item("price", 0).Value = "none"
doesn't work, because of decimal type of a cell.
I have 3 HTML combo/drop down boxes. All of them have a distinct name and id.
On a particular event I want to get the value of all three of them.
Can any one give me a code snippet for that?
I have the following SQL query, note I want the literal value '0' in the second
field in the second SELECT statement from the ItemSale table.
How do I express this in LINQ?
I get the error message 'Invalid anonymous type member declarator'.
SELECT BranchNumber,QuantitySold
FROM Department
UNION
SELECT BranchNumber,0
FROM ItemSale
How to express the '0' in LINQ?
var unionQuery = (from dept in Department
select new
{
dept.BranchNumber,
dept.QuantitySold,
})
.Concat(from item in ItemSale
select new
{
item.BranchNumber,
0
});
Hi,
in a Model I have a CharField with choices:
class MyModel(models.Model):
THE_CHOICES=(
('val',_(u'Value Description')),
)
...
myfield=models.CharField(max_length=3,choices=THE_CHOICES
Now in the template I access an instance of MyModel:
{{ my_instance.myfield }}
Of course the gives me val instead of Value Description. How do I get the description?
Thanks in advance!
I have the following code:
NSMutableDictionary *jsonObj = [parser objectWithString:json_string error:nil];
NSString *test = [[[jsonObj objectForKey:@"questions"] valueForKey:@"owner"] valueForKey:key];
but what I get back is:
(
1a19f089a2bc4ee42bff1c102c6e89b8
)
The actual value is fine, but I get those parenthesis, which show up in my string. How can I get rid of them?
how to get the value 4500 to a variable
stdClass Object ( [total] => 4500 )
i tried like these
$abc['total']
$abc->total
but get error when i tried to echo the variable
A PHP Error was encountered
Severity: 4096
Message: Object of class stdClass could not be converted to string
Filename: controllers/home.php
Line Number: 144
please help me
In Javascript I can do this:
function A(x) { return x || 3; }
This returns 3 if x is a "non-truthful" value like 0, null, false, and it returns x otherwise. This is useful for empty arguments, e.g. I can do A() and it will evaluate as 3.
Does Python have an equivalent? I guess I could make one out of the ternary operator a if b else c but was wondering what people use for this.
I want to do something like this
$.get('/Controller/Action/', { model : null }, function(data) {});
Unfortunatelly it doesn't work. In server side the value of the model is {object}.
How do I get null?
Hi,
How to alert variable name, not a value of variable?
var color = 'red';
alert(color); // Will alert 'red'
alert(/* magic */); // Will alert 'color'