走过海棠暮

文章 0 评论 0 浏览 24

走过海棠暮 2024-12-03 23:34:51

对于服务器应用程序来说,绝对是。拥有这么多内存但不使用它有什么意义呢?
(不,如果不使用内存单元,它不会节省电力)

JVM 喜欢内存。对于给定的应用程序,JVM 拥有的内存越多,执行的 GC 就越少。最好的部分是更多的物体会在年轻时死亡,而更少的物体会长期存在。

特别是在服务器启动期间,负载甚至高于正常情况。在这个阶段给服务器一个小的内存来工作是很愚蠢的。

Definitely yes for a server app. What's the point of having so much memory but not using it?
(No it doesn't save electricity if you don't use a memory cell)

JVM loves memory. For a given app, the more memory JVM has, the less GC it performs. The best part is more objects will die young and less will tenure.

Especially during a server startup, the load is even higher than normal. It's brain dead to give server a small memory to work with at this stage.

将最大和最小 JVM 堆大小设置为相同好吗?

走过海棠暮 2024-12-03 22:57:06

当您访问一个字段时,您需要先将 this 压入堆栈来正确引用它:

getIL.Emit(OpCodes.Ldarg_0);
getIL.Emit(OpCodes.Ldfld, fieldId);

When you access a field you need to reference it correctly by pushing this onto the stack first:

getIL.Emit(OpCodes.Ldarg_0);
getIL.Emit(OpCodes.Ldfld, fieldId);

C# 发出检查布尔字段并中断到标签

走过海棠暮 2024-12-03 22:41:12

损坏的图像是 CMYK .jpg,IE8 不支持。

The broken image is a CMYK .jpg, which IE8 does not support.

图像在 IE8 中不显示

走过海棠暮 2024-12-03 21:47:42

如果您不介意 VBA,这里有一个函数可以为您完成此任务。您的调用将类似于:

=CountRows(1:10) 
Function CountRows(ByVal range As range) As Long

Application.ScreenUpdating = False
Dim row As range
Dim count As Long

For Each row In range.Rows
    If (Application.WorksheetFunction.CountBlank(row)) - 256 <> 0 Then
        count = count + 1
    End If
Next

CountRows = count
Application.ScreenUpdating = True

End Function

它是如何工作的:我正在利用 256 行限制这一事实。工作表公式 CountBlank 将告诉您一行中有多少个单元格为空白。如果该行没有包含值的单元格,那么它将是 256。所以我只需负 256,如果它不是 0,那么我知道某处有一个具有某些值的单元格。

If you don't mind VBA, here is a function that will do it for you. Your call would be something like:

=CountRows(1:10) 
Function CountRows(ByVal range As range) As Long

Application.ScreenUpdating = False
Dim row As range
Dim count As Long

For Each row In range.Rows
    If (Application.WorksheetFunction.CountBlank(row)) - 256 <> 0 Then
        count = count + 1
    End If
Next

CountRows = count
Application.ScreenUpdating = True

End Function

How it works: I am exploiting the fact that there is a 256 row limit. The worksheet formula CountBlank will tell you how many cells in a row are blank. If the row has no cells with values, then it will be 256. So I just minus 256 and if it's not 0 then I know there is a cell somewhere that has some value.

如何计算 Excel 工作表中数据的行数?

走过海棠暮 2024-12-03 20:39:21

愿这应该是一个好的开始:

File xmlfile = null;
File propertiesfile = null;
Properties p = new Properties();
p.load(new FileReader(propertiesfile));

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document parse = db.parse(xmlfile);
DOMSource domSource = new DOMSource(parse);
Node root = domSource.getNode();
for (Object key : p.keySet()) {
    String sKey = "" + key;
    root.setTextContent(root.getTextContent()+sKey + "=" + p.getProperty(sKey));
}
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.transform(domSource, new StreamResult(xmlfile));

May this should be a good start:

File xmlfile = null;
File propertiesfile = null;
Properties p = new Properties();
p.load(new FileReader(propertiesfile));

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document parse = db.parse(xmlfile);
DOMSource domSource = new DOMSource(parse);
Node root = domSource.getNode();
for (Object key : p.keySet()) {
    String sKey = "" + key;
    root.setTextContent(root.getTextContent()+sKey + "=" + p.getProperty(sKey));
}
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.transform(domSource, new StreamResult(xmlfile));

如何读取属性文件并将数据插入到 XML 文件中?

走过海棠暮 2024-12-03 20:00:02

如果您使用的是 Windows,我建议使用 PyScripter。这太神奇了,尤其是对于初学者来说。

If you're on Windows I suggest using PyScripter. It's amazing, especially for beginners.

Python-IDLE语法错误问题

走过海棠暮 2024-12-03 19:48:14

如果想法只是将这些对象返回到客户端,为什么不使用匿名类返回所需的内容呢?

假设您有一个丑陋的 EntityFrameworkClass 对象列表,您可以这样做:

var result = (from c in List<EntityFrameworkClass> 
             select new { 
                        PropertyINeedOne=c.EntityFrameworkClassProperty1,
                        PropertyINeedTwo=c.EntityFrameworkClassProperty2
              }).ToList();

If the idea is simply to return those objects to the client side why don't you just return what you need using anonymous classes?

Assuming you have this ugly heavy list of EntityFrameworkClass objects, you could do this:

var result = (from c in List<EntityFrameworkClass> 
             select new { 
                        PropertyINeedOne=c.EntityFrameworkClassProperty1,
                        PropertyINeedTwo=c.EntityFrameworkClassProperty2
              }).ToList();

有没有办法让 JavaScriptSerializer 忽略某种泛型类型的属性?

走过海棠暮 2024-12-03 17:36:54

如果你想在 RowDataBound-event 中为 gridview 的每个项目设置 JS 代码,你可以在 ItemTemplate 中添加一个 Hyperlink-control 并将该控件的 NavigationUrl-property 设置为 JS

<ItemTemplate>
    <asp:Hyperlink runat="server" id="lnk" ImageUrl="..."/>
    ...
</ItemTemplate>

RowDataBound-eventhandler:

...
if (e.Row.RowType != DataControlRowType.DataRow)
    return;
string js = String.Format("javascript:ShowChildGrid('div{0}');", rowId);
var lnk = e.Row.FindControl("lnk") as Hyperlink;
if(lnk!=null)
{
    lnk.NavigationUrl = js;
    lnk.ImageUrl = ...;
}

当然,你还可以通过 runat-Attribute 使用 aimg

If you want to set the JS code for each single item of the gridview in RowDataBound-event, you could add a Hyperlink-control to your ItemTemplate and set the NavigationUrl-property of this control to the JS

<ItemTemplate>
    <asp:Hyperlink runat="server" id="lnk" ImageUrl="..."/>
    ...
</ItemTemplate>

RowDataBound-eventhandler:

...
if (e.Row.RowType != DataControlRowType.DataRow)
    return;
string js = String.Format("javascript:ShowChildGrid('div{0}');", rowId);
var lnk = e.Row.FindControl("lnk") as Hyperlink;
if(lnk!=null)
{
    lnk.NavigationUrl = js;
    lnk.ImageUrl = ...;
}

Of course, you can also use a and img using the runat-Attribute

如何在代码隐藏文件中编写Javascript?

走过海棠暮 2024-12-03 16:19:53

我想出了一个在问题描述部分提到的映射器方法。您可以在下面找到该方法的内容。可能有更好的方法来做到这一点,但这完全满足我的需要。我利用两件事来计算 JTable 中相应的行和列索引,如下所示:

int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
int weekOfMonth = cal.get(Calendar.WEEK_OF_MONTH);


 private int[] getCalendarIndexNumbers(
            int dayOfTheMonth,
            int year,
            int month) {

        int[] retArray = new int[2];
        Calendar cal = Calendar.getInstance();
        cal.set(year, month - 1, dayOfTheMonth);
        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
        int weekOfMonth = cal.get(Calendar.WEEK_OF_MONTH);

        int rowIndex = weekOfMonth-1;
        if (rowIndex < 0) {
            rowIndex = 0;
        }

        int columnIndex;
        switch (dayOfWeek) {
            case 1:
                columnIndex = 6;
                break;
            case 2:
                columnIndex = 0;
                break;
            case 3:
                columnIndex = 1;
                break;
            case 4:
                columnIndex = 2;
                break;
            case 5:
                columnIndex = 3;
                break;
            case 6:
                columnIndex = 4;
                break;
            case 7:
                columnIndex = 5;
                break;
            default:
                columnIndex = 6;
                break;
        }

        retArray[0] = rowIndex;
        retArray[1] = columnIndex;

        return retArray;

    }

为了填充 JTable 中单元格的内容,我必须编写一个实现 TableCellRenderer 并扩展 JTextArea 的自定义渲染器。示例如下: http://archive.devx .com/java/free/articles/kabutz07/Kabutz07-2.asp

希望这可以帮助那些需要开发类似应用程序的人。

感谢您之前的回复。

此致

I came up with a mapper method that I mentioned in the problem description section. Below you can find the content of this method. There might be better ways to do this but this perfectly meets my need. I utilized two things to calculate the corresponding row and column indexes in the JTable as follows:

int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
int weekOfMonth = cal.get(Calendar.WEEK_OF_MONTH);


 private int[] getCalendarIndexNumbers(
            int dayOfTheMonth,
            int year,
            int month) {

        int[] retArray = new int[2];
        Calendar cal = Calendar.getInstance();
        cal.set(year, month - 1, dayOfTheMonth);
        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
        int weekOfMonth = cal.get(Calendar.WEEK_OF_MONTH);

        int rowIndex = weekOfMonth-1;
        if (rowIndex < 0) {
            rowIndex = 0;
        }

        int columnIndex;
        switch (dayOfWeek) {
            case 1:
                columnIndex = 6;
                break;
            case 2:
                columnIndex = 0;
                break;
            case 3:
                columnIndex = 1;
                break;
            case 4:
                columnIndex = 2;
                break;
            case 5:
                columnIndex = 3;
                break;
            case 6:
                columnIndex = 4;
                break;
            case 7:
                columnIndex = 5;
                break;
            default:
                columnIndex = 6;
                break;
        }

        retArray[0] = rowIndex;
        retArray[1] = columnIndex;

        return retArray;

    }

In order to fill the contents of the cells in the JTable, I had to write a custom renderer that implements TableCellRenderer and extends JTextArea. An example for this is available at: http://archive.devx.com/java/free/articles/kabutz07/Kabutz07-2.asp

Hope this helps those who needs to develop a similar application.

Thanks for the previous responses.

Best Regards

类似于 Swing 应用程序的 Google 日历

走过海棠暮 2024-12-03 01:58:38

为此,您必须创建一个自定义对话框,如下所示,对其进行修改以满足您的需求

public static void showProgressDialog(Context mContext, String text, boolean remove)
{
    mDialog = new Dialog(mContext, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    LayoutInflater mInflater = LayoutInflater.from(mContext);
    View layout = mInflater.inflate(R.layout.popup_example, null);
    mDialog.setContentView(layout);

    TextView mTextView = (TextView) layout.findViewById(R.id.text);
    if (text.equals(""))
        mTextView.setVisibility(View.GONE);
    else
        mTextView.setText(text);

    mDialog.setCancelable(remove);
    // aiImage.post(new Starter(activityIndicator));
    mDialog.show();
}

popup_example.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_centerInParent="true">
        <ProgressBar
            android:id="@android:id/progress"
            style="?android:attr/progressBarStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dip"></ProgressBar>
        <TextView
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Loading Content"
            android:layout_margin="10dip"
            android:textColor="#FFFFFF"
            android:layout_gravity="center_vertical" />
    </LinearLayout>
</RelativeLayout>

For that you have to create a custom dialog box something like below modify it to suit your needs

public static void showProgressDialog(Context mContext, String text, boolean remove)
{
    mDialog = new Dialog(mContext, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    LayoutInflater mInflater = LayoutInflater.from(mContext);
    View layout = mInflater.inflate(R.layout.popup_example, null);
    mDialog.setContentView(layout);

    TextView mTextView = (TextView) layout.findViewById(R.id.text);
    if (text.equals(""))
        mTextView.setVisibility(View.GONE);
    else
        mTextView.setText(text);

    mDialog.setCancelable(remove);
    // aiImage.post(new Starter(activityIndicator));
    mDialog.show();
}

popup_example.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_centerInParent="true">
        <ProgressBar
            android:id="@android:id/progress"
            style="?android:attr/progressBarStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dip"></ProgressBar>
        <TextView
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Loading Content"
            android:layout_margin="10dip"
            android:textColor="#FFFFFF"
            android:layout_gravity="center_vertical" />
    </LinearLayout>
</RelativeLayout>

在 Android 中的进度指示器下方显示文本

走过海棠暮 2024-12-02 23:59:06

看看教程“UITableView – 将子视图添加到单元格的内容视图"。

尝试类似的操作

- (UITableViewCell *) getCellContentView:(NSString *)cellIdentifier {

    CGRect CellFrame = CGRectMake(0, 0, 320, 65);
    CGRect Label1Frame = CGRectMake(17,5,250,18);  

    UILabel *lblTemp;

    UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CellFrame reuseIdentifier:cellIdentifier] autorelease];  
    lblTemp = [[UILabel alloc] initWithFrame:Label1Frame];
    [lblTemp setFont:[UIFont fontWithName:@"Arial-BoldMT" size:15]];
    lblTemp.tag = 1;
    lblTemp.backgroundColor=[UIColor clearColor];
    lblTemp.numberOfLines=0;
    [cell.contentView addSubview:lblTemp];      
    return cell;  // this I forgot  
}

在 cellForRowAtIndexPath 中

{
    if(cell == nil)
            cell = [self getCellContentView:CellIdentifier];

    UILabel *lblTemp1 = (UILabel *)[cell viewWithTag:1];  
    lblTemp1.text =[nameArray objectAtIndex:value+indexPath.row];  
        return cell;
}

Have a look at the tutorial "UITableView – Adding subviews to a cell’s content view".

Try something like this

- (UITableViewCell *) getCellContentView:(NSString *)cellIdentifier {

    CGRect CellFrame = CGRectMake(0, 0, 320, 65);
    CGRect Label1Frame = CGRectMake(17,5,250,18);  

    UILabel *lblTemp;

    UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CellFrame reuseIdentifier:cellIdentifier] autorelease];  
    lblTemp = [[UILabel alloc] initWithFrame:Label1Frame];
    [lblTemp setFont:[UIFont fontWithName:@"Arial-BoldMT" size:15]];
    lblTemp.tag = 1;
    lblTemp.backgroundColor=[UIColor clearColor];
    lblTemp.numberOfLines=0;
    [cell.contentView addSubview:lblTemp];      
    return cell;  // this I forgot  
}

in cellForRowAtIndexPath

{
    if(cell == nil)
            cell = [self getCellContentView:CellIdentifier];

    UILabel *lblTemp1 = (UILabel *)[cell viewWithTag:1];  
    lblTemp1.text =[nameArray objectAtIndex:value+indexPath.row];  
        return cell;
}

向每个单元格添加额外的 UIlabel

走过海棠暮 2024-12-02 20:32:51
perl -ne'
   BEGIN { binmode STDOUT }
   s/\s//g;
   print pack "H*", $_;
' file.hex > file.gif

Perl 5.14:(

perl -ne'
   BEGIN { binmode STDOUT }
   print pack "H*", s/\s//gr;
' file.hex > file.gif

如果您想要,-nprint 可以替换为 -p$_ =高尔夫(缩短节目长度。)

perl -ne'
   BEGIN { binmode STDOUT }
   s/\s//g;
   print pack "H*", $_;
' file.hex > file.gif

Perl 5.14:

perl -ne'
   BEGIN { binmode STDOUT }
   print pack "H*", s/\s//gr;
' file.hex > file.gif

(-n and print can be replaced with -p and $_ = if you want to golf (shorten the length of the program.)

将十六进制流转换为 GIF

走过海棠暮 2024-12-02 11:54:48

在您的用例场景中,您可以使用 XML 文件中的“onclick”属性。输入要调用的方法的名称(不带括号),然后以 View 作为唯一参数来实现该方法。

http://developer.android.com/resources/articles/ui-1.6.html
滚动到底部,您将看到使用示例。

In your use case scenario, you can use the "onclick" attribute in the XML file. Put in the name of the method you want to call (without parentheses) and then implement that method taking in a View as the only parameter.

http://developer.android.com/resources/articles/ui-1.6.html
Scroll to the bottom and you will see the usage example.

Android 点击更改文本框文本

走过海棠暮 2024-12-02 11:07:41

以下是如何在 XNA 中围绕另一点旋转一个点的示例:

public Vector2 RotatePoint(Vector2 pointToRotate, Vector2 centerOfRotation, float angleOfRotation)
{
    Matrix rotationMatrix = Matrix.CreateRotationZ(angleOfRotation);
    return Vector2.Transform(pointToRotate - centerOfRotation, rotationMatrix);
}

Here is an example of how to rotate one point around another point in XNA:

public Vector2 RotatePoint(Vector2 pointToRotate, Vector2 centerOfRotation, float angleOfRotation)
{
    Matrix rotationMatrix = Matrix.CreateRotationZ(angleOfRotation);
    return Vector2.Transform(pointToRotate - centerOfRotation, rotationMatrix);
}

计算旋转时相对于其他点的点位置 - C# XNA

走过海棠暮 2024-12-02 09:59:18

std::cinstd::istream 类的实例。

cin>> x 只是调用 cin 对象上的函数。您可以直接调用该函数:

cin.operator >>(x);

为了允许您一次读取多个变量,operator>> 函数返回对其调用的流的引用。您可以调用:

cin >> x >> y;

或 等效:

cin.operator >>(x).operator >>(y);

或:

std::istream& stream = cin.operator >>(x);
stream.operator >>(y);

难题的最后一部分是 std::istream 可转换bool。布尔值是
相当于调用 !fail()

因此,在以下代码中:

int x;
std::istream& stream = std::cin.operator >>(x);
bool readOK = !stream.fail();
if (readOK)
{
  std::cout << x << "\n";
}

bool readOK = !stream.fail(); 可以简化为 bool readOK = stream;

您不需要单独的 bool 来存储流状态,因此只需执行 if (stream) 即可。

删除临时 stream 变量会得到 if (std::cin.operator >>(x))

使用运算符直接让我们回到原始代码:

int x;
if (std::cin >> x)
{
  std::cout << x << "\n";
}

std::cin is an instance of the std::istream class.

cin >> x is just calling a function on the cin object. You can call the function directly:

cin.operator >>(x);

To allow you to read multiple variables at once the operator >> function returns a reference to the stream it was called on. You can call:

cin >> x >> y;

or equivalently:

cin.operator >>(x).operator >>(y);

or:

std::istream& stream = cin.operator >>(x);
stream.operator >>(y);

The final part of the puzzle is that std::istream is convertible to bool. The bool is
equivalent to calling !fail().

So in the following code:

int x;
std::istream& stream = std::cin.operator >>(x);
bool readOK = !stream.fail();
if (readOK)
{
  std::cout << x << "\n";
}

bool readOK = !stream.fail(); can be reduced to just bool readOK = stream;.

You don't need a separate bool to store the stream state so can just do if (stream).

Removing the temporary stream variable gives if (std::cin.operator >>(x)).

Using the operator directly gets us back to the original code:

int x;
if (std::cin >> x)
{
  std::cout << x << "\n";
}

if (cin >> x) - 为什么可以使用该条件?

更多

推荐作者

束缚m

文章 0 评论 0

alipaysp_VP2a8Q4rgx

文章 0 评论 0

α

文章 0 评论 0

一口甜

文章 0 评论 0

厌味

文章 0 评论 0

转身泪倾城

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文