Skip to content

Instantly share code, notes, and snippets.

View xCASx's full-sized avatar
🚀
Work it Harder, Make it Better, Do it Faster, Makes Us Stronger

Maxim Kolesnikov xCASx

🚀
Work it Harder, Make it Better, Do it Faster, Makes Us Stronger
View GitHub Profile
@xCASx
xCASx / ConvertCollectionToArray.java
Last active December 19, 2015 05:39
Convert a collection to the array.
/**
* Convert a Collection to the array of {@link Class<T[]>} type
* @param type class of outgoing array
* @param collection collection which should be converted
* @param <T> base type for outgoing array
* @return outgoing array {@link Class<T[]>}
*/
private static <T> T[] convertCollectionToArray(Class<T[]> type, Collection collection) {
T[] t = type.cast(Array.newInstance(type.getComponentType(), collection.size()));
return (T[]) collection.toArray(t);
@xCASx
xCASx / get-icons-for-site-list.py
Created April 8, 2014 19:04
Gets url list from text file and request the pages, finds favicons and save them into current directory
'''
This programm gets url list from text file and request the pages, finds favicons and save them into current directory
'''
import urllib
from urllib.request import urlopen
from urllib.request import urlretrieve
from bs4 import BeautifulSoup
'''had to add this windows specific block to handle this bug in urllib2:
http://bugs.python.org/issue11220
@xCASx
xCASx / Excel duplicate in order rows
Last active August 29, 2015 14:02
Excel duplicate in order rows
// Next formula makes 12 copies in C for each row in A in a determined order
=ИНДЕКС(A:A;ОКРВВЕРХ(ЧСТРОК(C$1:C1)/12;1))
@xCASx
xCASx / postrgresql
Created June 4, 2014 17:44
Useful Postgres queries
-- export to csv
Copy (Select * From tablename) To 'C:\\dev\01.csv' With CSV;
-- import from csv
COPY tablename FROM 'C:\data\01.csv' DELIMITER ',' CSV HEADER;
-- Create a Range From 1 to 10
SELECT * FROM GENERATE_SERIES(1, 10)
@xCASx
xCASx / regex
Created June 27, 2014 23:20
Replace using group
Find: ref=\"tns:(.*)\"
Replace: name=\"\1\" type=\"tns:\1\"
@xCASx
xCASx / Git ignore SSL check commands
Last active August 29, 2015 14:05
Git ignore SSL check commands
# Turn off global property
git config http.sslVerify false
# Turn off ssl check for current operation
git -c http.sslVerify=false clone https://domain.com/path/to/git
@xCASx
xCASx / Maven install DB driver to local repo
Created August 20, 2014 18:11
Maven install DB driver to local repo
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4 -Dpackaging=jar -Dfile=ojdbc6.jar -DgeneratePom=true
@xCASx
xCASx / Oracle JDK for Ubuntu
Created November 4, 2014 12:15
Install Oracle JDK on Ubuntu
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
# If you have multiple java installed on your system, you can select with : sudo update-alternatives --config java
@xCASx
xCASx / MockitoTemplate
Created November 24, 2014 15:37
Mockito fixture template
/**
* Fixture for test.
*/
private static final class Fixture {
@Mock
CustomManager customManager;
@Mock
CustomRepository repository;
@xCASx
xCASx / git_pull_rebase
Created October 27, 2015 18:41
Commands for git pull --rebase strategy by default
# Force all new branches to automatically use rebase
git config --global branch.autosetuprebase always
# This will tell git to always pull with rebase.
git config --global --bool pull.rebase true
# After these two commands ~/.gitconfig will look like this:
[branch]
autosetuprebase = always
[pull]