Skip to content

Instantly share code, notes, and snippets.

View azakordonets's full-sized avatar

Andrew Zakordonets azakordonets

View GitHub Profile
@azakordonets
azakordonets / ArrayMaxMin.js
Created December 28, 2015 20:49
Get Max or Min from Javascript array
function getArrayMaxValue(arr) {
return Math.max.apply(null, arr);
}
function getArrayMinValue(arr) {
return Math.min.apply(null, arr);
}
@azakordonets
azakordonets / RemoveSpecialCharactersFromString.js
Last active December 28, 2015 20:31
Removes spaces and special symbols from string in javascript
function removeSpecialCharacters(str) {
return str.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/\s]/gi, "");
}
@azakordonets
azakordonets / count_symbols_in_docx_file.sh
Created November 2, 2015 13:18
This script allows you to count number of symbols in batch of docx files excluding white spaces and new line symbols. Just place this file into the folder with docx file and run in terminal 'sh count_symbols_in_docx_file.sh'
#!/bin/bash
for file in *.docx;do
number=$(unzip -p $file word/document.xml | sed -e 's/<[^>]\{1,\}>//g; s/[^[:print:]]\{1,\}//g'|tr -d ' '|tr -d '\n' |tr -d '\t' | wc -m | tr -d ' ' | tr -d '\t')
echo "File -> $file , symbols count: $number"
done
import re
# Passwords will contain at least (1) upper case letter
# Passwords will contain at least (1) lower case letter
# Passwords will contain at least (1) number or special character
# Passwords will contain at least (8) characters in length
protected boolean fieldWasChanged(String fieldName, IssueEvent issueEvent, String fieldValue) throws GenericEntityException {
boolean result = false;
List<GenericValue> changeItemList = issueEvent.getChangeLog().getRelated("ChildChangeItem");
Iterator<GenericValue> changeItemListIterator = changeItemList.iterator();
while (changeItemListIterator.hasNext()) {
GenericValue changeItem = (GenericValue) changeItemListIterator.next();
String currentFieldName = changeItem.get("field").toString();
if (currentFieldName.equals(fieldName)) // Name of custom field.
@azakordonets
azakordonets / getRandomEnumElement.java
Created July 2, 2015 10:15
This allows you easily to get random element from your enum
public enum MimeType {
APPLICATION,
AUDIO,
IMAGE,
MESSAGE,
MODEL,
MULTIPART,
TEXT,
VIDEO;
@azakordonets
azakordonets / teamCityFailedTestSuites.py
Last active August 29, 2015 14:23
I've created this small script to get a list of failed test suites from Team City. We are using there Allure reports and when i provide username, password and url to "All artifacts" of the job, i can get a sorted list of failed test suites in the console. Handy when you need to re-run only failed test suites
#!/usr/bin/env python
import urllib
import os.path
import sys
import json
import shutil
import getopt
import argparse
import re
@azakordonets
azakordonets / removeFilesExceptPattern.sh
Created June 23, 2015 07:30
Remove files except the one that matches pattern
find . -type f ! -name '*-testcase.json' -delete
@azakordonets
azakordonets / ResultSetToJson_XMLConverter.java
Created June 5, 2015 05:55
This class helps you easily to convert ResultSet(result of DB querry) into JSON or XML
import org.json.JSONArray;
import org.json.JSONObject;
import java.sql.ResultSet;
/**
* Utility for converting ResultSets into some Output formats
* @author marlonlom
*/
public class Convertor {
@azakordonets
azakordonets / hideiOSKeyboard.swift
Created May 28, 2015 13:44
This two methods should be included into the file, so it would make keyboard disappear on Enter button push, or tap outside the keyboard
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
self.view.endEditing(true)
}
func textFieldShouldReturn(input: UITextField) -> Bool {
input.resignFirstResponder()
return true
}