Skip to content

Instantly share code, notes, and snippets.

View artemnikitin's full-sized avatar
🍵

Artem Nikitin artemnikitin

🍵
View GitHub Profile
@artemnikitin
artemnikitin / aws-devicefarm-upload.go
Last active February 24, 2016 14:40
Example of file upload to AWS Device Farm
func uploadFile(url string) int {
file, err := os.Open(*appPath)
if err != nil {
log.Fatal("Failed to get file for upload because of: ", err.Error())
}
client := &http.Client{}
request, err := http.NewRequest("PUT", url, file)
if err != nil {
log.Fatal("Failed to create HTTP request because of: ", err.Error())
}
@artemnikitin
artemnikitin / gist:25ef5f9e5a14bb7b68a1
Created August 13, 2014 11:44
Binary search implementation with Python
#!/usr/bin/env python
import sys
sys.setrecursionlimit(20000)
data = [1, 4, 5, 22, 34, 55]
def search(start, end, value):
pivot = start + (end - start) / 2
if data[pivot] == value:
@artemnikitin
artemnikitin / gist:4f2b15fc90479777ba87
Last active August 29, 2015 14:05
Issue bill via Qiwi REST API
#!/usr/bin/env python
import httplib
import argparse
import datetime
import random
import string
def tomorrow():
@artemnikitin
artemnikitin / gist:ee3f91516fb05468d226
Created July 7, 2014 12:18
Generate Hmac SHA-1 signature via Python 2.7
#!/usr/bin/env python
import base64
import hmac
import hashlib
string = raw_input("Enter string to encode: ")
key = raw_input("Enter key: ")
hash = hmac.new(key, string, hashlib.sha1).digest()
@artemnikitin
artemnikitin / gist:d45a5746d68965545d03
Last active September 26, 2015 23:25
Generate Hmac SHA-1 signature via Java
import java.util.Base64;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public class Hmac {
private static String data = "2.00|5101603|RUB|bill|test-checking-one-way-response-from-processing|0|белый тест|paid|tel:+79167421378";
private static String key = "123456789";
public static void main(String[] args){
@artemnikitin
artemnikitin / gist:8952347
Last active August 29, 2015 13:56
Spock sample for Data Driven Testing
@Unroll("For currency #ccy and amount = #sum response will be #response_code - #response_text")
def "Check max and min sum for different currencies"() {
given: "Body for request with sum and currency"
String content = TestProperties.getRestBody(ccy, sum)
when: "Send request"
Response result = Request.send(RequestType.PUT, url, content);
then: "Check response"
result.status.contains(http)