Skip to content

Instantly share code, notes, and snippets.

View azakordonets's full-sized avatar

Andrew Zakordonets azakordonets

View GitHub Profile
const split = (str, nmb) => {
return str.split('')
.reduce((arr, rec) => {
console.log(`Arr: ${arr} Rec : ${rec}`)
if (arr[arr.length - 1].length < nmb) {
arr[arr.length - 1] = [...arr[arr.length - 1], rec]
return arr
}
return [...arr, [rec]]
}, [[]])
# private token or personal token authentication
import gitlab
gl = gitlab.Gitlab('https://gitlab.com', private_token='{your_token}')
# make an API request to create the gl.user object. This is mandatory if you
# use the username/password authentication.
result = []
gl.auth()
# if you gonna have more then 500 api gateways, then you gonna need to wrap this into the loop and after first 500 you gonna need to pass position parameter to get_rest_apis method
import boto3
client = boto3.client('apigateway')
response = client.get_rest_apis(
limit=500
)
print(f"We have {len(response['items'])} api gateways to process")
for apigateway in response['items']:
print(f"Enabling {apigateway['name']} api gateway tracing")
@azakordonets
azakordonets / ghostImageAlignment.html
Created April 15, 2014 20:57
Some code for image alignment in ghost blog editor
<!--To center an image-->
<p align="center">
![alt]()
</p>
<!--To right align an image-->
<p align="right">
![alt]()
</p>
@azakordonets
azakordonets / simpleHttpServer.py
Created September 1, 2013 13:22
Python simple HTTP Server that get's two variables for launch - port and time delay( time after which server will return response) . If we do not specify this two values, then server starts on 8000 port with delay = 0
#!/usr/bin/env python
import SimpleHTTPServer, BaseHTTPServer, SocketServer, socket, time, sys
class ThreadedHTTPServer(SocketServer.ThreadingMixIn,
BaseHTTPServer.HTTPServer) :
"""
New features w/r to BaseHTTPServer.HTTPServer:
- serves multiple requests simultaneously
- catches socket.timeout and socket.error exceptions (raised from
@azakordonets
azakordonets / subsctring_in_pipe.sh
Created August 20, 2019 10:51
Substring string in the piped command from command line
echo "1234567890" | cut -b 1-6
@azakordonets
azakordonets / subsctring_in_pipe.sh
Created August 20, 2019 10:51
Substring string in the piped command from command line
echo "1234567890" | cut -b 1-6
@azakordonets
azakordonets / dummyXCUITest.swift
Created April 25, 2018 14:42
This is an example of how to use XCTContext.runActivity method in page object patter for XCUITest. This allows to get nice reports with Allure in the future.
class LoginPage {
func login(with userName: String, and password: String): SomeOtherPage {
return XCTContext.runActivity("Login as existing user") {
this.enter(userName: userName)
this.enter(password: password)
this.submit()
return new SomeOtherPage(app: this.app);
}
}
@azakordonets
azakordonets / Dockerfile
Created July 23, 2019 10:32
Standalone Pact running in alpine Docker image
FROM alpine:3.9
RUN apk --no-cache add ca-certificates wget bash \
&& wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \
&& wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-2.29-r0.apk \
&& apk add glibc-2.29-r0.apk
RUN wget https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.69.0/pact-1.69.0-linux-x86_64.tar.gz \
&& tar xzf pact-1.69.0-linux-x86_64.tar.gz \
&& rm -rf pact-1.69.0-linux-x86_64.tar.gz
@azakordonets
azakordonets / ResultSetConvertor.java
Last active November 25, 2018 19:19
This class is designed to convert ResultSet data taken as a result of Db query into JSON. Also additional coverter methods are available
import org.json.JSONArray;
import org.json.JSONObject;
import java.sql.ResultSet;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
/**
* Utility for converting ResultSets into some Output formats