Skip to content

Instantly share code, notes, and snippets.

Andrew Zakordonets azakordonets

Block or report user

Report or block azakordonets

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@azakordonets
azakordonets / getPrivateProperty.php
Created Feb 11, 2014
Get private property from instance of the class
View getPrivateProperty.php
private function getProtectedProperty($class, $propertyName)
{
$reflectObj = new \ReflectionObject($class);
$extensions = $reflectObj->getProperty($propertyName);
$extensions->setAccessible(true);
return $extensions->getValue($class);
}
View setPrivateProperty.php
private function setProtectedProperty($class, $propertyName, $setValue)
{
$reflectObj = new \ReflectionObject($class);
$extensions = $reflectObj->getProperty($propertyName);
$extensions->setAccessible(true);
$extensions->setValue($class, $setValue);
}
View runProtectedMethod.php
protected function runProtectedFunction($class, $methodName, $args = null)
{
$reflectMethod = new \ReflectionMethod($class,$methodName);
$reflectMethod->setAccessible(true);
if ($args == null)
{
return $reflectMethod->invoke($class);
} else
{
return $reflectMethod->invokeArgs($class, $args);
@azakordonets
azakordonets / RandomInt.java
Created Mar 14, 2014
Generate random int number in Java
View RandomInt.java
/**
* Random generator in range
*
* @param minimum Number
* @param maximum Number
* @return randomNumber
*/
public int randomGenerator(int minimum, int maximum) {
Random rn = new Random();
int range = maximum - minimum + 1;
@azakordonets
azakordonets / IgnorePhpUnitTest.php
Created Apr 15, 2014
This call makes phpunit to mute specific test
View IgnorePhpUnitTest.php
$this->markTestSkipped('This test is scipped ');
@azakordonets
azakordonets / ProxySelector.java
Created Apr 18, 2014
This class allows you to get a hacky but working way of connecting with Java to SOCKS proxy, when standart ways are not working. Java has a problem with DNS resolving and therefore i had an issue with one of my project. When i was enabling proxy setting through System.Properties , i still was hitting production server, not the test server behind…
View ProxySelector.java
import java.net.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.io.IOException;
/**
* this class is needed for Java to connect to SOCKS proxy server
* Unfortunately Java cannot resolve remote DNS and therefore, when we set System.properties
* with our proxy server details, we hit incorrect server . This is because
* Java is connecting to Proxy, but DNS is resolving with system details and therefore goes to server directly.
@azakordonets
azakordonets / DbConnection.java
Created Apr 18, 2014
Class for DbConnection handiling
View DbConnection.java
package Base.db_connection;
import org.json.JSONObject;
import java.sql.*;
import static Base.TestPropertiesLoader.getDbConnectionDetails;
public class DbConnection {
public Connection con = null;
@azakordonets
azakordonets / yaml_to_json_convertor.py
Created Apr 30, 2014
Converty yaml to json on Python
View yaml_to_json_convertor.py
import yaml
import json
yml = "file_path"
data = yaml.load(open(yml,'r'))
json = json.dumps(data)
print(json)
@azakordonets
azakordonets / getJSONFromFile.java
Created May 6, 2014
This method allows you to read from file (where already stored data in json format) and save it into JSON object.
View getJSONFromFile.java
public static JSONObject getJSONFromFile(String path) throws JSONException, IOException, ParseException {
JSONParser parser = new JSONParser();
Object obj = parser.parse(new FileReader(path));
return new JSONObject(obj.toString());
}
@azakordonets
azakordonets / webDriverSnippets.java
Last active Aug 29, 2015
Set of handy commands and method to work with WebDriver
View webDriverSnippets.java
public void refreshPage(){
driver.navigate().refresh();
}
You can’t perform that action at this time.