Skip to content

Instantly share code, notes, and snippets.

View humanium's full-sized avatar

Ilya Mishchiy humanium

  • Nizhniy Novgorod, Russia
View GitHub Profile
@humanium
humanium / HTTPService.java
Created March 23, 2016 09:10
Simple HTTP(S) client based on RestTemplate
package service;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.Setter;
import org.springframework.core.NestedRuntimeException;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.*;
import org.springframework.http.client.ClientHttpResponse;
@humanium
humanium / FactoryTestNameChanged.java
Created January 28, 2016 08:16
TestNG test changing method name in report
package com.experimental.b;
import org.testng.ITest;
import org.testng.annotations.*;
import org.testng.xml.XmlTest;
@Listeners({SomeTestListener.class})
public class SomeFactoryTest implements ITest{
private int id;
private String name = "unknown";
@humanium
humanium / trail.py
Created October 28, 2015 09:04
Custom TestRail API wrapper
#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib2
import json
import base64
class TestRailAPIError(Exception):
@humanium
humanium / paths.py
Created April 7, 2015 11:52
Get all files paths in direstory recursively
def get_all_file_paths(root_path):
paths = []
for item in os.listdir(root_path):
full_path = os.path.join(root_path, item)
if os.path.isfile(full_path):
paths.append(full_path)
else:
paths.extend(get_all_file_paths(full_path))
return paths
@humanium
humanium / dateutil.py
Last active June 30, 2023 19:57
Date convertation utilities
import datetime
import time
def timestamp_from_date(year, month, day, hour, minutes, seconds):
t = datetime.datetime(year, month, day, hour, minutes, seconds).timetuple()
return time.mktime(t)
def date_from_utc_timestamp(timestamp):
# about date string formatting: http://strftime.org/
return datetime.datetime.utcfromtimestamp(timestamp).strftime('%b %d, %Y %I:%M %p') # 'Apr 18, 2015 06:04 AM'
@humanium
humanium / testlink_cases_stats.py
Created July 13, 2014 22:13
testlink 1.9.4: testcases statistics (execution count, projects etc)
#!/usr/bin/env python2
# coding: utf-8
import os,socket,threading,time
#import traceback
allow_delete = False
local_ip = socket.gethostbyname(socket.gethostname())
local_port = 8888
currdir=os.path.abspath('.')
@humanium
humanium / morphs.py
Last active August 29, 2015 14:01
dict to object (old version for history)
"""Module's functions allow convert Python dictionary to object.
"""
def dict2obj(pydict):
"""Converts dictionaries into objects that allow names
to be accessed as attributes as well as items.
"""
class container(object):
@humanium
humanium / oui_parser.py
Created September 25, 2013 15:20
oui.txt parser with csv output
# -*- coding: utf-8 -*-
import csv
fp = open('oui.txt', 'rb')
entries = [{'oui_hex': 'oui_hex',
'oui_base16': 'oui_base16',
'lower_mac_bound': 'lower_mac_bound',
'upper_mac_bound': 'upper_mac_bound',