2015年6月

Apache设定访问数量及下载速度限制

获取 mod_bw

#tar xvf mod_bw-0.8.gz

# cd mod_bw

# /opt/apache/bin/apxs -ac mod_bw.c

# gcc -shared -p /opt/apache/module/mod_bw.so mod_bw.o

#/opt/apache/bin/apxs -i -a -c mode_bw.c

然后在apache配置文件里面按照需要添加限制即可。

<VirtualHost *:80>

    DocumentRoot "/web/linuxidc"

    ServerName www.linuxidc.com


    BandwidthModule On

    ForceBandWidthModule On

    Bandwidth all 1024000

    MinBandwidth all 50000

    # *表示文件类型,所有大于500k的文件下载速度100k ,
    # 这里我当时以为两个单位一样的。。。
    LargeFileLimit * 500 100000    

</VirtualHost>

附录:

- 阅读剩余部分 -

What does shouldOptimizeForNetworkUse actually do?

When shouldOptimizedForNetworkUse is set to YES calling finishWriting will move the MP4 moov atom (movie atom) from the end of the file to the beginning of the file. The moov atom contains information about the movie file like timescale and duration. The moov also contains "subatoms" witch contain information like the tracks, the data offsets in the file etc.

Playback is only possible using the information in the moov atom and when its located in the beginning of the file rather than at the end of the file, a movie player can begin playing the file even if it has only loaded the beginning of it.

In practice modern browsers will fetch the moov atom from the end of the file using HTTP/1.1 Range header to load the moov atom even if it is at the end of the file.

Setting the shouldOptimizedForNetworkUse to YES also has a few side-effects:

Finishing the movie takes a bit longer as the file has to be modified along with the offsets in the atom.
The output file is locked and not accessible because finishWriting will need to modify the whole file (move and update atoms). When set to NO, the movieFragmentInterval sets the flush interval for writing to the output video file, making the file readable during writing as the fragments are flushed to the file in their final form. The finishWriting will just need to append the moov atom to the end of the file instead of touching the already written fragments.

jquery iframe

How to access the content of an iframe with jQuery?

$("#myiframe").contents().find("#myContent")

dump memory

mach_port_t task = 0;
    
    task_for_pid(mach_task_self(), getpid(), &task);
    
    
    mach_port_t oldTask = task;
    
    mach_vm_address_t address = 0;
    mach_vm_size_t size = 0;
    
    mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT_64;
    vm_region_flavor_t flavor = VM_REGION_BASIC_INFO_64;
    vm_region_basic_info_data_64_t info;
    

- 阅读剩余部分 -

ios android php 统一 gzip 压缩算法

android:

public static byte[] encodeData(String source) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        
        DeflaterOutputStream deflater = new DeflaterOutputStream(out, new Deflater(1, true));
        deflater.write(source.getBytes());
        deflater.close();
        
        out.close();
        
        return Base64.getEncoder().encode(out.toByteArray());
    }

- 阅读剩余部分 -