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 / regex
Created June 27, 2014 23:20
Replace using group
Find: ref=\"tns:(.*)\"
Replace: name=\"\1\" type=\"tns:\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 / 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 / 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 / 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);