compression

When compressing and encrypting, should I compress first, or encrypt first?

江枫思渺然 提交于 2019-11-27 09:39:50
问题 If I were to AES-encrypt a file, and then ZLIB-compress it, would the compression be less efficient than if I first compressed and then encrypted? In other words, should I compress first or encrypt first, or does it matter? 回答1: Compress first. Once you encrypt the file you will generate a stream of random data, which will be not be compressible. The compression process depends on finding compressible patterns in the data. 回答2: Compression before encryption is surely more space efficient but

Python script for minifying CSS? [closed]

这一生的挚爱 提交于 2019-11-27 09:07:55
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I'm looking for a simple Python script that can minify CSS as part of a web-site deployment process. (Python is the only scripting language supported on the server and full-blown parsers like CSS Utils are overkill for this project). Basically I'd like jsmin.py for CSS. A single script with no dependencies. Any

Split files using tar, gz, zip, or bzip2 [closed]

落爺英雄遲暮 提交于 2019-11-27 08:56:00
问题 I need to compress a large file of about 17-20 GB. I need to split it into several files of around 1GB per file. I searched for a solution via Google and found ways using split and cat commands. But they did not work for large files at all. Also, they won't work in Windows; I need to extract it on a Windows machine. 回答1: You can use the split command with the -b option: split -b 1024m file.tar.gz It can be reassembled on a Windows machine using @Joshua's answer. copy /b file1 + file2 + file3

Really simple short string compression

杀马特。学长 韩版系。学妹 提交于 2019-11-27 08:51:44
Is there a really simple compression technique for strings up to about 255 characters in length (yes, I'm compressing URLs )? I am not concerned with the strength of compression - I am looking for something that performs very well and is quick to implement. I would like something simpler than SharpZipLib : something that can be implemented with a couple of short methods. I think the key question here is " Why do you want to compress URLs? " Trying to shorten long urls for the address bar? You're better storing the original URL somewhere (database, text file ...) alongside a hashcode of the non

Why does BCL GZipStream (with StreamReader) not reliably detect Data Errors with CRC32?

半城伤御伤魂 提交于 2019-11-27 08:45:45
The the other day I ran into the question GZipStream doesn't detect corrupt data (even CRC32 passes)? (Of which this might very well be a "duplicate", I have mixed feelings on the subject. I was also the one who added the CRC32 to the title, but in retrospect that feels out of place with the remainder of the post). After exploring the problem a bit on my own, I think that the issue is far greater than the other question initially portrays. I expanded upon the other question and made the test code runnable under LINQPad and attempt to better showcase the CRC32 (Cyclic Redundancy Check) issue,

LZW Compression In Lua

喜夏-厌秋 提交于 2019-11-27 08:36:04
问题 Here is the Pseudocode for Lempel-Ziv-Welch Compression. pattern = get input character while ( not end-of-file ) { K = get input character if ( <<pattern, K>> is NOT in the string table ){ output the code for pattern add <<pattern, K>> to the string table pattern = K } else { pattern = <<pattern, K>> } } output the code for pattern output EOF_CODE I am trying to code this in Lua, but it is not really working. Here is the code I modeled after an LZW function in Python, but I am getting an

Read a .Z file (unix compresses file) in Java

白昼怎懂夜的黑 提交于 2019-11-27 08:35:52
问题 The said file extension is explained here at http://kb.iu.edu/data/abck.html. I want to use a java api to read the contents of a Z file. Neither the ZipFile api or the GZIPInputStream seem to work. I can use the ZipFile api to open normal .zip files. ZipFile zf = new ZipFile("CR93H2.Z"); Enumeration entries = zf.entries(); To add, the said .Z file opens up fine in winrar. Does anyone know about the solution to it. Thanks 回答1: You can use compress-j2me : % svn checkout --quiet http://compress

Encoding issue with requesting JSON from StackOverflow API

て烟熏妆下的殇ゞ 提交于 2019-11-27 07:57:07
问题 I can't figure this out for the life of me. Below is an implementation with the request module, but I've also tried with the node-XMLHttpRequest module to no avail. var request = require('request'); var url = 'http://api.stackexchange.com/2.1/questions?pagesize=100&fromdate=1356998400&todate=1359676800&order=desc&min=0&sort=votes&tagged=javascript&site=stackoverflow'; request.get({ url: url }, function(error, response, body) { if (error || response.statusCode !== 200) { console.log('There was

How to read or parse MHTML (.mht) files in java

牧云@^-^@ 提交于 2019-11-27 07:55:17
I need to mine the content of most of known document files like: pdf html doc/docx etc. For most of these file formats I am planning to use: http://tika.apache.org/ But as of now Tika does not support MHTML (*.mht) files.. ( http://en.wikipedia.org/wiki/MHTML ) There are few examples in C# ( http://www.codeproject.com/KB/files/MhtBuilder.aspx ) but I found none in Java. I tried opening the *.mht file in 7Zip and it failed...Although the WinZip was able to decompress the file into images and text (CSS, HTML, Script) as text and binary files... As per MSDN page ( http://msdn.microsoft.com/en-us

How to minify jquery files?

二次信任 提交于 2019-11-27 07:46:37
问题 I am using jquery and I got a couple plugins that don't offer a minified version. So I want to take the full version and minfiy it but all the sites I have found that you input your javascript and it minifies it breaks the plugin. Like it must strip something out because I get a syntax error. So anyone got a good one that I can use? 回答1: If you're familiar with Java you could also use YUI compressor to minify JS (and CSS) files yourself. We use it here as well and it works great. 回答2: