Skip to content

Instantly share code, notes, and snippets.

Avatar

Volodymyr Mykhailyk volodymyr-mykhailyk

View GitHub Profile
View phantom-test.js
var page = require('webpage').create();
page.open('http://www.google.com', function() {
setTimeout(function() {
page.render('google.png');
phantom.exit();
}, 200);
});
@volodymyr-mykhailyk
volodymyr-mykhailyk / crash.log
Created Feb 6, 2017
Terraform crash on s3 bucket compare
View crash.log
This file has been truncated, but you can view the full file.
2017/02/06 16:32:01 [INFO] Terraform version: 0.8.5
2017/02/06 16:32:01 [INFO] CLI args: []string{"/usr/local/Cellar/terraform/0.8.5/bin/terraform", "plan", "-refresh=false"}
2017/02/06 16:32:01 [DEBUG] Detected home directory from env var: /Users/vmykhailyk
2017/02/06 16:32:01 [DEBUG] Detected home directory from env var: /Users/vmykhailyk
2017/02/06 16:32:01 [DEBUG] Attempting to open CLI config file: /Users/vmykhailyk/.terraformrc
2017/02/06 16:32:01 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2017/02/06 16:32:01 [DEBUG] Detected home directory from env var: /Users/vmykhailyk
2017/02/06 16:32:01 [TRACE] Preserving existing state lineage "d146a253-a5f9-452e-a52d-b97665798bd3"
2017/02/06 16:32:01 [TRACE] Preserving existing state lineage "d146a253-a5f9-452e-a52d-b97665798bd3"
View [MCM] gist.rb
feature 'Concurrent getting from bucket' do
before do
@hunters = 3.times.map { create(:hunter) }
steal_bucket.update_attribute(:cookies, 10)
end
it 'should maintain total cookies amount' do
several_processes(10.times.map) do
login_hunter(@hunters.sample)
visit hunting_path
@volodymyr-mykhailyk
volodymyr-mykhailyk / gist:2923864
Created Jun 13, 2012
JV Deflate decompression procedures
View gist:2923864
package com.vmykhailyk.compression.deflate;
import org.apache.commons.codec.binary.Base64;
import java.io.ByteArrayOutputStream;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
public class DeflateDecompressor {
private Inflater decompressor;
@volodymyr-mykhailyk
volodymyr-mykhailyk / gist:2923826
Created Jun 13, 2012
JS Deflate compression procedures
View gist:2923826
var originalString = "some data that should be compressed";
//convert string to bytes array
var originalBytes = stringToByteArray(originalString);
//generate header as byte array
var headerBytes = String.fromCharCode(120, 218);
//compress data
var compressedBytes = compress(originalBytes);
//calculate checksum
var checksumBytes = adler32(originalBytes);
//create final byte array
@volodymyr-mykhailyk
volodymyr-mykhailyk / gist:2923823
Created Jun 13, 2012
JS Adler32 checksum implementation
View gist:2923823
function adler32(data) {
var MOD_ADLER = 65521;
var a = 1, b = 0;
var index;
// Process each byte of the data in order
for (index = 0; index < data.length; ++index) {
a = (a + data.charCodeAt(index)) % MOD_ADLER;
b = (b + a) % MOD_ADLER;
}
@volodymyr-mykhailyk
volodymyr-mykhailyk / gist:2923737
Created Jun 13, 2012
JV LZW decompression code
View gist:2923737
package com.vmykhailyk.compression.lzw;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class LZWModuleDecompression {
@volodymyr-mykhailyk
volodymyr-mykhailyk / gist:2923242
Created Jun 13, 2012
JS Integers array serialization example
View gist:2923242
//array of integers
var t = [123, 5468, 215,4,6543]
//will be serialized using:
//t.join(",")
//to following string:
"123,5468,215,4,6543"
@volodymyr-mykhailyk
volodymyr-mykhailyk / gist:2923232
Created Jun 13, 2012
JS LZW Compression procedures
View gist:2923232
var originalString = "some data that should be compressed";
//convert string to bytes array
var originalBytes = stringToByteArray(originalString).join("");
//compress data
var compressedData = compress(originalBytes);
//serialize the data
var serializedData = compressedData.join(",");
@volodymyr-mykhailyk
volodymyr-mykhailyk / gist:2923227
Created Jun 13, 2012
JS Unicode String to Byte Array
View gist:2923227
function stringToByteArray(str) {
var b = [], i, unicode;
for(i = 0; i < str.length; i++) {
unicode = str.charCodeAt(i);
// 0x00000000 - 0x0000007f -> 0xxxxxxx
if (unicode <= 0x7f) {
b.push(String.fromCharCode(unicode));
// 0x00000080 - 0x000007ff -> 110xxxxx 10xxxxxx
} else if (unicode <= 0x7ff) {
b.push(String.fromCharCode((unicode >> 6) | 0xc0));