bindata

Skipping Bytes when reading with BinData

我只是一个虾纸丫 提交于 2019-12-11 23:18:57
问题 So I have a Record like such: class Property < BinData::Record endian :little int32 :name_len string :name, read_length: :name_len # want to quit here. int32 :type_len string :type, read_length: :type_len end Is there a way for me to stop reading from the Record after it reads :name_len and :name, only if :name is equal to a certain value? Or is it the case that once you begin to read a file with a Record it must run all the way through? I know I can use :onlyif to skip all the remaining, but

Structuring BinData Records in Ruby

浪子不回头ぞ 提交于 2019-12-11 05:56:27
问题 I'm not sure choices is exactly what I need here, but I'll explain what I'm trying to do. I have the following BinData structure that works fine. class Property < BinData::Record endian :little int32 :name_len string :name, :read_length => :name_len int32 :type_len string :type, :read_length => :type_len int64 :data_len end However, after I get the :data_len, I need to get the actual data. How I handle what comes next depends on the value of the :type string. if type is "IntProperty" then the

005-Docker容器和服务器之间文件的传输

人走茶凉 提交于 2019-12-10 01:13:24
[root@jenkins data]# docker cp use_product centos2:/ [root@jenkins data]# sh /data/docker/docker_in.sh centos2 [root@f23c5bdd0542 /]# ls bin data dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp use_product usr var [root@f23c5bdd0542 /]# touch 2019 [root@f23c5bdd0542 /]# exit logout [root@jenkins data]# docker cp centos2:/2019 ./ [root@jenkins data]# stat 2019 File: ‘2019’ Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: fd00h/64768d Inode: 50668130 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2019-12-10 01:06:53.000000000

Java后端使用Freemarker导出word文档的各种细节

女生的网名这么多〃 提交于 2019-12-03 03:32:47
1.前言 最近在项目中,因客户要求,需要做一个导出成word的功能(比如月度报表等),技术选型也考虑过几种,比如easypoi,itext,但发现这两种在实现起来有困难,所以最终还是选Freemarker模板进行导出,灵活性比较好。 2.实现步骤 1.准备好标准文档的word,标题格式间距什么的先设计好,这是减少后面修改模板文很重要一步; 2.打开word原件把需要动态修改的内容替换成***,如果有图片,尽量选择较小的图片几十K左右,并调整好位置; 3.另存为,选择保存类型Word 2003 XML 文档(*.xml)【这里说一下为什么用Microsoft Office Word打开且要保存为Word 2003XML,本人亲测,用WPS找不到Word 2003XML选项,如果保存为Word XML,会有兼容问题,避免出现导出的word文档不能用Word 2003打开的问题】,还有保存的文件名尽量不要是中文; 4.用NotePad打开文件,notepad预先装好xml的插件,然后格式化,当然也可以用Firstobject free XML editor打开文件,选择Tools下的Indent【或者按快捷键F8】格式化文件内容。看个人喜欢; notepad xml插件下载地址: https://sourceforge.net/projects/npp-plugins/files/XML

Write array of radix-2 numeric strings to binary file in Ruby

你说的曾经没有我的故事 提交于 2019-11-30 11:07:36
I've written a simple Huffman encoding in Ruby. As output I've got an array, for example: ["010", "1111", "10", "10", "110", "1110", "001", "110", "000", "10", "011"] I need to write, and then read, it to and from a file. I tried several methods: IO.binwrite("out.cake", array) I get a simple text file and not binary. Or: File.open("out.cake", 'wb' ) do |output| array.each do | byte | output.print byte.chr end end Which looks like it works, but then I can't read it into array. Which encoding should I use? M. Shiina I think you can just use Array#pack and String#unpack like the following code: #

Write array of radix-2 numeric strings to binary file in Ruby

こ雲淡風輕ζ 提交于 2019-11-29 16:36:05
问题 I've written a simple Huffman encoding in Ruby. As output I've got an array, for example: ["010", "1111", "10", "10", "110", "1110", "001", "110", "000", "10", "011"] I need to write, and then read, it to and from a file. I tried several methods: IO.binwrite("out.cake", array) I get a simple text file and not binary. Or: File.open("out.cake", 'wb' ) do |output| array.each do | byte | output.print byte.chr end end Which looks like it works, but then I can't read it into array. Which encoding