I have a dataframe with numeric entries like this one
test <- data.frame(x=c(26,21,20),y=c(34,29,28))
How can I get the following vector?
> 26,34,21,29,20,28
Why do most developers consider the W3C box-model to be better than the box-model used by Internet Explorer?
I know it's very frustrating developing pages that look the way you want them on Internet Explorer, but I find the W3C box-model to be counter-intuitive. For example, if margins, padding, and border were factored into the width, I could assign fixed width values for all my columns without having to worry about how many columns I have and what changes I make to my padding and margins.
Under W3C box model I have to worry about how many columns I have, and develop something akin to a mathematical formula to calculate my values. Changing them would nightmarish, especially for complex layouts. My novice opinion is that it's more restrictive. Consider this small frame-work I wrote:
#content {
margin:0 auto 30px auto;
padding:0 30px 30px 30px;
width:900px;
}
#content .column {
float:left;
margin:0 20px 20px 20px;
}
#content .first {
margin-left:0;
}
#content .last {
margin-right:0;
}
.width_1-4 {
width:195px;
}
.width_1-3 {
width:273px;
}
.width_1-2 {
width:430px;
}
.width_3-4 {
width:645px;
}
.width_1-1 {
width:900px;
}
These values I have assigned here will falter unless there are three columns, and thus the margins at 0(first)+20+20+20+20+0(last). It would be a disaster if I wanted to add padding to my columns too, as my entire setup would have to be re calibrated. Now imagine if column width incorporated all the other elements, all I would need to do is change one associated value, and I have my layout. I'm less criticizing it and more hoping to understand why it's better, or why I'm finding it more difficult.
Am I doing this whole thing wrong? I don't know very much about this topic, but it seems counter intuitive to use W3C's box-model. Some advice would be really appreciated.
Thanks
HI,
I am sure this is very basic, however I am not able to find the solution.
I have a base ShapeContainer(UIComponent). I add a uicomponent which has mouse down listener to ShapeContainer. the listener works great.
When I add a simple sprite(draw square) on the ShapeContainer, The listener does not work any more.
In the code, if I comment below lines, The event listener works fine.
var square:Sprite = new Sprite();
square.graphics.lineStyle(4,0x00FF00);
square.graphics.drawRect(0,0,20,20);
square.mouseEnabled=false;
shapeContainer.addChildAt(square,1);
I have tried few things like, mouseenabled=false on top sprite.
also tried to add addChildAt but non of them did any help.
How can I draw a shape and also have the event listener work.
enter code here
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
var shapeContainer:UIComponent = new UIComponent();
shapeContainer.x=100;
shapeContainer.y=100;
shapeContainer.width=200;
shapeContainer.height=200;
rawChildren.addChild(shapeContainer);
var EventListenerShape:UIComponent = new UIComponent();
EventListenerShape.x=100;
EventListenerShape.y=100;
EventListenerShape.width=200;a
EventListenerShape.height=200;
EventListenerShape.graphics.clear();
EventListenerShape.graphics.beginFill(0xf1f1f1, 0.1);
EventListenerShape.graphics.drawRoundRect(0, 0, 200, 200, 10, 10);
EventListenerShape.alpha = 0;
EventListenerShape.graphics.endFill();
EventListenerShape.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownfunc);
shapeContainer.addChild(EventListenerShape);
var square:Sprite = new Sprite();
square.graphics.lineStyle(4,0x00FF00);
square.graphics.drawRect(0,0,20,20);
square.mouseEnabled=false;
shapeContainer.addChildAt(square,1);
}
private function mouseDownfunc(e:MouseEvent){
trace("mouse Down **");
}
]]>
</mx:Script>
<mx:Canvas id="uic" width="100%" height="100%" backgroundColor="0xFFFFFF">
</mx:Canvas>
I have a question related to Prepared Steatement pooling (across all connections). Here's the config file
<datasources>
<local-tx-datasource>
<jndi-name>JNDI-NAME</jndi-name>
<connection-url>jdbc:mysql://<server_name>/<database_name>?useServerPrepStmts=true</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>xxx</user-name>
<password>xxxxx</password>
<min-pool-size>10</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>20</idle-timeout-minutes>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
<background-validation>true</background-validation>
<background-validation-minutes>5</background-validation-minutes>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
It seems that this line:
<background-validation-minutes>5</background-validation-minutes>
doesn't cause any problems with Prepared Statements, but:
<idle-timeout-minutes>20</idle-timeout-minutes>
causes that all connections are removed and re-created if there was no traffic for the last 20 minutes. Because of that existing Prepared Statements are removed from the pool of cached Prepared Statements. How to overcome this issue? I have to use idle-timeout-minutes because MySQL server closes the connection after 8h
I have two tables:
table: points
|key_id | name | x | y |
------------------------
|1 | A |10 |20 |
|2 | A_1 |11 |21 |
|3 | B |30 |40 |
|4 | B_1 |31 |42 |
table: pairs
|f_key_p1 | f_key_p2 |
----------------------
|1 | 2 |
|3 | 4 |
Table 'pairs' defines which rows in table 'points' should be paired.
How can I query database to select paired rows?
My desired query result would be like this:
|name_1|x_1|x_2|name_2|x_2|y_2|
-------------------------------
|A |10 |20 |A_1 |11 |21 |
|B |30 |40 |B_1 |31 |41 |
How do you limit the result set of a mapped collection in nHibernate? For instance:
Model.Items;
will always return all the Items for the given Model. Is there any way to force it to return only, say, 20 Items without creating a specific query ? Something like
Model.Items.SetMaxResults(20);
In other words, I would like nHibernate to return IQueryable instead of a simple IList, when I access a collection.
I have a table named Student as followed:
CREATE TABLE "STUDENT"
( "ID" NUMBER(*,0),
"NAME" VARCHAR2(20),
"AGE" NUMBER(*,0),
"CITY" VARCHAR2(20),
PRIMARY KEY ("ID") ENABLE
)
I am trying to get all the records of the students having a larger age than the average age. This is what I tried:
SELECT *
FROM student
WHERE age > AVG(age)
and
SELECT *
FROM student
HAVING age > AVG(age)
Both ways did not work!
How can one put components into an advanced data grid?
I wish to have a standard row with string items,
in this row there is a date selector I want to put in,
and in another cell of the row I want to put a drop down list box containing text "40" and "20" or you can manually edit the cell so that it displays what ever input you decide (other than 40 and 20)
thanks so much
I know main() and other parts of the prog are missing, but please help
def horizLine(col):
for cols in range(col):
print("*", end='')
print()
def line(col): #C,E,F,G,I,L,P,T
for col in range(col//2):
print("*", end='')
print()
def functionT(width):
horizLine(width)
line(width)
enter width for the box
width = int(input("Enter a width between 5 and 20: "))
letter=input("Enter one of the capital letters: T ")
if ((width >= 5 and width <=20)):
if letter=="T":
functionT(width)
else:
print()
print("Invalid letter!")
else:
print("You have entered a wrong range for the width!")
main()
Hi all,
I have an sql query here and it returns a number of results. I'd like to show these results in groups.
What I mean is,
show the first 20 results in some part of the page,
show the next 20 results in another part of the page
etc...
How can I do that?
i can't seem to tween any bitmap filters. here's my code:
var dropShadow:DropShadowFilter = new DropShadowFilter();
mySprite.filters = [dropShadow];
var dropShadowTween:Tween = new Tween(dropShadow, "distance", Regular.easeOut, 4.0, 20, 2, true);
what is my mistake? i've also tried the following but it doesn't work:
var dropShadowTween:Tween = new Tween(mySprite.filters[0], "distance", Regular.easeOut, 4.0, 20, 2, true);
How to write following statement in c using switch statement in c
int i = 10;
int j = 20;
if (i == 10 && j == 20)
{
Mymethod();
}
else if (i == 100 && j == 200)
{
Yourmethod();
}
else if (i == 1000 || j == 2000) // OR
{
Anymethod();
}
Thanks
What happens in mysql multiple records insert during an error. I have a table:
id | value
2 | 100
UNIQUE(id)
Now i try to execute the query:
INSERT INTO table(id, value) VALUES (1,10),(2,20),(3,30)
I will get a duplicate-key error for the (2,20) BUT... Will the (1,10) get into the database? Will the (3,30) get into the database?
Just a little confused here...
I have a function in postgres, and when I'm at the pg prompt, I just do:
SELECT zp('zc',10,20,90);
FETCH ALL FROM zc;
I'm wondering how to do this from php?
I thought I could just do:
$q = pg_query("SELECT zp('zc',10,20,90)");
But, how do I "fetch" from that query?
Hi,
I want to access a file on remote machine(win2k3, 10.10.20.30), but i couldn't understand how to login to that machine in my program. is there any simple win api that takes network path, credentials and returns the handle?
i just want to access \10.10.20.30\c$\test.txt,
WNetAddConnection2, WNetAddConnection3 are little confusing. Any suggestion will be helpful.
In javascript you can create a Date object from a string, like
var mydate = new Date('2008/05/10 12:08:20');
console.log(mydate); //=> Sat May 10 2008 12:08:20 GMT+0200
Now try this using milliseconds in the string
var mydate = new Date('2008/05/10 12:08:20:551'); // or '2008/05/10 12:08:20.551'
console.log(mydate); //=> NaN
Just out of curiosity: why is this?
hello, i want to output some text in an label
<input type="text" size="20" maxlength="20" name="pizza1" value="Margherita">
is there a parameter that the text (value=Margherita) can't be changed, so the text is just displayed.
is input type= "text" the best way to output text? (later on the text is dynamic created)
thanks
I'm trying this as part of a big query:
(CONVERT(varchar(20), AZ_DTA_APP_AGE, 103) + ' ' + (CONVERT(varchar(20), AZ_DTA_APP_AGE, 108)) AS AZ_DTA_APP_AGE
why it doesn't work?
I get:
Syntax error near keyword 'AS'
Thank you
config.ini:
[globalloads]
plugin.SWPlugin = 1
plugin.SWPlugin.params.1 = true
plugin.SWPlugin.params.2 = 10
[testz : globballoads]
plugin.SWPlugin.params.2 = 20
Simple enough?
// load testz config and programmatically create this equivalent code:
SWPluginAbstract p = new SWPlugin(true, 20);
If a different config.ini setup is needed to do that, it's not a problem...
I have JPanel wrapped in JScrollPane and I want the rectangle to be drawn always on the same position = moving with scrollbars wont affect the visibility of the rectangle.
I tried following code:
public void paintComponent(Graphics g) {
g.setColor(Color.red);
g.drawRect(50, (int)getVisibleRect().getY(), 20 , 20);
}
but it only repaints the rectangle when size of whole JPanel is changed.
The rule at work here is that users can be awarded badges for a streak of 10, 20, and 30. If the user has a streak over 30, such as 40 or 50, then the logic must be that it only awards a 10-streak badge for 40 and a 20-streak badge for 50, and so on.
def check_win_streak(streak)
badge = 10
while badge < badge::MAX_STREAK_BADGE_SIZE do # MAX_STREAK_BADGE_SIZE = 30
if streak < badge then
break
end
if (streak % badge == 0) then
award_streak_badge(badge)
end
badge += 10
end
end
I'd like to export plotting symbols form R as a png graphic. But I haven't found a perfect way yet.
Using
png("symbol.png",width=20, height=20, bg="transparent")
par(mar=c(0,0,0,0))
plot.new()
symbols(1, 1, circles=0.3, bg=2, inches=FALSE, lwd=2, bty="n")
dev.off()
creates a little border around the symbol (I'd like it to be transparent) and the symbol isn't filling the whole space.
Is there a more specific way of doing this ?
Hello. How can I remove the first number in a string? Say if I had these 48 numbers seperated with a ',' (comma):
8,5,8,10,15,20,27,25,60,31,25,39,25,31,26,28,80,28,27,31,27,29,26,35,8,5,8,10,15,20,27,25,60,31,25,39,25,31,26,28,80,28,27,31,27,29,26,35
How would I remove the "8," from the string? Thanks.
So I have some data that looks like this.
`USERID1 USERID2`
1 10
2 20
2 30
3 40
3 50
1 10
2 20
2 30
3 50
I want a query that produces the following
`USERID1 COUNT`
2 2
3 2
It's a group by query that shows me the count of unique USERID2 for each USERID1 that has more than 1 USERID2 associated with it. God I hope you aren't as confused as I am by that last statement.
I have one table, which has three fields and data.
Name , Top , Total
cat , 1 , 10
dog , 2 , 7
cat , 3 , 20
horse , 4 , 4
cat , 5 , 10
dog , 6 , 9
I want to select the record which has highest value of Total for each Name, so my result should be like this:
Name , Top , Total
cat , 3 , 20
horse , 4 , 4
Dog , 6 , 9
I tried group by name order by total, but it give top most record of group by result. Can anyone guide me, please?