Skip to content

Instantly share code, notes, and snippets.


Paweł Hajduk phajduk

View GitHub Profile

Keybase proof

I hereby claim:

  • I am phajduk on github.
  • I am phajduk ( on keybase.
  • I have a public key whose fingerprint is 98FF C974 7825 E640 9EA9 2AA1 7571 470A C2F4 89CC

To claim this, I am signing this object:

public class UrlHelper {
public static Map<String, String> splitQuery(String query) {
Map<String, String> queryPairs = new LinkedHashMap<>();
String[] pairs = query.split("&");
for(String pair : pairs) {
int idx = pair.indexOf("=");
try {
queryPairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
} catch(UnsupportedEncodingException e) {
Timber.e(e, "Problem during parsing query args");
phajduk / gist:2e28254c6e1ecad37785
Created Jun 4, 2014
Getting mime type from file
View gist:2e28254c6e1ecad37785
Uri path = Uri.fromFile(file);
MimeTypeMap typeMap = MimeTypeMap.getSingleton();
String extension = MimeTypeMap.getFileExtensionFromUrl(path.toString()).toLowerCase();
if (extension.contains(".")) {
extension = extension.substring(extension.lastIndexOf("."));
String mimeType= typeMap.getMimeTypeFromExtension(extension);