compression

Compress JavaScript with gzip

浪尽此生 提交于 2019-12-13 04:53:36
问题 I ran Google PageSpeed Insights to optimize my site and it recommended archiving the numerous JavaScript files with gzip. How does this work? How are the files imported/included as an archive? Can they all be inside one big archive, or should they be individual archives? 回答1: You can configure your web server to do the compression for you; in the case of Apache: AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript 回答2: I think they were

Sending gzipped data over a network from C# to Java

你。 提交于 2019-12-13 04:49:18
问题 I have an application that sends data gathered from a data source on my PC (say, Excel or Access) to a receiving app on an Android tablet. I am in the testing stage of compressing the data before it is sent and then decompressing it after it is received. I'm using GZIP for this, with DotNetZip on the C# side and the built-in GZIPInputStream class on the Java side. I'm having issues getting it to work properly. When I do a test just on one side (compressing and decompressing to see if the data

Rails Asset Pipeline JS Compression Inserting “Illegal Characters”

别等时光非礼了梦想. 提交于 2019-12-13 04:45:29
问题 I just asked a question about an "Illegal Character" in my javascript. The answer there led me to find that there is a problem with compressing javascript in the Rails asset pipeline inserting various Illegal Characters. The error I was receiving in the post was: SyntaxError: Invalid character '\u0008' I found that not using compression caused this to go away completely ... but I want compression! That error was found using the Rails default uglifer gem. I thought maybe it was a bug with that

How to read .exe in c

妖精的绣舞 提交于 2019-12-13 04:42:15
问题 I'm on a little project of making a little compressor program. For that I want to read a file, say an .exe, and parse it char by char and use some simple dictionary algorithm to encrypt it. For reading the file I just thout in using a simple code I found: char *readFile(char *fileName) { FILE *file; char *code = malloc(10000* sizeof(char)); file = fopen(fileName, "rb"); do { *code++ = (char)fgetc(file); } while(*code != EOF); return code; } My problem is that it's seems imposible to read an

How to compress files in .NET 1.1

て烟熏妆下的殇ゞ 提交于 2019-12-13 04:15:09
问题 I need to compress files in [*.zip] format in .NET 1.1. I don't want to use SharpZip for compression as I got random errors - "Access Denied" - when running it in .NET 1.1. SharptZip will work properly only if I put the assembly on the GAC - which is not an option in my project. This is the problem. Check this: http://forums.asp.net/p/1139901/1839049.aspx#1839049 回答1: You can use a command-line tool for zip. For example 7-Zip. 回答2: You could grab the zlib dll and use .NET interop to call the

C. Loop compression + send (gzip) ZLIB

吃可爱长大的小学妹 提交于 2019-12-13 03:56:42
问题 I'm currently building an HTTP server in C. Please mind this piece of code : #define CHUNK 0x4000 z_stream strm; unsigned char out[CHUNK]; int ret; char buff[200]; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; int windowsBits = 15; int GZIP_ENCODING = 16; ret = deflateInit2(&strm, Z_BEST_SPEED, Z_DEFLATED, windowsBits | GZIP_ENCODING, 1, Z_DEFAULT_STRATEGY); fill(buff); //fill buff with infos do { strm.next_in = (z_const unsigned char *)buff; strm.avail_in = strlen(buff);

How to convert a byte array to string?

巧了我就是萌 提交于 2019-12-13 03:46:41
问题 I just finished creating a huffman compression algorithm . I converted my compressed text from a string to a byte array with bytearray(). Im attempting to decompress my huffman algorithm. My only concern though is that i cannot convert my byte array back into a string. Is there any built in function i could use to convert my byte array (with a variable) back into a string? If not is there a better method to convert my compressed string to something else? I attempted to use byte_array.decode()

Gzip not working

落爺英雄遲暮 提交于 2019-12-13 03:36:38
问题 I am trying to handle gzip. My sources: zlib,compression,https(article by Rob W) Server-Side: app.get('*', function (req, res, next) { if (req.headers['x-forwarded-proto'] != 'https') { res.setHeader('Content-Type', 'text/event-stream') res.setHeader('Cache-Control', 'no-cache') // send a ping approx every 2 seconds var timer = setInterval(function () { res.write('data: ping\n\n') // !!! this is the important part res.flush() }, 2000) res.on('close', function () { clearInterval(timer) }) res

Optimize an image once and avoid doing it again

拈花ヽ惹草 提交于 2019-12-13 02:49:18
问题 I have a large respository of images, mostly JPEG, which I'd like to optimize using a library like ImageMagick or a Linux CLI tool like jpegtran (as covered in JPG File Size Optimization - PHP, ImageMagick, & Google's Page Speed), but I don't want to have to track which ones have been optimized already and I don't want to re-optimize every one again later. Is there some sort of flag I could easily add to the file that would make it easy to detect and skip the optimization? Preferably one that

How Gzip in Tomcat works

空扰寡人 提交于 2019-12-13 02:18:06
问题 I am doing issues about script compression. Following is what I just found in stackoverflow: "If you are using it in a webpage, gzip is a configuration method in your web server. The file is gzipped by the server, sent to the browser. No manual action is needed. For Apache: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html. If you are delivering the code to developers, you could use the gzip command." Someone told me that if such script compression strategy is used, it will make you very