小编Mic*_*cha的帖子

如何在php和boost库IPC之间进行通信?

我在php中的客户端和服务器通过共享内存进行通信,现在我想使用Boost.Interprocess访问这个shred内存对象我该如何访问它?server.php:

  function create_image($str){
  // Create a blank image and add some text
  $im = imagecreatetruecolor(300, 20);
  $text_color = imagecolorallocate($im, 233, 14, 91);
  $stringBanner=exec("date").$str;
  imagestring($im, 1, 5, 5,  $stringBanner , $text_color);

  ob_start();
   imagejpeg($im);
  $i = ob_get_contents();
  ob_get_clean(); 
  imagedestroy($im);
   return $i; 
  }  
  echo "\n".__FILE__."\n";
  $shm_key = ftok(__FILE__, 't');
  echo $shm_key."\n";


  $shm_id = shmop_open($shm_key, "a", 0, 0); 
 if ($shm_id) {
  //it is already created
  shmop_delete($shm_id);
  shmop_close($shm_id); 
 } 
 //you need to create it with shmop_open using "c" only
 echo "try to create\n";
 if(!$shm_id = …
Run Code Online (Sandbox Code Playgroud)

php ipc shared-memory boost-interprocess

13
推荐指数
1
解决办法
1035
查看次数

从头读取大文件

我可以从我的最终读取PHP文件,例如,如果我想阅读最后10-20行吗?

而且,正如我读到的,如果文件的大小超过10mbs,我开始得到错误.

我该如何防止此错误?

为了阅读普通文件,我们使用以下代码:

if ($handle) {
    while (($buffer = fgets($handle, 4096)) !== false) {
    $i1++;
    $content[$i1]=$buffer;
    }
    if (!feof($handle)) {
        echo "Error: unexpected fgets() fail\n";
    }
    fclose($handle);
}
Run Code Online (Sandbox Code Playgroud)

我的文件可能超过10mbs,但我只需阅读最后几行.我该怎么做?

谢谢

php file-io

12
推荐指数
4
解决办法
2万
查看次数

在缩放的散点图中获取区域或元素

我有以下问题.我想放大Scatterplot然后选择所有显示的元素.

以某种方式获取放大的Scatterplot中的显示区域就足够了.从该区域的范围,我可以确定哪些元素在区域中显示,哪些不是.

\ edit:找到解决方案(实现AxisChangeListener接口)

import java.awt.Color;
import java.awt.Dimension;

import org.jfree.chart.ChartPanel;
import org.jfree.chart.event.AxisChangeEvent;
import org.jfree.chart.event.AxisChangeListener;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import org.jfree.chart.ChartFactory;  
import org.jfree.chart.JFreeChart; 


public class ScatterExample extends ApplicationFrame implements AxisChangeListener {
/**
 * Creates a new demo instance.
 * @param title the frame title. 
 */

private XYSeriesCollection dataset;
private JFreeChart chart;


public ScatterExample(String title) { 
    super(title);

    dataset = createSampleXYDataset();

    chart = ChartFactory.createScatterPlot(
            "Scatterplot Demo", // chart title
            "X", // domain axis label
            "Y", …
Run Code Online (Sandbox Code Playgroud)

zoom jfreechart elements selection area

12
推荐指数
1
解决办法
1493
查看次数

performTraversals递归的原因,长egl缓冲区交换时间

我在Android 4.2.2上的非根Nexus 4上使用systrace测量我的应用程序的性能.我在报告中看到一些对我没有意义的事情,我想知道它们是否可能是systrace错误,或者是否有人可能知道这些症状可能的根本原因.

1-运行结束时performTraversals下的大型递归

链接到报告 - 请查看运行结束时的大曲线(~18s).我的理解是performTraversals处于框架级别,它绘制了用户界面的单个框架.所以对我来说没有任何意义,它下面可能会有递归调用.另外,因为我在运行结束时得到了这种指数堆栈,我认为这实际上只是运行结束时数据的systrace缺陷.这种递归是否可能?这是什么意思?

2- performTraversals在运行过程中递归,具有较长的缓冲区交换时间

链接到报告 - 有趣的行为开始于12秒左右.当我在跑步中间看到类似的东西时,我想我也许不应该写下这个.此外,我花了很多时间试图弄清楚什么可能会占用这么长的eglSwapBuffers/queueBuffer(我的应用程序不使用openGL,只是直接使用框架)无济于事,当一位同事告诉我只是忽略它因为交换缓冲区总是瞬间完成的.可能还有更多吗?这里有什么需要调查的吗?

performance android systrace

12
推荐指数
1
解决办法
1314
查看次数

Segfault读取延迟字节串超过2 ^ 18个字节

请考虑以下代码:http://hpaste.org/90394

我将内存映射到一个大的460mb文件到一个懒惰的ByteString.ByteString报告的长度471053056.

何时nxNodeFromID file 110000更改为较低的节点ID,即:10000,它完美地工作.然而; 一旦我尝试序列化任何过去正好2 ^ 18字节(262144)的ByteString,我得到Segmentation fault/access violation in generated code并终止.

我正在运行Windows并使用GHC 7.4.2.

请告知这是我的错,还是懒惰的问题,或Haskell的一些问题.

haskell mmap lazy-evaluation ghc bytestring

11
推荐指数
1
解决办法
390
查看次数

Microsoft.Office.Interop.Excel:如何将边框应用于ONE CELL

我想使用Microsoft.Office.Interop.Excel库将边框应用于一个单元格.

我正在运行一个while循环,它在某个列中搜索一个空单元格,一旦找到单元格,我想对它应用边框.

我知道有很多关于这个使用Ranges的论坛,但我不能使用范围功能,因为我不知道它正在应用于哪个单元格.

我的想法是:

(Excel.Range)xlWS.Cells [row,1] .Borders.LineStyle =(Whatever Value);

有什么建议?(除了链接到其他论坛,我已经看过很多表格)?

c# excel border cell excel-interop

7
推荐指数
2
解决办法
4万
查看次数

在父窗体上启用滚动条

我有以下这个问题.基于图像在此输入图像描述 子表单上的某些控件无法正确显示.我也不能Autoscroll set to true在儿童形式上使用,因为它的一些控制是anchored bottom.我想的修复是当子表单的高度重叠时在父表单上有一个滚动条.我应该在代码上添加什么来使父表单有一个滚动条?

我使用此代码在父窗体中显示子窗体.

void ParentButtonClickNew(){

  ChildForm entry = new ChildForm();
  LoadChildForm(entry, this); 
}



 public void LoadChildForm(object childForm, object container)
    {
        System.Windows.Forms.Form xForm = (System.Windows.Forms.Form)childForm;
        System.Windows.Forms.Control control = (System.Windows.Forms.Control)container;

        xForm.TopLevel = false;

        if (control.Controls.Count == 0)
        {
            xForm.Parent = control;
            xForm.StartPosition = FormStartPosition.CenterScreen;
            //xForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            xForm.Show();
            xForm.BringToFront();

        }
        else
        {
            bool isFound = false;
            for (int i = 0; i <= control.Controls.Count - 1; i++)
            {
                try
                {
                    System.Windows.Forms.Form myForm = (System.Windows.Forms.Form)control.Controls[i]; …
Run Code Online (Sandbox Code Playgroud)

.net c# scrollbar winforms

7
推荐指数
1
解决办法
2869
查看次数

内部类和公共构造函数 - 为什么它与Activator.CreateInstance一起使用?

我想通过创建一些类的实例Activator.CreateInstance(...).所有类都继承相同的抽象类.构造函数有一个参数.

类和构造函数不应该是公共的.

这是我想要的代码(但不是得到):

internal abstract class FooAbstract
{
    protected Bar MyProperty { get; set; }

    // Constructor is only need in concreat classes of FooAbstract
    protected FooAbstract(Bar barProperty)
    {
        MyProperty = barProperty;
    }
}

internal class Foo : FooAbstract
{
    // Internal is enough, public is not necessary
    internal Foo(Bar barProperty) 
        : base(barProperty)
    {
}

// Many more Foo´s ...

internal class Creator()
{
    private object CreateAFoo<T>() where T : FooAbstract
    {
        T someFoo = (T)Activator.CreateInstance(typeof(T), …
Run Code Online (Sandbox Code Playgroud)

.net c# constructor access-modifiers activator

7
推荐指数
1
解决办法
2715
查看次数

清除部分输出缓存

我有一个页面,其控件是输出缓存(部分输出缓存).这些设置如下:

[PartialCaching(86400, null, null, "campaign.whatwhere", true)]
public partial class controls_LatestEnquiriesListCached : System.Web.UI.UserControl
{

...
Run Code Online (Sandbox Code Playgroud)

public override string GetVaryByCustomString(HttpContext context, string custom)
{
    if (custom == "campaign.whatwhere")
    {
        return (CampaignManager.CurrentCampaign.DefaultWorkTypeId ?? 0).ToString() + (CampaignManager.CurrentCampaign.DefaultEnquiryAreaId ?? 0).ToString();
    }
    return base.GetVaryByCustomString(context, custom);
}
Run Code Online (Sandbox Code Playgroud)

Global.asax

如何设置以便我可以在特定页面上清除此输出缓存?

有可能设置像MyPageWithCachedControl.aspx?ClearCache=true???

c# asp.net fragment-caching global-asax

5
推荐指数
1
解决办法
1262
查看次数

真正可见的选择器

jquery :visible:hidden选择器有点误导,他们选择在文档中占用空间的元素,因此即使它不是o_O visibility:hidden也被归类为:visible

我需要能够只选择:reallyvisible我能用眼睛看到的元素,例如,不是opacity:0visibility:hidden

显然,对于一个元素在视觉上可见所有它的祖先也必须是可见的所以我假设一个递归的查找树是必要的.

这太贵了吗?谁能建议一种可靠有效的方法来实现这一目标?

javascript jquery

5
推荐指数
1
解决办法
132
查看次数