This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ATTEMPTS_COUNTER=0 | |
URL=$1 | |
MAX_ATTEMPTS=${2:-10} | |
until $(curl --output /dev/null --silent --head --fail ${URL}); do | |
if [ ${ATTEMPTS_COUNTER} -eq ${MAX_ATTEMPTS} ];then | |
echo "Max attempts reached" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = require('webpage').create(); | |
page.open('http://www.google.com', function() { | |
setTimeout(function() { | |
page.render('google.png'); | |
phantom.exit(); | |
}, 200); | |
}); |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
2017/02/06 16:32:02 [WARN] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//array of integers | |
var t = [123, 5468, 215,4,6543] | |
//will be serialized using: | |
//t.join(",") | |
//to following string: | |
"123,5468,215,4,6543" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(","); |
NewerOlder