compression

Extracting files from a Jar more efficently

南笙酒味 提交于 2019-12-04 16:41:54
I'm extending a utility class that bundles a set of images and .xml description files. Currently I keep all the files in a directory and load them from there. The directory looks like this: 8.png 8.xml 9.png 9.xml 10.png 10.xml ... ... 50.png 50.xml ... Here's my current constructor. It is lightning fast and does what I need it to do. (I've stripped out some of the error checking to make it easier to read): public DivineFont(String directory ) { File dir = new File(directory); //children is an array that looks like this: '10.fnt', '11.fnt', etc. String[] children = dir.list(fntFileFilter);

How do you compress a string, and get a string back using zlib?

有些话、适合烂在心里 提交于 2019-12-04 15:37:30
问题 I am trying to utilize Zlib for text compression. For example I have a string T='blah blah blah blah' I need to compress it for this string. I am using S=zlib.compress(T) to compress it. Now what I want is to get the non-binary form of S so that I can decompress T but in a different program. Thanks! EDIT: I guess I got a method to solve what I wanted. Here is the method: import zlib, base64 text = 'STACK OVERFLOW STACK OVERFLOW STACK OVERFLOW STACK OVERFLOW STACK OVERFLOW STACK OVERFLOW STACK

Compression issues with JQuery file in YUI Compressor

时光总嘲笑我的痴心妄想 提交于 2019-12-04 15:28:48
问题 I am trying to minify a few files with YUI compressor. However, I seem to be getting an error on 2 lines of code, which prevents compression. The .js file for jcarouselLite contains 1 error, and my own code contains the other. I have narrowed it down and in both occasions it looks like the the float property used in jQuery is causing this. The line is: li.css({overflow: "hidden", float: o.vertical ? "none" : "left"}); (jcarousellite) $("#now-playing .js-kit-rating div:first").css({width:

PHP - compress static css file with GZIP

泄露秘密 提交于 2019-12-04 14:14:57
so I have a css file, style.css. in the same directory I have the images/ folder. How can I make a script that compresses style.css, but from another folder? Right now I have this: <?php if(isset($_GET['css'])) $file = array('url' => htmlspecialchars($_GET['css']), 'type' => 'text/css'); if(isset($_GET['js'])) $file = array('url' => htmlspecialchars($_GET['js']), 'type' => 'application/javascript'); if(!isset($file)) exit(); header('Content-type: '.$file['type']); header('Cache-Control: max-age='.(60*60*6).', must-revalidate'); // whitespace+comment removal, in case gzip is off function

Decompress Rar file in Android

本小妞迷上赌 提交于 2019-12-04 14:05:01
问题 I want to learn how to decompress a .rar file in android. Zip files can be easily decompressed using ZipStream. Is there any similar way for rar files. 回答1: I just realized this with jUnrar from here https://github.com/edmund-wagner/junrar Create a new package within your Android src directory called com.github.junrar You should delete com.github.junrar.vfs2 because it has some dependencies and you probably won't use it anyway. You will probably get some errors about the logger class. You can

Decompress all Gzip files in a Hadoop hdfs directory

主宰稳场 提交于 2019-12-04 12:42:24
On my HDFS, I have a bunch of gzip files that I want to decompress to a normal format. Is there an API for doing this? Or how could I write a function to do this? I don't want to use any command-line tools; instead, I want to accomplish this task by writing Java code. Paul Samsotha You need a CompressionCodec to decompress the file. The implementation for gzip is GzipCodec . You get a CompressedInputStream via the codec and out the result with simple IO. Something like this: say you have a file file.gz //path of file String uri = "/uri/to/file.gz"; Configuration conf = new Configuration();

Huffman trees for non-binary alphabets?

烂漫一生 提交于 2019-12-04 12:40:57
Is there an easy generalization of Huffman coding trees for situations where the resulting alphabet is not binary? For instance, if I wanted to compress some text by writing it out in ternary, I could still build up a prefix-free coding system for each character I as writing out. Would the straightforward generalization of the Huffman construction (using a k-ary tree rather than a binary tree) still work correctly and efficiently? Or does this construction lead to a highly inefficient coding scheme? The algorithm still works and it's still simple — in fact Wikipedia has a brief reference to n

How can I effectively encode/decode a compressed position description?

和自甴很熟 提交于 2019-12-04 11:47:24
I am writing a tablebase for a Japanese chess variant. To index the table base, I encode each chess position as an integer. In one of the encoding steps, I encode where the pieces are on the board. Since the actual method is a bit complicated, let me explain the problem in a simplified manner. The Encoding In the endgame tablebase, I have (let's say) six distinct chess pieces that I want to distribute over a board with 9 squares. I can naïvely represent their positions by a six-tuple ( a , b , c , d , e , f  ) where each of the variables a to f is a number in the range 0 to 8 inclusive

Buffered Background InputStream Implementations

怎甘沉沦 提交于 2019-12-04 10:55:16
问题 I've written background InputStream (and OutputStream ) implementations that wrap other streams, and read ahead on a background thread, primarily allowing for decompression/compression to happen in different threads from the processing of the decompressed stream. It's a fairly standard producer/consumer model. This seems like an easy way to make good use of multi-core CPUs with simple processes that read, process, and write data, allowing for more efficient use of both CPU and disk resources.

Compressing image taken from device or chosen from library, iOS

喜你入骨 提交于 2019-12-04 10:43:53
In my app, user is allowed to take a photo from a device or upload it from the library to set it as his profile pic. Now when user is done, I need to upload that image to server. Usually the image taken from device is of size 5-6MB. I need it to compress to 25KB before uploading to server. So I am using following method to that - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissModalViewControllerAnimated:YES]; [picker release]; profilePicImageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"